3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function testProtected() { $object = new Foo(); $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; } public function publicMethod() { return __METHOD__; } protected function protectedMethod() { return __METHOD__; } } $foo = new Foo(); $foo->testProtected();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FLtKI
function name:  (null)
number of ops:  6
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   29     3        INIT_METHOD_CALL                                         !0, 'testProtected'
          4        DO_FCALL                                      0          
          5      > RETURN                                                   1

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/FLtKI
function name:  testProtected
number of ops:  28
compiled vars:  !0 = $object, !1 = $reflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   NEW                                              $2      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
    9     3        NEW                                              $5      'ReflectionMethod'
          4        SEND_VAR_EX                                              !0
          5        SEND_VAL_EX                                              'protectedMethod'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   11     8        INIT_METHOD_CALL                                         !1, 'isProtected'
          9        DO_FCALL                                      0  $8      
         10      > JMPZ                                                     $8, ->13
         11    >   QM_ASSIGN                                        ~9      'TRUE'
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~9      'FALSE'
         14    >   CONCAT                                           ~10     'isProtected+++++-%3E+', ~9
         15        CONCAT                                           ~11     ~10, '%0A'
         16        ECHO                                                     ~11
   12    17        INIT_METHOD_CALL                                         !0, 'publicMethod'
         18        DO_FCALL                                      0  $12     
         19        CONCAT                                           ~13     'publicMethod++++-%3E+', $12
         20        CONCAT                                           ~14     ~13, '%0A'
         21        ECHO                                                     ~14
   13    22        INIT_METHOD_CALL                                         !0, 'protectedMethod'
         23        DO_FCALL                                      0  $15     
         24        CONCAT                                           ~16     'protectedMethod+-%3E+', $15
         25        CONCAT                                           ~17     ~16, '%0A'
         26        ECHO                                                     ~17
   14    27      > RETURN                                                   null

End of function testprotected

Function publicmethod:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FLtKI
function name:  publicMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E > > RETURN                                                   'Foo%3A%3ApublicMethod'
   19     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/FLtKI
function name:  protectedMethod
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E > > RETURN                                                   'Foo%3A%3AprotectedMethod'
   24     1*     > RETURN                                                   null

End of function protectedmethod

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.38 ms | 1399 KiB | 13 Q