3v4l.org

run code in 300+ PHP versions simultaneously
<?php $__CLASSES = []; $__CLASSES["Foo"] = [ "vars" => ["bar" => null], "methods" => [ "__construct" => function(&$this_, $bar) { $this_["vars"]["bar"] = $bar; }, "bar" => function(&$this_) { return $this_["methods"]["foo"]($this_); }, "foo" => function(&$this_) { static $bar; if (!$bar) { $bar = $this_["vars"]["bar"]; } return $bar; } ] ]; function __new($class, ...$args) { global $__CLASSES; $object = $__CLASSES[$class]; if (isset($object["methods"]["__construct"])) { $object["methods"]["__construct"]($object, ...$args); } return $object; } var_dump(($__temp = __new("Foo", 123))["methods"]["bar"]($__temp)); var_dump(($__temp = __new("Foo", 456))["methods"]["bar"]($__temp));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eUOJq
function name:  (null)
number of ops:  38
compiled vars:  !0 = $__CLASSES, !1 = $__temp
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    6     1        INIT_ARRAY                                       ~4      <array>, 'vars'
    8     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeUOJq%3A8%240'
   10     3        INIT_ARRAY                                       ~6      ~5, '__construct'
   11     4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeUOJq%3A11%241'
   13     5        ADD_ARRAY_ELEMENT                                ~6      ~7, 'bar'
   14     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FeUOJq%3A14%242'
   20     7        ADD_ARRAY_ELEMENT                                ~6      ~8, 'foo'
          8        ADD_ARRAY_ELEMENT                                ~4      ~6, 'methods'
    5     9        ASSIGN_DIM                                               !0, 'Foo'
   20    10        OP_DATA                                                  ~4
   34    11        INIT_FCALL                                               'var_dump'
         12        INIT_FCALL                                               '__new'
         13        SEND_VAL                                                 'Foo'
         14        SEND_VAL                                                 123
         15        DO_FCALL                                      0  $9      
         16        ASSIGN                                           ~10     !1, $9
         17        FETCH_DIM_R                                      ~11     ~10, 'methods'
         18        FETCH_DIM_R                                      ~12     ~11, 'bar'
         19        INIT_DYNAMIC_CALL                                        ~12
         20        SEND_VAR_EX                                              !1
         21        DO_FCALL                                      0  $13     
         22        SEND_VAR                                                 $13
         23        DO_ICALL                                                 
   35    24        INIT_FCALL                                               'var_dump'
         25        INIT_FCALL                                               '__new'
         26        SEND_VAL                                                 'Foo'
         27        SEND_VAL                                                 456
         28        DO_FCALL                                      0  $15     
         29        ASSIGN                                           ~16     !1, $15
         30        FETCH_DIM_R                                      ~17     ~16, 'methods'
         31        FETCH_DIM_R                                      ~18     ~17, 'bar'
         32        INIT_DYNAMIC_CALL                                        ~18
         33        SEND_VAR_EX                                              !1
         34        DO_FCALL                                      0  $19     
         35        SEND_VAR                                                 $19
         36        DO_ICALL                                                 
         37      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FeUOJq%3A8%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eUOJq
function name:  {closure}
number of ops:  6
compiled vars:  !0 = $this_, !1 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    9     2        FETCH_DIM_W                                      $2      !0, 'vars'
          3        ASSIGN_DIM                                               $2, 'bar'
          4        OP_DATA                                                  !1
   10     5      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FeUOJq%3A8%240

Function %00%7Bclosure%7D%2Fin%2FeUOJq%3A11%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eUOJq
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $this_
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   12     1        FETCH_DIM_R                                      ~1      !0, 'methods'
          2        FETCH_DIM_R                                      ~2      ~1, 'foo'
          3        INIT_DYNAMIC_CALL                                        ~2
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $3      
          6      > RETURN                                                   $3
   13     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FeUOJq%3A11%241

Function %00%7Bclosure%7D%2Fin%2FeUOJq%3A14%242:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/eUOJq
function name:  {closure}
number of ops:  9
compiled vars:  !0 = $this_, !1 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   RECV                                             !0      
   15     1        BIND_STATIC                                              !1
   16     2        BOOL_NOT                                         ~2      !1
          3      > JMPZ                                                     ~2, ->7
   17     4    >   FETCH_DIM_R                                      ~3      !0, 'vars'
          5        FETCH_DIM_R                                      ~4      ~3, 'bar'
          6        ASSIGN                                                   !1, ~4
   19     7    > > RETURN                                                   !1
   20     8*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FeUOJq%3A14%242

Function __new:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/eUOJq
function name:  __new
number of ops:  17
compiled vars:  !0 = $class, !1 = $args, !2 = $__CLASSES, !3 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
   25     2        BIND_GLOBAL                                              !2, '__CLASSES'
   27     3        FETCH_DIM_R                                      ~4      !2, !0
          4        ASSIGN                                                   !3, ~4
   28     5        FETCH_DIM_IS                                     ~6      !3, 'methods'
          6        ISSET_ISEMPTY_DIM_OBJ                         0          ~6, '__construct'
          7      > JMPZ                                                     ~7, ->15
   29     8    >   FETCH_DIM_R                                      ~8      !3, 'methods'
          9        FETCH_DIM_R                                      ~9      ~8, '__construct'
         10        INIT_DYNAMIC_CALL                                        ~9
         11        SEND_VAR_EX                                              !3
         12        SEND_UNPACK                                              !1
         13        CHECK_UNDEF_ARGS                                         
         14        DO_FCALL                                      1          
   31    15    > > RETURN                                                   !3
   32    16*     > RETURN                                                   null

End of function __new

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.47 ms | 1411 KiB | 17 Q