3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $foo; private $bar; private function __construct($foo, $bar){ $this->foo = $foo; $this->bar = $bar; } public function getFoo() { return $this->foo; } public function getBar() { return $this->bar; } } $args = array('eggs','bacon'); $class = 'Foo'; $reflClass = new \ReflectionClass($class); $instance = call_user_func(\Closure::bind(function () use ($args) { return call_user_func_array(new static,$args); }, $reflClass->newInstanceWithoutConstructor(), $class)); echo $instance->getFoo();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ScL9C
function name:  (null)
number of ops:  22
compiled vars:  !0 = $args, !1 = $class, !2 = $reflClass, !3 = $instance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, <array>
   20     1        ASSIGN                                                   !1, 'Foo'
   21     2        NEW                                              $6      'ReflectionClass'
          3        SEND_VAR_EX                                              !1
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !2, $6
   23     6        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FScL9C%3A23%240'
          8        BIND_LEXICAL                                             ~9, !0
   25     9        SEND_VAL                                                 ~9
         10        INIT_METHOD_CALL                                         !2, 'newInstanceWithoutConstructor'
         11        DO_FCALL                                      0  $10     
         12        SEND_VAR                                                 $10
         13        SEND_VAR                                                 !1
         14        DO_FCALL                                      0  $11     
         15        INIT_USER_CALL                                0          'call_user_func', $11
         16        DO_FCALL                                      0  $12     
   23    17        ASSIGN                                                   !3, $12
   28    18        INIT_METHOD_CALL                                         !3, 'getFoo'
         19        DO_FCALL                                      0  $14     
         20        ECHO                                                     $14
         21      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FScL9C%3A23%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ScL9C
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   BIND_STATIC                                              !0
   24     1        NEW                          static              $1      
          2        DO_FCALL                                      0          
          3        INIT_USER_CALL                                0          'call_user_func_array', $1
          4        SEND_ARRAY                                               !0
          5        CHECK_UNDEF_ARGS                                         
          6        DO_FCALL                                      0  $3      
          7      > RETURN                                                   $3
   25     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FScL9C%3A23%240

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

End of function __construct

Function getfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ScL9C
function name:  getFoo
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                      ~0      'foo'
          1      > RETURN                                                   ~0
   12     2*     > RETURN                                                   null

End of function getfoo

Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ScL9C
function name:  getBar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1      > RETURN                                                   ~0
   16     2*     > RETURN                                                   null

End of function getbar

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.45 ms | 1390 KiB | 13 Q