3v4l.org

run code in 300+ PHP versions simultaneously
<?php $obj = (object)array( 1 => 'value of 1', 'x' => 'value of x', ); function get_real_object_vars($obj) { if (version_compare(PHP_VERSION, '5.0.0') >= 0) { class StdclassIterator implements Iterator { private $subject; public function __construct($object) { $this->subject = $object; } public function current() { return current($this->subject); } public function next() { next($this->subject); } public function key() { return key($this->subject); } public function valid() { $key = key($this->subject); return NULL !== key($this->subject); } public function rewind() { reset($this->subject); } } return iterator_to_array(new StdclassIterator($obj)); } else { return get_object_vars($obj); } } var_dump($obj, get_real_object_vars($obj));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sZoH9
function name:  (null)
number of ops:  10
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   CAST                                          8  ~1      <array>
    2     1        ASSIGN                                                   !0, ~1
   50     2        INIT_FCALL                                               'var_dump'
          3        SEND_VAR                                                 !0
          4        INIT_FCALL                                               'get_real_object_vars'
          5        SEND_VAR                                                 !0
          6        DO_FCALL                                      0  $3      
          7        SEND_VAR                                                 $3
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function get_real_object_vars:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 16
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sZoH9
function name:  get_real_object_vars
number of ops:  21
compiled vars:  !0 = $obj
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        INIT_FCALL                                               'version_compare'
          2        SEND_VAL                                                 '8.0.0'
          3        SEND_VAL                                                 '5.0.0'
          4        DO_ICALL                                         $1      
          5        IS_SMALLER_OR_EQUAL                                      0, $1
          6      > JMPZ                                                     ~2, ->16
    9     7    >   DECLARE_CLASS                                            'stdclassiterator'
   44     8        INIT_FCALL                                               'iterator_to_array'
          9        NEW                                              $3      'StdclassIterator'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
         12        SEND_VAR                                                 $3
         13        DO_ICALL                                         $5      
         14      > RETURN                                                   $5
         15*       JMP                                                      ->20
   46    16    >   INIT_FCALL                                               'get_object_vars'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                         $6      
         19      > RETURN                                                   $6
   48    20*     > RETURN                                                   null

End of function get_real_object_vars

Class StdclassIterator:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sZoH9
function name:  __construct
number of ops:  4
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   15     1        ASSIGN_OBJ                                               'subject'
          2        OP_DATA                                                  !0
   16     3      > RETURN                                                   null

End of function __construct

Function current:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sZoH9
function name:  current
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   INIT_FCALL                                               'current'
          1        FETCH_OBJ_R                                      ~0      'subject'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   21     5*     > RETURN                                                   null

End of function current

Function next:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sZoH9
function name:  next
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_FCALL                                               'next'
          1        FETCH_OBJ_W                                      $0      'subject'
          2        SEND_REF                                                 $0
          3        DO_ICALL                                                 
   26     4      > RETURN                                                   null

End of function next

Function key:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sZoH9
function name:  key
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   INIT_FCALL                                               'key'
          1        FETCH_OBJ_R                                      ~0      'subject'
          2        SEND_VAL                                                 ~0
          3        DO_ICALL                                         $1      
          4      > RETURN                                                   $1
   31     5*     > RETURN                                                   null

End of function key

Function valid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sZoH9
function name:  valid
number of ops:  12
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   INIT_FCALL                                               'key'
          1        FETCH_OBJ_R                                      ~1      'subject'
          2        SEND_VAL                                                 ~1
          3        DO_ICALL                                         $2      
          4        ASSIGN                                                   !0, $2
   36     5        INIT_FCALL                                               'key'
          6        FETCH_OBJ_R                                      ~4      'subject'
          7        SEND_VAL                                                 ~4
          8        DO_ICALL                                         $5      
          9        TYPE_CHECK                                  1020  ~6      $5
         10      > RETURN                                                   ~6
   37    11*     > RETURN                                                   null

End of function valid

Function rewind:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sZoH9
function name:  rewind
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   41     0  E >   INIT_FCALL                                               'reset'
          1        FETCH_OBJ_W                                      $0      'subject'
          2        SEND_REF                                                 $0
          3        DO_ICALL                                                 
   42     4      > RETURN                                                   null

End of function rewind

End of class StdclassIterator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.02 ms | 1407 KiB | 30 Q