From eac6369db7c97deb418a6e6dc86bfeb078647853 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Thu, 9 Jul 2020 18:13:45 +0200 Subject: [PATCH] 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. --- src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php index 5efc35a805..693883ed78 100644 --- a/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php +++ b/src/Symfony/Bridge/PhpUnit/Legacy/SymfonyTestsListenerTrait.php @@ -232,7 +232,7 @@ class SymfonyTestsListenerTrait if (isset($annotations['class']['expectedDeprecation'])) { $test->getTestResultObject()->addError($test, new AssertionFailedError('`@expectedDeprecation` annotations are not allowed at the class level.'), 0); } - if (isset($annotations['method']['expectedDeprecation']) || $this->checkNumAssertions = \in_array(ExpectDeprecationTrait::class, class_uses($test), true)) { + if (isset($annotations['method']['expectedDeprecation']) || $this->checkNumAssertions = method_exists($test, 'expectDeprecation') && (new \ReflectionMethod($test, 'expectDeprecation'))->getFileName() === (new \ReflectionMethod(ExpectDeprecationTrait::class, 'expectDeprecation'))->getFileName()) { if (isset($annotations['method']['expectedDeprecation'])) { self::$expectedDeprecations = $annotations['method']['expectedDeprecation']; self::$previousErrorHandler = set_error_handler([self::class, 'handleError']);