Merge branch '4.4' into 5.0

* 4.4:
  Fix displaying anonymous classes on PHP 7.4
  Fix merge
This commit is contained in:
Nicolas Grekas 2019-12-16 15:48:47 +01:00
commit 6fe308bb2a
11 changed files with 22 additions and 10 deletions

View File

@ -26,7 +26,7 @@ env:
matrix:
include:
- php: 7.2
env: php_extra="7.4snapshot"
env: php_extra="7.4"
- php: 7.3
env: deps=high
- php: 7.4

View File

@ -783,7 +783,7 @@ class Application implements ResetInterface
}
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);
}

View File

@ -73,7 +73,7 @@ abstract class FileLoader extends BaseFileLoader
}
}
if ($args !== $frame['args']) {
if (__FILE__ !== $frame['file']) {
throw $e;
}
}

View File

@ -761,7 +761,7 @@ class ErrorHandler
*/
private function parseAnonymousClass(string $message): string
{
return preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', static function ($m) {
return preg_replace_callback('/class@anonymous\x00.*?\.php(?:0x?|:)[0-9a-fA-F]++/', static function ($m) {
return class_exists($m[0], false) ? get_parent_class($m[0]).'@anonymous' : $m[0];
}, $message);
}

View File

@ -200,7 +200,7 @@ class FlattenException
public function setMessage($message): self
{
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);
}

View File

@ -5,7 +5,7 @@
<?php } ?>
<?php if ('compact' !== $style && $trace['function']) { ?>
<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>
<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 } ?>
<?php } ?>
<?php if ($trace['file']) { ?>

View File

@ -28,7 +28,7 @@
foreach ($exception['trace'] as $trace) {
echo "\n ";
if ($trace['function']) {
echo 'at '.$trace['class'].$trace['type'].$trace['function'].'('.$this->formatArgsAsText($trace['args']).')';
echo 'at '.$trace['class'].$trace['type'].$trace['function'].'('.(isset($trace['args']) ? $this->formatArgsAsText($trace['args']) : '').')';
}
if ($trace['file'] && $trace['line']) {
echo($trace['function'] ? "\n (" : 'at ').strtr(strip_tags($this->formatFile($trace['file'], $trace['line'])), [' at line '.$trace['line'] => '']).':'.$trace['line'].($trace['function'] ? ')' : '');

View File

@ -226,6 +226,10 @@ class FlattenExceptionTest extends TestCase
public function testArguments()
{
if (\PHP_VERSION_ID >= 70400) {
$this->markTestSkipped('PHP 7.4 removes arguments from exception traces.');
}
$dh = opendir(__DIR__);
$fh = tmpfile();
@ -288,6 +292,10 @@ class FlattenExceptionTest extends TestCase
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);
@ -299,6 +307,10 @@ class FlattenExceptionTest extends TestCase
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) {

View File

@ -287,7 +287,7 @@ class ConnectionTest extends TestCase
$factory->method('createQueue')->willReturn($amqpQueue);
$amqpExchange->expects($this->once())->method('declareExchange');
$amqpExchange->expects($this->once())->method('publish')->with('body', null, AMQP_NOPARAM, ['headers' => []]);
$amqpExchange->expects($this->once())->method('publish')->with('body', null, AMQP_NOPARAM, ['headers' => [], 'delivery_mode' => 2]);
$amqpQueue->expects($this->once())->method('declareQueue');
$amqpQueue->expects($this->exactly(1))->method('bind')->withConsecutive(
[self::DEFAULT_EXCHANGE_NAME, null, ['x-match' => 'all']]

View File

@ -56,7 +56,7 @@ class ClassStub extends ConstStub
}
if (false !== strpos($identifier, "class@anonymous\0")) {
$this->value = $identifier = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
$this->value = $identifier = 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];
}, $identifier);
}

View File

@ -283,7 +283,7 @@ class ExceptionCaster
unset($a[$xPrefix.'string'], $a[Caster::PREFIX_DYNAMIC.'xdebug_message'], $a[Caster::PREFIX_DYNAMIC.'__destructorException']);
if (isset($a[Caster::PREFIX_PROTECTED.'message']) && false !== strpos($a[Caster::PREFIX_PROTECTED.'message'], "class@anonymous\0")) {
$a[Caster::PREFIX_PROTECTED.'message'] = preg_replace_callback('/class@anonymous\x00.*?\.php0x?[0-9a-fA-F]++/', function ($m) {
$a[Caster::PREFIX_PROTECTED.'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];
}, $a[Caster::PREFIX_PROTECTED.'message']);
}