3v4l.org

run code in 500+ PHP versions simultaneously
<?php class Sample { private $name; // Name is required! public function __construct($name) { $this->setName($name); } public function setName($name) { $this->name = $name; } public function getName() { return $this->name; } } class ModuleSample { /** * @var Sample */ private $originalSample; public function __construct(Sample $originalSample) { $this->originalSample = $originalSample; } public function __call($methodName, $arguments) { return $this->originalSample->$methodName(...$arguments); } } $sample = new Sample("John"); $moduleSample = new ModuleSample($sample); $moduleSample->setName("Andrew"); echo $moduleSample->getName(); // Should print "Andrew"
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pfWTh
function name:  (null)
number of ops:  15
compiled vars:  !0 = $sample, !1 = $moduleSample
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   40     0  E >   NEW                                                  $2      'Sample'
          1        SEND_VAL_EX                                                  'John'
          2        DO_FCALL                                          0          
          3        ASSIGN                                                       !0, $2
   41     4        NEW                                                  $5      'ModuleSample'
          5        SEND_VAR_EX                                                  !0
          6        DO_FCALL                                          0          
          7        ASSIGN                                                       !1, $5
   42     8        INIT_METHOD_CALL                                             !1, 'setName'
          9        SEND_VAL_EX                                                  'Andrew'
         10        DO_FCALL                                          0          
   43    11        INIT_METHOD_CALL                                             !1, 'getName'
         12        DO_FCALL                                          0  $9      
         13        ECHO                                                         $9
         14      > RETURN                                                       1

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

End of function __construct

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

End of function setname

Function getname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pfWTh
function name:  getName
number of ops:  3
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   18     0  E >   FETCH_OBJ_R                                          ~0      'name'
          1      > RETURN                                                       ~0
   19     2*     > RETURN                                                       null

End of function getname

End of class Sample.

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

End of function __construct

Function __call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pfWTh
function name:  __call
number of ops:  9
compiled vars:  !0 = $methodName, !1 = $arguments
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   34     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   36     2        FETCH_OBJ_R                                          ~2      'originalSample'
          3        INIT_METHOD_CALL                                             ~2, !0
          4        SEND_UNPACK                                                  !1
          5        CHECK_UNDEF_ARGS                                             
          6        DO_FCALL                                          1  $3      
          7      > RETURN                                                       $3
   37     8*     > RETURN                                                       null

End of function __call

End of class ModuleSample.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
169.88 ms | 3075 KiB | 13 Q