3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Garage { public function create():Vehicle; } class CarGarage implements Garage { public function create():Car { return new Car(); } } class Vehicle {} class Car extends Vehicle {} $class = new CarGarage(); var_dump($class->create());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/p1m14
function name:  (null)
number of ops:  10
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   DECLARE_CLASS                                            'cargarage'
   14     1        NEW                                              $1      'CarGarage'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   15     4        INIT_FCALL                                               'var_dump'
          5        INIT_METHOD_CALL                                         !0, 'create'
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

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

End of function create

End of class Garage.

Class CarGarage:
Function create:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/p1m14
function name:  create
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   NEW                                              $0      'Car'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
    9     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function create

End of class CarGarage.

Class Vehicle: [no user functions]
Class Car: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
176.5 ms | 1395 KiB | 15 Q