3v4l.org

run code in 300+ PHP versions simultaneously
<?php class AbstractFoo { public static function instance() { return new static(); } public function publicMethod() { echo __METHOD__; } protected function protectedMethod() { echo __METHOD__; } } class Foo extends AbstractFoo { public function testProtected() { $object = Bar::instance(); $reflection = new \ReflectionMethod($object, 'protectedMethod'); echo 'isProtected' . ($reflection->isProtected() ? 'TRUE' : 'FALSE'); // it works $object->protectedMethod(); } } class Bar extends AbstractFoo { } Foo::instance()->testProtected();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SMFMd
function name:  (null)
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   INIT_STATIC_METHOD_CALL                                  'Foo', 'instance'
          1        DO_FCALL                                      0  $0      
          2        INIT_METHOD_CALL                                         $0, 'testProtected'
          3        DO_FCALL                                      0          
          4      > RETURN                                                   1

Class AbstractFoo:
Function instance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SMFMd
function name:  instance
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                          static              $0      
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
    8     3*     > RETURN                                                   null

End of function instance

Function publicmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SMFMd
function name:  publicMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ECHO                                                     'AbstractFoo%3A%3ApublicMethod'
   13     1      > RETURN                                                   null

End of function publicmethod

Function protectedmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SMFMd
function name:  protectedMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ECHO                                                     'AbstractFoo%3A%3AprotectedMethod'
   18     1      > RETURN                                                   null

End of function protectedmethod

End of class AbstractFoo.

Class Foo:
Function testprotected:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SMFMd
function name:  testProtected
number of ops:  19
compiled vars:  !0 = $object, !1 = $reflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_STATIC_METHOD_CALL                                  'Bar', 'instance'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   27     3        NEW                                              $4      'ReflectionMethod'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAL_EX                                              'protectedMethod'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $4
   28     8        INIT_METHOD_CALL                                         !1, 'isProtected'
          9        DO_FCALL                                      0  $7      
         10      > JMPZ                                                     $7, ->13
         11    >   QM_ASSIGN                                        ~8      'TRUE'
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~8      'FALSE'
         14    >   CONCAT                                           ~9      'isProtected', ~8
         15        ECHO                                                     ~9
   31    16        INIT_METHOD_CALL                                         !0, 'protectedMethod'
         17        DO_FCALL                                      0          
   32    18      > RETURN                                                   null

End of function testprotected

Function instance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SMFMd
function name:  instance
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                          static              $0      
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
    8     3*     > RETURN                                                   null

End of function instance

Function publicmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SMFMd
function name:  publicMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ECHO                                                     'AbstractFoo%3A%3ApublicMethod'
   13     1      > RETURN                                                   null

End of function publicmethod

Function protectedmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SMFMd
function name:  protectedMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ECHO                                                     'AbstractFoo%3A%3AprotectedMethod'
   18     1      > RETURN                                                   null

End of function protectedmethod

End of class Foo.

Class Bar:
Function instance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SMFMd
function name:  instance
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                          static              $0      
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
    8     3*     > RETURN                                                   null

End of function instance

Function publicmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SMFMd
function name:  publicMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ECHO                                                     'AbstractFoo%3A%3ApublicMethod'
   13     1      > RETURN                                                   null

End of function publicmethod

Function protectedmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SMFMd
function name:  protectedMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   ECHO                                                     'AbstractFoo%3A%3AprotectedMethod'
   18     1      > RETURN                                                   null

End of function protectedmethod

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.7 ms | 1403 KiB | 13 Q