[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-cvs
Subject:    [PHP-CVS] com php-src: SimpleXMLElement and ResourceBundle implement Countable: NEWS UPGRADING =?UTF
From:       Christoph Michael Becker <cmb () php ! net>
Date:       2019-05-31 16:59:19
Message-ID: php-mail-759f05405dece814fdd938ffa607e9031794757130 () git ! php ! net
[Download RAW message or body]

Commit:    bfc10978eff5793a68e7aeb6144b5a2a393833f3
Author:    Thomas Gerbet <thomas.gerbet@enalean.com>         Wed, 29 May 2019 \
                16:45:10 +0200
Committer: Christoph M. Becker <cmbecker69@gmx.de>      Fri, 31 May 2019 18:59:19 \
                +0200
Parents:   7f26171445e0b060196bb9b6f1fc506269ced8a4
Branches:  master

Link:       http://git.php.net/?p=php-src.git;a=commitdiff;h=bfc10978eff5793a68e7aeb6144b5a2a393833f3


Log:
SimpleXMLElement and ResourceBundle implement Countable

Both classes already have a count() method and are considered
countable by \is_countable().

Changed paths:
  M  NEWS
  M  UPGRADING
  M  ext/intl/resourcebundle/resourcebundle_class.c
  A  ext/intl/tests/resourcebundle_countable.phpt
  M  ext/simplexml/simplexml.c
  A  ext/simplexml/tests/037.phpt


Diff:
diff --git a/NEWS b/NEWS
index 49b55ee..9b0f6c3 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 e9201f2..a2ef40c 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 2feb6ed..0f63109 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 0000000..bacc18f
--- /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 8077fba..fb55b6b 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 0000000..7a14165
--- /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==


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic