3v4l.org

run code in 300+ PHP versions simultaneously
<?php /* class Pont { } $towerBridge = new Pont; $towerBridge->__construct(12.2, 43.1); */ class Player { private int $level; private Weapon $weapon; public function __construct(int $level) { $this->level = $level; } public function getLevel(): int { return $this->level; } public function setLevel(int $level) : void { $this->level = $level; } public function getWeapon(): Weapon { return $this->weapon; } public function setWeapon(Weapon $weapon) : void { $this->weapon = $weapon; } } class Weapon { private string $name; private int $attack; public function __construct(string $name, int $attack) { $this->name = $name; $this->attack = $attack; } public function getName(): string { return $this->name; } public function setName(string $name) : void { $this->name = $name; } public function getAttack(): int { return $this->attack; } public function setAttack(int $attack) : void { $this->attack = $attack; } } $masterSword = new Weapon("Master Sword", 1000); $link = new Player(4); $link->setWeapon($masterSword); echo "Link est de niveau ".$link->getLevel()."et il possède la ".$link->getWeapon()->name;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6vvOu
function name:  (null)
number of ops:  22
compiled vars:  !0 = $masterSword, !1 = $link
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   77     0  E >   NEW                                              $2      'Weapon'
          1        SEND_VAL_EX                                              'Master+Sword'
          2        SEND_VAL_EX                                              1000
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !0, $2
   78     5        NEW                                              $5      'Player'
          6        SEND_VAL_EX                                              4
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $5
   79     9        INIT_METHOD_CALL                                         !1, 'setWeapon'
         10        SEND_VAR_EX                                              !0
         11        DO_FCALL                                      0          
   81    12        INIT_METHOD_CALL                                         !1, 'getLevel'
         13        DO_FCALL                                      0  $9      
         14        CONCAT                                           ~10     'Link+est+de+niveau+', $9
         15        CONCAT                                           ~11     ~10, 'et+il+poss%C3%A8de+la+'
         16        INIT_METHOD_CALL                                         !1, 'getWeapon'
         17        DO_FCALL                                      0  $12     
         18        FETCH_OBJ_R                                      ~13     $12, 'name'
         19        CONCAT                                           ~14     ~11, ~13
         20        ECHO                                                     ~14
   82    21      > RETURN                                                   1

Class Player:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6vvOu
function name:  __construct
number of ops:  4
compiled vars:  !0 = $level
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        ASSIGN_OBJ                                               'level'
          2        OP_DATA                                                  !0
   21     3      > RETURN                                                   null

End of function __construct

Function getlevel:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6vvOu
function name:  getLevel
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   FETCH_OBJ_R                                      ~0      'level'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   26     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getlevel

Function setlevel:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6vvOu
function name:  setLevel
number of ops:  4
compiled vars:  !0 = $level
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   RECV                                             !0      
   30     1        ASSIGN_OBJ                                               'level'
          2        OP_DATA                                                  !0
   31     3      > RETURN                                                   null

End of function setlevel

Function getweapon:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6vvOu
function name:  getWeapon
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   35     0  E >   FETCH_OBJ_R                                      ~0      'weapon'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   36     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getweapon

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

End of function setweapon

End of class Player.

Class Weapon:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6vvOu
function name:  __construct
number of ops:  7
compiled vars:  !0 = $name, !1 = $attack
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   49     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   51     2        ASSIGN_OBJ                                               'name'
          3        OP_DATA                                                  !0
   52     4        ASSIGN_OBJ                                               'attack'
          5        OP_DATA                                                  !1
   53     6      > RETURN                                                   null

End of function __construct

Function getname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6vvOu
function name:  getName
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   58     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getname

Function setname:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6vvOu
function name:  setName
number of ops:  4
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   60     0  E >   RECV                                             !0      
   62     1        ASSIGN_OBJ                                               'name'
          2        OP_DATA                                                  !0
   63     3      > RETURN                                                   null

End of function setname

Function getattack:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6vvOu
function name:  getAttack
number of ops:  5
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   67     0  E >   FETCH_OBJ_R                                      ~0      'attack'
          1        VERIFY_RETURN_TYPE                                       ~0
          2      > RETURN                                                   ~0
   68     3*       VERIFY_RETURN_TYPE                                       
          4*     > RETURN                                                   null

End of function getattack

Function setattack:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6vvOu
function name:  setAttack
number of ops:  4
compiled vars:  !0 = $attack
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   70     0  E >   RECV                                             !0      
   72     1        ASSIGN_OBJ                                               'attack'
          2        OP_DATA                                                  !0
   73     3      > RETURN                                                   null

End of function setattack

End of class Weapon.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.84 ms | 1403 KiB | 13 Q