mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 11:50:51 +00:00
[CodeQuality] Skip empty array push args and no 2nd arg on ChangeArrayPushToArrayAssignRector (#2266)
* [CodeQuality] Skip empty array push args and no 2nd arg on ChangeArrayPushToArrayAssignRector
* Fixed 🎉
This commit is contained in:
parent
88c9b8e20d
commit
ae2e38ed98
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Tests\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector\Fixture;
|
||||
|
||||
class SkipEmptyArgs
|
||||
{
|
||||
public function run()
|
||||
{
|
||||
array_push();
|
||||
|
||||
echo 'test';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Tests\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector\Fixture;
|
||||
|
||||
class SkipNoSecondArg
|
||||
{
|
||||
public function run(array $items)
|
||||
{
|
||||
array_push($items);
|
||||
}
|
||||
}
|
|
@ -70,9 +70,17 @@ CODE_SAMPLE
|
|||
|
||||
$args = $funcCall->getArgs();
|
||||
|
||||
if ($args === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @var Arg $firstArg */
|
||||
$firstArg = array_shift($args);
|
||||
|
||||
if ($args === []) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$arrayDimFetch = new ArrayDimFetch($firstArg->value);
|
||||
|
||||
$newStmts = [];
|
||||
|
|
Loading…
Reference in New Issue
Block a user