mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-17 13:28:18 +01:00
Update doctrine/inflector requirement from ^1.3 to ^1.4|^2.0
This commit is contained in:
parent
abd580a6cf
commit
b943ba59cf
@ -14,7 +14,7 @@
|
||||
"ext-json": "*",
|
||||
"composer/xdebug-handler": "^1.4",
|
||||
"doctrine/annotations": "^1.10.2",
|
||||
"doctrine/inflector": "^1.3",
|
||||
"doctrine/inflector": "^1.4|^2.0",
|
||||
"jean85/pretty-package-versions": "^1.2",
|
||||
"nette/robot-loader": "^3.2",
|
||||
"nette/utils": "^3.1",
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Doctrine\Inflector\Inflector;
|
||||
use Doctrine\Inflector\Rules\English\InflectorFactory;
|
||||
use OndraM\CiDetector\CiDetector;
|
||||
use PhpParser\BuilderFactory;
|
||||
use PhpParser\Lexer;
|
||||
@ -99,4 +101,9 @@ return static function (ContainerConfigurator $containerConfigurator): void {
|
||||
|
||||
$services->set(SymfonyStyle::class)
|
||||
->factory([ref(SymfonyStyleFactory::class), 'create']);
|
||||
|
||||
$services->set(InflectorFactory::class);
|
||||
|
||||
$services->set(Inflector::class)
|
||||
->factory([ref(InflectorFactory::class), 'build']);
|
||||
};
|
||||
|
@ -4,7 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Rector\CodeQuality\Rector\For_;
|
||||
|
||||
use Doctrine\Common\Inflector\Inflector;
|
||||
use Doctrine\Inflector\Inflector;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\ArrayDimFetch;
|
||||
@ -50,9 +50,15 @@ final class ForToForeachRector extends AbstractRector
|
||||
*/
|
||||
private $assignManipulator;
|
||||
|
||||
public function __construct(AssignManipulator $assignManipulator)
|
||||
/**
|
||||
* @var Inflector
|
||||
*/
|
||||
private $inflector;
|
||||
|
||||
public function __construct(AssignManipulator $assignManipulator, Inflector $inflector)
|
||||
{
|
||||
$this->assignManipulator = $assignManipulator;
|
||||
$this->inflector = $inflector;
|
||||
}
|
||||
|
||||
public function getDefinition(): RectorDefinition
|
||||
@ -132,7 +138,7 @@ PHP
|
||||
return null;
|
||||
}
|
||||
|
||||
$iteratedVariableSingle = Inflector::singularize($iteratedVariable);
|
||||
$iteratedVariableSingle = $this->inflector->singularize($iteratedVariable);
|
||||
$foreach = $this->createForeach($node, $iteratedVariableSingle);
|
||||
|
||||
$this->useForeachVariableInStmts($foreach->expr, $foreach->valueVar, $foreach->stmts);
|
||||
|
Loading…
x
Reference in New Issue
Block a user