mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-09 01:52:37 +02:00
[FuncCall] Don't add $result to parse_str if second parameter i… (#1709)
[FuncCall] Don't add $result to parse_str if second parameter is already set
This commit is contained in:
commit
2fabe47817
@ -52,6 +52,10 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isset($node->args[1])) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$resultVariable = new Variable('result');
|
||||
$node->args[1] = new Arg($resultVariable);
|
||||
|
||||
|
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Rector\Php\Tests\Rector\FuncCall\ParseStrWithResultArgumentRector\Fixture;
|
||||
|
||||
class AlreadySet
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$query = 'bla';
|
||||
parse_str($query, $data);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Php\Tests\Rector\FuncCall\ParseStrWithResultArgumentRector\Fixture;
|
||||
|
||||
class AlreadySet
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
$query = 'bla';
|
||||
parse_str($query, $data);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -9,7 +9,7 @@ final class ParseStrWithResultArgumentRectorTest extends AbstractRectorTestCase
|
||||
{
|
||||
public function test(): void
|
||||
{
|
||||
$this->doTestFiles([__DIR__ . '/Fixture/fixture.php.inc']);
|
||||
$this->doTestFiles([__DIR__ . '/Fixture/fixture.php.inc', __DIR__ . '/Fixture/already_set.php.inc']);
|
||||
}
|
||||
|
||||
protected function getRectorClass(): string
|
||||
|
Loading…
x
Reference in New Issue
Block a user