3v4l.org

run code in 300+ PHP versions simultaneously
<?php # The blueprint for designing creatures for your game interface LivingBeing { public function dealDamage( $idamage); public function takeDamage( $idamage); } interface Race { public function raceName(): string; } class Human implements LivingBeing, Race { private $hp = 150; public function dealDamage( $damage) { } public function takeDamage( $damage) { } public function raceName(): string { return 'Human'; } } class Elf implements LivingBeing, Race { private $hp = 100; public function dealDamage($damage) { } public function takeDamage($damage) { } public function raceName(): string { return 'Elf'; } } class Dwarf implements LivingBeing, Race { private $hp = 300; public function dealDamage($damage) { } public function takeDamage($damage) { } public function raceName(): string { return 'Dwarf'; } } # I am a junior dev, I am just going to write this code class Centaur { private $hp = 300; public function dealDamage($opponent) { // $opponent->takeDamage(4); } public function takeDamage($damage) { } public function raceName(): string { return 'Centaur'; } } class Orc { private $hp = 300; public function dealDamage($damage) { } public function raceName(): string { return 'Centaur'; } } function listTheirRace (Race ...$list) { $string = ''; foreach ($list as $being) { $string .= $being->raceName() . "\n"; } return $string; } $Adam = new Human; $Lucas = new Elf; $Jack = new Dwarf; # Let's fight! $Gabrielle = new Centaur; $Guthakug = new Orc; echo listTheirRace(...[$Adam, $Lucas, $Jack, $Gabrielle, $Guthakug]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  (null)
number of ops:  29
compiled vars:  !0 = $Adam, !1 = $Lucas, !2 = $Jack, !3 = $Gabrielle, !4 = $Guthakug
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   DECLARE_CLASS                                            'human'
   27     1        DECLARE_CLASS                                            'elf'
   41     2        DECLARE_CLASS                                            'dwarf'
   94     3        NEW                                              $5      'Human'
          4        DO_FCALL                                      0          
          5        ASSIGN                                                   !0, $5
   96     6        NEW                                              $8      'Elf'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $8
   98     9        NEW                                              $11     'Dwarf'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $11
  102    12        NEW                                              $14     'Centaur'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !3, $14
  103    15        NEW                                              $17     'Orc'
         16        DO_FCALL                                      0          
         17        ASSIGN                                                   !4, $17
  106    18        INIT_FCALL                                               'listtheirrace'
         19        INIT_ARRAY                                       ~20     !0
         20        ADD_ARRAY_ELEMENT                                ~20     !1
         21        ADD_ARRAY_ELEMENT                                ~20     !2
         22        ADD_ARRAY_ELEMENT                                ~20     !3
         23        ADD_ARRAY_ELEMENT                                ~20     !4
         24        SEND_UNPACK                                              ~20
         25        CHECK_UNDEF_ARGS                                         
         26        DO_FCALL                                      1  $21     
         27        ECHO                                                     $21
         28      > RETURN                                                   1

Function listtheirrace:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 9
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 9
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
filename:       /in/YkLgg
function name:  listTheirRace
number of ops:  12
compiled vars:  !0 = $list, !1 = $string, !2 = $being
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   85     0  E >   RECV_VARIADIC                                    !0      
   86     1        ASSIGN                                                   !1, ''
   87     2      > FE_RESET_R                                       $4      !0, ->9
          3    > > FE_FETCH_R                                               $4, !2, ->9
   88     4    >   INIT_METHOD_CALL                                         !2, 'raceName'
          5        DO_FCALL                                      0  $5      
          6        CONCAT                                           ~6      $5, '%0A'
          7        ASSIGN_OP                                     8          !1, ~6
   87     8      > JMP                                                      ->3
          9    >   FE_FREE                                                  $4
   91    10      > RETURN                                                   !1
   92    11*     > RETURN                                                   null

End of function listtheirrace

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

End of function dealdamage

Function takedamage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  takeDamage
number of ops:  2
compiled vars:  !0 = $idamage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function takedamage

End of class LivingBeing.

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

End of function racename

End of class Race.

Class Human:
Function dealdamage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  dealDamage
number of ops:  2
compiled vars:  !0 = $damage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   17     1      > RETURN                                                   null

End of function dealdamage

Function takedamage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  takeDamage
number of ops:  2
compiled vars:  !0 = $damage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   RECV                                             !0      
   20     1      > RETURN                                                   null

End of function takedamage

Function racename:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  raceName
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   23     0  E > > RETURN                                                   'Human'
   24     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function racename

End of class Human.

Class Elf:
Function dealdamage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  dealDamage
number of ops:  2
compiled vars:  !0 = $damage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   31     1      > RETURN                                                   null

End of function dealdamage

Function takedamage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  takeDamage
number of ops:  2
compiled vars:  !0 = $damage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   RECV                                             !0      
   34     1      > RETURN                                                   null

End of function takedamage

Function racename:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  raceName
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E > > RETURN                                                   'Elf'
   38     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function racename

End of class Elf.

Class Dwarf:
Function dealdamage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  dealDamage
number of ops:  2
compiled vars:  !0 = $damage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
   45     1      > RETURN                                                   null

End of function dealdamage

Function takedamage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  takeDamage
number of ops:  2
compiled vars:  !0 = $damage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   47     0  E >   RECV                                             !0      
   48     1      > RETURN                                                   null

End of function takedamage

Function racename:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  raceName
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   51     0  E > > RETURN                                                   'Dwarf'
   52     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function racename

End of class Dwarf.

Class Centaur:
Function dealdamage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  dealDamage
number of ops:  2
compiled vars:  !0 = $opponent
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   61     0  E >   RECV                                             !0      
   63     1      > RETURN                                                   null

End of function dealdamage

Function takedamage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  takeDamage
number of ops:  2
compiled vars:  !0 = $damage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   65     0  E >   RECV                                             !0      
   66     1      > RETURN                                                   null

End of function takedamage

Function racename:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  raceName
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   69     0  E > > RETURN                                                   'Centaur'
   70     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function racename

End of class Centaur.

Class Orc:
Function dealdamage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  dealDamage
number of ops:  2
compiled vars:  !0 = $damage
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   76     0  E >   RECV                                             !0      
   77     1      > RETURN                                                   null

End of function dealdamage

Function racename:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YkLgg
function name:  raceName
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   80     0  E > > RETURN                                                   'Centaur'
   81     1*       VERIFY_RETURN_TYPE                                       
          2*     > RETURN                                                   null

End of function racename

End of class Orc.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.55 ms | 1411 KiB | 14 Q