PhpStorm is highlighting $requestType
in the following piece of code in red, which I don't understand why. Maybe a bug in PhpStorm? Maybe is just not a good practice to define like that default function values?
class HttpClient
{
const RequestTypes = [
'DEFAULT' => 'default',
'JSON' => 'json'
];
public function makeRequest(
string $requestType = self::RequestTypes['DEFAULT']
): Response {
// The function
}
}
The error message is Default value for parameters with string type can only be string or NULL
.
Obviously the ['DEFAULT']
value is a string, but still giving an error.
What do you think?