Skip to content

Instantly share code, notes, and snippets.

@yoander
Last active January 31, 2019 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoander/76824e1e89273d46dca9f1cc4fa5de92 to your computer and use it in GitHub Desktop.
Save yoander/76824e1e89273d46dca9f1cc4fa5de92 to your computer and use it in GitHub Desktop.
<?php
abstract class A
{
abstract function test(string $s);
}
abstract class B extends A
{
abstract function test($s) : int;
}
Fatal error: Declaration of B::test(string $s): int must be compatible with A::test($s)
<?php
abstract class A
{
abstract function test($s);
}
abstract class B extends A
{
abstract function test(string $s) : int;
}
<?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");
// Print
// Param is type of: object
// Return is type of: object
<?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