|
11 | 11 | use PharIo\Version\VersionNumber;
|
12 | 12 | use PhpParser\Node;
|
13 | 13 | use PhpParser\Node\Expr\MethodCall;
|
14 |
| -use PhpParser\Node\Expr\NullsafeMethodCall; |
15 |
| -use PhpParser\Node\Stmt\Return_; |
16 | 14 | use PHPStan\Analyser\Scope;
|
17 | 15 | use PHPStan\Reflection\PassedByReference;
|
18 | 16 | use PHPStan\Rules\Rule;
|
|
25 | 23 | use Symfony\Component\Routing\Loader\Configurator\RouteConfigurator;
|
26 | 24 | use Symfony\Component\Routing\RouteCollection;
|
27 | 25 | use Symfony\Component\String\AbstractString;
|
28 |
| -use Symplify\Astral\ValueObject\AttributeKey; |
29 | 26 | use Symplify\PHPStanRules\Matcher\ObjectTypeMatcher;
|
30 | 27 | use Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface;
|
31 | 28 | use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
|
|
37 | 34 | * @see https://github.com/object-calisthenics/phpcs-calisthenics-rules#5-use-only-one-object-operator---per-statement
|
38 | 35 | *
|
39 | 36 | * @see \Symplify\PHPStanRules\ObjectCalisthenics\Tests\Rules\NoChainMethodCallRule\NoChainMethodCallRuleTest
|
| 37 | + * @implements Rule<MethodCall> |
40 | 38 | */
|
41 | 39 | final class NoChainMethodCallRule implements Rule, DocumentedRuleinterface, ConfigurableRuleInterface
|
42 | 40 | {
|
@@ -108,10 +106,6 @@ public function processNode(Node $node, Scope $scope): array
|
108 | 106 | return [];
|
109 | 107 | }
|
110 | 108 |
|
111 |
| - if ($this->isNullsafeMethodCall($node)) { |
112 |
| - return []; |
113 |
| - } |
114 |
| - |
115 | 109 | if ($this->shouldSkipType($scope, $node)) {
|
116 | 110 | return [];
|
117 | 111 | }
|
@@ -153,18 +147,4 @@ private function shouldSkipType(Scope $scope, MethodCall $methodCall): bool
|
153 | 147 |
|
154 | 148 | return $this->objectTypeMatcher->isExprTypes($methodCall->var, $scope, $this->allowedChainTypes);
|
155 | 149 | }
|
156 |
| - |
157 |
| - private function isNullsafeMethodCall(MethodCall $methodCall): bool |
158 |
| - { |
159 |
| - $parent = $methodCall->getAttribute(AttributeKey::PARENT); |
160 |
| - if ($parent instanceof NullsafeMethodCall) { |
161 |
| - return true; |
162 |
| - } |
163 |
| - |
164 |
| - if (! $parent instanceof Return_) { |
165 |
| - return false; |
166 |
| - } |
167 |
| - |
168 |
| - return $parent->expr instanceof NullsafeMethodCall; |
169 |
| - } |
170 | 150 | }
|
0 commit comments