Typed Variables

../_images/typed_variables.png

A local variable cannot be typed.

I mean, it may be typed at argument or return time, but not permanently, like a property.

To create a typed variable, one may use a reference to a property. The property may be typed, and this constraint is extended to the variable, with a dedicated message.

It works on static and normal properties. And it looks a bit cumbersome to use.

See Also

PHP Error Messages

PHP Features