Type Hinting in PHP7

I’m happy that PHP7 has finally been released, I’ve been wanting to correctly return type hint for such a long time. You can now do this comfortably:


function getAge(int $age) : int {
return $age;

echo var_dump(getAge(43));

But more usefully, you can type hint interfaces to guarantee the classes you get returned (which is actually far, far more useful and beneficial).