Type And Reference

../_images/type_and_reference.png

Parameter’s type is check at calling time. Later, the type of the argument is not enforced anymore, and the argument behaves like a local variable: its type may change.

When typing a parameter and passing it by reference, the type is checked at call time, and then, never checked again. This means the variable may change its type, and, by consequence, the original value may also end up with a different type than expected.

If you want persistent typing, use a property: its type is checked at every step of its life.

See Also

PHP Features