3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Food {} class AnimalFood extends Food {} abstract class Animal { protected string $name; public function __construct(string $name) { $this->name = $name; } public function eat(AnimalFood $food) { echo $this->name . " eats " . get_class($food); } } class Dog extends Animal { public function eat(Food $food) { echo $this->name . " eats " . get_class($food); } } $kitty = (new CatShelter)->adopt("Ricky"); $catFood = new AnimalFood(); $kitty->eat($catFood); echo "\n"; $doggy = (new DogShelter)->adopt("Mavrick"); $banana = new Food(); $doggy->eat($banana);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sa7LG
function name:  (null)
number of ops:  26
compiled vars:  !0 = $kitty, !1 = $catFood, !2 = $doggy, !3 = $banana
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   NEW                                              $4      'CatShelter'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $4, 'adopt'
          3        SEND_VAL_EX                                              'Ricky'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !0, $6
   30     6        NEW                                              $8      'AnimalFood'
          7        DO_FCALL                                      0          
          8        ASSIGN                                                   !1, $8
   31     9        INIT_METHOD_CALL                                         !0, 'eat'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0          
   32    12        ECHO                                                     '%0A'
   34    13        NEW                                              $12     'DogShelter'
         14        DO_FCALL                                      0          
         15        INIT_METHOD_CALL                                         $12, 'adopt'
         16        SEND_VAL_EX                                              'Mavrick'
         17        DO_FCALL                                      0  $14     
         18        ASSIGN                                                   !2, $14
   35    19        NEW                                              $16     'Food'
         20        DO_FCALL                                      0          
         21        ASSIGN                                                   !3, $16
   36    22        INIT_METHOD_CALL                                         !2, 'eat'
         23        SEND_VAR_EX                                              !3
         24        DO_FCALL                                      0          
         25      > RETURN                                                   1

Class Food: [no user functions]
Class AnimalFood: [no user functions]
Class Animal:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sa7LG
function name:  __construct
number of ops:  4
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        ASSIGN_OBJ                                               'name'
          2        OP_DATA                                                  !0
   14     3      > RETURN                                                   null

End of function __construct

Function eat:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sa7LG
function name:  eat
number of ops:  7
compiled vars:  !0 = $food
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
   18     1        FETCH_OBJ_R                                      ~1      'name'
          2        CONCAT                                           ~2      ~1, '+eats+'
          3        GET_CLASS                                        ~3      !0
          4        CONCAT                                           ~4      ~2, ~3
          5        ECHO                                                     ~4
   19     6      > RETURN                                                   null

End of function eat

End of class Animal.

Class Dog:
Function eat:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/sa7LG
function name:  eat
number of ops:  7
compiled vars:  !0 = $food
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   RECV                                             !0      
   25     1        FETCH_OBJ_R                                      ~1      'name'
          2        CONCAT                                           ~2      ~1, '+eats+'
          3        GET_CLASS                                        ~3      !0
          4        CONCAT                                           ~4      ~2, ~3
          5        ECHO                                                     ~4
   26     6      > RETURN                                                   null

End of function eat

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

End of function __construct

End of class Dog.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.23 ms | 1399 KiB | 13 Q