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) {} } class Bar implements Test { public function check(Foo $x) {} } //this is fail, but why? Bar implements Test, so.. logically it fulfills contract.. class Baz implements Test { public function check(Baz $x) {} }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n3FZT
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                                            'bar'
   20     2        DECLARE_CLASS                                            'baz'
   23     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/n3FZT
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/n3FZT
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 Bar:
Function check:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/n3FZT
function name:  check
number of ops:  2
compiled vars:  !0 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function check

End of class Bar.

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

End of function check

End of class Baz.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.24 ms | 1394 KiB | 13 Q