Skip to content

Commit 5f4edd9

Browse files
authored
Remove NonVariableToVariableOnFunctionCallRector, should be handled manually as might need attention (rectorphp#3357)
1 parent 651e283 commit 5f4edd9

35 files changed

+32
-971
lines changed

build/target-repository/docs/rector_rules_overview.md

+2-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 415 Rules Overview
1+
# 414 Rules Overview
22

33
<br>
44

@@ -34,7 +34,7 @@
3434

3535
- [Php56](#php56) (2)
3636

37-
- [Php70](#php70) (19)
37+
- [Php70](#php70) (18)
3838

3939
- [Php71](#php71) (9)
4040

@@ -4917,19 +4917,6 @@ Changes multiple `dirname()` calls to one with nesting level
49174917

49184918
<br>
49194919

4920-
### NonVariableToVariableOnFunctionCallRector
4921-
4922-
Transform non variable like arguments to variable where a function or method expects an argument passed by reference
4923-
4924-
- class: [`Rector\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector`](../rules/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector.php)
4925-
4926-
```diff
4927-
-reset(a());
4928-
+$a = a(); reset($a);
4929-
```
4930-
4931-
<br>
4932-
49334920
### Php4ConstructorRector
49344921

49354922
Changes PHP 4 style constructor to __construct.

config/set/php70.php

+21-39
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
use Rector\Php70\Rector\FuncCall\CallUserMethodRector;
1111
use Rector\Php70\Rector\FuncCall\EregToPregMatchRector;
1212
use Rector\Php70\Rector\FuncCall\MultiDirnameRector;
13-
use Rector\Php70\Rector\FuncCall\NonVariableToVariableOnFunctionCallRector;
1413
use Rector\Php70\Rector\FuncCall\RandomFunctionRector;
1514
use Rector\Php70\Rector\FuncCall\RenameMktimeWithoutArgsToTimeRector;
1615
use Rector\Php70\Rector\FunctionLike\ExceptionHandlerTypehintRector;
@@ -24,42 +23,25 @@
2423
use Rector\Php70\Rector\Variable\WrapVariableVariableNameInCurlyBracesRector;
2524

2625
return static function (RectorConfig $rectorConfig): void {
27-
$rectorConfig->rule(Php4ConstructorRector::class);
28-
29-
$rectorConfig->rule(TernaryToNullCoalescingRector::class);
30-
31-
$rectorConfig->rule(RandomFunctionRector::class);
32-
33-
$rectorConfig->rule(ExceptionHandlerTypehintRector::class);
34-
35-
$rectorConfig->rule(MultiDirnameRector::class);
36-
37-
$rectorConfig->rule(ListSplitStringRector::class);
38-
39-
$rectorConfig->rule(EmptyListRector::class);
40-
41-
# be careful, run this just once, since it can keep swapping order back and forth
42-
$rectorConfig->rule(ListSwapArrayOrderRector::class);
43-
44-
$rectorConfig->rule(CallUserMethodRector::class);
45-
46-
$rectorConfig->rule(EregToPregMatchRector::class);
47-
48-
$rectorConfig->rule(ReduceMultipleDefaultSwitchRector::class);
49-
50-
$rectorConfig->rule(TernaryToSpaceshipRector::class);
51-
52-
$rectorConfig->rule(WrapVariableVariableNameInCurlyBracesRector::class);
53-
54-
$rectorConfig->rule(IfToSpaceshipRector::class);
55-
56-
$rectorConfig->rule(StaticCallOnNonStaticToInstanceCallRector::class);
57-
58-
$rectorConfig->rule(ThisCallOnStaticMethodToStaticCallRector::class);
59-
60-
$rectorConfig->rule(BreakNotInLoopOrSwitchToReturnRector::class);
61-
62-
$rectorConfig->rule(RenameMktimeWithoutArgsToTimeRector::class);
63-
64-
$rectorConfig->rule(NonVariableToVariableOnFunctionCallRector::class);
26+
$rectorConfig->rules([
27+
Php4ConstructorRector::class,
28+
TernaryToNullCoalescingRector::class,
29+
RandomFunctionRector::class,
30+
ExceptionHandlerTypehintRector::class,
31+
MultiDirnameRector::class,
32+
ListSplitStringRector::class,
33+
EmptyListRector::class,
34+
// be careful, run this just once, since it can keep swapping order back and forth
35+
ListSwapArrayOrderRector::class,
36+
CallUserMethodRector::class,
37+
EregToPregMatchRector::class,
38+
ReduceMultipleDefaultSwitchRector::class,
39+
TernaryToSpaceshipRector::class,
40+
WrapVariableVariableNameInCurlyBracesRector::class,
41+
IfToSpaceshipRector::class,
42+
StaticCallOnNonStaticToInstanceCallRector::class,
43+
ThisCallOnStaticMethodToStaticCallRector::class,
44+
BreakNotInLoopOrSwitchToReturnRector::class,
45+
RenameMktimeWithoutArgsToTimeRector::class,
46+
]);
6547
};

packages/NodeNestingScope/ParentScopeFinder.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Rector\NodeNestingScope;
66

7-
use PhpParser\Node;
87
use PhpParser\Node\Expr\Closure;
8+
use PhpParser\Node\Expr\Variable;
99
use PhpParser\Node\Stmt\Class_;
1010
use PhpParser\Node\Stmt\ClassMethod;
1111
use PhpParser\Node\Stmt\Function_;
@@ -19,9 +19,9 @@ public function __construct(
1919
) {
2020
}
2121

22-
public function find(Node $node): ClassMethod | Function_ | Class_ | Namespace_ | Closure | null
22+
public function find(Variable $variable): ClassMethod | Function_ | Class_ | Namespace_ | Closure | null
2323
{
24-
return $this->betterNodeFinder->findParentByTypes($node, [
24+
return $this->betterNodeFinder->findParentByTypes($variable, [
2525
Closure::class,
2626
Function_::class,
2727
ClassMethod::class,

phpstan.neon

+3
Original file line numberDiff line numberDiff line change
@@ -808,3 +808,6 @@ parameters:
808808
-
809809
message: '#Function "dump_node\(\)" cannot be used/left in the code\: #'
810810
path: src/functions/node_helper.php
811+
812+
# nullable in external package
813+
- '#Parameters should use "PhpParser\\Node\\Expr\\FuncCall\|string\|string\|PHPStan\\Analyser\\Scope" types as the only types passed to this method#'

rules-tests/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector/Fixture/anonymous_class.php.inc

-28
This file was deleted.

rules-tests/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector/Fixture/anonymous_function.php.inc

-35
This file was deleted.

rules-tests/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector/Fixture/array_with_func_calls.php.inc

-34
This file was deleted.

rules-tests/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector/Fixture/assignment.php.inc

-31
This file was deleted.

rules-tests/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector/Fixture/binary_op.php.inc

-25
This file was deleted.

rules-tests/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector/Fixture/func_calls.php.inc

-46
This file was deleted.

rules-tests/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector/Fixture/has_prev_next_stmt.php.inc

-26
This file was deleted.

rules-tests/Php70/Rector/FuncCall/NonVariableToVariableOnFunctionCallRector/Fixture/invokable.php.inc

-28
This file was deleted.

0 commit comments

Comments
 (0)