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(); $streetRacer->setModeOfTransportation(new GoByDrivingAlgorithm()); $formulaone = new Vehicle(); $formulaone->setModeOfTransportation(new GoByDrivingAlgorithm()); $helicopter = new Vehicle(); $helicopter->setModeOfTransportation(new GoByFlying()); $jets = new Vehicle(); $jets->setModeOfTransportation(new GoByFlyingFast()); $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/hFBS3
function name:  (null)
number of ops:  44
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        INIT_METHOD_CALL                                         !0, 'setModeOfTransportation'
          7        NEW                                              $7      'GoByDrivingAlgorithm'
          8        DO_FCALL                                      0          
          9        SEND_VAR_NO_REF_EX                                       $7
         10        DO_FCALL                                      0          
   51    11        NEW                                              $10     'Vehicle'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !1, $10
   52    14        INIT_METHOD_CALL                                         !1, 'setModeOfTransportation'
         15        NEW                                              $13     'GoByDrivingAlgorithm'
         16        DO_FCALL                                      0          
         17        SEND_VAR_NO_REF_EX                                       $13
         18        DO_FCALL                                      0          
   53    19        NEW                                              $16     'Vehicle'
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !2, $16
   54    22        INIT_METHOD_CALL                                         !2, 'setModeOfTransportation'
         23        NEW                                              $19     'GoByFlying'
         24        DO_FCALL                                      0          
         25        SEND_VAR_NO_REF_EX                                       $19
         26        DO_FCALL                                      0          
   55    27        NEW                                              $22     'Vehicle'
         28        DO_FCALL                                      0          
         29        ASSIGN                                                   !3, $22
   56    30        INIT_METHOD_CALL                                         !3, 'setModeOfTransportation'
         31        NEW                                              $25     'GoByFlyingFast'
         32        DO_FCALL                                      0          
         33        SEND_VAR_NO_REF_EX                                       $25
         34        DO_FCALL                                      0          
   58    35        INIT_METHOD_CALL                                         !0, 'drive'
         36        DO_FCALL                                      0          
   59    37        INIT_METHOD_CALL                                         !1, 'drive'
         38        DO_FCALL                                      0          
   60    39        INIT_METHOD_CALL                                         !2, 'drive'
         40        DO_FCALL                                      0          
   61    41        INIT_METHOD_CALL                                         !3, 'drive'
         42        DO_FCALL                                      0          
         43      > RETURN                                                   1

Class GoAlgorithm:
Function go:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hFBS3
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/hFBS3
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/hFBS3
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/hFBS3
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/hFBS3
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/hFBS3
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:
151.06 ms | 1390 KiB | 13 Q