3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Container{ private $callables = []; public function __set(string $name,$value){ if($value instanceof Closure){ $this->callables[$name] = $value; } } public function __call(string $method, array $args){ if(isset($this->callables[$method])){ $callable = $this->callables[$method]; $callable($args); } } } $container = new Container(); $container->demo = function(){ return new Container(); }; var_dump($container->demo());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hletM
function name:  (null)
number of ops:  12
compiled vars:  !0 = $container
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $1      'Container'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   21     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FhletM%3A21%240'
          4        ASSIGN_OBJ                                               !0, 'demo'
   23     5        OP_DATA                                                  ~5
   25     6        INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !0, 'demo'
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
         11      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FhletM%3A21%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hletM
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $0      'Container'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
   23     3*     > RETURN                                                   null

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

Class Container:
Function __set:
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/hletM
function name:  __set
number of ops:  8
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    7     2        INSTANCEOF                                               !1, 'Closure'
          3      > JMPZ                                                     ~2, ->7
    8     4    >   FETCH_OBJ_W                                      $3      'callables'
          5        ASSIGN_DIM                                               $3, !0
          6        OP_DATA                                                  !1
   10     7    > > RETURN                                                   null

End of function __set

Function __call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 11
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/hletM
function name:  __call
number of ops:  12
compiled vars:  !0 = $method, !1 = $args, !2 = $callable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        FETCH_OBJ_IS                                     ~3      'callables'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~3, !0
          4      > JMPZ                                                     ~4, ->11
   14     5    >   FETCH_OBJ_R                                      ~5      'callables'
          6        FETCH_DIM_R                                      ~6      ~5, !0
          7        ASSIGN                                                   !2, ~6
   15     8        INIT_DYNAMIC_CALL                                        !2
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0          
   17    11    > > RETURN                                                   null

End of function __call

End of class Container.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.71 ms | 1400 KiB | 15 Q