|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: kinglozzer at gmail dot com
New email:
PHP Version: OS:


 [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-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 20 18:01:30 2024 UTC