Skip to content

Keep polyfill stub classes in the global namespace (v1.2.7)#2

Merged
mostafasoufi merged 1 commit into
mainfrom
fix/polyfill-stubs-global-namespace
Apr 22, 2026
Merged

Keep polyfill stub classes in the global namespace (v1.2.7)#2
mostafasoufi merged 1 commit into
mainfrom
fix/polyfill-stubs-global-namespace

Conversation

@mostafasoufi

Copy link
Copy Markdown
Member

Summary

  • Extend ClassmapReplacer built-in allowlist with the five polyfill-stub classes that were being prefixed: Normalizer, Attribute, JsonException, PhpToken, UnhandledMatchError
  • Also add the related modern-PHP globals CompileError, UnitEnum, BackedEnum, SensitiveParameter, Override so future polyfill stubs don't regress the same way
  • Bump to 1.2.7 and update CHANGELOG

Why

Symfony polyfill packages (polyfill-intl-normalizer, polyfill-php73, polyfill-php80) ship stub files that declare these classes in the global namespace specifically so they act as fallbacks when the corresponding PHP extension/version is missing. The previous allowlist covered Stringable and ValueError but missed the rest — so after scoping, the stubs ended up renamed (e.g. WPSmsWooProVendor_Normalizer) and no longer filled in the global \Normalizer that the scoped symfony/string code references. On servers without the intl extension this produced a fatal Class "Normalizer" not found at install time (see WSMS support ticket #15297).

Test plan

  • vendor/bin/phpunit — 134/134 tests pass
  • New dataProvider-backed regression test asserts each of the 5 polyfill stubs stays unprefixed in both declaration and usage contexts
  • End-to-end check: running the replacer on a synthetic classmap with Normalizer, Attribute, and a custom global class leaves the built-ins alone and prefixes only the custom class

Symfony polyfill packages ship stubs that declare Normalizer, Attribute,
JsonException, PhpToken, and UnhandledMatchError in the global namespace
so they serve as fallbacks when the corresponding PHP extension/version
is missing. ClassmapReplacer was prefixing those stubs alongside other
global classes, which broke the fallback and fatalled with "Class X not
found" on servers without the native implementation (e.g. no intl ext).

Extend the built-in allowlist with the five polyfilled classes plus
CompileError, UnitEnum, BackedEnum, SensitiveParameter, and Override
so future polyfill stubs don't regress the same way.
@mostafasoufi mostafasoufi merged commit 7a000ab into main Apr 22, 2026
7 checks passed
@mostafasoufi mostafasoufi deleted the fix/polyfill-stubs-global-namespace branch April 22, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant