Bug #62262 [Ver->Csd]: RecursiveArrayIterator does not implement Countable

From: Date: Tue, 19 Jun 2012 16:47:57 +0000
Subject: Bug #62262 [Ver->Csd]: RecursiveArrayIterator does not implement Countable
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-171373@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62262&edit=1 ID: 62262 Updated by: nikic@php.net Reported by: gen dot work at gmail dot com Summary: RecursiveArrayIterator does not implement Countable -Status: Verified +Status: Closed Type: Bug Package: SPL related Operating System: Windows XP, Ubuntu 10.04 PHP Version: 5.3.13 -Assigned To: +Assigned To: nikic Block user comment: N Private report: N New Comment: 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 Previous Comments: ------------------------------------------------------------------------ [2012-06-08 23:34:52] 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-08 09:05:16] 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) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62262&edit=1

« previous php.bugs (#171373) next »