3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Father { private $son; private $foo = ''; function getFoo() { return $this->foo; } } class Son { private $father; public function __construct(Father $dad) { $this->father = $dad; } function setFoo($value) { $this->dad->setFoo($value); } } $father = new Father(); $son = new Son($father); $son->setFoo('bar'); echo $father->getFoo(); //I want it to now be 'bar'
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e4DcD
function name:  (null)
number of ops:  14
compiled vars:  !0 = $father, !1 = $son
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   NEW                                              $2      'Father'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   31     3        NEW                                              $5      'Son'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
   33     7        INIT_METHOD_CALL                                         !1, 'setFoo'
          8        SEND_VAL_EX                                              'bar'
          9        DO_FCALL                                      0          
   35    10        INIT_METHOD_CALL                                         !0, 'getFoo'
         11        DO_FCALL                                      0  $9      
         12        ECHO                                                     $9
         13      > RETURN                                                   1

Class Father:
Function getfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e4DcD
function name:  getFoo
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                      ~0      'foo'
          1      > RETURN                                                   ~0
   12     2*     > RETURN                                                   null

End of function getfoo

End of class Father.

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

End of function __construct

Function setfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/e4DcD
function name:  setFoo
number of ops:  6
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   26     1        FETCH_OBJ_R                                      ~1      'dad'
          2        INIT_METHOD_CALL                                         ~1, 'setFoo'
          3        SEND_VAR_EX                                              !0
          4        DO_FCALL                                      0          
   27     5      > RETURN                                                   null

End of function setfoo

End of class Son.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.18 ms | 1395 KiB | 13 Q