Skip to content

Treat the register_setting option group as a read - #164

Merged
schlessera merged 1 commit into
mainfrom
fix/158-settings-group-reads
Oct 23, 2026
Merged

schlessera merged 1 commit into
mainfrom
fix/158-settings-group-reads

Conversation

@schlessera

Copy link
Copy Markdown
Member

Closes #158

What changed

The architecture.prefixedNames rule now treats the option group of register_setting() (1st argument) as a read: it passes when it carries the prefix or is listed in settings.allowed. The option name (2nd argument) is still a write and always needs the prefix. phpstan.neon.dist allows the five core settings groups (general, writing, reading, discussion, media), so a plugin can add a field to a core settings page without weakening the check. The docs table row and Allows paragraph describe the split.

Why this shape

The third element of a FUNCTIONS entry is now either the existing boolean or a list of the positions that only read. That keeps the table in one place and leaves every other entry untouched. Allowing the groups through managed was the alternative; it would exempt both positions, so an option literally named reading would pass.

Proof

The new fixture lines (Registrations.php:44-47) and the settings.allowed: [ 'reading' ] test config were added first. Before the rule change the test failed: reading was reported as an unprefixed setting name at line 44, and the expected reports for lines 45 to 47 were wrong (the option group was reported where it should not be). After the change:

  • register_setting( 'reading', 'acme_plugin_max_age' ) passes.
  • register_setting( 'reading', 'max_age' ) reports the name max_age.
  • register_setting( 'discussion', 'acme_plugin_max_age' ) reports the group discussion.
  • register_setting( 'reading', 'reading' ) reports the name reading.
  • The existing cases at lines 36 to 39 keep their results.
composer test   # OK (575 tests), PHP 8.3
composer lint   # phpcs, phpstan, psalm, rule tests (129 tests) pass, PHP 8.3

Checklist

  • composer test and composer lint pass locally, and CI is green on the current head.
  • Every acceptance criterion from the issue is met, or the gap is named below.
  • Nothing a generated plugin relies on changed, or the issue carries breaking and a ruling.
  • Docs and inline comments reflect the change, or nothing documented moved.

Anything left open

Nothing. Note that the issue's file:line citations had drifted slightly after #157 (the managed check is at PrefixedNamesRule.php:446, the table row at docs/architecture-rules.md:1124); they still pointed at the right code.

@schlessera schlessera added type: fix Something is broken and must behave the way it is documented. area: tooling composer.json, PHPCS, PHPStan, Psalm and Rector configuration. labels Oct 23, 2026
@schlessera
schlessera merged commit fd25d8a into main Oct 23, 2026
5 checks passed
schlessera added a commit to mwpd/content-freshness that referenced this pull request Oct 23, 2026
Ported from mwpd/basic-scaffold@fd25d8a (mwpd/basic-scaffold#164).

The plugin had made the same change; the scaffold's version replaces it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: tooling composer.json, PHPCS, PHPStan, Psalm and Rector configuration. type: fix Something is broken and must behave the way it is documented.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tooling: prefixedNames rejects a setting that joins a core settings page

1 participant