3v4l.org

run code in 300+ PHP versions simultaneously
<?php class B { public function __get($name) { $this->__set($name, new C); return $this->$name; } public function __set($name, $value) { $this->$name = $value; } } class C { public function test() { return new D; } } class D { public $d; } $b = new B; $b->c->test()->d = 'waa'; echo 'first call success' . PHP_EOL; $b->c->test(); echo 'just a call to test() works' . PHP_EOL; $b->c->test()->d = 'waa'; echo 'second call success' . PHP_EOL;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bMKbI
function name:  (null)
number of ops:  22
compiled vars:  !0 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   NEW                                              $1      'B'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   32     3        FETCH_OBJ_R                                      ~4      !0, 'c'
          4        INIT_METHOD_CALL                                         ~4, 'test'
          5        DO_FCALL                                      0  $5      
          6        SEPARATE                                         $5      $5
          7        ASSIGN_OBJ                                               $5, 'd'
          8        OP_DATA                                                  'waa'
   33     9        ECHO                                                     'first+call+success%0A'
   35    10        FETCH_OBJ_R                                      ~7      !0, 'c'
         11        INIT_METHOD_CALL                                         ~7, 'test'
         12        DO_FCALL                                      0          
   36    13        ECHO                                                     'just+a+call+to+test%28%29+works%0A'
   38    14        FETCH_OBJ_R                                      ~9      !0, 'c'
         15        INIT_METHOD_CALL                                         ~9, 'test'
         16        DO_FCALL                                      0  $10     
         17        SEPARATE                                         $10     $10
         18        ASSIGN_OBJ                                               $10, 'd'
         19        OP_DATA                                                  'waa'
   39    20        ECHO                                                     'second+call+success%0A'
         21      > RETURN                                                   1

Class B:
Function __get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bMKbI
function name:  __get
number of ops:  10
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        INIT_METHOD_CALL                                         '__set'
          2        SEND_VAR_EX                                              !0
          3        NEW                                              $1      'C'
          4        DO_FCALL                                      0          
          5        SEND_VAR_NO_REF_EX                                       $1
          6        DO_FCALL                                      0          
    8     7        FETCH_OBJ_R                                      ~4      !0
          8      > RETURN                                                   ~4
    9     9*     > RETURN                                                   null

End of function __get

Function __set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bMKbI
function name:  __set
number of ops:  5
compiled vars:  !0 = $name, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   13     2        ASSIGN_OBJ                                               !0
          3        OP_DATA                                                  !1
   14     4      > RETURN                                                   null

End of function __set

End of class B.

Class C:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/bMKbI
function name:  test
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $0      'D'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
   22     3*     > RETURN                                                   null

End of function test

End of class C.

Class D: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.34 ms | 1399 KiB | 13 Q