bug #34072 [Debug] remove return types that break FC badly (nicolas-grekas)

This PR was merged into the 4.4 branch.

Discussion
----------

[Debug] remove return types that break FC badly

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

The return type on Debug's FlattenException blocks creating a child class that is compatible with both v4.4 and v5.0.
Removing it fixes the issue with no BC break.
Adding `final` on `setPrevious` will allow updating its type hint in v5.0.

Commits
-------

cb5ef6ec18 [Debug] remove return types that break FC badly
This commit is contained in:
Fabien Potencier 2019-10-22 19:09:30 +02:00
commit 28c9f48f7e
2 changed files with 10 additions and 4 deletions

View File

@ -36,12 +36,18 @@ class FlattenException
private $file;
private $line;
/**
* @return static
*/
public static function create(\Exception $exception, $statusCode = null, array $headers = [])
{
return static::createFromThrowable($exception, $statusCode, $headers);
}
public static function createFromThrowable(\Throwable $exception, int $statusCode = null, array $headers = []): self
/**
* @return static
*/
public static function createFromThrowable(\Throwable $exception, int $statusCode = null, array $headers = [])
{
$e = new static();
$e->setMessage($exception->getMessage());

View File

@ -38,12 +38,12 @@ class FlattenException extends LegacyFlattenException
private $file;
private $line;
public static function create(\Exception $exception, $statusCode = null, array $headers = []): LegacyFlattenException
public static function create(\Exception $exception, $statusCode = null, array $headers = []): self
{
return static::createFromThrowable($exception, $statusCode, $headers);
}
public static function createFromThrowable(\Throwable $exception, int $statusCode = null, array $headers = []): LegacyFlattenException
public static function createFromThrowable(\Throwable $exception, int $statusCode = null, array $headers = []): self
{
$e = new static();
$e->setMessage($exception->getMessage());
@ -228,7 +228,7 @@ class FlattenException extends LegacyFlattenException
/**
* @return $this
*/
public function setPrevious(LegacyFlattenException $previous): self
final public function setPrevious(LegacyFlattenException $previous): self
{
$this->previous = $previous;