php 7.0 typehint:整数和默认值的致命错误

ᴄʀᴏ*_*ᴢᴇᴛ 3 php php-7

我刚刚更新了我的应用程序,使用php7 typehints作为标量类型.当我运行我的单元测试时,我收到了这个错误:

PHP致命错误:具有类类型的参数的默认值在第23行的xxx.php中只能为NULL

错误在于此功能:

public function call(string $url, integer $timeout = 30)
{
    // some code...
}
Run Code Online (Sandbox Code Playgroud)

如果我更换integerint错误消失.我总是听说int和integer是相同的我在文档中没有看到任何与此相关的内容......

php错误似乎说整数是一个类而不是标量类型.

此外,((int) 1) === ((integer) 1)返回true表明int和integer是相同的

我用的是php 7.0.8

小智 13

根据文档,这些是有效的类型:

Class name
Interface name
self
array
callable
bool
float
int
string
Run Code Online (Sandbox Code Playgroud)

还有这个:

警告

不支持上述标量类型的别名.相反,它们被视为类或接口名称.例如,使用boolean作为参数或返回类型将需要一个参数或返回值,该值是类或接口boolean的实例,而不是bool类型.

资料来源:http://php.net/manual/en/functions.arguments.php#functions.arguments.type-declaration