3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Test\Config { trait Base { public $config = []; function __construct($config = []) { echo 'Constructor'; $this->config = $config; } } } namespace TestB { class Config { use \Test\Config\Base; } } namespace { $test = new TestB\Config(['foo' => 'bar']); echo isset($test->config['foo']) ? 'Success: foo is set' : 'Error: foo is not set'; }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F3UdP
function name:  (null)
number of ops:  13
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   DECLARE_CLASS                                            'testb%5Cconfig'
   23     1        NEW                                              $1      'TestB%5CConfig'
          2        SEND_VAL_EX                                              <array>
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   25     5        FETCH_OBJ_IS                                     ~4      !0, 'config'
          6        ISSET_ISEMPTY_DIM_OBJ                         0          ~4, 'foo'
          7      > JMPZ                                                     ~5, ->10
          8    >   QM_ASSIGN                                        ~6      'Success%3A+foo+is+set'
          9      > JMP                                                      ->11
         10    >   QM_ASSIGN                                        ~6      'Error%3A+foo+is+not+set'
         11    >   ECHO                                                     ~6
   26    12      > RETURN                                                   1

Class Test\Config\Base:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F3UdP
function name:  __construct
number of ops:  5
compiled vars:  !0 = $config
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV_INIT                                        !0      <array>
    9     1        ECHO                                                     'Constructor'
   10     2        ASSIGN_OBJ                                               'config'
          3        OP_DATA                                                  !0
   11     4      > RETURN                                                   null

End of function __construct

End of class Test\Config\Base.

Class TestB\Config: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.03 ms | 1394 KiB | 13 Q