3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TestClass { public $prop2 = "test"; } class TestClass2 { public $prop; public function __construct() { $prop = new TestClass(); } } function deepProperty($obj,$property,$value = null) { $curObj = &$obj; $properties = explode('.',$property); while(count($properties) > 2) $curObj = $curObj->{array_unshift($properties)}; if ($value != null) $curObj->{$properties[0]} = $value; return $curObj->{$properties[0]}; } $object = new TestClass2(); echo deepProperty($object,"prop.prop2");
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AjtGd
function name:  (null)
number of ops:  9
compiled vars:  !0 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'TestClass2'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   28     3        INIT_FCALL                                               'deepproperty'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 'prop.prop2'
          6        DO_FCALL                                      0  $4      
          7        ECHO                                                     $4
          8      > RETURN                                                   1

Function deepproperty:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 10
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 23
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 10
Branch analysis from position: 18
Branch analysis from position: 10
filename:       /in/AjtGd
function name:  deepProperty
number of ops:  27
compiled vars:  !0 = $obj, !1 = $property, !2 = $value, !3 = $curObj, !4 = $properties
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
   17     3        ASSIGN_REF                                               !3, !0
   18     4        INIT_FCALL                                               'explode'
          5        SEND_VAL                                                 '.'
          6        SEND_VAR                                                 !1
          7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !4, $6
   19     9      > JMP                                                      ->15
   20    10    >   INIT_FCALL                                               'array_unshift'
         11        SEND_REF                                                 !4
         12        DO_ICALL                                         $8      
         13        FETCH_OBJ_R                                      ~9      !3, $8
         14        ASSIGN                                                   !3, ~9
   19    15    >   COUNT                                            ~11     !4
         16        IS_SMALLER                                               2, ~11
         17      > JMPNZ                                                    ~12, ->10
   21    18    >   IS_NOT_EQUAL                                             !2, null
         19      > JMPZ                                                     ~13, ->23
   22    20    >   FETCH_DIM_R                                      ~14     !4, 0
         21        ASSIGN_OBJ                                               !3, ~14
         22        OP_DATA                                                  !2
   23    23    >   FETCH_DIM_R                                      ~16     !4, 0
         24        FETCH_OBJ_R                                      ~17     !3, ~16
         25      > RETURN                                                   ~17
   24    26*     > RETURN                                                   null

End of function deepproperty

Class TestClass: [no user functions]
Class TestClass2:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/AjtGd
function name:  __construct
number of ops:  4
compiled vars:  !0 = $prop
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $1      'TestClass'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   13     3      > RETURN                                                   null

End of function __construct

End of class TestClass2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.68 ms | 1394 KiB | 18 Q