-
Notifications
You must be signed in to change notification settings - Fork 50
Closed
Description
Hello
Inside a unit test I had a code like this
$collector = $client->getProfile()->getCollector('request');
because $client->getProfile()
can return false|Profile
phpstan was reporting the following issue:
20 Cannot call method getCollector() on
false|Symfony\Component\HttpKernel\Profiler\Profile.
------ ----------------------------------------------------------------------------------------------------
I changed my code to something like this:
$profiler = $client->getProfile();
$this->assertInstanceOf(Profile::class, $profiler);
$collector = $profiler->getCollector('request');
And the error was still reported. So finally I had to add this /** @var Profile $profiler */
inline docblock in order for the error not to be reported and trick PHPstan.
I believe that since you do an assertInstanceOf
there is no need to display an error and having to trick PHPstan by adding inline docblock. Is this possible to be fixed?
Metadata
Metadata
Assignees
Labels
No labels