From: Thomas Gerbet Date: Wed, 29 May 2019 14:45:10 +0000 (+0200) Subject: SimpleXMLElement and ResourceBundle implement Countable X-Git-Tag: php-7.4.0alpha1~127 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bfc10978eff5793a68e7aeb6144b5a2a393833f3;p=php SimpleXMLElement and ResourceBundle implement Countable Both classes already have a count() method and are considered countable by \is_countable(). --- diff --git a/NEWS b/NEWS index 49b55ee375..9b0f6c3f59 100644 --- a/NEWS +++ b/NEWS @@ -74,6 +74,7 @@ PHP NEWS - Intl: . Raised requirements to ICU ≥ 50.1. (cmb) + . Changed ResourceBundle to implement Countable. (LeSuisse) . Changed default of $variant parameter of idn_to_ascii() and idn_to_utf8(). (cmb) @@ -121,6 +122,10 @@ PHP NEWS (krakjoe) . Fixed bug #77805 (phpdbg build fails when readline is shared). (krakjoe) +- SimpleXML: + . Implemented FR #65215 (SimpleXMLElement could register as implementing + Countable). (LeSuisse) + - Sockets: . Fixed bug #67619 (Validate length on socket_write). (thiagooak) diff --git a/UPGRADING b/UPGRADING index e9201f24d4..a2ef40c716 100644 --- a/UPGRADING +++ b/UPGRADING @@ -402,6 +402,7 @@ PHP 7.4 UPGRADE NOTES - Intl: . The Intl extension now requires at least ICU 50.1. + . ResourceBundle now implements Countable. - Libxml: . All libxml based extensions now require libxml 2.7.6 or newer. @@ -422,6 +423,9 @@ PHP 7.4 UPGRADE NOTES results of Reflection...::getModifiers(), using hard-coded numeric values. Use corresponding constants instead (e.g. ReflectionMethod::IS_PUBLIC). +- SimpleXML: + . SimpleXMLElement now implements Countable. + - SQLite3: . The bundled libsqlite has been removed. To build the SQLite3 extension a system libsqlite3 ≥ 3.7.4 is now required. To build the PDO_SQLite diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c index 2feb6edb13..0f63109eca 100644 --- a/ext/intl/resourcebundle/resourcebundle_class.c +++ b/ext/intl/resourcebundle/resourcebundle_class.c @@ -455,6 +455,6 @@ void resourcebundle_register_class( void ) ResourceBundle_object_handlers.read_dimension = resourcebundle_array_get; ResourceBundle_object_handlers.count_elements = resourcebundle_array_count; - zend_class_implements(ResourceBundle_ce_ptr, 1, zend_ce_traversable); + zend_class_implements(ResourceBundle_ce_ptr, 2, zend_ce_traversable, zend_ce_countable); } /* }}} */ diff --git a/ext/intl/tests/resourcebundle_countable.phpt b/ext/intl/tests/resourcebundle_countable.phpt new file mode 100644 index 0000000000..bacc18f10c --- /dev/null +++ b/ext/intl/tests/resourcebundle_countable.phpt @@ -0,0 +1,14 @@ +--TEST-- +Test ResourceBundle implements Countable +--SKIPIF-- + +--FILE-- + +--EXPECT-- +bool(true) diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index 8077fba77d..fb55b6b195 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -2686,7 +2686,7 @@ PHP_MINIT_FUNCTION(simplexml) sxe.create_object = sxe_object_new; sxe_class_entry = zend_register_internal_class(&sxe); sxe_class_entry->get_iterator = php_sxe_get_iterator; - zend_class_implements(sxe_class_entry, 1, zend_ce_traversable); + zend_class_implements(sxe_class_entry, 2, zend_ce_traversable, zend_ce_countable); memcpy(&sxe_object_handlers, &std_object_handlers, sizeof(zend_object_handlers)); sxe_object_handlers.offset = XtOffsetOf(php_sxe_object, zo); diff --git a/ext/simplexml/tests/037.phpt b/ext/simplexml/tests/037.phpt new file mode 100644 index 0000000000..7a141658c7 --- /dev/null +++ b/ext/simplexml/tests/037.phpt @@ -0,0 +1,15 @@ +--TEST-- +SimpleXML: implement Countable +--SKIPIF-- + +--FILE-- +'; +$sxe = new SimpleXmlElement($str); +var_dump($sxe instanceof Countable); +?> +==Done== +--EXPECT-- +bool(true) +==Done==