3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $closure; public function __construct(callable $closure) { $this->closure = $closure; } public function run1(...$args) { ($this->closure)(...$args); } public function run2(...$args) { $this->closure(...$args); } } $foo = new Foo(function($var){ var_dump($var); }); $foo->run1('bar'); $foo->run2('bar'); $foo->run3('bar');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D3YEa
function name:  (null)
number of ops:  15
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $1      'Foo'
          1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FD3YEa%3A21%240'
   23     2        SEND_VAL_EX                                              ~2
          3        DO_FCALL                                      0          
   21     4        ASSIGN                                                   !0, $1
   25     5        INIT_METHOD_CALL                                         !0, 'run1'
          6        SEND_VAL_EX                                              'bar'
          7        DO_FCALL                                      0          
   26     8        INIT_METHOD_CALL                                         !0, 'run2'
          9        SEND_VAL_EX                                              'bar'
         10        DO_FCALL                                      0          
   27    11        INIT_METHOD_CALL                                         !0, 'run3'
         12        SEND_VAL_EX                                              'bar'
         13        DO_FCALL                                      0          
         14      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FD3YEa%3A21%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D3YEa
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $var
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   22     1        INIT_FCALL                                               'var_dump'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                                 
   23     4      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FD3YEa%3A21%240

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D3YEa
function name:  __construct
number of ops:  4
compiled vars:  !0 = $closure
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        ASSIGN_OBJ                                               'closure'
          2        OP_DATA                                                  !0
    8     3      > RETURN                                                   null

End of function __construct

Function run1:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D3YEa
function name:  run1
number of ops:  7
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV_VARIADIC                                    !0      
   12     1        FETCH_OBJ_R                                      ~1      'closure'
          2        INIT_DYNAMIC_CALL                                        ~1
          3        SEND_UNPACK                                              !0
          4        CHECK_UNDEF_ARGS                                         
          5        DO_FCALL                                      1          
   13     6      > RETURN                                                   null

End of function run1

Function run2:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/D3YEa
function name:  run2
number of ops:  6
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV_VARIADIC                                    !0      
   17     1        INIT_METHOD_CALL                                         'closure'
          2        SEND_UNPACK                                              !0
          3        CHECK_UNDEF_ARGS                                         
          4        DO_FCALL                                      1          
   18     5      > RETURN                                                   null

End of function run2

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.75 ms | 1400 KiB | 15 Q