]> granicus.if.org Git - php/commitdiff
Fixed bug #55610: ResourceBundle and Traversable
authorGustavo André dos Santos Lopes <cataphract@php.net>
Thu, 24 May 2012 12:31:07 +0000 (14:31 +0200)
committerGustavo André dos Santos Lopes <cataphract@php.net>
Thu, 24 May 2012 12:33:05 +0000 (14:33 +0200)
NEWS
ext/intl/resourcebundle/resourcebundle_class.c
ext/intl/tests/resourcebundle_traversable.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 174b5e6dc43627139e29e76ba1b485b79d79d673..5fa6ecbcd1cb578ffd665ae877f39a984632c499 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ PHP                                                                        NEWS
   . Fixed bug #62017 (datefmt_create with incorrectly encoded timezone leaks
     pattern). (Gustavo)
   . Fixed bug #60785 (memory leak in IntlDateFormatter constructor). (Gustavo)
+  . Fixed bug #55610 (ResourceBundle should implement Traversable). (stealth35)
 
 - XML Writer:
   . Fixed bug #62064 (memory leak in the XML Writer module). 
index 3bf3468e37b37b1d3fb299912ac3399eddad98ea..d2a29d9b25c0ccf658b11c28b32570e2372e914e 100644 (file)
@@ -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 (file)
index 0000000..1e6af7b
--- /dev/null
@@ -0,0 +1,23 @@
+--TEST--
+Bug #55610: ResourceBundle does not implement Traversable
+--SKIPIF--
+<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
+--FILE--
+<?php
+       include "resourcebundle.inc";
+
+       $r = new ResourceBundle( 'es', 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"
+}