3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface GoAlgorithm { public function go(); } class GoByDrivingAlgorithm implements GoAlgorithm { public function go() { echo("Now I'm driving."); } } class GoByFlying implements GoAlgorithm { public function go() { echo("Now I'm flying."); } } class GoByFlyingFast implements GoAlgorithm { public function go() { echo("Now I'm flying fast"); } } class Vehicle { private $goAlgorithm; public function setModeOfTransportation(GoAlgorithm $goType) { $this->goAlgorithm = $goType; } public function drive() { return $this->goAlgorithm->go(); } } $streetRacer = new Vehicle(); $formulaone = new Vehicle(); $helicopter = new Vehicle(); $jets = new Vehicle(); $streetRacer->drive(); $formulaone->drive(); $helicopter->drive(); $jets->drive();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O8Y1I
function name:  (null)
number of ops:  24
compiled vars:  !0 = $streetRacer, !1 = $formulaone, !2 = $helicopter, !3 = $jets
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   DECLARE_CLASS                                            'gobydrivingalgorithm'
   16     1        DECLARE_CLASS                                            'gobyflying'
   25     2        DECLARE_CLASS                                            'gobyflyingfast'
   49     3        NEW                                              $4      'Vehicle'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $4
   50     6        NEW                                              $7      'Vehicle'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $7
   51     9        NEW                                              $10     'Vehicle'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $10
   52    12        NEW                                              $13     'Vehicle'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !3, $13
   54    15        INIT_METHOD_CALL                                         !0, 'drive'
         16        DO_FCALL                                      0          
   55    17        INIT_METHOD_CALL                                         !1, 'drive'
         18        DO_FCALL                                      0          
   56    19        INIT_METHOD_CALL                                         !2, 'drive'
         20        DO_FCALL                                      0          
   57    21        INIT_METHOD_CALL                                         !3, 'drive'
         22        DO_FCALL                                      0          
         23      > RETURN                                                   1

Class GoAlgorithm:
Function go:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O8Y1I
function name:  go
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E > > RETURN                                                   null

End of function go

End of class GoAlgorithm.

Class GoByDrivingAlgorithm:
Function go:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O8Y1I
function name:  go
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   ECHO                                                     'Now+I%27m+driving.'
   13     1      > RETURN                                                   null

End of function go

End of class GoByDrivingAlgorithm.

Class GoByFlying:
Function go:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O8Y1I
function name:  go
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   ECHO                                                     'Now+I%27m+flying.'
   22     1      > RETURN                                                   null

End of function go

End of class GoByFlying.

Class GoByFlyingFast:
Function go:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O8Y1I
function name:  go
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   ECHO                                                     'Now+I%27m+flying+fast'
   31     1      > RETURN                                                   null

End of function go

End of class GoByFlyingFast.

Class Vehicle:
Function setmodeoftransportation:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O8Y1I
function name:  setModeOfTransportation
number of ops:  4
compiled vars:  !0 = $goType
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   38     0  E >   RECV                                             !0      
   40     1        ASSIGN_OBJ                                               'goAlgorithm'
          2        OP_DATA                                                  !0
   41     3      > RETURN                                                   null

End of function setmodeoftransportation

Function drive:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/O8Y1I
function name:  drive
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   FETCH_OBJ_R                                      ~0      'goAlgorithm'
          1        INIT_METHOD_CALL                                         ~0, 'go'
          2        DO_FCALL                                      0  $1      
          3      > RETURN                                                   $1
   46     4*     > RETURN                                                   null

End of function drive

End of class Vehicle.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.61 ms | 1399 KiB | 13 Q