3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface ArraySerializableInterface {} class Baz { private $eventq = 'test222'; } class Bar{ private $event = 'test'; private $test3; /** * Constructor. */ public function __construct() { $this->test3 = [ new Baz(), new Baz(), new Baz(), new Baz(), ]; } } class Foo { private $test = 'sd'; private $test2; /** * Constructor. */ public function __construct() { $this->test2 = [ new Bar(), new Bar(), new Bar(), new Bar(), ]; } public function dismount($object = null) { $object = $object?: $this; $reflectionClass = new \ReflectionClass(get_class($object)); $array =[]; foreach ($reflectionClass->getProperties() as $property) { $property->setAccessible(true); $value = $property->getValue($object); if (is_array($value)) { $this->foo($value, $property, $array); continue; } $array[$property->getName()] = $value; $property->setAccessible(false); } return $array; } private function foo($value, \ReflectionProperty $property, &$array) { foreach ($value as $name => $subValue) { if (is_object($subValue)) { $array[$property->getName()][$name] = $this->dismount($subValue); continue; } if (is_array($subValue)) { //$this->foo($subValue, $property, $array); continue; } } } } $foo = new Foo; var_dump( $foo->dismount());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3pCch
function name:  (null)
number of ops:  9
compiled vars:  !0 = $foo
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   92     0  E >   NEW                                              $1      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   93     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'dismount'
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Class ArraySerializableInterface: [no user functions]
Class Baz: [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/3pCch
function name:  __construct
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $1      'Baz'
          1        DO_FCALL                                      0          
          2        INIT_ARRAY                                       ~3      $1
   21     3        NEW                                              $4      'Baz'
          4        DO_FCALL                                      0          
          5        ADD_ARRAY_ELEMENT                                ~3      $4
   22     6        NEW                                              $6      'Baz'
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~3      $6
   23     9        NEW                                              $8      'Baz'
         10        DO_FCALL                                      0          
         11        ADD_ARRAY_ELEMENT                                ~3      $8
   19    12        ASSIGN_OBJ                                               'test3'
   23    13        OP_DATA                                                  ~3
   25    14      > RETURN                                                   null

End of function __construct

End of class Bar.

Class Foo:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3pCch
function name:  __construct
number of ops:  15
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   NEW                                              $1      'Bar'
          1        DO_FCALL                                      0          
          2        INIT_ARRAY                                       ~3      $1
   40     3        NEW                                              $4      'Bar'
          4        DO_FCALL                                      0          
          5        ADD_ARRAY_ELEMENT                                ~3      $4
   41     6        NEW                                              $6      'Bar'
          7        DO_FCALL                                      0          
          8        ADD_ARRAY_ELEMENT                                ~3      $6
   42     9        NEW                                              $8      'Bar'
         10        DO_FCALL                                      0          
         11        ADD_ARRAY_ELEMENT                                ~3      $8
   38    12        ASSIGN_OBJ                                               'test2'
   42    13        OP_DATA                                                  ~3
   44    14      > RETURN                                                   null

End of function __construct

Function dismount:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 38
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 38
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 30
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/3pCch
function name:  dismount
number of ops:  41
compiled vars:  !0 = $object, !1 = $reflectionClass, !2 = $array, !3 = $property, !4 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   46     0  E >   RECV_INIT                                        !0      null
   48     1        JMP_SET                                          ~5      !0, ->4
          2        FETCH_THIS                                       ~6      
          3        QM_ASSIGN                                        ~5      ~6
          4        ASSIGN                                                   !0, ~5
   49     5        NEW                                              $8      'ReflectionClass'
          6        GET_CLASS                                        ~9      !0
          7        SEND_VAL_EX                                              ~9
          8        DO_FCALL                                      0          
          9        ASSIGN                                                   !1, $8
   50    10        ASSIGN                                                   !2, <array>
   51    11        INIT_METHOD_CALL                                         !1, 'getProperties'
         12        DO_FCALL                                      0  $13     
         13      > FE_RESET_R                                       $14     $13, ->38
         14    > > FE_FETCH_R                                               $14, !3, ->38
   52    15    >   INIT_METHOD_CALL                                         !3, 'setAccessible'
         16        SEND_VAL_EX                                              <true>
         17        DO_FCALL                                      0          
   53    18        INIT_METHOD_CALL                                         !3, 'getValue'
         19        SEND_VAR_EX                                              !0
         20        DO_FCALL                                      0  $16     
         21        ASSIGN                                                   !4, $16
   55    22        TYPE_CHECK                                  128          !4
         23      > JMPZ                                                     ~18, ->30
   56    24    >   INIT_METHOD_CALL                                         'foo'
         25        SEND_VAR_EX                                              !4
         26        SEND_VAR_EX                                              !3
         27        SEND_VAR_EX                                              !2
         28        DO_FCALL                                      0          
   58    29      > JMP                                                      ->14
   61    30    >   INIT_METHOD_CALL                                         !3, 'getName'
         31        DO_FCALL                                      0  $20     
         32        ASSIGN_DIM                                               !2, $20
         33        OP_DATA                                                  !4
   62    34        INIT_METHOD_CALL                                         !3, 'setAccessible'
         35        SEND_VAL_EX                                              <false>
         36        DO_FCALL                                      0          
   51    37      > JMP                                                      ->14
         38    >   FE_FREE                                                  $14
   65    39      > RETURN                                                   !2
   66    40*     > RETURN                                                   null

End of function dismount

Function foo:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 21
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 21
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 20
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
filename:       /in/3pCch
function name:  foo
number of ops:  23
compiled vars:  !0 = $value, !1 = $property, !2 = $array, !3 = $subValue, !4 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   68     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
   70     3      > FE_RESET_R                                       $5      !0, ->21
          4    > > FE_FETCH_R                                       ~6      $5, !3, ->21
          5    >   ASSIGN                                                   !4, ~6
   71     6        TYPE_CHECK                                  256          !3
          7      > JMPZ                                                     ~8, ->17
   72     8    >   INIT_METHOD_CALL                                         !1, 'getName'
          9        DO_FCALL                                      0  $9      
         10        INIT_METHOD_CALL                                         'dismount'
         11        SEND_VAR_EX                                              !3
         12        DO_FCALL                                      0  $12     
         13        FETCH_DIM_W                                      $10     !2, $9
         14        ASSIGN_DIM                                               $10, !4
         15        OP_DATA                                                  $12
   74    16      > JMP                                                      ->4
   76    17    >   TYPE_CHECK                                  128          !3
         18      > JMPZ                                                     ~13, ->20
   79    19    > > JMP                                                      ->4
   70    20    > > JMP                                                      ->4
         21    >   FE_FREE                                                  $5
   86    22      > RETURN                                                   null

End of function foo

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.39 ms | 945 KiB | 16 Q