Skip to content
This repository was archived by the owner on Dec 3, 2023. It is now read-only.

Commit d89b630

Browse files
authored
remove ParentParamTypeGuard (#4132)
1 parent 275299b commit d89b630

File tree

6 files changed

+8
-79
lines changed

6 files changed

+8
-79
lines changed

packages/phpstan-rules/config/configurable-rules.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ services:
3737
tags: [phpstan.rules.rule]
3838
arguments:
3939
oldToPreferredClasses:
40-
SplFileInfo: 'Symplify\SmartFileSystem\SmartFileInfo'
4140
DateTime: 'Nette\Utils\DateTime'
4241
'PhpCsFixer\Finder': 'Symfony\Component\Finder\Finder'
4342
# smart file system

packages/phpstan-rules/config/services/generated-services.neon

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ services:
4141
- Symplify\PHPStanRules\ParentGuard\ParentClassMethodGuard
4242
- Symplify\PHPStanRules\ParentGuard\ParentElementResolver\ParentMethodResolver
4343
- Symplify\PHPStanRules\ParentGuard\ParentElementResolver\ParentMethodReturnTypeResolver
44-
- Symplify\PHPStanRules\ParentGuard\ParentParamTypeGuard
4544
- Symplify\PHPStanRules\ParentGuard\ParentPropertyGuard
4645
- Symplify\PHPStanRules\ParentMethodAnalyser
4746
- Symplify\PHPStanRules\PhpDoc\AnnotationAttributeDetector

packages/phpstan-rules/src/ParentGuard/ParentParamTypeGuard.php

Lines changed: 0 additions & 47 deletions
This file was deleted.

packages/phpstan-rules/src/Rules/PreferredClassRule.php

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use PHPStan\Analyser\Scope;
1515
use SplFileInfo;
1616
use Symplify\Astral\Naming\SimpleNameResolver;
17-
use Symplify\PHPStanRules\ParentGuard\ParentParamTypeGuard;
1817
use Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface;
1918
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
2019
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
@@ -35,7 +34,6 @@ final class PreferredClassRule extends AbstractSymplifyRule implements Configura
3534
*/
3635
public function __construct(
3736
private SimpleNameResolver $simpleNameResolver,
38-
private ParentParamTypeGuard $parentParamTypeGuard,
3937
private array $oldToPreferredClasses
4038
) {
4139
}
@@ -55,18 +53,18 @@ public function getNodeTypes(): array
5553
public function process(Node $node, Scope $scope): array
5654
{
5755
if ($node instanceof New_) {
58-
return $this->processNew($node, $scope);
56+
return $this->processNew($node);
5957
}
6058

6159
if ($node instanceof Class_) {
6260
return $this->processClass($node);
6361
}
6462

6563
if ($node instanceof StaticCall) {
66-
return $this->processStaticCall($node, $scope);
64+
return $this->processStaticCall($node);
6765
}
6866

69-
return $this->processClassName($node->toString(), $node, $scope);
67+
return $this->processClassName($node->toString());
7068
}
7169

7270
public function getRuleDefinition(): RuleDefinition
@@ -107,14 +105,14 @@ public function run()
107105
/**
108106
* @return string[]
109107
*/
110-
private function processNew(New_ $new, Scope $scope): array
108+
private function processNew(New_ $new): array
111109
{
112110
$className = $this->simpleNameResolver->getName($new->class);
113111
if ($className === null) {
114112
return [];
115113
}
116114

117-
return $this->processClassName($className, $new, $scope);
115+
return $this->processClassName($className);
118116
}
119117

120118
/**
@@ -149,12 +147,8 @@ private function processClass(Class_ $class): array
149147
/**
150148
* @return string[]
151149
*/
152-
private function processClassName(string $className, Node $node, Scope $scope): array
150+
private function processClassName(string $className): array
153151
{
154-
if ($this->parentParamTypeGuard->isRequiredByContract($node, $scope)) {
155-
return [];
156-
}
157-
158152
foreach ($this->oldToPreferredClasses as $oldClass => $prefferedClass) {
159153
if ($className !== $oldClass) {
160154
continue;
@@ -170,14 +164,14 @@ private function processClassName(string $className, Node $node, Scope $scope):
170164
/**
171165
* @return string[]
172166
*/
173-
private function processStaticCall(StaticCall $staticCall, Scope $scope): array
167+
private function processStaticCall(StaticCall $staticCall): array
174168
{
175169
if ($staticCall->class instanceof Expr) {
176170
return [];
177171
}
178172

179173
$className = (string) $staticCall->class;
180174

181-
return $this->processClassName($className, $staticCall, $scope);
175+
return $this->processClassName($className);
182176
}
183177
}

packages/phpstan-rules/tests/Rules/PreferredClassRule/Fixture/SkipRequiredByContract.php

Lines changed: 0 additions & 15 deletions
This file was deleted.

packages/phpstan-rules/tests/Rules/PreferredClassRule/PreferredClassRuleTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public function provideData(): Iterator
3434
yield [__DIR__ . '/Fixture/SomeStaticCall.php', [[$errorMessage, 13]]];
3535

3636
yield [__DIR__ . '/Fixture/SkipPreferredExtendingTheOldOne.php', []];
37-
yield [__DIR__ . '/Fixture/SkipRequiredByContract.php', []];
3837
}
3938

4039
/**

0 commit comments

Comments
 (0)