Updated Rector to commit 24a32dfefb

24a32dfefb Fix docs double import (#478)
This commit is contained in:
Tomas Votruba 2021-07-21 13:46:30 +00:00
parent d15985c4e5
commit e3f99041de
56 changed files with 236 additions and 234 deletions

View File

@ -53,8 +53,9 @@ final class TypeFactory
return $this->createUnionOrSingleType($types); return $this->createUnionOrSingleType($types);
} }
/** /**
* @param Type[] $types * @template TType as Type
* @return Type[] * @param array<TType> $types
* @return array<TType>
*/ */
public function uniquateTypes(array $types, bool $keepConstant = \false) : array public function uniquateTypes(array $types, bool $keepConstant = \false) : array
{ {

View File

@ -14,6 +14,8 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
use Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper; use Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper;
use Rector\Core\Configuration\Option; use Rector\Core\Configuration\Option;
use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\Provider\CurrentFileProvider;
use Rector\Core\ValueObject\Application\File;
use Rector\PostRector\Collector\UseNodesToAddCollector; use Rector\PostRector\Collector\UseNodesToAddCollector;
use Rector\StaticTypeMapper\StaticTypeMapper; use Rector\StaticTypeMapper\StaticTypeMapper;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
@ -41,12 +43,17 @@ final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20210721\Symplif
* @var \Rector\PostRector\Collector\UseNodesToAddCollector * @var \Rector\PostRector\Collector\UseNodesToAddCollector
*/ */
private $useNodesToAddCollector; private $useNodesToAddCollector;
public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \RectorPrefix20210721\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper $classNameImportSkipper, \Rector\PostRector\Collector\UseNodesToAddCollector $useNodesToAddCollector) /**
* @var \Rector\Core\Provider\CurrentFileProvider
*/
private $currentFileProvider;
public function __construct(\Rector\StaticTypeMapper\StaticTypeMapper $staticTypeMapper, \RectorPrefix20210721\Symplify\PackageBuilder\Parameter\ParameterProvider $parameterProvider, \Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper $classNameImportSkipper, \Rector\PostRector\Collector\UseNodesToAddCollector $useNodesToAddCollector, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider)
{ {
$this->staticTypeMapper = $staticTypeMapper; $this->staticTypeMapper = $staticTypeMapper;
$this->parameterProvider = $parameterProvider; $this->parameterProvider = $parameterProvider;
$this->classNameImportSkipper = $classNameImportSkipper; $this->classNameImportSkipper = $classNameImportSkipper;
$this->useNodesToAddCollector = $useNodesToAddCollector; $this->useNodesToAddCollector = $useNodesToAddCollector;
$this->currentFileProvider = $currentFileProvider;
} }
public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void public function beforeTraverse(\PHPStan\PhpDocParser\Ast\Node $node) : void
{ {
@ -74,39 +81,47 @@ final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20210721\Symplif
if ($this->shouldSkipShortClassName($staticType)) { if ($this->shouldSkipShortClassName($staticType)) {
return null; return null;
} }
return $this->processFqnNameImport($this->currentPhpParserNode, $node, $staticType); $file = $this->currentFileProvider->getFile();
if (!$file instanceof \Rector\Core\ValueObject\Application\File) {
return null;
}
return $this->processFqnNameImport($this->currentPhpParserNode, $node, $staticType, $file);
} }
public function setCurrentNode(\PhpParser\Node $phpParserNode) : void public function setCurrentNode(\PhpParser\Node $phpParserNode) : void
{ {
$this->currentPhpParserNode = $phpParserNode; $this->currentPhpParserNode = $phpParserNode;
} }
private function processFqnNameImport(\PhpParser\Node $phpParserNode, \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $identifierTypeNode, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : ?\PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode private function processFqnNameImport(\PhpParser\Node $phpParserNode, \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $identifierTypeNode, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType, \Rector\Core\ValueObject\Application\File $file) : ?\PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode
{ {
if ($this->classNameImportSkipper->shouldSkipNameForFullyQualifiedObjectType($phpParserNode, $fullyQualifiedObjectType)) { if ($this->classNameImportSkipper->shouldSkipNameForFullyQualifiedObjectType($file, $phpParserNode, $fullyQualifiedObjectType)) {
return $identifierTypeNode; return null;
} }
$parent = $identifierTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT); $parent = $identifierTypeNode->getAttribute(\Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey::PARENT);
if ($parent instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode) { if ($parent instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode) {
// might break // might break
return null; return null;
} }
// should skip because its already used
if ($this->useNodesToAddCollector->isShortImported($phpParserNode, $fullyQualifiedObjectType)) {
if ($this->useNodesToAddCollector->isImportShortable($phpParserNode, $fullyQualifiedObjectType)) {
$newNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($fullyQualifiedObjectType->getShortName()); $newNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($fullyQualifiedObjectType->getShortName());
// should skip because its already used
if ($this->useNodesToAddCollector->isShortImported($file, $fullyQualifiedObjectType)) {
if (!$this->useNodesToAddCollector->isImportShortable($file, $fullyQualifiedObjectType)) {
return null;
}
if ($newNode->name !== $identifierTypeNode->name) { if ($newNode->name !== $identifierTypeNode->name) {
$this->useNodesToAddCollector->addUseImport($fullyQualifiedObjectType);
return $newNode; return $newNode;
} }
return $identifierTypeNode; return null;
} }
return $identifierTypeNode; if ($newNode->name !== $identifierTypeNode->name) {
// do not import twice
if ($this->useNodesToAddCollector->isShortImported($file, $fullyQualifiedObjectType)) {
return null;
} }
$this->useNodesToAddCollector->addUseImport($fullyQualifiedObjectType); $this->useNodesToAddCollector->addUseImport($fullyQualifiedObjectType);
$newNode = new \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode($fullyQualifiedObjectType->getShortName());
if ($newNode->name !== $identifierTypeNode->name) {
return $newNode; return $newNode;
} }
return $identifierTypeNode; return null;
} }
private function shouldSkipShortClassName(\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : bool private function shouldSkipShortClassName(\Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : bool
{ {
@ -126,7 +141,11 @@ final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20210721\Symplif
} }
$staticType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($staticType->getClassName()); $staticType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($staticType->getClassName());
} }
$shortentedIdentifierTypeNode = $this->processFqnNameImport($this->currentPhpParserNode, $identifierTypeNode, $staticType); $file = $this->currentFileProvider->getFile();
if (!$file instanceof \Rector\Core\ValueObject\Application\File) {
return;
}
$shortentedIdentifierTypeNode = $this->processFqnNameImport($this->currentPhpParserNode, $identifierTypeNode, $staticType, $file);
if (!$shortentedIdentifierTypeNode instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) { if (!$shortentedIdentifierTypeNode instanceof \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode) {
return; return;
} }
@ -154,7 +173,11 @@ final class NameImportingPhpDocNodeVisitor extends \RectorPrefix20210721\Symplif
} }
$staticType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($staticType->getClassName()); $staticType = new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($staticType->getClassName());
} }
$importedName = $this->processFqnNameImport($this->currentPhpParserNode, $identifierTypeNode, $staticType); $file = $this->currentFileProvider->getFile();
if (!$file instanceof \Rector\Core\ValueObject\Application\File) {
return null;
}
$importedName = $this->processFqnNameImport($this->currentPhpParserNode, $identifierTypeNode, $staticType, $file);
if ($importedName !== null) { if ($importedName !== null) {
$spacelessPhpDocTagNode->name = '@' . $importedName->name; $spacelessPhpDocTagNode->name = '@' . $importedName->name;
return $spacelessPhpDocTagNode; return $spacelessPhpDocTagNode;

View File

@ -14,10 +14,6 @@ use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
use Symplify\SmartFileSystem\SmartFileInfo; use Symplify\SmartFileSystem\SmartFileInfo;
final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collector\NodeCollectorInterface final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collector\NodeCollectorInterface
{ {
/**
* @var string[][]
*/
private $removedShortUsesInFilePath = [];
/** /**
* @var array<string, FullyQualifiedObjectType[]> * @var array<string, FullyQualifiedObjectType[]>
*/ */
@ -57,34 +53,15 @@ final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collec
$smartFileInfo = $file->getSmartFileInfo(); $smartFileInfo = $file->getSmartFileInfo();
$this->functionUseImportTypesInFilePath[$smartFileInfo->getRealPath()][] = $fullyQualifiedObjectType; $this->functionUseImportTypesInFilePath[$smartFileInfo->getRealPath()][] = $fullyQualifiedObjectType;
} }
/**
* @param \PhpParser\Node $node
* @param string $shortUse
*/
public function removeShortUse($node, $shortUse) : void
{
$file = $this->currentFileProvider->getFile();
if (!$file instanceof \Rector\Core\ValueObject\Application\File) {
return;
}
$smartFileInfo = $file->getSmartFileInfo();
$this->removedShortUsesInFilePath[$smartFileInfo->getRealPath()][] = $shortUse;
}
/**
* @param \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo
*/
public function clear($smartFileInfo) : void
{
// clear applied imports, so isActive() doesn't return any false positives
unset($this->useImportTypesInFilePath[$smartFileInfo->getRealPath()], $this->functionUseImportTypesInFilePath[$smartFileInfo->getRealPath()]);
}
/** /**
* @return AliasedObjectType[]|FullyQualifiedObjectType[] * @return AliasedObjectType[]|FullyQualifiedObjectType[]
* @param \Rector\Core\ValueObject\Application\File $file
* @param \PhpParser\Node $node * @param \PhpParser\Node $node
*/ */
public function getUseImportTypesByNode($node) : array public function getUseImportTypesByNode($file, $node) : array
{ {
$filePath = $this->getRealPathFromNode(); $fileInfo = $file->getSmartFileInfo();
$filePath = $fileInfo->getRealPath();
$objectTypes = $this->useImportTypesInFilePath[$filePath] ?? []; $objectTypes = $this->useImportTypesInFilePath[$filePath] ?? [];
/** @var Use_[] $useNodes */ /** @var Use_[] $useNodes */
$useNodes = (array) $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::USE_NODES); $useNodes = (array) $node->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::USE_NODES);
@ -100,12 +77,13 @@ final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collec
return $objectTypes; return $objectTypes;
} }
/** /**
* @param \Rector\Core\ValueObject\Application\File $file
* @param \PhpParser\Node $node * @param \PhpParser\Node $node
* @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType * @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType
*/ */
public function hasImport($node, $fullyQualifiedObjectType) : bool public function hasImport($file, $node, $fullyQualifiedObjectType) : bool
{ {
$useImports = $this->getUseImportTypesByNode($node); $useImports = $this->getUseImportTypesByNode($file, $node);
foreach ($useImports as $useImport) { foreach ($useImports as $useImport) {
if ($useImport->equals($fullyQualifiedObjectType)) { if ($useImport->equals($fullyQualifiedObjectType)) {
return \true; return \true;
@ -114,17 +92,15 @@ final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collec
return \false; return \false;
} }
/** /**
* @param \PhpParser\Node $node * @param \Rector\Core\ValueObject\Application\File $file
* @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType * @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType
*/ */
public function isShortImported($node, $fullyQualifiedObjectType) : bool public function isShortImported($file, $fullyQualifiedObjectType) : bool
{ {
$filePath = $this->getRealPathFromNode(); $fileInfo = $file->getSmartFileInfo();
if ($filePath === null) { $filePath = $fileInfo->getRealPath();
return \false;
}
$shortName = $fullyQualifiedObjectType->getShortName(); $shortName = $fullyQualifiedObjectType->getShortName();
if ($this->isShortClassImported($filePath, $shortName)) { if ($this->isShortClassImported($file, $shortName)) {
return \true; return \true;
} }
$fileFunctionUseImportTypes = $this->functionUseImportTypesInFilePath[$filePath] ?? []; $fileFunctionUseImportTypes = $this->functionUseImportTypesInFilePath[$filePath] ?? [];
@ -136,12 +112,13 @@ final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collec
return \false; return \false;
} }
/** /**
* @param \PhpParser\Node $node * @param \Rector\Core\ValueObject\Application\File $file
* @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType * @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType
*/ */
public function isImportShortable($node, $fullyQualifiedObjectType) : bool public function isImportShortable($file, $fullyQualifiedObjectType) : bool
{ {
$filePath = $this->getRealPathFromNode(); $fileInfo = $file->getSmartFileInfo();
$filePath = $fileInfo->getRealPath();
$fileUseImportTypes = $this->useImportTypesInFilePath[$filePath] ?? []; $fileUseImportTypes = $this->useImportTypesInFilePath[$filePath] ?? [];
foreach ($fileUseImportTypes as $fileUseImportType) { foreach ($fileUseImportTypes as $fileUseImportType) {
if ($fullyQualifiedObjectType->equals($fileUseImportType)) { if ($fullyQualifiedObjectType->equals($fileUseImportType)) {
@ -172,26 +149,11 @@ final class UseNodesToAddCollector implements \Rector\PostRector\Contract\Collec
{ {
return $this->functionUseImportTypesInFilePath[$smartFileInfo->getRealPath()] ?? []; return $this->functionUseImportTypesInFilePath[$smartFileInfo->getRealPath()] ?? [];
} }
/** private function isShortClassImported(\Rector\Core\ValueObject\Application\File $file, string $shortName) : bool
* @return string[]
* @param \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo
*/
public function getShortUsesByFileInfo($smartFileInfo) : array
{ {
return $this->removedShortUsesInFilePath[$smartFileInfo->getRealPath()] ?? []; $fileInfo = $file->getSmartFileInfo();
} $realPath = $fileInfo->getRealPath();
private function getRealPathFromNode() : ?string $fileUseImports = $this->useImportTypesInFilePath[$realPath] ?? [];
{
$file = $this->currentFileProvider->getFile();
if (!$file instanceof \Rector\Core\ValueObject\Application\File) {
return null;
}
$smartFileInfo = $file->getSmartFileInfo();
return $smartFileInfo->getRealPath();
}
private function isShortClassImported(string $filePath, string $shortName) : bool
{
$fileUseImports = $this->useImportTypesInFilePath[$filePath] ?? [];
foreach ($fileUseImports as $fileUseImport) { foreach ($fileUseImports as $fileUseImport) {
if ($fileUseImport->getShortName() === $shortName) { if ($fileUseImport->getShortName() === $shortName) {
return \true; return \true;

View File

@ -117,18 +117,25 @@ CODE_SAMPLE
// @todo test if old stmts or new stmts! or both? :) // @todo test if old stmts or new stmts! or both? :)
/** @var Use_[] $currentUses */ /** @var Use_[] $currentUses */
$currentUses = $this->betterNodeFinder->findInstanceOf($file->getNewStmts(), \PhpParser\Node\Stmt\Use_::class); $currentUses = $this->betterNodeFinder->findInstanceOf($file->getNewStmts(), \PhpParser\Node\Stmt\Use_::class);
if (\substr_count($name->toCodeString(), '\\') <= 1) { if ($this->shouldImportName($name, $file, $currentUses)) {
return $this->nameImporter->importName($name, $currentUses); return $this->nameImporter->importName($name, $file, $currentUses);
}
if (!$this->classNameImportSkipper->isFoundInUse($name, $currentUses)) {
return $this->nameImporter->importName($name, $currentUses);
}
if ($this->classNameImportSkipper->isAlreadyImported($name, $currentUses)) {
return $this->nameImporter->importName($name, $currentUses);
}
if ($this->reflectionProvider->hasFunction(new \PhpParser\Node\Name($name->getLast()), null)) {
return $this->nameImporter->importName($name, $currentUses);
} }
return null; return null;
} }
/**
* @param Use_[] $currentUses
*/
private function shouldImportName(\PhpParser\Node\Name $name, \Rector\Core\ValueObject\Application\File $file, array $currentUses) : bool
{
if (\substr_count($name->toCodeString(), '\\') <= 1) {
return \true;
}
if (!$this->classNameImportSkipper->isFoundInUse($name, $currentUses)) {
return \true;
}
if ($this->classNameImportSkipper->isAlreadyImported($name, $currentUses)) {
return \true;
}
return $this->reflectionProvider->hasFunction(new \PhpParser\Node\Name($name->getLast()), null);
}
} }

View File

@ -70,20 +70,18 @@ final class UseAddingPostRector extends \Rector\PostRector\Rector\AbstractPostRe
$smartFileInfo = $file->getSmartFileInfo(); $smartFileInfo = $file->getSmartFileInfo();
$useImportTypes = $this->useNodesToAddCollector->getObjectImportsByFileInfo($smartFileInfo); $useImportTypes = $this->useNodesToAddCollector->getObjectImportsByFileInfo($smartFileInfo);
$functionUseImportTypes = $this->useNodesToAddCollector->getFunctionImportsByFileInfo($smartFileInfo); $functionUseImportTypes = $this->useNodesToAddCollector->getFunctionImportsByFileInfo($smartFileInfo);
$removedShortUses = $this->useNodesToAddCollector->getShortUsesByFileInfo($smartFileInfo);
$oldToNewClasses = $this->renamedClassesDataCollector->getOldToNewClasses(); $oldToNewClasses = $this->renamedClassesDataCollector->getOldToNewClasses();
// nothing to import or remove // nothing to import or remove
if ($useImportTypes === [] && $functionUseImportTypes === [] && $removedShortUses === [] && $oldToNewClasses === []) { if ($useImportTypes === [] && $functionUseImportTypes === [] && $oldToNewClasses === []) {
return $nodes; return $nodes;
} }
/** @var FullyQualifiedObjectType[] $useImportTypes */ /** @var FullyQualifiedObjectType[] $useImportTypes */
$useImportTypes = $this->typeFactory->uniquateTypes($useImportTypes); $useImportTypes = $this->typeFactory->uniquateTypes($useImportTypes);
$this->useNodesToAddCollector->clear($smartFileInfo);
// A. has namespace? add under it // A. has namespace? add under it
$namespace = $this->betterNodeFinder->findFirstInstanceOf($nodes, \PhpParser\Node\Stmt\Namespace_::class); $namespace = $this->betterNodeFinder->findFirstInstanceOf($nodes, \PhpParser\Node\Stmt\Namespace_::class);
if ($namespace instanceof \PhpParser\Node\Stmt\Namespace_) { if ($namespace instanceof \PhpParser\Node\Stmt\Namespace_) {
// first clean // first clean
$this->useImportsRemover->removeImportsFromNamespace($namespace, $removedShortUses); //$this->useImportsRemover->removeImportsFromNamespace($namespace, $removedShortUses);
// then add, to prevent adding + removing false positive of same short use // then add, to prevent adding + removing false positive of same short use
$this->useImportsAdder->addImportsToNamespace($namespace, $useImportTypes, $functionUseImportTypes); $this->useImportsAdder->addImportsToNamespace($namespace, $useImportTypes, $functionUseImportTypes);
return $nodes; return $nodes;
@ -92,7 +90,7 @@ final class UseAddingPostRector extends \Rector\PostRector\Rector\AbstractPostRe
if ($firstNode instanceof \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace) { if ($firstNode instanceof \Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace) {
$nodes = $firstNode->stmts; $nodes = $firstNode->stmts;
} }
$removedShortUses = \array_merge($removedShortUses, $this->renamedClassesDataCollector->getOldClasses()); $removedShortUses = $this->renamedClassesDataCollector->getOldClasses();
// B. no namespace? add in the top // B. no namespace? add in the top
// first clean // first clean
$nodes = $this->useImportsRemover->removeImportsFromStmts($nodes, $removedShortUses); $nodes = $this->useImportsRemover->removeImportsFromStmts($nodes, $removedShortUses);

View File

@ -45,9 +45,11 @@ final class FullyQualifiedObjectType extends \PHPStan\Type\ObjectType
public function getFunctionUseNode() : \PhpParser\Node\Stmt\Use_ public function getFunctionUseNode() : \PhpParser\Node\Stmt\Use_
{ {
$name = new \PhpParser\Node\Name($this->getClassName()); $name = new \PhpParser\Node\Name($this->getClassName());
$useUse = new \PhpParser\Node\Stmt\UseUse($name, null, \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION); $useUse = new \PhpParser\Node\Stmt\UseUse($name, null);
$name->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE, $useUse); $name->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE, $useUse);
return new \PhpParser\Node\Stmt\Use_([$useUse]); $use = new \PhpParser\Node\Stmt\Use_([$useUse]);
$use->type = \PhpParser\Node\Stmt\Use_::TYPE_FUNCTION;
return $use;
} }
public function getShortNameLowered() : string public function getShortNameLowered() : string
{ {

View File

@ -11,6 +11,7 @@ use PhpParser\Node\Stmt\Nop;
use PhpParser\Node\Stmt\Use_; use PhpParser\Node\Stmt\Use_;
use PHPStan\Type\ObjectType; use PHPStan\Type\ObjectType;
use Rector\CodingStyle\ClassNameImport\UsedImportsResolver; use Rector\CodingStyle\ClassNameImport\UsedImportsResolver;
use Rector\NodeTypeResolver\PHPStan\Type\TypeFactory;
use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\AliasedObjectType;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
final class UseImportsAdder final class UseImportsAdder
@ -19,9 +20,14 @@ final class UseImportsAdder
* @var \Rector\CodingStyle\ClassNameImport\UsedImportsResolver * @var \Rector\CodingStyle\ClassNameImport\UsedImportsResolver
*/ */
private $usedImportsResolver; private $usedImportsResolver;
public function __construct(\Rector\CodingStyle\ClassNameImport\UsedImportsResolver $usedImportsResolver) /**
* @var \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory
*/
private $typeFactory;
public function __construct(\Rector\CodingStyle\ClassNameImport\UsedImportsResolver $usedImportsResolver, \Rector\NodeTypeResolver\PHPStan\Type\TypeFactory $typeFactory)
{ {
$this->usedImportsResolver = $usedImportsResolver; $this->usedImportsResolver = $usedImportsResolver;
$this->typeFactory = $typeFactory;
} }
/** /**
* @param Stmt[] $stmts * @param Stmt[] $stmts

View File

@ -6,6 +6,7 @@ namespace Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter;
use PhpParser\Node; use PhpParser\Node;
use Rector\CodingStyle\ClassNameImport\AliasUsesResolver; use Rector\CodingStyle\ClassNameImport\AliasUsesResolver;
use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface; use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface;
use Rector\Core\ValueObject\Application\File;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
/** /**
* Prevents adding: * Prevents adding:
@ -27,10 +28,11 @@ final class AliasClassNameImportSkipVoter implements \Rector\CodingStyle\Contrac
$this->aliasUsesResolver = $aliasUsesResolver; $this->aliasUsesResolver = $aliasUsesResolver;
} }
/** /**
* @param \Rector\Core\ValueObject\Application\File $file
* @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType * @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType
* @param \PhpParser\Node $node * @param \PhpParser\Node $node
*/ */
public function shouldSkip($fullyQualifiedObjectType, $node) : bool public function shouldSkip($file, $fullyQualifiedObjectType, $node) : bool
{ {
$aliasedUses = $this->aliasUsesResolver->resolveForNode($node); $aliasedUses = $this->aliasUsesResolver->resolveForNode($node);
foreach ($aliasedUses as $aliasedUse) { foreach ($aliasedUses as $aliasedUse) {

View File

@ -6,6 +6,7 @@ namespace Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter;
use PhpParser\Node; use PhpParser\Node;
use Rector\CodingStyle\ClassNameImport\ShortNameResolver; use Rector\CodingStyle\ClassNameImport\ShortNameResolver;
use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface; use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface;
use Rector\Core\ValueObject\Application\File;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
/** /**
* Prevents adding: * Prevents adding:
@ -27,10 +28,11 @@ final class ClassLikeNameClassNameImportSkipVoter implements \Rector\CodingStyle
$this->shortNameResolver = $shortNameResolver; $this->shortNameResolver = $shortNameResolver;
} }
/** /**
* @param \Rector\Core\ValueObject\Application\File $file
* @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType * @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType
* @param \PhpParser\Node $node * @param \PhpParser\Node $node
*/ */
public function shouldSkip($fullyQualifiedObjectType, $node) : bool public function shouldSkip($file, $fullyQualifiedObjectType, $node) : bool
{ {
$classLikeNames = $this->shortNameResolver->resolveShortClassLikeNamesForNode($node); $classLikeNames = $this->shortNameResolver->resolveShortClassLikeNamesForNode($node);
foreach ($classLikeNames as $classLikeName) { foreach ($classLikeNames as $classLikeName) {

View File

@ -6,7 +6,7 @@ namespace Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter;
use PhpParser\Node; use PhpParser\Node;
use Rector\CodingStyle\ClassNameImport\ShortNameResolver; use Rector\CodingStyle\ClassNameImport\ShortNameResolver;
use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface; use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface;
use Rector\Core\Provider\CurrentFileProvider; use Rector\Core\ValueObject\Application\File;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
/** /**
* Prevents adding: * Prevents adding:
@ -23,23 +23,18 @@ final class FullyQualifiedNameClassNameImportSkipVoter implements \Rector\Coding
* @var \Rector\CodingStyle\ClassNameImport\ShortNameResolver * @var \Rector\CodingStyle\ClassNameImport\ShortNameResolver
*/ */
private $shortNameResolver; private $shortNameResolver;
/** public function __construct(\Rector\CodingStyle\ClassNameImport\ShortNameResolver $shortNameResolver)
* @var \Rector\Core\Provider\CurrentFileProvider
*/
private $currentFileProvider;
public function __construct(\Rector\CodingStyle\ClassNameImport\ShortNameResolver $shortNameResolver, \Rector\Core\Provider\CurrentFileProvider $currentFileProvider)
{ {
$this->shortNameResolver = $shortNameResolver; $this->shortNameResolver = $shortNameResolver;
$this->currentFileProvider = $currentFileProvider;
} }
/** /**
* @param \Rector\Core\ValueObject\Application\File $file
* @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType * @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType
* @param \PhpParser\Node $node * @param \PhpParser\Node $node
*/ */
public function shouldSkip($fullyQualifiedObjectType, $node) : bool public function shouldSkip($file, $fullyQualifiedObjectType, $node) : bool
{ {
// "new X" or "X::static()" // "new X" or "X::static()"
$file = $this->currentFileProvider->getFile();
$shortNamesToFullyQualifiedNames = $this->shortNameResolver->resolveForNode($file); $shortNamesToFullyQualifiedNames = $this->shortNameResolver->resolveForNode($file);
foreach ($shortNamesToFullyQualifiedNames as $shortName => $fullyQualifiedName) { foreach ($shortNamesToFullyQualifiedNames as $shortName => $fullyQualifiedName) {
$shortNameLowered = \strtolower($shortName); $shortNameLowered = \strtolower($shortName);

View File

@ -6,6 +6,7 @@ namespace Rector\CodingStyle\ClassNameImport\ClassNameImportSkipVoter;
use PhpParser\Node; use PhpParser\Node;
use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface; use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface;
use Rector\Core\Configuration\RenamedClassesDataCollector; use Rector\Core\Configuration\RenamedClassesDataCollector;
use Rector\Core\ValueObject\Application\File;
use Rector\PostRector\Collector\UseNodesToAddCollector; use Rector\PostRector\Collector\UseNodesToAddCollector;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
/** /**
@ -31,12 +32,13 @@ final class UsesClassNameImportSkipVoter implements \Rector\CodingStyle\Contract
$this->renamedClassesDataCollector = $renamedClassesDataCollector; $this->renamedClassesDataCollector = $renamedClassesDataCollector;
} }
/** /**
* @param \Rector\Core\ValueObject\Application\File $file
* @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType * @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType
* @param \PhpParser\Node $node * @param \PhpParser\Node $node
*/ */
public function shouldSkip($fullyQualifiedObjectType, $node) : bool public function shouldSkip($file, $fullyQualifiedObjectType, $node) : bool
{ {
$useImportTypes = $this->useNodesToAddCollector->getUseImportTypesByNode($node); $useImportTypes = $this->useNodesToAddCollector->getUseImportTypesByNode($file, $node);
foreach ($useImportTypes as $useImportType) { foreach ($useImportTypes as $useImportType) {
// if the class is renamed, the use import is no longer blocker // if the class is renamed, the use import is no longer blocker
if ($this->renamedClassesDataCollector->hasOldClass($useImportType->getClassName())) { if ($this->renamedClassesDataCollector->hasOldClass($useImportType->getClassName())) {

View File

@ -9,6 +9,7 @@ use PhpParser\Node\Stmt\Use_;
use PhpParser\Node\Stmt\UseUse; use PhpParser\Node\Stmt\UseUse;
use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface; use Rector\CodingStyle\Contract\ClassNameImport\ClassNameImportSkipVoterInterface;
use Rector\Core\Configuration\RenamedClassesDataCollector; use Rector\Core\Configuration\RenamedClassesDataCollector;
use Rector\Core\ValueObject\Application\File;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
final class ClassNameImportSkipper final class ClassNameImportSkipper
{ {
@ -28,10 +29,10 @@ final class ClassNameImportSkipper
$this->classNameImportSkipVoters = $classNameImportSkipVoters; $this->classNameImportSkipVoters = $classNameImportSkipVoters;
$this->renamedClassesDataCollector = $renamedClassesDataCollector; $this->renamedClassesDataCollector = $renamedClassesDataCollector;
} }
public function shouldSkipNameForFullyQualifiedObjectType(\PhpParser\Node $node, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : bool public function shouldSkipNameForFullyQualifiedObjectType(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node $node, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : bool
{ {
foreach ($this->classNameImportSkipVoters as $classNameImportSkipVoter) { foreach ($this->classNameImportSkipVoters as $classNameImportSkipVoter) {
if ($classNameImportSkipVoter->shouldSkip($fullyQualifiedObjectType, $node)) { if ($classNameImportSkipVoter->shouldSkip($file, $fullyQualifiedObjectType, $node)) {
return \true; return \true;
} }
} }

View File

@ -4,12 +4,14 @@ declare (strict_types=1);
namespace Rector\CodingStyle\Contract\ClassNameImport; namespace Rector\CodingStyle\Contract\ClassNameImport;
use PhpParser\Node; use PhpParser\Node;
use Rector\Core\ValueObject\Application\File;
use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType; use Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType;
interface ClassNameImportSkipVoterInterface interface ClassNameImportSkipVoterInterface
{ {
/** /**
* @param \Rector\Core\ValueObject\Application\File $file
* @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType * @param \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType
* @param \PhpParser\Node $node * @param \PhpParser\Node $node
*/ */
public function shouldSkip($fullyQualifiedObjectType, $node) : bool; public function shouldSkip($file, $fullyQualifiedObjectType, $node) : bool;
} }

View File

@ -14,6 +14,7 @@ use PHPStan\Reflection\ReflectionProvider;
use Rector\CodingStyle\ClassNameImport\AliasUsesResolver; use Rector\CodingStyle\ClassNameImport\AliasUsesResolver;
use Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper; use Rector\CodingStyle\ClassNameImport\ClassNameImportSkipper;
use Rector\Core\Configuration\Option; use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\Application\File;
use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\Node\AttributeKey; use Rector\NodeTypeResolver\Node\AttributeKey;
use Rector\PostRector\Collector\UseNodesToAddCollector; use Rector\PostRector\Collector\UseNodesToAddCollector;
@ -67,7 +68,7 @@ final class NameImporter
/** /**
* @param Use_[] $uses * @param Use_[] $uses
*/ */
public function importName(\PhpParser\Node\Name $name, array $uses) : ?\PhpParser\Node\Name public function importName(\PhpParser\Node\Name $name, \Rector\Core\ValueObject\Application\File $file, array $uses) : ?\PhpParser\Node\Name
{ {
if ($this->shouldSkipName($name)) { if ($this->shouldSkipName($name)) {
return null; return null;
@ -80,7 +81,7 @@ final class NameImporter
return null; return null;
} }
$this->aliasedUses = $this->aliasUsesResolver->resolveForNode($name); $this->aliasedUses = $this->aliasUsesResolver->resolveForNode($name);
return $this->importNameAndCollectNewUseStatement($name, $staticType); return $this->importNameAndCollectNewUseStatement($file, $name, $staticType);
} }
private function shouldSkipName(\PhpParser\Node\Name $name) : bool private function shouldSkipName(\PhpParser\Node\Name $name) : bool
{ {
@ -109,19 +110,19 @@ final class NameImporter
} }
return \false; return \false;
} }
private function importNameAndCollectNewUseStatement(\PhpParser\Node\Name $name, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : ?\PhpParser\Node\Name private function importNameAndCollectNewUseStatement(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node\Name $name, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : ?\PhpParser\Node\Name
{ {
// the same end is already imported → skip // the same end is already imported → skip
if ($this->classNameImportSkipper->shouldSkipNameForFullyQualifiedObjectType($name, $fullyQualifiedObjectType)) { if ($this->classNameImportSkipper->shouldSkipNameForFullyQualifiedObjectType($file, $name, $fullyQualifiedObjectType)) {
return null; return null;
} }
if ($this->useNodesToAddCollector->isShortImported($name, $fullyQualifiedObjectType)) { if ($this->useNodesToAddCollector->isShortImported($file, $fullyQualifiedObjectType)) {
if ($this->useNodesToAddCollector->isImportShortable($name, $fullyQualifiedObjectType)) { if ($this->useNodesToAddCollector->isImportShortable($file, $fullyQualifiedObjectType)) {
return $fullyQualifiedObjectType->getShortNameNode(); return $fullyQualifiedObjectType->getShortNameNode();
} }
return null; return null;
} }
$this->addUseImport($name, $fullyQualifiedObjectType); $this->addUseImport($file, $name, $fullyQualifiedObjectType);
// possibly aliased // possibly aliased
foreach ($this->aliasedUses as $aliasedUse) { foreach ($this->aliasedUses as $aliasedUse) {
if ($fullyQualifiedObjectType->getClassName() === $aliasedUse) { if ($fullyQualifiedObjectType->getClassName() === $aliasedUse) {
@ -159,9 +160,9 @@ final class NameImporter
} }
return \false; return \false;
} }
private function addUseImport(\PhpParser\Node\Name $name, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : void private function addUseImport(\Rector\Core\ValueObject\Application\File $file, \PhpParser\Node\Name $name, \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType $fullyQualifiedObjectType) : void
{ {
if ($this->useNodesToAddCollector->hasImport($name, $fullyQualifiedObjectType)) { if ($this->useNodesToAddCollector->hasImport($file, $name, $fullyQualifiedObjectType)) {
return; return;
} }
$parentNode = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE); $parentNode = $name->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::PARENT_NODE);

View File

@ -16,11 +16,11 @@ final class VersionResolver
/** /**
* @var string * @var string
*/ */
public const PACKAGE_VERSION = '242fa166104396ce6835c07b69eef3cd0936c653'; public const PACKAGE_VERSION = '24a32dfefb21f925bbf48ad58b3d834d7988ca40';
/** /**
* @var string * @var string
*/ */
public const RELEASE_DATE = '2021-07-21 11:27:17'; public const RELEASE_DATE = '2021-07-21 15:37:24';
public static function resolvePackageVersion() : string public static function resolvePackageVersion() : string
{ {
$process = new \RectorPrefix20210721\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__); $process = new \RectorPrefix20210721\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

2
vendor/autoload.php vendored
View File

@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php'; require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit38f8337ccf82794415d0e1cc2bb4c25a::getLoader(); return ComposerAutoloaderInit6360f57b832da85cfc9162265ec2d310::getLoader();

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer // autoload_real.php @generated by Composer
class ComposerAutoloaderInit38f8337ccf82794415d0e1cc2bb4c25a class ComposerAutoloaderInit6360f57b832da85cfc9162265ec2d310
{ {
private static $loader; private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit38f8337ccf82794415d0e1cc2bb4c25a
return self::$loader; return self::$loader;
} }
spl_autoload_register(array('ComposerAutoloaderInit38f8337ccf82794415d0e1cc2bb4c25a', 'loadClassLoader'), true, true); spl_autoload_register(array('ComposerAutoloaderInit6360f57b832da85cfc9162265ec2d310', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit38f8337ccf82794415d0e1cc2bb4c25a', 'loadClassLoader')); spl_autoload_unregister(array('ComposerAutoloaderInit6360f57b832da85cfc9162265ec2d310', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) { if ($useStaticLoader) {
require __DIR__ . '/autoload_static.php'; require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit38f8337ccf82794415d0e1cc2bb4c25a::getInitializer($loader)); call_user_func(\Composer\Autoload\ComposerStaticInit6360f57b832da85cfc9162265ec2d310::getInitializer($loader));
} else { } else {
$classMap = require __DIR__ . '/autoload_classmap.php'; $classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) { if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit38f8337ccf82794415d0e1cc2bb4c25a
$loader->register(true); $loader->register(true);
if ($useStaticLoader) { if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit38f8337ccf82794415d0e1cc2bb4c25a::$files; $includeFiles = Composer\Autoload\ComposerStaticInit6360f57b832da85cfc9162265ec2d310::$files;
} else { } else {
$includeFiles = require __DIR__ . '/autoload_files.php'; $includeFiles = require __DIR__ . '/autoload_files.php';
} }
foreach ($includeFiles as $fileIdentifier => $file) { foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire38f8337ccf82794415d0e1cc2bb4c25a($fileIdentifier, $file); composerRequire6360f57b832da85cfc9162265ec2d310($fileIdentifier, $file);
} }
return $loader; return $loader;
} }
} }
function composerRequire38f8337ccf82794415d0e1cc2bb4c25a($fileIdentifier, $file) function composerRequire6360f57b832da85cfc9162265ec2d310($fileIdentifier, $file)
{ {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file; require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload; namespace Composer\Autoload;
class ComposerStaticInit38f8337ccf82794415d0e1cc2bb4c25a class ComposerStaticInit6360f57b832da85cfc9162265ec2d310
{ {
public static $files = array ( public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php', 'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -3844,9 +3844,9 @@ class ComposerStaticInit38f8337ccf82794415d0e1cc2bb4c25a
public static function getInitializer(ClassLoader $loader) public static function getInitializer(ClassLoader $loader)
{ {
return \Closure::bind(function () use ($loader) { return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit38f8337ccf82794415d0e1cc2bb4c25a::$prefixLengthsPsr4; $loader->prefixLengthsPsr4 = ComposerStaticInit6360f57b832da85cfc9162265ec2d310::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit38f8337ccf82794415d0e1cc2bb4c25a::$prefixDirsPsr4; $loader->prefixDirsPsr4 = ComposerStaticInit6360f57b832da85cfc9162265ec2d310::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit38f8337ccf82794415d0e1cc2bb4c25a::$classMap; $loader->classMap = ComposerStaticInit6360f57b832da85cfc9162265ec2d310::$classMap;
}, null, ClassLoader::class); }, null, ClassLoader::class);
} }

View File

@ -1779,12 +1779,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https:\/\/github.com\/symfony\/console.git", "url": "https:\/\/github.com\/symfony\/console.git",
"reference": "c7fa320bd77e22743a34b0f03933afbba75dfbb9" "reference": "300db7fbe658482a65db9d35ede3cb6de01d8af4"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/c7fa320bd77e22743a34b0f03933afbba75dfbb9", "url": "https:\/\/api.github.com\/repos\/symfony\/console\/zipball\/300db7fbe658482a65db9d35ede3cb6de01d8af4",
"reference": "c7fa320bd77e22743a34b0f03933afbba75dfbb9", "reference": "300db7fbe658482a65db9d35ede3cb6de01d8af4",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1792,7 +1792,7 @@
"symfony\/deprecation-contracts": "^2.1", "symfony\/deprecation-contracts": "^2.1",
"symfony\/polyfill-mbstring": "~1.0", "symfony\/polyfill-mbstring": "~1.0",
"symfony\/polyfill-php73": "^1.8", "symfony\/polyfill-php73": "^1.8",
"symfony\/polyfill-php80": "^1.15", "symfony\/polyfill-php80": "^1.16",
"symfony\/service-contracts": "^1.1|^2", "symfony\/service-contracts": "^1.1|^2",
"symfony\/string": "^5.1" "symfony\/string": "^5.1"
}, },
@ -1822,7 +1822,7 @@
"symfony\/lock": "", "symfony\/lock": "",
"symfony\/process": "" "symfony\/process": ""
}, },
"time": "2021-07-21T09:14:51+00:00", "time": "2021-07-21T12:40:44+00:00",
"default-branch": true, "default-branch": true,
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
@ -1882,19 +1882,19 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https:\/\/github.com\/symfony\/dependency-injection.git", "url": "https:\/\/github.com\/symfony\/dependency-injection.git",
"reference": "a917d7cf73f5ada5641728779214c477bd5238c4" "reference": "6b12d5bcd1e2f1cc9507cea6181787d642ec46b5"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https:\/\/api.github.com\/repos\/symfony\/dependency-injection\/zipball\/a917d7cf73f5ada5641728779214c477bd5238c4", "url": "https:\/\/api.github.com\/repos\/symfony\/dependency-injection\/zipball\/6b12d5bcd1e2f1cc9507cea6181787d642ec46b5",
"reference": "a917d7cf73f5ada5641728779214c477bd5238c4", "reference": "6b12d5bcd1e2f1cc9507cea6181787d642ec46b5",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": ">=7.2.5", "php": ">=7.2.5",
"psr\/container": "^1.1.1", "psr\/container": "^1.1.1",
"symfony\/deprecation-contracts": "^2.1", "symfony\/deprecation-contracts": "^2.1",
"symfony\/polyfill-php80": "^1.15", "symfony\/polyfill-php80": "^1.16",
"symfony\/service-contracts": "^1.1.6|^2" "symfony\/service-contracts": "^1.1.6|^2"
}, },
"conflict": { "conflict": {
@ -1920,7 +1920,7 @@
"symfony\/proxy-manager-bridge": "Generate service proxies to lazy load them", "symfony\/proxy-manager-bridge": "Generate service proxies to lazy load them",
"symfony\/yaml": "" "symfony\/yaml": ""
}, },
"time": "2021-07-18T16:30:56+00:00", "time": "2021-07-21T12:40:44+00:00",
"default-branch": true, "default-branch": true,
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",

File diff suppressed because one or more lines are too long

View File

@ -9,8 +9,8 @@ $loader = require_once __DIR__.'/autoload.php';
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) { if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
spl_autoload_call('RectorPrefix20210721\AutoloadIncluder'); spl_autoload_call('RectorPrefix20210721\AutoloadIncluder');
} }
if (!class_exists('ComposerAutoloaderInit38f8337ccf82794415d0e1cc2bb4c25a', false) && !interface_exists('ComposerAutoloaderInit38f8337ccf82794415d0e1cc2bb4c25a', false) && !trait_exists('ComposerAutoloaderInit38f8337ccf82794415d0e1cc2bb4c25a', false)) { if (!class_exists('ComposerAutoloaderInit6360f57b832da85cfc9162265ec2d310', false) && !interface_exists('ComposerAutoloaderInit6360f57b832da85cfc9162265ec2d310', false) && !trait_exists('ComposerAutoloaderInit6360f57b832da85cfc9162265ec2d310', false)) {
spl_autoload_call('RectorPrefix20210721\ComposerAutoloaderInit38f8337ccf82794415d0e1cc2bb4c25a'); spl_autoload_call('RectorPrefix20210721\ComposerAutoloaderInit6360f57b832da85cfc9162265ec2d310');
} }
if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) { if (!class_exists('Doctrine\Inflector\Inflector', false) && !interface_exists('Doctrine\Inflector\Inflector', false) && !trait_exists('Doctrine\Inflector\Inflector', false)) {
spl_autoload_call('RectorPrefix20210721\Doctrine\Inflector\Inflector'); spl_autoload_call('RectorPrefix20210721\Doctrine\Inflector\Inflector');
@ -3308,9 +3308,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20210721\print_node(...func_get_args()); return \RectorPrefix20210721\print_node(...func_get_args());
} }
} }
if (!function_exists('composerRequire38f8337ccf82794415d0e1cc2bb4c25a')) { if (!function_exists('composerRequire6360f57b832da85cfc9162265ec2d310')) {
function composerRequire38f8337ccf82794415d0e1cc2bb4c25a() { function composerRequire6360f57b832da85cfc9162265ec2d310() {
return \RectorPrefix20210721\composerRequire38f8337ccf82794415d0e1cc2bb4c25a(...func_get_args()); return \RectorPrefix20210721\composerRequire6360f57b832da85cfc9162265ec2d310(...func_get_args());
} }
} }
if (!function_exists('parseArgs')) { if (!function_exists('parseArgs')) {

View File

@ -724,7 +724,7 @@ class Application implements \RectorPrefix20210721\Symfony\Contracts\Service\Res
} else { } else {
$len = 0; $len = 0;
} }
if (\false !== \strpos($message, "@anonymous\0")) { if (\strpos($message, "@anonymous\0") !== \false) {
$message = \preg_replace_callback('/[a-zA-Z_\\x7f-\\xff][\\\\a-zA-Z0-9_\\x7f-\\xff]*+@anonymous\\x00.*?\\.php(?:0x?|:[0-9]++\\$)[0-9a-fA-F]++/', function ($m) { $message = \preg_replace_callback('/[a-zA-Z_\\x7f-\\xff][\\\\a-zA-Z0-9_\\x7f-\\xff]*+@anonymous\\x00.*?\\.php(?:0x?|:[0-9]++\\$)[0-9a-fA-F]++/', function ($m) {
return \class_exists($m[0], \false) ? ((\get_parent_class($m[0]) ?: \key(\class_implements($m[0]))) ?: 'class') . '@anonymous' : $m[0]; return \class_exists($m[0], \false) ? ((\get_parent_class($m[0]) ?: \key(\class_implements($m[0]))) ?: 'class') . '@anonymous' : $m[0];
}, $message); }, $message);
@ -982,7 +982,7 @@ class Application implements \RectorPrefix20210721\Symfony\Contracts\Service\Res
continue; continue;
} }
$lev = \levenshtein($subname, $parts[$i]); $lev = \levenshtein($subname, $parts[$i]);
if ($lev <= \strlen($subname) / 3 || '' !== $subname && \false !== \strpos($parts[$i], $subname)) { if ($lev <= \strlen($subname) / 3 || '' !== $subname && \strpos($parts[$i], $subname) !== \false) {
$alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev; $alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
} elseif ($exists) { } elseif ($exists) {
$alternatives[$collectionName] += $threshold; $alternatives[$collectionName] += $threshold;
@ -991,7 +991,7 @@ class Application implements \RectorPrefix20210721\Symfony\Contracts\Service\Res
} }
foreach ($collection as $item) { foreach ($collection as $item) {
$lev = \levenshtein($name, $item); $lev = \levenshtein($name, $item);
if ($lev <= \strlen($name) / 3 || \false !== \strpos($item, $name)) { if ($lev <= \strlen($name) / 3 || \strpos($item, $name) !== \false) {
$alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev; $alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
} }
} }

View File

@ -586,7 +586,7 @@ class Command
*/ */
public function addUsage($usage) public function addUsage($usage)
{ {
if (0 !== \strpos($usage, $this->name)) { if (\strncmp($usage, $this->name, \strlen($this->name)) !== 0) {
$usage = \sprintf('%s %s', $this->name, $usage); $usage = \sprintf('%s %s', $this->name, $usage);
} }
$this->usages[] = $usage; $this->usages[] = $usage;

View File

@ -48,7 +48,7 @@ class OutputFormatter implements \RectorPrefix20210721\Symfony\Component\Console
*/ */
public static function escapeTrailingBackslash($text) : string public static function escapeTrailingBackslash($text) : string
{ {
if ('\\' === \substr($text, -1)) { if (\substr_compare($text, '\\', -\strlen('\\')) === 0) {
$len = \strlen($text); $len = \strlen($text);
$text = \rtrim($text, '\\'); $text = \rtrim($text, '\\');
$text = \str_replace("\0", '', $text); $text = \str_replace("\0", '', $text);
@ -163,7 +163,7 @@ class OutputFormatter implements \RectorPrefix20210721\Symfony\Component\Console
} }
} }
$output .= $this->applyCurrentStyle(\substr($message, $offset), $output, $width, $currentLineLength); $output .= $this->applyCurrentStyle(\substr($message, $offset), $output, $width, $currentLineLength);
if (\false !== \strpos($output, "\0")) { if (\strpos($output, "\0") !== \false) {
return \strtr($output, ["\0" => '\\', '\\<' => '<']); return \strtr($output, ["\0" => '\\', '\\<' => '<']);
} }
return \str_replace('\\<', '<', $output); return \str_replace('\\<', '<', $output);

View File

@ -265,7 +265,7 @@ class QuestionHelper extends \RectorPrefix20210721\Symfony\Component\Console\Hel
$fullChoice .= $remainingCharacters; $fullChoice .= $remainingCharacters;
$i = \false === ($encoding = \mb_detect_encoding($fullChoice, null, \true)) ? \strlen($fullChoice) : \mb_strlen($fullChoice, $encoding); $i = \false === ($encoding = \mb_detect_encoding($fullChoice, null, \true)) ? \strlen($fullChoice) : \mb_strlen($fullChoice, $encoding);
$matches = \array_filter($autocomplete($ret), function ($match) use($ret) { $matches = \array_filter($autocomplete($ret), function ($match) use($ret) {
return '' === $ret || 0 === \strpos($match, $ret); return '' === $ret || \strncmp($match, $ret, \strlen($ret)) === 0;
}); });
$numMatches = \count($matches); $numMatches = \count($matches);
$ofs = -1; $ofs = -1;
@ -293,7 +293,7 @@ class QuestionHelper extends \RectorPrefix20210721\Symfony\Component\Console\Hel
$ofs = 0; $ofs = 0;
foreach ($autocomplete($ret) as $value) { foreach ($autocomplete($ret) as $value) {
// If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle) // If typed characters match the beginning chunk of value (e.g. [AcmeDe]moBundle)
if (0 === \strpos($value, $tempRet)) { if (\strncmp($value, $tempRet, \strlen($tempRet)) === 0) {
$matches[$numMatches++] = $value; $matches[$numMatches++] = $value;
} }
} }
@ -314,7 +314,7 @@ class QuestionHelper extends \RectorPrefix20210721\Symfony\Component\Console\Hel
private function mostRecentlyEnteredValue(string $entered) : string private function mostRecentlyEnteredValue(string $entered) : string
{ {
// Determine the most recent value that the user entered // Determine the most recent value that the user entered
if (\false === \strpos($entered, ',')) { if (\strpos($entered, ',') === \false) {
return $entered; return $entered;
} }
$choices = \explode(',', $entered); $choices = \explode(',', $entered);

View File

@ -335,6 +335,7 @@ class Table
$this->calculateColumnsWidth($rows); $this->calculateColumnsWidth($rows);
$isHeader = !$this->horizontal; $isHeader = !$this->horizontal;
$isFirstRow = $this->horizontal; $isFirstRow = $this->horizontal;
$hasTitle = (bool) $this->headerTitle;
foreach ($rows as $row) { foreach ($rows as $row) {
if ($divider === $row) { if ($divider === $row) {
$isHeader = \false; $isHeader = \false;
@ -349,12 +350,9 @@ class Table
continue; continue;
} }
if ($isHeader || $isFirstRow) { if ($isHeader || $isFirstRow) {
if ($isFirstRow) { $this->renderRowSeparator($isHeader ? self::SEPARATOR_TOP : self::SEPARATOR_TOP_BOTTOM, $hasTitle ? $this->headerTitle : null, $hasTitle ? $this->style->getHeaderTitleFormat() : null);
$this->renderRowSeparator(self::SEPARATOR_TOP_BOTTOM);
$isFirstRow = \false; $isFirstRow = \false;
} else { $hasTitle = \false;
$this->renderRowSeparator(self::SEPARATOR_TOP, $this->headerTitle, $this->style->getHeaderTitleFormat());
}
} }
if ($this->horizontal) { if ($this->horizontal) {
$this->renderRow($row, $this->style->getCellRowFormat(), $this->style->getCellHeaderFormat()); $this->renderRow($row, $this->style->getCellRowFormat(), $this->style->getCellHeaderFormat());

View File

@ -67,7 +67,7 @@ class ArgvInput extends \RectorPrefix20210721\Symfony\Component\Console\Input\In
$this->parseArgument($token); $this->parseArgument($token);
} elseif ($parseOptions && '--' == $token) { } elseif ($parseOptions && '--' == $token) {
$parseOptions = \false; $parseOptions = \false;
} elseif ($parseOptions && 0 === \strpos($token, '--')) { } elseif ($parseOptions && \strncmp($token, '--', \strlen('--')) === 0) {
$this->parseLongOption($token); $this->parseLongOption($token);
} elseif ($parseOptions && '-' === $token[0] && '-' !== $token) { } elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
$this->parseShortOption($token); $this->parseShortOption($token);
@ -235,7 +235,7 @@ class ArgvInput extends \RectorPrefix20210721\Symfony\Component\Console\Input\In
$isOption = \false; $isOption = \false;
foreach ($this->tokens as $i => $token) { foreach ($this->tokens as $i => $token) {
if ($token && '-' === $token[0]) { if ($token && '-' === $token[0]) {
if (\false !== \strpos($token, '=') || !isset($this->tokens[$i + 1])) { if (\strpos($token, '=') !== \false || !isset($this->tokens[$i + 1])) {
continue; continue;
} }
// If it's a long option, consider that everything after "--" is the option name. // If it's a long option, consider that everything after "--" is the option name.
@ -271,8 +271,8 @@ class ArgvInput extends \RectorPrefix20210721\Symfony\Component\Console\Input\In
// Options with values: // Options with values:
// For long options, test for '--option=' at beginning // For long options, test for '--option=' at beginning
// For short options, test for '-o' at beginning // For short options, test for '-o' at beginning
$leading = 0 === \strpos($value, '--') ? $value . '=' : $value; $leading = \strncmp($value, '--', \strlen('--')) === 0 ? $value . '=' : $value;
if ($token === $value || '' !== $leading && 0 === \strpos($token, $leading)) { if ($token === $value || '' !== $leading && \strncmp($token, $leading, \strlen($leading)) === 0) {
return \true; return \true;
} }
} }
@ -299,8 +299,8 @@ class ArgvInput extends \RectorPrefix20210721\Symfony\Component\Console\Input\In
// Options with values: // Options with values:
// For long options, test for '--option=' at beginning // For long options, test for '--option=' at beginning
// For short options, test for '-o' at beginning // For short options, test for '-o' at beginning
$leading = 0 === \strpos($value, '--') ? $value . '=' : $value; $leading = \strncmp($value, '--', \strlen('--')) === 0 ? $value . '=' : $value;
if ('' !== $leading && 0 === \strpos($token, $leading)) { if ('' !== $leading && \strncmp($token, $leading, \strlen($leading)) === 0) {
return \substr($token, \strlen($leading)); return \substr($token, \strlen($leading));
} }
} }

View File

@ -116,9 +116,9 @@ class ArrayInput extends \RectorPrefix20210721\Symfony\Component\Console\Input\I
if ('--' === $key) { if ('--' === $key) {
return; return;
} }
if (0 === \strpos($key, '--')) { if (\strncmp($key, '--', \strlen('--')) === 0) {
$this->addLongOption(\substr($key, 2), $value); $this->addLongOption(\substr($key, 2), $value);
} elseif (0 === \strpos($key, '-')) { } elseif (\strncmp($key, '-', \strlen('-')) === 0) {
$this->addShortOption(\substr($key, 1), $value); $this->addShortOption(\substr($key, 1), $value);
} else { } else {
$this->addArgument($key, $value); $this->addArgument($key, $value);

View File

@ -53,7 +53,7 @@ class InputOption
*/ */
public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null) public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
{ {
if (0 === \strpos($name, '--')) { if (\strncmp($name, '--', \strlen('--')) === 0) {
$name = \substr($name, 2); $name = \substr($name, 2);
} }
if (empty($name)) { if (empty($name)) {

View File

@ -77,7 +77,7 @@ class ConsoleLogger extends \RectorPrefix20210721\Psr\Log\AbstractLogger
*/ */
private function interpolate(string $message, array $context) : string private function interpolate(string $message, array $context) : string
{ {
if (\false === \strpos($message, '{')) { if (\strpos($message, '{') === \false) {
return $message; return $message;
} }
$replacements = []; $replacements = [];

View File

@ -383,7 +383,7 @@ class SymfonyStyle extends \RectorPrefix20210721\Symfony\Component\Console\Style
{ {
$fetched = $this->bufferedOutput->fetch(); $fetched = $this->bufferedOutput->fetch();
//Prepend new line if last char isn't EOL: //Prepend new line if last char isn't EOL:
if ("\n" !== \substr($fetched, -1)) { if (\substr_compare($fetched, "\n", -\strlen("\n")) !== 0) {
$this->newLine(); $this->newLine();
} }
} }

View File

@ -25,7 +25,7 @@
"symfony\/deprecation-contracts": "^2.1", "symfony\/deprecation-contracts": "^2.1",
"symfony\/polyfill-mbstring": "~1.0", "symfony\/polyfill-mbstring": "~1.0",
"symfony\/polyfill-php73": "^1.8", "symfony\/polyfill-php73": "^1.8",
"symfony\/polyfill-php80": "^1.15", "symfony\/polyfill-php80": "^1.16",
"symfony\/service-contracts": "^1.1|^2", "symfony\/service-contracts": "^1.1|^2",
"symfony\/string": "^5.1" "symfony\/string": "^5.1"
}, },

View File

@ -97,7 +97,7 @@ class Alias
if (\preg_match('#[\\r\\n]|\\*/#', $message)) { if (\preg_match('#[\\r\\n]|\\*/#', $message)) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('Invalid characters found in deprecation template.'); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('Invalid characters found in deprecation template.');
} }
if (\false === \strpos($message, '%alias_id%')) { if (\strpos($message, '%alias_id%') === \false) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('The deprecation template must contain the "%alias_id%" placeholder.'); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('The deprecation template must contain the "%alias_id%" placeholder.');
} }
} }

View File

@ -85,7 +85,7 @@ class ChildDefinition extends \RectorPrefix20210721\Symfony\Component\Dependency
{ {
if (\is_int($index)) { if (\is_int($index)) {
$this->arguments['index_' . $index] = $value; $this->arguments['index_' . $index] = $value;
} elseif (0 === \strpos($index, '$')) { } elseif (\strncmp($index, '$', \strlen('$')) === 0) {
$this->arguments[$index] = $value; $this->arguments[$index] = $value;
} else { } else {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('The argument must be an existing index or the name of a constructor\'s parameter.'); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('The argument must be an existing index or the name of a constructor\'s parameter.');

View File

@ -274,7 +274,7 @@ class AutowirePass extends \RectorPrefix20210721\Symfony\Component\DependencyInj
} }
if ($this->container->has($name) && !$this->container->findDefinition($name)->isAbstract()) { if ($this->container->has($name) && !$this->container->findDefinition($name)->isAbstract()) {
foreach ($this->container->getAliases() as $id => $alias) { foreach ($this->container->getAliases() as $id => $alias) {
if ($name === (string) $alias && 0 === \strpos($id, $type . ' $')) { if ($name === (string) $alias && \strncmp($id, $type . ' $', \strlen($type . ' $')) === 0) {
return new \RectorPrefix20210721\Symfony\Component\DependencyInjection\TypedReference($name, $type, $reference->getInvalidBehavior()); return new \RectorPrefix20210721\Symfony\Component\DependencyInjection\TypedReference($name, $type, $reference->getInvalidBehavior());
} }
} }

View File

@ -47,7 +47,7 @@ class CheckDefinitionValidityPass implements \RectorPrefix20210721\Symfony\Compo
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Please add the class to service "%s" even if it is constructed by a factory since we might need to add method calls based on compile-time checks.', $id)); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Please add the class to service "%s" even if it is constructed by a factory since we might need to add method calls based on compile-time checks.', $id));
} }
if (\class_exists($id) || \interface_exists($id, \false)) { if (\class_exists($id) || \interface_exists($id, \false)) {
if (0 === \strpos($id, '\\') && 1 < \substr_count($id, '\\')) { if (\strncmp($id, '\\', \strlen('\\')) === 0 && 1 < \substr_count($id, '\\')) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface. Please specify the class attribute explicitly or remove the leading backslash by renaming the service to "%s" to get rid of this error.', $id, \substr($id, 1))); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface. Please specify the class attribute explicitly or remove the leading backslash by renaming the service to "%s" to get rid of this error.', $id, \substr($id, 1)));
} }
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface in the global namespace. Leaving out the "class" attribute is only allowed for namespaced classes. Please specify the class attribute explicitly to get rid of this error.', $id)); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('The definition for "%s" has no class attribute, and appears to reference a class or interface in the global namespace. Leaving out the "class" attribute is only allowed for namespaced classes. Please specify the class attribute explicitly to get rid of this error.', $id));

View File

@ -180,7 +180,7 @@ final class CheckTypeDeclarationsPass extends \RectorPrefix20210721\Symfony\Comp
if ('%' === ($value[0] ?? '') && \preg_match('/^%([^%]+)%$/', $value, $match)) { if ('%' === ($value[0] ?? '') && \preg_match('/^%([^%]+)%$/', $value, $match)) {
$value = $this->container->getParameter(\substr($value, 1, -1)); $value = $this->container->getParameter(\substr($value, 1, -1));
} }
if ($envPlaceholderUniquePrefix && \is_string($value) && \false !== \strpos($value, 'env_')) { if ($envPlaceholderUniquePrefix && \is_string($value) && \strpos($value, 'env_') !== \false) {
// If the value is an env placeholder that is either mixed with a string or with another env placeholder, then its resolved value will always be a string, so we don't need to resolve it. // If the value is an env placeholder that is either mixed with a string or with another env placeholder, then its resolved value will always be a string, so we don't need to resolve it.
// We don't need to change the value because it is already a string. // We don't need to change the value because it is already a string.
if ('' === \preg_replace('/' . $envPlaceholderUniquePrefix . '_\\w+_[a-f0-9]{32}/U', '', $value, -1, $c) && 1 === $c) { if ('' === \preg_replace('/' . $envPlaceholderUniquePrefix . '_\\w+_[a-f0-9]{32}/U', '', $value, -1, $c) && 1 === $c) {

View File

@ -62,7 +62,7 @@ class Compiler
*/ */
public function log($pass, $message) public function log($pass, $message)
{ {
if (\false !== \strpos($message, "\n")) { if (\strpos($message, "\n") !== \false) {
$message = \str_replace("\n", "\n" . \get_class($pass) . ': ', \trim($message)); $message = \str_replace("\n", "\n" . \get_class($pass) . ': ', \trim($message));
} }
$this->log[] = \get_class($pass) . ': ' . $message; $this->log[] = \get_class($pass) . ': ' . $message;

View File

@ -194,7 +194,7 @@ class MergeExtensionConfigurationContainerBuilder extends \RectorPrefix20210721\
return parent::resolveEnvPlaceholders($value, $format, $usedEnvs); return parent::resolveEnvPlaceholders($value, $format, $usedEnvs);
} }
foreach ($bag->getEnvPlaceholders() as $env => $placeholders) { foreach ($bag->getEnvPlaceholders() as $env => $placeholders) {
if (\false === \strpos($env, ':')) { if (\strpos($env, ':') === \false) {
continue; continue;
} }
foreach ($placeholders as $placeholder) { foreach ($placeholders as $placeholder) {

View File

@ -94,7 +94,7 @@ class RegisterServiceSubscribersPass extends \RectorPrefix20210721\Symfony\Compo
if ($name) { if ($name) {
if (\false !== ($i = \strpos($name, '::get'))) { if (\false !== ($i = \strpos($name, '::get'))) {
$name = \lcfirst(\substr($name, 5 + $i)); $name = \lcfirst(\substr($name, 5 + $i));
} elseif (\false !== \strpos($name, '::')) { } elseif (\strpos($name, '::') !== \false) {
$name = null; $name = null;
} }
} }

View File

@ -40,7 +40,7 @@ class ResolveBindingsPass extends \RectorPrefix20210721\Symfony\Component\Depend
parent::process($container); parent::process($container);
foreach ($this->unusedBindings as [$key, $serviceId, $bindingType, $file]) { foreach ($this->unusedBindings as [$key, $serviceId, $bindingType, $file]) {
$argumentType = $argumentName = $message = null; $argumentType = $argumentName = $message = null;
if (\false !== \strpos($key, ' ')) { if (\strpos($key, ' ') !== \false) {
[$argumentType, $argumentName] = \explode(' ', $key, 2); [$argumentType, $argumentName] = \explode(' ', $key, 2);
} elseif ('$' === $key[0]) { } elseif ('$' === $key[0]) {
$argumentName = $key; $argumentName = $key;

View File

@ -152,7 +152,7 @@ class ResolveChildDefinitionsPass extends \RectorPrefix20210721\Symfony\Componen
foreach ($definition->getArguments() as $k => $v) { foreach ($definition->getArguments() as $k => $v) {
if (\is_numeric($k)) { if (\is_numeric($k)) {
$def->addArgument($v); $def->addArgument($v);
} elseif (0 === \strpos($k, 'index_')) { } elseif (\strncmp($k, 'index_', \strlen('index_')) === 0) {
$def->replaceArgument((int) \substr($k, \strlen('index_')), $v); $def->replaceArgument((int) \substr($k, \strlen('index_')), $v);
} else { } else {
$def->setArgument($k, $v); $def->setArgument($k, $v);

View File

@ -236,7 +236,7 @@ class Container implements \RectorPrefix20210721\Symfony\Component\DependencyInj
continue; continue;
} }
$lev = \levenshtein($id, $knownId); $lev = \levenshtein($id, $knownId);
if ($lev <= \strlen($id) / 3 || \false !== \strpos($knownId, $id)) { if ($lev <= \strlen($id) / 3 || \strpos($knownId, $id) !== \false) {
$alternatives[] = $knownId; $alternatives[] = $knownId;
} }
} }

View File

@ -1461,7 +1461,7 @@ class ContainerBuilder extends \RectorPrefix20210721\Symfony\Component\Dependenc
} }
$path = \realpath($path) ?: $path; $path = \realpath($path) ?: $path;
foreach ($this->vendors as $vendor) { foreach ($this->vendors as $vendor) {
if (0 === \strpos($path, $vendor) && \false !== \strpbrk(\substr($path, \strlen($vendor), 1), '/' . \DIRECTORY_SEPARATOR)) { if (\strncmp($path, $vendor, \strlen($vendor)) === 0 && \false !== \strpbrk(\substr($path, \strlen($vendor), 1), '/' . \DIRECTORY_SEPARATOR)) {
$this->addResource(new \RectorPrefix20210721\Symfony\Component\Config\Resource\FileResource($vendor . '/composer/installed.json')); $this->addResource(new \RectorPrefix20210721\Symfony\Component\Config\Resource\FileResource($vendor . '/composer/installed.json'));
return \true; return \true;
} }

View File

@ -92,7 +92,7 @@ class Definition
public function setFactory($factory) public function setFactory($factory)
{ {
$this->changes['factory'] = \true; $this->changes['factory'] = \true;
if (\is_string($factory) && \false !== \strpos($factory, '::')) { if (\is_string($factory) && \strpos($factory, '::') !== \false) {
$factory = \explode('::', $factory, 2); $factory = \explode('::', $factory, 2);
} elseif ($factory instanceof \RectorPrefix20210721\Symfony\Component\DependencyInjection\Reference) { } elseif ($factory instanceof \RectorPrefix20210721\Symfony\Component\DependencyInjection\Reference) {
$factory = [$factory, '__invoke']; $factory = [$factory, '__invoke'];
@ -656,7 +656,7 @@ class Definition
if (\preg_match('#[\\r\\n]|\\*/#', $message)) { if (\preg_match('#[\\r\\n]|\\*/#', $message)) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('Invalid characters found in deprecation template.'); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('Invalid characters found in deprecation template.');
} }
if (\false === \strpos($message, '%service_id%')) { if (\strpos($message, '%service_id%') === \false) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('The deprecation template must contain the "%service_id%" placeholder.'); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException('The deprecation template must contain the "%service_id%" placeholder.');
} }
} }
@ -705,7 +705,7 @@ class Definition
public function setConfigurator($configurator) public function setConfigurator($configurator)
{ {
$this->changes['configurator'] = \true; $this->changes['configurator'] = \true;
if (\is_string($configurator) && \false !== \strpos($configurator, '::')) { if (\is_string($configurator) && \strpos($configurator, '::') !== \false) {
$configurator = \explode('::', $configurator, 2); $configurator = \explode('::', $configurator, 2);
} elseif ($configurator instanceof \RectorPrefix20210721\Symfony\Component\DependencyInjection\Reference) { } elseif ($configurator instanceof \RectorPrefix20210721\Symfony\Component\DependencyInjection\Reference) {
$configurator = [$configurator, '__invoke']; $configurator = [$configurator, '__invoke'];

View File

@ -138,7 +138,7 @@ class PhpDumper extends \RectorPrefix20210721\Symfony\Component\DependencyInject
$this->inlineFactories = $this->asFiles && $options['inline_factories_parameter'] && $this->container->hasParameter($options['inline_factories_parameter']) && $this->container->getParameter($options['inline_factories_parameter']); $this->inlineFactories = $this->asFiles && $options['inline_factories_parameter'] && $this->container->hasParameter($options['inline_factories_parameter']) && $this->container->getParameter($options['inline_factories_parameter']);
$this->inlineRequires = $options['inline_class_loader_parameter'] && ($this->container->hasParameter($options['inline_class_loader_parameter']) ? $this->container->getParameter($options['inline_class_loader_parameter']) : \PHP_VERSION_ID < 70400 || $options['debug']); $this->inlineRequires = $options['inline_class_loader_parameter'] && ($this->container->hasParameter($options['inline_class_loader_parameter']) ? $this->container->getParameter($options['inline_class_loader_parameter']) : \PHP_VERSION_ID < 70400 || $options['debug']);
$this->serviceLocatorTag = $options['service_locator_tag']; $this->serviceLocatorTag = $options['service_locator_tag'];
if (0 !== \strpos($baseClass = $options['base_class'], '\\') && 'Container' !== $baseClass) { if (\strncmp($baseClass = $options['base_class'], '\\', \strlen('\\')) !== 0 && 'Container' !== $baseClass) {
$baseClass = \sprintf('%s\\%s', $options['namespace'] ? '\\' . $options['namespace'] : '', $baseClass); $baseClass = \sprintf('%s\\%s', $options['namespace'] ? '\\' . $options['namespace'] : '', $baseClass);
$this->baseClass = $baseClass; $this->baseClass = $baseClass;
} elseif ('Container' === $baseClass) { } elseif ('Container' === $baseClass) {
@ -273,7 +273,7 @@ require __DIR__.'/{$preloadedFiles}';
EOF; EOF;
foreach ($this->preload as $class) { foreach ($this->preload as $class) {
if (!$class || \false !== \strpos($class, '$') || \in_array($class, ['int', 'float', 'string', 'bool', 'resource', 'object', 'array', 'null', 'callable', 'iterable', 'mixed', 'void'], \true)) { if (!$class || \strpos($class, '$') !== \false || \in_array($class, ['int', 'float', 'string', 'bool', 'resource', 'object', 'array', 'null', 'callable', 'iterable', 'mixed', 'void'], \true)) {
continue; continue;
} }
if (!(\class_exists($class, \false) || \interface_exists($class, \false) || \trait_exists($class, \false)) || (new \ReflectionClass($class))->isUserDefined()) { if (!(\class_exists($class, \false) || \interface_exists($class, \false) || \trait_exists($class, \false)) || (new \ReflectionClass($class))->isUserDefined()) {
@ -447,7 +447,7 @@ EOF;
return; return;
} }
$file = $r->getFileName(); $file = $r->getFileName();
if (') : eval()\'d code' === \substr($file, -17)) { if (\substr_compare($file, ') : eval()\'d code', -\strlen(') : eval()\'d code')) === 0) {
$file = \substr($file, 0, \strrpos($file, '(', -17)); $file = \substr($file, 0, \strrpos($file, '(', -17));
} }
if (!$file || $this->doExport($file) === ($exportedFile = $this->export($file))) { if (!$file || $this->doExport($file) === ($exportedFile = $this->export($file))) {
@ -553,7 +553,7 @@ EOF;
private function addServiceInstance(string $id, \RectorPrefix20210721\Symfony\Component\DependencyInjection\Definition $definition, bool $isSimpleInstance) : string private function addServiceInstance(string $id, \RectorPrefix20210721\Symfony\Component\DependencyInjection\Definition $definition, bool $isSimpleInstance) : string
{ {
$class = $this->dumpValue($definition->getClass()); $class = $this->dumpValue($definition->getClass());
if (0 === \strpos($class, "'") && \false === \strpos($class, '$') && !\preg_match('/^\'(?:\\\\{2})?[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(?:\\\\{2}[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)*\'$/', $class)) { if (\strncmp($class, "'", \strlen("'")) === 0 && \strpos($class, '$') === \false && !\preg_match('/^\'(?:\\\\{2})?[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(?:\\\\{2}[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)*\'$/', $class)) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id)); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id));
} }
$isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition); $isProxyCandidate = $this->getProxyDumper()->isProxyCandidate($definition);
@ -659,10 +659,10 @@ EOF;
} }
$class = $this->dumpValue($callable[0]); $class = $this->dumpValue($callable[0]);
// If the class is a string we can optimize away // If the class is a string we can optimize away
if (0 === \strpos($class, "'") && \false === \strpos($class, '$')) { if (\strncmp($class, "'", \strlen("'")) === 0 && \strpos($class, '$') === \false) {
return \sprintf(" %s::%s(\$%s);\n", $this->dumpLiteralClass($class), $callable[1], $variableName); return \sprintf(" %s::%s(\$%s);\n", $this->dumpLiteralClass($class), $callable[1], $variableName);
} }
if (0 === \strpos($class, 'new ')) { if (\strncmp($class, 'new ', \strlen('new ')) === 0) {
return \sprintf(" (%s)->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName); return \sprintf(" (%s)->%s(\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
} }
return \sprintf(" [%s, '%s'](\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName); return \sprintf(" [%s, '%s'](\$%s);\n", $this->dumpValue($callable[0]), $callable[1], $variableName);
@ -678,7 +678,7 @@ EOF;
$return = []; $return = [];
if ($class = $definition->getClass()) { if ($class = $definition->getClass()) {
$class = $class instanceof \RectorPrefix20210721\Symfony\Component\DependencyInjection\Parameter ? '%' . $class . '%' : $this->container->resolveEnvPlaceholders($class); $class = $class instanceof \RectorPrefix20210721\Symfony\Component\DependencyInjection\Parameter ? '%' . $class . '%' : $this->container->resolveEnvPlaceholders($class);
$return[] = \sprintf(0 === \strpos($class, '%') ? '@return object A %1$s instance' : '@return \\%s', \ltrim($class, '\\')); $return[] = \sprintf(\strncmp($class, '%', \strlen('%')) === 0 ? '@return object A %1$s instance' : '@return \\%s', \ltrim($class, '\\'));
} elseif ($definition->getFactory()) { } elseif ($definition->getFactory()) {
$factory = $definition->getFactory(); $factory = $definition->getFactory();
if (\is_string($factory)) { if (\is_string($factory)) {
@ -690,7 +690,7 @@ EOF;
} }
} }
if ($definition->isDeprecated()) { if ($definition->isDeprecated()) {
if ($return && 0 === \strpos($return[\count($return) - 1], '@return')) { if ($return && \strncmp($return[\count($return) - 1], '@return', \strlen('@return')) === 0) {
$return[] = ''; $return[] = '';
} }
$deprecation = $definition->getDeprecation($id); $deprecation = $definition->getDeprecation($id);
@ -956,13 +956,13 @@ EOTXT
} }
$class = $this->dumpValue($callable[0]); $class = $this->dumpValue($callable[0]);
// If the class is a string we can optimize away // If the class is a string we can optimize away
if (0 === \strpos($class, "'") && \false === \strpos($class, '$')) { if (\strncmp($class, "'", \strlen("'")) === 0 && \strpos($class, '$') === \false) {
if ("''" === $class) { if ("''" === $class) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Cannot dump definition: "%s" service is defined to be created by a factory but is missing the service reference, did you forget to define the factory service id or class?', $id ? 'The "' . $id . '"' : 'inline')); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Cannot dump definition: "%s" service is defined to be created by a factory but is missing the service reference, did you forget to define the factory service id or class?', $id ? 'The "' . $id . '"' : 'inline'));
} }
return $return . \sprintf('%s::%s(%s)', $this->dumpLiteralClass($class), $callable[1], $arguments ? \implode(', ', $arguments) : '') . $tail; return $return . \sprintf('%s::%s(%s)', $this->dumpLiteralClass($class), $callable[1], $arguments ? \implode(', ', $arguments) : '') . $tail;
} }
if (0 === \strpos($class, 'new ')) { if (\strncmp($class, 'new ', \strlen('new ')) === 0) {
return $return . \sprintf('(%s)->%s(%s)', $class, $callable[1], $arguments ? \implode(', ', $arguments) : '') . $tail; return $return . \sprintf('(%s)->%s(%s)', $class, $callable[1], $arguments ? \implode(', ', $arguments) : '') . $tail;
} }
return $return . \sprintf("[%s, '%s'](%s)", $class, $callable[1], $arguments ? \implode(', ', $arguments) : '') . $tail; return $return . \sprintf("[%s, '%s'](%s)", $class, $callable[1], $arguments ? \implode(', ', $arguments) : '') . $tail;
@ -1595,14 +1595,14 @@ EOF;
*/ */
private function dumpLiteralClass(string $class) : string private function dumpLiteralClass(string $class) : string
{ {
if (\false !== \strpos($class, '$')) { if (\strpos($class, '$') !== \false) {
return \sprintf('${($_ = %s) && false ?: "_"}', $class); return \sprintf('${($_ = %s) && false ?: "_"}', $class);
} }
if (0 !== \strpos($class, "'") || !\preg_match('/^\'(?:\\\\{2})?[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(?:\\\\{2}[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)*\'$/', $class)) { if (\strncmp($class, "'", \strlen("'")) !== 0 || !\preg_match('/^\'(?:\\\\{2})?[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(?:\\\\{2}[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)*\'$/', $class)) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Cannot dump definition because of invalid class name (%s).', $class ?: 'n/a')); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\RuntimeException(\sprintf('Cannot dump definition because of invalid class name (%s).', $class ?: 'n/a'));
} }
$class = \substr(\str_replace('\\\\', '\\', $class), 1, -1); $class = \substr(\str_replace('\\\\', '\\', $class), 1, -1);
return 0 === \strpos($class, '\\') ? $class : '\\' . $class; return \strncmp($class, '\\', \strlen('\\')) === 0 ? $class : '\\' . $class;
} }
private function dumpParameter(string $name) : string private function dumpParameter(string $name) : string
{ {
@ -1810,7 +1810,7 @@ EOF;
if ($shouldCacheValue && isset($this->exportedVariables[$value])) { if ($shouldCacheValue && isset($this->exportedVariables[$value])) {
return $this->exportedVariables[$value]; return $this->exportedVariables[$value];
} }
if (\is_string($value) && \false !== \strpos($value, "\n")) { if (\is_string($value) && \strpos($value, "\n") !== \false) {
$cleanParts = \explode("\n", $value); $cleanParts = \explode("\n", $value);
$cleanParts = \array_map(function ($part) { $cleanParts = \array_map(function ($part) {
return \var_export($part, \true); return \var_export($part, \true);
@ -1829,7 +1829,7 @@ EOF;
} }
if ($resolveEnv && "'" === $export[0] && $export !== ($resolvedExport = $this->container->resolveEnvPlaceholders($export, "'.\$this->getEnv('string:%s').'"))) { if ($resolveEnv && "'" === $export[0] && $export !== ($resolvedExport = $this->container->resolveEnvPlaceholders($export, "'.\$this->getEnv('string:%s').'"))) {
$export = $resolvedExport; $export = $resolvedExport;
if (".''" === \substr($export, -3)) { if (\substr_compare($export, ".''", -\strlen(".''")) === 0) {
$export = \substr($export, 0, -3); $export = \substr($export, 0, -3);
if ("'" === $export[1]) { if ("'" === $export[1]) {
$export = \substr_replace($export, '', 18, 7); $export = \substr_replace($export, '', 18, 7);
@ -1858,7 +1858,7 @@ EOF;
continue; continue;
} }
foreach (\get_declared_classes() as $class) { foreach (\get_declared_classes() as $class) {
if (0 === \strpos($class, 'ComposerAutoloaderInit') && $class::getLoader() === $autoloader[0]) { if (\strncmp($class, 'ComposerAutoloaderInit', \strlen('ComposerAutoloaderInit')) === 0 && $class::getLoader() === $autoloader[0]) {
$file = \dirname((new \ReflectionClass($class))->getFileName(), 2) . '/autoload.php'; $file = \dirname((new \ReflectionClass($class))->getFileName(), 2) . '/autoload.php';
if (null !== $this->targetDirRegex && \preg_match($this->targetDirRegex . 'A', $file)) { if (null !== $this->targetDirRegex && \preg_match($this->targetDirRegex . 'A', $file)) {
return $file; return $file;

View File

@ -293,7 +293,7 @@ class YamlDumper extends \RectorPrefix20210721\Symfony\Component\DependencyInjec
foreach ($parameters as $key => $value) { foreach ($parameters as $key => $value) {
if (\is_array($value)) { if (\is_array($value)) {
$value = $this->prepareParameters($value, $escape); $value = $this->prepareParameters($value, $escape);
} elseif ($value instanceof \RectorPrefix20210721\Symfony\Component\DependencyInjection\Reference || \is_string($value) && 0 === \strpos($value, '@')) { } elseif ($value instanceof \RectorPrefix20210721\Symfony\Component\DependencyInjection\Reference || \is_string($value) && \strncmp($value, '@', \strlen('@')) === 0) {
$value = '@' . $value; $value = '@' . $value;
} }
$filtered[$key] = $value; $filtered[$key] = $value;

View File

@ -96,7 +96,7 @@ class EnvVarProcessor implements \RectorPrefix20210721\Symfony\Component\Depende
$env = $getEnv($name); $env = $getEnv($name);
} elseif (isset($_ENV[$name])) { } elseif (isset($_ENV[$name])) {
$env = $_ENV[$name]; $env = $_ENV[$name];
} elseif (isset($_SERVER[$name]) && 0 !== \strpos($name, 'HTTP_')) { } elseif (isset($_SERVER[$name]) && \strncmp($name, 'HTTP_', \strlen('HTTP_')) !== 0) {
$env = $_SERVER[$name]; $env = $_SERVER[$name];
} elseif (\false === ($env = \getenv($name)) || null === $env) { } elseif (\false === ($env = \getenv($name)) || null === $env) {
// null is a possible value because of thread safety issues // null is a possible value because of thread safety issues

View File

@ -62,7 +62,7 @@ abstract class Extension implements \RectorPrefix20210721\Symfony\Component\Depe
public function getAlias() public function getAlias()
{ {
$className = static::class; $className = static::class;
if ('Extension' != \substr($className, -9)) { if (\substr_compare($className, 'Extension', -\strlen('Extension')) !== 0) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.'); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\BadMethodCallException('This extension does not follow the naming convention; you must overwrite the getAlias() method.');
} }
$classBaseName = \substr(\strrchr($className, '\\'), 1, -9); $classBaseName = \substr(\strrchr($className, '\\'), 1, -9);
@ -76,7 +76,7 @@ abstract class Extension implements \RectorPrefix20210721\Symfony\Component\Depe
public function getConfiguration($config, $container) public function getConfiguration($config, $container)
{ {
$class = static::class; $class = static::class;
if (\false !== \strpos($class, "\0")) { if (\strpos($class, "\0") !== \false) {
return null; return null;
// ignore anonymous classes // ignore anonymous classes
} }

View File

@ -46,6 +46,6 @@ class DirectoryLoader extends \RectorPrefix20210721\Symfony\Component\Dependency
if ('directory' === $type) { if ('directory' === $type) {
return \true; return \true;
} }
return null === $type && \is_string($resource) && '/' === \substr($resource, -1); return null === $type && \is_string($resource) && \substr_compare($resource, '/', -\strlen('/')) === 0;
} }
} }

View File

@ -82,7 +82,7 @@ abstract class FileLoader extends \RectorPrefix20210721\Symfony\Component\Config
*/ */
public function registerClasses($prototype, $namespace, $resource, $exclude = null) public function registerClasses($prototype, $namespace, $resource, $exclude = null)
{ {
if ('\\' !== \substr($namespace, -1)) { if (\substr_compare($namespace, '\\', -\strlen('\\')) !== 0) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Namespace prefix must end with a "\\": "%s".', $namespace)); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Namespace prefix must end with a "\\": "%s".', $namespace));
} }
if (!\preg_match('/^(?:[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+\\\\)++$/', $namespace)) { if (!\preg_match('/^(?:[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*+\\\\)++$/', $namespace)) {
@ -172,7 +172,7 @@ abstract class FileLoader extends \RectorPrefix20210721\Symfony\Component\Config
foreach ($this->glob($pattern, \true, $resource, \false, \false, $excludePaths) as $path => $info) { foreach ($this->glob($pattern, \true, $resource, \false, \false, $excludePaths) as $path => $info) {
if (null === $prefixLen) { if (null === $prefixLen) {
$prefixLen = \strlen($resource->getPrefix()); $prefixLen = \strlen($resource->getPrefix());
if ($excludePrefix && 0 !== \strpos($excludePrefix, $resource->getPrefix())) { if ($excludePrefix && \strncmp($excludePrefix, $resource->getPrefix(), \strlen($resource->getPrefix())) !== 0) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid "exclude" pattern when importing classes for "%s": make sure your "exclude" pattern (%s) is a subset of the "resource" pattern (%s).', $namespace, $excludePattern, $pattern)); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Invalid "exclude" pattern when importing classes for "%s": make sure your "exclude" pattern (%s) is a subset of the "resource" pattern (%s).', $namespace, $excludePattern, $pattern));
} }
} }

View File

@ -282,7 +282,7 @@ class XmlFileLoader extends \RectorPrefix20210721\Symfony\Component\DependencyIn
if ('name' === $name && '' === $tagName) { if ('name' === $name && '' === $tagName) {
continue; continue;
} }
if (\false !== \strpos($name, '-') && \false === \strpos($name, '_') && !\array_key_exists($normalizedName = \str_replace('-', '_', $name), $parameters)) { if (\strpos($name, '-') !== \false && \strpos($name, '_') === \false && !\array_key_exists($normalizedName = \str_replace('-', '_', $name), $parameters)) {
$parameters[$normalizedName] = \RectorPrefix20210721\Symfony\Component\Config\Util\XmlUtils::phpize($node->nodeValue); $parameters[$normalizedName] = \RectorPrefix20210721\Symfony\Component\Config\Util\XmlUtils::phpize($node->nodeValue);
} }
// keep not normalized key // keep not normalized key
@ -533,7 +533,7 @@ class XmlFileLoader extends \RectorPrefix20210721\Symfony\Component\DependencyIn
\array_shift($parts); \array_shift($parts);
$locationstart = 'phar:///'; $locationstart = 'phar:///';
} }
} elseif ('\\' === \DIRECTORY_SEPARATOR && 0 === \strpos($location, '\\\\')) { } elseif ('\\' === \DIRECTORY_SEPARATOR && \strncmp($location, '\\\\', \strlen('\\\\')) === 0) {
$locationstart = ''; $locationstart = '';
} }
$drive = '\\' === \DIRECTORY_SEPARATOR ? \array_shift($parts) . '/' : ''; $drive = '\\' === \DIRECTORY_SEPARATOR ? \array_shift($parts) . '/' : '';

View File

@ -154,7 +154,7 @@ class YamlFileLoader extends \RectorPrefix20210721\Symfony\Component\DependencyI
if (!$service || !\is_array($service)) { if (!$service || !\is_array($service)) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Type definition "%s" must be a non-empty array within "_instanceof" in "%s". Check your YAML syntax.', $id, $file)); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Type definition "%s" must be a non-empty array within "_instanceof" in "%s". Check your YAML syntax.', $id, $file));
} }
if (\is_string($service) && 0 === \strpos($service, '@')) { if (\is_string($service) && \strncmp($service, '@', \strlen('@')) === 0) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Type definition "%s" cannot be an alias within "_instanceof" in "%s". Check your YAML syntax.', $id, $file)); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Type definition "%s" cannot be an alias within "_instanceof" in "%s". Check your YAML syntax.', $id, $file));
} }
$this->parseDefinition($id, $service, $file, []); $this->parseDefinition($id, $service, $file, []);
@ -225,7 +225,7 @@ class YamlFileLoader extends \RectorPrefix20210721\Symfony\Component\DependencyI
private function isUsingShortSyntax(array $service) : bool private function isUsingShortSyntax(array $service) : bool
{ {
foreach ($service as $key => $value) { foreach ($service as $key => $value) {
if (\is_string($key) && ('' === $key || '$' !== $key[0] && \false === \strpos($key, '\\'))) { if (\is_string($key) && ('' === $key || '$' !== $key[0] && \strpos($key, '\\') === \false)) {
return \false; return \false;
} }
} }
@ -243,7 +243,7 @@ class YamlFileLoader extends \RectorPrefix20210721\Symfony\Component\DependencyI
if (\preg_match('/^_[a-zA-Z0-9_]*$/', $id)) { if (\preg_match('/^_[a-zA-Z0-9_]*$/', $id)) {
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Service names that start with an underscore are reserved. Rename the "%s" service or define it in XML instead.', $id)); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('Service names that start with an underscore are reserved. Rename the "%s" service or define it in XML instead.', $id));
} }
if (\is_string($service) && 0 === \strpos($service, '@')) { if (\is_string($service) && \strncmp($service, '@', \strlen('@')) === 0) {
$alias = new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Alias(\substr($service, 1)); $alias = new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Alias(\substr($service, 1));
if (isset($defaults['public'])) { if (isset($defaults['public'])) {
$alias->setPublic($defaults['public']); $alias->setPublic($defaults['public']);
@ -528,7 +528,7 @@ class YamlFileLoader extends \RectorPrefix20210721\Symfony\Component\DependencyI
{ {
if (\is_string($callable)) { if (\is_string($callable)) {
if ('' !== $callable && '@' === $callable[0]) { if ('' !== $callable && '@' === $callable[0]) {
if (\false === \strpos($callable, ':')) { if (\strpos($callable, ':') === \false) {
return [$this->resolveServices($callable, $file), '__invoke']; return [$this->resolveServices($callable, $file), '__invoke'];
} }
throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The value of the "%s" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s" in "%s").', $parameter, $id, $callable, \substr($callable, 1), $file)); throw new \RectorPrefix20210721\Symfony\Component\DependencyInjection\Exception\InvalidArgumentException(\sprintf('The value of the "%s" option for the "%s" service must be the id of the service without the "@" prefix (replace "%s" with "%s" in "%s").', $parameter, $id, $callable, \substr($callable, 1), $file));
@ -683,19 +683,19 @@ class YamlFileLoader extends \RectorPrefix20210721\Symfony\Component\DependencyI
foreach ($value as $k => $v) { foreach ($value as $k => $v) {
$value[$k] = $this->resolveServices($v, $file, $isParameter); $value[$k] = $this->resolveServices($v, $file, $isParameter);
} }
} elseif (\is_string($value) && 0 === \strpos($value, '@=')) { } elseif (\is_string($value) && \strncmp($value, '@=', \strlen('@=')) === 0) {
if (!\class_exists(\RectorPrefix20210721\Symfony\Component\ExpressionLanguage\Expression::class)) { if (!\class_exists(\RectorPrefix20210721\Symfony\Component\ExpressionLanguage\Expression::class)) {
throw new \LogicException('The "@=" expression syntax cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".'); throw new \LogicException('The "@=" expression syntax cannot be used without the ExpressionLanguage component. Try running "composer require symfony/expression-language".');
} }
return new \RectorPrefix20210721\Symfony\Component\ExpressionLanguage\Expression(\substr($value, 2)); return new \RectorPrefix20210721\Symfony\Component\ExpressionLanguage\Expression(\substr($value, 2));
} elseif (\is_string($value) && 0 === \strpos($value, '@')) { } elseif (\is_string($value) && \strncmp($value, '@', \strlen('@')) === 0) {
if (0 === \strpos($value, '@@')) { if (\strncmp($value, '@@', \strlen('@@')) === 0) {
$value = \substr($value, 1); $value = \substr($value, 1);
$invalidBehavior = null; $invalidBehavior = null;
} elseif (0 === \strpos($value, '@!')) { } elseif (\strncmp($value, '@!', \strlen('@!')) === 0) {
$value = \substr($value, 2); $value = \substr($value, 2);
$invalidBehavior = \RectorPrefix20210721\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE; $invalidBehavior = \RectorPrefix20210721\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE;
} elseif (0 === \strpos($value, '@?')) { } elseif (\strncmp($value, '@?', \strlen('@?')) === 0) {
$value = \substr($value, 2); $value = \substr($value, 2);
$invalidBehavior = \RectorPrefix20210721\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE; $invalidBehavior = \RectorPrefix20210721\Symfony\Component\DependencyInjection\ContainerInterface::IGNORE_ON_INVALID_REFERENCE;
} else { } else {

View File

@ -28,7 +28,7 @@ class EnvPlaceholderParameterBag extends \RectorPrefix20210721\Symfony\Component
*/ */
public function get($name) public function get($name)
{ {
if (0 === \strpos($name, 'env(') && ')' === \substr($name, -1) && 'env()' !== $name) { if (\strncmp($name, 'env(', \strlen('env(')) === 0 && \substr_compare($name, ')', -\strlen(')')) === 0 && 'env()' !== $name) {
$env = \substr($name, 4, -1); $env = \substr($name, 4, -1);
if (isset($this->envPlaceholders[$env])) { if (isset($this->envPlaceholders[$env])) {
foreach ($this->envPlaceholders[$env] as $placeholder) { foreach ($this->envPlaceholders[$env] as $placeholder) {

View File

@ -63,12 +63,12 @@ class ParameterBag implements \RectorPrefix20210721\Symfony\Component\Dependency
$alternatives = []; $alternatives = [];
foreach ($this->parameters as $key => $parameterValue) { foreach ($this->parameters as $key => $parameterValue) {
$lev = \levenshtein($name, $key); $lev = \levenshtein($name, $key);
if ($lev <= \strlen($name) / 3 || \false !== \strpos($key, $name)) { if ($lev <= \strlen($name) / 3 || \strpos($key, $name) !== \false) {
$alternatives[] = $key; $alternatives[] = $key;
} }
} }
$nonNestedAlternative = null; $nonNestedAlternative = null;
if (!\count($alternatives) && \false !== \strpos($name, '.')) { if (!\count($alternatives) && \strpos($name, '.') !== \false) {
$namePartsLength = \array_map('strlen', \explode('.', $name)); $namePartsLength = \array_map('strlen', \explode('.', $name));
$key = \substr($name, 0, -1 * (1 + \array_pop($namePartsLength))); $key = \substr($name, 0, -1 * (1 + \array_pop($namePartsLength)));
while (\count($namePartsLength)) { while (\count($namePartsLength)) {

View File

@ -19,7 +19,7 @@
"php": ">=7.2.5", "php": ">=7.2.5",
"psr\/container": "^1.1.1", "psr\/container": "^1.1.1",
"symfony\/deprecation-contracts": "^2.1", "symfony\/deprecation-contracts": "^2.1",
"symfony\/polyfill-php80": "^1.15", "symfony\/polyfill-php80": "^1.16",
"symfony\/service-contracts": "^1.1.6|^2" "symfony\/service-contracts": "^1.1.6|^2"
}, },
"require-dev": { "require-dev": {