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( A $object=null) { $property = $object; } } $test = new B(new A); echo $test->property->sum(1,2); // output 3
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8KJFo
function name:  (null)
number of ops:  13
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $1      'B'
          1        NEW                                              $2      'A'
          2        DO_FCALL                                      0          
          3        SEND_VAR_NO_REF_EX                                       $2
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $1
   18     6        FETCH_OBJ_R                                      ~6      !0, 'property'
          7        INIT_METHOD_CALL                                         ~6, 'sum'
          8        SEND_VAL_EX                                              1
          9        SEND_VAL_EX                                              2
         10        DO_FCALL                                      0  $7      
         11        ECHO                                                     $7
         12      > RETURN                                                   1

Class A:
Function sum:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8KJFo
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/8KJFo
function name:  __construct
number of ops:  3
compiled vars:  !0 = $object, !1 = $property
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV_INIT                                        !0      null
   12     1        ASSIGN                                                   !1, !0
   13     2      > RETURN                                                   null

End of function __construct

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.4 ms | 1394 KiB | 13 Q