PHP 8.5.0 Alpha 2 available for testing

Voting

: min(five, zero)?
(Example: nine)

The Note You're Voting On

Anonymous
5 years ago
Covariance also works with general type-hinting, note also the interface:

interface xInterface
{
public function y() : object;
}

abstract class x implements xInterface
{
abstract public function y() : object;
}

class a extends x
{
public function y() : \DateTime
{
return new \DateTime("now");
}
}

$a = new a;
echo '<pre>';
var_dump($a->y());
echo '</pre>';

<< Back to user notes page

To Top