|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72122 IteratorIterator breaks '@' error suppression
Submitted: 2016-04-28 14:32 UTC Modified: 2016-07-12 08:28 UTC
From: kinglozzer at gmail dot com Assigned: jpauli (profile)
Status: Closed Package: SPL related
PHP Version: 5.5.34 OS: OS X
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
10 + 30 = ?
Subscribe to this entry?

 [2016-04-28 14:32 UTC] kinglozzer at gmail dot com
The '@' error suppression operator appears to not work correctly when wrapped by IteratorIterator. The issue occurs when an error is triggered (and supposedly suppressed) in getIterator() in the inner iterator - an InvalidArgumentException is thrown instead.

I’ve not tested this in any great detail, or with other iterator types (apologies, time is tight at the moment).

Test script:

class CustomIterator implements IteratorAggregate {
	public function getIterator() {
		return new ArrayIterator(array('item'));

$obj = new CustomIterator;
$iterator = new IteratorIterator($obj);

echo 'done';

Expected result:
Text 'done' should be shown

Actual result:
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'unlink(/missing/file.txt): No such file or directory'


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-07-12 08:28 UTC]
-Status: Open +Status: Closed -Assigned To: +Assigned To: jpauli
 [2016-07-12 08:28 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Dec 08 00:05:52 2022 UTC