File tree 1 file changed +10
-3
lines changed
src/Symfony/Component/VarDumper/Cloner
1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ protected function doClone($var)
42
42
$ currentDepth = 0 ; // Current tree depth
43
43
$ currentDepthFinalIndex = 0 ; // Final $queue index for current tree depth
44
44
$ minimumDepthReached = 0 === $ minDepth ; // Becomes true when minimum tree depth has been reached
45
- $ cookie = (object ) []; // Unique object used to detect hard references
45
+ $ cookie = (object ) []; // Unique object used to detect hard references
46
46
$ a = null ; // Array cast for nested structures
47
47
$ stub = null ; // Stub capturing the main properties of an original item value
48
48
// or null if the original value is used directly
@@ -86,8 +86,15 @@ protected function doClone($var)
86
86
}
87
87
foreach ($ vals as $ k => $ v ) {
88
88
// $v is the original value or a stub object in case of hard references
89
- $ refs [$ k ] = $ cookie ;
90
- if ($ zvalIsRef = $ vals [$ k ] === $ cookie ) {
89
+
90
+ if (\PHP_VERSION_ID >= 70400 ) {
91
+ $ zvalIsRef = null !== \ReflectionReference::fromArrayElement ($ vals , $ k );
92
+ } else {
93
+ $ refs [$ k ] = $ cookie ;
94
+ $ zvalIsRef = $ vals [$ k ] === $ cookie ;
95
+ }
96
+
97
+ if ($ zvalIsRef ) {
91
98
$ vals [$ k ] = &$ stub ; // Break hard references to make $queue completely
92
99
unset($ stub ); // independent from the original structure
93
100
if ($ v instanceof Stub && isset ($ hardRefs [spl_object_hash ($ v )])) {
You can’t perform that action at this time.
0 commit comments