3v4l.org

run code in 300+ PHP versions simultaneously
<?php $alias_list = []; $alias_autoloader = function($class_name) use (&$alias_list) { if (isset($alias_list[strtolower($class_name)])) { var_dump($class_name); class_alias($class_name, $alias_list[strtolower($class_name)]); return true; } }; $alias = function($from, $to) use (&$alias_list) { $alias_list[strtolower($to)] = $from; }; spl_autoload_register($alias_autoloader); class Foo { function test() { return get_class_name($this); } } class BarCollision extends Foo { } $alias('Foo', 'Bar'); $alias('Foo', 'BarCollision'); $b = new Bar; $c = new BarCollision; var_dump($b->test(), $c->test());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BJRPm
function name:  (null)
number of ops:  33
compiled vars:  !0 = $alias_list, !1 = $alias_autoloader, !2 = $alias, !3 = $b, !4 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBJRPm%3A5%240'
          2        BIND_LEXICAL                                             ~6, !0
          3        ASSIGN                                                   !1, ~6
   12     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBJRPm%3A12%241'
          5        BIND_LEXICAL                                             ~8, !0
          6        ASSIGN                                                   !2, ~8
   15     7        INIT_FCALL                                               'spl_autoload_register'
          8        SEND_VAR                                                 !1
          9        DO_ICALL                                                 
   32    10        INIT_DYNAMIC_CALL                                        !2
         11        SEND_VAL_EX                                              'Foo'
         12        SEND_VAL_EX                                              'Bar'
         13        DO_FCALL                                      0          
   33    14        INIT_DYNAMIC_CALL                                        !2
         15        SEND_VAL_EX                                              'Foo'
         16        SEND_VAL_EX                                              'BarCollision'
         17        DO_FCALL                                      0          
   36    18        NEW                                              $13     'Bar'
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !3, $13
   37    21        NEW                                              $16     'BarCollision'
         22        DO_FCALL                                      0          
         23        ASSIGN                                                   !4, $16
   39    24        INIT_FCALL                                               'var_dump'
         25        INIT_METHOD_CALL                                         !3, 'test'
         26        DO_FCALL                                      0  $19     
         27        SEND_VAR                                                 $19
         28        INIT_METHOD_CALL                                         !4, 'test'
         29        DO_FCALL                                      0  $20     
         30        SEND_VAR                                                 $20
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FBJRPm%3A5%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 19
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BJRPm
function name:  {closure}
number of ops:  20
compiled vars:  !0 = $class_name, !1 = $alias_list
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
    6     2        INIT_FCALL                                               'strtolower'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $2      
          5        ISSET_ISEMPTY_DIM_OBJ                         0          !1, $2
          6      > JMPZ                                                     ~3, ->19
    7     7    >   INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
    8    10        INIT_FCALL                                               'class_alias'
         11        SEND_VAR                                                 !0
         12        INIT_FCALL                                               'strtolower'
         13        SEND_VAR                                                 !0
         14        DO_ICALL                                         $5      
         15        FETCH_DIM_R                                      ~6      !1, $5
         16        SEND_VAL                                                 ~6
         17        DO_ICALL                                                 
    9    18      > RETURN                                                   <true>
   11    19    > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FBJRPm%3A5%240

Function %00%7Bclosure%7D%2Fin%2FBJRPm%3A12%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BJRPm
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $from, !1 = $to, !2 = $alias_list
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        BIND_STATIC                                              !2
   13     3        INIT_FCALL                                               'strtolower'
          4        SEND_VAR                                                 !1
          5        DO_ICALL                                         $3      
          6        ASSIGN_DIM                                               !2, $3
          7        OP_DATA                                                  !0
   14     8      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FBJRPm%3A12%241

Class Foo:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BJRPm
function name:  test
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL_BY_NAME                                       'get_class_name'
          1        FETCH_THIS                                       $0      
          2        SEND_VAR_EX                                              $0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   23     5*     > RETURN                                                   null

End of function test

End of class Foo.

Class BarCollision:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BJRPm
function name:  test
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL_BY_NAME                                       'get_class_name'
          1        FETCH_THIS                                       $0      
          2        SEND_VAR_EX                                              $0
          3        DO_FCALL                                      0  $1      
          4      > RETURN                                                   $1
   23     5*     > RETURN                                                   null

End of function test

End of class BarCollision.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
278.99 ms | 1404 KiB | 22 Q