Updated Rector to commit 4f70e80c2d5f1febd01de2e7fa4a057880909dcb

4f70e80c2d Bump phpstan to 1.11.11 and pcre to 3.3.0 (#6241)
This commit is contained in:
Tomas Votruba 2024-08-20 13:23:49 +00:00
parent 0d670df26a
commit e001fc4219
17 changed files with 112 additions and 44 deletions

View File

@ -8,7 +8,7 @@
],
"require": {
"php": "^7.2|^8.0",
"phpstan/phpstan": "^1.11.9"
"phpstan/phpstan": "^1.11.11"
},
"autoload": {
"files": [

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api
* @var string
*/
public const PACKAGE_VERSION = 'fc1e742fa4d9861ccdc5933f3b53613b8223438d';
public const PACKAGE_VERSION = '4f70e80c2d5f1febd01de2e7fa4a057880909dcb';
/**
* @api
* @var string
*/
public const RELEASE_DATE = '2024-08-17 01:15:07';
public const RELEASE_DATE = '2024-08-20 13:21:19';
/**
* @var int
*/

2
vendor/autoload.php vendored
View File

@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) {
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit969cf4fb8686733ba64d08544d342ca0::getLoader();
return ComposerAutoloaderInit900e9d3a850659d65b1997f7abdf1e41::getLoader();

View File

@ -355,6 +355,7 @@ return array(
'RectorPrefix202408\\Composer\\Pcre\\PHPStan\\PregMatchFlags' => $vendorDir . '/composer/pcre/src/PHPStan/PregMatchFlags.php',
'RectorPrefix202408\\Composer\\Pcre\\PHPStan\\PregMatchParameterOutTypeExtension' => $vendorDir . '/composer/pcre/src/PHPStan/PregMatchParameterOutTypeExtension.php',
'RectorPrefix202408\\Composer\\Pcre\\PHPStan\\PregMatchTypeSpecifyingExtension' => $vendorDir . '/composer/pcre/src/PHPStan/PregMatchTypeSpecifyingExtension.php',
'RectorPrefix202408\\Composer\\Pcre\\PHPStan\\PregReplaceCallbackClosureTypeExtension' => $vendorDir . '/composer/pcre/src/PHPStan/PregReplaceCallbackClosureTypeExtension.php',
'RectorPrefix202408\\Composer\\Pcre\\PHPStan\\UnsafeStrictGroupsCallRule' => $vendorDir . '/composer/pcre/src/PHPStan/UnsafeStrictGroupsCallRule.php',
'RectorPrefix202408\\Composer\\Pcre\\PcreException' => $vendorDir . '/composer/pcre/src/PcreException.php',
'RectorPrefix202408\\Composer\\Pcre\\Preg' => $vendorDir . '/composer/pcre/src/Preg.php',

View File

@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit969cf4fb8686733ba64d08544d342ca0
class ComposerAutoloaderInit900e9d3a850659d65b1997f7abdf1e41
{
private static $loader;
@ -22,17 +22,17 @@ class ComposerAutoloaderInit969cf4fb8686733ba64d08544d342ca0
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit969cf4fb8686733ba64d08544d342ca0', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit900e9d3a850659d65b1997f7abdf1e41', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__));
spl_autoload_unregister(array('ComposerAutoloaderInit969cf4fb8686733ba64d08544d342ca0', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit900e9d3a850659d65b1997f7abdf1e41', 'loadClassLoader'));
require __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit969cf4fb8686733ba64d08544d342ca0::getInitializer($loader));
call_user_func(\Composer\Autoload\ComposerStaticInit900e9d3a850659d65b1997f7abdf1e41::getInitializer($loader));
$loader->setClassMapAuthoritative(true);
$loader->register(true);
$filesToLoad = \Composer\Autoload\ComposerStaticInit969cf4fb8686733ba64d08544d342ca0::$files;
$filesToLoad = \Composer\Autoload\ComposerStaticInit900e9d3a850659d65b1997f7abdf1e41::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;

View File

@ -4,7 +4,7 @@
namespace Composer\Autoload;
class ComposerStaticInit969cf4fb8686733ba64d08544d342ca0
class ComposerStaticInit900e9d3a850659d65b1997f7abdf1e41
{
public static $files = array (
'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php',
@ -574,6 +574,7 @@ class ComposerStaticInit969cf4fb8686733ba64d08544d342ca0
'RectorPrefix202408\\Composer\\Pcre\\PHPStan\\PregMatchFlags' => __DIR__ . '/..' . '/composer/pcre/src/PHPStan/PregMatchFlags.php',
'RectorPrefix202408\\Composer\\Pcre\\PHPStan\\PregMatchParameterOutTypeExtension' => __DIR__ . '/..' . '/composer/pcre/src/PHPStan/PregMatchParameterOutTypeExtension.php',
'RectorPrefix202408\\Composer\\Pcre\\PHPStan\\PregMatchTypeSpecifyingExtension' => __DIR__ . '/..' . '/composer/pcre/src/PHPStan/PregMatchTypeSpecifyingExtension.php',
'RectorPrefix202408\\Composer\\Pcre\\PHPStan\\PregReplaceCallbackClosureTypeExtension' => __DIR__ . '/..' . '/composer/pcre/src/PHPStan/PregReplaceCallbackClosureTypeExtension.php',
'RectorPrefix202408\\Composer\\Pcre\\PHPStan\\UnsafeStrictGroupsCallRule' => __DIR__ . '/..' . '/composer/pcre/src/PHPStan/UnsafeStrictGroupsCallRule.php',
'RectorPrefix202408\\Composer\\Pcre\\PcreException' => __DIR__ . '/..' . '/composer/pcre/src/PcreException.php',
'RectorPrefix202408\\Composer\\Pcre\\Preg' => __DIR__ . '/..' . '/composer/pcre/src/Preg.php',
@ -2805,9 +2806,9 @@ class ComposerStaticInit969cf4fb8686733ba64d08544d342ca0
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit969cf4fb8686733ba64d08544d342ca0::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit969cf4fb8686733ba64d08544d342ca0::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit969cf4fb8686733ba64d08544d342ca0::$classMap;
$loader->prefixLengthsPsr4 = ComposerStaticInit900e9d3a850659d65b1997f7abdf1e41::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit900e9d3a850659d65b1997f7abdf1e41::$prefixDirsPsr4;
$loader->classMap = ComposerStaticInit900e9d3a850659d65b1997f7abdf1e41::$classMap;
}, null, ClassLoader::class);
}

View File

@ -69,31 +69,31 @@
},
{
"name": "composer\/pcre",
"version": "3.2.0",
"version_normalized": "3.2.0.0",
"version": "3.3.0",
"version_normalized": "3.3.0.0",
"source": {
"type": "git",
"url": "https:\/\/github.com\/composer\/pcre.git",
"reference": "ea4ab6f9580a4fd221e0418f2c357cdd39102a90"
"reference": "1637e067347a0c40bbb1e3cd786b20dcab556a81"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/composer\/pcre\/zipball\/ea4ab6f9580a4fd221e0418f2c357cdd39102a90",
"reference": "ea4ab6f9580a4fd221e0418f2c357cdd39102a90",
"url": "https:\/\/api.github.com\/repos\/composer\/pcre\/zipball\/1637e067347a0c40bbb1e3cd786b20dcab556a81",
"reference": "1637e067347a0c40bbb1e3cd786b20dcab556a81",
"shasum": ""
},
"require": {
"php": "^7.4 || ^8.0"
},
"conflict": {
"phpstan\/phpstan": "<1.11.8"
"phpstan\/phpstan": "<1.11.10"
},
"require-dev": {
"phpstan\/phpstan": "^1.11.8",
"phpstan\/phpstan": "^1.11.10",
"phpstan\/phpstan-strict-rules": "^1.1",
"phpunit\/phpunit": "^8 || ^9"
},
"time": "2024-07-25T09:36:02+00:00",
"time": "2024-08-19T19:43:53+00:00",
"type": "library",
"extra": {
"branch-alias": {
@ -131,7 +131,7 @@
],
"support": {
"issues": "https:\/\/github.com\/composer\/pcre\/issues",
"source": "https:\/\/github.com\/composer\/pcre\/tree\/3.2.0"
"source": "https:\/\/github.com\/composer\/pcre\/tree\/3.3.0"
},
"funding": [
{
@ -1875,12 +1875,12 @@
"source": {
"type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "0eca1e4ae7f7c799119363d469ca6ce477b1a919"
"reference": "d7cc42e17c272184d6dfcfa699e2f16285bb5392"
},
"dist": {
"type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/0eca1e4ae7f7c799119363d469ca6ce477b1a919",
"reference": "0eca1e4ae7f7c799119363d469ca6ce477b1a919",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/d7cc42e17c272184d6dfcfa699e2f16285bb5392",
"reference": "d7cc42e17c272184d6dfcfa699e2f16285bb5392",
"shasum": ""
},
"require": {
@ -1910,7 +1910,7 @@
"tomasvotruba\/unused-public": "^0.3.10",
"tracy\/tracy": "^2.10"
},
"time": "2024-08-18T07:44:05+00:00",
"time": "2024-08-20T12:50:29+00:00",
"default-branch": true,
"type": "rector-extension",
"extra": {

File diff suppressed because one or more lines are too long

View File

@ -21,11 +21,11 @@
},
"require-dev": {
"phpunit\/phpunit": "^8 || ^9",
"phpstan\/phpstan": "^1.11.8",
"phpstan\/phpstan": "^1.11.10",
"phpstan\/phpstan-strict-rules": "^1.1"
},
"conflict": {
"phpstan\/phpstan": "<1.11.8"
"phpstan\/phpstan": "<1.11.10"
},
"autoload": {
"psr-4": {

View File

@ -3,19 +3,19 @@
# These can be reused by third party packages by including 'vendor/composer/pcre/extension.neon'
# in your phpstan config
conditionalTags:
Composer\Pcre\PHPStan\PregMatchParameterOutTypeExtension:
phpstan.staticMethodParameterOutTypeExtension: %featureToggles.narrowPregMatches%
Composer\Pcre\PHPStan\PregMatchTypeSpecifyingExtension:
phpstan.typeSpecifier.staticMethodTypeSpecifyingExtension: %featureToggles.narrowPregMatches%
Composer\Pcre\PHPStan\UnsafeStrictGroupsCallRule:
phpstan.rules.rule: %featureToggles.narrowPregMatches%
services:
-
class: Composer\Pcre\PHPStan\PregMatchParameterOutTypeExtension
tags:
- phpstan.staticMethodParameterOutTypeExtension
-
class: Composer\Pcre\PHPStan\PregMatchTypeSpecifyingExtension
tags:
- phpstan.typeSpecifier.staticMethodTypeSpecifyingExtension
-
class: Composer\Pcre\PHPStan\PregReplaceCallbackClosureTypeExtension
tags:
- phpstan.staticMethodParameterClosureTypeExtension
rules:
- Composer\Pcre\PHPStan\UnsafeStrictGroupsCallRule

View File

@ -14,7 +14,7 @@ final class PregMatchFlags
public static function getType(?Arg $flagsArg, Scope $scope) : ?Type
{
if ($flagsArg === null) {
return new ConstantIntegerType(\PREG_UNMATCHED_AS_NULL | RegexArrayShapeMatcher::PREG_UNMATCHED_AS_NULL_ON_72_73);
return new ConstantIntegerType(\PREG_UNMATCHED_AS_NULL);
}
$flagsType = $scope->getType($flagsArg->value);
$constantScalars = $flagsType->getConstantScalarValues();
@ -26,7 +26,7 @@ final class PregMatchFlags
if (!\is_int($constantScalarValue)) {
return null;
}
$internalFlagsTypes[] = new ConstantIntegerType($constantScalarValue | \PREG_UNMATCHED_AS_NULL | RegexArrayShapeMatcher::PREG_UNMATCHED_AS_NULL_ON_72_73);
$internalFlagsTypes[] = new ConstantIntegerType($constantScalarValue | \PREG_UNMATCHED_AS_NULL);
}
return TypeCombinator::union(...$internalFlagsTypes);
}

View File

@ -24,7 +24,7 @@ final class PregMatchParameterOutTypeExtension implements StaticMethodParameterO
}
public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter) : bool
{
return $methodReflection->getDeclaringClass()->getName() === Preg::class && \in_array($methodReflection->getName(), ['match', 'isMatch', 'matchStrictGroups', 'isMatchStrictGroups'], \true) && $parameter->getName() === 'matches';
return $methodReflection->getDeclaringClass()->getName() === Preg::class && \in_array($methodReflection->getName(), ['match', 'isMatch', 'matchStrictGroups', 'isMatchStrictGroups', 'matchAll', 'isMatchAll', 'matchAllStrictGroups', 'isMatchAllStrictGroups'], \true) && $parameter->getName() === 'matches';
}
public function getParameterOutTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope) : ?Type
{
@ -39,6 +39,9 @@ final class PregMatchParameterOutTypeExtension implements StaticMethodParameterO
if ($flagsType === null) {
return null;
}
if (\stripos($methodReflection->getName(), 'matchAll') !== \false) {
return $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createMaybe(), $scope);
}
return $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createMaybe(), $scope);
}
}

