3v4l.org

run code in 500+ PHP versions simultaneously
<?php class MyClass { protected Closure $modifier; public function __construct(callable $modifier) { $this->modifier = Closure::fromCallable($modifier); } public function runClosure() { var_dump(($this->modifier)()); } } class SomeOtherClass { public static function func() { return ['a' => 'b']; } } $test = new MyClass(SomeOtherClass::func(...)); $test->runClosure();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nMmvq
function name:  (null)
number of ops:  9
compiled vars:  !0 = $test
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   25     0  E >   NEW                                                  $1      'MyClass'
          1        INIT_STATIC_METHOD_CALL                                      'SomeOtherClass', 'func'
          2        CALLABLE_CONVERT                                     ~2      
          3        SEND_VAL_EX                                                  ~2
          4        DO_FCALL                                          0          
          5        ASSIGN                                                       !0, $1
   26     6        INIT_METHOD_CALL                                             !0, 'runClosure'
          7        DO_FCALL                                          0          
          8      > RETURN                                                       1

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

End of function __construct

Function runclosure:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nMmvq
function name:  runClosure
number of ops:  7
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                                   'var_dump'
          1        FETCH_OBJ_R                                          ~0      'modifier'
          2        INIT_DYNAMIC_CALL                                            ~0
          3        DO_FCALL                                          0  $1      
          4        SEND_VAR                                                     $1
          5        DO_ICALL                                                     
   14     6      > RETURN                                                       null

End of function runclosure

End of class MyClass.

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

End of function func

End of class SomeOtherClass.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
167.56 ms | 1586 KiB | 14 Q