From 021eb0a1284cdd1afcd777ac40d641f95de173e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20W=C3=BCnsch?= Date: Wed, 12 Aug 2026 15:15:47 +0200 Subject: [PATCH] Code Modernization: Use `is_iterable()` instead of manual array or `Traversable` checks. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `is_iterable()` returns true for arrays and `Traversable` instances and nothing else, so it is an exact replacement for the compound `is_array() || … instanceof Traversable` condition. It has been available since PHP 7.1, well below the current minimum requirement of PHP 7.4. Sites where a `Traversable` check is a distinct branch with its own handling, such as the `iterator_to_array()` branch in `wp_insert_user()`, are intentionally left unchanged. --- .../ai-client/adapters/class-wp-ai-client-http-client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/ai-client/adapters/class-wp-ai-client-http-client.php b/src/wp-includes/ai-client/adapters/class-wp-ai-client-http-client.php index 1c1db9a26c707..d8f1e25e8fa47 100644 --- a/src/wp-includes/ai-client/adapters/class-wp-ai-client-http-client.php +++ b/src/wp-includes/ai-client/adapters/class-wp-ai-client-http-client.php @@ -211,7 +211,7 @@ private function create_psr_response( array $wp_response ): ResponseInterface { $headers = $headers->get_headers(); } - if ( is_array( $headers ) || $headers instanceof Traversable ) { + if ( is_iterable( $headers ) ) { foreach ( $headers as $name => $value ) { $response = $response->withHeader( $name, $value ); }