8000 Remove int return type from FlattenException::getCode · symfony/symfony@0f22e07 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0f22e07

Browse files
wucdbmfabpot
authored andcommitted
Remove int return type from FlattenException::getCode
1 parent ff30b43 commit 0f22e07

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

src/Symfony/Component/ErrorHandler/Exception/FlattenException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public function setMessage($message): self
206206
return $this;
207207
}
208208

209-
public function getCode(): int
209+
public function getCode()
210210
{
211211
return $this->code;
212212
}

src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Component\Debug\Exception\FatalThrowableError;
1616
use Symfony\Component\ErrorHandler\Exception\FlattenException;
17+
use Symfony\Component\ErrorHandler\Tests\Fixtures\StringErrorCodeException;
1718
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
1819
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
1920
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
@@ -197,6 +198,15 @@ public function testFile(\Throwable $exception)
197198
$this->assertSame($exception->getFile(), $flattened->getFile());
198199
}
199200

201+
/**
202+
* @dataProvider stringAndIntDataProvider
203+
*/
204+
public function testCode(\Throwable $exception)
205+
{
206+
$flattened = FlattenException::createFromThrowable($exception);
207+
$this->assertSame($exception->getCode(), $flattened->getCode());
208+
}
209+
200210
/**
201211
* @dataProvider flattenDataProvider
202212
*/
@@ -238,6 +248,14 @@ public function flattenDataProvider(): array
238248
];
239249
}
240250

251+
public function stringAndIntDataProvider(): array
252+
{
253+
return [
254+
[new \Exception('test1', 123)],
255+
[new StringErrorCodeException('test2', '42S02')],
256+
];
257+
}
258+
241259
public function testArguments()
242260
{
243261
if (\PHP_VERSION_ID >= 70400) {
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
namespace Symfony\Component\ErrorHandler\Tests\Fixtures;
4+
5+
class StringErrorCodeException extends \Exception
6+
{
7+
8+
public function __construct(string $message, string $code) {
9+
parent::__construct($message);
10+
$this->code = $code;
11+
}
12+
13+
}

0 commit comments

Comments
 (0)
0