Bug #67189 [Opn]: Clone is not implemented for IteratorIterator and related classes

From: Date: Fri, 28 Nov 2014 15:15:55 +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-188838@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: jpauli@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: @Johannes: There is a PR pending for this one, which looks right to me. Can you read it / elaborate about your previous comment ? Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#188838) next »