Skip to content

Commit

Permalink
Updated Rector to commit 69983e907a570f9b4f708be81e8cf1eae8a7f1d0
Browse files Browse the repository at this point in the history
rectorphp/rector-src@69983e9 [Php] Fix filter cache on PolyfillPackagesProvider (#5390)
  • Loading branch information
TomasVotruba committed Dec 25, 2023
1 parent 3f2b3ed commit d29c258
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/Application/VersionResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
20 changes: 11 additions & 9 deletions src/Php/PolyfillPackagesProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,25 @@
final class PolyfillPackagesProvider
{
/**
* @var array<PolyfillPackage::*>
* @var null|array<int, PolyfillPackage::*>
*/
private $cachedPolyfillPackages = [];
private $cachedPolyfillPackages = null;
/**
* @return array<PolyfillPackage::*>
* @return array<int, PolyfillPackage::*>
*/
public function provide() : array
{
// used in tests mostly
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);
Expand All @@ -37,12 +39,12 @@ public function provide() : array
}
/**
* @param array<string, string> $require
* @return array<PolyfillPackage::*>
* @return array<int, PolyfillPackage::*>
*/
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;
});
}
}

0 comments on commit d29c258

Please sign in to comment.