Skip to content

Commit 2ac4572

Browse files
committed
fixes
1 parent 817dcd9 commit 2ac4572

File tree

8 files changed

+17
-110
lines changed

8 files changed

+17
-110
lines changed

composer.json

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -118,23 +118,6 @@
118118
"patches": {
119119
"illuminate/container": [
120120
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/illuminate-container-container-php.patch"
121-
],
122-
"nikic/php-parser": [
123-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-expr-closure-php.patch",
124-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-finally-php.patch",
125-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-function-php.patch",
126-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-do-php.patch",
127-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-catch-php.patch",
128-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-trycatch-php.patch",
129-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-for-php.patch",
130-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-classmethod-php.patch",
131-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-else-php.patch",
132-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-while-php.patch",
133-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-foreach-php.patch",
134-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-if-php.patch",
135-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-case-php.patch",
136-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-elseif-php.patch",
137-
"https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-namespace-php.patch"
138121
]
139122
},
140123
"composer-exit-on-patch-failure": true,

rules/CodeQuality/Rector/FunctionLike/SimplifyUselessVariableRector.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use PhpParser\Node;
99
use PhpParser\Node\Expr\Assign;
1010
use PhpParser\Node\Expr\AssignOp;
11+
use PhpParser\Node\Expr\Closure;
1112
use PhpParser\Node\Expr\Ternary;
1213
use PhpParser\Node\Expr\Variable;
1314
use PhpParser\Node\Stmt;
@@ -151,12 +152,16 @@ public function refactor(Node $node): ?Node
151152
return null;
152153
}
153154

155+
/**
156+
* @param StmtsAwareInterface $stmtsAware
157+
* @return StmtsAwareInterface
158+
*/
154159
private function processSimplifyUselessVariable(
155-
StmtsAwareInterface $stmtsAware,
160+
Stmt|Closure $stmtsAware,
156161
Return_ $return,
157162
Assign|AssignOp $assign,
158163
int $key
159-
): ?StmtsAwareInterface {
164+
): Stmt|Closure|null {
160165
if (! $assign instanceof Assign) {
161166
$binaryClass = $this->assignAndBinaryMap->getAlternative($assign);
162167
if ($binaryClass === null) {

rules/CodeQuality/Rector/If_/SimplifyIfNotNullReturnRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PhpParser\Node;
88
use PhpParser\Node\Expr;
9+
use PhpParser\Node\Stmt;
910
use PhpParser\Node\Stmt\Else_;
1011
use PhpParser\Node\Stmt\If_;
1112
use PhpParser\Node\Stmt\Return_;
@@ -62,7 +63,7 @@ public function getNodeTypes(): array
6263
/**
6364
* @param StmtsAwareInterface $node
6465
*/
65-
public function refactor(Node $node): ?StmtsAwareInterface
66+
public function refactor(Node $node): ?Stmt
6667
{
6768
foreach ((array) $node->stmts as $key => $stmt) {
6869
if (! $stmt instanceof If_) {

rules/Php70/Rector/ClassMethod/Php4ConstructorRector.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public function refactor(Node $node): Class_|null
121121
}
122122

123123
$parentClassName = $classReflection->getParentClass() instanceof ClassReflection
124-
? $classReflection->getParentClass()->getName() : '';
124+
? $classReflection->getParentClass()
125+
->getName() : '';
125126

126127
foreach ($classMethodStmts as $classMethodStmt) {
127128
if (! $classMethodStmt instanceof Expression) {

src/NodeManipulator/StmtsManipulator.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use PhpParser\Node;
88
use PhpParser\Node\Expr;
9+
use PhpParser\Node\Expr\Closure;
910
use PhpParser\Node\Expr\Variable;
1011
use PhpParser\Node\Stmt;
1112
use PhpParser\Node\Stmt\ClassMethod;
@@ -73,11 +74,11 @@ function (Node $node) use (&$stmts): null {
7374
return $stmts;
7475
}
7576

76-
public function isVariableUsedInNextStmt(
77-
StmtsAwareInterface $stmtsAware,
78-
int $jumpToKey,
79-
string $variableName
80-
): bool {
77+
/**
78+
* @param StmtsAwareInterface $stmtsAware
79+
*/
80+
public function isVariableUsedInNextStmt(Stmt|Closure $stmtsAware, int $jumpToKey, string $variableName): bool
81+
{
8182
if ($stmtsAware->stmts === null) {
8283
return false;
8384
}

src/PHPStan/NodeVisitor/StmtsAwareWrappingNodeVisitor.php

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

src/PhpParser/Node/CustomNode/StmtsAwareNode.php

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

src/PhpParser/Printer/BetterStandardPrinter.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
use Rector\NodeAnalyzer\ExprAnalyzer;
3838
use Rector\NodeTypeResolver\Node\AttributeKey;
3939
use Rector\PhpParser\Node\CustomNode\FileWithoutNamespace;
40-
use Rector\PhpParser\Node\CustomNode\StmtsAwareNode;
4140
use Rector\Util\NewLineSplitter;
4241
use Rector\Util\Reflection\PrivatesAccessor;
4342
use Rector\Util\StringUtils;
@@ -274,19 +273,6 @@ protected function pArray(
274273
// reindex positions for printer
275274
$nodes = array_values($nodes);
276275

277-
// unwrap StmtsAwareNode to make their printing work
278-
foreach ($nodes as $key => $node) {
279-
if ($node instanceof StmtsAwareNode) {
280-
$nodes[$key] = $node->getOriginalNode();
281-
}
282-
}
283-
284-
foreach ($origNodes as $key => $origNode) {
285-
if ($origNode instanceof StmtsAwareNode) {
286-
$origNodes[$key] = $origNode->getOriginalNode();
287-
}
288-
}
289-
290276
$content = parent::pArray($nodes, $origNodes, $pos, $indentAdjustment, $parentNodeClass, $subNodeName, $fixup);
291277
if ($content === null) {
292278
return $content;

0 commit comments

Comments
 (0)