3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Invoker { public function __invoke() { echo 'hello!'; } } class Obj { public static function method() { } } function doClosure(Closure $closure) { echo 'didClosure...'; $closure(); } function doCallable(callable $cb) { echo 'didCallable...'; $cb(); } doCallable(function () {}); // works doCallable(new Invoker()); // works doCallable(['Obj', 'method']); // works doClosure(function () {}); // works doClosure(new Invoker()); // does not work doClosure(['Obj', 'method']); // does not work
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1sn8
function name:  (null)
number of ops:  25
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   INIT_FCALL                                               'docallable'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Ff1sn8%3A29%240'
          2        SEND_VAL                                                 ~0
          3        DO_FCALL                                      0          
   30     4        INIT_FCALL                                               'docallable'
          5        NEW                                              $2      'Invoker'
          6        DO_FCALL                                      0          
          7        SEND_VAR                                                 $2
          8        DO_FCALL                                      0          
   31     9        INIT_FCALL                                               'docallable'
         10        SEND_VAL                                                 <array>
         11        DO_FCALL                                      0          
   34    12        INIT_FCALL                                               'doclosure'
         13        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2Ff1sn8%3A34%241'
         14        SEND_VAL                                                 ~6
         15        DO_FCALL                                      0          
   35    16        INIT_FCALL                                               'doclosure'
         17        NEW                                              $8      'Invoker'
         18        DO_FCALL                                      0          
         19        SEND_VAR                                                 $8
         20        DO_FCALL                                      0          
   36    21        INIT_FCALL                                               'doclosure'
         22        SEND_VAL                                                 <array>
         23        DO_FCALL                                      0          
         24      > RETURN                                                   1

Function doclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1sn8
function name:  doClosure
number of ops:  5
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
   19     1        ECHO                                                     'didClosure...'
   20     2        INIT_DYNAMIC_CALL                                        !0
          3        DO_FCALL                                      0          
   21     4      > RETURN                                                   null

End of function doclosure

Function docallable:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1sn8
function name:  doCallable
number of ops:  5
compiled vars:  !0 = $cb
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   RECV                                             !0      
   25     1        ECHO                                                     'didCallable...'
   26     2        INIT_DYNAMIC_CALL                                        !0
          3        DO_FCALL                                      0          
   27     4      > RETURN                                                   null

End of function docallable

Function %00%7Bclosure%7D%2Fin%2Ff1sn8%3A29%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1sn8
function name:  {closure}
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Ff1sn8%3A29%240

Function %00%7Bclosure%7D%2Fin%2Ff1sn8%3A34%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1sn8
function name:  {closure}
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2Ff1sn8%3A34%241

Class Invoker:
Function __invoke:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1sn8
function name:  __invoke
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   ECHO                                                     'hello%21'
    7     1      > RETURN                                                   null

End of function __invoke

End of class Invoker.

Class Obj:
Function method:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/f1sn8
function name:  method
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E > > RETURN                                                   null

End of function method

End of class Obj.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.29 ms | 1407 KiB | 19 Q