Bug #67189 [Opn]: Clone is not implemented for IteratorIterator and related classes
| From: | johannes@php.net | Date: | Tue, 06 May 2014 08:41:16 +0000 |
| Subject: | Bug #67189 [Opn]: Clone is not implemented for IteratorIterator and related classes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-185658@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67189&edit=1
ID: 67189
Updated by: johannes@php.net
Reported by: ottodavid at gmx dot net
Summary: Clone is not implemented for IteratorIterator and
related classes
Status: Open
Type: Bug
Package: SPL related
Operating System: OS X
PHP Version: 5.5.12
Block user comment: N
Private report: N
New Comment:
Iterator is an interface which doesn't make any requirements towards cloneability. Adding clone
support for IteratorIterator isn't easy as we can't guarantee state always.
Previous Comments:
------------------------------------------------------------------------
[2014-05-03 12:16:49] ottodavid at gmx dot net
Description:
------------
IteratorIterator and derived classes like FilterIterator, RegexIterator etc. are not cloneable,
because the implementation for spl_dual_it.clone_obj is missing.
This is issue, especially because Iterator is clonable, IteratorIterator is derived from Iterator
and is not clonable, thereby violating the liskov substitution principle.
Test script:
---------------
<?php
$arrayIterator = new ArrayIterator(array(1,2,3));
$it1 = new IteratorIterator($arrayIterator);
$it2 = clone $it1;
Actual result:
--------------
PHP Fatal error: Trying to clone an uncloneable object of class IteratorIterator
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67189&edit=1