Commit c7415c757a for wordpress.org
commit c7415c757a9467e514aa314aa9e79ca924aef9d5
Author: westonruter <westonruter@git.wordpress.org>
Date: Mon Nov 16 20:14:04 2026 +0000
Code Quality: Use `decimal-int-string` for integer strings.
PHPStan 2.2.0 introduced the `decimal-int-string` type for a string in canonical decimal integer form, such as `'123'` or `'-5'`, which is exactly what casting an integer to a string produces. For historical reasons, WordPress passes many integers around as strings, since that is what MySQL returns for integer columns. These had been typed as `numeric-string`, which also admits floats, exponents, and leading zeros or whitespace. The narrower `decimal-int-string` type is now used for object IDs, `COUNT(*)` results, and the integer columns exposed on the core object classes. The `numeric-string` type is kept where a value can be zero-padded or fractional, such as date parts and EXIF image metadata, and for now in `wp_unique_id()` and `wp_unique_prefixed_id()` due to a PHPStan issue.
Developed in https://github.com/WordPress/wordpress-develop/pull/16013.
Follow-up to r62437, r62640, r62717, r62822, r63488, r63618, r65269, r65527.
See #65817.
Built from https://develop.svn.wordpress.org/trunk@65534
git-svn-id: http://core.svn.wordpress.org/trunk@64607 1a063a9b-81f0-0310-95a4-ce76da25c4cd
diff --git a/wp-includes/category.php b/wp-includes/category.php
index e93c6c122e..79f05c6cfc 100644
--- a/wp-includes/category.php
+++ b/wp-includes/category.php
@@ -25,7 +25,7 @@
*
* @phpstan-return (
* $args is array{ fields: 'count', ... }
- * ? list<0|numeric-string>
+ * ? list<0|decimal-int-string>
* : (
* $args is array{ fields: 'names'|'slugs', ... }
* ? list<string>
diff --git a/wp-includes/class-wp-comment.php b/wp-includes/class-wp-comment.php
index c2ebe94ec8..7ba2ff46dc 100644
--- a/wp-includes/class-wp-comment.php
+++ b/wp-includes/class-wp-comment.php
@@ -16,31 +16,31 @@
*
* @since 4.4.0
*
- * @property-read numeric-string|''|null $post_author
- * @property-read string|null $post_date
- * @property-read string|null $post_date_gmt
- * @property-read string|null $post_content
- * @property-read string|null $post_title
- * @property-read string|null $post_excerpt
- * @property-read non-empty-string|null $post_status
- * @property-read non-empty-string|null $comment_status
- * @property-read non-empty-string|null $ping_status
- * @property-read string|null $post_name
- * @property-read string|null $to_ping
- * @property-read string|null $pinged
- * @property-read string|null $post_modified
- * @property-read string|null $post_modified_gmt
- * @property-read string|null $post_content_filtered
- * @property-read non-negative-int|null $post_parent
- * @property-read string|null $guid
- * @property-read int|null $menu_order
- * @property-read non-empty-string|null $post_type
- * @property-read string|null $post_mime_type
- * @property-read numeric-string|null $comment_count
+ * @property-read decimal-int-string|''|null $post_author
+ * @property-read string|null $post_date
+ * @property-read string|null $post_date_gmt
+ * @property-read string|null $post_content
+ * @property-read string|null $post_title
+ * @property-read string|null $post_excerpt
+ * @property-read non-empty-string|null $post_status
+ * @property-read non-empty-string|null $comment_status
+ * @property-read non-empty-string|null $ping_status
+ * @property-read string|null $post_name
+ * @property-read string|null $to_ping
+ * @property-read string|null $pinged
+ * @property-read string|null $post_modified
+ * @property-read string|null $post_modified_gmt
+ * @property-read string|null $post_content_filtered
+ * @property-read non-negative-int|null $post_parent
+ * @property-read string|null $guid
+ * @property-read int|null $menu_order
+ * @property-read non-empty-string|null $post_type
+ * @property-read string|null $post_mime_type
+ * @property-read decimal-int-string|null $comment_count
*
* @phpstan-type Data_Array array{
- * comment_ID: numeric-string,
- * comment_post_ID: numeric-string,
+ * comment_ID: decimal-int-string,
+ * comment_post_ID: decimal-int-string,
* comment_author: string,
* comment_author_email: string,
* comment_author_url: string,
@@ -48,12 +48,12 @@
* comment_date: non-empty-string,
* comment_date_gmt: non-empty-string,
* comment_content: string,
- * comment_karma: numeric-string,
+ * comment_karma: decimal-int-string,
* comment_approved: non-empty-string,
* comment_agent: string,
* comment_type: string,
- * comment_parent: numeric-string,
- * user_id: numeric-string,
+ * comment_parent: decimal-int-string,
+ * user_id: decimal-int-string,
* ...
* }
*/
@@ -68,7 +68,7 @@ final class WP_Comment {
*
* @since 4.4.0
* @var string|int
- * @phpstan-var numeric-string|int
+ * @phpstan-var decimal-int-string|int
*/
public $comment_ID;
@@ -80,7 +80,7 @@ final class WP_Comment {
*
* @since 4.4.0
* @var string|int
- * @phpstan-var numeric-string|int
+ * @phpstan-var decimal-int-string|int
*/
public $comment_post_ID = '0';
@@ -149,7 +149,7 @@ final class WP_Comment {
*
* @since 4.4.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $comment_karma = '0';
@@ -196,7 +196,7 @@ final class WP_Comment {
*
* @since 4.4.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $comment_parent = '0';
@@ -207,7 +207,7 @@ final class WP_Comment {
*
* @since 4.4.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $user_id = '0';
@@ -253,7 +253,7 @@ final class WP_Comment {
* @global wpdb $wpdb WordPress database abstraction object.
*
* @param int $id Comment ID.
- * @phpstan-param int|numeric-string $id
+ * @phpstan-param int|decimal-int-string $id
* @return WP_Comment|false Comment object, otherwise false.
*/
public static function get_instance( $id ) {
diff --git a/wp-includes/class-wp-network.php b/wp-includes/class-wp-network.php
index b9f6b01f29..da1df2d374 100644
--- a/wp-includes/class-wp-network.php
+++ b/wp-includes/class-wp-network.php
@@ -22,7 +22,7 @@
* @property string $blog_id
* @property int $site_id
*
- * @phpstan-property numeric-string $blog_id
+ * @phpstan-property decimal-int-string $blog_id
*/
#[AllowDynamicProperties]
class WP_Network {
@@ -64,7 +64,7 @@ class WP_Network {
*
* @since 4.4.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
private $blog_id = '0';
diff --git a/wp-includes/class-wp-post.php b/wp-includes/class-wp-post.php
index 4008c6bc12..002d83a424 100644
--- a/wp-includes/class-wp-post.php
+++ b/wp-includes/class-wp-post.php
@@ -20,7 +20,7 @@
*
* @phpstan-type Data_Array array{
* ID: non-negative-int,
- * post_author: numeric-string|'',
+ * post_author: decimal-int-string|'',
* post_date: string,
* post_date_gmt: string,
* post_content: string,
@@ -41,7 +41,7 @@
* menu_order: int,
* post_type: non-empty-string,
* post_mime_type: string,
- * comment_count: numeric-string,
+ * comment_count: decimal-int-string,
* filter: 'raw'|'edit'|'db'|'display'|'attribute'|'js'|'sample'|null,
* ancestors: list<non-negative-int>,
* page_template: string,
@@ -70,7 +70,7 @@ final class WP_Post {
*
* @since 3.5.0
* @var string
- * @phpstan-var numeric-string|''
+ * @phpstan-var decimal-int-string|''
*/
public $post_author = '0';
@@ -246,7 +246,7 @@ final class WP_Post {
*
* @since 3.5.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $comment_count = '0';
@@ -274,7 +274,7 @@ final class WP_Post {
* @param int $post_id Post ID.
* @return WP_Post|false Post object, false otherwise.
*
- * @phpstan-param int|numeric-string $post_id
+ * @phpstan-param int|decimal-int-string $post_id
*/
public static function get_instance( $post_id ) {
global $wpdb;
diff --git a/wp-includes/class-wp-site.php b/wp-includes/class-wp-site.php
index bb6c2d50a3..450d71a8c2 100644
--- a/wp-includes/class-wp-site.php
+++ b/wp-includes/class-wp-site.php
@@ -22,7 +22,7 @@
* @property int|string|false $post_count
* @property string $home
*
- * @phpstan-property int|numeric-string|false $post_count
+ * @phpstan-property int|decimal-int-string|false $post_count
*/
#[AllowDynamicProperties]
final class WP_Site {
@@ -36,7 +36,7 @@ final class WP_Site {
*
* @since 4.5.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $blog_id;
@@ -66,7 +66,7 @@ final class WP_Site {
*
* @since 4.5.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $site_id = '0';
@@ -93,7 +93,7 @@ final class WP_Site {
*
* @since 4.5.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $public = '1';
@@ -104,7 +104,7 @@ final class WP_Site {
*
* @since 4.5.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $archived = '0';
@@ -118,7 +118,7 @@ final class WP_Site {
*
* @since 4.5.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $mature = '0';
@@ -129,7 +129,7 @@ final class WP_Site {
*
* @since 4.5.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $spam = '0';
@@ -140,7 +140,7 @@ final class WP_Site {
*
* @since 4.5.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $deleted = '0';
@@ -151,7 +151,7 @@ final class WP_Site {
*
* @since 4.5.0
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $lang_id = '0';
diff --git a/wp-includes/class-wp-term-query.php b/wp-includes/class-wp-term-query.php
index 0f4e85ae80..179a8decd7 100644
--- a/wp-includes/class-wp-term-query.php
+++ b/wp-includes/class-wp-term-query.php
@@ -307,7 +307,7 @@ class WP_Term_Query {
*
* @phpstan-return (
* $query is array{ fields: 'count', ... }
- * ? 0|numeric-string
+ * ? 0|decimal-int-string
* : ( $query is array{ fields: 'ids'|'tt_ids', ... }
* ? int[]
* : ( $query is array{ fields: 'id=>parent', ... }
@@ -361,7 +361,7 @@ class WP_Term_Query {
* integer 0 when the queried parent term is not in the
* taxonomy hierarchy.
*
- * @phpstan-return 0|numeric-string|int[]|array<int, int>|string[]|array<int, string>|WP_Term[]
+ * @phpstan-return 0|decimal-int-string|int[]|array<int, int>|string[]|array<int, string>|WP_Term[]
*/
public function get_terms() {
global $wpdb;
@@ -821,7 +821,7 @@ class WP_Term_Query {
if ( 'count' === $_fields ) {
// The request selects a single COUNT column, so it only returns null on a database error.
- /** @var numeric-string $count */
+ /** @var decimal-int-string $count */
$count = $wpdb->get_var( $this->request ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
if ( $args['cache_results'] ) {
wp_cache_set_salted( $cache_key, $count, 'term-queries', $last_changed );
diff --git a/wp-includes/class-wp-user-request.php b/wp-includes/class-wp-user-request.php
index 9bf80752d8..96fcb89cef 100644
--- a/wp-includes/class-wp-user-request.php
+++ b/wp-includes/class-wp-user-request.php
@@ -21,7 +21,7 @@ final class WP_User_Request {
*
* @since 4.9.6
* @var string
- * @phpstan-var numeric-string
+ * @phpstan-var decimal-int-string
*/
public $user_id = '0';
diff --git a/wp-includes/class-wp-user.php b/wp-includes/class-wp-user.php
index b50a6790a2..dd0ce64cbb 100644
--- a/wp-includes/class-wp-user.php
+++ b/wp-includes/class-wp-user.php
@@ -40,8 +40,8 @@
* @property string $syntax_highlighting
* @property string $use_ssl
*
- * @phpstan-property numeric-string $user_status
- * @phpstan-property int|numeric-string|'' $user_level
+ * @phpstan-property decimal-int-string $user_status
+ * @phpstan-property int|decimal-int-string|'' $user_level
*/
#[AllowDynamicProperties]
class WP_User {
diff --git a/wp-includes/comment.php b/wp-includes/comment.php
index cd622cbf0f..6a1641cbae 100644
--- a/wp-includes/comment.php
+++ b/wp-includes/comment.php
@@ -584,7 +584,7 @@ function delete_comment_meta( $comment_id, $meta_key, $meta_value = '' ) {
* the type it was registered with, which may be an integer, float, or
* boolean.
*
- * @phpstan-param int|numeric-string $comment_id
+ * @phpstan-param int|decimal-int-string $comment_id
* @phpstan-return (
* $key is ''|'0'
* ? array<array-key, list<string>>|false
diff --git a/wp-includes/meta.php b/wp-includes/meta.php
index 437737804f..64e0750176 100644
--- a/wp-includes/meta.php
+++ b/wp-includes/meta.php
@@ -608,7 +608,7 @@ function delete_metadata( $meta_type, $object_id, $meta_key, $meta_value = '', $
* the type it was registered with, which may be an integer, float, or
* boolean.
*
- * @phpstan-param int|numeric-string $object_id
+ * @phpstan-param int|decimal-int-string $object_id
* @phpstan-return (
* $meta_key is ''|'0'
* ? ( $single is true
@@ -653,7 +653,7 @@ function get_metadata( $meta_type, $object_id, $meta_key = '', $single = false )
* When `$meta_key` is not specified, the values are returned exactly as
* they are held in the object cache, which means they are still serialized.
*
- * @phpstan-param int|numeric-string $object_id
+ * @phpstan-param int|decimal-int-string $object_id
* @phpstan-return (
* $meta_key is ''|'0'
* ? array<array-key, list<string>>|false|null
@@ -747,7 +747,7 @@ function get_metadata_raw( $meta_type, $object_id, $meta_key = '', $single = fal
* @return mixed An array of default values if `$single` is false.
* The default value of the meta field if `$single` is true.
*
- * @phpstan-param int|numeric-string $object_id
+ * @phpstan-param int|decimal-int-string $object_id
* @phpstan-return ( $single is true ? mixed : list<mixed> )
*/
function get_metadata_default( $meta_type, $object_id, $meta_key, $single = false ) {
@@ -857,7 +857,7 @@ function metadata_exists( $meta_type, $object_id, $meta_key ) {
* @type string $user_id Optional. The object ID when the meta type is 'user'.
* }
*
- * @phpstan-param int|numeric-string $meta_id
+ * @phpstan-param int|decimal-int-string $meta_id
*/
function get_metadata_by_mid( $meta_type, $meta_id ) {
global $wpdb;
@@ -930,7 +930,7 @@ function get_metadata_by_mid( $meta_type, $meta_id ) {
* @param string|false $meta_key Optional. You can provide a meta key to update it. Default false.
* @return bool True on successful update, false on failure.
*
- * @phpstan-param int|numeric-string $meta_id
+ * @phpstan-param int|decimal-int-string $meta_id
*/
function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key = false ) {
global $wpdb;
@@ -1057,7 +1057,7 @@ function update_metadata_by_mid( $meta_type, $meta_id, $meta_value, $meta_key =
* @param int|string $meta_id ID for a specific meta row.
* @return bool True on successful delete, false on failure.
*
- * @phpstan-param int|numeric-string $meta_id
+ * @phpstan-param int|decimal-int-string $meta_id
*/
function delete_metadata_by_mid( $meta_type, $meta_id ) {
global $wpdb;
diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
index 9f6559e648..4aa7f83ce8 100644
--- a/wp-includes/post-template.php
+++ b/wp-includes/post-template.php
@@ -1352,7 +1352,7 @@ function wp_list_pages( $args = '' ) {
* @since 2.1.0
*
* @param string[] $exclude_array An array of page IDs to exclude.
- * @phpstan-param list<numeric-string> $exclude_array
+ * @phpstan-param list<decimal-int-string> $exclude_array
*/
$parsed_args['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) );
diff --git a/wp-includes/post.php b/wp-includes/post.php
index e0afc05cd1..3511fbfc81 100644
--- a/wp-includes/post.php
+++ b/wp-includes/post.php
@@ -1132,7 +1132,7 @@ function get_extended( $post ) {
* @return WP_Post|array|null Type corresponding to $output on success or null on failure.
* When $output is OBJECT, a `WP_Post` instance is returned.
*
- * @phpstan-param int|numeric-string|WP_Post|null $post
+ * @phpstan-param int|decimal-int-string|WP_Post|null $post
* @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output
* @phpstan-param 'raw'|'edit'|'db'|'display' $filter
* @phpstan-return (
@@ -4599,7 +4599,7 @@ function wp_untrash_post_comments( $post = null ) {
*
* @phpstan-return (
* $args is array{ fields: 'count', ... }
- * ? numeric-string|WP_Error
+ * ? decimal-int-string|WP_Error
* : ( $args is array{ fields: 'id=>parent', ... }
* ? array<int, int>|WP_Error
* : ( $args is array{ fields: 'names'|'slugs', ... }
@@ -4641,7 +4641,7 @@ function wp_get_post_categories( $post_id = 0, $args = array() ) {
*
* @phpstan-return (
* $args is array{ fields: 'count', ... }
- * ? numeric-string|WP_Error
+ * ? decimal-int-string|WP_Error
* : ( $args is array{ fields: 'ids'|'tt_ids', ... }
* ? int[]|WP_Error
* : ( $args is array{ fields: 'id=>parent', ... }
@@ -4678,7 +4678,7 @@ function wp_get_post_tags( $post_id = 0, $args = array() ) {
*
* @phpstan-return (
* $args is array{ fields: 'count', ... }
- * ? numeric-string|WP_Error
+ * ? decimal-int-string|WP_Error
* : ( $args is array{ fields: 'ids'|'tt_ids', ... }
* ? int[]|WP_Error
* : ( $args is array{ fields: 'id=>parent', ... }
@@ -6455,7 +6455,7 @@ function get_all_page_ids() {
* 'edit', 'db', 'display'. Default 'raw'.
* @return WP_Post|array|null WP_Post or array on success, null on failure.
*
- * @phpstan-param int|numeric-string|WP_Post|null $page
+ * @phpstan-param int|decimal-int-string|WP_Post|null $page
* @phpstan-param 'OBJECT'|'ARRAY_A'|'ARRAY_N' $output
* @phpstan-param 'raw'|'edit'|'db'|'display' $filter
* @phpstan-return (
diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php
index 2bf9f30dfb..8a64e726d2 100644
--- a/wp-includes/taxonomy.php
+++ b/wp-includes/taxonomy.php
@@ -1348,7 +1348,7 @@ function get_term_to_edit( $id, $taxonomy ) {
*
* @phpstan-return (
* $args is array{ fields: 'count', ... }
- * ? 0|numeric-string|WP_Error
+ * ? 0|decimal-int-string|WP_Error
* : ( $args is array{ fields: 'ids'|'tt_ids', ... }
* ? int[]|WP_Error
* : ( $args is array{ fields: 'id=>parent', ... }
@@ -1657,10 +1657,10 @@ function unregister_term_meta( $taxonomy, $meta_key ) {
* @phpstan-return (
* $term is null ? null : (
* $term is 0 ? 0 : (
- * $taxonomy is '' ? numeric-string|null : (
+ * $taxonomy is '' ? decimal-int-string|null : (
* array{
- * term_id: numeric-string,
- * term_taxonomy_id: numeric-string,
+ * term_id: decimal-int-string,
+ * term_taxonomy_id: decimal-int-string,
* }|null
* )
* )
@@ -2039,7 +2039,7 @@ function sanitize_term_field( $field, $value, $term_id, $taxonomy, $context ) {
* @return string|int|WP_Error Numeric string containing the number of terms in that taxonomy,
* the integer 0 when the queried parent term is not in the taxonomy
* hierarchy, or WP_Error if the taxonomy does not exist.
- * @phpstan-return numeric-string|0|WP_Error
+ * @phpstan-return decimal-int-string|0|WP_Error
*/
function wp_count_terms( $args = array(), $deprecated = '' ) {
$use_legacy_args = false;
@@ -2379,7 +2379,7 @@ function wp_delete_category( $cat_id ) {
*
* @phpstan-return (
* $args is array{ fields: 'count', ... }
- * ? numeric-string|WP_Error
+ * ? decimal-int-string|WP_Error
* : ( $args is array{ fields: 'ids'|'tt_ids', ... }
* ? int[]|WP_Error
* : ( $args is array{ fields: 'id=>parent', ... }
@@ -2581,7 +2581,7 @@ function wp_get_object_terms( $object_ids, $taxonomies, $args = array() ) {
* } $args
* @phpstan-return array{
* term_id: int,
- * term_taxonomy_id: int|numeric-string,
+ * term_taxonomy_id: int|decimal-int-string,
* }|WP_Error
*/
function wp_insert_term( $term, $taxonomy, $args = array() ) {
@@ -2768,7 +2768,7 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
do_action( 'edited_terms', $term_id, $taxonomy, $args );
}
- /** @var numeric-string|null $tt_id */
+ /** @var decimal-int-string|null $tt_id */
$tt_id = $wpdb->get_var( $wpdb->prepare( "SELECT tt.term_taxonomy_id FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.term_id = %d", $taxonomy, $term_id ) );
if ( ! empty( $tt_id ) ) {
diff --git a/wp-includes/user.php b/wp-includes/user.php
index 518278feb9..8c43123ded 100644
--- a/wp-includes/user.php
+++ b/wp-includes/user.php
@@ -876,7 +876,7 @@ function get_user( $user_id ) {
*
* @phpstan-return (
* $args is array{ fields: 'all'|'all_with_meta', ... } ? array<int, WP_User> : (
- * $args is array{ fields: 'ID'|'id', ... } ? list<numeric-string> : (
+ * $args is array{ fields: 'ID'|'id', ... } ? list<decimal-int-string> : (
* $args is array{ fields: non-empty-string|non-empty-array<array-key, string>, ... } ? array<int, mixed> : array<int, WP_User>
* )
* )
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 255d18385c..34dc85317f 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
-$wp_version = '7.2-beta5-65533';
+$wp_version = '7.2-beta5-65534';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.