Tag Archives: strict type

Strict types in Zend Framework and in PHP

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.