8000 bug #23662 [VarDumper] Adapt to php 7.2 changes (nicolas-grekas) · symfony/symfony@e5790af · GitHub
[go: up one dir, main page]

Skip to content 10000

Commit e5790af

Browse files
bug #23662 [VarDumper] Adapt to php 7.2 changes (nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- [VarDumper] Adapt to php 7.2 changes | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - As required by this change on PHP 7.2: https://wiki.php.net/rfc/convert_numeric_keys_in_object_array_casts Tests pass locally (until we add 7.2 to Travis) Commits ------- 3c2f5f7 [VarDumper] Adapt to php 7.2 changes
2 parents 2af5959 + 3c2f5f7 commit e5790af

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed

src/Symfony/Component/VarDumper/Caster/Caster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static function castObject($obj, \ReflectionClass $reflector)
5454
if ($a) {
5555
$p = array_keys($a);
5656
foreach ($p as $i => $k) {
57-
if (isset($k[0]) && "\0" !== $k[0] && !$reflector->hasProperty($k)) {
57+
if (isset($k[0]) ? "\0" !== $k[0] && !$reflector->hasProperty($k) : \PHP_VERSION_ID >= 70200) {
5858
$p[$i] = self::PREFIX_DYNAMIC.$k;
5959
} elseif (isset($k[16]) && "\0" === $k[16] && 0 === strpos($k, "\0class@anonymous\0")) {
6060
$p[$i] = "\0".$reflector->getParentClass().'@anonymous'.strrchr($k, "\0");

src/Symfony/Component/VarDumper/Tests/CliDumperTest.php

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,35 +141,62 @@ public function testJsonCast()
141141
$var[] = &$v;
142142
$var[''] = 2;
143143

144-
$this->assertDumpMatchesFormat(
145-
<<<'EOTXT'
144+
if (\PHP_VERSION_ID >= 70200) {
145+
$this->assertDumpMatchesFormat(
146+
<<<'EOTXT'
147+
array:4 [
148+
0 => {}
149+
1 => &1 null
150+
2 => &1 null
151+
"" => 2
152+
]
153+
EOTXT
154+
,
155+
$var
156+
);
157+
} else {
158+
$this->assertDumpMatchesFormat(
159+
<<<'EOTXT'
146160
array:4 [
147161
"0" => {}
148162
"1" => &1 null
149163
0 => &1 null
150164
"" => 2
151165
]
152166
EOTXT
153-
,
154-
$var
155-
);
167+
,
168+
$var
169+
);
170+
}
156171
}
157172

158173
public function testObjectCast()
159174
{
160175
$var = (object) array(1 => 1);
161176
$var->{1} = 2;
162177

163-
$this->assertDumpMatchesFormat(
164-
<<<'EOTXT'
178+
if (\PHP_VERSION_ID >= 70200) {
179+
$this->assertDumpMatchesFormat(
180+
<<<'EOTXT'
181+
{
182+
+"1": 2
183+
}< 8000 /span>
184+
EOTXT
185+
,
186+
$var
187+
);
188+
} else {
189+
$this->assertDumpMatchesFormat(
190+
<<<'EOTXT'
165191
{
166192
+1: 1
167193
+"1": 2
168194
}
169195
EOTXT
170-
,
171-
$var
172-
);
196+
,
197+
$var
198+
);
199+
}
173200
}
174201

175202
public function testClosedResource()

src/Symfony/Component/VarDumper/Tests/VarClonerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function testJsonCast()
203203
EOTXT;
204204
ob_start();
205205
var_dump($clone);
206-
$this->assertStringMatchesFormat($expected, ob_get_clean());
206+
$this->assertStringMatchesFormat(\PHP_VERSION_ID >= 70200 ? str_replace('"1"', '1', $expected) : $expected, ob_get_clean());
207207
}
208208

209209
public function testCaster()

0 commit comments

Comments
 (0)
0