diff --git a/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php b/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php index 129c390bb5b..80d837e066b 100644 --- a/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php +++ b/packages/VendorLocker/ParentClassMethodTypeOverrideGuard.php @@ -7,7 +7,6 @@ use PhpParser\Node\Stmt\ClassMethod; use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\MethodReflection; use PHPStan\Type\Type; -use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\Reflection\ReflectionResolver; use Rector\Core\Util\Reflection\PrivatesAccessor; use Rector\NodeNameResolver\NodeNameResolver; @@ -49,14 +48,15 @@ final class ParentClassMethodTypeOverrideGuard $this->staticTypeMapper = $staticTypeMapper; $this->privatesAccessor = $privatesAccessor; } - public function hasParentClassMethod(ClassMethod $classMethod) : ?bool + public function hasParentClassMethod(ClassMethod $classMethod) : bool { try { $parentClassMethod = $this->resolveParentClassMethod($classMethod); return $parentClassMethod instanceof MethodReflection; } catch (UnresolvableClassException $exception) { - // we don't know all involved parents. - return null; + // we don't know all involved parents, + // marking as parent exists which usually means the method is guarded against overrides. + return \true; } } public function getParentClassMethod(ClassMethod $classMethod) : ?MethodReflection @@ -64,8 +64,7 @@ final class ParentClassMethodTypeOverrideGuard try { return $this->resolveParentClassMethod($classMethod); } catch (UnresolvableClassException $exception) { - // we don't know all involved parents. - throw new ShouldNotHappenException('Unable to resolve involved class. You are likely missing hasParentClassMethod() before calling getParentClassMethod().'); + return null; } } public function shouldSkipReturnTypeChange(ClassMethod $classMethod, Type $parentType) : bool diff --git a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php index 9ec0ed4f40f..43127244646 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/AddParamTypeFromPropertyTypeRector.php @@ -121,7 +121,7 @@ CODE_SAMPLE if (!$paramType instanceof Node) { continue; } - if ($this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($node) !== \false) { + if ($this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($node)) { return null; } $param->type = $paramType; diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php index 611b1fc0e3b..bfee0a14348 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ParamTypeByMethodCallTypeRector.php @@ -135,7 +135,7 @@ CODE_SAMPLE if ($classMethod->params === []) { return \true; } - return $this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($classMethod) !== \false; + return $this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($classMethod); } /** * @param \PhpParser\Node\Identifier|\PhpParser\Node\Name|\PhpParser\Node\NullableType|\PhpParser\Node\UnionType|\PhpParser\Node\ComplexType $paramType diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictParamRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictParamRector.php index 36359b9ca39..f0131d54699 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictParamRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromStrictParamRector.php @@ -177,7 +177,7 @@ CODE_SAMPLE return \true; } if ($node instanceof ClassMethod) { - if ($this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($node) !== \false) { + if ($this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($node)) { return \true; } if ($node->isMagic()) { diff --git a/rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php b/rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php index 4d3a5330261..ad0c4f34357 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/StrictArrayParamDimFetchRector.php @@ -70,7 +70,7 @@ CODE_SAMPLE public function refactor(Node $node) : ?Node { $hasChanged = \false; - if ($node instanceof ClassMethod && $this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($node) !== \false) { + if ($node instanceof ClassMethod && $this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($node)) { return null; } foreach ($node->getParams() as $param) { diff --git a/rules/TypeDeclaration/Rector/ClassMethod/StrictStringParamConcatRector.php b/rules/TypeDeclaration/Rector/ClassMethod/StrictStringParamConcatRector.php index 967ce3b2883..8b1091bf7f8 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/StrictStringParamConcatRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/StrictStringParamConcatRector.php @@ -71,7 +71,7 @@ CODE_SAMPLE */ public function refactor(Node $node) : ?Node { - if ($node instanceof ClassMethod && $this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($node) !== \false) { + if ($node instanceof ClassMethod && $this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($node)) { return null; } $hasChanged = \false; diff --git a/rules/TypeDeclaration/Rector/Param/ParamTypeFromStrictTypedPropertyRector.php b/rules/TypeDeclaration/Rector/Param/ParamTypeFromStrictTypedPropertyRector.php index 13bd6c7a4f4..7b7f3d5702f 100644 --- a/rules/TypeDeclaration/Rector/Param/ParamTypeFromStrictTypedPropertyRector.php +++ b/rules/TypeDeclaration/Rector/Param/ParamTypeFromStrictTypedPropertyRector.php @@ -108,7 +108,7 @@ CODE_SAMPLE if ($classMethod->isAbstract()) { return null; } - if ($this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($classMethod) !== \false) { + if ($this->parentClassMethodTypeOverrideGuard->hasParentClassMethod($classMethod)) { return null; } $originalParamType = $this->resolveParamOriginalType($param, $scope); diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 14b58fd3ee5..21214cd0dd8 100644 --- a/src/Application/VersionResolver.php +++ b/src/Application/VersionResolver.php @@ -19,12 +19,12 @@ final class VersionResolver * @api * @var string */ - public const PACKAGE_VERSION = '41a4d2456cde167c50c628f62aa5587689c0a8b5'; + public const PACKAGE_VERSION = '92b6e3a6d1e9a4289b5347e52f1cf379a68d74b4'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-08-07 13:01:37'; + public const RELEASE_DATE = '2023-08-07 13:16:17'; /** * @var int */ diff --git a/vendor/autoload.php b/vendor/autoload.php index e3da0f99ab0..17703bfd154 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -22,4 +22,4 @@ if (PHP_VERSION_ID < 50600) { require_once __DIR__ . '/composer/autoload_real.php'; -return ComposerAutoloaderInitbaa316b255ef95eb936dbd87b6717275::getLoader(); +return ComposerAutoloaderInit07f692a9b7f057489054a15eec63fa36::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 824d0bc2a5f..a5f5073fded 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitbaa316b255ef95eb936dbd87b6717275 +class ComposerAutoloaderInit07f692a9b7f057489054a15eec63fa36 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInitbaa316b255ef95eb936dbd87b6717275 return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitbaa316b255ef95eb936dbd87b6717275', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit07f692a9b7f057489054a15eec63fa36', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitbaa316b255ef95eb936dbd87b6717275', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit07f692a9b7f057489054a15eec63fa36', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitbaa316b255ef95eb936dbd87b6717275::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit07f692a9b7f057489054a15eec63fa36::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitbaa316b255ef95eb936dbd87b6717275::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit07f692a9b7f057489054a15eec63fa36::$files; $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 352063d7675..7b38300b53f 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitbaa316b255ef95eb936dbd87b6717275 +class ComposerStaticInit07f692a9b7f057489054a15eec63fa36 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -3012,9 +3012,9 @@ class ComposerStaticInitbaa316b255ef95eb936dbd87b6717275 public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitbaa316b255ef95eb936dbd87b6717275::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitbaa316b255ef95eb936dbd87b6717275::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitbaa316b255ef95eb936dbd87b6717275::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit07f692a9b7f057489054a15eec63fa36::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit07f692a9b7f057489054a15eec63fa36::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit07f692a9b7f057489054a15eec63fa36::$classMap; }, null, ClassLoader::class); }