8000 Remove int return type from FlattenException::getCode by wucdbm · Pull Request #35993 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Remove int return type from FlattenException::getCode #35993

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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