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

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

End of function %00%7Bclosure%7D%2Fin%2FWN6Qa%3A29%240

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

End of function __construct

End of class DatabaseConnection.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.98 ms | 1404 KiB | 17 Q