Skip to content

fix(switcher): migrate extension for Polylang 3.9 - #24

Merged
Screenfeed merged 1 commit into
masterfrom
fix/switcher-polylang-3.9
Sep 1, 2026
Merged

fix(switcher): migrate extension for Polylang 3.9#24
Screenfeed merged 1 commit into
masterfrom
fix/switcher-polylang-3.9

Conversation

@Hug0-Drelon

@Hug0-Drelon Hug0-Drelon commented Sep 1, 2026

Copy link
Copy Markdown
Member

What?

  • Remove PLL_Switcher::the_languages() return-type extension (class removed in Polylang 3.9).
  • Update pll_the_languages() inference for raw, echo, and default void return.
  • Add DeprecatedPllSwitcherRule and a scan-only stub to report legacy PLL_Switcher usage.
  • Refresh PHPUnit coverage and add a local tests/phpstan.neon for extension development.

Why?

Polylang 3.9 refactored the language switcher: PLL_Switcher is gone, pll_the_languages() now returns void|string|array depending on $args, and the new WP_Syntex\Polylang\Switcher\Switcher class is typed via stubs/source.

The previous extension targeted a removed API and produced *ERROR* types once updated stubs dropped PLL_Switcher.

How?

  • Replace GuessTypeFromSwitcherAttributes with GuessTypeFromSwitcherArgs, using PHPStan 2 APIs (getConstantArrays(), getConstantStrings()).
  • Register DeprecatedPllSwitcherRule (polylang.deprecatedSwitcher, polylang.deprecatedSwitcherMethod).
  • Load stubs/pll-switcher-deprecated.php via scanFiles so the deprecated symbol remains discoverable.
  • Declare phpstan/phpstan as a direct runtime dependency.

Test plan

  • composer test (34 PHPUnit tests)
  • composer stan (self-analysis of switcher inference code)
  • Consumer check: run PHPStan in polylang/ after bumping this package

Replace PLL_Switcher return-type support with pll_the_languages() inference
for raw/echo, add deprecation reporting, and update tests for the new API.
@Hug0-Drelon Hug0-Drelon self-assigned this Sep 1, 2026
@Hug0-Drelon Hug0-Drelon added the bug Something isn't working label Sep 1, 2026
@Screenfeed
Screenfeed merged commit 38985aa into master Sep 1, 2026
2 checks passed
@Screenfeed
Screenfeed deleted the fix/switcher-polylang-3.9 branch September 1, 2026 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants