Skip to content
Permalink
Browse files

[HttpKernel] change $previous argument for HttpException to \Throwable

  • Loading branch information...
sGy1980de authored and fabpot committed Mar 27, 2019
1 parent 30b9617 commit 15cb4754e7b1f75ff5cd60c83bf3a24c62c5a5a2
Showing with 77 additions and 59 deletions.
  1. +2 −2 src/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php
  2. +2 −2 src/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php
  3. +2 −2 src/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php
  4. +2 −2 src/Symfony/Component/HttpKernel/Exception/GoneHttpException.php
  5. +1 −1 src/Symfony/Component/HttpKernel/Exception/HttpException.php
  6. +2 −2 src/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php
  7. +2 −2 src/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php
  8. +2 −2 src/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php
  9. +2 −2 src/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php
  10. +2 −2 src/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php
  11. +2 −2 src/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php
  12. +2 −2 src/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php
  13. +2 −2 src/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php
  14. +2 −2 src/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php
  15. +2 −2 src/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php
  16. +2 −2 src/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php
  17. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/AccessDeniedHttpExceptionTest.php
  18. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php
  19. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php
  20. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php
  21. +10 −2 src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php
  22. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php
  23. +5 −0 src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php
  24. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php
  25. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php
  26. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php
  27. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php
  28. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php
  29. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php
  30. +5 −0 src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php
  31. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php
  32. +2 −2 src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php
@@ -19,11 +19,11 @@ class AccessDeniedHttpException extends HttpException
{
/**
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(403, $message, $previous, $headers, $code);
}
@@ -18,11 +18,11 @@ class BadRequestHttpException extends HttpException
{
/**
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(400, $message, $previous, $headers, $code);
}
@@ -18,11 +18,11 @@ class ConflictHttpException extends HttpException
{
/**
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(409, $message, $previous, $headers, $code);
}
@@ -18,11 +18,11 @@ class GoneHttpException extends HttpException
{
/**
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(410, $message, $previous, $headers, $code);
}
@@ -21,7 +21,7 @@ class HttpException extends \RuntimeException implements HttpExceptionInterface
private $statusCode;
private $headers;
public function __construct(int $statusCode, string $message = null, \Exception $previous = null, array $headers = [], ?int $code = 0)
public function __construct(int $statusCode, string $message = null, \Throwable $previous = null, array $headers = [], ?int $code = 0)
{
$this->statusCode = $statusCode;
$this->headers = $headers;
@@ -18,11 +18,11 @@ class LengthRequiredHttpException extends HttpException
{
/**
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(411, $message, $previous, $headers, $code);
}
@@ -19,11 +19,11 @@ class MethodNotAllowedHttpException extends HttpException
/**
* @param array $allow An array of allowed methods
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(array $allow, string $message = null, \Exception $previous = null, ?int $code = 0, array $headers = [])
public function __construct(array $allow, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
$headers['Allow'] = strtoupper(implode(', ', $allow));
@@ -18,11 +18,11 @@ class NotAcceptableHttpException extends HttpException
{
/**
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(406, $message, $previous, $headers, $code);
}
@@ -18,11 +18,11 @@ class NotFoundHttpException extends HttpException
{
/**
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(404, $message, $previous, $headers, $code);
}
@@ -18,11 +18,11 @@ class PreconditionFailedHttpException extends HttpException
{
/**
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(412, $message, $previous, $headers, $code);
}
@@ -20,11 +20,11 @@ class PreconditionRequiredHttpException extends HttpException
{
/**
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(428, $message, $previous, $headers, $code);
}
@@ -19,11 +19,11 @@ class ServiceUnavailableHttpException extends HttpException
/**
* @param int|string $retryAfter The number of seconds or HTTP-date after which the request may be retried
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct($retryAfter = null, string $message = null, \Exception $previous = null, ?int $code = 0, array $headers = [])
public function __construct($retryAfter = null, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
if ($retryAfter) {
$headers['Retry-After'] = $retryAfter;
@@ -21,11 +21,11 @@ class TooManyRequestsHttpException extends HttpException
/**
* @param int|string $retryAfter The number of seconds or HTTP-date after which the request may be retried
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct($retryAfter = null, string $message = null, \Exception $previous = null, ?int $code = 0, array $headers = [])
public function __construct($retryAfter = null, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
if ($retryAfter) {
$headers['Retry-After'] = $retryAfter;
@@ -19,11 +19,11 @@ class UnauthorizedHttpException extends HttpException
/**
* @param string $challenge WWW-Authenticate challenge string
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $challenge, string $message = null, \Exception $previous = null, ?int $code = 0, array $headers = [])
public function __construct(string $challenge, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
$headers['WWW-Authenticate'] = $challenge;
@@ -18,11 +18,11 @@ class UnprocessableEntityHttpException extends HttpException
{
/**
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(422, $message, $previous, $headers, $code);
}
@@ -18,11 +18,11 @@ class UnsupportedMediaTypeHttpException extends HttpException
{
/**
* @param string $message The internal exception message
* @param \Exception $previous The previous exception
* @param \Throwable $previous The previous exception
* @param int $code The internal exception code
* @param array $headers
*/
public function __construct(string $message = null, \Exception $previous = null, int $code = 0, array $headers = [])
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
{
parent::__construct(415, $message, $previous, $headers, $code);
}
@@ -6,8 +6,8 @@
class AccessDeniedHttpExceptionTest extends HttpExceptionTest
{
protected function createException()
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new AccessDeniedHttpException();
return new AccessDeniedHttpException($message, $previous, $code, $headers);
}
}
@@ -6,8 +6,8 @@
class BadRequestHttpExceptionTest extends HttpExceptionTest
{
protected function createException()
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new BadRequestHttpException();
return new BadRequestHttpException($message, $previous, $code, $headers);
}
}
@@ -6,8 +6,8 @@
class ConflictHttpExceptionTest extends HttpExceptionTest
{
protected function createException()
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new ConflictHttpException();
return new ConflictHttpException($message, $previous, $code, $headers);
}
}
@@ -6,8 +6,8 @@
class GoneHttpExceptionTest extends HttpExceptionTest
{
protected function createException()
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new GoneHttpException();
return new GoneHttpException($message, $previous, $code, $headers);
}
}
@@ -46,8 +46,16 @@ public function testHeadersSetter($headers)
$this->assertSame($headers, $exception->getHeaders());
}
protected function createException()
public function testThrowableIsAllowedForPrevious()
{
return new HttpException(200);
$previous = new class('Error of PHP 7+') extends \Error {
};
$exception = $this->createException(null, $previous);
$this->assertSame($previous, $exception->getPrevious());
}
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new HttpException(200, $message, $previous, $headers, $code);
}
}
@@ -6,8 +6,8 @@
class LengthRequiredHttpExceptionTest extends HttpExceptionTest
{
protected function createException()
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new LengthRequiredHttpException();
return new LengthRequiredHttpException($message, $previous, $code, $headers);
}
}
@@ -34,4 +34,9 @@ public function testHeadersSetter($headers)
$exception->setHeaders($headers);
$this->assertSame($headers, $exception->getHeaders());
}
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new MethodNotAllowedHttpException(['get'], $message, $previous, $code, $headers);
}
}
@@ -6,8 +6,8 @@
class NotAcceptableHttpExceptionTest extends HttpExceptionTest
{
protected function createException()
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new NotAcceptableHttpException();
return new NotAcceptableHttpException($message, $previous, $code, $headers);
}
}
@@ -6,8 +6,8 @@
class NotFoundHttpExceptionTest extends HttpExceptionTest
{
protected function createException()
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new NotFoundHttpException();
return new NotFoundHttpException($message, $previous, $code, $headers);
}
}
@@ -6,8 +6,8 @@
class PreconditionFailedHttpExceptionTest extends HttpExceptionTest
{
protected function createException()
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new PreconditionFailedHttpException();
return new PreconditionFailedHttpException($message, $previous, $code, $headers);
}
}
@@ -6,8 +6,8 @@
class PreconditionRequiredHttpExceptionTest extends HttpExceptionTest
{
protected function createException()
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new PreconditionRequiredHttpException();
return new PreconditionRequiredHttpException($message, $previous, $code, $headers);
}
}
@@ -35,8 +35,8 @@ public function testHeadersSetter($headers)
$this->assertSame($headers, $exception->getHeaders());
}
protected function createException()
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new ServiceUnavailableHttpException();
return new ServiceUnavailableHttpException(null, $message, $previous, $code, $headers);
}
}
@@ -35,8 +35,8 @@ public function testHeadersSetter($headers)
$this->assertSame($headers, $exception->getHeaders());
}
protected function createException()
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new TooManyRequestsHttpException();
return new TooManyRequestsHttpException(null, $message, $previous, $code, $headers);
}
}
@@ -34,4 +34,9 @@ public function testHeadersSetter($headers)
$exception->setHeaders($headers);
$this->assertSame($headers, $exception->getHeaders());
}
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new UnauthorizedHttpException('Challenge', $message, $previous, $code, $headers);
}
}
@@ -6,8 +6,8 @@
class UnprocessableEntityHttpExceptionTest extends HttpExceptionTest
{
protected function createException()
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
{
return new UnprocessableEntityHttpException();
return new UnprocessableEntityHttpException($message, $previous, $code, $headers);
}
}

0 comments on commit 15cb475

Please sign in to comment.
You can’t perform that action at this time.