3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Error { private $_errors; private function _init(){ $this->_errors = (object) [ 'small' => 'Small mistake' ]; } public function getError(){ var_dump($this->_errors); } } class Test { use Error; public function __construct(){ $this->_errors = $this->_init(); } } $obj = new Test(); $obj->getError();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F1Cta
function name:  (null)
number of ops:  8
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'error'
   19     1        DECLARE_CLASS                                            'test'
   29     2        NEW                                              $1      'Test'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   30     5        INIT_METHOD_CALL                                         !0, 'getError'
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Class Error:
Function _init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F1Cta
function name:  _init
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   CAST                                          8  ~1      <array>
    8     1        ASSIGN_OBJ                                               '_errors'
    9     2        OP_DATA                                                  ~1
   11     3      > RETURN                                                   null

End of function _init

Function geterror:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F1Cta
function name:  getError
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                               'var_dump'
          1        FETCH_OBJ_R                                      ~0      '_errors'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                                 
   15     4      > RETURN                                                   null

End of function geterror

End of class Error.

Class Test:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/F1Cta
function name:  __construct
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_METHOD_CALL                                         '_init'
          1        DO_FCALL                                      0  $1      
          2        ASSIGN_OBJ                                               '_errors'
          3        OP_DATA                                                  $1
   25     4      > RETURN                                                   null

End of function __construct

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.74 ms | 1396 KiB | 15 Q