Updated Rector to commit c19a849702

c19a849702 add few more checks for class name
This commit is contained in:
Tomas Votruba 2021-11-29 09:58:41 +00:00
parent 34b0b39e5f
commit 00448d7b2b
20 changed files with 80 additions and 19 deletions

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\CodingStyle\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class ReturnArrayClassMethodToYield
{
/**
@ -18,6 +19,7 @@ final class ReturnArrayClassMethodToYield
{
$this->type = $type;
$this->method = $method;
\Rector\Core\Validation\RectorAssert::className($type);
}
public function getObjectType() : \PHPStan\Type\ObjectType
{

View File

@ -6,6 +6,7 @@ namespace Rector\DeadCode\ValueObject;
use PhpParser\Node;
use PhpParser\Node\Expr\Variable;
use Rector\Core\Exception\ShouldNotHappenException;
use Rector\Core\Validation\RectorAssert;
use Rector\NodeTypeResolver\Node\AttributeKey;
final class VariableNodeUse
{
@ -44,6 +45,7 @@ final class VariableNodeUse
$this->type = $type;
$this->variable = $variable;
$this->nestingHash = $nestingHash;
\Rector\Core\Validation\RectorAssert::className($type);
}
public function isName(string $name) : bool
{

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\Renaming\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class RenameAnnotation
{
/**
@ -23,6 +24,7 @@ final class RenameAnnotation
$this->type = $type;
$this->oldAnnotation = $oldAnnotation;
$this->newAnnotation = $newAnnotation;
\Rector\Core\Validation\RectorAssert::className($type);
}
public function getObjectType() : \PHPStan\Type\ObjectType
{

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\Renaming\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class RenameProperty
{
/**
@ -23,6 +24,7 @@ final class RenameProperty
$this->type = $type;
$this->oldProperty = $oldProperty;
$this->newProperty = $newProperty;
\Rector\Core\Validation\RectorAssert::className($type);
}
public function getObjectType() : \PHPStan\Type\ObjectType
{

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\Transform\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class MethodCallToAnotherMethodCallWithArguments
{
/**
@ -31,6 +32,7 @@ final class MethodCallToAnotherMethodCallWithArguments
$this->oldMethod = $oldMethod;
$this->newMethod = $newMethod;
$this->newArguments = $newArguments;
\Rector\Core\Validation\RectorAssert::className($type);
}
public function getObjectType() : \PHPStan\Type\ObjectType
{

View File

@ -3,6 +3,7 @@
declare (strict_types=1);
namespace Rector\Transform\ValueObject;
use Rector\Core\Validation\RectorAssert;
final class MethodCallToMethodCall
{
/**
@ -31,6 +32,8 @@ final class MethodCallToMethodCall
$this->oldMethod = $oldMethod;
$this->newType = $newType;
$this->newMethod = $newMethod;
\Rector\Core\Validation\RectorAssert::className($oldType);
\Rector\Core\Validation\RectorAssert::className($newType);
}
public function getOldType() : string
{

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\Transform\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class NewArgToMethodCall
{
/**
@ -23,6 +24,7 @@ final class NewArgToMethodCall
$this->type = $type;
$this->value = $value;
$this->methodCall = $methodCall;
\Rector\Core\Validation\RectorAssert::className($type);
}
public function getObjectType() : \PHPStan\Type\ObjectType
{

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\Transform\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class NewToStaticCall
{
/**
@ -23,6 +24,8 @@ final class NewToStaticCall
$this->type = $type;
$this->staticCallClass = $staticCallClass;
$this->staticCallMethod = $staticCallMethod;
\Rector\Core\Validation\RectorAssert::className($type);
\Rector\Core\Validation\RectorAssert::className($staticCallClass);
}
public function getObjectType() : \PHPStan\Type\ObjectType
{

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\Transform\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class PropertyFetchToMethodCall
{
/**
@ -36,6 +37,7 @@ final class PropertyFetchToMethodCall
$this->newGetMethod = $newGetMethod;
$this->newSetMethod = $newSetMethod;
$this->newGetArguments = $newGetArguments;
\Rector\Core\Validation\RectorAssert::className($oldType);
}
public function getOldObjectType() : \PHPStan\Type\ObjectType
{

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\Transform\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class ServiceGetterToConstructorInjection
{
/**
@ -23,6 +24,8 @@ final class ServiceGetterToConstructorInjection
$this->oldType = $oldType;
$this->oldMethod = $oldMethod;
$this->serviceType = $serviceType;
\Rector\Core\Validation\RectorAssert::className($oldType);
\Rector\Core\Validation\RectorAssert::className($serviceType);
}
public function getOldObjectType() : \PHPStan\Type\ObjectType
{

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\Transform\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class UnsetAndIssetToMethodCall
{
/**
@ -23,6 +24,7 @@ final class UnsetAndIssetToMethodCall
$this->type = $type;
$this->issetMethodCall = $issetMethodCall;
$this->unsedMethodCall = $unsedMethodCall;
\Rector\Core\Validation\RectorAssert::className($type);
}
public function getObjectType() : \PHPStan\Type\ObjectType
{

View File

@ -4,6 +4,7 @@ declare (strict_types=1);
namespace Rector\Transform\ValueObject;
use PHPStan\Type\ObjectType;
use Rector\Core\Validation\RectorAssert;
final class WrapReturn
{
/**
@ -23,6 +24,7 @@ final class WrapReturn
$this->type = $type;
$this->method = $method;
$this->isArrayWrap = $isArrayWrap;
\Rector\Core\Validation\RectorAssert::className($type);
}
public function getObjectType() : \PHPStan\Type\ObjectType
{

View File

@ -5,6 +5,7 @@ namespace Rector\TypeDeclaration\ValueObject;
use PHPStan\Type\ObjectType;
use PHPStan\Type\Type;
use Rector\Core\Validation\RectorAssert;
final class AddParamTypeDeclaration
{
/**
@ -29,6 +30,7 @@ final class AddParamTypeDeclaration
$this->methodName = $methodName;
$this->position = $position;
$this->paramType = $paramType;
\Rector\Core\Validation\RectorAssert::className($className);
}
public function getObjectType() : \PHPStan\Type\ObjectType
{

View File

@ -16,11 +16,11 @@ final class VersionResolver
/**
* @var string
*/
public const PACKAGE_VERSION = '50bbdd1e934f3ae6cc808debf5059bf48bd8d3e2';
public const PACKAGE_VERSION = 'c19a849702aca3f00b5908703b635baaeef93476';
/**
* @var string
*/
public const RELEASE_DATE = '2021-11-29 09:30:00';
public const RELEASE_DATE = '2021-11-29 12:46:02';
public static function resolvePackageVersion() : string
{
$process = new \RectorPrefix20211129\Symfony\Component\Process\Process(['git', 'log', '--pretty="%H"', '-n1', 'HEAD'], __DIR__);

View File

@ -0,0 +1,30 @@
<?php
declare (strict_types=1);
namespace Rector\Core\Validation;
use Rector\Core\Util\StringUtils;
use RectorPrefix20211129\Webmozart\Assert\InvalidArgumentException;
/**
* @see \Rector\Core\Tests\Validation\RectorAssertTest
*/
final class RectorAssert
{
/**
* @see https://stackoverflow.com/a/12011255/1348344
* @see https://regex101.com/r/PYQaPF/1
* @var string
*/
public const CLASS_NAME_REGEX = '#^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*(\\\\[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*)*$#';
/**
* Assert value is valid class name
*/
public static function className(string $className) : void
{
if (\Rector\Core\Util\StringUtils::isMatch($className, self::CLASS_NAME_REGEX)) {
return;
}
$errorMessage = $className . ' is not a valid class name';
throw new \RectorPrefix20211129\Webmozart\Assert\InvalidArgumentException($errorMessage);
}
}

2
vendor/autoload.php vendored
View File

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

View File

@ -1757,6 +1757,7 @@ return array(
'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',
'Rector\\Core\\Validation\\RectorAssert' => $baseDir . '/src/Validation/RectorAssert.php',
'Rector\\Core\\ValueObjectFactory\\Application\\FileFactory' => $baseDir . '/src/ValueObjectFactory/Application/FileFactory.php',
'Rector\\Core\\ValueObjectFactory\\ProcessResultFactory' => $baseDir . '/src/ValueObjectFactory/ProcessResultFactory.php',
'Rector\\Core\\ValueObject\\Application\\File' => $baseDir . '/src/ValueObject/Application/File.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit9a0804c2fa2b16f124e30b25ead868d5
class ComposerAutoloaderInit855958c43fb6380deae0dc1449c0f846
{
private static $loader;
@ -22,15 +22,15 @@ class ComposerAutoloaderInit9a0804c2fa2b16f124e30b25ead868d5
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit9a0804c2fa2b16f124e30b25ead868d5', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit855958c43fb6380deae0dc1449c0f846', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__)));
spl_autoload_unregister(array('ComposerAutoloaderInit9a0804c2fa2b16f124e30b25ead868d5', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit855958c43fb6380deae0dc1449c0f846', '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\ComposerStaticInit9a0804c2fa2b16f124e30b25ead868d5::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit855958c43fb6380deae0dc1449c0f846::getInitializer($loader));
} else {
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
@ -42,19 +42,19 @@ class ComposerAutoloaderInit9a0804c2fa2b16f124e30b25ead868d5
$loader->register(true);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit9a0804c2fa2b16f124e30b25ead868d5::$files;
$includeFiles = Composer\Autoload\ComposerStaticInit855958c43fb6380deae0dc1449c0f846::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire9a0804c2fa2b16f124e30b25ead868d5($fileIdentifier, $file);
composerRequire855958c43fb6380deae0dc1449c0f846($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire9a0804c2fa2b16f124e30b25ead868d5($fileIdentifier, $file)
function composerRequire855958c43fb6380deae0dc1449c0f846($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit9a0804c2fa2b16f124e30b25ead868d5
class ComposerStaticInit855958c43fb6380deae0dc1449c0f846
{
public static $files = array (
'a4a119a56e50fbb293281d9a48007e0e' => __DIR__ . '/..' . '/symfony/polyfill-php80/bootstrap.php',
@ -2154,6 +2154,7 @@ class ComposerStaticInit9a0804c2fa2b16f124e30b25ead868d5
'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',
'Rector\\Core\\Validation\\RectorAssert' => __DIR__ . '/../..' . '/src/Validation/RectorAssert.php',
'Rector\\Core\\ValueObjectFactory\\Application\\FileFactory' => __DIR__ . '/../..' . '/src/ValueObjectFactory/Application/FileFactory.php',
'Rector\\Core\\ValueObjectFactory\\ProcessResultFactory' => __DIR__ . '/../..' . '/src/ValueObjectFactory/ProcessResultFactory.php',
'Rector\\Core\\ValueObject\\Application\\File' => __DIR__ . '/../..' . '/src/ValueObject/Application/File.php',
@ -3771,9 +3772,9 @@ class ComposerStaticInit9a0804c2fa2b16f124e30b25ead868d5
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit9a0804c2fa2b16f124e30b25ead868d5::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit9a0804c2fa2b16f124e30b25ead868d5::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit9a0804c2fa2b16f124e30b25ead868d5::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit855958c43fb6380deae0dc1449c0f846::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit855958c43fb6380deae0dc1449c0f846::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit855958c43fb6380deae0dc1449c0f846::$classMap;
}, null, ClassLoader::class);
}

View File

@ -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('RectorPrefix20211129\AutoloadIncluder');
}
if (!class_exists('ComposerAutoloaderInit9a0804c2fa2b16f124e30b25ead868d5', false) && !interface_exists('ComposerAutoloaderInit9a0804c2fa2b16f124e30b25ead868d5', false) && !trait_exists('ComposerAutoloaderInit9a0804c2fa2b16f124e30b25ead868d5', false)) {
spl_autoload_call('RectorPrefix20211129\ComposerAutoloaderInit9a0804c2fa2b16f124e30b25ead868d5');
if (!class_exists('ComposerAutoloaderInit855958c43fb6380deae0dc1449c0f846', false) && !interface_exists('ComposerAutoloaderInit855958c43fb6380deae0dc1449c0f846', false) && !trait_exists('ComposerAutoloaderInit855958c43fb6380deae0dc1449c0f846', false)) {
spl_autoload_call('RectorPrefix20211129\ComposerAutoloaderInit855958c43fb6380deae0dc1449c0f846');
}
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('RectorPrefix20211129\Helmich\TypoScriptParser\Parser\AST\Statement');
@ -81,9 +81,9 @@ if (!function_exists('print_node')) {
return \RectorPrefix20211129\print_node(...func_get_args());
}
}
if (!function_exists('composerRequire9a0804c2fa2b16f124e30b25ead868d5')) {
function composerRequire9a0804c2fa2b16f124e30b25ead868d5() {
return \RectorPrefix20211129\composerRequire9a0804c2fa2b16f124e30b25ead868d5(...func_get_args());
if (!function_exists('composerRequire855958c43fb6380deae0dc1449c0f846')) {
function composerRequire855958c43fb6380deae0dc1449c0f846() {
return \RectorPrefix20211129\composerRequire855958c43fb6380deae0dc1449c0f846(...func_get_args());
}
}
if (!function_exists('scanPath')) {