<?php
interface RegularInterface {}
interface BetterInterface extends RegularInterface {}
class Thing implements BetterInterface {
}
class RegularClass {
public static function doSomething(RegularInterface $thing) {
echo 'hello';
}
}
class BetterClass extends RegularClass {
// Attempt to specify a more specific typehint.
public static function doSomething(BetterInterface $thing) {
echo 'hello';
}
}
$thing = new Thing();
BetterClass::doSomething($thing);
Fatal error: Declaration of BetterClass::doSomething(BetterInterface $thing) must be compatible with RegularClass::doSomething(RegularInterface $thing) in /in/b1C4e on line 17
Process exited with code 255.
Output for 7.4.0 - 7.4.33
Warning: Declaration of BetterClass::doSomething(BetterInterface $thing) should be compatible with RegularClass::doSomething(RegularInterface $thing) in /in/b1C4e on line 17
hello
Warning: Declaration of BetterClass::doSomething(BetterInterface $thing) should be compatible with RegularClass::doSomething(RegularInterface $thing) in /in/b1C4e on line 20
hello
Strict Standards: Declaration of BetterClass::doSomething() should be compatible with RegularClass::doSomething(RegularInterface $thing) in /in/b1C4e on line 20
hello
Strict Standards: Declaration of BetterClass::doSomething() should be compatible with that of RegularClass::doSomething() in /in/b1C4e on line 20
hello
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/b1C4e on line 3
Process exited with code 255.