3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $bar; function getBar() { return $this->bar; } function setBar($bar) { $this->bar = $bar; } function get_object_vars() { return get_object_vars($this); } } $f = new Foo(); $f->setBar('x'); foreach($f->get_object_vars() as $k) { $keys[] = $k; $getter = 'get'.ucfirst($k); $values[] = call_user_func(array($f, $getter)); } var_dump($keys, $values);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 24
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 24
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 24
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 24
filename:       /in/6cTF0
function name:  (null)
number of ops:  30
compiled vars:  !0 = $f, !1 = $k, !2 = $keys, !3 = $getter, !4 = $values
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   NEW                                              $5      'Foo'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $5
   20     3        INIT_METHOD_CALL                                         !0, 'setBar'
          4        SEND_VAL_EX                                              'x'
          5        DO_FCALL                                      0          
   22     6        INIT_METHOD_CALL                                         !0, 'get_object_vars'
          7        DO_FCALL                                      0  $9      
          8      > FE_RESET_R                                       $10     $9, ->24
          9    > > FE_FETCH_R                                               $10, !1, ->24
   23    10    >   ASSIGN_DIM                                               !2
         11        OP_DATA                                                  !1
   24    12        INIT_FCALL                                               'ucfirst'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                         $12     
         15        CONCAT                                           ~13     'get', $12
         16        ASSIGN                                                   !3, ~13
   25    17        INIT_ARRAY                                       ~16     !0
         18        ADD_ARRAY_ELEMENT                                ~16     !3
         19        INIT_USER_CALL                                0          'call_user_func', ~16
         20        DO_FCALL                                      0  $17     
         21        ASSIGN_DIM                                               !4
         22        OP_DATA                                                  $17
   22    23      > JMP                                                      ->9
         24    >   FE_FREE                                                  $10
   28    25        INIT_FCALL                                               'var_dump'
         26        SEND_VAR                                                 !2
         27        SEND_VAR                                                 !4
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Class Foo:
Function getbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6cTF0
function name:  getBar
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   FETCH_OBJ_R                                      ~0      'bar'
          1      > RETURN                                                   ~0
    8     2*     > RETURN                                                   null

End of function getbar

Function setbar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6cTF0
function name:  setBar
number of ops:  4
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
   11     1        ASSIGN_OBJ                                               'bar'
          2        OP_DATA                                                  !0
   12     3      > RETURN                                                   null

End of function setbar

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

End of function get_object_vars

End of class Foo.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
190.47 ms | 1400 KiB | 19 Q