3v4l.org

run code in 300+ PHP versions simultaneously
<?php $object = new stdClass(); $object->id = 12; $object->datetime = new \DateTime(); $object->foo = 'foo'; $object->bar = 'foo'; $object->a = 'foo'; $object->b = 'foo'; $object->c = 'foo'; $object->d = 'foo'; $object->e = 'foo'; /* @var callable $toArray */ $toArray = null; $toArray = function ($object) use (&$toArray) { $array = []; foreach ($object as $key => $attribute) { if ($attribute instanceof \DateTime) { $array[$key] = $attribute->format('c'); } elseif (is_object($attribute) || is_array($attribute)) { $array[$key] = $toArray($attribute); } else { $array[$key] = $attribute; } } return $array; }; for ($i = 0; $i < 1000; $i++) { $toArray($object); } var_dump($toArray($object));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 29
Branch analysis from position: 35
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 29
Branch analysis from position: 35
Branch analysis from position: 29
filename:       /in/VRQLQ
function name:  (null)
number of ops:  42
compiled vars:  !0 = $object, !1 = $toArray, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $3      'stdClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
    4     3        ASSIGN_OBJ                                               !0, 'id'
          4        OP_DATA                                                  12
    5     5        NEW                                              $8      'DateTime'
          6        DO_FCALL                                      0          
          7        ASSIGN_OBJ                                               !0, 'datetime'
          8        OP_DATA                                                  $8
    6     9        ASSIGN_OBJ                                               !0, 'foo'
         10        OP_DATA                                                  'foo'
    7    11        ASSIGN_OBJ                                               !0, 'bar'
         12        OP_DATA                                                  'foo'
    8    13        ASSIGN_OBJ                                               !0, 'a'
         14        OP_DATA                                                  'foo'
    9    15        ASSIGN_OBJ                                               !0, 'b'
         16        OP_DATA                                                  'foo'
   10    17        ASSIGN_OBJ                                               !0, 'c'
         18        OP_DATA                                                  'foo'
   11    19        ASSIGN_OBJ                                               !0, 'd'
         20        OP_DATA                                                  'foo'
   12    21        ASSIGN_OBJ                                               !0, 'e'
         22        OP_DATA                                                  'foo'
   15    23        ASSIGN                                                   !1, null
   17    24        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVRQLQ%3A17%240'
         25        BIND_LEXICAL                                             ~18, !1
         26        ASSIGN                                                   !1, ~18
   31    27        ASSIGN                                                   !2, 0
         28      > JMP                                                      ->33
   32    29    >   INIT_DYNAMIC_CALL                                        !1
         30        SEND_VAR_EX                                              !0
         31        DO_FCALL                                      0          
   31    32        PRE_INC                                                  !2
         33    >   IS_SMALLER                                               !2, 1000
         34      > JMPNZ                                                    ~23, ->29
   35    35    >   INIT_FCALL                                               'var_dump'
         36        INIT_DYNAMIC_CALL                                        !1
         37        SEND_VAR_EX                                              !0
         38        DO_FCALL                                      0  $24     
         39        SEND_VAR                                                 $24
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FVRQLQ%3A17%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 28
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 28
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 14
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 14
2 jumps found. (Code = 47) Position 1 = 16, Position 2 = 18
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 27
Branch analysis from position: 27
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 18
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
filename:       /in/VRQLQ
function name:  {closure}
number of ops:  31
compiled vars:  !0 = $object, !1 = $toArray, !2 = $array, !3 = $attribute, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   18     2        ASSIGN                                                   !2, <array>
   19     3      > FE_RESET_R                                       $6      !0, ->28
          4    > > FE_FETCH_R                                       ~7      $6, !3, ->28
          5    >   ASSIGN                                                   !4, ~7
   20     6        INSTANCEOF                                               !3, 'DateTime'
          7      > JMPZ                                                     ~9, ->14
   21     8    >   INIT_METHOD_CALL                                         !3, 'format'
          9        SEND_VAL_EX                                              'c'
         10        DO_FCALL                                      0  $11     
         11        ASSIGN_DIM                                               !2, !4
         12        OP_DATA                                                  $11
         13      > JMP                                                      ->27
   22    14    >   TYPE_CHECK                                  256  ~12     !3
         15      > JMPNZ_EX                                         ~12     ~12, ->18
         16    >   TYPE_CHECK                                  128  ~13     !3
         17        BOOL                                             ~12     ~13
         18    > > JMPZ                                                     ~12, ->25
   23    19    >   INIT_DYNAMIC_CALL                                        !1
         20        SEND_VAR_EX                                              !3
         21        DO_FCALL                                      0  $15     
         22        ASSIGN_DIM                                               !2, !4
         23        OP_DATA                                                  $15
         24      > JMP                                                      ->27
   25    25    >   ASSIGN_DIM                                               !2, !4
         26        OP_DATA                                                  !3
   19    27    > > JMP                                                      ->4
         28    >   FE_FREE                                                  $6
   28    29      > RETURN                                                   !2
   29    30*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FVRQLQ%3A17%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.23 ms | 1404 KiB | 15 Q