File tree Expand file tree Collapse file tree 2 files changed +23
-4
lines changed
src/Symfony/Component/VarDumper Expand file tree Collapse file tree 2 files changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -85,9 +85,15 @@ protected function doClone($var)
85
85
}
86
86
}
87
87
foreach ($ vals as $ k => $ v ) {
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 ) {
88
+ if (\PHP_VERSION_ID >= 70400 ) {
89
+ // see https://wiki.php.net/rfc/reference_reflection
90
+ $ zvalIsRef = null !== \ReflectionReference::fromArrayElement ($ vals , $ k );
91
+ } else {
92
+ $ refs [$ k ] = $ cookie ; // $v is the original value or a stub object in case of hard references
93
+ $ zvalIsRef = $ vals [$ k ] === $ cookie ;
94
+ }
95
+
96
+ if ($ zvalIsRef ) {
91
97
$ vals [$ k ] = &$ stub ; // Break hard references to make $queue completely
92
98
unset($ stub ); // independent from the original structure
93
99
if ($ v instanceof Stub && isset ($ hardRefs [\spl_object_hash ($ v )])) {
Original file line number Diff line number Diff line change @@ -230,7 +230,20 @@ public function testJsonCast()
230
230
$ var [] = &$ v ;
231
231
$ var ['' ] = 2 ;
232
232
233
- if (\PHP_VERSION_ID >= 70200 ) {
233
+ if (\PHP_VERSION_ID >= 70400 ) {
234
+ $ this ->assertDumpMatchesFormat (
235
+ <<<'EOTXT'
236
+ array:4 [
237
+ 0 => & {}
238
+ 1 => &2 null
239
+ 2 => &2 null
240
+ "" => 2
241
+ ]
242
+ EOTXT
243
+ ,
244
+ $ var
245
+ );
246
+ } elseif (\PHP_VERSION_ID >= 70200 ) {
234
247
$ this ->assertDumpMatchesFormat (
235
248
<<<'EOTXT'
236
249
array:4 [
You can’t perform that action at this time.
0 commit comments