php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #63507 IteratorIterator inheritance problems
Submitted: 2012-11-13 22:12 UTC Modified: 2012-11-13 22:24 UTC
From: levim@php.net Assigned: levim (profile)
Status: Closed Package: SPL related
PHP Version: Irrelevant OS:
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: levim@php.net
New email:
PHP Version: OS:

 

 [2012-11-13 22:12 UTC] levim@php.net
Description:
------------
IteratorIterator has a method `seek` that matches the signature for implementing 
SeekableIterator, but it doesn't implement the interface.

Also, subclasses of IteratorIterator do not inherit the seek method. This breaks 
the rules for inheritance.

I'm not sure how to propose fixing it at this point.  This should have been caught 
before being released. Like much of the SPL, this was not properly thought out and 
tested.

Test script:
---------------
$iterator = new IteratorIterator(
    new EmptyIterator()
);

var_dump($iterator instanceof SeekableIterator);
var_dump(method_exists($iterator, 'seek');

$iterator = new NoRewindIterator(
    new EmptyIterator()
);
var_dump(method_exists($iterator, 'seek');


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

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-11-13 22:24 UTC] levim@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

I seem to have tested the wrong things, somehow.  Silly mistake.
 [2012-11-13 22:24 UTC] levim@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: levim
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 19:01:29 2024 UTC