Skip to content

Commit 55eaac9

Browse files
Merge branch '4.4' into 5.2
* 4.4: Switched to non-null defaults in exception constructors [Routing] fix conflict with param named class in attribute [Cache] fix setting items' metadata on commit()
2 parents e6abf97 + 64dd49d commit 55eaac9

32 files changed

+102
-87
lines changed

Exception/AccessDeniedHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
class AccessDeniedHttpException extends HttpException
1919
{
2020
/**
21-
* @param string $message The internal exception message
22-
* @param \Throwable $previous The previous exception
23-
* @param int $code The internal exception code
21+
* @param string|null $message The internal exception message
22+
* @param \Throwable|null $previous The previous exception
23+
* @param int $code The internal exception code
2424
*/
25-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
25+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2626
{
2727
parent::__construct(403, $message, $previous, $headers, $code);
2828
}

Exception/BadRequestHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
class BadRequestHttpException extends HttpException
1818
{
1919
/**
20-
* @param string $message The internal exception message
21-
* @param \Throwable $previous The previous exception
22-
* @param int $code The internal exception code
20+
* @param string|null $message The internal exception message
21+
* @param \Throwable|null $previous The previous exception
22+
* @param int $code The internal exception code
2323
*/
24-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
24+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2525
{
2626
parent::__construct(400, $message, $previous, $headers, $code);
2727
}

Exception/ConflictHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
class ConflictHttpException extends HttpException
1818
{
1919
/**
20-
* @param string $message The internal exception message
21-
* @param \Throwable $previous The previous exception
22-
* @param int $code The internal exception code
20+
* @param string|null $message The internal exception message
21+
* @param \Throwable|null $previous The previous exception
22+
* @param int $code The internal exception code
2323
*/
24-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
24+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2525
{
2626
parent::__construct(409, $message, $previous, $headers, $code);
2727
}

Exception/GoneHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
class GoneHttpException extends HttpException
1818
{
1919
/**
20-
* @param string $message The internal exception message
21-
* @param \Throwable $previous The previous exception
22-
* @param int $code The internal exception code
20+
* @param string|null $message The internal exception message
21+
* @param \Throwable|null $previous The previous exception
22+
* @param int $code The internal exception code
2323
*/
24-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
24+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2525
{
2626
parent::__construct(410, $message, $previous, $headers, $code);
2727
}

Exception/HttpException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class HttpException extends \RuntimeException implements HttpExceptionInterface
2121
private $statusCode;
2222
private $headers;
2323

24-
public function __construct(int $statusCode, string $message = null, \Throwable $previous = null, array $headers = [], ?int $code = 0)
24+
public function __construct(int $statusCode, ?string $message = '', \Throwable $previous = null, array $headers = [], ?int $code = 0)
2525
{
2626
$this->statusCode = $statusCode;
2727
$this->headers = $headers;

Exception/LengthRequiredHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
class LengthRequiredHttpException extends HttpException
1818
{
1919
/**
20-
* @param string $message The internal exception message
21-
* @param \Throwable $previous The previous exception
22-
* @param int $code The internal exception code
20+
* @param string|null $message The internal exception message
21+
* @param \Throwable|null $previous The previous exception
22+
* @param int $code The internal exception code
2323
*/
24-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
24+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2525
{
2626
parent::__construct(411, $message, $previous, $headers, $code);
2727
}

Exception/MethodNotAllowedHttpException.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
class MethodNotAllowedHttpException extends HttpException
1818
{
1919
/**
20-
* @param array $allow An array of allowed methods
21-
* @param string $message The internal exception message
22-
* @param \Throwable $previous The previous exception
23-
* @param int $code The internal exception code
20+
* @param string[] $allow An array of allowed methods
21+
* @param string|null $message The internal exception message
22+
* @param \Throwable|null $previous The previous exception
23+
* @param int|null $code The internal exception code
2424
*/
25-
public function __construct(array $allow, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
25+
public function __construct(array $allow, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = [])
2626
{
2727
$headers['Allow'] = strtoupper(implode(', ', $allow));
2828

Exception/NotAcceptableHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
class NotAcceptableHttpException extends HttpException
1818
{
1919
/**
20-
* @param string $message The internal exception message
21-
* @param \Throwable $previous The previous exception
22-
* @param int $code The internal exception code
20+
* @param string|null $message The internal exception message
21+
* @param \Throwable|null $previous The previous exception
22+
* @param int $code The internal exception code
2323
*/
24-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
24+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2525
{
2626
parent::__construct(406, $message, $previous, $headers, $code);
2727
}

Exception/NotFoundHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
class NotFoundHttpException extends HttpException
1818
{
1919
/**
20-
* @param string $message The internal exception message
21-
* @param \Throwable $previous The previous exception
22-
* @param int $code The internal exception code
20+
* @param string|null $message The internal exception message
21+
* @param \Throwable|null $previous The previous exception
22+
* @param int $code The internal exception code
2323
*/
24-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
24+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2525
{
2626
parent::__construct(404, $message, $previous, $headers, $code);
2727
}

Exception/PreconditionFailedHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
class PreconditionFailedHttpException extends HttpException
1818
{
1919
/**
20-
* @param string $message The internal exception message
21-
* @param \Throwable $previous The previous exception
22-
* @param int $code The internal exception code
20+
* @param string|null $message The internal exception message
21+
* @param \Throwable|null $previous The previous exception
22+
* @param int $code The internal exception code
2323
*/
24-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
24+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2525
{
2626
parent::__construct(412, $message, $previous, $headers, $code);
2727
}

Exception/PreconditionRequiredHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
class PreconditionRequiredHttpException extends HttpException
2020
{
2121
/**
22-
* @param string $message The internal exception message
23-
* @param \Throwable $previous The previous exception
24-
* @param int $code The internal exception code
22+
* @param string|null $message The internal exception message
23+
* @param \Throwable|null $previous The previous exception
24+
* @param int $code The internal exception code
2525
*/
26-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
26+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2727
{
2828
parent::__construct(428, $message, $previous, $headers, $code);
2929
}

Exception/ServiceUnavailableHttpException.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
class ServiceUnavailableHttpException extends HttpException
1818
{
1919
/**
20-
* @param int|string $retryAfter The number of seconds or HTTP-date after which the request may be retried
21-
* @param string $message The internal exception message
22-
* @param \Throwable $previous The previous exception
23-
* @param int $code The internal exception code
20+
* @param int|string|null $retryAfter The number of seconds or HTTP-date after which the request may be retried
21+
* @param string|null $message The internal exception message
22+
* @param \Throwable|null $previous The previous exception
23+
* @param int|null $code The internal exception code
2424
*/
25-
public function __construct($retryAfter = null, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
25+
public function __construct($retryAfter = null, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = [])
2626
{
2727
if ($retryAfter) {
2828
$headers['Retry-After'] = $retryAfter;

Exception/TooManyRequestsHttpException.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@
1919
class TooManyRequestsHttpException extends HttpException
2020
{
2121
/**
22-
* @param int|string $retryAfter The number of seconds or HTTP-date after which the request may be retried
23-
* @param string $message The internal exception message
24-
* @param \Throwable $previous The previous exception
25-
* @param int $code The internal exception code
22+
* @param int|string|null $retryAfter The number of seconds or HTTP-date after which the request may be retried
23+
* @param string|null $message The internal exception message
24+
* @param \Throwable|null $previous The previous exception
25+
* @param int|null $code The internal exception code
2626
*/
27-
public function __construct($retryAfter = null, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
27+
public function __construct($retryAfter = null, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = [])
2828
{
2929
if ($retryAfter) {
3030
$headers['Retry-After'] = $retryAfter;

Exception/UnauthorizedHttpException.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
class UnauthorizedHttpException extends HttpException
1818
{
1919
/**
20-
* @param string $challenge WWW-Authenticate challenge string
21-
* @param string $message The internal exception message
22-
* @param \Throwable $previous The previous exception
23-
* @param int $code The internal exception code
20+
* @param string $challenge WWW-Authenticate challenge string
21+
* @param string|null $message The internal exception message
22+
* @param \Throwable|null $previous The previous exception
23+
* @param int|null $code The internal exception code
2424
*/
25-
public function __construct(string $challenge, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
25+
public function __construct(string $challenge, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = [])
2626
{
2727
$headers['WWW-Authenticate'] = $challenge;
2828

Exception/UnprocessableEntityHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
class UnprocessableEntityHttpException extends HttpException
1818
{
1919
/**
20-
* @param string $message The internal exception message
21-
* @param \Throwable $previous The previous exception
22-
* @param int $code The internal exception code
20+
* @param string|null $message The internal exception message
21+
* @param \Throwable|null $previous The previous exception
22+
* @param int $code The internal exception code
2323
*/
24-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
24+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2525
{
2626
parent::__construct(422, $message, $previous, $headers, $code);
2727
}

Exception/UnsupportedMediaTypeHttpException.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
class UnsupportedMediaTypeHttpException extends HttpException
1818
{
1919
/**
20-
* @param string $message The internal exception message
21-
* @param \Throwable $previous The previous exception
22-
* @param int $code The internal exception code
20+
* @param string|null $message The internal exception message
21+
* @param \Throwable|null $previous The previous exception
22+
* @param int $code The internal exception code
2323
*/
24-
public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = [])
24+
public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = [])
2525
{
2626
parent::__construct(415, $message, $previous, $headers, $code);
2727
}

Tests/Exception/AccessDeniedHttpExceptionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace Symfony\Component\HttpKernel\Tests\Exception;
44

55
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
6+
use Symfony\Component\HttpKernel\Exception\HttpException;
67

78
class AccessDeniedHttpExceptionTest extends HttpExceptionTest
89
{
9-
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
10+
protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException
1011
{
1112
return new AccessDeniedHttpException($message, $previous, $code, $headers);
1213
}

Tests/Exception/BadRequestHttpExceptionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace Symfony\Component\HttpKernel\Tests\Exception;
44

55
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
6+
use Symfony\Component\HttpKernel\Exception\HttpException;
67

78
class BadRequestHttpExceptionTest extends HttpExceptionTest
89
{
9-
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
10+
protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException
1011
{
1112
return new BadRequestHttpException($message, $previous, $code, $headers);
1213
}

Tests/Exception/ConflictHttpExceptionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace Symfony\Component\HttpKernel\Tests\Exception;
44

55
use Symfony\Component\HttpKernel\Exception\ConflictHttpException;
6+
use Symfony\Component\HttpKernel\Exception\HttpException;
67

78
class ConflictHttpExceptionTest extends HttpExceptionTest
89
{
9-
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
10+
protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException
1011
{
1112
return new ConflictHttpException($message, $previous, $code, $headers);
1213
}

Tests/Exception/GoneHttpExceptionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
namespace Symfony\Component\HttpKernel\Tests\Exception;
44

55
use Symfony\Component\HttpKernel\Exception\GoneHttpException;
6+
use Symfony\Component\HttpKernel\Exception\HttpException;
67

78
class GoneHttpExceptionTest extends HttpExceptionTest
89
{
9-
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
10+
protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException
1011
{
1112
return new GoneHttpException($message, $previous, $code, $headers);
1213
}

Tests/Exception/HttpExceptionTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testHeadersDefault()
3232
*/
3333
public function testHeadersConstructor($headers)
3434
{
35-
$exception = new HttpException(200, null, null, $headers);
35+
$exception = new HttpException(200, '', null, $headers);
3636
$this->assertSame($headers, $exception->getHeaders());
3737
}
3838

@@ -50,11 +50,11 @@ public function testThrowableIsAllowedForPrevious()
5050
{
5151
$previous = new class('Error of PHP 7+') extends \Error {
5252
};
53-
$exception = $this->createException(null, $previous);
53+
$exception = $this->createException('', $previous);
5454
$this->assertSame($previous, $exception->getPrevious());
5555
}
5656

57-
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
57+
protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException
5858
{
5959
return new HttpException(200, $message, $previous, $headers, $code);
6060
}

Tests/Exception/LengthRequiredHttpExceptionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
namespace Symfony\Component\HttpKernel\Tests\Exception;
44

5+
use Symfony\Component\HttpKernel\Exception\HttpException;
56
use Symfony\Component\HttpKernel\Exception\LengthRequiredHttpException;
67

78
class LengthRequiredHttpExceptionTest extends HttpExceptionTest
89
{
9-
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
10+
protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException
1011
{
1112
return new LengthRequiredHttpException($message, $previous, $code, $headers);
1213
}

Tests/Exception/MethodNotAllowedHttpExceptionTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Symfony\Component\HttpKernel\Tests\Exception;
44

5+
use Symfony\Component\HttpKernel\Exception\HttpException;
56
use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException;
67

78
class MethodNotAllowedHttpExceptionTest extends HttpExceptionTest
@@ -18,7 +19,7 @@ public function testWithHeaderConstruct()
1819
'Cache-Control' => 'public, s-maxage=1200',
1920
];
2021

21-
$exception = new MethodNotAllowedHttpException(['get'], null, null, null, $headers);
22+
$exception = new MethodNotAllowedHttpException(['get'], '', null, 0, $headers);
2223

2324
$headers['Allow'] = 'GET';
2425

@@ -35,7 +36,7 @@ public function testHeadersSetter($headers)
3536
$this->assertSame($headers, $exception->getHeaders());
3637
}
3738

38-
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
39+
protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException
3940
{
4041
return new MethodNotAllowedHttpException(['get'], $message, $previous, $code, $headers);
4142
}

Tests/Exception/NotAcceptableHttpExceptionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
namespace Symfony\Component\HttpKernel\Tests\Exception;
44

5+
use Symfony\Component\HttpKernel\Exception\HttpException;
56
use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException;
67

78
class NotAcceptableHttpExceptionTest extends HttpExceptionTest
89
{
9-
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
10+
protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException
1011
{
1112
return new NotAcceptableHttpException($message, $previous, $code, $headers);
1213
}

Tests/Exception/NotFoundHttpExceptionTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
namespace Symfony\Component\HttpKernel\Tests\Exception;
44

5+
use Symfony\Component\HttpKernel\Exception\HttpException;
56
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
67

78
class NotFoundHttpExceptionTest extends HttpExceptionTest
89
{
9-
protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = [])
10+
protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException
1011
{
1112
return new NotFoundHttpException($message, $previous, $code, $headers);
1213
}

0 commit comments

Comments
 (0)