Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,11 @@
"phpstan/phpstan-phpunit": "^2.0",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^13.3",
"rector/jack": "^1.1",
"rector/swiss-knife": "^2.6",
"rector/swiss-knife": "^2.7",
"shipmonk/composer-dependency-analyser": "^1.8",
"symfony/process": "^8.1",
"symplify/easy-coding-standard": "^13.2.13",
"symplify/phpstan-rules": "^14.13",
"symplify/phpstan-rules": "^14.18",
"tomasvotruba/class-leak": "^2.1",
"tomasvotruba/fast-unit": "^0.1",
"tomasvotruba/type-coverage": "^2.3.6",
Expand Down
42 changes: 15 additions & 27 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ rules:
parameters:
level: 8

reportUnmatchedIgnoredErrors: false
# reportUnmatchedIgnoredErrors: false
errorFormat: symplify

# see https://phpstan.org/writing-php-code/phpdoc-types#global-type-aliases
Expand Down Expand Up @@ -45,6 +45,13 @@ parameters:
# see https://github.com/symplify/phpstan-rules
symplify:
pathStrings: true
naming: true
complexity: true
configurable: true
static: true
phpunit: true
mocks: true
ctor: true

# see https://github.com/TomasVotruba/type-coverage
type_coverage:
Expand Down Expand Up @@ -339,15 +346,8 @@ parameters:
-
identifier: symplify.noDynamicName
message: '#Use explicit names over dynamic ones#'
paths:
- src/CustomRules/SimpleNodeDumper.php
- src/PhpDocParser/PhpDocParser/PhpDocNodeTraverser.php

# copied from /vendor, to keep as original as possible
-
identifier: symplify.noDynamicName
path: src/PhpParser/NodeTraverser/RectorNodeTraverser.php

# reference params in legacy/perf code, kept as original
-
identifier: symplify.noReference
message: '#Use explicit return value over magic &reference#'
Expand All @@ -356,10 +356,14 @@ parameters:
- rules/Php70/EregToPcreTransformer.php
- src/BetterPhpDocParser/PhpDocManipulator/PhpDocClassRenamer.php
- src/NodeTypeResolver/PHPStan/Type/TypeFactory.php
- rules/CodeQuality/Rector/Class_/InnerFunctionToPrivateMethodRector.php
- rules/CodeQuality/NodeAnalyzer/VariableDimFetchAssignResolver.php

-
identifier: symplify.noReference
message: '#Use explicit return value over magic &reference#'
identifier: symplify.noNullableServiceInConstructor
path: src/NodeTypeResolver/PHPStan/ObjectWithoutClassTypeWithParentTypes.php

- identifier: symplify.commandHasAsCommandAttribute

# fixture Rector rules
-
Expand All @@ -376,19 +380,3 @@ parameters:
-
identifier: varTag.nativeType
path: src/BetterPhpDocParser/PhpDocParser/StaticDoctrineAnnotationParser.php


-
identifier: symplify.noNullableServiceInConstructor
paths:
- src/NodeTypeResolver/PHPStan/ObjectWithoutClassTypeWithParentTypes.php

- identifier: symplify.commandHasAsCommandAttribute
paths:
- src/Console/Command/ValidateConfigCommand.php
- src/Console/Command/WorkerCommand.php
- src/Console/Command/ProcessCommand.php
- src/Console/Command/ListRulesCommand.php
- src/Console/Command/CustomRuleCommand.php
- src/Console/Command/ComposerBasedCommand.php
- src/Console/Command/SetupCICommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ private function processExplicitIf(Expression $expression): ?Node

private function isSameLocalMethodCallChain(BooleanAnd|BooleanOr $booleanExpr): bool
{
$leaves = [];
$this->collectOperands($booleanExpr, $leaves);
$leaves = $this->collectOperands($booleanExpr);

$firstMethodCall = null;
foreach ($leaves as $leaf) {
Expand All @@ -148,16 +147,14 @@ private function isSameLocalMethodCallChain(BooleanAnd|BooleanOr $booleanExpr):
}

/**
* @param Expr[] $leaves
* @return Expr[]
*/
private function collectOperands(Expr $expr, array &$leaves): void
private function collectOperands(Expr $expr): array
{
if ($expr instanceof BooleanAnd || $expr instanceof BooleanOr) {
$this->collectOperands($expr->left, $leaves);
$this->collectOperands($expr->right, $leaves);
return;
return array_merge($this->collectOperands($expr->left), $this->collectOperands($expr->right));
}

$leaves[] = $expr;
return [$expr];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -211,21 +211,24 @@ private function shouldSkip(array $stmts): bool
}

/**
* @param string[] $refVariableNames
* @return string[]
*/
private function collectAssignRefVariableNames(Stmt $stmt, array &$refVariableNames): void
private function collectAssignRefVariableNames(Stmt $stmt): array
{
if (! NodeGroup::isStmtAwareNode($stmt)) {
return;
return [];
}

$refVariableNames = [];
$this->traverseNodesWithCallable($stmt, function (Node $subNode) use (&$refVariableNames): Node {
if ($subNode instanceof AssignRef && $subNode->var instanceof Variable) {
$refVariableNames[] = (string) $this->getName($subNode->var);
}

return $subNode;
});

return $refVariableNames;
}

/**
Expand All @@ -239,7 +242,7 @@ private function resolvedAssignedVariablesByStmtPosition(array $stmts): array

foreach ($stmts as $key => $stmt) {
if (! $stmt instanceof Expression) {
$this->collectAssignRefVariableNames($stmt, $refVariableNames);
$refVariableNames = array_merge($refVariableNames, $this->collectAssignRefVariableNames($stmt));
continue;
}

Expand Down
Loading