3v4l.org

run code in 500+ PHP versions simultaneously
<?php namespace test; use \Closure; class MyClass { protected Closure $modifier; public function __construct(callable $modifier) { $this->modifier = Closure::fromCallable($modifier); } } class SomeOtherClass { public static function func() { return ['a' => 'b']; } } // this will work fine $a = new MyClass(['\test\SomeOtherClass', 'func']); var_dump($a); // this will cause error $b = new MyClass(['SomeOtherClass', 'func']);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pnWYC
function name:  (null)
number of ops:  12
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   24     0  E >   NEW                                                  $2      'test%5CMyClass'
          1        SEND_VAL_EX                                                  <array>
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $2
   25     4        INIT_NS_FCALL_BY_NAME                                        'test%5Cvar_dump'
          5        SEND_VAR_EX                                                  !0
          6        DO_FCALL                                          0          
   28     7        NEW                                                  $6      'test%5CMyClass'
          8        SEND_VAL_EX                                                  <array>
          9        DO_FCALL                                          0          
         10        ASSIGN                                                       !1, $6
         11      > RETURN                                                       1

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

End of function __construct

End of class test\MyClass.

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

End of function func

End of class test\SomeOtherClass.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
168.87 ms | 1643 KiB | 14 Q