3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface factory { public static function new(): factory; } #[Value] class Value { public int $value; public function __construct(int $value) { $this->value = $value; } } #[Value(value: 42)] class One implements factory { public static function new(): One { return new One; } } #[Value(value: 2)] class Two implements factory { public static function new(): Two { return new Two; } } #[Value(value: 3)] class Three implements factory { public static function new(): Three { return new Three; } } $arrayOfClasses = [One::new(), Two::new(), Three::new()]; function dumpAttributeData(ReflectionClass $reflection) { $attributes = $reflection->getAttributes(); foreach ($attributes as $attribute) { var_dump($attribute->getName()); var_dump($attribute->getArguments()); } } foreach ($arrayOfClasses as $class) { dumpAttributeData(new ReflectionClass($class::class)); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 23
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 23
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/dt8R3
function name:  (null)
number of ops:  25
compiled vars:  !0 = $arrayOfClasses, !1 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   DECLARE_CLASS                                            'one'
   30     1        DECLARE_CLASS                                            'two'
   39     2        DECLARE_CLASS                                            'three'
   49     3        INIT_STATIC_METHOD_CALL                                  'One', 'new'
          4        DO_FCALL                                      0  $2      
          5        INIT_ARRAY                                       ~3      $2
          6        INIT_STATIC_METHOD_CALL                                  'Two', 'new'
          7        DO_FCALL                                      0  $4      
          8        ADD_ARRAY_ELEMENT                                ~3      $4
          9        INIT_STATIC_METHOD_CALL                                  'Three', 'new'
         10        DO_FCALL                                      0  $5      
         11        ADD_ARRAY_ELEMENT                                ~3      $5
         12        ASSIGN                                                   !0, ~3
   61    13      > FE_RESET_R                                       $7      !0, ->23
         14    > > FE_FETCH_R                                               $7, !1, ->23
   62    15    >   INIT_FCALL                                               'dumpattributedata'
         16        NEW                                              $8      'ReflectionClass'
         17        FETCH_CLASS_NAME                                 ~9      !1
         18        SEND_VAL_EX                                              ~9
         19        DO_FCALL                                      0          
         20        SEND_VAR                                                 $8
         21        DO_FCALL                                      0          
   61    22      > JMP                                                      ->14
         23    >   FE_FREE                                                  $7
   63    24      > RETURN                                                   1

Function dumpattributedata:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 17
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 17
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/dt8R3
function name:  dumpAttributeData
number of ops:  19
compiled vars:  !0 = $reflection, !1 = $attributes, !2 = $attribute
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E >   RECV                                             !0      
   53     1        INIT_METHOD_CALL                                         !0, 'getAttributes'
          2        DO_FCALL                                      0  $3      
          3        ASSIGN                                                   !1, $3
   55     4      > FE_RESET_R                                       $5      !1, ->17
          5    > > FE_FETCH_R                                               $5, !2, ->17
   56     6    >   INIT_FCALL                                               'var_dump'
          7        INIT_METHOD_CALL                                         !2, 'getName'
          8        DO_FCALL                                      0  $6      
          9        SEND_VAR                                                 $6
         10        DO_ICALL                                                 
   57    11        INIT_FCALL                                               'var_dump'
         12        INIT_METHOD_CALL                                         !2, 'getArguments'
         13        DO_FCALL                                      0  $8      
         14        SEND_VAR                                                 $8
         15        DO_ICALL                                                 
   55    16      > JMP                                                      ->5
         17    >   FE_FREE                                                  $5
   59    18      > RETURN                                                   null

End of function dumpattributedata

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

End of function new

End of class factory.

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

End of function __construct

End of class Value.

Class One:
Function new:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dt8R3
function name:  new
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $0      'One'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   25     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function new

End of class One.

Class Two:
Function new:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dt8R3
function name:  new
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   NEW                                              $0      'Two'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   35     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function new

End of class Two.

Class Three:
Function new:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/dt8R3
function name:  new
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   43     0  E >   NEW                                              $0      'Three'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   44     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function new

End of class Three.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.75 ms | 1407 KiB | 16 Q