Skip to content

Commit 4608633

Browse files
Merge branch '4.4' into 5.0
* 4.4: Fix displaying anonymous classes on PHP 7.4 Fix merge
2 parents 50c02e0 + 6d7d771 commit 4608633

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
@@ -200,7 +200,7 @@ public function getMessage(): string
200200
public function setMessage($message): self
201201
{
202202
if (false !== strpos($message, "class@anonymous\0")) {
203-
$message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
203+
$message = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', function ($m) {
204204
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
205205
}, $message);
206206
}

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
@@ -226,6 +226,10 @@ public function flattenDataProvider(): array
226226

227227
public function testArguments()
228228
{
229+
if (\PHP_VERSION_ID >= 70400) {
230+
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
231+
}
232+
229233
$dh = opendir(__DIR__);
230234
$fh = tmpfile();
231235

@@ -288,6 +292,10 @@ function () {},
288292

289293
public function testRecursionInArguments()
290294
{
295+
if (\PHP_VERSION_ID >= 70400) {
296+
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
297+
}
298+
291299
$a = null;
292300
$a = ['foo', [2, &$a]];
293301
$exception = $this->createException($a);
@@ -299,6 +307,10 @@ public function testRecursionInArguments()
299307

300308
public function testTooBigArray()
301309
{
310+
if (\PHP_VERSION_ID >= 70400) {
311+
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
312+
}
313+
302314
$a = [];
303315
for ($i = 0; $i < 20; ++$i) {
304316
for ($j = 0; $j < 50; ++$j) {

0 commit comments

Comments
 (0)