3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public $foo = 'foo'; protected $bar = 'two'; private $baz = 'three'; } function objectToArray($obj) { if (is_array($obj)) { return $obj; } $array = (array) $obj; $result = array(); foreach($array as $key => $value) { $result[str_replace('*', '', $key)] = $value; } return $result; } $b = objectToArray(new Foo()); var_dump($b);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/d0GH5
function name:  (null)
number of ops:  10
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   INIT_FCALL                                               'objecttoarray'
          1        NEW                                              $1      'Foo'
          2        DO_FCALL                                      0          
          3        SEND_VAR                                                 $1
          4        DO_FCALL                                      0  $3      
          5        ASSIGN                                                   !0, $3
   26     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !0
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function objecttoarray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 4
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 18
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/d0GH5
function name:  objectToArray
number of ops:  21
compiled vars:  !0 = $obj, !1 = $array, !2 = $result, !3 = $value, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   11     1        TYPE_CHECK                                  128          !0
          2      > JMPZ                                                     ~5, ->4
   12     3    > > RETURN                                                   !0
   14     4    >   CAST                                          7  ~6      !0
          5        ASSIGN                                                   !1, ~6
   15     6        ASSIGN                                                   !2, <array>
   17     7      > FE_RESET_R                                       $9      !1, ->18
          8    > > FE_FETCH_R                                       ~10     $9, !3, ->18
          9    >   ASSIGN                                                   !4, ~10
   18    10        INIT_FCALL                                               'str_replace'
         11        SEND_VAL                                                 '%2A'
         12        SEND_VAL                                                 ''
         13        SEND_VAR                                                 !4
         14        DO_ICALL                                         $12     
         15        ASSIGN_DIM                                               !2, $12
         16        OP_DATA                                                  !3
   17    17      > JMP                                                      ->8
         18    >   FE_FREE                                                  $9
   21    19      > RETURN                                                   !2
   22    20*     > RETURN                                                   null

End of function objecttoarray

Class Foo: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.16 ms | 1399 KiB | 18 Q