Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7678d62

Browse filesBrowse files
bug #40494 [PhpUnitBridge] fix compat with symfony/debug (nicolas-grekas)
This PR was merged into the 4.4 branch. Discussion ---------- [PhpUnitBridge] fix compat with symfony/debug | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #40390 | License | MIT | Doc PR | - Best reviewed [ignoring whitespaces](https://github.com/symfony/symfony/pull/40494/files?w=1). Commits ------- 35dd54a [PhpUnitBridge] fix compat with symfony/debug
2 parents 550489a + 35dd54a commit 7678d62
Copy full SHA for 7678d62

File tree

Expand file treeCollapse file tree

1 file changed

+33
-27
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+33
-27
lines changed

‎src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php
+33-27Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Bridge\PhpUnit\DeprecationErrorHandler;
1313

14+
use PHPUnit\Framework\TestCase;
15+
use PHPUnit\Framework\TestSuite;
1416
use PHPUnit\Util\Test;
1517
use Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerFor;
1618
use Symfony\Component\Debug\DebugClassLoader as LegacyDebugClassLoader;
@@ -82,37 +84,41 @@ public function __construct($message, array $trace, $file)
8284
}
8385
}
8486

85-
if (isset($line['object']) || isset($line['class'])) {
86-
if (!isset($line['class'], $trace[$i - 2]['function']) || 0 !== strpos($line['class'], SymfonyTestsListenerFor::class)) {
87-
$this->originClass = isset($line['object']) ? \get_class($line['object']) : $line['class'];
88-
$this->originMethod = $line['function'];
87+
if (!isset($line['object']) && !isset($line['class'])) {
88+
return;
89+
}
8990

90-
return;
91-
}
91+
if (!isset($line['class'], $trace[$i - 2]['function']) || 0 !== strpos($line['class'], SymfonyTestsListenerFor::class)) {
92+
$this->originClass = isset($line['object']) ? \get_class($line['object']) : $line['class'];
93+
$this->originMethod = $line['function'];
9294

93-
if ('trigger_error' !== $trace[$i - 2]['function'] || isset($trace[$i - 2]['class'])) {
94-
$this->originClass = \get_class($line['args'][0]);
95-
$this->originMethod = $line['args'][0]->getName();
95+
return;
96+
}
9697

97-
return;
98-
}
98+
$test = isset($line['args'][0]) ? $line['args'][0] : null;
9999

100-
set_error_handler(function () {});
101-
$parsedMsg = unserialize($this->message);
102-
restore_error_handler();
103-
$this->message = $parsedMsg['deprecation'];
104-
$this->originClass = $parsedMsg['class'];
105-
$this->originMethod = $parsedMsg['method'];
106-
if (isset($parsedMsg['files_stack'])) {
107-
$this->originalFilesStack = $parsedMsg['files_stack'];
108-
}
109-
// If the deprecation has been triggered via
110-
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
111-
// then we need to use the serialized information to determine
112-
// if the error has been triggered from vendor code.
113-
if (isset($parsedMsg['triggering_file'])) {
114-
$this->triggeringFile = $parsedMsg['triggering_file'];
115-
}
100+
if (($test instanceof TestCase || $test instanceof TestSuite) && ('trigger_error' !== $trace[$i - 2]['function'] || isset($trace[$i - 2]['class']))) {
101+
$this->originClass = \get_class($line['args'][0]);
102+
$this->originMethod = $line['args'][0]->getName();
103+
104+
return;
105+
}
106+
107+
set_error_handler(function () {});
108+
$parsedMsg = unserialize($this->message);
109+
restore_error_handler();
110+
$this->message = $parsedMsg['deprecation'];
111+
$this->originClass = $parsedMsg['class'];
112+
$this->originMethod = $parsedMsg['method'];
113+
if (isset($parsedMsg['files_stack'])) {
114+
$this->originalFilesStack = $parsedMsg['files_stack'];
115+
}
116+
// If the deprecation has been triggered via
117+
// \Symfony\Bridge\PhpUnit\Legacy\SymfonyTestsListenerTrait::endTest()
118+
// then we need to use the serialized information to determine
119+
// if the error has been triggered from vendor code.
120+
if (isset($parsedMsg['triggering_file'])) {
121+
$this->triggeringFile = $parsedMsg['triggering_file'];
116122
}
117123
}
118124

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.