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 a03dc92

Browse filesBrowse files
committed
consider traits imported in parent classes
A public method declared in a trait can be used by a class without importing the trait itself when the trait is already imported by one of the parent classes from the inheritance chain.
1 parent 5992bf0 commit a03dc92
Copy full SHA for a03dc92

File tree

1 file changed

+13
-1
lines changed
Filter options

1 file changed

+13
-1
lines changed

‎src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,19 @@ public function startTest($test)
232232
if (isset($annotations['class']['expectedDeprecation'])) {
233233
$test->getTestResultObject()->addError($test, new AssertionFailedError('`@expectedDeprecation` annotations are not allowed at the class level.'), 0);
234234
}
235-
if (isset($annotations['method']['expectedDeprecation']) || $this->checkNumAssertions = \in_array(ExpectDeprecationTrait::class, class_uses($test), true)) {
235+
236+
$class = \get_class($test);
237+
$traits = [];
238+
239+
do {
240+
$traits = array_merge(class_uses($class), $traits);
241+
} while ($class = get_parent_class($class));
242+
243+
foreach ($traits as $trait => $same) {
244+
$traits = array_merge(class_uses($trait), $traits);
245+
}
246+
247+
if (isset($annotations['method']['expectedDeprecation']) || $this->checkNumAssertions = \in_array(ExpectDeprecationTrait::class, $traits, true)) {
236248
if (isset($annotations['method']['expectedDeprecation'])) {
237249
self::$expectedDeprecations = $annotations['method']['expectedDeprecation'];
238250
self::$previousErrorHandler = set_error_handler([self::class, 'handleError']);

0 commit comments

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