PhpStorm$requestType
在下面的红色代码中突出显示,我不明白为什么。也许是 PhpStorm 中的错误?也许像这样定义默认函数值不是一个好习惯?
class HttpClient
{
const RequestTypes = [
'DEFAULT' => 'default',
'JSON' => 'json'
];
public function makeRequest(
string $requestType = self::RequestTypes['DEFAULT']
): Response {
// The function
}
}
错误消息是Default value for parameters with string type can only be string or NULL
。
显然该['DEFAULT']
值是一个字符串,但仍然给出错误。
你怎么看?