3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public function callme(callable $callback) { $callback(); } public function hi() { echo 'A->hi()' . PHP_EOL; } public static function hiStatic() { echo 'A::hiStatic()' . PHP_EOL; } } class B extends A { public function callme(callable $callback) { call_user_func($callback); } public function hi() { echo 'B->hi()' . PHP_EOL; } public static function hiStatic() { echo 'B::hiStatic()' . PHP_EOL; } } $a = new A(); $b = new B(); $a->callme(array($a, 'hi')); echo "####################\n"; $a->callme(array('A', 'hiStatic')); //$a->callme('A::hiStatic'); $a->callme(array('self', 'hiStatic')); //$a->callme('self::hiStatic'); $a->callme(array('static', 'hiStatic')); $a->callme('static::hiStatic'); echo "####################\n"; $b->callme(array('B', 'hiStatic')); $b->callme(array('self', 'hiStatic')); $b->callme(array('static', 'hiStatic')); echo "####################\n"; $b->callme('B::hiStatic'); $b->callme('self::hiStatic'); $b->callme('static::hiStatic'); echo "####################\n"; $b->callme('parent::hi'); $b->callme('parent::hiStatic');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iq7m7
function name:  (null)
number of ops:  52
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $2      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   22     3        NEW                                              $5      'B'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   24     6        INIT_METHOD_CALL                                         !0, 'callme'
          7        INIT_ARRAY                                       ~8      !0
          8        ADD_ARRAY_ELEMENT                                ~8      'hi'
          9        SEND_VAL_EX                                              ~8
         10        DO_FCALL                                      0          
   26    11        ECHO                                                     '%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%0A'
   27    12        INIT_METHOD_CALL                                         !0, 'callme'
         13        SEND_VAL_EX                                              <array>
         14        DO_FCALL                                      0          
   29    15        INIT_METHOD_CALL                                         !0, 'callme'
         16        SEND_VAL_EX                                              <array>
         17        DO_FCALL                                      0          
   31    18        INIT_METHOD_CALL                                         !0, 'callme'
         19        SEND_VAL_EX                                              <array>
         20        DO_FCALL                                      0          
   32    21        INIT_METHOD_CALL                                         !0, 'callme'
         22        SEND_VAL_EX                                              'static%3A%3AhiStatic'
         23        DO_FCALL                                      0          
   34    24        ECHO                                                     '%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%0A'
   35    25        INIT_METHOD_CALL                                         !1, 'callme'
         26        SEND_VAL_EX                                              <array>
         27        DO_FCALL                                      0          
   36    28        INIT_METHOD_CALL                                         !1, 'callme'
         29        SEND_VAL_EX                                              <array>
         30        DO_FCALL                                      0          
   37    31        INIT_METHOD_CALL                                         !1, 'callme'
         32        SEND_VAL_EX                                              <array>
         33        DO_FCALL                                      0          
   39    34        ECHO                                                     '%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%0A'
   40    35        INIT_METHOD_CALL                                         !1, 'callme'
         36        SEND_VAL_EX                                              'B%3A%3AhiStatic'
         37        DO_FCALL                                      0          
   41    38        INIT_METHOD_CALL                                         !1, 'callme'
         39        SEND_VAL_EX                                              'self%3A%3AhiStatic'
         40        DO_FCALL                                      0          
   42    41        INIT_METHOD_CALL                                         !1, 'callme'
         42        SEND_VAL_EX                                              'static%3A%3AhiStatic'
         43        DO_FCALL                                      0          
   44    44        ECHO                                                     '%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%23%0A'
   45    45        INIT_METHOD_CALL                                         !1, 'callme'
         46        SEND_VAL_EX                                              'parent%3A%3Ahi'
         47        DO_FCALL                                      0          
   46    48        INIT_METHOD_CALL                                         !1, 'callme'
         49        SEND_VAL_EX                                              'parent%3A%3AhiStatic'
         50        DO_FCALL                                      0          
         51      > RETURN                                                   1

Class A:
Function callme:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iq7m7
function name:  callme
number of ops:  4
compiled vars:  !0 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    5     1        INIT_DYNAMIC_CALL                                        !0
          2        DO_FCALL                                      0          
    6     3      > RETURN                                                   null

End of function callme

Function hi:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iq7m7
function name:  hi
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   ECHO                                                     'A-%3Ehi%28%29%0A'
          1      > RETURN                                                   null

End of function hi

Function histatic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iq7m7
function name:  hiStatic
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   ECHO                                                     'A%3A%3AhiStatic%28%29%0A'
          1      > RETURN                                                   null

End of function histatic

End of class A.

Class B:
Function callme:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iq7m7
function name:  callme
number of ops:  4
compiled vars:  !0 = $callback
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        INIT_USER_CALL                                0          'call_user_func', !0
          2        DO_FCALL                                      0          
   15     3      > RETURN                                                   null

End of function callme

Function hi:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iq7m7
function name:  hi
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ECHO                                                     'B-%3Ehi%28%29%0A'
          1      > RETURN                                                   null

End of function hi

Function histatic:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iq7m7
function name:  hiStatic
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ECHO                                                     'B%3A%3AhiStatic%28%29%0A'
          1      > RETURN                                                   null

End of function histatic

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.59 ms | 1403 KiB | 13 Q