Skip to content

Commit d121089

Browse files
committed
bug #43241 [PhpUnitBridge] Do not override correct triggering file for return type deprecations (wouterj)
This PR was submitted for the 5.4 branch but it was merged into the 5.3 branch instead. Discussion ---------- [PhpUnitBridge] Do not override correct triggering file for return type deprecations | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Return type deprecations were sometimes incorrectly marked as direct/indirect, even when they occur on a vendor package. This is due to their special message, which starts with `Method "classFromVendor::method()" might add "type" [...] do the same in "affectedClass" [...]` (normal messages start with the affected class). This means that the deprecation type checked whether the method causing the deprecation was inside the vendor directory, rather than the method affected by the deprecation. Even more, if the causing method was from PHP internals, `$this->triggeringFile` would become `false`, causing `realpath(false)` to return the current directory - meaning these were always marked as direct. Commits ------- 9bcfdde Do not override correct triggering file for return type deprecations
2 parents 500ffa2 + 9bcfdde commit d121089

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function __construct($message, array $trace, $file)
8787
$this->getOriginalFilesStack();
8888
array_splice($this->originalFilesStack, 0, $j, [$this->triggeringFile]);
8989

90-
if (preg_match('/(?|"([^"]++)" that is deprecated|should implement method "(?:static )?([^:]++))/', $message, $m) || preg_match('/^(?:The|Method) "([^":]++)/', $message, $m)) {
90+
if (preg_match('/(?|"([^"]++)" that is deprecated|should implement method "(?:static )?([^:]++))/', $message, $m) || (false === strpos($message, 'native return type declaration') && preg_match('/^(?:The|Method) "([^":]++)/', $message, $m))) {
9191
$this->triggeringFile = (new \ReflectionClass($m[1]))->getFileName();
9292
array_unshift($this->originalFilesStack, $this->triggeringFile);
9393
}

0 commit comments

Comments
 (0)