mirror of
https://github.com/rectorphp/rector.git
synced 2025-04-22 16:32:27 +02:00
Updated Rector to commit f985e811be98213dc0f0f6422f1a6e63ccc90ee5
f985e811be
[DX] Add strict PHPStan rules - step #1 (#1324)
This commit is contained in:
parent
439d1f1762
commit
0562d594e0
@ -21,6 +21,7 @@ use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
||||
use Rector\Core\Configuration\CurrentNodeProvider;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
final class DoctrineAnnotationDecorator
|
||||
{
|
||||
/**
|
||||
@ -100,7 +101,7 @@ final class DoctrineAnnotationDecorator
|
||||
break;
|
||||
}
|
||||
$nextPhpDocChildNode = $phpDocNode->children[$key];
|
||||
if ($nextPhpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode && \RectorPrefix20211128\Nette\Utils\Strings::match($nextPhpDocChildNode->text, self::NESTED_ANNOTATION_END_REGEX)) {
|
||||
if ($nextPhpDocChildNode instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTextNode && \Rector\Core\Util\StringUtils::isMatch($nextPhpDocChildNode->text, self::NESTED_ANNOTATION_END_REGEX)) {
|
||||
// @todo how to detect previously opened brackets?
|
||||
// probably local property with holding count of opened brackets
|
||||
$composedContent = $genericTagValueNode->value . \PHP_EOL . $nextPhpDocChildNode->text;
|
||||
|
@ -21,6 +21,7 @@ use Rector\BetterPhpDocParser\PhpDocNodeVisitor\ChangedPhpDocNodeVisitor;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\BetterPhpDocParser\ValueObject\StartAndEnd;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use RectorPrefix20211128\Symplify\SimplePhpDocParser\PhpDocNodeTraverser;
|
||||
/**
|
||||
* @see \Rector\Tests\BetterPhpDocParser\PhpDocInfo\PhpDocInfoPrinter\PhpDocInfoPrinterTest
|
||||
@ -163,11 +164,11 @@ final class PhpDocInfoPrinter
|
||||
}
|
||||
$output = $this->printEnd($output);
|
||||
// fix missing start
|
||||
if (!\RectorPrefix20211128\Nette\Utils\Strings::match($output, self::DOCBLOCK_START_REGEX) && $output) {
|
||||
if (!\Rector\Core\Util\StringUtils::isMatch($output, self::DOCBLOCK_START_REGEX) && $output) {
|
||||
$output = '/**' . $output;
|
||||
}
|
||||
// fix missing end
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($output, self::OPENING_DOCBLOCK_REGEX) && $output && !\RectorPrefix20211128\Nette\Utils\Strings::match($output, self::CLOSING_DOCBLOCK_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($output, self::OPENING_DOCBLOCK_REGEX) && $output && !\Rector\Core\Util\StringUtils::isMatch($output, self::CLOSING_DOCBLOCK_REGEX)) {
|
||||
$output .= ' */';
|
||||
}
|
||||
return $output;
|
||||
@ -243,7 +244,6 @@ final class PhpDocInfoPrinter
|
||||
for ($i = $from; $i < $to; ++$i) {
|
||||
while (isset($positionJumpSet[$i])) {
|
||||
$i = $positionJumpSet[$i];
|
||||
continue;
|
||||
}
|
||||
$output .= $this->tokens[$i][0] ?? '';
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ use PHPStan\PhpDocParser\Ast\Node;
|
||||
use PHPStan\PhpDocParser\Ast\NodeAttributes;
|
||||
use PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode;
|
||||
use Rector\BetterPhpDocParser\ValueObject\PhpDocAttributeKey;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagValueNode
|
||||
{
|
||||
use NodeAttributes;
|
||||
@ -83,11 +84,8 @@ abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpD
|
||||
public function changeValue(string $key, $value) : void
|
||||
{
|
||||
// is quoted?
|
||||
if (isset($this->values[$key]) && \is_string($this->values[$key])) {
|
||||
$isQuoted = (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($this->values[$key], self::UNQUOTED_VALUE_REGEX);
|
||||
if ($isQuoted) {
|
||||
$value = '"' . $value . '"';
|
||||
}
|
||||
if (isset($this->values[$key]) && \is_string($this->values[$key]) && \Rector\Core\Util\StringUtils::isMatch($this->values[$key], self::UNQUOTED_VALUE_REGEX)) {
|
||||
$value = '"' . $value . '"';
|
||||
}
|
||||
$this->values[$key] = $value;
|
||||
// invoke reprint
|
||||
@ -111,8 +109,7 @@ abstract class AbstractValuesAwareNode implements \PHPStan\PhpDocParser\Ast\PhpD
|
||||
public function changeSilentValue($value) : void
|
||||
{
|
||||
// is quoted?
|
||||
$isQuoted = (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($this->values[0], self::UNQUOTED_VALUE_REGEX);
|
||||
if ($isQuoted) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($this->values[0], self::UNQUOTED_VALUE_REGEX)) {
|
||||
$value = '"' . $value . '"';
|
||||
}
|
||||
$this->values[0] = $value;
|
||||
|
@ -4,6 +4,7 @@ declare (strict_types=1);
|
||||
namespace Rector\FileFormatter\Formatter;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\FileFormatter\Contract\Formatter\FileFormatterInterface;
|
||||
use Rector\FileFormatter\ValueObject\EditorConfigConfiguration;
|
||||
@ -129,11 +130,11 @@ final class XmlFileFormatter implements \Rector\FileFormatter\Contract\Formatter
|
||||
}
|
||||
private function isOpeningTag(string $part) : bool
|
||||
{
|
||||
return (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($part, self::IS_OPENING_TAG_REGEX);
|
||||
return \Rector\Core\Util\StringUtils::isMatch($part, self::IS_OPENING_TAG_REGEX);
|
||||
}
|
||||
private function isClosingTag(string $part) : bool
|
||||
{
|
||||
return (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($part, self::IS_CLOSING_TAG_REGEX);
|
||||
return \Rector\Core\Util\StringUtils::isMatch($part, self::IS_CLOSING_TAG_REGEX);
|
||||
}
|
||||
private function isOpeningCdataTag(string $part) : bool
|
||||
{
|
||||
|
@ -3,7 +3,6 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\FileSystemRector\ValueObjectFactory;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
@ -12,6 +11,7 @@ use PhpParser\Node\Stmt\Namespace_;
|
||||
use Rector\Autodiscovery\Configuration\CategoryNamespaceProvider;
|
||||
use Rector\Core\Configuration\RenamedClassesDataCollector;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\FileSystemRector\ValueObject\AddedFileWithNodes;
|
||||
use Rector\PSR4\FileInfoAnalyzer\FileInfoDeletionAnalyzer;
|
||||
@ -71,7 +71,7 @@ final class AddedFileWithNodesFactory
|
||||
if ($oldClassName === $newClassName) {
|
||||
return null;
|
||||
}
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($oldClassName, '#\\b' . $desiredGroupName . '\\b#')) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($oldClassName, '#\\b' . $desiredGroupName . '\\b#')) {
|
||||
return null;
|
||||
}
|
||||
// 1. rename namespace
|
||||
|
@ -3,10 +3,10 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\NodeCollector;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PHPStan\PhpDoc\ResolvedPhpDocBlock;
|
||||
use PHPStan\Reflection\ClassReflection;
|
||||
use PHPStan\Reflection\ReflectionProvider;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
final class StaticAnalyzer
|
||||
{
|
||||
/**
|
||||
@ -40,6 +40,6 @@ final class StaticAnalyzer
|
||||
return \false;
|
||||
}
|
||||
// @see https://regex101.com/r/7Zkej2/1
|
||||
return (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($resolvedPhpDocBlock->getPhpDocString(), '#@method\\s*static\\s*((([\\w\\|\\\\]+)|\\$this)*+(\\[\\])*)*\\s+\\b' . $methodName . '\\b#');
|
||||
return \Rector\Core\Util\StringUtils::isMatch($resolvedPhpDocBlock->getPhpDocString(), '#@method\\s*static\\s*((([\\w\\|\\\\]+)|\\$this)*+(\\[\\])*)*\\s+\\b' . $methodName . '\\b#');
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\NodeNameResolver;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
@ -15,6 +14,7 @@ use PhpParser\Node\Stmt\ClassLike;
|
||||
use Rector\CodingStyle\Naming\ClassNaming;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\NodeAnalyzer\CallAnalyzer;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeNameResolver\Contract\NodeNameResolverInterface;
|
||||
use Rector\NodeNameResolver\Error\InvalidNameNodeReporter;
|
||||
use Rector\NodeNameResolver\Regex\RegexPatternDetector;
|
||||
@ -182,7 +182,7 @@ final class NodeNameResolver
|
||||
public function endsWith(string $currentName, string $expectedName) : bool
|
||||
{
|
||||
$suffixNamePattern = '#\\w+' . \ucfirst($expectedName) . '#';
|
||||
return (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($currentName, $suffixNamePattern);
|
||||
return \Rector\Core\Util\StringUtils::isMatch($currentName, $suffixNamePattern);
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\Stmt\ClassLike|string $name
|
||||
@ -206,7 +206,7 @@ final class NodeNameResolver
|
||||
}
|
||||
// is probably regex pattern
|
||||
if ($this->regexPatternDetector->isRegexPattern($desiredName)) {
|
||||
return (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($resolvedName, $desiredName);
|
||||
return \Rector\Core\Util\StringUtils::isMatch($resolvedName, $desiredName);
|
||||
}
|
||||
// is probably fnmatch
|
||||
if (\strpos($desiredName, '*') !== \false) {
|
||||
|
@ -3,7 +3,6 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\NodeTypeResolver\PHPStan\Scope;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
@ -23,6 +22,7 @@ use Rector\Caching\FileSystem\DependencyResolver;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\StaticReflection\SourceLocator\ParentAttributeSourceLocator;
|
||||
use Rector\Core\StaticReflection\SourceLocator\RenamedClassesSourceLocator;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\PHPStan\Scope\NodeVisitor\RemoveDeepChainMethodCallNodeVisitor;
|
||||
use RectorPrefix20211128\Symplify\PackageBuilder\Reflection\PrivatesAccessor;
|
||||
@ -159,7 +159,7 @@ final class PHPStanNodeScopeResolver
|
||||
{
|
||||
$className = $this->resolveClassName($classLike);
|
||||
// is anonymous class? - not possible to enter it since PHPStan 0.12.33, see https://github.com/phpstan/phpstan-src/commit/e87fb0ec26f9c8552bbeef26a868b1e5d8185e91
|
||||
if ($classLike instanceof \PhpParser\Node\Stmt\Class_ && \RectorPrefix20211128\Nette\Utils\Strings::match($className, self::ANONYMOUS_CLASS_START_REGEX)) {
|
||||
if ($classLike instanceof \PhpParser\Node\Stmt\Class_ && \Rector\Core\Util\StringUtils::isMatch($className, self::ANONYMOUS_CLASS_START_REGEX)) {
|
||||
$classReflection = $this->reflectionProvider->getAnonymousClassReflection($classLike, $mutatingScope);
|
||||
} elseif (!$this->reflectionProvider->hasClass($className)) {
|
||||
return $mutatingScope;
|
||||
|
@ -68,7 +68,6 @@ final class PropertyTypeVendorLockResolver
|
||||
// validate parent not typed yet → it's not ok
|
||||
return \true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
|
@ -3,10 +3,10 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Autodiscovery\Rector\Class_;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Doctrine\PhpDocParser\DoctrineDocBlockResolver;
|
||||
use Rector\FileSystemRector\ValueObject\AddedFileWithNodes;
|
||||
use Rector\FileSystemRector\ValueObjectFactory\AddedFileWithNodesFactory;
|
||||
@ -86,7 +86,7 @@ CODE_SAMPLE
|
||||
}
|
||||
// is entity in expected directory?
|
||||
$smartFileInfo = $this->file->getSmartFileInfo();
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($smartFileInfo->getRealPath(), self::ENTITY_PATH_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($smartFileInfo->getRealPath(), self::ENTITY_PATH_REGEX)) {
|
||||
return null;
|
||||
}
|
||||
$addedFileWithNodes = $this->addedFileWithNodesFactory->createWithDesiredGroup($smartFileInfo, $this->file, 'Entity');
|
||||
|
@ -3,12 +3,12 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Autodiscovery\Rector\Class_;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use Rector\Autodiscovery\FileLocation\ExpectedFileLocationResolver;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\FileSystemRector\ValueObject\AddedFileWithNodes;
|
||||
use Rector\FileSystemRector\ValueObjectFactory\AddedFileWithNodesFactory;
|
||||
@ -104,14 +104,14 @@ CODE_SAMPLE
|
||||
foreach ($groupNamesBySuffix as $groupNames) {
|
||||
// has class suffix
|
||||
$suffixPattern = '\\w+' . $groupNames . '(Test)?\\.php$';
|
||||
if (!\RectorPrefix20211128\Nette\Utils\Strings::match($smartFileInfo->getRealPath(), '#' . $suffixPattern . '#')) {
|
||||
if (!\Rector\Core\Util\StringUtils::isMatch($smartFileInfo->getRealPath(), '#' . $suffixPattern . '#')) {
|
||||
continue;
|
||||
}
|
||||
if ($this->isLocatedInExpectedLocation($groupNames, $suffixPattern, $smartFileInfo)) {
|
||||
continue;
|
||||
}
|
||||
// file is already in the group
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($smartFileInfo->getPath(), '#' . $groupNames . '$#')) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($smartFileInfo->getPath(), '#' . $groupNames . '$#')) {
|
||||
continue;
|
||||
}
|
||||
$this->moveFileToGroupName($smartFileInfo, $this->file, $groupNames);
|
||||
@ -121,7 +121,7 @@ CODE_SAMPLE
|
||||
private function isLocatedInExpectedLocation(string $groupName, string $suffixPattern, \Symplify\SmartFileSystem\SmartFileInfo $smartFileInfo) : bool
|
||||
{
|
||||
$expectedLocationFilePattern = $this->expectedFileLocationResolver->resolve($groupName, $suffixPattern);
|
||||
return (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($smartFileInfo->getRealPath(), $expectedLocationFilePattern);
|
||||
return \Rector\Core\Util\StringUtils::isMatch($smartFileInfo->getRealPath(), $expectedLocationFilePattern);
|
||||
}
|
||||
private function moveFileToGroupName(\Symplify\SmartFileSystem\SmartFileInfo $fileInfo, \Rector\Core\ValueObject\Application\File $file, string $desiredGroupName) : void
|
||||
{
|
||||
|
@ -4,7 +4,6 @@ declare (strict_types=1);
|
||||
namespace Rector\CodingStyle\ClassNameImport;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Reflection;
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Name;
|
||||
@ -18,6 +17,7 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfo;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\CodingStyle\NodeAnalyzer\UseImportNameMatcher;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
@ -163,7 +163,7 @@ final class ShortNameResolver
|
||||
$phpDocNodeTraverser->traverseWithCallable($phpDocInfo->getPhpDocNode(), '', function ($node) use(&$shortNames) {
|
||||
if ($node instanceof \PHPStan\PhpDocParser\Ast\PhpDoc\PhpDocTagNode) {
|
||||
$shortName = \trim($node->name, '@');
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($shortName, self::BIG_LETTER_START_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($shortName, self::BIG_LETTER_START_REGEX)) {
|
||||
$shortNames[] = $shortName;
|
||||
}
|
||||
return null;
|
||||
|
@ -8,6 +8,7 @@ use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use PhpParser\Node\Stmt\UseUse;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
final class UseImportNameMatcher
|
||||
{
|
||||
/**
|
||||
@ -54,7 +55,7 @@ final class UseImportNameMatcher
|
||||
$shortName = $useUse->alias !== null ? $useUse->alias->name : $useUse->name->getLast();
|
||||
$shortNamePattern = \preg_quote($shortName, '#');
|
||||
$pattern = \sprintf(self::SHORT_NAME_REGEX, $shortNamePattern);
|
||||
return (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($tag, $pattern);
|
||||
return \Rector\Core\Util\StringUtils::isMatch($tag, $pattern);
|
||||
}
|
||||
private function resolveName(string $tag, \PhpParser\Node\Stmt\UseUse $useUse) : string
|
||||
{
|
||||
|
@ -23,6 +23,7 @@ use Rector\CodingStyle\NodeFactory\JsonEncodeStaticCallFactory;
|
||||
use Rector\CodingStyle\ValueObject\ConcatExpressionJoinData;
|
||||
use Rector\CodingStyle\ValueObject\NodeToRemoveAndConcatItem;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
@ -148,7 +149,7 @@ CODE_SAMPLE
|
||||
}
|
||||
private function isJsonString(string $stringValue) : bool
|
||||
{
|
||||
if (!(bool) \RectorPrefix20211128\Nette\Utils\Strings::match($stringValue, self::JSON_STRING_REGEX)) {
|
||||
if (!\Rector\Core\Util\StringUtils::isMatch($stringValue, self::JSON_STRING_REGEX)) {
|
||||
return \false;
|
||||
}
|
||||
try {
|
||||
|
@ -11,6 +11,7 @@ use PhpParser\Node\Expr\Variable;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use PhpParser\Node\Stmt\Nop;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
@ -80,7 +81,7 @@ CODE_SAMPLE
|
||||
}
|
||||
$varName = '$' . $this->getName($node->var);
|
||||
$varPattern = '# ' . \preg_quote($varName, '#') . ' #';
|
||||
if (!\RectorPrefix20211128\Nette\Utils\Strings::match($docContent, $varPattern)) {
|
||||
if (!\Rector\Core\Util\StringUtils::isMatch($docContent, $varPattern)) {
|
||||
return null;
|
||||
}
|
||||
// switch docs
|
||||
@ -126,7 +127,7 @@ CODE_SAMPLE
|
||||
$docContent = \RectorPrefix20211128\Nette\Utils\Strings::replace($docContent, self::SINGLE_ASTERISK_COMMENT_START_REGEX, '/** ');
|
||||
}
|
||||
// $value is first, instead of type is first
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($docContent, self::VAR_ANNOTATION_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($docContent, self::VAR_ANNOTATION_REGEX)) {
|
||||
$docContent = \RectorPrefix20211128\Nette\Utils\Strings::replace($docContent, self::VARIABLE_NAME_AND_TYPE_MATCH_REGEX, '$3$2$1');
|
||||
}
|
||||
return new \PhpParser\Comment\Doc($docContent);
|
||||
|
@ -11,6 +11,7 @@ use PhpParser\Node\Identifier;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use Rector\CodingStyle\ValueObject\ObjectMagicMethods;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
@ -64,7 +65,7 @@ CODE_SAMPLE
|
||||
if (\in_array($methodName, \Rector\CodingStyle\ValueObject\ObjectMagicMethods::METHOD_NAMES, \true)) {
|
||||
return null;
|
||||
}
|
||||
if (!\RectorPrefix20211128\Nette\Utils\Strings::match($methodName, self::DOUBLE_UNDERSCORE_START_REGEX)) {
|
||||
if (!\Rector\Core\Util\StringUtils::isMatch($methodName, self::DOUBLE_UNDERSCORE_START_REGEX)) {
|
||||
return null;
|
||||
}
|
||||
$newName = \RectorPrefix20211128\Nette\Utils\Strings::substring($methodName, 2);
|
||||
|
@ -12,6 +12,7 @@ use PhpParser\Node\Scalar\String_;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
@ -134,7 +135,7 @@ CODE_SAMPLE
|
||||
$string = $arg->value;
|
||||
$string->value = \RectorPrefix20211128\Nette\Utils\Strings::replace($string->value, self::INNER_REGEX, function (array $match) use(&$string) : string {
|
||||
$printedString = $this->betterStandardPrinter->print($string);
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($printedString, self::DOUBLE_QUOTED_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($printedString, self::DOUBLE_QUOTED_REGEX)) {
|
||||
$string->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN, \true);
|
||||
}
|
||||
$innerPattern = $match['content'];
|
||||
|
@ -3,10 +3,10 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\CodingStyle\Rector\String_;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
@ -94,6 +94,6 @@ CODE_SAMPLE
|
||||
}
|
||||
private function isMatchEscapedChars(string $string) : bool
|
||||
{
|
||||
return (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($string, self::ESCAPED_CHAR_REGEX);
|
||||
return \Rector\Core\Util\StringUtils::isMatch($string, self::ESCAPED_CHAR_REGEX);
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\DowngradePhp73\Tokenizer;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Core\ValueObject\Application\File;
|
||||
final class FollowedByCommaAnalyzer
|
||||
{
|
||||
@ -15,7 +15,7 @@ final class FollowedByCommaAnalyzer
|
||||
while (isset($oldTokens[$nextTokenPosition])) {
|
||||
$currentToken = $oldTokens[$nextTokenPosition];
|
||||
// only space
|
||||
if (\is_array($currentToken) || \RectorPrefix20211128\Nette\Utils\Strings::match($currentToken, '#\\s+#')) {
|
||||
if (\is_array($currentToken) || \Rector\Core\Util\StringUtils::isMatch($currentToken, '#\\s+#')) {
|
||||
++$nextTokenPosition;
|
||||
continue;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ namespace Rector\Naming\ExpectedNameResolver;
|
||||
|
||||
use RectorPrefix20211128\Doctrine\Inflector\Inflector;
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
/**
|
||||
* @see \Rector\Core\Tests\Naming\ExpectedNameResolver\InflectorSingularResolverTest
|
||||
*/
|
||||
@ -76,11 +77,11 @@ final class InflectorSingularResolver
|
||||
if ($currentName === $plural) {
|
||||
return $singular;
|
||||
}
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($currentName, '#' . \ucfirst($plural) . '#')) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($currentName, '#' . \ucfirst($plural) . '#')) {
|
||||
$resolvedValue = \RectorPrefix20211128\Nette\Utils\Strings::replace($currentName, '#' . \ucfirst($plural) . '#', \ucfirst($singular));
|
||||
return $this->singularizeCamelParts($resolvedValue);
|
||||
}
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($currentName, '#' . $plural . '#')) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($currentName, '#' . $plural . '#')) {
|
||||
$resolvedValue = \RectorPrefix20211128\Nette\Utils\Strings::replace($currentName, '#' . $plural . '#', $singular);
|
||||
return $this->singularizeCamelParts($resolvedValue);
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ declare (strict_types=1);
|
||||
namespace Rector\Naming\Guard;
|
||||
|
||||
use DateTimeInterface;
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\Variable;
|
||||
@ -17,6 +16,7 @@ use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Type\ObjectType;
|
||||
use PHPStan\Type\TypeWithClassName;
|
||||
use Rector\Core\PhpParser\Node\BetterNodeFinder;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Naming\Naming\ConflictingNameResolver;
|
||||
use Rector\Naming\Naming\OverridenExistingNamesResolver;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
@ -219,6 +219,6 @@ final class BreakingVariableRenameGuard
|
||||
}
|
||||
/** @var string $currentName */
|
||||
$currentName = $this->nodeNameResolver->getName($param);
|
||||
return (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($currentName, self::AT_NAMING_REGEX . '');
|
||||
return \Rector\Core\Util\StringUtils::isMatch($currentName, self::AT_NAMING_REGEX . '');
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ declare (strict_types=1);
|
||||
namespace Rector\Naming\Guard;
|
||||
|
||||
use DateTimeInterface;
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PHPStan\Type\TypeWithClassName;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Naming\Contract\Guard\ConflictingNameGuardInterface;
|
||||
use Rector\Naming\Contract\RenameValueObjectInterface;
|
||||
use Rector\Naming\ValueObject\PropertyRename;
|
||||
@ -48,6 +48,6 @@ final class DateTimeAtNamingConventionGuard implements \Rector\Naming\Contract\G
|
||||
if (!\is_a($type->getClassName(), \DateTimeInterface::class, \true)) {
|
||||
return \false;
|
||||
}
|
||||
return (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($propertyRename->getCurrentName(), self::AT_NAMING_REGEX . '');
|
||||
return \Rector\Core\Util\StringUtils::isMatch($propertyRename->getCurrentName(), self::AT_NAMING_REGEX . '');
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ use PHPStan\Type\StaticType;
|
||||
use PHPStan\Type\Type;
|
||||
use PHPStan\Type\TypeWithClassName;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Naming\RectorNamingInflector;
|
||||
use Rector\Naming\ValueObject\ExpectedName;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
@ -92,7 +93,7 @@ final class PropertyNaming
|
||||
return null;
|
||||
}
|
||||
foreach (self::EXCLUDED_CLASSES as $excludedClass) {
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($className, $excludedClass)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($className, $excludedClass)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -204,7 +205,7 @@ final class PropertyNaming
|
||||
return $shortName;
|
||||
}
|
||||
// starts with "I\W+"?
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($shortName, self::I_PREFIX_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($shortName, self::I_PREFIX_REGEX)) {
|
||||
return \RectorPrefix20211128\Nette\Utils\Strings::substring($shortName, 1);
|
||||
}
|
||||
if (\substr_compare($shortName, self::INTERFACE, -\strlen(self::INTERFACE)) === 0) {
|
||||
|
@ -3,10 +3,10 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Naming\NamingConvention;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node\Expr\FuncCall;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\Expr\StaticCall;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
final class NamingConventionAnalyzer
|
||||
{
|
||||
@ -34,6 +34,6 @@ final class NamingConventionAnalyzer
|
||||
return \true;
|
||||
}
|
||||
// starts with or ends with
|
||||
return (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($currentName, '#^(' . $expectedName . '|' . $expectedName . '$)#i');
|
||||
return \Rector\Core\Util\StringUtils::isMatch($currentName, '#^(' . $expectedName . '|' . $expectedName . '$)#i');
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,13 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Php70\Rector\FunctionLike;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Name\FullyQualified;
|
||||
use PhpParser\Node\NullableType;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
@ -64,7 +64,7 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
// is probably handling exceptions
|
||||
if (!\RectorPrefix20211128\Nette\Utils\Strings::match((string) $node->name, self::HANDLE_INSENSITIVE_REGEX)) {
|
||||
if (!\Rector\Core\Util\StringUtils::isMatch((string) $node->name, self::HANDLE_INSENSITIVE_REGEX)) {
|
||||
return null;
|
||||
}
|
||||
if (!$paramNode->type instanceof \PhpParser\Node\NullableType) {
|
||||
|
@ -10,6 +10,7 @@ use PhpParser\Node\Expr\StaticCall;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use Rector\Core\Php\Regex\RegexPatternArgumentManipulator;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
@ -77,7 +78,7 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
foreach ($regexArguments as $regexArgument) {
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($regexArgument->value, self::THREE_BACKSLASH_FOR_ESCAPE_NEXT_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($regexArgument->value, self::THREE_BACKSLASH_FOR_ESCAPE_NEXT_REGEX)) {
|
||||
continue;
|
||||
}
|
||||
$this->escapeStringNode($regexArgument);
|
||||
@ -87,13 +88,13 @@ CODE_SAMPLE
|
||||
private function escapeStringNode(\PhpParser\Node\Scalar\String_ $string) : void
|
||||
{
|
||||
$stringValue = $string->value;
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($stringValue, self::LEFT_HAND_UNESCAPED_DASH_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($stringValue, self::LEFT_HAND_UNESCAPED_DASH_REGEX)) {
|
||||
$string->value = \RectorPrefix20211128\Nette\Utils\Strings::replace($stringValue, self::LEFT_HAND_UNESCAPED_DASH_REGEX, '$1\\-');
|
||||
// helped needed to skip re-escaping regular expression
|
||||
$string->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN, \true);
|
||||
return;
|
||||
}
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($stringValue, self::RIGHT_HAND_UNESCAPED_DASH_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($stringValue, self::RIGHT_HAND_UNESCAPED_DASH_REGEX)) {
|
||||
$string->value = \RectorPrefix20211128\Nette\Utils\Strings::replace($stringValue, self::RIGHT_HAND_UNESCAPED_DASH_REGEX, '\\-$1]');
|
||||
// helped needed to skip re-escaping regular expression
|
||||
$string->setAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN, \true);
|
||||
|
@ -9,6 +9,7 @@ use PhpParser\Node\Scalar\DNumber;
|
||||
use PhpParser\Node\Scalar\LNumber;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Core\ValueObject\PhpVersionFeature;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\VersionBonding\Contract\MinPhpVersionInterface;
|
||||
@ -139,7 +140,7 @@ CODE_SAMPLE
|
||||
return \true;
|
||||
}
|
||||
// e+/e-
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($numericValueAsString, '#e#i')) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($numericValueAsString, '#e#i')) {
|
||||
return \true;
|
||||
}
|
||||
// too short
|
||||
|
@ -3,7 +3,6 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Php80\NodeManipulator;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr;
|
||||
@ -21,6 +20,7 @@ use PHPStan\Type\ArrayType;
|
||||
use Rector\Core\NodeAnalyzer\ArgsAnalyzer;
|
||||
use Rector\Core\PhpParser\Comparing\NodeComparator;
|
||||
use Rector\Core\PhpParser\Node\Value\ValueResolver;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
use Rector\NodeTypeResolver\NodeTypeResolver;
|
||||
@ -158,7 +158,7 @@ final class TokenManipulator
|
||||
if ($constName === null) {
|
||||
return null;
|
||||
}
|
||||
if (!\RectorPrefix20211128\Nette\Utils\Strings::match($constName, '#^T_#')) {
|
||||
if (!\Rector\Core\Util\StringUtils::isMatch($constName, '#^T_#')) {
|
||||
return null;
|
||||
}
|
||||
return $this->createIsTConstTypeMethodCall($arrayDimFetch, $arrayDimFetchAndConstFetch->getConstFetch());
|
||||
|
@ -7,6 +7,7 @@ use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\CodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
/**
|
||||
@ -51,7 +52,7 @@ CODE_SAMPLE
|
||||
$smartFileInfo = $this->file->getSmartFileInfo();
|
||||
$oldPathname = $smartFileInfo->getPathname();
|
||||
// ends with Spec.php
|
||||
if (!\RectorPrefix20211128\Nette\Utils\Strings::match($oldPathname, self::SPEC_SUFFIX_REGEX)) {
|
||||
if (!\Rector\Core\Util\StringUtils::isMatch($oldPathname, self::SPEC_SUFFIX_REGEX)) {
|
||||
return null;
|
||||
}
|
||||
$newPathName = $this->createPathName($oldPathname);
|
||||
|
@ -3,7 +3,6 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Restoration\Rector\Namespace_;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
@ -11,6 +10,7 @@ use PhpParser\Node\Stmt\Namespace_;
|
||||
use PhpParser\Node\Stmt\Use_;
|
||||
use Rector\Core\Contract\Rector\ConfigurableRectorInterface;
|
||||
use Rector\Core\Rector\AbstractRector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Restoration\ValueObject\CompleteImportForPartialAnnotation;
|
||||
use RectorPrefix20211128\Symplify\Astral\ValueObject\NodeBuilder\UseBuilder;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
@ -73,7 +73,7 @@ CODE_SAMPLE
|
||||
$printedClass = $this->print($class);
|
||||
foreach ($this->useImportsToRestore as $useImportToRestore) {
|
||||
$annotationToSeek = '#\\*\\s+\\@' . $useImportToRestore->getAlias() . '#';
|
||||
if (!\RectorPrefix20211128\Nette\Utils\Strings::match($printedClass, $annotationToSeek)) {
|
||||
if (!\Rector\Core\Util\StringUtils::isMatch($printedClass, $annotationToSeek)) {
|
||||
continue;
|
||||
}
|
||||
$node = $this->addImportToNamespaceIfMissing($node, $useImportToRestore);
|
||||
|
@ -71,7 +71,7 @@ final class DoctrineRelationPropertyTypeInferer implements \Rector\TypeDeclarati
|
||||
{
|
||||
$types = [];
|
||||
$targetEntity = $doctrineAnnotationTagValueNode->getValueWithoutQuotes('targetEntity');
|
||||
if ($targetEntity) {
|
||||
if (\is_string($targetEntity)) {
|
||||
$entityFullyQualifiedClass = $this->shortClassExpander->resolveFqnTargetEntity($targetEntity, $property);
|
||||
$types[] = new \PHPStan\Type\ArrayType(new \PHPStan\Type\MixedType(), new \Rector\StaticTypeMapper\ValueObject\Type\FullyQualifiedObjectType($entityFullyQualifiedClass));
|
||||
}
|
||||
|
@ -3,10 +3,7 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer;
|
||||
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\TypeDeclaration\Contract\TypeInferer\ReturnTypeInfererInterface;
|
||||
|
@ -4,13 +4,11 @@ declare (strict_types=1);
|
||||
namespace Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\MethodCall;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PhpParser\Node\Stmt\Interface_;
|
||||
use PhpParser\Node\Stmt\Return_;
|
||||
use PhpParser\Node\Stmt\Trait_;
|
||||
|
@ -5,12 +5,9 @@ namespace Rector\TypeDeclaration\TypeInferer\ReturnTypeInferer;
|
||||
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\Yield_;
|
||||
use PhpParser\Node\Expr\YieldFrom;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
use PhpParser\Node\Stmt\Function_;
|
||||
use PhpParser\NodeTraverser;
|
||||
use PHPStan\Type\MixedType;
|
||||
use PHPStan\Type\Type;
|
||||
|
@ -6,6 +6,7 @@ namespace Rector\TypeDeclaration\TypeInferer;
|
||||
use PhpParser\Node\Expr\ArrowFunction;
|
||||
use PhpParser\Node\Expr\Closure;
|
||||
use PhpParser\Node\Expr\Yield_;
|
||||
use PhpParser\Node\FunctionLike;
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node\Stmt\ClassLike;
|
||||
use PhpParser\Node\Stmt\ClassMethod;
|
||||
@ -55,18 +56,15 @@ final class SilentVoidResolver
|
||||
}
|
||||
return \true;
|
||||
}
|
||||
/**
|
||||
* @param \PhpParser\Node\Expr\ArrowFunction|\PhpParser\Node\Expr\Closure|\PhpParser\Node\Stmt\ClassMethod|\PhpParser\Node\Stmt\Function_ $functionLike
|
||||
*/
|
||||
public function hasSilentVoid($functionLike) : bool
|
||||
public function hasSilentVoid(\PhpParser\Node\FunctionLike $functionLike) : bool
|
||||
{
|
||||
if ($functionLike instanceof \PhpParser\Node\Expr\ArrowFunction) {
|
||||
return \false;
|
||||
}
|
||||
if ($this->hasStmtsAlwaysReturn((array) $functionLike->stmts)) {
|
||||
if ($this->hasStmtsAlwaysReturn((array) $functionLike->getStmts())) {
|
||||
return \false;
|
||||
}
|
||||
foreach ((array) $functionLike->stmts as $stmt) {
|
||||
foreach ((array) $functionLike->getStmts() as $stmt) {
|
||||
// has switch with always return
|
||||
if ($stmt instanceof \PhpParser\Node\Stmt\Switch_ && $this->isSwitchWithAlwaysReturn($stmt)) {
|
||||
return \false;
|
||||
|
@ -85,11 +85,11 @@ CODE_SAMPLE
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param array<string, ChangeConstantVisibility[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$classConstantVisibilityChanges = $configuration[self::CLASS_CONSTANT_VISIBILITY_CHANGES] ?? ($configuration ?: []);
|
||||
$classConstantVisibilityChanges = $configuration[self::CLASS_CONSTANT_VISIBILITY_CHANGES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($classConstantVisibilityChanges);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($classConstantVisibilityChanges, \Rector\Visibility\ValueObject\ChangeConstantVisibility::class);
|
||||
$this->classConstantVisibilityChanges = $classConstantVisibilityChanges;
|
||||
|
@ -109,11 +109,12 @@ CODE_SAMPLE
|
||||
return $node;
|
||||
}
|
||||
/**
|
||||
* @param array<string, ChangeMethodVisibility[]> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$methodVisibilities = $configuration[self::METHOD_VISIBILITIES] ?? ($configuration ?: []);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($methodVisibilities);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allIsInstanceOf($methodVisibilities, \Rector\Visibility\ValueObject\ChangeMethodVisibility::class);
|
||||
$this->methodVisibilities = $methodVisibilities;
|
||||
}
|
||||
|
@ -16,11 +16,11 @@ final class VersionResolver
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '3f6f70602cc4e3bd65b34720c45caf1acaa2b3e6';
|
||||
public const PACKAGE_VERSION = 'f985e811be98213dc0f0f6422f1a6e63ccc90ee5';
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2021-11-28 16:52:57';
|
||||
public const RELEASE_DATE = '2021-11-28 17:26:14';
|
||||
public static function resolvePackageVersion() : string
|
||||
{
|
||||
$process = new \RectorPrefix20211128\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);
|
||||
|
@ -7,6 +7,9 @@ use PHPStan\Analyser\Scope;
|
||||
use PHPStan\Reflection\FunctionReflection;
|
||||
use PHPStan\Reflection\MethodReflection;
|
||||
use PHPStan\Type\Type;
|
||||
/**
|
||||
* @template TType as Type
|
||||
*/
|
||||
interface TypeToCallReflectionResolverInterface
|
||||
{
|
||||
/**
|
||||
@ -14,8 +17,8 @@ interface TypeToCallReflectionResolverInterface
|
||||
*/
|
||||
public function supports($type) : bool;
|
||||
/**
|
||||
* @return FunctionReflection|MethodReflection|null
|
||||
* @param \PHPStan\Type\Type $type
|
||||
* @return FunctionReflection|MethodReflection|null
|
||||
* @param \PHPStan\Analyser\Scope $scope
|
||||
*/
|
||||
public function resolve($type, $scope);
|
||||
|
@ -7,7 +7,7 @@ use Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface;
|
||||
interface ConfigurableRectorInterface extends \Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface
|
||||
{
|
||||
/**
|
||||
* @param array<string, mixed> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void;
|
||||
}
|
||||
|
@ -3,7 +3,6 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\Exclusion;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Const_;
|
||||
use PhpParser\Node\Stmt;
|
||||
@ -14,6 +13,7 @@ use Rector\BetterPhpDocParser\PhpDocInfo\PhpDocInfoFactory;
|
||||
use Rector\Core\Contract\Rector\PhpRectorInterface;
|
||||
use Rector\Core\Contract\Rector\RectorInterface;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
/**
|
||||
* @see \Rector\Core\Tests\Exclusion\ExclusionManagerTest
|
||||
@ -95,11 +95,11 @@ final class ExclusionManager
|
||||
private function matchesNoRectorComment(\PhpParser\Node $node, string $rectorClass) : bool
|
||||
{
|
||||
foreach ($node->getComments() as $comment) {
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($comment->getText(), self::NO_RECTOR_START_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($comment->getText(), self::NO_RECTOR_START_REGEX)) {
|
||||
return \true;
|
||||
}
|
||||
$noRectorWithRule = '#@noRector \\\\?' . \preg_quote($rectorClass, '#') . '$#';
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($comment->getText(), $noRectorWithRule)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($comment->getText(), $noRectorWithRule)) {
|
||||
return \true;
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\FileSystem;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use Rector\Caching\UnchangedFilesFilter;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use RectorPrefix20211128\Symfony\Component\Finder\Finder;
|
||||
use RectorPrefix20211128\Symfony\Component\Finder\SplFileInfo;
|
||||
use RectorPrefix20211128\Symplify\Skipper\SkipCriteriaResolver\SkippedPathsResolver;
|
||||
@ -116,7 +116,7 @@ final class FilesFinder
|
||||
foreach ($excludePaths as $excludePath) {
|
||||
// make the path work accross different OSes
|
||||
$excludePath = \str_replace('\\', '/', $excludePath);
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($realPath, '#' . \preg_quote($excludePath, '#') . '#')) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($realPath, '#' . \preg_quote($excludePath, '#') . '#')) {
|
||||
return \false;
|
||||
}
|
||||
$excludePath = $this->normalizeForFnmatch($excludePath);
|
||||
@ -134,11 +134,11 @@ final class FilesFinder
|
||||
private function normalizeForFnmatch(string $path) : string
|
||||
{
|
||||
// ends with *
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($path, self::ENDS_WITH_ASTERISK_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($path, self::ENDS_WITH_ASTERISK_REGEX)) {
|
||||
return '*' . $path;
|
||||
}
|
||||
// starts with *
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($path, self::STARTS_WITH_ASTERISK_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($path, self::STARTS_WITH_ASTERISK_REGEX)) {
|
||||
return $path . '*';
|
||||
}
|
||||
return $path;
|
||||
|
@ -3,10 +3,10 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\NodeAnalyzer;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Expr\New_;
|
||||
use PhpParser\Node\Stmt\Class_;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeNameResolver\NodeNameResolver;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
final class ClassAnalyzer
|
||||
@ -41,6 +41,6 @@ final class ClassAnalyzer
|
||||
return \true;
|
||||
}
|
||||
// match PHPStan pattern for anonymous classes
|
||||
return (bool) \RectorPrefix20211128\Nette\Utils\Strings::match($className, self::ANONYMOUS_CLASS_REGEX);
|
||||
return \Rector\Core\Util\StringUtils::isMatch($className, self::ANONYMOUS_CLASS_REGEX);
|
||||
}
|
||||
}
|
||||
|
@ -125,11 +125,7 @@ final class ClassMethodManipulator
|
||||
if (!$this->nodeTypeResolver->isObjectType($paramNode, $objectType)) {
|
||||
continue;
|
||||
}
|
||||
$paramName = $this->nodeNameResolver->getName($paramNode);
|
||||
if (!\is_string($paramName)) {
|
||||
throw new \Rector\Core\Exception\ShouldNotHappenException();
|
||||
}
|
||||
return $paramName;
|
||||
return $this->nodeNameResolver->getName($paramNode);
|
||||
}
|
||||
$paramName = $this->resolveName($classMethod, $possibleNames);
|
||||
$classMethod->params[] = new \PhpParser\Node\Param(new \PhpParser\Node\Expr\Variable($paramName), null, new \PhpParser\Node\Name\FullyQualified($objectType->getClassName()));
|
||||
|
@ -39,7 +39,7 @@ final class PropertyFetchAssignManipulator
|
||||
}
|
||||
/** @var Assign $node */
|
||||
$propertyName = $this->nodeNameResolver->getName($node->expr);
|
||||
if ($propertyName) {
|
||||
if (\is_string($propertyName)) {
|
||||
$propertyNames[] = $propertyName;
|
||||
}
|
||||
return null;
|
||||
|
@ -11,6 +11,7 @@ use Rector\PostRector\Contract\Rector\ComplementaryRectorInterface;
|
||||
use Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface;
|
||||
use Symplify\RuleDocGenerator\ValueObject\CodeSample\ConfiguredCodeSample;
|
||||
use Symplify\RuleDocGenerator\ValueObject\RuleDefinition;
|
||||
use RectorPrefix20211128\Webmozart\Assert\Assert;
|
||||
final class RenameClassNonPhpRector implements \Rector\Core\Contract\Rector\NonPhpRectorInterface, \Symplify\RuleDocGenerator\Contract\ConfigurableRuleInterface, \Rector\Core\Contract\Rector\ConfigurableRectorInterface, \Rector\PostRector\Contract\Rector\ComplementaryRectorInterface
|
||||
{
|
||||
/**
|
||||
@ -59,11 +60,15 @@ CODE_SAMPLE
|
||||
return $this->renameClasses($fileContent, $classRenames);
|
||||
}
|
||||
/**
|
||||
* @param array<string, array<string, string>> $configuration
|
||||
* @param mixed[] $configuration
|
||||
*/
|
||||
public function configure(array $configuration) : void
|
||||
{
|
||||
$this->renameClasses = $configuration[self::RENAME_CLASSES] ?? [];
|
||||
$renameClasses = $configuration[self::RENAME_CLASSES] ?? $configuration;
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::isArray($renameClasses);
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString(\array_keys($renameClasses));
|
||||
\RectorPrefix20211128\Webmozart\Assert\Assert::allString($renameClasses);
|
||||
$this->renameClasses = $renameClasses;
|
||||
}
|
||||
/**
|
||||
* @param array<string, string> $classRenames
|
||||
|
@ -9,6 +9,9 @@ use PHPStan\TrinaryLogic;
|
||||
use PHPStan\Type\ClosureType;
|
||||
use PHPStan\Type\Type;
|
||||
use Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverInterface;
|
||||
/**
|
||||
* @implements TypeToCallReflectionResolverInterface<ClosureType>
|
||||
*/
|
||||
final class ClosureTypeToCallReflectionResolver implements \Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverInterface
|
||||
{
|
||||
/**
|
||||
|
@ -16,6 +16,8 @@ use PHPStan\Type\Type;
|
||||
use Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverInterface;
|
||||
/**
|
||||
* @see https://github.com/phpstan/phpstan-src/blob/b1fd47bda2a7a7d25091197b125c0adf82af6757/src/Type/Constant/ConstantArrayType.php#L188
|
||||
*
|
||||
* @implements TypeToCallReflectionResolverInterface<ConstantArrayType>
|
||||
*/
|
||||
final class ConstantArrayTypeToCallReflectionResolver implements \Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverInterface
|
||||
{
|
||||
|
@ -14,6 +14,8 @@ use PHPStan\Type\Type;
|
||||
use Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverInterface;
|
||||
/**
|
||||
* @see https://github.com/phpstan/phpstan-src/blob/b1fd47bda2a7a7d25091197b125c0adf82af6757/src/Type/Constant/ConstantStringType.php#L147
|
||||
*
|
||||
* @implements TypeToCallReflectionResolverInterface<ConstantStringType>
|
||||
*/
|
||||
final class ConstantStringTypeToCallReflectionResolver implements \Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverInterface
|
||||
{
|
||||
|
@ -12,6 +12,8 @@ use Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToC
|
||||
use Rector\Core\ValueObject\MethodName;
|
||||
/**
|
||||
* @see https://github.com/phpstan/phpstan-src/blob/b1fd47bda2a7a7d25091197b125c0adf82af6757/src/Type/ObjectType.php#L705
|
||||
*
|
||||
* @implements TypeToCallReflectionResolverInterface<ObjectType>
|
||||
*/
|
||||
final class ObjectTypeToCallReflectionResolver implements \Rector\Core\Contract\PHPStan\Reflection\TypeToCallReflectionResolver\TypeToCallReflectionResolverInterface
|
||||
{
|
||||
|
@ -3,10 +3,10 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\Php;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use Rector\Core\Configuration\Option;
|
||||
use Rector\Core\Exception\Configuration\InvalidConfigurationException;
|
||||
use Rector\Core\Php\PhpVersionResolver\ProjectComposerJsonPhpVersionResolver;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Core\ValueObject\PhpVersion;
|
||||
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
|
||||
use RectorPrefix20211128\Symplify\PackageBuilder\Parameter\ParameterProvider;
|
||||
@ -72,7 +72,7 @@ final class PhpVersionProvider
|
||||
if (!\is_int($phpVersionFeatures)) {
|
||||
$this->throwInvalidTypeException($phpVersionFeatures);
|
||||
}
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match((string) $phpVersionFeatures, self::VALID_PHP_VERSION_REGEX) && $phpVersionFeatures >= \Rector\Core\ValueObject\PhpVersion::PHP_53 - 1) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch((string) $phpVersionFeatures, self::VALID_PHP_VERSION_REGEX) && $phpVersionFeatures >= \Rector\Core\ValueObject\PhpVersion::PHP_53 - 1) {
|
||||
return;
|
||||
}
|
||||
$this->throwInvalidTypeException($phpVersionFeatures);
|
||||
|
@ -11,11 +11,6 @@ final class TypeAnalyzer
|
||||
* @var string[]
|
||||
*/
|
||||
private const EXTRA_TYPES = ['object'];
|
||||
/**
|
||||
* @var string
|
||||
* @see https://regex101.com/r/fKFtfL/1
|
||||
*/
|
||||
private const ARRAY_TYPE_REGEX = '#array<(.*?)>#';
|
||||
/**
|
||||
* @var string
|
||||
* @see https://regex101.com/r/57HGpC/1
|
||||
@ -45,24 +40,4 @@ final class TypeAnalyzer
|
||||
}
|
||||
return \false;
|
||||
}
|
||||
public function normalizeType(string $type) : string
|
||||
{
|
||||
$loweredType = \strtolower($type);
|
||||
if ($loweredType === 'boolean') {
|
||||
return 'bool';
|
||||
}
|
||||
if (\in_array($loweredType, ['double', 'real'], \true)) {
|
||||
return 'float';
|
||||
}
|
||||
if ($loweredType === 'integer') {
|
||||
return 'int';
|
||||
}
|
||||
if ($loweredType === 'callback') {
|
||||
return 'callable';
|
||||
}
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($loweredType, self::ARRAY_TYPE_REGEX)) {
|
||||
return 'array';
|
||||
}
|
||||
return $type;
|
||||
}
|
||||
}
|
||||
|
@ -130,12 +130,6 @@ final class AstResolver
|
||||
if ($fileName === null) {
|
||||
return null;
|
||||
}
|
||||
$fileContent = $this->smartFileSystem->readFile($fileName);
|
||||
if (!\is_string($fileContent)) {
|
||||
// avoids parsing again falsy file
|
||||
$this->classMethodsByClassAndMethod[$classReflection->getName()][$methodReflection->getName()] = null;
|
||||
return null;
|
||||
}
|
||||
$nodes = $this->parseFileNameToDecoratedNodes($fileName);
|
||||
if ($nodes === null) {
|
||||
return null;
|
||||
@ -171,11 +165,6 @@ final class AstResolver
|
||||
return null;
|
||||
}
|
||||
$fileContent = $this->smartFileSystem->readFile($fileName);
|
||||
if (!\is_string($fileContent)) {
|
||||
// to avoid parsing missing function again
|
||||
$this->functionsByName[$functionReflection->getName()] = null;
|
||||
return null;
|
||||
}
|
||||
$nodes = $this->parseFileNameToDecoratedNodes($fileName);
|
||||
if ($nodes === null) {
|
||||
return null;
|
||||
@ -244,11 +233,12 @@ final class AstResolver
|
||||
*/
|
||||
public function parseClassReflectionTraits(\PHPStan\Reflection\ClassReflection $classReflection) : array
|
||||
{
|
||||
/** @var ClassReflection[] $classLikes */
|
||||
$classLikes = $classReflection->getTraits(\true);
|
||||
$traits = [];
|
||||
foreach ($classLikes as $classLike) {
|
||||
$fileName = $classLike->getFileName();
|
||||
if (!$fileName) {
|
||||
if ($fileName === null) {
|
||||
continue;
|
||||
}
|
||||
$nodes = $this->parseFileNameToDecoratedNodes($fileName);
|
||||
|
@ -3,7 +3,6 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\PhpParser;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
use PhpParser\BuilderHelpers;
|
||||
use PhpParser\Node\Arg;
|
||||
use PhpParser\Node\Expr;
|
||||
@ -15,6 +14,7 @@ use PhpParser\Node\Expr\Yield_;
|
||||
use PhpParser\Node\Scalar\String_;
|
||||
use PhpParser\Node\Stmt\Expression;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\Core\ValueObject\SprintfStringAndArgs;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
final class NodeTransformer
|
||||
@ -42,7 +42,7 @@ final class NodeTransformer
|
||||
$messageParts = $this->splitBySpace($stringValue);
|
||||
$arrayMessageParts = [];
|
||||
foreach ($messageParts as $messagePart) {
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::match($messagePart, self::PERCENT_TEXT_REGEX)) {
|
||||
if (\Rector\Core\Util\StringUtils::isMatch($messagePart, self::PERCENT_TEXT_REGEX)) {
|
||||
/** @var Expr $messagePartNode */
|
||||
$messagePartNode = \array_shift($arrayItems);
|
||||
} else {
|
||||
|
@ -3,7 +3,7 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\PhpParser\NodeTraverser;
|
||||
|
||||
use PhpParser\Node\Stmt;
|
||||
use PhpParser\Node;
|
||||
use PhpParser\Node\Stmt\Namespace_;
|
||||
use PhpParser\NodeFinder;
|
||||
use PhpParser\NodeTraverser;
|
||||
@ -38,8 +38,9 @@ final class RectorNodeTraverser extends \PhpParser\NodeTraverser
|
||||
$this->phpVersionedFilter = $phpVersionedFilter;
|
||||
}
|
||||
/**
|
||||
* @param Stmt[] $nodes
|
||||
* @return Stmt[]
|
||||
* @template TNode as Node
|
||||
* @param TNode[] $nodes
|
||||
* @return TNode[]
|
||||
*/
|
||||
public function traverse($nodes) : array
|
||||
{
|
||||
|
@ -15,6 +15,7 @@ use PhpParser\Node\Stmt;
|
||||
use PhpParser\Parser;
|
||||
use Rector\Core\Exception\ShouldNotHappenException;
|
||||
use Rector\Core\PhpParser\Printer\BetterStandardPrinter;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeTypeResolver\NodeScopeAndMetadataDecorator;
|
||||
use RectorPrefix20211128\Symplify\SmartFileSystem\SmartFileSystem;
|
||||
final class InlineCodeParser
|
||||
@ -72,8 +73,8 @@ final class InlineCodeParser
|
||||
$content = $this->smartFileSystem->readFile($content);
|
||||
}
|
||||
// wrap code so php-parser can interpret it
|
||||
$content = \RectorPrefix20211128\Nette\Utils\Strings::match($content, self::OPEN_PHP_TAG_REGEX) ? $content : '<?php ' . $content;
|
||||
$content = \RectorPrefix20211128\Nette\Utils\Strings::match($content, self::ENDING_SEMI_COLON_REGEX) ? $content : $content . ';';
|
||||
$content = \Rector\Core\Util\StringUtils::isMatch($content, self::OPEN_PHP_TAG_REGEX) ? $content : '<?php ' . $content;
|
||||
$content = \Rector\Core\Util\StringUtils::isMatch($content, self::ENDING_SEMI_COLON_REGEX) ? $content : $content . ';';
|
||||
$stmts = $this->simplePhpParser->parseString($content);
|
||||
return $this->nodeScopeAndMetadataDecorator->decorateStmtsFromString($stmts);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ use PhpParser\PrettyPrinter\Standard;
|
||||
use Rector\Comments\NodeDocBlock\DocBlockUpdater;
|
||||
use Rector\Core\PhpParser\Node\CustomNode\FileWithoutNamespace;
|
||||
use Rector\Core\PhpParser\Printer\Whitespace\IndentCharacterDetector;
|
||||
use Rector\Core\Util\StringUtils;
|
||||
use Rector\NodeTypeResolver\Node\AttributeKey;
|
||||
/**
|
||||
* @see \Rector\Core\Tests\PhpParser\Printer\BetterStandardPrinterTest
|
||||
@ -97,7 +98,7 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard
|
||||
$this->tabOrSpaceIndentCharacter = $this->indentCharacterDetector->detect($origTokens);
|
||||
$content = parent::printFormatPreserving($newStmts, $origStmts, $origTokens);
|
||||
// add new line in case of added stmts
|
||||
if (\count($stmts) !== \count($origStmts) && !(bool) \RectorPrefix20211128\Nette\Utils\Strings::match($content, self::NEWLINE_END_REGEX)) {
|
||||
if (\count($stmts) !== \count($origStmts) && !\Rector\Core\Util\StringUtils::isMatch($content, self::NEWLINE_END_REGEX)) {
|
||||
$content .= $this->nl;
|
||||
}
|
||||
return $content;
|
||||
@ -246,7 +247,7 @@ final class BetterStandardPrinter extends \PhpParser\PrettyPrinter\Standard
|
||||
*/
|
||||
protected function pScalar_String(\PhpParser\Node\Scalar\String_ $string) : string
|
||||
{
|
||||
$isRegularPattern = $string->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN);
|
||||
$isRegularPattern = (bool) $string->getAttribute(\Rector\NodeTypeResolver\Node\AttributeKey::IS_REGULAR_PATTERN, \false);
|
||||
if (!$isRegularPattern) {
|
||||
return parent::pScalar_String($string);
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ final class IndentCharacterDetector
|
||||
foreach ($tokens as $token) {
|
||||
if ($token[0] === \T_WHITESPACE) {
|
||||
$tokenContent = $token[1];
|
||||
if (\RectorPrefix20211128\Nette\Utils\Strings::matchAll($tokenContent, '#^\\t#m')) {
|
||||
$tabMatches = \RectorPrefix20211128\Nette\Utils\Strings::matchAll($tokenContent, '#^\\t#m');
|
||||
if ($tabMatches !== []) {
|
||||
return "\t";
|
||||
}
|
||||
}
|
||||
|
@ -222,7 +222,7 @@ abstract class AbstractRector extends \PhpParser\NodeVisitorAbstract implements
|
||||
return parent::beforeTraverse($nodes);
|
||||
}
|
||||
/**
|
||||
* @return Expression|Node|Node[]|int|null
|
||||
* @return Node|int|null
|
||||
*/
|
||||
public final function enterNode(\PhpParser\Node $node)
|
||||
{
|
||||
|
@ -37,7 +37,10 @@ final class PHPStanStubLoader
|
||||
}
|
||||
foreach (self::VENDOR_PATHS as $vendorPath) {
|
||||
$vendorPath = \realpath($vendorPath);
|
||||
if (!$vendorPath) {
|
||||
if ($vendorPath === \false) {
|
||||
continue;
|
||||
}
|
||||
if ($vendorPath === '') {
|
||||
continue;
|
||||
}
|
||||
foreach (self::STUBS as $stub) {
|
||||
|
14
src/Util/StringUtils.php
Normal file
14
src/Util/StringUtils.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Core\Util;
|
||||
|
||||
use RectorPrefix20211128\Nette\Utils\Strings;
|
||||
final class StringUtils
|
||||
{
|
||||
public static function isMatch(string $value, string $regex) : bool
|
||||
{
|
||||
$match = \RectorPrefix20211128\Nette\Utils\Strings::match($value, $regex);
|
||||
return $match !== null;
|
||||
}
|
||||
}
|
@ -50,9 +50,6 @@ final class EmptyConfigurableRectorCollector
|
||||
$codeSamples = $ruleDefinition->getCodeSamples();
|
||||
foreach ($codeSamples as $codeSample) {
|
||||
$configuration = $codeSample->getConfiguration();
|
||||
if (!\is_array($configuration)) {
|
||||
continue;
|
||||
}
|
||||
foreach (\array_keys($configuration) as $key) {
|
||||
$key = $this->propertyNaming->underscoreToName($key);
|
||||
if (!\property_exists($rector, $key)) {
|
||||
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
@ -4,4 +4,4 @@
|
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit1ce97d352017e6e73b3a56c72f10da86::getLoader();
|
||||
return ComposerAutoloaderInit476c42b1d042076509785e15f689eb32::getLoader();
|
||||
|
1
vendor/composer/autoload_classmap.php
vendored
1
vendor/composer/autoload_classmap.php
vendored
@ -1753,6 +1753,7 @@ return array(
|
||||
'Rector\\Core\\Template\\DefaultResolver' => $baseDir . '/src/Template/DefaultResolver.php',
|
||||
'Rector\\Core\\Util\\PhpVersionFactory' => $baseDir . '/src/Util/PhpVersionFactory.php',
|
||||
'Rector\\Core\\Util\\StaticRectorStrings' => $baseDir . '/src/Util/StaticRectorStrings.php',
|
||||
'Rector\\Core\\Util\\StringUtils' => $baseDir . '/src/Util/StringUtils.php',
|
||||
'Rector\\Core\\Validation\\Collector\\EmptyConfigurableRectorCollector' => $baseDir . '/src/Validation/Collector/EmptyConfigurableRectorCollector.php',
|
||||
'Rector\\Core\\Validation\\EmptyConfigurableRectorChecker' => $baseDir . '/src/Validation/EmptyConfigurableRectorChecker.php',
|
||||
'Rector\\Core\\Validation\\InfiniteLoopValidator' => $baseDir . '/src/Validation/InfiniteLoopValidator.php',
|
||||
|
14
vendor/composer/autoload_real.php
vendored
14
vendor/composer/autoload_real.php
vendored
@ -2,7 +2,7 @@
|
||||
|
||||
// autoload_real.php @generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit1ce97d352017e6e73b3a56c72f10da86
|
||||
class ComposerAutoloaderInit476c42b1d042076509785e15f689eb32
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
@ -22,15 +22,15 @@ class ComposerAutoloaderInit1ce97d352017e6e73b3a56c72f10da86
|
||||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit1ce97d352017e6e73b3a56c72f10da86', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInit476c42b1d042076509785e15f689eb32', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit1ce97d352017e6e73b3a56c72f10da86', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit476c42b1d042076509785e15f689eb32', 'loadClassLoader'));
|
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
||||
if ($useStaticLoader) {
|
||||
require __DIR__ . '/autoload_static.php';
|
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit1ce97d352017e6e73b3a56c72f10da86::getInitializer($loader));
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit476c42b1d042076509785e15f689eb32::getInitializer($loader));
|
||||
} else {
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php';
|
||||
if ($classMap) {
|
||||
@ -42,19 +42,19 @@ class ComposerAutoloaderInit1ce97d352017e6e73b3a56c72f10da86
|
||||
$loader->register(true);
|
||||
|
||||
if ($useStaticLoader) {
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit1ce97d352017e6e73b3a56c72f10da86::$files;
|
||||
$includeFiles = Composer\Autoload\ComposerStaticInit476c42b1d042076509785e15f689eb32::$files;
|
||||
} else {
|
||||
$includeFiles = require __DIR__ . '/autoload_files.php';
|
||||
}
|
||||
foreach ($includeFiles as $fileIdentifier => $file) {
|
||||
composerRequire1ce97d352017e6e73b3a56c72f10da86($fileIdentifier, $file);
|
||||
composerRequire476c42b1d042076509785e15f689eb32($fileIdentifier, $file);
|
||||
}
|
||||
|
||||
return $loader;
|
||||
}
|
||||
}
|
||||
|
||||
function composerRequire1ce97d352017e6e73b3a56c72f10da86($fileIdentifier, $file)
|
||||
function composerRequire476c42b1d042076509785e15f689eb32($fileIdentifier, $file)
|
||||
{
|
||||
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
||||
require $file;
|
||||
|
9
vendor/composer/autoload_static.php
vendored
9
vendor/composer/autoload_static.php
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
namespace Composer\Autoload;
|
||||
|
||||
class ComposerStaticInit1ce97d352017e6e73b3a56c72f10da86
|
||||
class ComposerStaticInit476c42b1d042076509785e15f689eb32
|
||||
{
|
||||
public static $files = array (
|
||||
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
|
||||
@ -2150,6 +2150,7 @@ class ComposerStaticInit1ce97d352017e6e73b3a56c72f10da86
|
||||
'Rector\\Core\\Template\\DefaultResolver' => __DIR__ . '/../..' . '/src/Template/DefaultResolver.php',
|
||||
'Rector\\Core\\Util\\PhpVersionFactory' => __DIR__ . '/../..' . '/src/Util/PhpVersionFactory.php',
|
||||
'Rector\\Core\\Util\\StaticRectorStrings' => __DIR__ . '/../..' . '/src/Util/StaticRectorStrings.php',
|
||||
'Rector\\Core\\Util\\StringUtils' => __DIR__ . '/../..' . '/src/Util/StringUtils.php',
|
||||
'Rector\\Core\\Validation\\Collector\\EmptyConfigurableRectorCollector' => __DIR__ . '/../..' . '/src/Validation/Collector/EmptyConfigurableRectorCollector.php',
|
||||
'Rector\\Core\\Validation\\EmptyConfigurableRectorChecker' => __DIR__ . '/../..' . '/src/Validation/EmptyConfigurableRectorChecker.php',
|
||||
'Rector\\Core\\Validation\\InfiniteLoopValidator' => __DIR__ . '/../..' . '/src/Validation/InfiniteLoopValidator.php',
|
||||
@ -3770,9 +3771,9 @@ class ComposerStaticInit1ce97d352017e6e73b3a56c72f10da86
|
||||
public static function getInitializer(ClassLoader $loader)
|
||||
{
|
||||
return \Closure::bind(function () use ($loader) {
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit1ce97d352017e6e73b3a56c72f10da86::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit1ce97d352017e6e73b3a56c72f10da86::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit1ce97d352017e6e73b3a56c72f10da86::$classMap;
|
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit476c42b1d042076509785e15f689eb32::$prefixLengthsPsr4;
|
||||
$loader->prefixDirsPsr4 = ComposerStaticInit476c42b1d042076509785e15f689eb32::$prefixDirsPsr4;
|
||||
$loader->classMap = ComposerStaticInit476c42b1d042076509785e15f689eb32::$classMap;
|
||||
|
||||
}, null, ClassLoader::class);
|
||||
}
|
||||
|
10
vendor/scoper-autoload.php
vendored
10
vendor/scoper-autoload.php
vendored
@ -12,8 +12,8 @@ if (!class_exists('GenerateChangelogCommand', false) && !interface_exists('Gener
|
||||
if (!class_exists('AutoloadIncluder', false) && !interface_exists('AutoloadIncluder', false) && !trait_exists('AutoloadIncluder', false)) {
|
||||
spl_autoload_call('RectorPrefix20211128\AutoloadIncluder');
|
||||
}
|
||||
if (!class_exists('ComposerAutoloaderInit1ce97d352017e6e73b3a56c72f10da86', false) && !interface_exists('ComposerAutoloaderInit1ce97d352017e6e73b3a56c72f10da86', false) && !trait_exists('ComposerAutoloaderInit1ce97d352017e6e73b3a56c72f10da86', false)) {
|
||||
spl_autoload_call('RectorPrefix20211128\ComposerAutoloaderInit1ce97d352017e6e73b3a56c72f10da86');
|
||||
if (!class_exists('ComposerAutoloaderInit476c42b1d042076509785e15f689eb32', false) && !interface_exists('ComposerAutoloaderInit476c42b1d042076509785e15f689eb32', false) && !trait_exists('ComposerAutoloaderInit476c42b1d042076509785e15f689eb32', false)) {
|
||||
spl_autoload_call('RectorPrefix20211128\ComposerAutoloaderInit476c42b1d042076509785e15f689eb32');
|
||||
}
|
||||
if (!class_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !interface_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false) && !trait_exists('Helmich\TypoScriptParser\Parser\AST\Statement', false)) {
|
||||
spl_autoload_call('RectorPrefix20211128\Helmich\TypoScriptParser\Parser\AST\Statement');
|
||||
@ -81,9 +81,9 @@ if (!function_exists('print_node')) {
|
||||
return \RectorPrefix20211128\print_node(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('composerRequire1ce97d352017e6e73b3a56c72f10da86')) {
|
||||
function composerRequire1ce97d352017e6e73b3a56c72f10da86() {
|
||||
return \RectorPrefix20211128\composerRequire1ce97d352017e6e73b3a56c72f10da86(...func_get_args());
|
||||
if (!function_exists('composerRequire476c42b1d042076509785e15f689eb32')) {
|
||||
function composerRequire476c42b1d042076509785e15f689eb32() {
|
||||
return \RectorPrefix20211128\composerRequire476c42b1d042076509785e15f689eb32(...func_get_args());
|
||||
}
|
||||
}
|
||||
if (!function_exists('scanPath')) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user