Skip to content

Narrow return type of wp_get_development_mode - #500

Merged
szepeviktor merged 1 commit into
php-stubs:masterfrom
s-a-s-k-i-a:fix/wp-get-development-mode-return-type
Nov 1, 2026
Merged

szepeviktor merged 1 commit into
php-stubs:masterfrom
s-a-s-k-i-a:fix/wp-get-development-mode-return-type

Conversation

@s-a-s-k-i-a

Copy link
Copy Markdown
Contributor

wp_get_development_mode() only returns one of five values: '', 'all', 'core', 'plugin' or 'theme'. WordPress checks WP_DEVELOPMENT_MODE against this fixed list and falls back to '' for anything else. There is no filter.

The stubs still say string. This PR adds the five values to functionMap.php, the same way #296 did for wp_get_server_protocol().

phpstan-wordpress already tells users to call wp_get_development_mode() instead of reading the constant. With this change, PHPStan reports a typo like wp_get_development_mode() === 'themes' as always false.

Changes

  • functionMap.php: new entry for wp_get_development_mode.
  • wordpress-stubs.php: regenerated with ./generate.sh.
  • tests/data/return/wp-get-development-mode.php: new return type test.

Testing

  • composer run test passes locally on PHP 8.2, 8.4 and 8.5.
  • The new test fails with the old stubs and passes with the new ones.
  • The Integrate and Spelling workflows pass on my fork.

AI-assisted (Claude). I reviewed and tested the change.

wp_get_development_mode() reads WP_DEVELOPMENT_MODE and checks it against
a fixed list. Any other value becomes ''. The static cache is set only after
this check. There is no filter. The function therefore always returns '',
'all', 'core', 'plugin' or 'theme'.
@s-a-s-k-i-a
s-a-s-k-i-a marked this pull request as ready for review November 1, 2026 11:42
@szepeviktor
szepeviktor merged commit 5eb2e44 into php-stubs:master Nov 1, 2026
8 checks passed
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