mirror of
https://github.com/rectorphp/rector.git
synced 2024-06-07 11:50:51 +00:00
[Php72] Handle crash on PreInc usage on CreateFunctionToAnonymousFunctionRector (#2456)
* [Php72] Handle crash on PreInc usage on CreateFunctionToAnonymousFunctionRector
* Fixed 🎉
* phpstan
* [ci-review] Rector Rectify
Co-authored-by: GitHub Action <action@github.com>
This commit is contained in:
parent
cb1473a3ac
commit
f2300baf89
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Rector\Tests\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector\Fixture;
|
||||
|
||||
class UseIncrement
|
||||
{
|
||||
private array $_quoteIdentifierCallbacks = array();
|
||||
private int $_qiCallbacksCount = 0;
|
||||
|
||||
public function getQuoteIdentifierCallback($adapter)
|
||||
{
|
||||
$callback = create_function('$v', 'return Mage::helper(\'customgrid/collection\')->callQuoteIdentifier($v, '.++$this->_qiCallbacksCount.');');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
-----
|
||||
<?php
|
||||
|
||||
namespace Rector\Tests\Php72\Rector\FuncCall\CreateFunctionToAnonymousFunctionRector\Fixture;
|
||||
|
||||
class UseIncrement
|
||||
{
|
||||
private array $_quoteIdentifierCallbacks = array();
|
||||
private int $_qiCallbacksCount = 0;
|
||||
|
||||
public function getQuoteIdentifierCallback($adapter)
|
||||
{
|
||||
$callback = function ($v) {
|
||||
return Mage::helper('customgrid/collection')->callQuoteIdentifier($v, ++$this->_qiCallbacksCount);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -7,15 +7,10 @@ namespace Rector\Core\PhpParser\Parser;
|
|||
use Nette\Utils\Strings;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\BinaryOp\Concat;
|
||||
use PhpParser\Node\Expr\PropertyFetch;
|
||||
use PhpParser\Node\Expr\StaticPropertyFetch;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Scalar\Encapsed;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Parser;
|
||||
use Rector\Core\Contract\PhpParser\NodePrinterInterface;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator;
|
||||
use Symplify\SmartFileSystem\SmartFileSystem;
|
||||
|
@ -91,10 +86,6 @@ final class InlineCodeParser
|
|||
return $this->stringify($expr->left) . $this->stringify($expr->right);
|
||||
}
|
||||
|
||||
if ($expr instanceof Variable || $expr instanceof PropertyFetch || $expr instanceof StaticPropertyFetch) {
|
||||
return $this->nodePrinter->print($expr);
|
||||
}
|
||||
|
||||
throw new ShouldNotHappenException($expr::class . ' ' . __METHOD__);
|
||||
return $this->nodePrinter->print($expr);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user