Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?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