mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
"Countable" interface is moved from SPL to Core
This commit is contained in:
parent
44ec732752
commit
27e7aea412
10 changed files with 26 additions and 14 deletions
1
NEWS
1
NEWS
|
@ -3,6 +3,7 @@ PHP NEWS
|
|||
?? ??? ????, PHP 7.2
|
||||
|
||||
- Core:
|
||||
. "Countable" interface is moved from SPL to Core. (Dmitry)
|
||||
. Added ZEND_IN_ARRAY instruction, implementing optimized in_array() builtin
|
||||
function, through hash lookup in flipped array. (Dmitry)
|
||||
. Removed IS_TYPE_IMMUTABLE (it's the same as COPYABLE & !REFCOUNTED). (Dmitry)
|
||||
|
|
|
@ -28,6 +28,7 @@ ZEND_API zend_class_entry *zend_ce_aggregate;
|
|||
ZEND_API zend_class_entry *zend_ce_iterator;
|
||||
ZEND_API zend_class_entry *zend_ce_arrayaccess;
|
||||
ZEND_API zend_class_entry *zend_ce_serializable;
|
||||
ZEND_API zend_class_entry *zend_ce_countable;
|
||||
|
||||
/* {{{ zend_call_method
|
||||
Only returns the returned zval if retval_ptr != NULL */
|
||||
|
@ -470,6 +471,13 @@ static int zend_implement_serializable(zend_class_entry *interface, zend_class_e
|
|||
}
|
||||
/* }}}*/
|
||||
|
||||
/* {{{ zend_implement_countable */
|
||||
static int zend_implement_countable(zend_class_entry *interface, zend_class_entry *class_type)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}}*/
|
||||
|
||||
/* {{{ function tables */
|
||||
const zend_function_entry zend_funcs_aggregate[] = {
|
||||
ZEND_ABSTRACT_ME(iterator, getIterator, NULL)
|
||||
|
@ -517,6 +525,14 @@ const zend_function_entry zend_funcs_serializable[] = {
|
|||
ZEND_FENTRY(unserialize, NULL, arginfo_serializable_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT|ZEND_ACC_CTOR)
|
||||
ZEND_FE_END
|
||||
};
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_countable_count, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
const zend_function_entry zend_funcs_countable[] = {
|
||||
ZEND_ABSTRACT_ME(Countable, count, arginfo_countable_count)
|
||||
ZEND_FE_END
|
||||
};
|
||||
/* }}} */
|
||||
|
||||
/* {{{ zend_register_interfaces */
|
||||
|
@ -533,6 +549,8 @@ ZEND_API void zend_register_interfaces(void)
|
|||
REGISTER_MAGIC_INTERFACE(arrayaccess, ArrayAccess);
|
||||
|
||||
REGISTER_MAGIC_INTERFACE(serializable, Serializable);
|
||||
|
||||
REGISTER_MAGIC_INTERFACE(countable, Countable);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ extern ZEND_API zend_class_entry *zend_ce_aggregate;
|
|||
extern ZEND_API zend_class_entry *zend_ce_iterator;
|
||||
extern ZEND_API zend_class_entry *zend_ce_arrayaccess;
|
||||
extern ZEND_API zend_class_entry *zend_ce_serializable;
|
||||
extern ZEND_API zend_class_entry *zend_ce_countable;
|
||||
|
||||
typedef struct _zend_user_iterator {
|
||||
zend_object_iterator it;
|
||||
|
|
|
@ -5403,12 +5403,12 @@ void phar_object_init(void) /* {{{ */
|
|||
INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
|
||||
phar_ce_archive = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator);
|
||||
|
||||
zend_class_implements(phar_ce_archive, 2, spl_ce_Countable, zend_ce_arrayaccess);
|
||||
zend_class_implements(phar_ce_archive, 2, zend_ce_countable, zend_ce_arrayaccess);
|
||||
|
||||
INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
|
||||
phar_ce_data = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator);
|
||||
|
||||
zend_class_implements(phar_ce_data, 2, spl_ce_Countable, zend_ce_arrayaccess);
|
||||
zend_class_implements(phar_ce_data, 2, zend_ce_countable, zend_ce_arrayaccess);
|
||||
|
||||
INIT_CLASS_ENTRY(ce, "PharFileInfo", php_entry_methods);
|
||||
phar_ce_entry = zend_register_internal_class_ex(&ce, spl_ce_SplFileInfo);
|
||||
|
|
|
@ -211,7 +211,7 @@ PHP_MINIT_FUNCTION(sxe) /* {{{ */
|
|||
ce_SimpleXMLIterator->create_object = ce_SimpleXMLElement->create_object;
|
||||
|
||||
zend_class_implements(ce_SimpleXMLIterator, 1, spl_ce_RecursiveIterator);
|
||||
zend_class_implements(ce_SimpleXMLIterator, 1, spl_ce_Countable);
|
||||
zend_class_implements(ce_SimpleXMLIterator, 1, zend_ce_countable);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
|
|
@ -184,7 +184,6 @@ PHP_FUNCTION(class_uses)
|
|||
SPL_ADD_CLASS(BadMethodCallException, z_list, sub, allow, ce_flags); \
|
||||
SPL_ADD_CLASS(CachingIterator, z_list, sub, allow, ce_flags); \
|
||||
SPL_ADD_CLASS(CallbackFilterIterator, z_list, sub, allow, ce_flags); \
|
||||
SPL_ADD_CLASS(Countable, z_list, sub, allow, ce_flags); \
|
||||
SPL_ADD_CLASS(DirectoryIterator, z_list, sub, allow, ce_flags); \
|
||||
SPL_ADD_CLASS(DomainException, z_list, sub, allow, ce_flags); \
|
||||
SPL_ADD_CLASS(EmptyIterator, z_list, sub, allow, ce_flags); \
|
||||
|
|
|
@ -566,7 +566,7 @@ interface Iterator extends Traversable
|
|||
function valid();
|
||||
}
|
||||
|
||||
/** @ingroup SPL
|
||||
/** @ingroup ZendEngine
|
||||
* @brief This Interface allows to hook into the global count() function.
|
||||
* @since PHP 5.1
|
||||
*/
|
||||
|
|
|
@ -60,7 +60,6 @@ PHPAPI zend_class_entry *spl_ce_EmptyIterator;
|
|||
PHPAPI zend_class_entry *spl_ce_AppendIterator;
|
||||
PHPAPI zend_class_entry *spl_ce_RegexIterator;
|
||||
PHPAPI zend_class_entry *spl_ce_RecursiveRegexIterator;
|
||||
PHPAPI zend_class_entry *spl_ce_Countable;
|
||||
PHPAPI zend_class_entry *spl_ce_RecursiveTreeIterator;
|
||||
|
||||
ZEND_BEGIN_ARG_INFO(arginfo_recursive_it_void, 0)
|
||||
|
@ -3670,11 +3669,6 @@ static const zend_function_entry spl_funcs_OuterIterator[] = {
|
|||
PHP_FE_END
|
||||
};
|
||||
|
||||
static const zend_function_entry spl_funcs_Countable[] = {
|
||||
SPL_ABSTRACT_ME(Countable, count, arginfo_recursive_it_void)
|
||||
PHP_FE_END
|
||||
};
|
||||
|
||||
/* {{{ PHP_MINIT_FUNCTION(spl_iterators)
|
||||
*/
|
||||
PHP_MINIT_FUNCTION(spl_iterators)
|
||||
|
@ -3729,7 +3723,6 @@ PHP_MINIT_FUNCTION(spl_iterators)
|
|||
|
||||
REGISTER_SPL_SUB_CLASS_EX(ParentIterator, RecursiveFilterIterator, spl_dual_it_new, spl_funcs_ParentIterator);
|
||||
|
||||
REGISTER_SPL_INTERFACE(Countable);
|
||||
REGISTER_SPL_INTERFACE(SeekableIterator);
|
||||
REGISTER_SPL_ITERATOR(SeekableIterator);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#define spl_ce_Aggregate zend_ce_aggregate
|
||||
#define spl_ce_ArrayAccess zend_ce_arrayaccess
|
||||
#define spl_ce_Serializable zend_ce_serializable
|
||||
#define spl_ce_Countable zend_ce_countable
|
||||
|
||||
extern PHPAPI zend_class_entry *spl_ce_RecursiveIterator;
|
||||
extern PHPAPI zend_class_entry *spl_ce_RecursiveIteratorIterator;
|
||||
|
@ -51,7 +52,6 @@ extern PHPAPI zend_class_entry *spl_ce_EmptyIterator;
|
|||
extern PHPAPI zend_class_entry *spl_ce_AppendIterator;
|
||||
extern PHPAPI zend_class_entry *spl_ce_RegexIterator;
|
||||
extern PHPAPI zend_class_entry *spl_ce_RecursiveRegexIterator;
|
||||
extern PHPAPI zend_class_entry *spl_ce_Countable;
|
||||
extern PHPAPI zend_class_entry *spl_ce_CallbackFilterIterator;
|
||||
extern PHPAPI zend_class_entry *spl_ce_RecursiveCallbackFilterIterator;
|
||||
|
||||
|
|
|
@ -813,7 +813,7 @@ PHP_FUNCTION(count)
|
|||
}
|
||||
}
|
||||
/* if not and the object implements Countable we call its count() method */
|
||||
if (instanceof_function(Z_OBJCE_P(array), spl_ce_Countable)) {
|
||||
if (instanceof_function(Z_OBJCE_P(array), zend_ce_countable)) {
|
||||
zend_call_method_with_0_params(array, NULL, NULL, "count", &retval);
|
||||
if (Z_TYPE(retval) != IS_UNDEF) {
|
||||
RETVAL_LONG(zval_get_long(&retval));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue