3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { protected $var; function initClass() { $this->var = __CLASS__; } function getVar() { assert($this->var !== null); // ensure initClass was called return $this->var; } } class bar extends foo { function initClass() { $this->var = __CLASS__; } } class baz extends bar { function initClass() { $this->var = __CLASS__; } } $baz = new baz; call_user_func([$baz, "foo::initClass"]); var_dump($baz->getVar());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qv1ij
function name:  (null)
number of ops:  13
compiled vars:  !0 = $baz
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $1      'baz'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   29     3        INIT_ARRAY                                       ~4      !0
          4        ADD_ARRAY_ELEMENT                                ~4      'foo%3A%3AinitClass'
          5        INIT_USER_CALL                                0          'call_user_func', ~4
          6        DO_FCALL                                      0          
   31     7        INIT_FCALL                                               'var_dump'
          8        INIT_METHOD_CALL                                         !0, 'getVar'
          9        DO_FCALL                                      0  $6      
         10        SEND_VAR                                                 $6
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Class foo:
Function initclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qv1ij
function name:  initClass
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   ASSIGN_OBJ                                               'var'
          1        OP_DATA                                                  'foo'
    8     2      > RETURN                                                   null

End of function initclass

Function getvar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qv1ij
function name:  getVar
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSERT_CHECK                                             
          1        INIT_FCALL                                               'assert'
          2        FETCH_OBJ_R                                      ~0      'var'
          3        TYPE_CHECK                                  1020  ~1      ~0
          4        SEND_VAL                                                 ~1
          5        SEND_VAL                                                 'assert%28%24this-%3Evar+%21%3D%3D+null%29'
          6        DO_ICALL                                                 
   12     7        FETCH_OBJ_R                                      ~3      'var'
          8      > RETURN                                                   ~3
   13     9*     > RETURN                                                   null

End of function getvar

End of class foo.

Class bar:
Function initclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qv1ij
function name:  initClass
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ASSIGN_OBJ                                               'var'
          1        OP_DATA                                                  'bar'
   19     2      > RETURN                                                   null

End of function initclass

Function getvar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qv1ij
function name:  getVar
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSERT_CHECK                                             
          1        INIT_FCALL                                               'assert'
          2        FETCH_OBJ_R                                      ~0      'var'
          3        TYPE_CHECK                                  1020  ~1      ~0
          4        SEND_VAL                                                 ~1
          5        SEND_VAL                                                 'assert%28%24this-%3Evar+%21%3D%3D+null%29'
          6        DO_ICALL                                                 
   12     7        FETCH_OBJ_R                                      ~3      'var'
          8      > RETURN                                                   ~3
   13     9*     > RETURN                                                   null

End of function getvar

End of class bar.

Class baz:
Function initclass:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qv1ij
function name:  initClass
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   ASSIGN_OBJ                                               'var'
          1        OP_DATA                                                  'baz'
   25     2      > RETURN                                                   null

End of function initclass

Function getvar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qv1ij
function name:  getVar
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   ASSERT_CHECK                                             
          1        INIT_FCALL                                               'assert'
          2        FETCH_OBJ_R                                      ~0      'var'
          3        TYPE_CHECK                                  1020  ~1      ~0
          4        SEND_VAL                                                 ~1
          5        SEND_VAL                                                 'assert%28%24this-%3Evar+%21%3D%3D+null%29'
          6        DO_ICALL                                                 
   12     7        FETCH_OBJ_R                                      ~3      'var'
          8      > RETURN                                                   ~3
   13     9*     > RETURN                                                   null

End of function getvar

End of class baz.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.15 ms | 1400 KiB | 17 Q