3v4l.org

run code in 300+ PHP versions simultaneously
<?php //$test = array( 'permissions2', 'this2', 'test'); //$toost = array('permissions2', 'test', 'this2'); //$yo = array_diff($toost, $test); //if (array_diff($toost, $test) || array_diff($test, $toost)) // echo 'false'; //else // echo 'true'; error_reporting(-1); ini_set('display_errors', 'on'); 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/EgtvS
function name:  (null)
number of ops:  18
compiled vars:  !0 = $b, !1 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 -1
          2        DO_ICALL                                                 
   14     3        INIT_FCALL                                               'ini_set'
          4        SEND_VAL                                                 'display_errors'
          5        SEND_VAL                                                 'on'
          6        DO_ICALL                                                 
   37     7        NEW                                              $4      'B'
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !0, $4
   38    10        INIT_METHOD_CALL                                         !0, 'test'
         11        DO_FCALL                                      0          
   39    12        NEW                                              $8      'C'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !1, $8
   40    15        INIT_METHOD_CALL                                         !1, 'test'
         16        DO_FCALL                                      0          
         17      > RETURN                                                   1

Class A:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EgtvS
function name:  foo
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ECHO                                                     'success%21%0A'
   19     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/EgtvS
function name:  test
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_METHOD_CALL                                         'foo'
          1        DO_FCALL                                      0          
   22     2        INIT_STATIC_METHOD_CALL                                  'foo'
          3        DO_FCALL                                      0          
   23     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/EgtvS
function name:  foo
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   ECHO                                                     'success%21%0A'
   19     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/EgtvS
function name:  test
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_METHOD_CALL                                         'foo'
          1        DO_FCALL                                      0          
   22     2        INIT_STATIC_METHOD_CALL                                  'foo'
          3        DO_FCALL                                      0          
   23     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/EgtvS
function name:  foo
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     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/EgtvS
function name:  test
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_METHOD_CALL                                         'foo'
          1        DO_FCALL                                      0          
   22     2        INIT_STATIC_METHOD_CALL                                  'foo'
          3        DO_FCALL                                      0          
   23     4      > RETURN                                                   null

End of function test

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.58 ms | 1400 KiB | 17 Q