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 (!is_object($attribute) && !is_array($attribute)) { $array[$key] = $atttribute; } elseif ($attribute instanceof \DateTime) { $array[$key] = $attribute->format('c'); } else { $array[$key] = $toArray($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/f9KSE
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%2Ff9KSE%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%2Ff9KSE%3A17%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 30
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 30
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 16
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 24
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 12
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/f9KSE
function name:  {closure}
number of ops:  33
compiled vars:  !0 = $object, !1 = $toArray, !2 = $array, !3 = $attribute, !4 = $key, !5 = $atttribute
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                                       $7      !0, ->30
          4    > > FE_FETCH_R                                       ~8      $7, !3, ->30
          5    >   ASSIGN                                                   !4, ~8
   20     6        TYPE_CHECK                                  256  ~10     !3
          7        BOOL_NOT                                         ~11     ~10
          8      > JMPZ_EX                                          ~11     ~11, ->12
          9    >   TYPE_CHECK                                  128  ~12     !3
         10        BOOL_NOT                                         ~13     ~12
         11        BOOL                                             ~11     ~13
         12    > > JMPZ                                                     ~11, ->16
   21    13    >   ASSIGN_DIM                                               !2, !4
         14        OP_DATA                                                  !5
         15      > JMP                                                      ->29
   22    16    >   INSTANCEOF                                               !3, 'DateTime'
         17      > JMPZ                                                     ~15, ->24
   23    18    >   INIT_METHOD_CALL                                         !3, 'format'
         19        SEND_VAL_EX                                              'c'
         20        DO_FCALL                                      0  $17     
         21        ASSIGN_DIM                                               !2, !4
         22        OP_DATA                                                  $17
         23      > JMP                                                      ->29
   25    24    >   INIT_DYNAMIC_CALL                                        !1
         25        SEND_VAR_EX                                              !3
         26        DO_FCALL                                      0  $19     
         27        ASSIGN_DIM                                               !2, !4
         28        OP_DATA                                                  $19
   19    29    > > JMP                                                      ->4
         30    >   FE_FREE                                                  $7
   28    31      > RETURN                                                   !2
   29    32*     > RETURN                                                   null

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

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.52 ms | 1404 KiB | 15 Q