I just updated my app to use php7 typehints for scalar types. When i run my unit tests, i got this error :
PHP Fatal error: Default value for parameters with a class type can only be NULL in xxx.php on line 23
The error is in this function :
public function call(string $url, integer $timeout = 30)
{
// some code...
}
If i replace integer
with int
the error disappears. I always heard that int and integer is the same I don't see anything related to this in the documentation...
The php error seems to say that integer is a class and not a scalar type.
Moreover, ((int) 1) === ((integer) 1)
returns true suggesting again that int and integer are the same
I use php 7.0.8
According to the documentation these are the valid types:
Class name
Interface name
self
array
callable
bool
float
int
string
Also there's this:
Warning
Aliases for the above scalar types are not supported. Instead, they are treated as class or interface names. For example, using boolean as a parameter or return type will require an argument or return value that is an instanceof the class or interface boolean, rather than of type bool.
Source: http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With