Param typehint fails for renamed imports
The check for the param in the docblock doesn't take into account typehinted paramaters that have been used with a different name.
The example below throws the error Expected type hint "\React\EventLoop\LoopInterface"; found "EventLoopInterface" for $loop
use React\EventLoop\LoopInterface as EventLoopInterface;
/**
* Get a new instance of datagram.
*
* @param \React\EventLoop\LoopInterface $loop
*
* @return \React\Datagram\Factory
*/
public function getDatagram(EventLoopInterface $loop)
{
if (!$this->datagram) {
$this->datagram = function (EventLoopInterface $loop) {
return new Datagram($loop);
};
}
return call_user_func($this->datagram, $loop);
}
- Any specific reason why you're using FQCN in DocBlock while class name is already imported and can be used without namespace prefix?
- What is expected result:
- no warning
- warning saying to use FQCN
- warning saying to use non-FQCN ?
I guess it comes down to a more readable docblock for a human. FQCN in docblocks are a pretty common thing, with most packages that I use doing the same.
In an ideal world, no error.
While it's still in draft PSR-5 states object types should use FQCN (unless undetermined): https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#valid-class-name