3v4l.org

run code in 300+ PHP versions simultaneously
<?php enum Status: int { case Open = 1; case Close = 2; } #[Attribute] class Bar { private int $value; public function __construct(int $value) { $this->value = $value; } public function debug() { var_dump("value is => [{$this->value}]"); } } #[Bar(Status::Open->value)] class Foo { } $reflector = new \ReflectionClass(Foo::class); $attributes = $reflector->getAttributes(); $bar = $attributes[0]->newInstance(); $bar->debug();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FOU3Y
function name:  (null)
number of ops:  15
compiled vars:  !0 = $reflector, !1 = $attributes, !2 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_CLASS                                            'status'
   31     1        NEW                                              $3      'ReflectionClass'
          2        SEND_VAL_EX                                              'Foo'
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $3
   32     5        INIT_METHOD_CALL                                         !0, 'getAttributes'
          6        DO_FCALL                                      0  $6      
          7        ASSIGN                                                   !1, $6
   34     8        FETCH_DIM_R                                      ~8      !1, 0
          9        INIT_METHOD_CALL                                         ~8, 'newInstance'
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !2, $9
   35    12        INIT_METHOD_CALL                                         !2, 'debug'
         13        DO_FCALL                                      0          
         14      > RETURN                                                   1

Class Status: [no user functions]
Class Bar:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FOU3Y
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

Function debug:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/FOU3Y
function name:  debug
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'var_dump'
          1        ROPE_INIT                                     3  ~2      'value+is+%3D%3E+%5B'
          2        FETCH_OBJ_R                                      ~0      'value'
          3        ROPE_ADD                                      1  ~2      ~2, ~0
          4        ROPE_END                                      2  ~1      ~2, '%5D'
          5        SEND_VAL                                                 ~1
          6        DO_ICALL                                                 
   21     7      > RETURN                                                   null

End of function debug

End of class Bar.

Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
194.35 ms | 1011 KiB | 14 Q