View File

@ -41,7 +41,7 @@ final class PregMatchTypeSpecifyingExtension implements StaticMethodTypeSpecifyi
}
public function isStaticMethodSupported(MethodReflection $methodReflection, StaticCall $node, TypeSpecifierContext $context) : bool
{
return \in_array($methodReflection->getName(), ['match', 'isMatch', 'matchStrictGroups', 'isMatchStrictGroups'], \true) && !$context->null();
return \in_array($methodReflection->getName(), ['match', 'isMatch', 'matchStrictGroups', 'isMatchStrictGroups', 'matchAll', 'isMatchAll', 'matchAllStrictGroups', 'isMatchAllStrictGroups'], \true) && !$context->null();
}
public function specifyTypes(MethodReflection $methodReflection, StaticCall $node, Scope $scope, TypeSpecifierContext $context) : SpecifiedTypes
{
@ -56,7 +56,11 @@ final class PregMatchTypeSpecifyingExtension implements StaticMethodTypeSpecifyi
if ($flagsType === null) {
return new SpecifiedTypes();
}
$matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope);
if (\stripos($methodReflection->getName(), 'matchAll') !== \false) {
$matchedType = $this->regexShapeMatcher->matchAllExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope);
} else {
$matchedType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createFromBoolean($context->true()), $scope);
}
if ($matchedType === null) {
return new SpecifiedTypes();
}

