8000 minor #33809 [HttpKernel] Inherit Throwable in HttpExceptionInterface… · symfony/symfony@76e5ea8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 76e5ea8

Browse files
committed
minor #33809 [HttpKernel] Inherit Throwable in HttpExceptionInterface (nesk)
This PR was merged into the 4.4 branch. Discussion ---------- [HttpKernel] Inherit Throwable in HttpExceptionInterface | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | Deprecations? | no | **BC BREAKS?**| **YES** | Tickets | n/a | License | MIT | Doc PR | n/a When using a static analysis tools, it is not possible to do this: ```php if ($exception instanceof HttpExceptionInterface) { $exception->getStatusCode(); $exception->getHeaders(); $exception->getMessage(); // ❌ Will fail here } ``` This is due to `getMessage()` not being a method declared in `HttpExceptionInterface`. Since Symfony now requires PHP 7.1+ to run, it is safe to inherit from the `Throwable` interface (added in PHP 7.0). ### About backward compatibility Adding new methods to `HttpExceptionInterface` [breaks BC](https://symfony.com/doc/current/contributing/code/bc.html#changing-interfaces), however this interface shouldn't be used on a class other than an exception, so this shouldn't affect much code. ### About tests I'm not sure this really needs tests, but maybe I'm wrong? Tell me what to test if you think this is required. Commits ------- 2ac3fbf Inherit Throwable in HttpExceptionInterface
2 parents b2d6c10 + 2ac3fbf commit 76e5ea8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/Symfony/Component/HttpKernel/Exception/HttpExceptionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @author Kris Wallsmith <kris@symfony.com>
1818
*/
19-
interface HttpExceptionInterface
19+
interface HttpExceptionInterface extends \Throwable
2020
{
2121
/**
2222
* Returns the status code.

0 commit comments

Comments
 (0)
0