3v4l.org

run code in 300+ PHP versions simultaneously
<?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 */ } } $b = new B(); $b->test(); $c = new C(); $c->test(); //fails ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vLnut
function name:  (null)
number of ops:  11
compiled vars:  !0 = $b, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E >   NEW                                              $2      'B'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   24     3        INIT_METHOD_CALL                                         !0, 'test'
          4        DO_FCALL                                      0          
   25     5        NEW                                              $6      'C'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
   26     8        INIT_METHOD_CALL                                         !1, 'test'
          9        DO_FCALL                                      0          
   27    10      > RETURN                                                   1

Class A:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vLnut
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
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vLnut
function name:  test
number of ops:  5
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        INIT_STATIC_METHOD_CALL                                  'foo'
          3        DO_FCALL                                      0          
    9     4      > RETURN                                                   null

End of function test

End of class A.

Class B:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vLnut
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
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vLnut
function name:  test
number of ops:  5
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        INIT_STATIC_METHOD_CALL                                  'foo'
          3        DO_FCALL                                      0          
    9     4      > RETURN                                                   null

End of function test

End of class B.

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

End of function foo

Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vLnut
function name:  test
number of ops:  5
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        INIT_STATIC_METHOD_CALL                                  'foo'
          3        DO_FCALL                                      0          
    9     4      > RETURN                                                   null

End of function test

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
145.95 ms | 1390 KiB | 13 Q