|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48667 "could not implement" - NOT redefining functions
Submitted: 2009-06-23 22:14 UTC Modified: 2010-02-01 13:48 UTC
From: uramihsayibok at gmail dot com Assigned: colder (profile)
Status: Closed Package: SPL related
PHP Version: 5.2.10 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: uramihsayibok at gmail dot com
New email:
PHP Version: OS:


 [2009-06-23 22:14 UTC] uramihsayibok at gmail dot com
When trying to make a class that implements IteratorAggregate and SPL's SeekableIterator the order of the interfaces in the list matters. One order (IA first SI second) works while the other (SI first IA second) produces a fatal error in Unknown.

Traversable -> Iterator -> SeekableIterator (seek,current,next,key,valid,rewind)
Traversable -> IteratorAggregate (getIterator)

I haven't been able to reproduce this with user-defined interfaces and I haven't gone looking to see if this happens with any other built-in interfaces.

Something to do with that fact that they redefine how iteration on a class works?

Reproduce code:
#1 (works)
abstract class Foo1 implements IteratorAggregate, SeekableIterator {}

#2 (does not work)
abstract class Foo2 implements SeekableIterator, IteratorAggregate {}

Expected result:
#1 and #2 should both work or both not work.
In this case, work, since neither have any functions in common to redefine.

Actual result:
#1 - okay
#2 - "Fatal error: Class Foo2 could not implement interface IteratorAggregate in Unknown on line 0"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-25 07:27 UTC]
Reproducable and strange. Error is also not very descriptive.
 [2009-08-26 12:29 UTC] admin at somesite dot de
When i set display_errors to on and display_startup_errors to on i even get an error message window displaying the same error. according to the taskmanager, this window is created by csrss.exe .

i use Windows XP SP2 with xampp + PHP5.3
 [2010-02-01 13:45 UTC]
Automatic comment from SVN on behalf of colder
Log: Fix #48667 (Implementing Iterator and IteratorAggregate is now restricted in both orders)
 [2010-02-01 13:48 UTC]
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
Thank you for the report, and for helping us make PHP better.

Both orders are now restricted.

The problem is not that they do share any function, but they both 
overwrite the internal get_iterator handler used by foreach, for 
 [2010-02-05 00:37 UTC]
Automatic comment from SVN on behalf of pajoye
Log: - Fix #48667 (Implementing Iterator and IteratorAggregate is now restricted..
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Dec 07 17:05:52 2022 UTC