3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {} class B extends A {} class C { public function test() : A { return new A; } } class D extends C { // overriding method C::test() : A public function test() : B // Fatal error due to variance mismatch { return new B; } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t2fYQ
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E > > RETURN                                                   1

Class A: [no user functions]
Class B: [no user functions]
Class C:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/t2fYQ
function name:  test
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   NEW                                              $0      'A'
          1        DO_FCALL                                      0          
          2        VERIFY_RETURN_TYPE                                       $0
          3      > RETURN                                                   $0
   11     4*       VERIFY_RETURN_TYPE                                       
          5*     > RETURN                                                   null

End of function test

End of class C.

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

End of function test

End of class D.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.69 ms | 1398 KiB | 13 Q