fix(switcher): migrate extension for Polylang 3.9 - #24
Merged
Conversation
Replace PLL_Switcher return-type support with pll_the_languages() inference for raw/echo, add deprecation reporting, and update tests for the new API.
Screenfeed
approved these changes
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
PLL_Switcher::the_languages()return-type extension (class removed in Polylang 3.9).pll_the_languages()inference forraw,echo, and defaultvoidreturn.DeprecatedPllSwitcherRuleand a scan-only stub to report legacyPLL_Switcherusage.tests/phpstan.neonfor extension development.Why?
Polylang 3.9 refactored the language switcher:
PLL_Switcheris gone,pll_the_languages()now returnsvoid|string|arraydepending on$args, and the newWP_Syntex\Polylang\Switcher\Switcherclass is typed via stubs/source.The previous extension targeted a removed API and produced
*ERROR*types once updated stubs droppedPLL_Switcher.How?
GuessTypeFromSwitcherAttributeswithGuessTypeFromSwitcherArgs, using PHPStan 2 APIs (getConstantArrays(),getConstantStrings()).DeprecatedPllSwitcherRule(polylang.deprecatedSwitcher,polylang.deprecatedSwitcherMethod).stubs/pll-switcher-deprecated.phpviascanFilesso the deprecated symbol remains discoverable.phpstan/phpstanas a direct runtime dependency.Test plan
composer test(34 PHPUnit tests)composer stan(self-analysis of switcher inference code)polylang/after bumping this package