mirror of
https://github.com/rectorphp/rector.git
synced 2025-02-24 03:35:01 +01:00
Merge pull request #1531 from Aerendir/add-variables-only-once-1530
Failing test for anonymous functions.
This commit is contained in:
commit
0bc79f70fd
@ -10,6 +10,7 @@ final class AddDefaultValueForUndefinedVariableRectorTest extends AbstractRector
|
||||
public function test(): void
|
||||
{
|
||||
$this->doTestFiles([
|
||||
__DIR__ . '/Fixture/anonymous_function.php.inc',
|
||||
__DIR__ . '/Fixture/fixture.php.inc',
|
||||
__DIR__ . '/Fixture/in_foreach.php.inc',
|
||||
__DIR__ . '/Fixture/vimeo_one.php.inc',
|
||||
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Php\Tests\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector\Fixture;
|
||||
|
||||
class AnonymousFunction
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$lines = [];
|
||||
|
||||
return array_map(static function ($line) {
|
||||
[$value1, $value2] = explode("\t", $line);
|
||||
|
||||
return [
|
||||
'value_1' => $value1,
|
||||
'value_2' => $value2,
|
||||
];
|
||||
}, $lines);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Php\Tests\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector\Fixture;
|
||||
|
||||
class AnonymousFunction
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$lines = [];
|
||||
|
||||
return array_map(static function ($line) {
|
||||
$value1 = null;
|
||||
$value2 = null;
|
||||
[$value1, $value2] = explode("\t", $line);
|
||||
|
||||
return [
|
||||
'value_1' => $value1,
|
||||
'value_2' => $value2,
|
||||
];
|
||||
}, $lines);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
x
Reference in New Issue
Block a user