[PhpUnitBridge] fix compat with symfony/debug
This commit is contained in:
parent
a78fb1832b
commit
35dd54a654
@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use PHPUnit\Framework\TestSuite;
|
||||
use PHPUnit\Util\Test;
|
||||
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor;
|
||||
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
|
||||
@ -82,37 +84,41 @@ class Deprecation
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($line['object']) || isset($line['class'])) {
|
||||
if (!isset($line['class'], $trace[$i - 2]['function']) || 0 !== strpos($line['class'], SymfonyTestsListenerFor::class)) {
|
||||
$this->originClass = isset($line['object']) ? \get_class($line['object']) : $line['class'];
|
||||
$this->originMethod = $line['function'];
|
||||
if (!isset($line['object']) && !isset($line['class'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
if (!isset($line['class'], $trace[$i - 2]['function']) || 0 !== strpos($line['class'], SymfonyTestsListenerFor::class)) {
|
||||
$this->originClass = isset($line['object']) ? \get_class($line['object']) : $line['class'];
|
||||
$this->originMethod = $line['function'];
|
||||
|
||||
if ('trigger_error' !== $trace[$i - 2]['function'] || isset($trace[$i - 2]['class'])) {
|
||||
$this->originClass = \get_class($line['args'][0]);
|
||||
$this->originMethod = $line['args'][0]->getName();
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
$test = isset($line['args'][0]) ? $line['args'][0] : null;
|
||||
|
||||
set_error_handler(function () {});
|
||||
$parsedMsg = unserialize($this->message);
|
||||
restore_error_handler();
|
||||
$this->message = $parsedMsg['deprecation'];
|
||||
$this->originClass = $parsedMsg['class'];
|
||||
$this->originMethod = $parsedMsg['method'];
|
||||
if (isset($parsedMsg['files_stack'])) {
|
||||
$this->originalFilesStack = $parsedMsg['files_stack'];
|
||||
}
|
||||
// If the deprecation has been triggered via
|
||||
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
|
||||
// then we need to use the serialized information to determine
|
||||
// if the error has been triggered from vendor code.
|
||||
if (isset($parsedMsg['triggering_file'])) {
|
||||
$this->triggeringFile = $parsedMsg['triggering_file'];
|
||||
}
|
||||
if (($test instanceof TestCase || $test instanceof TestSuite) && ('trigger_error' !== $trace[$i - 2]['function'] || isset($trace[$i - 2]['class']))) {
|
||||
$this->originClass = \get_class($line['args'][0]);
|
||||
$this->originMethod = $line['args'][0]->getName();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
set_error_handler(function () {});
|
||||
$parsedMsg = unserialize($this->message);
|
||||
restore_error_handler();
|
||||
$this->message = $parsedMsg['deprecation'];
|
||||
$this->originClass = $parsedMsg['class'];
|
||||
$this->originMethod = $parsedMsg['method'];
|
||||
if (isset($parsedMsg['files_stack'])) {
|
||||
$this->originalFilesStack = $parsedMsg['files_stack'];
|
||||
}
|
||||
// If the deprecation has been triggered via
|
||||
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
|
||||
// then we need to use the serialized information to determine
|
||||
// if the error has been triggered from vendor code.
|
||||
if (isset($parsedMsg['triggering_file'])) {
|
||||
$this->triggeringFile = $parsedMsg['triggering_file'];
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user