3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar; private $qux; public function __construct($a, $b) { $this->bar = $a; $this->qux = $b; } public function toArray() { $reflector = new ReflectionClass(self::class); foreach ($reflector->getProperties() as $property) { $name = $property->getName(); $array[$name] = $this->$name; } return $array; } } $foo = new Foo(1, 2); var_dump($foo->toArray());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/7I4mv
function name:  (null)
number of ops:  11
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $1      'Foo'
          1        SEND_VAL_EX                                              1
          2        SEND_VAL_EX                                              2
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $1
   25     5        INIT_FCALL                                               'var_dump'
          6        INIT_METHOD_CALL                                         !0, 'toArray'
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

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

End of function __construct

Function toarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 15
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 15
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/7I4mv
function name:  toArray
number of ops:  18
compiled vars:  !0 = $reflector, !1 = $property, !2 = $name, !3 = $array
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   NEW                                              $4      'ReflectionClass'
          1        SEND_VAL_EX                                              'Foo'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $4
   15     4        INIT_METHOD_CALL                                         !0, 'getProperties'
          5        DO_FCALL                                      0  $7      
          6      > FE_RESET_R                                       $8      $7, ->15
          7    > > FE_FETCH_R                                               $8, !1, ->15
   16     8    >   INIT_METHOD_CALL                                         !1, 'getName'
          9        DO_FCALL                                      0  $9      
         10        ASSIGN                                                   !2, $9
   17    11        FETCH_OBJ_R                                      ~12     !2
         12        ASSIGN_DIM                                               !3, !2
         13        OP_DATA                                                  ~12
   15    14      > JMP                                                      ->7
         15    >   FE_FREE                                                  $8
   20    16      > RETURN                                                   !3
   21    17*     > RETURN                                                   null

End of function toarray

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.17 ms | 1003 KiB | 14 Q