[php-src] master: Zend: remove zend_is_countable() (#23010)

Gina Peter Banyard via GitHub <[email protected]>
Newsgroups gmane.comp.php.cvs.general
Message-ID <[email protected]>
Author: Gina Peter Banyard (Girgias)
Committer: GitHub (web-flow)
Pusher: Girgias
Date: 2026-08-12T13:51:03+01:00

Commit: https://github.com/php/php-src/commit/f74acb62a39a70849b50621c11f49f8eabd87aa9
Raw diff: https://github.com/php/php-src/commit/f74acb62a39a70849b50621c11f49f8eabd87aa9.diff

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

Changed paths:
  M  UPGRADING.INTERNALS
  M  Zend/zend_API.c
  M  Zend/zend_API.h
  M  ext/standard/type.c


Diff:

diff --git a/UPGRADING.INTERNALS b/UPGRADING.INTERNALS
index 4be8421dd7b1..a83b4f882fe2 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 e47c489dcee7..7731f4094ed6 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 ad224884f360..b91d586eedc3 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 fc681a3c50a7..dc99dac93dac 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;
+	}
 }
 /* }}} */
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.