Last active
November 25, 2016 16:01
-
-
Save alcaeus/8dd2d4ca3be37f9ca7d2009cd644ad84 to your computer and use it in GitHub Desktop.
Extending interfaces
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types = 1); | |
class FooImplementation implements FooInterface | |
{ | |
// Note: this throws an error in PHP 7.1: | |
// Declaration of FooImplementation::doSomething(): FooImplementation must be compatible with FooInterface::doSomething(): FooInterface | |
public function doSomething(): FooImplementation | |
{ | |
return $this; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types = 1); | |
interface FooInterface | |
{ | |
public function doSomething(): FooInterface; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment