Skip to content

Commit bf19914

Browse files
committed
Added missing rules to StubValidator
1 parent d598545 commit bf19914

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

src/PhpDoc/StubValidator.php

+20
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747
use PHPStan\Rules\Generics\ClassAncestorsRule;
4848
use PHPStan\Rules\Generics\ClassTemplateTypeRule;
4949
use PHPStan\Rules\Generics\CrossCheckInterfacesHelper;
50+
use PHPStan\Rules\Generics\EnumAncestorsRule;
51+
use PHPStan\Rules\Generics\EnumTemplateTypeRule;
5052
use PHPStan\Rules\Generics\FunctionSignatureVarianceRule;
5153
use PHPStan\Rules\Generics\FunctionTemplateTypeRule;
5254
use PHPStan\Rules\Generics\GenericAncestorsCheck;
@@ -58,8 +60,10 @@
5860
use PHPStan\Rules\Generics\MethodTagTemplateTypeRule;
5961
use PHPStan\Rules\Generics\MethodTagTemplateTypeTraitRule;
6062
use PHPStan\Rules\Generics\MethodTemplateTypeRule;
63+
use PHPStan\Rules\Generics\PropertyVarianceRule;
6164
use PHPStan\Rules\Generics\TemplateTypeCheck;
6265
use PHPStan\Rules\Generics\TraitTemplateTypeRule;
66+
use PHPStan\Rules\Generics\UsedTraitsRule;
6367
use PHPStan\Rules\Generics\VarianceCheck;
6468
use PHPStan\Rules\Methods\ExistingClassesInTypehintsRule;
6569
use PHPStan\Rules\Methods\MethodParameterComparisonHelper;
@@ -69,6 +73,10 @@
6973
use PHPStan\Rules\Methods\MissingMethodSelfOutTypeRule;
7074
use PHPStan\Rules\Methods\OverridingMethodRule;
7175
use PHPStan\Rules\MissingTypehintCheck;
76+
use PHPStan\Rules\PhpDoc\AssertRuleHelper;
77+
use PHPStan\Rules\PhpDoc\ConditionalReturnTypeRuleHelper;
78+
use PHPStan\Rules\PhpDoc\FunctionAssertRule;
79+
use PHPStan\Rules\PhpDoc\FunctionConditionalReturnTypeRule;
7280
use PHPStan\Rules\PhpDoc\GenericCallableRuleHelper;
7381
use PHPStan\Rules\PhpDoc\IncompatibleClassConstantPhpDocTypeRule;
7482
use PHPStan\Rules\PhpDoc\IncompatibleParamImmediatelyInvokedCallableRule;
@@ -78,6 +86,8 @@
7886
use PHPStan\Rules\PhpDoc\InvalidPhpDocTagValueRule;
7987
use PHPStan\Rules\PhpDoc\InvalidPHPStanDocTagRule;
8088
use PHPStan\Rules\PhpDoc\InvalidThrowsPhpDocValueRule;
89+
use PHPStan\Rules\PhpDoc\MethodAssertRule;
90+
use PHPStan\Rules\PhpDoc\MethodConditionalReturnTypeRule;
8191
use PHPStan\Rules\PhpDoc\UnresolvableTypeHelper;
8292
use PHPStan\Rules\Properties\ExistingClassesInPropertiesRule;
8393
use PHPStan\Rules\Properties\MissingPropertyTypehintRule;
@@ -186,6 +196,8 @@ private function getRuleRegistry(Container $container): RuleRegistry
186196
$propertyTagCheck = new PropertyTagCheck($reflectionProvider, $classNameCheck, $genericObjectTypeCheck, $missingTypehintCheck, $unresolvableTypeHelper, true, true);
187197
$reflector = $container->getService('stubReflector');
188198
$relativePathHelper = $container->getService('simpleRelativePathHelper');
199+
$assertRuleHelper = $container->getByType(AssertRuleHelper::class);
200+
$conditionalReturnTypeRuleHelper = $container->getByType(ConditionalReturnTypeRuleHelper::class);
189201

190202
$rules = [
191203
// level 0
@@ -237,6 +249,14 @@ private function getRuleRegistry(Container $container): RuleRegistry
237249
new PropertyTagRule($propertyTagCheck),
238250
new PropertyTagTraitRule($propertyTagCheck, $reflectionProvider),
239251
new PropertyTagTraitUseRule($propertyTagCheck),
252+
new EnumAncestorsRule($genericAncestorsCheck, $crossCheckInterfacesHelper),
253+
new EnumTemplateTypeRule(),
254+
new PropertyVarianceRule($varianceCheck),
255+
new UsedTraitsRule($fileTypeMapper, $genericAncestorsCheck),
256+
new FunctionAssertRule($assertRuleHelper),
257+
new MethodAssertRule($assertRuleHelper),
258+
new FunctionConditionalReturnTypeRule($conditionalReturnTypeRuleHelper),
259+
new MethodConditionalReturnTypeRule($conditionalReturnTypeRuleHelper),
240260

241261
// level 6
242262
new MissingFunctionParameterTypehintRule($missingTypehintCheck),

stubs/ReflectionClass.stub

-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
class ReflectionClass
77
{
88

9-
/**
10-
* @var class-string<T>
11-
*/
12-
public $name;
13-
149
/**
1510
* @param T|class-string<T> $argument
1611
* @throws ReflectionException

stubs/ext-ds.stub

-10
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,6 @@ final class Map implements Collection, ArrayAccess
353353
*/
354354
final class Pair implements JsonSerializable
355355
{
356-
/**
357-
* @var TKey
358-
*/
359-
public $key;
360-
361-
/**
362-
* @var TValue
363-
*/
364-
public $value;
365-
366356
/**
367357
* @param TKey $key
368358
* @param TValue $value

0 commit comments

Comments
 (0)