Commit f74acb62a39 for php.net

commit f74acb62a39a70849b50621c11f49f8eabd87aa9
Author: Gina Peter Banyard <girgias@php.net>
Date:   Wed Aug 12 13:51:03 2026 +0100

    Zend: remove zend_is_countable() (#23010)

    This function is only used once internally, and no usage is reported from a SourceGraph search. [1]

    [1] https://sourcegraph.com/search?q=context:global+-f:zend_API.c+-f:zend_API.h+zend_is_countable&patternType=keyword&sm=0

diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS
index 4be8421dd7b..a83b4f882fe 100644
--- a/UPGRADING.INTERNALS
+++ b/UPGRADING.INTERNALS
@@ -136,6 +136,7 @@ PHP 8.6 INTERNALS UPGRADE NOTES
   . The zend_save_error_handling() function was removed.
   . The zend_parse_parameter() function has been removed, use one fo the
     zend_parse_arg_TYPE() APIs instead.
+  . The zend_is_countable() function was removed.

 - Changed:
   . Internal functions that return by reference are now expected to
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index e47c489dcee..7731f4094ed 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -5233,23 +5233,6 @@ ZEND_API bool zend_is_iterable(const zval *iterable) /* {{{ */
 }
 /* }}} */

-ZEND_API bool zend_is_countable(const zval *countable) /* {{{ */
-{
-	switch (Z_TYPE_P(countable)) {
-		case IS_ARRAY:
-			return 1;
-		case IS_OBJECT:
-			if (Z_OBJ_HT_P(countable)->count_elements) {
-				return 1;
-			}
-
-			return zend_class_implements_interface(Z_OBJCE_P(countable), zend_ce_countable);
-		default:
-			return 0;
-	}
-}
-/* }}} */
-
 static zend_result get_default_via_ast(zval *default_value_zval, const char *default_value) {
 	zend_ast *ast;
 	zend_arena *ast_arena;
diff --git a/Zend/zend_API.h b/Zend/zend_API.h
index ad224884f36..b91d586eedc 100644
--- a/Zend/zend_API.h
+++ b/Zend/zend_API.h
@@ -960,8 +960,6 @@ static zend_always_inline const char *zend_get_object_type_uc(const zend_class_e

 ZEND_API bool zend_is_iterable(const zval *iterable);

-ZEND_API bool zend_is_countable(const zval *countable);
-
 ZEND_API void zend_convert_internal_arg_info(zend_arg_info *new_arg_info,
 		const zend_internal_arg_info *arg_info, bool is_return_info,
 		bool permanent);
diff --git a/ext/standard/type.c b/ext/standard/type.c
index fc681a3c50a..dc99dac93da 100644
--- a/ext/standard/type.c
+++ b/ext/standard/type.c
@@ -13,6 +13,7 @@
 */

 #include "php.h"
+#include "zend_interfaces.h"

 /* {{{ Returns the type of the variable */
 PHP_FUNCTION(gettype)
@@ -458,6 +459,18 @@ PHP_FUNCTION(is_countable)
 		Z_PARAM_ZVAL(var)
 	ZEND_PARSE_PARAMETERS_END();

-	RETURN_BOOL(zend_is_countable(var));
+
+	switch (Z_TYPE_P(var)) {
+		case IS_ARRAY:
+			RETURN_TRUE;
+		case IS_OBJECT:
+			if (Z_OBJ_HT_P(var)->count_elements) {
+				RETURN_TRUE;
+			}
+
+			RETURN_BOOL(zend_class_implements_interface(Z_OBJCE_P(var), zend_ce_countable));
+		default:
+			RETURN_FALSE;
+	}
 }
 /* }}} */