Bug #67189 [Com]: Clone is not implemented for IteratorIterator and related classes
| From: | ottodavid at gmx dot net | Date: | Tue, 17 Feb 2015 23:11:27 +0000 |
| Subject: | Bug #67189 [Com]: Clone is not implemented for IteratorIterator and related classes | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-190758@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
Comment by: ottodavid at gmx dot 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:
Sorry I missed to see that Iterator is just an interface.
Anyway, my PR implements/improves/fixes this functionality, Is there any chance to get it merged?
Previous Comments:
------------------------------------------------------------------------
[2014-11-28 15:15:55] jpauli@php.net
@Johannes: There is a PR pending for this one, which looks right to me. Can you read it / elaborate
about your previous comment ?
------------------------------------------------------------------------
[2014-05-06 08:41:16] johannes@php.net
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.
------------------------------------------------------------------------
[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