3v4l.org

run code in 300+ PHP versions simultaneously
<?php class AbstractFoo { public static function instance() { return new static(); } public function publicMethod() { return __METHOD__; } protected function protectedMethod() { return __METHOD__; } } class Foo extends AbstractFoo { public function testProtected() { $object = Bar::instance(); $reflection = new \ReflectionMethod($object, 'protectedMethod'); echo 'isProtected' . ($reflection->isProtected() ? 'TRUE' : 'FALSE') . PHP_EOL; echo 'publicMethod' . $object->publicMethod() . PHP_EOL; echo 'protectedMethod' . $object->protectedMethod() . PHP_EOL; } } 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/Y8DVG
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/Y8DVG
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/Y8DVG
function name:  publicMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E > > RETURN                                                   '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/Y8DVG
function name:  protectedMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E > > RETURN                                                   '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/Y8DVG
function name:  testProtected
number of ops:  28
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
   29     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        CONCAT                                           ~10     ~9, '%0A'
         16        ECHO                                                     ~10
   30    17        INIT_METHOD_CALL                                         !0, 'publicMethod'
         18        DO_FCALL                                      0  $11     
         19        CONCAT                                           ~12     'publicMethod', $11
         20        CONCAT                                           ~13     ~12, '%0A'
         21        ECHO                                                     ~13
   31    22        INIT_METHOD_CALL                                         !0, 'protectedMethod'
         23        DO_FCALL                                      0  $14     
         24        CONCAT                                           ~15     'protectedMethod', $14
         25        CONCAT                                           ~16     ~15, '%0A'
         26        ECHO                                                     ~16
   32    27      > 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/Y8DVG
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/Y8DVG
function name:  publicMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E > > RETURN                                                   '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/Y8DVG
function name:  protectedMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E > > RETURN                                                   '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/Y8DVG
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/Y8DVG
function name:  publicMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E > > RETURN                                                   '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/Y8DVG
function name:  protectedMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E > > RETURN                                                   '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:
159.7 ms | 1403 KiB | 13 Q