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

Commit 1fa07a4

Browse files
authored
[PHPStanRules] Remove parent from NoChainMethodCallRule (#4133)
1 parent d89b630 commit 1fa07a4

File tree

3 files changed

+1
-37
lines changed

3 files changed

+1
-37
lines changed

packages/phpstan-rules/packages/object-calisthenics/src/Rules/NoChainMethodCallRule.php

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
use PharIo\Version\VersionNumber;
1212
use PhpParser\Node;
1313
use PhpParser\Node\Expr\MethodCall;
14-
use PhpParser\Node\Expr\NullsafeMethodCall;
15-
use PhpParser\Node\Stmt\Return_;
1614
use PHPStan\Analyser\Scope;
1715
use PHPStan\Reflection\PassedByReference;
1816
use PHPStan\Rules\Rule;
@@ -25,7 +23,6 @@
2523
use Symfony\Component\Routing\Loader\Configurator\RouteConfigurator;
2624
use Symfony\Component\Routing\RouteCollection;
2725
use Symfony\Component\String\AbstractString;
28-
use Symplify\Astral\ValueObject\AttributeKey;
2926
use Symplify\PHPStanRules\Matcher\ObjectTypeMatcher;
3027
use Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface;
3128
use Symplify\RuleDocGenerator\Contract\DocumentedRuleInterface;
@@ -37,6 +34,7 @@
3734
* @see https://github.com/object-calisthenics/phpcs-calisthenics-rules#5-use-only-one-object-operator---per-statement
3835
*
3936
* @see \Symplify\PHPStanRules\ObjectCalisthenics\Tests\Rules\NoChainMethodCallRule\NoChainMethodCallRuleTest
37+
* @implements Rule<MethodCall>
4038
*/
4139
final class NoChainMethodCallRule implements Rule, DocumentedRuleinterface, ConfigurableRuleInterface
4240
{
@@ -108,10 +106,6 @@ public function processNode(Node $node, Scope $scope): array
108106
return [];
109107
}
110108

111-
if ($this->isNullsafeMethodCall($node)) {
112-
return [];
113-
}
114-
115109
if ($this->shouldSkipType($scope, $node)) {
116110
return [];
117111
}
@@ -153,18 +147,4 @@ private function shouldSkipType(Scope $scope, MethodCall $methodCall): bool
153147

154148
return $this->objectTypeMatcher->isExprTypes($methodCall->var, $scope, $this->allowedChainTypes);
155149
}
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-
}
170150
}

packages/phpstan-rules/packages/object-calisthenics/tests/Rules/NoChainMethodCallRule/Fixture/SkipNullsafeCalls.php

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

packages/phpstan-rules/packages/object-calisthenics/tests/Rules/NoChainMethodCallRule/NoChainMethodCallRuleTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public function provideData(): Iterator
2828
yield [__DIR__ . '/Fixture/ChainMethodCall.php', [[NoChainMethodCallRule::ERROR_MESSAGE, 11]]];
2929
yield [__DIR__ . '/Fixture/SkipSymfonyConfig.php', []];
3030
yield [__DIR__ . '/Fixture/SkipExtraAllowedClass.php', []];
31-
yield [__DIR__ . '/Fixture/SkipNullsafeCalls.php', []];
3231
yield [__DIR__ . '/Fixture/SkipTrinaryLogic.php', []];
3332
}
3433

0 commit comments

Comments
 (0)