3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class A { private function foo() { echo "success!\n"; } public function test() { $this->foo(); static::foo(); } } class B extends A { /* foo() will be copied to B, hence its scope will still be A and * the call be successful */ } class C extends A { private function foo() { /* original method is replaced; the scope of the new one is C */ } } $c = new C(); $c->test(); //fails ?>
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/13UhM
function name:  (null)
number of ops:  11
compiled vars:  !0 = $c
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   2     0  E >   NOP                                                      
  13     1        NOP                                                      
         2        NOP                                                      
  18     3        NOP                                                      
         4        NOP                                                      
  25     5        NEW                                              $6      :-2
         6        DO_FCALL                                      0          
         7        ASSIGN                                                   !0, $6
  26     8        INIT_METHOD_CALL                                         !0, 'test'
         9        DO_FCALL                                      0          
        10      > RETURN                                                   1

Class A:
Function foo:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/13UhM
function name:  foo
number of ops:  2
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   4     0  E >   ECHO                                                     'success%21%0A'
   5     1      > RETURN                                                   null

End of function foo

Function test:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/13UhM
function name:  test
number of ops:  6
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   7     0  E >   INIT_METHOD_CALL                                         'foo'
         1        DO_FCALL                                      0          
   8     2        FETCH_CLASS                                 515  :1      
         3        INIT_STATIC_METHOD_CALL                                  $1, 'foo'
         4        DO_FCALL                                      0          
  10     5      > RETURN                                                   null

End of function test

End of class A.

Class B:
Function foo:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/13UhM
function name:  foo
number of ops:  2
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   4     0  E >   ECHO                                                     'success%21%0A'
   5     1      > RETURN                                                   null

End of function foo

Function test:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/13UhM
function name:  test
number of ops:  6
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   7     0  E >   INIT_METHOD_CALL                                         'foo'
         1        DO_FCALL                                      0          
   8     2        FETCH_CLASS                                 515  :1      
         3        INIT_STATIC_METHOD_CALL                                  $1, 'foo'
         4        DO_FCALL                                      0          
  10     5      > RETURN                                                   null

End of function test

End of class B.

Class C:
Function foo:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/13UhM
function name:  foo
number of ops:  1
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  21     0  E > > RETURN                                                   null

End of function foo

Function test:
Finding entry points
Branch analysis from position: 0
Jump found. Position 1 = -2
filename:       /in/13UhM
function name:  test
number of ops:  6
compiled vars:  none
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   7     0  E >   INIT_METHOD_CALL                                         'foo'
         1        DO_FCALL                                      0          
   8     2        FETCH_CLASS                                 515  :1      
         3        INIT_STATIC_METHOD_CALL                                  $1, 'foo'
         4        DO_FCALL                                      0          
  10     5      > RETURN                                                   null

End of function test

End of class C.

Generated using Vulcan Logic Dumper, using php 7.2.0