3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DIContainer { private $properties = []; 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; } public function query($sql) { /* ... */ } } $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); $db->query('');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BokD8
function name:  (null)
number of ops:  21
compiled vars:  !0 = $di, !1 = $db
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $2      'DIContainer'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   26     3        ASSIGN_OBJ                                               !0, 'databaseUsername'
          4        OP_DATA                                                  'user'
   27     5        ASSIGN_OBJ                                               !0, 'databasePassword'
          6        OP_DATA                                                  '123456'
   28     7        ASSIGN_OBJ                                               !0, 'databaseConnectionClass'
          8        OP_DATA                                                  'DatabaseConnection'
   29     9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBokD8%3A29%240'
         10        ASSIGN_OBJ                                               !0, 'databaseConnection'
   32    11        OP_DATA                                                  ~9
   34    12        FETCH_OBJ_R                                      ~10     !0, 'databaseConnection'
         13        ASSIGN                                                   !1, ~10
   35    14        INIT_FCALL                                               'print_r'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                                 
   36    17        INIT_METHOD_CALL                                         !1, 'query'
         18        SEND_VAL_EX                                              ''
         19        DO_FCALL                                      0          
         20      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FBokD8%3A29%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BokD8
function name:  {closure}
number of ops:  14
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, '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
   32    13*     > RETURN                                                   null

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

Class DIContainer:
Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BokD8
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/BokD8
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/BokD8
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

Function query:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BokD8
function name:  query
number of ops:  2
compiled vars:  !0 = $sql
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
   22     1      > RETURN                                                   null

End of function query

End of class DatabaseConnection.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
165.58 ms | 1404 KiB | 17 Q