3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DIContainer { private $properties = array(); public function __set($propertyName, $value) { $this->properties[$propertyName] = $value; } public function __get($propertyName) { return is_callable($this->properties[$propertyName]) ? $this->properties[$propertyName]($this) : $this->properties[$propertyName]; } } class SessionClass { public $cookieName; public function __construct($cookieName) { $this->cookieName = $cookieName; } } class Application { public static function run() { $di = new DIContainer(); $di->sessionCookieName = 'id'; $di->sessionStorageClass = 'SessionClass'; $di->sessionStorage = function ($di) { $className = $di->sessionStorageClass; return new $className($di->sessionCookieName); }; $sessionHandler = $di->sessionStorage; echo get_class($sessionHandler), "\n", $sessionHandler->cookieName; } } Application::run();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6M56S
function name:  (null)
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_STATIC_METHOD_CALL                                  'Application', 'run'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F6M56S%3A25%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6M56S
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $di, !1 = $className
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        FETCH_OBJ_R                                      ~2      !0, 'sessionStorageClass'
          2        ASSIGN                                                   !1, ~2
   27     3        FETCH_CLASS                                   0  $4      !1
          4        NEW                                              $5      $4
          5        CHECK_FUNC_ARG                                           
          6        FETCH_OBJ_FUNC_ARG                               $6      !0, 'sessionCookieName'
          7        SEND_FUNC_ARG                                            $6
          8        DO_FCALL                                      0          
          9      > RETURN                                                   $5
   28    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F6M56S%3A25%240

Class DIContainer:
Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6M56S
function name:  __set
number of ops:  6
compiled vars:  !0 = $propertyName, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        FETCH_OBJ_W                                      $2      'properties'
          3        ASSIGN_DIM                                               $2, !0
          4        OP_DATA                                                  !1
    7     5      > RETURN                                                   null

End of function __set

Function __get:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 18
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6M56S
function name:  __get
number of ops:  20
compiled vars:  !0 = $propertyName
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
    9     1        INIT_FCALL                                               'is_callable'
          2        FETCH_OBJ_R                                      ~1      'properties'
          3        FETCH_DIM_R                                      ~2      ~1, !0
          4        SEND_VAL                                                 ~2
          5        DO_ICALL                                         $3      
          6      > JMPZ                                                     $3, ->15
          7    >   FETCH_OBJ_R                                      ~4      'properties'
          8        FETCH_DIM_R                                      ~5      ~4, !0
          9        INIT_DYNAMIC_CALL                                        ~5
         10        FETCH_THIS                                       $6      
         11        SEND_VAR_EX                                              $6
         12        DO_FCALL                                      0  $7      
         13        QM_ASSIGN                                        ~8      $7
         14      > JMP                                                      ->18
         15    >   FETCH_OBJ_R                                      ~9      'properties'
         16        FETCH_DIM_R                                      ~10     ~9, !0
         17        QM_ASSIGN                                        ~8      ~10
         18    > > RETURN                                                   ~8
   10    19*     > RETURN                                                   null

End of function __get

End of class DIContainer.

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

End of function __construct

End of class SessionClass.

Class Application:
Function run:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6M56S
function name:  run
number of ops:  18
compiled vars:  !0 = $di, !1 = $sessionHandler
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $2      'DIContainer'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   23     3        ASSIGN_OBJ                                               !0, 'sessionCookieName'
          4        OP_DATA                                                  'id'
   24     5        ASSIGN_OBJ                                               !0, 'sessionStorageClass'
          6        OP_DATA                                                  'SessionClass'
   25     7        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F6M56S%3A25%240'
          8        ASSIGN_OBJ                                               !0, 'sessionStorage'
   28     9        OP_DATA                                                  ~8
   29    10        FETCH_OBJ_R                                      ~9      !0, 'sessionStorage'
         11        ASSIGN                                                   !1, ~9
   30    12        GET_CLASS                                        ~11     !1
         13        ECHO                                                     ~11
         14        ECHO                                                     '%0A'
         15        FETCH_OBJ_R                                      ~12     !1, 'cookieName'
         16        ECHO                                                     ~12
   31    17      > RETURN                                                   null

End of function run

End of class Application.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.81 ms | 1392 KiB | 15 Q