3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Test { public function check(Test $x); } //this is ok: class Foo implements Test { public function check(Test $x) {} } interface BarInterface extends Test {}; //this is fail, but why? Bar implements Test, so.. logically it fulfills contract.. class Bar implements BarInterface { public function check(Foo $x) {} }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EAvUE
function name:  (null)
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   DECLARE_CLASS                                            'foo'
   14     1        DECLARE_CLASS                                            'barinterface'
   18     2        DECLARE_CLASS                                            'bar'
   21     3      > RETURN                                                   1

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

End of function check

End of class Test.

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

End of function check

End of class Foo.

Class BarInterface: [no user functions]
Class Bar:
Function check:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EAvUE
function name:  check
number of ops:  2
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function check

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
170.2 ms | 1394 KiB | 13 Q