3v4l.org

run code in 300+ PHP versions simultaneously
<?php abstract class Animal { protected $name; public function __construct(string $name) { $this->name = $name; } abstract public function speak(); } class Dog extends Animal { public function speak() { echo $this->name . " barks"; } } class Cat extends Animal { public function speak() { echo $this->name . " meows"; } } interface AnimalShelter { public static function adopt(string $name): Animal; } class CatShelter implements AnimalShelter { public static function adopt(string $name): Cat { return new Cat($name); } } class DogShelter implements AnimalShelter { public static function adopt(string $name): Dog { return new Dog($name); } } $kitty = CatShelter::adopt("Ricky"); $kitty->speak(); echo "\n"; $doggy = DogShelter::adopt("Mavrick"); $doggy->speak();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nJT9R
function name:  (null)
number of ops:  16
compiled vars:  !0 = $kitty, !1 = $doggy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   34     0  E >   DECLARE_CLASS                                            'catshelter'
   42     1        DECLARE_CLASS                                            'dogshelter'
   50     2        INIT_STATIC_METHOD_CALL                                  'CatShelter', 'adopt'
          3        SEND_VAL_EX                                              'Ricky'
          4        DO_FCALL                                      0  $2      
          5        ASSIGN                                                   !0, $2
   51     6        INIT_METHOD_CALL                                         !0, 'speak'
          7        DO_FCALL                                      0          
   52     8        ECHO                                                     '%0A'
   54     9        INIT_STATIC_METHOD_CALL                                  'DogShelter', 'adopt'
         10        SEND_VAL_EX                                              'Mavrick'
         11        DO_FCALL                                      0  $5      
         12        ASSIGN                                                   !1, $5
   55    13        INIT_METHOD_CALL                                         !1, 'speak'
         14        DO_FCALL                                      0          
         15      > RETURN                                                   1

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

End of function __construct

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

End of function speak

End of class Animal.

Class Dog:
Function speak:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nJT9R
function name:  speak
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1        CONCAT                                           ~1      ~0, '+barks'
          2        ECHO                                                     ~1
   19     3      > RETURN                                                   null

End of function speak

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

End of function __construct

End of class Dog.

Class Cat:
Function speak:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nJT9R
function name:  speak
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   FETCH_OBJ_R                                      ~0      'name'
          1        CONCAT                                           ~1      ~0, '+meows'
          2        ECHO                                                     ~1
   26     3      > RETURN                                                   null

End of function speak

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

End of function __construct

End of class Cat.

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

End of function adopt

End of class AnimalShelter.

Class CatShelter:
Function adopt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nJT9R
function name:  adopt
number of ops:  8
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   RECV                                             !0      
   38     1        NEW                                              $1      'Cat'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        VERIFY_RETURN_TYPE                                       $1
          5      > RETURN                                                   $1
   39     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function adopt

End of class CatShelter.

Class DogShelter:
Function adopt:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nJT9R
function name:  adopt
number of ops:  8
compiled vars:  !0 = $name
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   44     0  E >   RECV                                             !0      
   46     1        NEW                                              $1      'Dog'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        VERIFY_RETURN_TYPE                                       $1
          5      > RETURN                                                   $1
   47     6*       VERIFY_RETURN_TYPE                                       
          7*     > RETURN                                                   null

End of function adopt

End of class DogShelter.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.1 ms | 1004 KiB | 13 Q