3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar; public function __construct($bar) { $this->bar = $bar; } public function getBar() { return $this->bar; } } class Baz extends Foo { private $wrapped; public function __construct($bar) { $this->wrapped = $this->wrapped ?: (new \ReflectionClass('Foo'))->newInstanceWithoutConstructor(); $this->wrapped->__construct($bar); } public function getBar() { return $this->wrapped->getBar(); } } var_dump((new Baz('tab'))->getBar());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZvZtG
function name:  (null)
number of ops:  9
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   INIT_FCALL                                               'var_dump'
          1        NEW                                              $0      'Baz'
          2        SEND_VAL_EX                                              'tab'
          3        DO_FCALL                                      0          
          4        INIT_METHOD_CALL                                         $0, 'getBar'
          5        DO_FCALL                                      0  $2      
          6        SEND_VAR                                                 $2
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZvZtG
function name:  __construct
number of ops:  4
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    8     1        ASSIGN_OBJ                                               'bar'
          2        OP_DATA                                                  !0
    9     3      > RETURN                                                   null

End of function __construct

Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZvZtG
function name:  getBar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1      > RETURN                                                   ~0
   14     2*     > RETURN                                                   null

End of function getbar

End of class Foo.

Class Baz:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZvZtG
function name:  __construct
number of ops:  16
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
   23     1        FETCH_OBJ_R                                      ~2      'wrapped'
          2        JMP_SET                                          ~3      ~2, ->9
          3        NEW                                              $4      'ReflectionClass'
          4        SEND_VAL_EX                                              'Foo'
          5        DO_FCALL                                      0          
          6        INIT_METHOD_CALL                                         $4, 'newInstanceWithoutConstructor'
          7        DO_FCALL                                      0  $6      
          8        QM_ASSIGN                                        ~3      $6
          9        ASSIGN_OBJ                                               'wrapped'
         10        OP_DATA                                                  ~3
   25    11        FETCH_OBJ_R                                      ~7      'wrapped'
         12        INIT_METHOD_CALL                                         ~7, '__construct'
         13        SEND_VAR_EX                                              !0
         14        DO_FCALL                                      0          
   26    15      > RETURN                                                   null

End of function __construct

Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZvZtG
function name:  getBar
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   FETCH_OBJ_R                                      ~0      'wrapped'
          1        INIT_METHOD_CALL                                         ~0, 'getBar'
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
   31     4*     > RETURN                                                   null

End of function getbar

End of class Baz.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.62 ms | 1400 KiB | 15 Q