php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #55610
Patch fix55610 revision 2012-03-30 12:15 UTC by jinmoku at hotmail dot com

Patch fix55610 for I18N and L10N related Bug #55610

Patch version 2012-03-30 12:15 UTC

Return to Bug #55610 | Download this patch
Patch Revisions:

Developer: jinmoku@hotmail.com

diff --git a/NEWS b/NEWS
index 6fc9126..33f8e71 100644
--- a/NEWS
+++ b/NEWS
@@ -54,6 +54,8 @@ PHP                                                                        NEWS
 - Intl:
   . Fixed bug #61487 (Incorrent bounds checking in grapheme_strpos).
     (Stas)
+  . Fixed bug #55610 (ResourceBundle should implement Traverable).
+    (stealth35)
 
 - mbstring:
   . MFH mb_ereg_replace_callback() for security enhancements. (Rui)
diff --git a/ext/intl/resourcebundle/resourcebundle_class.c b/ext/intl/resourcebundle/resourcebundle_class.c
index 5471e5b..0b6cb8d 100644
--- a/ext/intl/resourcebundle/resourcebundle_class.c
+++ b/ext/intl/resourcebundle/resourcebundle_class.c
@@ -427,6 +427,8 @@ void resourcebundle_register_class( TSRMLS_D )
 	ResourceBundle_object_handlers.clone_obj	  = NULL; /* ICU ResourceBundle has no clone implementation */
 	ResourceBundle_object_handlers.read_dimension = resourcebundle_array_get;
 	ResourceBundle_object_handlers.count_elements = resourcebundle_array_count;
+
+	zend_class_implements(ResourceBundle_ce_ptr TSRMLS_CC, 1, zend_ce_traversable);
 }
 /* }}} */
 
diff --git a/ext/intl/tests/resourcebundle_traversable.phpt b/ext/intl/tests/resourcebundle_traversable.phpt
new file mode 100644
index 0000000..6295e3f
--- /dev/null
+++ b/ext/intl/tests/resourcebundle_traversable.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Test ResourceBundle iterator
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+	include "resourcebundle.inc";
+
+	$r = new ResourceBundle( 'en_US', BUNDLE );
+
+	var_dump($r instanceof Traversable);
+	var_dump(iterator_to_array($r->get('testarray')));
+?>
+--EXPECTF--
+bool(true)
+array(3) {
+  [0]=>
+  string(8) "cadena 1"
+  [1]=>
+  string(8) "cadena 2"
+  [2]=>
+  string(8) "cadena 3"
+}
\ No newline at end of file
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 06 14:01:33 2024 UTC