Skip to content

Commit 6d7d771

Browse files
Merge branch '4.3' into 4.4
* 4.3: Fix displaying anonymous classes on PHP 7.4
1 parent 3fe2fa8 commit 6d7d771

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

ErrorHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,7 @@ private function cleanTrace(array $backtrace, int $type, string $file, int $line
761761
*/
762762
private function parseAnonymousClass(string $message): string
763763
{
764-
return preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', static function ($m) {
764+
return preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', static function ($m) {
765765
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
766766
}, $message);
767767
}

Exception/FlattenException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public function getMessage(): string
196196
public function setMessage($message): self
197197
{
198198
if (false !== strpos($message, "class@anonymous\0")) {
199-
$message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
199+
$message = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', function ($m) {
200200
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
201201
}, $message);
202202
}

Resources/views/trace.html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<?php } ?>
66

77
<?php if ('compact' !== $style && $trace['function']) { ?>
8-
<span class="trace-class"><?= $this->abbrClass($trace['class']); ?></span><?php if ($trace['type']) { ?><span class="trace-type"><?= $trace['type']; ?></span><?php } ?><span class="trace-method"><?= $trace['function']; ?></span><span class="trace-arguments">(<?= $this->formatArgs($trace['args']); ?>)</span>
8+
<span class="trace-class"><?= $this->abbrClass($trace['class']); ?></span><?php if ($trace['type']) { ?><span class="trace-type"><?= $trace['type']; ?></span><?php } ?><span class="trace-method"><?= $trace['function']; ?></span><?php if (isset($trace['args'])) { ?><span class="trace-arguments">(<?= $this->formatArgs($trace['args']); ?>)</span><?php } ?>
99
<?php } ?>
1010

1111
<?php if ($trace['file']) { ?>

Resources/views/traces_text.html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
foreach ($exception['trace'] as $trace) {
2929
echo "\n ";
3030
if ($trace['function']) {
31-
echo 'at '.$trace['class'].$trace['type'].$trace['function'].'('.$this->formatArgsAsText($trace['args']).')';
31+
echo 'at '.$trace['class'].$trace['type'].$trace['function'].'('.(isset($trace['args']) ? $this->formatArgsAsText($trace['args']) : '').')';
3232
}
3333
if ($trace['file'] && $trace['line']) {
3434
echo($trace['function'] ? "\n (" : 'at ').strtr(strip_tags($this->formatFile($trace['file'], $trace['line'])), [' at line '.$trace['line'] => '']).':'.$trace['line'].($trace['function'] ? ')' : '');

Tests/Exception/FlattenExceptionTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ public function flattenDataProvider(): array
240240

241241
public function testArguments()
242242
{
243+
if (\PHP_VERSION_ID >= 70400) {
244+
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
245+
}
246+
243247
$dh = opendir(__DIR__);
244248
$fh = tmpfile();
245249

@@ -302,6 +306,10 @@ function () {},
302306

303307
public function testRecursionInArguments()
304308
{
309+
if (\PHP_VERSION_ID >= 70400) {
310+
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
311+
}
312+
305313
$a = null;
306314
$a = ['foo', [2, &$a]];
307315
$exception = $this->createException($a);
@@ -313,6 +321,10 @@ public function testRecursionInArguments()
313321

314322
public function testTooBigArray()
315323
{
324+
if (\PHP_VERSION_ID >= 70400) {
325+
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
326+
}
327+
316328
$a = [];
317329
for ($i = 0; $i < 20; ++$i) {
318330
for ($j = 0; $j < 50; ++$j) {

0 commit comments

Comments
 (0)