Skip to content

Commit

Permalink
MissingTypehintCheck - do not report non-generic object types of gene…
Browse files Browse the repository at this point in the history
…ric class
  • Loading branch information
ondrejmirtes committed May 2, 2020
1 parent a7893a8 commit a3fad5e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ parameters:
count: 1
path: src/Rules/Registry.php

-
message: "#^Method PHPStan\\\\Testing\\\\RuleTestCase\\:\\:getRule\\(\\) return type with generic interface PHPStan\\\\Rules\\\\Rule does not specify its types\\: TNodeType$#"
count: 1
path: src/Testing/RuleTestCase.php

-
message: "#^Cannot call method getActiveTemplateTypeMap\\(\\) on PHPStan\\\\Reflection\\\\ClassReflection\\|null\\.$#"
count: 2
Expand Down
3 changes: 3 additions & 0 deletions src/Rules/MissingTypehintCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public function getNonGenericObjectTypesWithGenericClass(Type $type): array
if ($type instanceof GenericObjectType) {
return $type;
}
if ($type instanceof TemplateType) {
return $type;
}
if ($type instanceof ObjectType) {
$classReflection = $type->getClassReflection();
if ($classReflection === null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,17 @@ public function doFoo($it)
}

}

class GenericClassInTemplateBound
{

/**
* @template T of GenericClass
* @param T $obj
*/
public function doFoo($obj)
{

}

}

0 comments on commit a3fad5e

Please sign in to comment.