3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[\Attribute] final class Attr1 {} #[\Attribute] final class Attr2 {} final class A { public function __construct( #[Attr1] #[Attr2] public string $a ) {} } $reflection = new \ReflectionClass(A::class); var_dump(array_keys($reflection->getConstructor()->getParameters()[0]->getAttributes(Attr2::class)));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LYAMb
function name:  (null)
number of ops:  19
compiled vars:  !0 = $reflection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   NEW                                              $1      'ReflectionClass'
          1        SEND_VAL_EX                                              'A'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   20     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'array_keys'
          6        INIT_METHOD_CALL                                         !0, 'getConstructor'
          7        DO_FCALL                                      0  $4      
          8        INIT_METHOD_CALL                                         $4, 'getParameters'
          9        DO_FCALL                                      0  $5      
         10        FETCH_DIM_R                                      ~6      $5, 0
         11        INIT_METHOD_CALL                                         ~6, 'getAttributes'
         12        SEND_VAL_EX                                              'Attr2'
         13        DO_FCALL                                      0  $7      
         14        SEND_VAR                                                 $7
         15        DO_ICALL                                         $8      
         16        SEND_VAR                                                 $8
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

Class Attr1: [no user functions]
Class Attr2: [no user functions]
Class A:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/LYAMb
function name:  __construct
number of ops:  4
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        ASSIGN_OBJ                                               'a'
          2        OP_DATA                                                  !0
   15     3      > RETURN                                                   null

End of function __construct

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.16 ms | 1446 KiB | 15 Q