8000 [VarDumper] Adapt to php 7.2 changes by nicolas-grekas · Pull Request #23662 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[VarDumper] Adapt to php 7.2 changes #23662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[VarDumper] Adapt to php 7.2 changes
  • Loading branch information
nicolas-grekas committed Jul 25, 2017
commit 3c2f5f7a248fb8675e9d5259714eae388eb81e4d
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarDumper/Caster/Caster.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static function castObject($obj, \ReflectionClass $reflector)
if ($a) {
$p = array_keys($a);
foreach ($p as $i => $k) {
if (isset($k[0]) && "\0" !== $k[0] && !$reflector->hasProperty($k)) {
if (isset($k[0]) ? "\0" !== $k[0] && !$reflector->hasProperty($k) : \PHP_VERSION_ID >= 70200) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nicolas-grekas is there any need of writing such agly assertions? ;) I think some brackets would help in reading this code

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always try to improve my style, a never ending story, thanks for pointing :)

$p[$i] = self::PREFIX_DYNAMIC.$k;
} elseif (isset($k[16]) && "\0" === $k[16] && 0 === strpos($k, "\0class@anonymous\0")) {
$p[$i] = "\0".$reflector->getParentClass().'@anonymous'.strrchr($k, "\0");
Expand Down
47 changes: 37 additions & 10 deletions src/Symfony/Component/VarDumper/Tests/CliDumperTest.php
8000
Original file line number Diff line number Diff line change
Expand Up @@ -141,35 +141,62 @@ public function testJsonCast()
$var[] = &$v;
$var[''] = 2;

$this->assertDumpMatchesFormat(
<<<'EOTXT'
if (\PHP_VERSION_ID >= 70200) {
$this->assertDumpMatchesFormat(
<<<'EOTXT'
array:4 [
0 => {}
1 => &1 null
2 => &1 null
"" => 2
]
EOTXT
,
$var
);
} else {
$this->assertDumpMatchesFormat(
<<<'EOTXT'
array:4 [
"0" => {}
"1" => &1 null
0 => &1 null
"" => 2
]
EOTXT
,
$var
);
,
$var
);
}
}

public function testObjectCast()
{
$var = (object) array(1 => 1);
$var->{1} = 2;

$this->assertDumpMatchesFormat(
<<<'EOTXT'
if (\PHP_VERSION_ID >= 70200) {
$this->assertDumpMatchesFormat(
<<<'EOTXT'
{
+"1": 2
}
EOTXT
,
$var
);
} else {
$this->assertDumpMatchesFormat(
<<<'EOTXT'
{
+1: 1
+"1": 2
}
EOTXT
,
$var
);
,
$var
);
}
}

public function testClosedResource()
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarDumper/Tests/VarClonerTest.php
46C8
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public function testJsonCast()
EOTXT;
ob_start();
var_dump($clone);
$this->assertStringMatchesFormat($expected, ob_get_clean());
$this->assertStringMatchesFormat(\PHP_VERSION_ID >= 70200 ? str_replace('"1"', '1', $expected) : $expected, ob_get_clean());
}

public function testCaster()
Expand Down
0