3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Config extends ArrayObject { } final class MyClass { public function __construct(Config $config) { // Read settings echo $config['key'] . "\n"; echo $config->offsetGet('key') . "\n"; // Reading a sub-key echo $config['db']['hostname'] . "\n"; echo $config->offsetGet('db')['hostname'] . "\n"; } } // Within the DI container definition // Load settings from settings.php $settings = [ 'key' => 'value', 'db' => [ 'hostname' => '127.0.0.1', ] ]; $config = new Config($settings); // Let the DI container inject this object via autowiring new MyClass($config);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g41BL
function name:  (null)
number of ops:  10
compiled vars:  !0 = $settings, !1 = $config
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   ASSIGN                                                   !0, <array>
   32     1        NEW                                              $3      'Config'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $3
   35     5        NEW                                              $6      'MyClass'
          6        SEND_VAR_EX                                              !1
          7        DO_FCALL                                      0          
          8        FREE                                                     $6
          9      > RETURN                                                   1

Class Config: [no user functions]
Class MyClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/g41BL
function name:  __construct
number of ops:  20
compiled vars:  !0 = $config
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   13     1        FETCH_DIM_R                                      ~1      !0, 'key'
          2        CONCAT                                           ~2      ~1, '%0A'
          3        ECHO                                                     ~2
   14     4        INIT_METHOD_CALL                                         !0, 'offsetGet'
          5        SEND_VAL_EX                                              'key'
          6        DO_FCALL                                      0  $3      
          7        CONCAT                                           ~4      $3, '%0A'
          8        ECHO                                                     ~4
   17     9        FETCH_DIM_R                                      ~5      !0, 'db'
         10        FETCH_DIM_R                                      ~6      ~5, 'hostname'
         11        CONCAT                                           ~7      ~6, '%0A'
         12        ECHO                                                     ~7
   18    13        INIT_METHOD_CALL                                         !0, 'offsetGet'
         14        SEND_VAL_EX                                              'db'
         15        DO_FCALL                                      0  $8      
         16        FETCH_DIM_R                                      ~9      $8, 'hostname'
         17        CONCAT                                           ~10     ~9, '%0A'
         18        ECHO                                                     ~10
   20    19      > RETURN                                                   null

End of function __construct

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.33 ms | 1449 KiB | 13 Q