Last active
January 31, 2019 23:22
-
-
Save yoander/76824e1e89273d46dca9f1cc4fa5de92 to your computer and use it in GitHub Desktop.
This file contains 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 | |
abstract class A | |
{ | |
abstract function test(string $s); | |
} | |
abstract class B extends A | |
{ | |
abstract function test($s) : int; | |
} |
This file contains 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
Fatal error: Declaration of B::test(string $s): int must be compatible with A::test($s) |
This file contains 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 | |
abstract class A | |
{ | |
abstract function test($s); | |
} | |
abstract class B extends A | |
{ | |
abstract function test(string $s) : int; | |
} |
This file contains 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 | |
function test(object $obj): object | |
{ | |
echo 'Param is type of: ', gettype($obj), nl2br("\n"); | |
return new SplQueue(); | |
} | |
$result = test(new StdClass()); | |
echo 'Return is type of: ', gettype($result), nl2br("\n"); | |
// Param is type of: object | |
// Return is type of: object |
This file contains 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 | |
interface A | |
{ | |
public function test(array $input); | |
} | |
class B implements A | |
{ | |
public function test($input) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment