From d29c258132b199c459d5bdaf49b6ee1c817e3f4f Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Mon, 25 Dec 2023 03:00:38 +0000 Subject: [PATCH] Updated Rector to commit 69983e907a570f9b4f708be81e8cf1eae8a7f1d0 https://github.com/rectorphp/rector-src/commit/69983e907a570f9b4f708be81e8cf1eae8a7f1d0 [Php] Fix filter cache on PolyfillPackagesProvider (#5390) --- src/Application/VersionResolver.php | 4 ++-- src/Php/PolyfillPackagesProvider.php | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/Application/VersionResolver.php b/src/Application/VersionResolver.php index c35adf097990..7ac5bc47ce40 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 = '6ebab94b971a930457c8e217dcb699c671ad617b'; + public const PACKAGE_VERSION = '69983e907a570f9b4f708be81e8cf1eae8a7f1d0'; /** * @api * @var string */ - public const RELEASE_DATE = '2023-12-25 00:53:36'; + public const RELEASE_DATE = '2023-12-25 09:58:30'; /** * @var int */ diff --git a/src/Php/PolyfillPackagesProvider.php b/src/Php/PolyfillPackagesProvider.php index a6df534f7a10..e8f48db0c68a 100644 --- a/src/Php/PolyfillPackagesProvider.php +++ b/src/Php/PolyfillPackagesProvider.php @@ -11,11 +11,11 @@ final class PolyfillPackagesProvider { /** - * @var array + * @var null|array */ - private $cachedPolyfillPackages = []; + private $cachedPolyfillPackages = null; /** - * @return array + * @return array */ public function provide() : array { @@ -23,11 +23,13 @@ public function provide() : array if (SimpleParameterProvider::hasParameter(Option::POLYFILL_PACKAGES)) { return SimpleParameterProvider::provideArrayParameter(Option::POLYFILL_PACKAGES); } + // already cached, even only empty array + if ($this->cachedPolyfillPackages !== null) { + return $this->cachedPolyfillPackages; + } $projectComposerJson = \getcwd() . '/composer.json'; if (!\file_exists($projectComposerJson)) { - return []; - } - if ($this->cachedPolyfillPackages !== []) { + $this->cachedPolyfillPackages = []; return $this->cachedPolyfillPackages; } $composerContents = FileSystem::read($projectComposerJson); @@ -37,12 +39,12 @@ public function provide() : array } /** * @param array $require - * @return array + * @return array */ private function filterPolyfillPackages(array $require) : array { - return \array_filter($require, static function (string $packageName) : bool { - return \strncmp($packageName, 'symfony/polyfill-', \strlen('symfony/polyfill-')) !== 0; + return \array_filter(\array_keys($require), static function (string $packageName) : bool { + return \strncmp($packageName, 'symfony/polyfill-', \strlen('symfony/polyfill-')) === 0; }); } }