Skip to content

Commit

Permalink
Updated Rector to commit b90952f
Browse files Browse the repository at this point in the history
rectorphp/rector-src@b90952f Let Rector upgrade itself to PHP 8 🤖😇 (#123)
  • Loading branch information
TomasVotruba committed May 29, 2021
1 parent eb050eb commit 7313b64
Show file tree
Hide file tree
Showing 96 changed files with 152 additions and 169 deletions.
5 changes: 5 additions & 0 deletions config/set/downgrade-php80.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@
use Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector;
use Rector\DowngradePhp80\Rector\NullsafeMethodCall\DowngradeNullsafeToTernaryOperatorRector;
use Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector;
use Rector\Removing\Rector\Class_\RemoveInterfacesRector;
use RectorPrefix20210529\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (\RectorPrefix20210529\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator $containerConfigurator) : void {
$parameters = $containerConfigurator->parameters();
$parameters->set(\Rector\Core\Configuration\Option::PHP_VERSION_FEATURES, \Rector\Core\ValueObject\PhpVersion::PHP_74);
$services = $containerConfigurator->services();
$services->set(\Rector\Removing\Rector\Class_\RemoveInterfacesRector::class)->call('configure', [[\Rector\Removing\Rector\Class_\RemoveInterfacesRector::INTERFACES_TO_REMOVE => [
// @see https://wiki.php.net/rfc/stringable
'Stringable',
]]]);
$services->set(\Rector\DowngradePhp80\Rector\Property\DowngradeUnionTypeTypedPropertyRector::class);
$services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeUnionTypeDeclarationRector::class);
$services->set(\Rector\DowngradePhp80\Rector\FunctionLike\DowngradeMixedTypeDeclarationRector::class);
Expand Down
2 changes: 1 addition & 1 deletion config/set/php80.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$services->set(\Rector\Php80\Rector\NotIdentical\StrContainsRector::class);
$services->set(\Rector\Php80\Rector\Identical\StrStartsWithRector::class);
$services->set(\Rector\Php80\Rector\Identical\StrEndsWithRector::class);
$services->set(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class)->call('configure', [\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'startsWith', 'str_starts_with'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'endsWith', 'str_ends_with'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'contains', 'str_contains')])]);
$services->set(\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::class)->call('configure', [[\Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector::STATIC_CALLS_TO_FUNCTIONS => \Symplify\SymfonyPhpConfig\ValueObjectInliner::inline([new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'startsWith', 'str_starts_with'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'endsWith', 'str_ends_with'), new \Rector\Transform\ValueObject\StaticCallToFuncCall('Nette\\Utils\\Strings', 'contains', 'str_contains')])]]);
$services->set(\Rector\Php80\Rector\Class_\StringableForToStringRector::class);
$services->set(\Rector\Php80\Rector\FuncCall\ClassOnObjectRector::class);
$services->set(\Rector\Php80\Rector\Ternary\GetDebugTypeRector::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Rector\BetterPhpDocParser\PhpDoc;

use Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode;
use Stringable;
final class DoctrineAnnotationTagValueNode extends \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Rector\BetterPhpDocParser\PhpDoc;

use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode;
use Stringable;
/**
* Useful for annotation class based annotation, e.g. @ORM\Entity to prevent space
* between the @ORM\Entity and (someContent)
Expand Down
2 changes: 1 addition & 1 deletion packages/BetterPhpDocParser/PhpDocInfo/PhpDocInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ private function resolveNameForPhpDocTagValueNode(\PHPStan\PhpDocParser\Ast\PhpD
}
private function isFnmatch(string $currentValue, string $desiredValue) : bool
{
if (!\RectorPrefix20210529\Nette\Utils\Strings::contains($desiredValue, '*')) {
if (\strpos($desiredValue, '*') === \false) {
return \false;
}
return \fnmatch($desiredValue, $currentValue, \FNM_NOESCAPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private function resolveName(string $tag, \PhpParser\Node\Stmt\UseUse $useUse) :
return $useUse->name->toString();
}
$unaliasedShortClass = \RectorPrefix20210529\Nette\Utils\Strings::substring($tag, \RectorPrefix20210529\Nette\Utils\Strings::length($useUse->alias->toString()));
if (\RectorPrefix20210529\Nette\Utils\Strings::startsWith($unaliasedShortClass, '\\')) {
if (\str_starts_with($unaliasedShortClass, '\\')) {
return $useUse->name . $unaliasedShortClass;
}
return $useUse->name . '\\' . $unaliasedShortClass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare (strict_types=1);
namespace Rector\BetterPhpDocParser\PhpDocParser;

use RectorPrefix20210529\Nette\Utils\Strings;
use PhpParser\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode;
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocNode;
Expand Down Expand Up @@ -129,7 +128,7 @@ private function transformGenericTagValueNodesToDoctrineAnnotationTagValueNodes(
// known doc tag to annotation class
$fullyQualifiedAnnotationClass = $this->classAnnotationMatcher->resolveTagFullyQualifiedName($phpDocChildNode->name, $currentPhpNode);
// not an annotations class
if (!\RectorPrefix20210529\Nette\Utils\Strings::contains($fullyQualifiedAnnotationClass, '\\')) {
if (\strpos($fullyQualifiedAnnotationClass, '\\') === \false) {
continue;
}
$genericTagValueNode = $phpDocChildNode->value;
Expand Down Expand Up @@ -159,10 +158,10 @@ private function isClosedContent(string $composedContent) : bool
return \true;
}
do {
if ($composedTokenIterator->isCurrentTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES]) || \RectorPrefix20210529\Nette\Utils\Strings::contains($composedTokenIterator->currentTokenValue(), '(')) {
if ($composedTokenIterator->isCurrentTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_CURLY_BRACKET, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_OPEN_PARENTHESES]) || \strpos($composedTokenIterator->currentTokenValue(), '(') !== \false) {
++$openBracketCount;
}
if ($composedTokenIterator->isCurrentTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES]) || \RectorPrefix20210529\Nette\Utils\Strings::contains($composedTokenIterator->currentTokenValue(), ')')) {
if ($composedTokenIterator->isCurrentTokenTypes([\PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_CURLY_BRACKET, \PHPStan\PhpDocParser\Lexer\Lexer::TOKEN_CLOSE_PARENTHESES]) || \strpos($composedTokenIterator->currentTokenValue(), ')') !== \false) {
++$closeBracketCount;
}
$composedTokenIterator->next();
Expand Down
2 changes: 1 addition & 1 deletion packages/BetterPhpDocParser/Printer/PhpDocInfoPrinter.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private function addTokensFromTo(string $output, int $from, int $to, bool $shoul
--$from;
}
// skip extra empty lines above if this is the last one
if ($shouldSkipEmptyLinesAbove && \RectorPrefix20210529\Nette\Utils\Strings::contains($this->tokens[$from][0], \PHP_EOL) && \RectorPrefix20210529\Nette\Utils\Strings::contains($this->tokens[$from + 1][0], \PHP_EOL)) {
if ($shouldSkipEmptyLinesAbove && \strpos($this->tokens[$from][0], \PHP_EOL) !== \false && \strpos($this->tokens[$from + 1][0], \PHP_EOL) !== \false) {
++$from;
}
return $this->appendToOutput($output, $from, $to, $positionJumpSet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare (strict_types=1);
namespace Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation;

use Stringable;
final class CurlyListNode extends \Rector\BetterPhpDocParser\ValueObject\PhpDoc\DoctrineAnnotation\AbstractValuesAwareNode
{
public function __toString() : string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode;
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use Stringable;
final class SpacingAwareTemplateTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\TemplateTagValueNode
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Rector\BetterPhpDocParser\ValueObject\PhpDoc;

use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
use Stringable;
final class VariadicAwareParamTagValueNode extends \PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode
{
public function __toString() : string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use PHPStan\PhpDocParser\Ast\Node;
use PHPStan\PhpDocParser\Ast\NodeAttributes;
use Rector\Core\Exception\ShouldNotHappenException;
use Stringable;
/**
* @deprecated
* Just for back compatibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Rector\BetterPhpDocParser\ValueObject\Type;

use PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode;
use Stringable;
final class BracketsAwareIntersectionTypeNode extends \PHPStan\PhpDocParser\Ast\Type\IntersectionTypeNode
{
public function __toString() : string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use Stringable;
final class BracketsAwareUnionTypeNode extends \PHPStan\PhpDocParser\Ast\Type\UnionTypeNode
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use Stringable;
final class EmptyGenericTypeNode extends \PHPStan\PhpDocParser\Ast\Type\GenericTypeNode
{
public function __construct(\PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $identifierTypeNode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace Rector\BetterPhpDocParser\ValueObject\Type;

use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use Stringable;
final class FullyQualifiedIdentifierTypeNode extends \PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode
{
public function __toString() : string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PHPStan\PhpDocParser\Ast\Type\TypeNode;
use PHPStan\PhpDocParser\Ast\Type\UnionTypeNode;
use Rector\PHPStanStaticTypeMapper\TypeMapper\ArrayTypeMapper;
use Stringable;
final class SpacingAwareArrayTypeNode extends \PHPStan\PhpDocParser\Ast\Type\ArrayTypeNode
{
public function __toString() : string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
declare (strict_types=1);
namespace Rector\BetterPhpDocParser\ValueObject\Type;

use RectorPrefix20210529\Nette\Utils\Strings;
use PHPStan\PhpDocParser\Ast\NodeAttributes;
use PHPStan\PhpDocParser\Ast\Type\CallableTypeNode;
use PHPStan\PhpDocParser\Ast\Type\GenericTypeNode;
use PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode;
use Stringable;
final class SpacingAwareCallableTypeNode extends \PHPStan\PhpDocParser\Ast\Type\CallableTypeNode
{
use NodeAttributes;
Expand All @@ -22,7 +22,7 @@ private function createExplicitCallable() : string
$returnType = $this->returnType;
$parameterTypeString = $this->createParameterTypeString();
$returnTypeAsString = (string) $returnType;
if (\RectorPrefix20210529\Nette\Utils\Strings::contains($returnTypeAsString, '|')) {
if (\strpos($returnTypeAsString, '|') !== \false) {
$returnTypeAsString = '(' . $returnTypeAsString . ')';
}
$parameterTypeString = $this->normalizeParameterType($parameterTypeString, $returnTypeAsString);
Expand Down
6 changes: 3 additions & 3 deletions packages/FileFormatter/Formatter/XmlFileFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function formatXml(string $xml) : string
$output = '';
$this->depth = 0;
$parts = $this->getXmlParts($xml);
if (\strpos($parts[0], '<?xml') === 0) {
if (\str_starts_with($parts[0], '<?xml')) {
$output = \array_shift($parts) . \PHP_EOL;
}
foreach ($parts as $part) {
Expand Down Expand Up @@ -130,10 +130,10 @@ private function isClosingTag(string $part) : bool
}
private function isOpeningCdataTag(string $part) : bool
{
return \RectorPrefix20210529\Nette\Utils\Strings::contains($part, '<![CDATA[');
return \strpos($part, '<![CDATA[') !== \false;
}
private function isClosingCdataTag(string $part) : bool
{
return \RectorPrefix20210529\Nette\Utils\Strings::contains($part, ']]>');
return \strpos($part, ']]>') !== \false;
}
}
3 changes: 2 additions & 1 deletion packages/FileFormatter/ValueObject/Indent.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Rector\FileFormatter\Exception\InvalidIndentStringException;
use Rector\FileFormatter\Exception\InvalidIndentStyleException;
use Rector\FileFormatter\Exception\ParseIndentException;
use Stringable;
/**
* @see \Rector\Tests\FileFormatter\ValueObject\IndentTest
*/
Expand Down Expand Up @@ -115,6 +116,6 @@ public function getIndentStyleCharacter() : string
}
private function startsWithSpace() : bool
{
return \RectorPrefix20210529\Nette\Utils\Strings::startsWith($this->string, ' ');
return \str_starts_with($this->string, ' ');
}
}
2 changes: 1 addition & 1 deletion packages/FileFormatter/ValueObject/NewLine.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* @see \Rector\Tests\FileFormatter\ValueObject\NewLineTest
*/
final class NewLine implements \Stringable
final class NewLine
{
/**
* @var string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function createWithDesiredGroup(\Symplify\SmartFileSystem\SmartFileInfo $
}
// is already in the right group
$currentNamespaceName = $currentNamespace->name->toString();
if (\RectorPrefix20210529\Nette\Utils\Strings::endsWith($currentNamespaceName, '\\' . $desiredGroupName)) {
if (\str_ends_with($currentNamespaceName, '\\' . $desiredGroupName)) {
return null;
}
$oldClassName = $currentNamespaceName . '\\' . $this->fileInfoDeletionAnalyzer->clearNameFromTestingPrefix($oldFileInfo->getBasenameWithoutSuffix());
Expand Down
5 changes: 2 additions & 3 deletions packages/NodeCollector/NodeCollector/NodeRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
namespace Rector\NodeCollector\NodeCollector;

use RectorPrefix20210529\Nette\Utils\Arrays;
use RectorPrefix20210529\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Attribute;
use PhpParser\Node\Expr;
Expand Down Expand Up @@ -168,7 +167,7 @@ public function findClassMethodByStaticCall(\PhpParser\Node\Expr\StaticCall $sta
}
public function findClassMethod(string $className, string $methodName) : ?\PhpParser\Node\Stmt\ClassMethod
{
if (\RectorPrefix20210529\Nette\Utils\Strings::contains($methodName, '\\')) {
if (\strpos($methodName, '\\') !== \false) {
$message = \sprintf('Class and method arguments are switched in "%s"', __METHOD__);
throw new \Rector\Core\Exception\ShouldNotHappenException($message);
}
Expand Down Expand Up @@ -270,7 +269,7 @@ public function findClassesBySuffix(string $suffix) : array
{
$classNodes = [];
foreach ($this->parsedNodeCollector->getClasses() as $className => $classNode) {
if (!\RectorPrefix20210529\Nette\Utils\Strings::endsWith($className, $suffix)) {
if (!\str_ends_with($className, $suffix)) {
continue;
}
$classNodes[] = $classNode;
Expand Down
5 changes: 2 additions & 3 deletions packages/NodeCollector/NodeCollector/ParsedNodeCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare (strict_types=1);
namespace Rector\NodeCollector\NodeCollector;

use RectorPrefix20210529\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Expr\Array_;
use PhpParser\Node\Expr\ClassConstFetch;
Expand Down Expand Up @@ -115,15 +114,15 @@ public function findTrait(string $name) : ?\PhpParser\Node\Stmt\Trait_
public function findByShortName(string $shortName) : ?\PhpParser\Node\Stmt\Class_
{
foreach ($this->classes as $className => $classNode) {
if (\RectorPrefix20210529\Nette\Utils\Strings::endsWith($className, '\\' . $shortName)) {
if (\str_ends_with($className, '\\' . $shortName)) {
return $classNode;
}
}
return null;
}
public function findClassConstant(string $className, string $constantName) : ?\PhpParser\Node\Stmt\ClassConst
{
if (\RectorPrefix20210529\Nette\Utils\Strings::contains($constantName, '\\')) {
if (\strpos($constantName, '\\') !== \false) {
throw new \Rector\Core\Exception\ShouldNotHappenException(\sprintf('Switched arguments in "%s"', __METHOD__));
}
return $this->constantsByType[$className][$constantName] ?? null;
Expand Down
2 changes: 1 addition & 1 deletion packages/NodeNameResolver/NodeNameResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ private function isSingleName(\PhpParser\Node $node, string $name) : bool
return (bool) \RectorPrefix20210529\Nette\Utils\Strings::match($resolvedName, $name);
}
// is probably fnmatch
if (\RectorPrefix20210529\Nette\Utils\Strings::contains($name, '*')) {
if (\strpos($name, '*') !== \false) {
return \fnmatch($name, $resolvedName, \FNM_NOESCAPE);
}
// special case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private function resolveDependentFiles(\PhpParser\Node $node, \PHPStan\Analyser\
foreach ($dependentFiles as $dependentFile) {
$this->dependentFiles[] = $dependentFile;
}
} catch (\PHPStan\AnalysedCodeException $analysedCodeException) {
} catch (\PHPStan\AnalysedCodeException $exception) {
// @ignoreException
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private function shouldSkip(\PHPStan\PhpDocParser\Ast\Type\IdentifierTypeNode $i
if (!$staticType instanceof \PHPStan\Type\ObjectType) {
return \true;
}
if (!\RectorPrefix20210529\Nette\Utils\Strings::startsWith($staticType->getClassName(), $pseudoNamespaceToNamespace->getNamespacePrefix())) {
if (!\str_starts_with($staticType->getClassName(), $pseudoNamespaceToNamespace->getNamespacePrefix())) {
return \true;
}
// excluded?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare (strict_types=1);
namespace Rector\PHPStanStaticTypeMapper\TypeMapper;

use RectorPrefix20210529\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Name;
use PhpParser\Node\Name\FullyQualified;
Expand Down Expand Up @@ -112,7 +111,7 @@ private function resolveGenericObjectTypeName(\PHPStan\Type\Generic\GenericObjec
if ($genericObjectType instanceof \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedGenericObjectType) {
return '\\' . $genericObjectType->getClassName();
}
if (\RectorPrefix20210529\Nette\Utils\Strings::contains($genericObjectType->getClassName(), '\\')) {
if (\strpos($genericObjectType->getClassName(), '\\') !== \false) {
return '\\' . $genericObjectType->getClassName();
}
return $genericObjectType->getClassName();
Expand Down
3 changes: 1 addition & 2 deletions packages/PostRector/Rector/UseAddingPostRector.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare (strict_types=1);
namespace Rector\PostRector\Rector;

use RectorPrefix20210529\Nette\Utils\Strings;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Namespace_;
use Rector\CodingStyle\Application\UseImportsAdder;
Expand Down Expand Up @@ -129,7 +128,7 @@ private function filterOutNonNamespacedNames(array $useImportTypes) : array
{
$namespacedUseImportTypes = [];
foreach ($useImportTypes as $useImportType) {
if (!\RectorPrefix20210529\Nette\Utils\Strings::contains($useImportType->getClassName(), '\\')) {
if (\strpos($useImportType->getClassName(), '\\') === \false) {
continue;
}
$namespacedUseImportTypes[] = $useImportType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
declare (strict_types=1);
namespace Rector\StaticTypeMapper\PhpParser;

use RectorPrefix20210529\Nette\Utils\Strings;
use PhpParser\Node;
use PhpParser\Node\Name\FullyQualified;
use PHPStan\Type\Type;
Expand Down Expand Up @@ -41,6 +40,6 @@ private function isAliasedName(string $originalName, string $fullyQualifiedName)
if ($originalName === $fullyQualifiedName) {
return \false;
}
return !\RectorPrefix20210529\Nette\Utils\Strings::endsWith($fullyQualifiedName, '\\' . $originalName);
return !\str_ends_with($fullyQualifiedName, '\\' . $originalName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function areShortNamesEqual(\PHPStan\Type\ObjectType $comparedObjectType)
}
public function getShortName() : string
{
if (!\RectorPrefix20210529\Nette\Utils\Strings::contains($this->getClassName(), '\\')) {
if (\strpos($this->getClassName(), '\\') === \false) {
return $this->getClassName();
}
return (string) \RectorPrefix20210529\Nette\Utils\Strings::after($this->getClassName(), '\\', -1);
Expand Down
Loading

0 comments on commit 7313b64

Please sign in to comment.