3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[\Attribute(\Attribute::TARGET_METHOD)] class TestAttribute {} class ParentClass { #[TestAttribute] function foo() { } } class ChildclassA extends ParentClass {} class ChildclassB extends ParentClass { function foo() { } } $method = new \ReflectionMethod(ParentClass::class, 'foo'); var_dump($method->getAttributes(TestAttribute::class)); $method = new \ReflectionMethod(ChildClassA::class, 'foo'); var_dump($method->getAttributes(TestAttribute::class)); $method = new \ReflectionMethod(ChildClassB::class, 'foo'); var_dump($method->getAttributes(TestAttribute::class));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/42bu0
function name:  (null)
number of ops:  34
compiled vars:  !0 = $method
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'ReflectionMethod'
          1        SEND_VAL_EX                                              'ParentClass'
          2        SEND_VAL_EX                                              'foo'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   26     5        INIT_FCALL                                               'var_dump'
          6        INIT_METHOD_CALL                                         !0, 'getAttributes'
          7        SEND_VAL_EX                                              'TestAttribute'
          8        DO_FCALL                                      0  $4      
          9        SEND_VAR                                                 $4
         10        DO_ICALL                                                 
   29    11        NEW                                              $6      'ReflectionMethod'
         12        SEND_VAL_EX                                              'ChildClassA'
         13        SEND_VAL_EX                                              'foo'
         14        DO_FCALL                                      0          
         15        ASSIGN                                                   !0, $6
   30    16        INIT_FCALL                                               'var_dump'
         17        INIT_METHOD_CALL                                         !0, 'getAttributes'
         18        SEND_VAL_EX                                              'TestAttribute'
         19        DO_FCALL                                      0  $9      
         20        SEND_VAR                                                 $9
         21        DO_ICALL                                                 
   33    22        NEW                                              $11     'ReflectionMethod'
         23        SEND_VAL_EX                                              'ChildClassB'
         24        SEND_VAL_EX                                              'foo'
         25        DO_FCALL                                      0          
         26        ASSIGN                                                   !0, $11
   34    27        INIT_FCALL                                               'var_dump'
         28        INIT_METHOD_CALL                                         !0, 'getAttributes'
         29        SEND_VAL_EX                                              'TestAttribute'
         30        DO_FCALL                                      0  $14     
         31        SEND_VAR                                                 $14
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Class TestAttribute: [no user functions]
Class ParentClass:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/42bu0
function name:  foo
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E > > RETURN                                                   null

End of function foo

End of class ParentClass.

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

End of function foo

End of class ChildclassA.

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

End of function foo

End of class ChildclassB.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
124.83 ms | 1437 KiB | 14 Q