diff --git a/bin/rector.php b/bin/rector.php index ca687105b64..b4647e3526f 100755 --- a/bin/rector.php +++ b/bin/rector.php @@ -87,10 +87,8 @@ final class AutoloadIncluder if (\in_array($filePath, $this->alreadyLoadedAutoloadFiles, \true)) { return; } + /** @var string $realPath always string after file_exists() check */ $realPath = \realpath($filePath); - if (!\is_string($realPath)) { - return; - } $this->alreadyLoadedAutoloadFiles[] = $realPath; require_once $filePath; } diff --git a/packages/Caching/Detector/ChangedFilesDetector.php b/packages/Caching/Detector/ChangedFilesDetector.php index e250f152b6d..d5762113ee4 100644 --- a/packages/Caching/Detector/ChangedFilesDetector.php +++ b/packages/Caching/Detector/ChangedFilesDetector.php @@ -85,6 +85,7 @@ final class ChangedFilesDetector } private function resolvePath(string $filePath) : string { + /** @var string|false $realPath */ $realPath = \realpath($filePath); if ($realPath === \false) { return $filePath; diff --git a/packages/Config/RectorConfig.php b/packages/Config/RectorConfig.php index af31ffd53b1..ee24f874c39 100644 --- a/packages/Config/RectorConfig.php +++ b/packages/Config/RectorConfig.php @@ -295,7 +295,7 @@ final class RectorConfig extends Container */ private function isRuleNoLongerExists($skipRule) : bool { - return \is_string($skipRule) && \strpos($skipRule, '*') === \false && \realpath($skipRule) === \false && \substr_compare($skipRule, 'Rector', -\strlen('Rector')) === 0 && !\class_exists($skipRule); + return \is_string($skipRule) && \strpos($skipRule, '*') === \false && \substr_compare($skipRule, 'Rector', -\strlen('Rector')) === 0 && !\is_dir($skipRule) && !\is_file($skipRule) && !\class_exists($skipRule); } /** * @param string[] $values diff --git a/packages/Skipper/FileSystem/FnMatchPathNormalizer.php b/packages/Skipper/FileSystem/FnMatchPathNormalizer.php index a2042c8ebec..3386731ba4f 100644 --- a/packages/Skipper/FileSystem/FnMatchPathNormalizer.php +++ b/packages/Skipper/FileSystem/FnMatchPathNormalizer.php @@ -14,6 +14,7 @@ final class FnMatchPathNormalizer return '*' . \trim($path, '*') . '*'; } if (\strpos($path, '..') !== \false) { + /** @var string|false $path */ $path = \realpath($path); if ($path === \false) { return ''; diff --git a/packages/Skipper/RealpathMatcher.php b/packages/Skipper/RealpathMatcher.php index 89cbae2997c..2a189790406 100644 --- a/packages/Skipper/RealpathMatcher.php +++ b/packages/Skipper/RealpathMatcher.php @@ -7,10 +7,12 @@ final class RealpathMatcher { public function match(string $matchingPath, string $filePath) : bool { + /** @var string|false $realPathMatchingPath */ $realPathMatchingPath = \realpath($matchingPath); if (!\is_string($realPathMatchingPath)) { return \false; } + /** @var string|false $realpathFilePath */ $realpathFilePath = \realpath($filePath); if (!\is_string($realpathFilePath)) { return \false; diff --git a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnNewRector.php b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnNewRector.php index 0903ae1f815..dd22a7aa06c 100644 --- a/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnNewRector.php +++ b/rules/TypeDeclaration/Rector/ClassMethod/ReturnTypeFromReturnNewRector.php @@ -4,6 +4,7 @@ declare (strict_types=1); namespace Rector\TypeDeclaration\Rector\ClassMethod; use PhpParser\Node; +use PhpParser\Node\Expr; use PhpParser\Node\Expr\ArrowFunction; use PhpParser\Node\Expr\Closure; use PhpParser\Node\Expr\New_; @@ -213,7 +214,15 @@ CODE_SAMPLE { $newTypes = []; foreach ($returns as $return) { + if (!$return->expr instanceof Expr) { + return null; + } if (!$return->expr instanceof New_) { + $returnType = $this->nodeTypeResolver->getNativeType($return->expr); + if ($returnType instanceof ObjectType) { + $newTypes[] = $returnType; + continue; + } return null; } $new = $return->expr; diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index 5b984a682ce..c4079aefb8e 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 = 'c956f862094345e72533d83e629938437bf29a43'; + public const PACKAGE_VERSION = '2cf8d837421963a540d2cf6e3b42702b1a8ae09e'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-09-17 20:16:42'; + public const RELEASE_DATE = '2023-09-18 13:12:36'; /** * @var int */ diff --git a/src/Autoloading/BootstrapFilesIncluder.php b/src/Autoloading/BootstrapFilesIncluder.php index 95ca558c12a..13253fa4472 100644 --- a/src/Autoloading/BootstrapFilesIncluder.php +++ b/src/Autoloading/BootstrapFilesIncluder.php @@ -34,6 +34,7 @@ final class BootstrapFilesIncluder } private function requireRectorStubs() : void { + /** @var false|string $stubsRectorDirectory */ $stubsRectorDirectory = \realpath(__DIR__ . '/../../stubs-rector'); if ($stubsRectorDirectory === \false) { return; diff --git a/vendor/autoload.php b/vendor/autoload.php index 58d3c461029..69a8c4d1c1c 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 ComposerAutoloaderInitedb0f92e91530e9ec0d0e8514967c6be::getLoader(); +return ComposerAutoloaderInit30b515138a376fc3fe949fa234dad2a9::getLoader(); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index 4fc030911fa..dbebc3c42f6 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -2,7 +2,7 @@ // autoload_real.php @generated by Composer -class ComposerAutoloaderInitedb0f92e91530e9ec0d0e8514967c6be +class ComposerAutoloaderInit30b515138a376fc3fe949fa234dad2a9 { private static $loader; @@ -22,17 +22,17 @@ class ComposerAutoloaderInitedb0f92e91530e9ec0d0e8514967c6be return self::$loader; } - spl_autoload_register(array('ComposerAutoloaderInitedb0f92e91530e9ec0d0e8514967c6be', 'loadClassLoader'), true, true); + spl_autoload_register(array('ComposerAutoloaderInit30b515138a376fc3fe949fa234dad2a9', 'loadClassLoader'), true, true); self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); - spl_autoload_unregister(array('ComposerAutoloaderInitedb0f92e91530e9ec0d0e8514967c6be', 'loadClassLoader')); + spl_autoload_unregister(array('ComposerAutoloaderInit30b515138a376fc3fe949fa234dad2a9', 'loadClassLoader')); require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInitedb0f92e91530e9ec0d0e8514967c6be::getInitializer($loader)); + call_user_func(\Composer\Autoload\ComposerStaticInit30b515138a376fc3fe949fa234dad2a9::getInitializer($loader)); $loader->setClassMapAuthoritative(true); $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInitedb0f92e91530e9ec0d0e8514967c6be::$files; + $filesToLoad = \Composer\Autoload\ComposerStaticInit30b515138a376fc3fe949fa234dad2a9::$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 209b15632b9..6686086cbf2 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -4,7 +4,7 @@ namespace Composer\Autoload; -class ComposerStaticInitedb0f92e91530e9ec0d0e8514967c6be +class ComposerStaticInit30b515138a376fc3fe949fa234dad2a9 { public static $files = array ( 'ad155f8f1cf0d418fe49e248db8c661b' => __DIR__ . '/..' . '/react/promise/src/functions_include.php', @@ -2593,9 +2593,9 @@ class ComposerStaticInitedb0f92e91530e9ec0d0e8514967c6be public static function getInitializer(ClassLoader $loader) { return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitedb0f92e91530e9ec0d0e8514967c6be::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitedb0f92e91530e9ec0d0e8514967c6be::$prefixDirsPsr4; - $loader->classMap = ComposerStaticInitedb0f92e91530e9ec0d0e8514967c6be::$classMap; + $loader->prefixLengthsPsr4 = ComposerStaticInit30b515138a376fc3fe949fa234dad2a9::$prefixLengthsPsr4; + $loader->prefixDirsPsr4 = ComposerStaticInit30b515138a376fc3fe949fa234dad2a9::$prefixDirsPsr4; + $loader->classMap = ComposerStaticInit30b515138a376fc3fe949fa234dad2a9::$classMap; }, null, ClassLoader::class); }