3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A{ public function sum($num1, $num2){ return $num1 + $num2; } } class B { public $property; public function __construct($object) { $this->property = $object; } } $obj = new A(); $test = new B($obj); echo $test->property->sum(1,2),"\n"; // output 3 // another: trait AA { public function sum($num1, $num2){ return $num1 + $num2; } } class BB { use AA; } $test = new BB(); echo $test->sum(2,3); // output 5
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SFF1I
function name:  (null)
number of ops:  24
compiled vars:  !0 = $obj, !1 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $2      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   16     3        NEW                                              $5      'B'
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !1, $5
   18     7        FETCH_OBJ_R                                      ~8      !1, 'property'
          8        INIT_METHOD_CALL                                         ~8, 'sum'
          9        SEND_VAL_EX                                              1
         10        SEND_VAL_EX                                              2
         11        DO_FCALL                                      0  $9      
         12        ECHO                                                     $9
         13        ECHO                                                     '%0A'
   27    14        DECLARE_CLASS                                            'bb'
   32    15        NEW                                              $10     'BB'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !1, $10
   34    18        INIT_METHOD_CALL                                         !1, 'sum'
         19        SEND_VAL_EX                                              2
         20        SEND_VAL_EX                                              3
         21        DO_FCALL                                      0  $13     
         22        ECHO                                                     $13
         23      > RETURN                                                   1

Class A:
Function sum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SFF1I
function name:  sum
number of ops:  5
compiled vars:  !0 = $num1, !1 = $num2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    4     2        ADD                                              ~2      !0, !1
          3      > RETURN                                                   ~2
    5     4*     > RETURN                                                   null

End of function sum

End of class A.

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

End of function __construct

End of class B.

Class AA:
Function sum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SFF1I
function name:  sum
number of ops:  5
compiled vars:  !0 = $num1, !1 = $num2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   23     2        ADD                                              ~2      !0, !1
          3      > RETURN                                                   ~2
   24     4*     > RETURN                                                   null

End of function sum

End of class AA.

Class BB: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.34 ms | 1399 KiB | 13 Q