8000 bug #17691 Fixed (string) catchable fatal error for PHP Incomplete Cl… · symfony/symfony@ca6f1f7 · GitHub
[go: up one dir, main page]

Skip to content

Commit ca6f1f7

Browse files
committed
bug #17691 Fixed (string) catchable fatal error for PHP Incomplete Class instances (yceruto)
This PR was submitted for the master branch but it was merged into the 2.7 branch instead (closes #17691). Discussion ---------- Fixed (string) catchable fatal error for PHP Incomplete Class instances | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17586 | License | MIT | Doc PR | - Commits ------- 4b7ed98 avoid (string) catchable fatal error for instances of __PHP_Incomplete_Class
2 parents 4598b74 + 4b7ed98 commit ca6f1f7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public function exportValue($value, $depth = 1, $deep = false)
3535
return sprintf('Object(%s)', get_class($value));
3636
}
3737

38+
if ($value instanceof \__PHP_Incomplete_Class) {
39+
return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($value));
40+
}
41+
3842
if (is_array($value)) {
3943
if (empty($value)) {
4044
return '[]';
@@ -75,4 +79,11 @@ public function exportValue($value, $depth = 1, $deep = false)
7579

7680
return (string) $value;
7781
}
82+
83+
private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value)
84+
{
85+
$array = new \ArrayObject($value);
86+
87+
return $array['__PHP_Incomplete_Class_Name'];
88+
}
7889
}

src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,12 @@ public function testDateTimeImmutable()
3939
$dateTime = new \DateTimeImmutable('2014-06-10 07:35:40', new \DateTimeZone('UTC'));
4040
$this->assertSame('Object(DateTimeImmutable) - 2014-06-10T07:35:40+0000', $this->valueExporter->exportValue($dateTime));
4141
}
42+
43+
public function testIncompleteClass()
44+
{
45+
$foo = new \__PHP_Incomplete_Class();
46+
$array = new \ArrayObject($foo);
47+
$array['__PHP_Incomplete_Class_Name'] = 'AppBundle/Foo';
48+
$this->assertSame('__PHP_Incomplete_Class(AppBundle/Foo)', $this->valueExporter->exportValue($foo));
49+
}
4250
}

0 commit comments

Comments
 (0)
0