Skip to content

Allow \Throwable $previous everywhere #34332

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
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 @@ -288,7 +288,7 @@ protected function stream(string $view, array $parameters = [], StreamedResponse
*
* @final
*/
protected function createNotFoundException(string $message = 'Not Found', \Exception $previous = null): NotFoundHttpException
protected function createNotFoundException(string $message = 'Not Found', \Throwable $previous = null): NotFoundHttpException
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Allowed because @final.

{
return new NotFoundHttpException($message, $previous);
}
Expand All @@ -304,7 +304,7 @@ protected function createNotFoundException(string $message = 'Not Found', \Excep
*
* @final
*/
protected function createAccessDeniedException(string $message = 'Access Denied.', \Exception $previous = null): AccessDeniedException
protected function createAccessDeniedException(string $message = 'Access Denied.', \Throwable $previous = null): AccessDeniedException
{
if (!class_exists(AccessDeniedException::class)) {
throw new \LogicException('You can not use the "createAccessDeniedException" method if the Security component is not available. Try running "composer require symfony/security-bundle".');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class FileLoaderImportCircularReferenceException extends LoaderLoadException
{
public function __construct(array $resources, int $code = null, \Exception $previous = null)
public function __construct(array $resources, int $code = null, \Throwable $previous = null)
{
$message = sprintf('Circular reference detected in "%s" ("%s" > "%s").', $this->varToString($resources[0]), implode('" > "', $resources), $resources[0]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class FileLocatorFileNotFoundException extends \InvalidArgumentException
{
private $paths;

public function __construct(string $message = '', int $code = 0, \Exception $previous = null, array $paths = [])
public function __construct(string $message = '', int $code = 0, \Throwable $previous = null, array $paths = [])
{
parent::__construct($message, $code, $previous);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class AutowiringFailedException extends RuntimeException
private $serviceId;
private $messageCallback;

public function __construct(string $serviceId, $message = '', int $code = 0, \Exception $previous = null)
public function __construct(string $serviceId, $message = '', int $code = 0, \Throwable $previous = null)
{
$this->serviceId = $serviceId;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class EnvParameterException extends InvalidArgumentException
{
public function __construct(array $envs, \Exception $previous = null, string $message = 'Incompatible use of dynamic environment variables "%s" found in parameters.')
public function __construct(array $envs, \Throwable $previous = null, string $message = 'Incompatible use of dynamic environment variables "%s" found in parameters.')
{
parent::__construct(sprintf($message, implode('", "', $envs)), 0, $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ParameterCircularReferenceException extends RuntimeException
{
private $parameters;

public function __construct(array $parameters, \Exception $previous = null)
public function __construct(array $parameters, \Throwable $previous = null)
{
parent::__construct(sprintf('Circular reference detected for parameter "%s" ("%s" > "%s").', $parameters[0], implode('" > "', $parameters), $parameters[0]), 0, $previous);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ class ParameterNotFoundException extends InvalidArgumentException implements Not
* @param string $key The requested parameter key
* @param string $sourceId The service id that references the non-existent parameter
* @param string $sourceKey The parameter key that references the non-existent parameter
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param string[] $alternatives Some parameter name alternatives
* @param string|null $nonNestedAlternative The alternative parameter name when the user expected dot notation for nested parameters
*/
public function __construct(string $key, string $sourceId = null, string $sourceKey = null, \Exception $previous = null, array $alternatives = [], string $nonNestedAlternative = null)
public function __construct(string $key, string $sourceId = null, string $sourceKey = null, \Throwable $previous = null, array $alternatives = [], string $nonNestedAlternative = null)
{
$this->key = $key;
$this->sourceId = $sourceId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ServiceCircularReferenceException extends RuntimeException
private $serviceId;
private $path;

public function __construct(string $serviceId, array $path, \Exception $previous = null)
public function __construct(string $serviceId, array $path, \Throwable $previous = null)
{
parent::__construct(sprintf('Circular reference detected for service "%s", path: "%s".', $serviceId, implode(' -> ', $path)), 0, $previous);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ServiceNotFoundException extends InvalidArgumentException implements NotFo
private $sourceId;
private $alternatives;

public function __construct(string $id, string $sourceId = null, \Exception $previous = null, array $alternatives = [], string $msg = null)
public function __construct(string $id, string $sourceId = null, \Throwable $previous = null, array $alternatives = [], string $msg = null)
{
if (null !== $msg) {
// no-op
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Dotenv/Exception/FormatException.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ final class FormatException extends \LogicException implements ExceptionInterfac
{
private $context;

public function __construct(string $message, FormatExceptionContext $context, int $code = 0, \Exception $previous = null)
public function __construct(string $message, FormatExceptionContext $context, int $code = 0, \Throwable $previous = null)
{
$this->context = $context;

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Dotenv/Exception/PathException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
final class PathException extends \RuntimeException implements ExceptionInterface
{
public function __construct(string $path, int $code = 0, \Exception $previous = null)
public function __construct(string $path, int $code = 0, \Throwable $previous = null)
{
parent::__construct(sprintf('Unable to read the "%s" environment file.', $path), $code, $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
class FileNotFoundException extends IOException
{
public function __construct(string $message = null, int $code = 0, \Exception $previous = null, string $path = null)
public function __construct(string $message = null, int $code = 0, \Throwable $previous = null, string $path = null)
{
if (null === $message) {
if (null === $path) {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Filesystem/Exception/IOException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class IOException extends \RuntimeException implements IOExceptionInterface
{
private $path;

public function __construct(string $message, int $code = 0, \Exception $previous = null, string $path = null)
public function __construct(string $message, int $code = 0, \Throwable $previous = null, string $path = null)
{
$this->path = $path;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class HttpTransportException extends TransportException
{
private $response;

public function __construct(string $message = null, ResponseInterface $response, int $code = 0, \Exception $previous = null)
public function __construct(string $message = null, ResponseInterface $response, int $code = 0, \Throwable $previous = null)
{
parent::__construct($message, $code, $previous);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class MethodNotAllowedException extends \RuntimeException implements ExceptionIn
{
protected $allowedMethods = [];

public function __construct(array $allowedMethods, string $message = null, int $code = 0, \Exception $previous = null)
public function __construct(array $allowedMethods, string $message = null, int $code = 0, \Throwable $previous = null)
{
$this->allowedMethods = array_map('strtoupper', $allowedMethods);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class AccessDeniedException extends RuntimeException
private $attributes = [];
private $subject;

public function __construct(string $message = 'Access Denied.', \Exception $previous = null)
public function __construct(string $message = 'Access Denied.', \Throwable $previous = null)
{
parent::__construct($message, 403, $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class CustomUserMessageAuthenticationException extends AuthenticationException

private $messageData = [];

public function __construct(string $message = '', array $messageData = [], int $code = 0, \Exception $previous = null)
public function __construct(string $message = '', array $messageData = [], int $code = 0, \Throwable $previous = null)
{
parent::__construct($message, $code, $previous);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
class LogoutException extends RuntimeException
{
public function __construct(string $message = 'Logout Exception', \Exception $previous = null)
public function __construct(string $message = 'Logout Exception', \Throwable $previous = null)
{
parent::__construct($message, 403, $previous);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ExtraAttributesException extends RuntimeException
{
private $extraAttributes;

public function __construct(array $extraAttributes, \Exception $previous = null)
public function __construct(array $extraAttributes, \Throwable $previous = null)
{
$msg = sprintf('Extra attributes are not allowed ("%s" are unknown).', implode('", "', $extraAttributes));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
class ThrowingCasterException extends \Exception
{
/**
* @param \Exception $prev The exception thrown from the caster
* @param \Throwable $prev The exception thrown from the caster
*/
public function __construct(\Exception $prev)
public function __construct(\Throwable $prev)
{
parent::__construct('Unexpected '.\get_class($prev).' thrown from a caster: '.$prev->getMessage(), 0, $prev);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Yaml/Exception/ParseException.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class ParseException extends RuntimeException
* @param string|null $parsedFile The file name where the error occurred
* @param \Exception|null $previous The previous exception
*/
public function __construct(string $message, int $parsedLine = -1, string $snippet = null, string $parsedFile = null, \Exception $previous = null)
public function __construct(string $message, int $parsedLine = -1, string $snippet = null, string $parsedFile = null, \Throwable $previous = null)
{
$this->parsedFile = $parsedFile;
$this->parsedLine = $parsedLine;
Expand Down