From 3429087f6cca279b31f2c101e9ffc0dc693db779 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 23 Dec 2025 21:20:31 +0000 Subject: [PATCH] Code Modernization: Replace `isset()` with null coalescing in `WP_Roles::get_role()`. Since PHP 7.0 introduced the [https://www.php.net/manual/en/migration70.new-features.php#migration70.new-features.null-coalesce-op null coalescing operator], and WordPress now requires at least PHP 7.2.24, `isset( $var ) ? $var : null` ternary checks can be safely replaced with the more concise `$var ?? null` syntax. As some new code using the null coalescing operator has already been introduced into core in recent releases, this commit continues with the code modernization by implementing incremental changes for easier review. Follow-up to [2703], [61403]. Props dilipbheda, mukesh27, spacedmonkey, SergeyBiryukov. Fixes #63216. See #58874. Built from https://develop.svn.wordpress.org/trunk@61404 git-svn-id: http://core.svn.wordpress.org/trunk@60716 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-roles.php | 6 +----- wp-includes/version.php | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/wp-includes/class-wp-roles.php b/wp-includes/class-wp-roles.php index f620fb5a05..6f7a7fbc84 100644 --- a/wp-includes/class-wp-roles.php +++ b/wp-includes/class-wp-roles.php @@ -268,11 +268,7 @@ class WP_Roles { * @return WP_Role|null WP_Role object if found, null if the role does not exist. */ public function get_role( $role ) { - if ( isset( $this->role_objects[ $role ] ) ) { - return $this->role_objects[ $role ]; - } else { - return null; - } + return $this->role_objects[ $role ] ?? null; } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 0856da5843..af45aca00b 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '7.0-alpha-61403'; +$wp_version = '7.0-alpha-61404'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.