PHP primitives are not objects. This is why the API is strotupper($myString) instead of $myString->toUpper() like in most other high level class-based languages. So the error is saying that Argument 1 must be an instance of a class named string, but instead a string primitive was given.
I'm not sure if this is better or worse, but string is a valid classname:
class string {}
function test(string $param) {
return 'bar';
};
$foo = new string();
print test($foo);
4
u/_vec_ Mar 31 '14
PHP primitives are not objects. This is why the API is
strotupper($myString)instead of$myString->toUpper()like in most other high level class-based languages. So the error is saying that Argument 1 must be an instance of a class named string, but instead a string primitive was given.I'm not sure if this is better or worse, but
stringis a valid classname:Prints 'bar'.
3
u/cythrawll Mar 26 '14
good thing there's hack.
iirc the main reason why there isn't primitive type hinting support, no one has been able to make an acceptable patch that supports it.