Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c36568a

Browse filesBrowse files
Fix displaying anonymous classes on PHP 7.4
1 parent b729b5c commit c36568a
Copy full SHA for c36568a

File tree

6 files changed

+21
-5
lines changed
Filter options

6 files changed

+21
-5
lines changed

‎src/Symfony/Component/Console/Application.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Application.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
795795
}
796796

797797
if (false !== strpos($message, "class@anonymous\0")) {
798-
$message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
798+
$message = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', function ($m) {
799799
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
800800
}, $message);
801801
}

‎src/Symfony/Component/Debug/Exception/FlattenException.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/Exception/FlattenException.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function getMessage()
172172
public function setMessage($message)
173173
{
174174
if (false !== strpos($message, "class@anonymous\0")) {
175-
$message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
175+
$message = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', function ($m) {
176176
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
177177
}, $message);
178178
}

‎src/Symfony/Component/Debug/ExceptionHandler.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/ExceptionHandler.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,11 @@ public function getContent(FlattenException $exception)
252252
foreach ($e['trace'] as $trace) {
253253
$content .= '<tr><td>';
254254
if ($trace['function']) {
255-
$content .= sprintf('at <span class="trace-class">%s</span><span class="trace-type">%s</span><span class="trace-method">%s</span>(<span class="trace-arguments">%s</span>)', $this->formatClass($trace['class']), $trace['type'], $trace['function'], $this->formatArgs($trace['args']));
255+
$content .= sprintf('at <span class="trace-class">%s</span><span class="trace-type">%s</span><span class="trace-method">%s</span>', $this->formatClass($trace['class']), $trace['type'], $trace['function']);
256+
257+
if (isset($trace['args'])) {
258+
$content .= sprintf('(<span class="trace-arguments">%s</span>)', $this->formatArgs($trace['args']));
259+
}
256260
}
257261
if (isset($trace['file']) && isset($trace['line'])) {
258262
$content .= $this->formatPath($trace['file'], $trace['line']);

‎src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ public function flattenDataProvider()
237237

238238
public function testArguments()
239239
{
240+
if (\PHP_VERSION_ID >= 70400) {
241+
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
242+
}
243+
240244
$dh = opendir(__DIR__);
241245
$fh = tmpfile();
242246

@@ -299,6 +303,10 @@ function () {},
299303

300304
public function testRecursionInArguments()
301305
{
306+
if (\PHP_VERSION_ID >= 70400) {
307+
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
308+
}
309+
302310
$a = null;
303311
$a = ['foo', [2, &$a]];
304312
$exception = $this->createException($a);
@@ -310,6 +318,10 @@ public function testRecursionInArguments()
310318

311319
public function testTooBigArray()
312320
{
321+
if (\PHP_VERSION_ID >= 70400) {
322+
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
323+
}
324+
313325
$a = [];
314326
for ($i = 0; $i < 20; ++$i) {
315327
for ($j = 0; $j < 50; ++$j) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/ClassStub.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function __construct(string $identifier, $callable = null)
5656
}
5757

5858
if (false !== strpos($identifier, "class@anonymous\0")) {
59-
$this->value = $identifier = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
59+
$this->value = $identifier = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', function ($m) {
6060
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
6161
}, $identifier);
6262
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/VarDumper/Caster/ExceptionCaster.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ private static function filterExceptionArray($xClass, array $a, $xPrefix, $filte
282282
unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']);
283283

284284
if (isset($a[Caster::PREFIX_PROTECTED.'message']) && false !== strpos($a[Caster::PREFIX_PROTECTED.'message'], "class@anonymous\0")) {
285-
$a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
285+
$a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', function ($m) {
286286
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
287287
}, $a[Caster::PREFIX_PROTECTED.'message']);
288288
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.