3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Foo { private $name = 'john'; function say() { echo $this->name; } } class Foo2 extends Foo { private $name = 'lisa'; } Closure::fromCallable([new Foo2(), 'say'])->call(new Foo()); // good Closure::fromCallable([new Foo(), 'say'])->call(new Foo2()); // bad
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jM1rt
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   19     0  E >   INIT_STATIC_METHOD_CALL                                      'Closure', 'fromCallable'
          1        NEW                                                  $0      'Foo2'
          2        DO_FCALL                                          0          
          3        INIT_ARRAY                                           ~2      $0
          4        ADD_ARRAY_ELEMENT                                    ~2      'say'
          5        SEND_VAL                                                     ~2
          6        DO_FCALL                                          0  $3      
          7        INIT_METHOD_CALL                                             $3, 'call'
          8        NEW                                                  $4      'Foo'
          9        DO_FCALL                                          0          
         10        SEND_VAR_NO_REF_EX                                           $4
         11        DO_FCALL                                          0          
   20    12        INIT_STATIC_METHOD_CALL                                      'Closure', 'fromCallable'
         13        NEW                                                  $7      'Foo'
         14        DO_FCALL                                          0          
         15        INIT_ARRAY                                           ~9      $7
         16        ADD_ARRAY_ELEMENT                                    ~9      'say'
         17        SEND_VAL                                                     ~9
         18        DO_FCALL                                          0  $10     
         19        INIT_METHOD_CALL                                             $10, 'call'
         20        NEW                                                  $11     'Foo2'
         21        DO_FCALL                                          0          
         22        SEND_VAR_NO_REF_EX                                           $11
         23        DO_FCALL                                          0          
         24      > RETURN                                                       1

Class Foo:
Function say:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jM1rt
function name:  say
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                          ~0      'name'
          1        ECHO                                                         ~0
   10     2      > RETURN                                                       null

End of function say

End of class Foo.

Class Foo2:
Function say:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jM1rt
function name:  say
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                          ~0      'name'
          1        ECHO                                                         ~0
   10     2      > RETURN                                                       null

End of function say

End of class Foo2.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
153.56 ms | 1591 KiB | 13 Q