View File

@ -0,0 +1,56 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202408\Composer\Pcre\PHPStan;
use RectorPrefix202408\Composer\Pcre\Preg;
use RectorPrefix202408\Composer\Pcre\Regex;
use PhpParser\Node\Expr\StaticCall;
use PHPStan\Analyser\Scope;
use PHPStan\Reflection\MethodReflection;
use PHPStan\Reflection\Native\NativeParameterReflection;
use PHPStan\Reflection\ParameterReflection;
use PHPStan\TrinaryLogic;
use PHPStan\Type\ClosureType;
use PHPStan\Type\Constant\ConstantArrayType;
use PHPStan\Type\Php\RegexArrayShapeMatcher;
use PHPStan\Type\StaticMethodParameterClosureTypeExtension;
use PHPStan\Type\StringType;
use PHPStan\Type\TypeCombinator;
use PHPStan\Type\Type;
final class PregReplaceCallbackClosureTypeExtension implements StaticMethodParameterClosureTypeExtension
{
/**
* @var RegexArrayShapeMatcher
*/
private $regexShapeMatcher;
public function __construct(RegexArrayShapeMatcher $regexShapeMatcher)
{
$this->regexShapeMatcher = $regexShapeMatcher;
}
public function isStaticMethodSupported(MethodReflection $methodReflection, ParameterReflection $parameter) : bool
{
return \in_array($methodReflection->getDeclaringClass()->getName(), [Preg::class, Regex::class], \true) && \in_array($methodReflection->getName(), ['replaceCallback', 'replaceCallbackStrictGroups'], \true) && $parameter->getName() === 'replacement';
}
public function getTypeFromStaticMethodCall(MethodReflection $methodReflection, StaticCall $methodCall, ParameterReflection $parameter, Scope $scope) : ?Type
{
$args = $methodCall->getArgs();
$patternArg = $args[0] ?? null;
$flagsArg = $args[5] ?? null;
if ($patternArg === null) {
return null;
}
$flagsType = PregMatchFlags::getType($flagsArg, $scope);
$matchesType = $this->regexShapeMatcher->matchExpr($patternArg->value, $flagsType, TrinaryLogic::createYes(), $scope);
if ($matchesType === null) {
return null;
}
if ($methodReflection->getName() === 'replaceCallbackStrictGroups' && \count($matchesType->getConstantArrays()) === 1) {
$matchesType = $matchesType->getConstantArrays()[0];
$matchesType = new ConstantArrayType($matchesType->getKeyTypes(), \array_map(static function (Type $valueType) : Type {
return TypeCombinator::removeNull($valueType);
}, $matchesType->getValueTypes()), $matchesType->getNextAutoIndexes(), [], $matchesType->isList());
}
return new ClosureType([new NativeParameterReflection($parameter->getName(), $parameter->isOptional(), $matchesType, $parameter->passedByReference(), $parameter->isVariadic(), $parameter->getDefaultValue())], new StringType());
}
}

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/
final class GeneratedConfig
{
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 657d715'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main ceccbe4'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 93a04b0'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 0eca1e4'));
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main 657d715'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main ceccbe4'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 93a04b0'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main d7cc42e'));
private function __construct()
{
}

View File

@ -91,6 +91,9 @@ CODE_SAMPLE
*/
public function refactor(Node $node) : ?Node
{
if ($node->isAbstract()) {
return null;
}
if (!$this->reflectionProvider->hasClass(SymfonyAnnotation::AS_COMMAND)) {
return null;
}

View File

@ -30,7 +30,7 @@ if (!function_exists('humbug_phpscoper_expose_class')) {
}
}
humbug_phpscoper_expose_class('AutoloadIncluder', 'RectorPrefix202408\AutoloadIncluder');
humbug_phpscoper_expose_class('ComposerAutoloaderInit969cf4fb8686733ba64d08544d342ca0', 'RectorPrefix202408\ComposerAutoloaderInit969cf4fb8686733ba64d08544d342ca0');
humbug_phpscoper_expose_class('ComposerAutoloaderInit900e9d3a850659d65b1997f7abdf1e41', 'RectorPrefix202408\ComposerAutoloaderInit900e9d3a850659d65b1997f7abdf1e41');
humbug_phpscoper_expose_class('Product', 'RectorPrefix202408\Product');
// Function aliases. For more information see: