3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {} interface SomeInterface { public function test() : A; } class B implements SomeInterface { public function test() : A // all good! { return null; // Fatal error: Uncaught TypeError: Return value of B::test() must be an instance of A, null returned... } } ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5SH2o
function name:  (null)
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DECLARE_CLASS                                            'b'
   17     1      > RETURN                                                   1

Class A: [no user functions]
Class SomeInterface:
Function test:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/5SH2o
function name:  test
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   VERIFY_RETURN_TYPE                                       
          1      > RETURN                                                   null

End of function test

End of class SomeInterface.

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

End of function test

End of class B.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.5 ms | 1393 KiB | 13 Q