From 4b7c9cbb238527392d685f967bf9687fe53a9b78 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Thu, 4 Feb 2016 15:06:04 -0500 Subject: [PATCH] avoid (string) catchable fatal error for instances of __PHP_Incomplete_Class --- .../HttpKernel/DataCollector/Util/ValueExporter.php | 11 +++++++++++ .../Tests/DataCollector/Util/ValueExporterTest.php | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php b/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php index d2f0898605968..c9e51cc26ff12 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/Util/ValueExporter.php @@ -35,6 +35,10 @@ public function exportValue($value, $depth = 1, $deep = false) return sprintf('Object(%s)', get_class($value)); } + if ($value instanceof \__PHP_Incomplete_Class) { + return sprintf('__PHP_Incomplete_Class(%s)', $this->getClassNameFromIncomplete($value)); + } + if (is_array($value)) { if (empty($value)) { return '[]'; @@ -75,4 +79,11 @@ public function exportValue($value, $depth = 1, $deep = false) return (string) $value; } + + private function getClassNameFromIncomplete(\__PHP_Incomplete_Class $value) + { + $array = new \ArrayObject($value); + + return $array['__PHP_Incomplete_Class_Name']; + } } diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php index d5bccfd6007ad..09810a98b1275 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/Util/ValueExporterTest.php @@ -36,4 +36,12 @@ public function testDateTimeImmutable() $dateTime = new \DateTimeImmutable('2014-06-10 07:35:40', new \DateTimeZone('UTC')); $this->assertSame('Object(DateTimeImmutable) - 2014-06-10T07:35:40+0000', $this->valueExporter->exportValue($dateTime)); } + + public function testIncompleteClass() + { + $foo = new \__PHP_Incomplete_Class(); + $array = new \ArrayObject($foo); + $array['__PHP_Incomplete_Class_Name'] = 'AppBundle/Foo'; + $this->assertSame('__PHP_Incomplete_Class(AppBundle/Foo)', $this->valueExporter->exportValue($foo)); + } } pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy