Commit 8a08a94098 for wordpress.org

commit 8a08a94098f9b0e58bcfeb2eb9724c81060c7ca9
Author: westonruter <westonruter@git.wordpress.org>
Date:   Wed Sep 23 18:00:49 2026 +0000

    Code Quality: Remove unnecessary null coalescing.

    In `get_current_user_id()` the `?? 0` fallback is removed since `wp_get_current_user()` returns a `WP_User`, but the `(int)` cast is retained since the function is pluggable and the `ID` property may be set to a non-integer value. The deprecated `id` property is now also cast to an integer in `WP_User::__set()`, as is done in `WP_User::init()`.

    In `WP_Http_Cookie::test()` the fallback for the `path` property is removed since the constructor always initializes it to a string, and the fallback for the `port` property is removed since it was a no-op. The `port` property and the corresponding constructor `$data` args are now documented as nullable.

    The `$authordata` global is now documented as `WP_User|false|null` since it is populated by `get_userdata()` and is unset outside the loop, which accounts for the null coalescing in `get_the_author_meta()`.

    The PHPStan baseline entries which no longer apply are removed.

    Developed in https://github.com/WordPress/wordpress-develop/pull/13674.
    Follow-up to r61435, r61454, r61637, r63023.

    Props arshidkv12, westonruter, mukesh27.
    See #65817.
    Fixes #66163.

    Built from https://develop.svn.wordpress.org/trunk@63899


    git-svn-id: http://core.svn.wordpress.org/trunk@63068 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php
index b27bbf6237..342132fead 100644
--- a/wp-includes/author-template.php
+++ b/wp-includes/author-template.php
@@ -16,7 +16,7 @@
  * @since 1.5.0
  * @since 6.3.0 Returns an empty string if the author's display name is unknown.
  *
- * @global WP_User $authordata The current author's data.
+ * @global WP_User|false|null $authordata The current author's data.
  *
  * @param string $deprecated Deprecated.
  * @return string The author's display name, empty string if unknown.
