-
Notifications
You must be signed in to change notification settings - Fork 50
Closed
Description
I'm using
"phpstan/phpstan": "0.12.*",
"phpstan/phpstan-phpunit": "0.12.*",
"phpunit/phpunit": "8.2.5",
I have warning from Phpstorm 'void' method 'getMockBuilder' result used
with the following code :
$pdfGenerator = $this->getMockBuilder(PdfGenerator::class)->getMock();
When I Cmd + Click, I see Phpstorm are locating the getMockBuilder in phpstan/phpstan-phpunit/stubs
(instead of inside Phpunit package, maybe he take the first one in lexical order) with the following annotation:
/**
* @template T
* @phpstan-param class-string<T> $originalClassName
* @phpstan-return MockObject&T
*/
public function createConfiguredMock($originalClassName) {}
And theses annotations are not understood by Phpstorm.
Changing to
/**
* @template T
* @phpstan-param class-string<T> $originalClassName
* @phpstan-return MockObject&T
* @return MockBuilder
*/
public function createConfiguredMock($originalClassName) {}
Fix the issue.
By the way, in Phpunit code, the annotations are
/**
* Returns a builder object to create mock objects using a fluent interface.
*
* @param string|string[] $className
*
* @psalm-template RealInstanceType of object
* @psalm-param class-string<RealInstanceType>|string[] $className
* @psalm-return MockBuilder<RealInstanceType>
*/
public function getMockBuilder($className): MockBuilder
{
$this->recordDoubledType($className);
return new MockBuilder($this, $className);
}
So the returnType/paramsType are added both with the psalm syntax and the regular syntax.
Shouldn't the regular syntax be used too in the stubs provided by phpstan ?
Metadata
Metadata
Assignees
Labels
No labels