phpstan-symfony
phpstan-symfony copied to clipboard
Add more precise type info for ResponseInterface::getInfo
\Symfony\Contracts\HttpClient\ResponseInterface::getInfo
defines the return type as mixed
in phpdoc. However, when the value of the argument is known, we could have more precise info thanks to the type defined for a bunch of known info keys (if the key is unknown in the interface contract, the type will indeed be mixed
): https://github.com/symfony/symfony/blob/22a2729f371eb4bc8b08330a872291b9712e93da/src/Symfony/Contracts/HttpClient/ResponseInterface.php#L81-L109
Can't it be done directly with a conditional return type ?
/**
* @return ($type is null ? array : ($type is 'foo' ? bool : ($type is 'bar' ? string : ...)))
*/
public function getInfo(string $type = null): mixed;