From 2e3cef15aada084dfc31bd333e6e3074be764d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20W=C3=BCnsch?= Date: Wed, 24 Jun 2026 13:04:26 +0200 Subject: [PATCH] Code Modernization: Use `array_any()` in `WP_REST_Comments_Controller`. This replaces a `foreach` loop in `check_post_type_supports_notes()` that iterates the editor supports, returns `true` as soon as an element has non-empty notes, and otherwise falls through to `false`. That is exactly what PHP 8.4's `array_any()` expresses in a single, more readable call. WordPress core includes a polyfill for `array_any()` on PHP < 8.4 as of WordPress 6.8, so the change works on every supported PHP version without raising the minimum requirement. Follow-up to [59783], [62550]. --- .../endpoints/class-wp-rest-comments-controller.php | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php index f462928847c77..ab6122ee512db 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php @@ -2055,11 +2055,6 @@ private function check_post_type_supports_notes( $post_type ) { if ( ! is_array( $supports['editor'] ) ) { return false; } - foreach ( $supports['editor'] as $item ) { - if ( ! empty( $item['notes'] ) ) { - return true; - } - } - return false; + return array_any( $supports['editor'], fn( $item ) => ! empty( $item['notes'] ) ); } }