From 2e6faaab135c9b520998eacf6b1830da9fb9d198 Mon Sep 17 00:00:00 2001 From: Saskia Teichmann Date: Sat, 31 Oct 2026 15:17:34 +0100 Subject: [PATCH] Narrow return type of wp_get_environment_type wp_get_environment_type() reads WP_ENVIRONMENT_TYPE from the environment or the constant and checks it against a fixed list. Any other value becomes 'production'. The static cache is validated before every return, and no call can read it in between. There is no filter. The function therefore always returns 'local', 'development', 'staging' or 'production'. --- functionMap.php | 1 + tests/data/return/wp-get-environment-type.php | 14 ++++++++++++++ wordpress-stubs.php | 1 + 3 files changed, 16 insertions(+) create mode 100644 tests/data/return/wp-get-environment-type.php diff --git a/functionMap.php b/functionMap.php index 6fe36ba..951b8c9 100644 --- a/functionMap.php +++ b/functionMap.php @@ -254,6 +254,7 @@ 'wp_get_archives' => ['($args is array{echo: false|0, ...} ? string|void : void)'], 'wp_get_comment_status' => ["'approved'|'spam'|'trash'|'unapproved'|false"], 'wp_get_elements_class_name' => ['lowercase-string&non-falsy-string'], + 'wp_get_environment_type' => ["'development'|'local'|'production'|'staging'"], 'wp_get_http_headers' => [null, 'deprecated' => 'false'], 'wp_get_inline_script_tag' => ['non-falsy-string', 'attributes' => 'array'], 'wp_get_link_cats' => ['($link_id is empty ? array{} : array>)'], diff --git a/tests/data/return/wp-get-environment-type.php b/tests/data/return/wp-get-environment-type.php new file mode 100644 index 0000000..6a37c3e --- /dev/null +++ b/tests/data/return/wp-get-environment-type.php @@ -0,0 +1,14 @@ +