Skip to content

Commit

Permalink
Remove int return type from FlattenException::getCode
Browse files Browse the repository at this point in the history
  • Loading branch information
wucdbm authored and fabpot committed Mar 9, 2020
1 parent ff30b43 commit 0f22e07
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
Expand Up @@ -206,7 +206,7 @@ public function setMessage($message): self
return $this;
}

public function getCode(): int
public function getCode()
{
return $this->code;
}
Expand Down
Expand Up @@ -14,6 +14,7 @@
use PHPUnit\Framework\TestCase;
use Symfony\Component\Debug\Exception\FatalThrowableError;
use Symfony\Component\ErrorHandler\Exception\FlattenException;
use Symfony\Component\ErrorHandler\Tests\Fixtures\StringErrorCodeException;
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
Expand Down Expand Up @@ -197,6 +198,15 @@ public function testFile(\Throwable $exception)
$this->assertSame($exception->getFile(), $flattened->getFile());
}

/**
* @dataProvider stringAndIntDataProvider
*/
public function testCode(\Throwable $exception)
{
$flattened = FlattenException::createFromThrowable($exception);
$this->assertSame($exception->getCode(), $flattened->getCode());
}

/**
* @dataProvider flattenDataProvider
*/
Expand Down Expand Up @@ -238,6 +248,14 @@ public function flattenDataProvider(): array
];
}

public function stringAndIntDataProvider(): array
{
return [
[new \Exception('test1', 123)],
[new StringErrorCodeException('test2', '42S02')],
];
}

public function testArguments()
{
if (\PHP_VERSION_ID >= 70400) {
Expand Down
@@ -0,0 +1,13 @@
<?php

namespace Symfony\Component\ErrorHandler\Tests\Fixtures;

class StringErrorCodeException extends \Exception
{

public function __construct(string $message, string $code) {
parent::__construct($message);
$this->code = $code;
}

}

0 comments on commit 0f22e07

Please sign in to comment.