Skip to content

[Php] Fix filter cache on PolyfillPackagesProvider - #5390

Merged
samsonasik merged 3 commits into
mainfrom
fix-filter-cache-polify
Dec 25, 2023
Merged

samsonasik merged 3 commits into
mainfrom
fix-filter-cache-polify

Conversation

@samsonasik

Copy link
Copy Markdown
Member

private function filterPolyfillPackages(array $require): array
{
return array_filter($require, static fn (string $packageName): bool => ! str_starts_with(
return array_filter(array_keys($require), static fn (string $packageName): bool => str_starts_with(

@samsonasik samsonasik Dec 25, 2023 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here only key is needed, when we define in composer.json

"require": {
    "symfony/polyfill-php80" => "*"
}

then, filter the str_starts_with() one instead, so it get data:

array('symfony/polyfill-php80')

to compare with in_array() on PhpVersionedFilter

$polyfillPackageNames = $this->polyfillPackagesProvider->provide();
if (in_array($rector->providePolyfillPackage(), $polyfillPackageNames, true)) {
$activeRectors[] = $rector;
continue;
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (! file_exists($projectComposerJson)) {
return [];
// already cached, even only empty array
if ($this->cachedPolyfillPackages !== null) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here compare no null = already cached.

@samsonasik

Copy link
Copy Markdown
Member Author

All checks have passed 🎉 @TomasVotruba I am merging it ;)

@samsonasik
samsonasik merged commit 69983e9 into main Dec 25, 2023
@samsonasik
samsonasik deleted the fix-filter-cache-polify branch December 25, 2023 02:58
@TomasVotruba

Copy link
Copy Markdown
Member

Awesome, thanks for catching the glitches 👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants