3v4l.org

run code in 300+ PHP versions simultaneously
<?php #[Attribute(Attribute::TARGET_PROPERTY)] class PropertyAttributes { public function __construct( public readonly ?string $name = null, public readonly ?string $label = null, ) {} } #[Attribute(Attribute::TARGET_PROPERTY)] class IntegerPropertyAttributes extends PropertyAttributes { public function __construct( ?string $name = null, ?string $label = null, public readonly ?int $default = null, public readonly ?int $min = null, public readonly ?int $max = null, public readonly ?int $step = null, ) { parent::__construct($name, $label); } } #[Attribute(Attribute::TARGET_PROPERTY)] class FloatPropertyAttributes extends PropertyAttributes { public function __construct( ?string $name = null, ?string $label = null, public readonly ?float $default = null, public readonly ?float $min = null, public readonly ?float $max = null, ) { parent::__construct($name, $label); } } class MyClass { #[IntegerPropertyAttributes('prop','property: ',5,0,10,1)] public int $prop; } $refl = new ReflectionProperty('MyClass', 'prop'); $attributes = $refl->getAttributes(); foreach ($attributes as $attribute) { var_dump($attribute->getName()); var_dump($attribute->getArguments()); var_dump($attribute->newInstance()); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 26
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 26
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/TrMTe
function name:  (null)
number of ops:  28
compiled vars:  !0 = $refl, !1 = $attributes, !2 = $attribute
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   NEW                                              $3      'ReflectionProperty'
          1        SEND_VAL_EX                                              'MyClass'
          2        SEND_VAL_EX                                              'prop'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $3
   48     5        INIT_METHOD_CALL                                         !0, 'getAttributes'
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !1, $6
   50     8      > FE_RESET_R                                       $8      !1, ->26
          9    > > FE_FETCH_R                                               $8, !2, ->26
   51    10    >   INIT_FCALL                                               'var_dump'
         11        INIT_METHOD_CALL                                         !2, 'getName'
         12        DO_FCALL                                      0  $9      
         13        SEND_VAR                                                 $9
         14        DO_ICALL                                                 
   52    15        INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !2, 'getArguments'
         17        DO_FCALL                                      0  $11     
         18        SEND_VAR                                                 $11
         19        DO_ICALL                                                 
   53    20        INIT_FCALL                                               'var_dump'
         21        INIT_METHOD_CALL                                         !2, 'newInstance'
         22        DO_FCALL                                      0  $13     
         23        SEND_VAR                                                 $13
         24        DO_ICALL                                                 
   50    25      > JMP                                                      ->9
         26    >   FE_FREE                                                  $8
   54    27      > RETURN                                                   1

Class PropertyAttributes:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TrMTe
function name:  __construct
number of ops:  7
compiled vars:  !0 = $name, !1 = $label
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
          2        ASSIGN_OBJ                                               'name'
          3        OP_DATA                                                  !0
          4        ASSIGN_OBJ                                               'label'
          5        OP_DATA                                                  !1
    9     6      > RETURN                                                   null

End of function __construct

End of class PropertyAttributes.

Class IntegerPropertyAttributes:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TrMTe
function name:  __construct
number of ops:  19
compiled vars:  !0 = $name, !1 = $label, !2 = $default, !3 = $min, !4 = $max, !5 = $step
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      null
          3        RECV_INIT                                        !3      null
          4        RECV_INIT                                        !4      null
          5        RECV_INIT                                        !5      null
          6        ASSIGN_OBJ                                               'default'
          7        OP_DATA                                                  !2
          8        ASSIGN_OBJ                                               'min'
          9        OP_DATA                                                  !3
         10        ASSIGN_OBJ                                               'max'
         11        OP_DATA                                                  !4
         12        ASSIGN_OBJ                                               'step'
         13        OP_DATA                                                  !5
   23    14        INIT_STATIC_METHOD_CALL                                  
         15        SEND_VAR_EX                                              !0
         16        SEND_VAR_EX                                              !1
         17        DO_FCALL                                      0          
   24    18      > RETURN                                                   null

End of function __construct

End of class IntegerPropertyAttributes.

Class FloatPropertyAttributes:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TrMTe
function name:  __construct
number of ops:  16
compiled vars:  !0 = $name, !1 = $label, !2 = $default, !3 = $min, !4 = $max
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      null
          3        RECV_INIT                                        !3      null
          4        RECV_INIT                                        !4      null
          5        ASSIGN_OBJ                                               'default'
          6        OP_DATA                                                  !2
          7        ASSIGN_OBJ                                               'min'
          8        OP_DATA                                                  !3
          9        ASSIGN_OBJ                                               'max'
         10        OP_DATA                                                  !4
   37    11        INIT_STATIC_METHOD_CALL                                  
         12        SEND_VAR_EX                                              !0
         13        SEND_VAR_EX                                              !1
         14        DO_FCALL                                      0          
   38    15      > RETURN                                                   null

End of function __construct

End of class FloatPropertyAttributes.

Class MyClass: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.13 ms | 1005 KiB | 14 Q