3v4l.org

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

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

End of function __construct

Function toarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0IiVM
function name:  toArray
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   INIT_METHOD_CALL                                         'getVars'
          1        DO_FCALL                                      0  $0      
          2      > RETURN                                                   $0
   14     3*     > RETURN                                                   null

End of function toarray

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

End of function getvars

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.86 ms | 1400 KiB | 15 Q