3v4l.org

run code in 500+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)] readonly class UseFilter { /** * @param string $filterClass */ public function __construct( /** @phan-suppress PhanWriteOnlyPublicProperty */ public string $filterClass, ) { } } #[UseFilter('class level')] class Foobar { #[UseFilter('method level')] public function foobaz(): void { } } $class = new ReflectionClass(Foobar::class); $allFilters = []; foreach ($class->getAttributes(UseFilter::class) as $attr) { var_dump($attr->getTarget()); } $method = $class->getMethod('foobaz'); foreach ($method->getAttributes(UseFilter::class) as $attr) { var_dump($attr->getTarget()); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
2 jumps found. (Code = 77) Position 1 = 25, Position 2 = 32
Branch analysis from position: 25
2 jumps found. (Code = 78) Position 1 = 26, Position 2 = 32
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 25
Branch analysis from position: 25
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
Branch analysis from position: 16
filename:       /in/dDuXj
function name:  (null)
number of ops:  34
compiled vars:  !0 = $class, !1 = $allFilters, !2 = $attr, !3 = $method
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   27     0  E >   NEW                                                  $4      'ReflectionClass'
          1        SEND_VAL_EX                                                  'Foobar'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $4
   29     4        ASSIGN                                                       !1, <array>
   31     5        INIT_METHOD_CALL                                             !0, 'getAttributes'
          6        SEND_VAL_EX                                                  'UseFilter'
          7        DO_FCALL                                          0  $8      
          8      > FE_RESET_R                                           $9      $8, ->16
          9    > > FE_FETCH_R                                                   $9, !2, ->16
   32    10    >   INIT_FCALL                                                   'var_dump'
         11        INIT_METHOD_CALL                                             !2, 'getTarget'
         12        DO_FCALL                                          0  $10     
         13        SEND_VAR                                                     $10
         14        DO_ICALL                                                     
   31    15      > JMP                                                          ->9
         16    >   FE_FREE                                                      $9
   35    17        INIT_METHOD_CALL                                             !0, 'getMethod'
         18        SEND_VAL_EX                                                  'foobaz'
         19        DO_FCALL                                          0  $12     
         20        ASSIGN                                                       !3, $12
   37    21        INIT_METHOD_CALL                                             !3, 'getAttributes'
         22        SEND_VAL_EX                                                  'UseFilter'
         23        DO_FCALL                                          0  $14     
         24      > FE_RESET_R                                           $15     $14, ->32
         25    > > FE_FETCH_R                                                   $15, !2, ->32
   38    26    >   INIT_FCALL                                                   'var_dump'
         27        INIT_METHOD_CALL                                             !2, 'getTarget'
         28        DO_FCALL                                          0  $16     
         29        SEND_VAR                                                     $16
         30        DO_ICALL                                                     
   37    31      > JMP                                                          ->25
         32    >   FE_FREE                                                      $15
   39    33      > RETURN                                                       1

Class UseFilter:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dDuXj
function name:  __construct
number of ops:  4
compiled vars:  !0 = $filterClass
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   RECV                                                 !0      
          1        ASSIGN_OBJ                                                   'filterClass'
          2        OP_DATA                                                      !0
   13     3      > RETURN                                                       null

End of function __construct

End of class UseFilter.

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

End of function foobaz

End of class Foobar.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
164.62 ms | 1335 KiB | 14 Q