Skip to content
Permalink
Browse files

Merge branch '4.3' into 4.4

* 4.3:
  Fix displaying anonymous classes on PHP 7.4
  • Loading branch information
nicolas-grekas committed Dec 16, 2019
2 parents b9b11ce + c533fe8 commit 5c4c1db977dc70bb3250e1308d3e8c6341aa38f5
Showing with 18 additions and 2 deletions.
  1. +1 −1 Exception/FlattenException.php
  2. +5 −1 ExceptionHandler.php
  3. +12 −0 Tests/Exception/FlattenExceptionTest.php
@@ -180,7 +180,7 @@ public function getMessage()
public function setMessage($message)
{
if (false !== strpos($message, "class@anonymous\0")) {
$message = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
$message = preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', function ($m) {
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
}, $message);
}
@@ -256,7 +256,11 @@ public function getContent(FlattenException $exception)
foreach ($e['trace'] as $trace) {
$content .= '<tr><td>';
if ($trace['function']) {
$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']));
$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']);

if (isset($trace['args'])) {
$content .= sprintf('(<span class="trace-arguments">%s</span>)', $this->formatArgs($trace['args']));
}
}
if (isset($trace['file']) && isset($trace['line'])) {
$content .= $this->formatPath($trace['file'], $trace['line']);
@@ -240,6 +240,10 @@ public function flattenDataProvider()

public function testArguments()
{
if (\PHP_VERSION_ID >= 70400) {
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
}

$dh = opendir(__DIR__);
$fh = tmpfile();

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

public function testRecursionInArguments()
{
if (\PHP_VERSION_ID >= 70400) {
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
}

$a = null;
$a = ['foo', [2, &$a]];
$exception = $this->createException($a);
@@ -313,6 +321,10 @@ public function testRecursionInArguments()

public function testTooBigArray()
{
if (\PHP_VERSION_ID >= 70400) {
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
}

$a = [];
for ($i = 0; $i < 20; ++$i) {
for ($j = 0; $j < 50; ++$j) {

0 comments on commit 5c4c1db

Please sign in to comment.
You can’t perform that action at this time.