Skip to content

I18N: Correct the case of the MO class in a WP_Locale_Switcher docblock - #12938

Open
CallumBW95 wants to merge 1 commit into
WordPress:trunkfrom
CallumBW95:phpstan/class-name-case-locale-switcher
Open

I18N: Correct the case of the MO class in a WP_Locale_Switcher docblock#12938
CallumBW95 wants to merge 1 commit into
WordPress:trunkfrom
CallumBW95:phpstan/class-name-case-locale-switcher

Conversation

@CallumBW95

Copy link
Copy Markdown

Corrects the @global annotation for $l10n in
WP_Locale_Switcher::load_translations(), which documented the array as Mo[].
The class is MO, defined in wp-includes/pomo/mo.php; no class named Mo
exists. Every other @global annotation for $l10n in core already uses
MO[], so this was the sole outlier. The description is also clarified to note
that the array is keyed by text domain.

This was the only remaining class.nameCase occurrence, so the change empties
tests/phpstan/baselines/class.nameCase.neon. As the baseline header directs,
the file is deleted along with its includes entry in phpstan.neon.dist. The
baseline was regenerated with
composer phpstan:baselines -- --identifier=class.nameCase, not edited by hand.

Background

git blame dates the annotation to [38961] (2016-10-26), the changeset that
introduced WP_Locale_Switcher. It has been present in every revision of the
file since — roughly nine years — and was never copied elsewhere, which is why
the rest of core is already consistent.

Testing instructions

  1. npm run typecheck:php on trunk reports [OK] No errors, because the
    occurrence is baselined.
  2. Delete tests/phpstan/baselines/class.nameCase.neon and its includes entry,
    then re-run: PHPStan reports
    Class MO referenced with incorrect case: Mo. at
    src/wp-includes/class-wp-locale-switcher.php:241.
  3. With this branch applied, npm run typecheck:php reports [OK] No errors
    with the baseline gone.
  4. npm run test:php is unchanged: 30774 tests, 4559286 assertions,
    86 warnings, 44 skipped, exit 0 — identical before and after.

Documentation-only change; no runtime behaviour is affected.

Trac ticket: https://core.trac.wordpress.org/ticket/65817

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5
Used for: locating the occurrence via the PHPStan class.nameCase baseline,
git blame/git log -S archaeology to date the annotation, and drafting this
description. The change itself, the baseline regeneration, and verification
against the full PHPUnit and PHPStan runs were reviewed and confirmed by me in a
local development environment.

The `@global` tag for `$l10n` in `WP_Locale_Switcher::load_translations()`
documented the array as `Mo[]`. The class is `MO`, defined in
`wp-includes/pomo/mo.php`; no class named `Mo` exists. Every other `@global`
annotation for `$l10n` in core already uses `MO[]`, so this was the sole
outlier. The description is also clarified to note that the array is keyed by
text domain.

This empties the `class.nameCase` PHPStan baseline, so the file is removed
along with its `includes` entry in `phpstan.neon.dist`.

Props CallumBW95.
See #65817.
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props callumbw95, westonruter.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@westonruter

westonruter commented Aug 7, 2026

Copy link
Copy Markdown
Member

This is what I'm talking about! 🎉

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.

2 participants