diff options
author | Thomas Gerbet <thomas.gerbet@enalean.com> | 2019-05-29 16:45:10 +0200 |
---|---|---|
committer | Christoph M. Becker <cmbecker69@gmx.de> | 2019-05-31 18:59:19 +0200 |
commit | bfc10978eff5793a68e7aeb6144b5a2a393833f3 (patch) | |
tree | 76ab0b304dea41a38b99985c5fe2c86a15f5481e | |
parent | 7f26171445e0b060196bb9b6f1fc506269ced8a4 (diff) | |
download | php-git-bfc10978eff5793a68e7aeb6144b5a2a393833f3.tar.gz |
SimpleXMLElement and ResourceBundle implement Countable
Both classes already have a count() method and are considered
countable by \is_countable().
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | UPGRADING | 4 | ||||
-rw-r--r-- | ext/intl/resourcebundle/resourcebundle_class.c | 2 | ||||
-rw-r--r-- | ext/intl/tests/resourcebundle_countable.phpt | 14 | ||||
-rw-r--r-- | ext/simplexml/simplexml.c | 2 | ||||
-rw-r--r-- | ext/simplexml/tests/037.phpt | 15 |
6 files changed, 40 insertions, 2 deletions
@@ -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) @@ -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-- +<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?> +--FILE-- +<?php + include "resourcebundle.inc"; + + $r = new ResourceBundle( 'es', BUNDLE ); + + var_dump($r instanceof Countable); +?> +--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-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +$str = '<xml></xml>'; +$sxe = new SimpleXmlElement($str); +var_dump($sxe instanceof Countable); +?> +==Done== +--EXPECT-- +bool(true) +==Done== |