php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #62262 RecursiveArrayIterator does not implement Countable
Submitted: 2012-06-08 09:05 UTC Modified: 2012-06-19 16:47 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: gen dot work at gmail dot com Assigned: nikic (profile)
Status: Closed Package: SPL related
PHP Version: 5.3.13 OS: Windows XP, Ubuntu 10.04
Private report: No CVE-ID: None
 [2012-06-08 09:05 UTC] gen dot work at gmail dot com
Description:
------------
The RecursiveArrayIterator class does not implement Countable interface, although it extends ArrayIterator.



Test script:
---------------
$it  = new \ArrayIterator(array(1, 2, 3));
$rit = new \RecursiveArrayIterator($it);

var_dump($it instanceof \Countable);
var_dump($rit instanceof \Countable);

Expected result:
----------------
bool(true)
bool(true)

Actual result:
--------------
bool(true)
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-06-08 23:34 UTC] nikic@php.net
-Status: Open +Status: Verified
 [2012-06-08 23:34 UTC] nikic@php.net
Reproduced on 5.4.1. The problem is probably that ArrayIterator implements Countable only *after* RecursiveArrayIterator already inherited from it (see http://lxr.php.net/xref/PHP_TRUNK/ext/spl/spl_array.c#1978). Fixing should be as simple as moving that macro a few lines up :)
 [2012-06-19 16:47 UTC] nikic@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.

 For Windows:

http://windows.php.net/snapshots/
 
Thank you for the report, and for helping us make PHP better.

Fixed in https://github.com/php/php-src/commit/fed1f2d12447227947bb8c6ba27eca45f244f498
 [2012-06-19 16:47 UTC] nikic@php.net
-Status: Verified +Status: Closed -Assigned To: +Assigned To: nikic
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 06:01:30 2024 UTC