Thoughts on PHP7 typing

PHP is stupid because it doesn't check the code when compiling on possible type errors - only checking on syntax errors is being made. It means that if somewhere in your code there is function a which takes one array argument and there is a place where you call thise function a passing on one *non* array argument PHP won't say anything untill execution.

Here is a simple code to represent my thought. SAy you have a file source.php with following code:

function a(array $aa) : bool
{
	return is_array($aa);
}

a('aaa');

If you enable send opcache in php.ini and try to compile this file with opcache_compile_file(...) it says true:


var_dump(opcache_compile_file('/path/to/source.php'));

Keep dreaming of *true* compile in PHP.

Probably the only thing where types might be useful (with current php7 implementation) is typehinting but it worked already in 5 version. So I don't see any benefits on typing in PHP. It doesn't warn about possible errors as it does gcc or other compilers (c++, erlang, go). And I think any other choice is better than PHP, unless PHP is the most familiar language for the team.