3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Ancestor { protected $val = 'ancestor'; } class Child1 extends Ancestor { function __construct() { $this->val = 'child1'; } } class Child2 extends Ancestor { function output(Ancestor $subject) { $subject->val = 'surprise motherfucker'; echo $subject->val, "\n"; } } $child1 = new Child1(); $child2 = new Child2(); $child2->output($child1); // Output: child1
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Kn3M9
function name:  (null)
number of ops:  10
compiled vars:  !0 = $child1, !1 = $child2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   NEW                                              $2      'Child1'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   33     3        NEW                                              $5      'Child2'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !1, $5
   35     6        INIT_METHOD_CALL                                         !1, 'output'
          7        SEND_VAR_EX                                              !0
          8        DO_FCALL                                      0          
   36     9      > RETURN                                                   1

Class Ancestor: [no user functions]
Class Child1:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Kn3M9
function name:  __construct
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN_OBJ                                               'val'
          1        OP_DATA                                                  'child1'
   16     2      > RETURN                                                   null

End of function __construct

End of class Child1.

Class Child2:
Function output:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Kn3M9
function name:  output
number of ops:  7
compiled vars:  !0 = $subject
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   24     1        ASSIGN_OBJ                                               !0, 'val'
          2        OP_DATA                                                  'surprise+motherfucker'
   26     3        FETCH_OBJ_R                                      ~2      !0, 'val'
          4        ECHO                                                     ~2
          5        ECHO                                                     '%0A'
   28     6      > RETURN                                                   null

End of function output

End of class Child2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.56 ms | 1394 KiB | 13 Q