-
-
Notifications
You must be signed in to change notification settings - Fork 336
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DowngradePhp74] Handle nested uses on ArrowFunctionToAnonymousFuncti…
…onRector (#1040) * [DowngradePhp74] add failing test cases for nested uses * close #1039 * phpstan * support more than 4 nested * phpstan * phpstan * apply more than 4 nested * [ci-review] Rector Rectify * phpstan * it works to keep sorted * final touch: clean up * [ci-review] Rector Rectify * [ci-review] Rector Rectify * real final touch: clean up * fix duplicate ClosureUse definitino * [ci-review] Rector Rectify * cs Co-authored-by: Lctrs <jerome@prmntr.me> Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
39edeb3
commit f9fdebf
Showing
3 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
87 changes: 87 additions & 0 deletions
87
...rrowFunction/ArrowFunctionToAnonymousFunctionRector/Fixture/nested_static_fn_uses.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp74\Rector\ArrowFunction\ArrowFunctionToAnonymousFunctionRector\Fixture; | ||
|
||
final class NestedStaticFnUses | ||
{ | ||
public function __invoke() | ||
{ | ||
return fn ($foo) => fn ($bar) => fn () => [$foo, $bar]; | ||
} | ||
|
||
public function many() | ||
{ | ||
return fn ($foo) => fn ($bar) => fn ($baz) => fn () => [$foo, $bar, $baz]; | ||
} | ||
|
||
public function toomany() | ||
{ | ||
return fn ($foo) => fn ($bar) => fn ($baz) => fn ($bat) => fn () => [$foo, $bar, $baz, $bat]; | ||
} | ||
|
||
public function mixed() | ||
{ | ||
return fn($foo) => fn ($bar) => function () use ($foo, $bar) { | ||
return [$foo, $bar]; | ||
}; | ||
} | ||
} | ||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\DowngradePhp74\Rector\ArrowFunction\ArrowFunctionToAnonymousFunctionRector\Fixture; | ||
|
||
final class NestedStaticFnUses | ||
{ | ||
public function __invoke() | ||
{ | ||
return function ($foo) { | ||
return function ($bar) use ($foo) { | ||
return function () use ($foo, $bar) { | ||
return [$foo, $bar]; | ||
}; | ||
}; | ||
}; | ||
} | ||
|
||
public function many() | ||
{ | ||
return function ($foo) { | ||
return function ($bar) use ($foo) { | ||
return function ($baz) use ($foo, $bar) { | ||
return function () use ($foo, $bar, $baz) { | ||
return [$foo, $bar, $baz]; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} | ||
|
||
public function toomany() | ||
{ | ||
return function ($foo) { | ||
return function ($bar) use ($foo) { | ||
return function ($baz) use ($foo, $bar) { | ||
return function ($bat) use ($foo, $bar, $baz) { | ||
return function () use ($foo, $bar, $baz, $bat) { | ||
return [$foo, $bar, $baz, $bat]; | ||
}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} | ||
|
||
public function mixed() | ||
{ | ||
return function ($foo) { | ||
return function ($bar) use ($foo) { | ||
return function () use ($foo, $bar) { | ||
return [$foo, $bar]; | ||
}; | ||
}; | ||
}; | ||
} | ||
} | ||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters