Skip to content

Commit 126eab1

Browse files
committed
Prevents ArrayIterator to be cloned
See https://stackoverflow.com/a/34468458/738091
1 parent 090c9cd commit 126eab1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Doctrine/Instantiator/Instantiator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Doctrine\Instantiator;
44

5+
use ArrayIterator;
56
use Doctrine\Instantiator\Exception\InvalidArgumentException;
67
use Doctrine\Instantiator\Exception\UnexpectedValueException;
78
use Exception;
@@ -195,6 +196,8 @@ private function hasInternalAncestors(ReflectionClass $reflectionClass) : bool
195196
*/
196197
private function isSafeToClone(ReflectionClass $reflection) : bool
197198
{
198-
return $reflection->isCloneable() && ! $reflection->hasMethod('__clone');
199+
return $reflection->isCloneable()
200+
&& ! $reflection->hasMethod('__clone')
201+
&& ! $reflection->isSubclassOf(ArrayIterator::class);
199202
}
200203
}

0 commit comments

Comments
 (0)