3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); final class Container{ private $callables = array(); public function __set($name,$value){ if($value instanceof Closure){ $this->callables[$name] = $value; } } public function __call($method, array $args){ if(isset($this->callables[$method])){ $callable = $this->callables[$method]; return call_user_func_array($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/Yr8vM
function name:  (null)
number of ops:  12
compiled vars:  !0 = $container
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $1      'Container'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   22     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FYr8vM%3A22%240'
          4        ASSIGN_OBJ                                               !0, 'demo'
   24     5        OP_DATA                                                  ~5
   26     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%2FYr8vM%3A22%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Yr8vM
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $0      'Container'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
   24     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FYr8vM%3A22%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/Yr8vM
function name:  __set
number of ops:  8
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        INSTANCEOF                                               !1, 'Closure'
          3      > JMPZ                                                     ~2, ->7
    9     4    >   FETCH_OBJ_W                                      $3      'callables'
          5        ASSIGN_DIM                                               $3, !0
          6        OP_DATA                                                  !1
   11     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 = 13
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Yr8vM
function name:  __call
number of ops:  14
compiled vars:  !0 = $method, !1 = $args, !2 = $callable
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        FETCH_OBJ_IS                                     ~3      'callables'
          3        ISSET_ISEMPTY_DIM_OBJ                         0          ~3, !0
          4      > JMPZ                                                     ~4, ->13
   15     5    >   FETCH_OBJ_R                                      ~5      'callables'
          6        FETCH_DIM_R                                      ~6      ~5, !0
          7        ASSIGN                                                   !2, ~6
   16     8        INIT_USER_CALL                                0          'call_user_func_array', !2
          9        SEND_ARRAY                                               !1
         10        CHECK_UNDEF_ARGS                                         
         11        DO_FCALL                                      0  $8      
         12      > RETURN                                                   $8
   18    13    > > RETURN                                                   null

End of function __call

End of class Container.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
291.76 ms | 1400 KiB | 16 Q