diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php index 68d8d8e339590..d81e36149273d 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler.php @@ -139,7 +139,7 @@ public function handleError($type, $msg, $file, $line, $context = []) $msg = $trace[1]['args'][0]; } - $deprecation = new Deprecation($msg, $trace, $file); + $deprecation = new Deprecation($msg, $trace, $file, \E_DEPRECATED === $type); if ($deprecation->isMuted()) { return null; } diff --git a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php index d122de44090a8..9f4f593962235 100644 --- a/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php +++ b/src/Symfony/Bridge/PhpUnit/DeprecationErrorHandler/Deprecation.php @@ -37,6 +37,7 @@ class Deprecation private $trace = []; private $message; + private $languageDeprecation; private $originClass; private $originMethod; private $triggeringFile; @@ -56,11 +57,13 @@ class Deprecation /** * @param string $message * @param string $file + * @param bool $languageDeprecation */ - public function __construct($message, array $trace, $file) + public function __construct($message, array $trace, $file, $languageDeprecation = false) { $this->trace = $trace; $this->message = $message; + $this->languageDeprecation = $languageDeprecation; $i = \count($trace); while (1 < $i && $this->lineShouldBeSkipped($trace[--$i])) { @@ -227,7 +230,12 @@ public function isMuted() */ public function getType() { - if (self::PATH_TYPE_SELF === $pathType = $this->getPathType($this->triggeringFile)) { + $pathType = $this->getPathType($this->triggeringFile); + if ($this->languageDeprecation && self::PATH_TYPE_VENDOR === $pathType) { + // the triggering file must be used for language deprecations + return self::TYPE_INDIRECT; + } + if (self::PATH_TYPE_SELF === $pathType) { return self::TYPE_SELF; } if (self::PATH_TYPE_UNDETERMINED === $pathType) { diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/PhpDeprecation.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/PhpDeprecation.php new file mode 100644 index 0000000000000..26a3237e77941 --- /dev/null +++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/fake_vendor/acme/lib/PhpDeprecation.php @@ -0,0 +1,15 @@ + +--FILE-- + +--EXPECTF-- +Remaining indirect deprecation notices (1) + + 1x: acme\lib\PhpDeprecation implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) + 1x in DebugClassLoader::loadClass from Symfony\Component\ErrorHandler
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: