Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions UPGRADING.INTERNALS
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ PHP 8.6 INTERNALS UPGRADE NOTES
flags parameter was never used.
. The PHP stream function _php_stream_flush() was removed,
instead the PHP macro php_stream_flush() is now a proper function.
. The zend_is_countable() function was removed.

- Changed:
. Internal functions that return by reference are now expected to
Expand Down
17 changes: 0 additions & 17 deletions Zend/zend_API.c
Original file line number Diff line number Diff line change
Expand Up @@ -5245,23 +5245,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;
Expand Down
2 changes: 0 additions & 2 deletions Zend/zend_API.h
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,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);
Expand Down
15 changes: 14 additions & 1 deletion ext/standard/type.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*/

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

/* {{{ Returns the type of the variable */
PHP_FUNCTION(gettype)
Expand Down Expand Up @@ -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;
}
}
/* }}} */
Loading