@@ -158,7 +158,7 @@ function the_modified_author() {
  * @since 2.8.0
  * @since 6.9.0 Removed `aim`, `jabber`, and `yim` as valid values for the `$field` parameter.
  *
- * @global WP_User $authordata The current author's data.
+ * @global WP_User|false|null $authordata The current author's data.
  *
  * @param string    $field   Optional. The user field to retrieve. Default empty.
  * @param int|false $user_id Optional. User ID. Defaults to the current post author.
@@ -231,7 +231,7 @@ function the_author_meta( $field = '', $user_id = false ) {
  * @since 3.0.0
  * @since 7.0.0 Added `$use_title_attr` parameter.
  *
- * @global WP_User $authordata The current author's data.
+ * @global WP_User|false|null $authordata The current author's data.
  *
  * @param bool $use_title_attr Optional. Whether to add a title attribute.
  *                             Default true.
@@ -321,7 +321,7 @@ function the_author_posts() {
  * @since 4.4.0
  * @since 7.0.0 Removed title attribute.
  *
- * @global WP_User $authordata The current author's data.
+ * @global WP_User|false|null $authordata The current author's data.
  *
  * @return string An HTML link to the author page, or an empty string if $authordata is not set.
  */
diff --git a/wp-includes/class-wp-http-cookie.php b/wp-includes/class-wp-http-cookie.php
index 6049681f11..4546f58a1a 100644
--- a/wp-includes/class-wp-http-cookie.php
+++ b/wp-includes/class-wp-http-cookie.php
@@ -71,7 +71,7 @@ class WP_Http_Cookie {
 	 *
 	 * @since 2.8.0
 	 *
-	 * @var int|string
+	 * @var int|string|null
 	 */
 	public $port;

@@ -99,9 +99,9 @@ class WP_Http_Cookie {
 	 *     @type string          $name      Cookie name.
 	 *     @type mixed           $value     Value. Should NOT already be urlencoded.
 	 *     @type string|int|null $expires   Optional. Unix timestamp or formatted date. Default null.
-	 *     @type string          $path      Optional. Path. Default '/'.
+	 *     @type string|null     $path      Optional. Path. Default '/'.
 	 *     @type string          $domain    Optional. Domain. Default host of parsed $requested_url.
-	 *     @type int|string      $port      Optional. Port or comma-separated list of ports. Default null.
+	 *     @type int|string|null $port      Optional. Port or comma-separated list of ports. Default null.
 	 *     @type bool            $host_only Optional. host-only storage flag. Default true.
 	 * }
 	 * @param string       $requested_url The URL which the cookie was set on, used for default $domain
@@ -194,8 +194,8 @@ class WP_Http_Cookie {
 		$url['path'] ??= '/';

 		// Values to use for comparison against the URL.
-		$path   = $this->path ?? '/';
-		$port   = $this->port ?? null;
+		$path   = $this->path;
+		$port   = $this->port;
 		$domain = isset( $this->domain ) ? strtolower( $this->domain ) : strtolower( $url['host'] );
 		if ( false === stripos( $domain, '.' ) ) {
 			$domain .= '.local';
diff --git a/wp-includes/class-wp-query.php b/wp-includes/class-wp-query.php
index 2835da604b..513f0f702c 100644
--- a/wp-includes/class-wp-query.php
+++ b/wp-includes/class-wp-query.php
@@ -4824,15 +4824,15 @@ class WP_Query {
 	 * @since 4.1.0
 	 * @since 4.4.0 Added the ability to pass a post ID to `$post`.
 	 *
-	 * @global int     $id
-	 * @global WP_User $authordata
-	 * @global string  $currentday
-	 * @global string  $currentmonth
-	 * @global int     $page
-	 * @global array   $pages
-	 * @global int     $multipage
-	 * @global int     $more
-	 * @global int     $numpages
+	 * @global int                $id
+	 * @global WP_User|false|null $authordata
+	 * @global string             $currentday
+	 * @global string             $currentmonth
+	 * @global int                $page
+	 * @global array              $pages
+	 * @global int                $multipage
+	 * @global int                $more
+	 * @global int                $numpages
 	 *
 	 * @param WP_Post|object|int $post WP_Post instance or Post ID/object.
 	 * @return bool True on success, false on failure.
diff --git a/wp-includes/class-wp-user.php b/wp-includes/class-wp-user.php
index 7a6cec0018..b50a6790a2 100644
--- a/wp-includes/class-wp-user.php
+++ b/wp-includes/class-wp-user.php
@@ -364,7 +364,7 @@ class WP_User {
 					'<code>WP_User->ID</code>'
 				)
 			);
-			$this->ID = $value;
+			$this->ID = (int) $value;
 			return;
 		}

diff --git a/wp-includes/class-wp.php b/wp-includes/class-wp.php
index ad6ce74b17..67201d1394 100644
--- a/wp-includes/class-wp.php
+++ b/wp-includes/class-wp.php
@@ -650,14 +650,14 @@ class WP {
 	 *
 	 * @since 2.0.0
 	 *
-	 * @global WP_Query     $wp_query     WordPress Query object.
-	 * @global string       $query_string Query string for the loop.
-	 * @global array        $posts        The found posts.
-	 * @global WP_Post|null $post         The current post, if available.
-	 * @global string       $request      The SQL statement for the request.
-	 * @global int          $more         Only set, if single page or post.
-	 * @global int          $single       If single page or post. Only set, if single page or post.
-	 * @global WP_User      $authordata   Only set, if author archive.
+	 * @global WP_Query           $wp_query     WordPress Query object.
+	 * @global string             $query_string Query string for the loop.
+	 * @global array              $posts        The found posts.
+	 * @global WP_Post|null       $post         The current post, if available.
+	 * @global string             $request      The SQL statement for the request.
+	 * @global int                $more         Only set, if single page or post.
+	 * @global int                $single       If single page or post. Only set, if single page or post.
+	 * @global WP_User|false|null $authordata   Only set, if author archive.
 	 */
 	public function register_globals() {
 		global $wp_query;
diff --git a/wp-includes/user.php b/wp-includes/user.php
index b4ab594038..8eab615269 100644
--- a/wp-includes/user.php
+++ b/wp-includes/user.php
@@ -728,7 +728,7 @@ function get_current_user_id() {
 		return 0;
 	}
 	$user = wp_get_current_user();
-	return (int) ( $user->ID ?? 0 );
+	return (int) $user->ID;
 }

 /**
diff --git a/wp-includes/version.php b/wp-includes/version.php
index d377572e56..f1250ce98d 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.2-alpha-63898';
+$wp_version = '7.2-alpha-63899';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.