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 DatabaseConnection { private $username; private $password; public function __construct($username, $password) { $this->username = $username; $this->password = $password; } } foreach (get_declared_classes() as $className) { define($className, $className); } $di = new DIContainer(); $di->databaseUsername = 'user'; $di->databasePassword = '123456'; $di->databaseConnectionClass = DatabaseConnection; $di->databaseConnection = function ($di) { $className = $di->databaseConnectionClass; return new $className($di->databaseUsername, $di->databasePassword); }; $db = $di->databaseConnection; print_r($db);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/dWrqI
function name:  (null)
number of ops:  29
compiled vars:  !0 = $className, !1 = $di, !2 = $db
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   INIT_FCALL                                               'get_declared_classes'
          1        DO_ICALL                                         $3      
          2      > FE_RESET_R                                       $4      $3, ->9
          3    > > FE_FETCH_R                                               $4, !0, ->9
   23     4    >   INIT_FCALL                                               'define'
          5        SEND_VAR                                                 !0
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                                 
   22     8      > JMP                                                      ->3
          9    >   FE_FREE                                                  $4
   26    10        NEW                                              $6      'DIContainer'
         11        DO_FCALL                                      0          
         12        ASSIGN                                                   !1, $6
   27    13        ASSIGN_OBJ                                               !1, 'databaseUsername'
         14        OP_DATA                                                  'user'
   28    15        ASSIGN_OBJ                                               !1, 'databasePassword'
         16        OP_DATA                                                  '123456'
   29    17        FETCH_CONSTANT                                   ~12     'DatabaseConnection'
         18        ASSIGN_OBJ                                               !1, 'databaseConnectionClass'
         19        OP_DATA                                                  ~12
   30    20        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FdWrqI%3A30%240'
         21        ASSIGN_OBJ                                               !1, 'databaseConnection'
   33    22        OP_DATA                                                  ~14
   35    23        FETCH_OBJ_R                                      ~15     !1, 'databaseConnection'
         24        ASSIGN                                                   !2, ~15
   36    25        INIT_FCALL                                               'print_r'
         26        SEND_VAR                                                 !2
         27        DO_ICALL                                                 
         28      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FdWrqI%3A30%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dWrqI
function name:  {closure}
number of ops:  14
compiled vars:  !0 = $di, !1 = $className
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1        FETCH_OBJ_R                                      ~2      !0, 'databaseConnectionClass'
          2        ASSIGN                                                   !1, ~2
   32     3        FETCH_CLASS                                   0  $4      !1
          4        NEW                                              $5      $4
          5        CHECK_FUNC_ARG                                           
          6        FETCH_OBJ_FUNC_ARG                               $6      !0, 'databaseUsername'
          7        SEND_FUNC_ARG                                            $6
          8        CHECK_FUNC_ARG                                           
          9        FETCH_OBJ_FUNC_ARG                               $7      !0, 'databasePassword'
         10        SEND_FUNC_ARG                                            $7
         11        DO_FCALL                                      0          
         12      > RETURN                                                   $5
   33    13*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FdWrqI%3A30%240

Class DIContainer:
Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dWrqI
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/dWrqI
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 DatabaseConnection:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dWrqI
function name:  __construct
number of ops:  7
compiled vars:  !0 = $username, !1 = $password
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   17     2        ASSIGN_OBJ                                               'username'
          3        OP_DATA                                                  !0
   18     4        ASSIGN_OBJ                                               'password'
          5        OP_DATA                                                  !1
   19     6      > RETURN                                                   null

End of function __construct

End of class DatabaseConnection.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.8 ms | 1404 KiB | 21 Q