As you may know you can add strict types for a function parameters in PHP i.e.
public function func1(string $test)
{}
and this may be some simple function in some Zend Framework standard model! Now the problem comes with the instance of this function. If you call it like this:
func1('foo bar');
in a ZF controller, you simply will get an error.
It is strange …
isn’t it! But in PHP you can use strict types only for an array, which is built in type. In other words if some object implements the __toString() method than you can use string strict type.
Related posts:










Actually, the only types you can use for type hinting in PHP are “array”, “object”, and any interface or class name — and that’s it. You cannot hint on any of the scalar types (string, bool, int, float, etc.).
Absolutely!