diff --git a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php index 36533e12f0..5bdf54565d 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php +++ b/src/Symfony/Bundle/FrameworkBundle/Routing/DelegatingLoader.php @@ -61,7 +61,7 @@ class DelegatingLoader extends BaseDelegatingLoader // - this handles the case and prevents the second fatal error // by triggering an exception beforehand. - throw new LoaderLoadException($resource, null, null, null, $type); + throw new LoaderLoadException($resource, null, 0, null, $type); } $this->loading = true; diff --git a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php index ae3116ed8d..5a0cb1c0d2 100644 --- a/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/AbstractTagAwareAdapter.php @@ -110,6 +110,7 @@ abstract class AbstractTagAwareAdapter implements TagAwareAdapterInterface, TagA } $byLifetime[$ttl][$getId($key)] = $value; + $item->metadata = $item->newMetadata; } return $byLifetime; diff --git a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php index 7f1677e400..2ee3e367b9 100644 --- a/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php +++ b/src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php @@ -83,6 +83,7 @@ class TagAwareAdapter implements TagAwareAdapterInterface, TagAwareCacheInterfac $tagsByKey = []; foreach ($deferred as $key => $item) { $tagsByKey[$key] = $item->newMetadata[CacheItem::METADATA_TAGS] ?? []; + $item->metadata = $item->newMetadata; } return $tagsByKey; diff --git a/src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php index a9f3407eae..393210e16e 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/FilesystemTagAwareAdapterTest.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\FilesystemTagAwareAdapter; -use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait; /** * @group time-sensitive diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php index dbd93bdd71..3540155685 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\PdoAdapter; -use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; /** * @group time-sensitive diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php index 82441bdbc4..0e5dd36bfb 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoDbalAdapterTest.php @@ -17,7 +17,6 @@ use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\Schema\Schema; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\PdoAdapter; -use Symfony\Component\Cache\Tests\Traits\PdoPruneableTrait; /** * @group time-sensitive diff --git a/src/Symfony/Component/Cache/Tests/Traits/PdoPruneableTrait.php b/src/Symfony/Component/Cache/Tests/Adapter/PdoPruneableTrait.php similarity index 95% rename from src/Symfony/Component/Cache/Tests/Traits/PdoPruneableTrait.php rename to src/Symfony/Component/Cache/Tests/Adapter/PdoPruneableTrait.php index baca2df8b3..23f977fd6e 100644 --- a/src/Symfony/Component/Cache/Tests/Traits/PdoPruneableTrait.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PdoPruneableTrait.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Cache\Tests\Traits; +namespace Symfony\Component\Cache\Tests\Adapter; trait PdoPruneableTrait { diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php index c072be952f..6cffbde792 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareAdapterTest.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; -use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait; /** * @group integration diff --git a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php index 9b05edd915..21120d606a 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareClusterAdapterTest.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; -use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait; /** * @group integration diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php index 0e73e81e87..5c82016be2 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareAdapterTest.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; -use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait; use Symfony\Component\Cache\Traits\RedisProxy; /** diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php index 5527789d79..3ec500a901 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareArrayAdapterTest.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; -use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait; /** * @group integration diff --git a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php index e527223fd7..50f078c04d 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/RedisTagAwareClusterAdapterTest.php @@ -13,7 +13,6 @@ namespace Symfony\Component\Cache\Tests\Adapter; use Psr\Cache\CacheItemPoolInterface; use Symfony\Component\Cache\Adapter\RedisTagAwareAdapter; -use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait; use Symfony\Component\Cache\Traits\RedisClusterProxy; /** diff --git a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php index a3d157d7df..e96db881d0 100644 --- a/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareAdapterTest.php @@ -19,7 +19,6 @@ use Symfony\Component\Cache\Adapter\ArrayAdapter; use Symfony\Component\Cache\Adapter\FilesystemAdapter; use Symfony\Component\Cache\Adapter\TagAwareAdapter; use Symfony\Component\Cache\Tests\Fixtures\PrunableAdapter; -use Symfony\Component\Cache\Tests\Traits\TagAwareTestTrait; use Symfony\Component\Filesystem\Filesystem; /** diff --git a/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareTestTrait.php similarity index 96% rename from src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php rename to src/Symfony/Component/Cache/Tests/Adapter/TagAwareTestTrait.php index 21119dece1..2ea5021084 100644 --- a/src/Symfony/Component/Cache/Tests/Traits/TagAwareTestTrait.php +++ b/src/Symfony/Component/Cache/Tests/Adapter/TagAwareTestTrait.php @@ -9,7 +9,7 @@ * file that was distributed with this source code. */ -namespace Symfony\Component\Cache\Tests\Traits; +namespace Symfony\Component\Cache\Tests\Adapter; use Symfony\Component\Cache\CacheItem; @@ -136,7 +136,9 @@ trait TagAwareTestTrait $pool = $this->createCachePool(); $i = $pool->getItem('k'); + $this->assertSame([], $i->getMetadata()); $pool->save($i->tag('foo')); + $this->assertSame(['foo' => 'foo'], $i->getMetadata()[CacheItem::METADATA_TAGS]); $i = $pool->getItem('k'); $this->assertSame(['foo' => 'foo'], $i->getMetadata()[CacheItem::METADATA_TAGS]); diff --git a/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php b/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php index 8c5e736524..aa27f9869b 100644 --- a/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php +++ b/src/Symfony/Component/Config/Exception/FileLoaderImportCircularReferenceException.php @@ -18,7 +18,7 @@ namespace Symfony\Component\Config\Exception; */ class FileLoaderImportCircularReferenceException extends LoaderLoadException { - public function __construct(array $resources, int $code = null, \Throwable $previous = null) + public function __construct(array $resources, ?int $code = 0, \Throwable $previous = null) { $message = sprintf('Circular reference detected in "%s" ("%s" > "%s").', $this->varToString($resources[0]), implode('" > "', $resources), $resources[0]); diff --git a/src/Symfony/Component/Config/Loader/DelegatingLoader.php b/src/Symfony/Component/Config/Loader/DelegatingLoader.php index 2ec64cb021..e5a74ee63b 100644 --- a/src/Symfony/Component/Config/Loader/DelegatingLoader.php +++ b/src/Symfony/Component/Config/Loader/DelegatingLoader.php @@ -34,7 +34,7 @@ class DelegatingLoader extends Loader public function load($resource, string $type = null) { if (false === $loader = $this->resolver->resolve($resource, $type)) { - throw new LoaderLoadException($resource, null, null, null, $type); + throw new LoaderLoadException($resource, null, 0, null, $type); } return $loader->load($resource, $type); diff --git a/src/Symfony/Component/Config/Loader/FileLoader.php b/src/Symfony/Component/Config/Loader/FileLoader.php index 0b01df49f3..5979f4c4fb 100644 --- a/src/Symfony/Component/Config/Loader/FileLoader.php +++ b/src/Symfony/Component/Config/Loader/FileLoader.php @@ -170,7 +170,7 @@ abstract class FileLoader extends Loader throw $e; } - throw new LoaderLoadException($resource, $sourceResource, null, $e, $type); + throw new LoaderLoadException($resource, $sourceResource, 0, $e, $type); } } diff --git a/src/Symfony/Component/Config/Loader/Loader.php b/src/Symfony/Component/Config/Loader/Loader.php index 62cae685e2..3969d9fa1e 100644 --- a/src/Symfony/Component/Config/Loader/Loader.php +++ b/src/Symfony/Component/Config/Loader/Loader.php @@ -70,7 +70,7 @@ abstract class Loader implements LoaderInterface $loader = null === $this->resolver ? false : $this->resolver->resolve($resource, $type); if (false === $loader) { - throw new LoaderLoadException($resource, null, null, null, $type); + throw new LoaderLoadException($resource, null, 0, null, $type); } return $loader; diff --git a/src/Symfony/Component/Config/Tests/Exception/LoaderLoadExceptionTest.php b/src/Symfony/Component/Config/Tests/Exception/LoaderLoadExceptionTest.php index 60650c3daf..67c40edd2c 100644 --- a/src/Symfony/Component/Config/Tests/Exception/LoaderLoadExceptionTest.php +++ b/src/Symfony/Component/Config/Tests/Exception/LoaderLoadExceptionTest.php @@ -24,13 +24,13 @@ class LoaderLoadExceptionTest extends TestCase public function testMessageCannotLoadResourceWithType() { - $exception = new LoaderLoadException('resource', null, null, null, 'foobar'); + $exception = new LoaderLoadException('resource', null, 0, null, 'foobar'); $this->assertEquals('Cannot load resource "resource". Make sure there is a loader supporting the "foobar" type.', $exception->getMessage()); } public function testMessageCannotLoadResourceWithAnnotationType() { - $exception = new LoaderLoadException('resource', null, null, null, 'annotation'); + $exception = new LoaderLoadException('resource', null, 0, null, 'annotation'); $this->assertEquals('Cannot load resource "resource". Make sure annotations are installed and enabled.', $exception->getMessage()); } @@ -56,7 +56,7 @@ class LoaderLoadExceptionTest extends TestCase $exception = new LoaderLoadException( 'resource', null, - null, + 0, new \Exception('There was a previous error with an ending dot.') ); $this->assertEquals( @@ -70,7 +70,7 @@ class LoaderLoadExceptionTest extends TestCase $exception = new LoaderLoadException( 'resource', null, - null, + 0, new \Exception('There was a previous error with no ending dot') ); $this->assertEquals( @@ -84,7 +84,7 @@ class LoaderLoadExceptionTest extends TestCase $exception = new LoaderLoadException( '@resource', null, - null, + 0, new \Exception('There was a previous error with an ending dot.') ); $this->assertEquals( diff --git a/src/Symfony/Component/Console/Exception/CommandNotFoundException.php b/src/Symfony/Component/Console/Exception/CommandNotFoundException.php index 69d5cb996a..590a71c779 100644 --- a/src/Symfony/Component/Console/Exception/CommandNotFoundException.php +++ b/src/Symfony/Component/Console/Exception/CommandNotFoundException.php @@ -21,10 +21,10 @@ class CommandNotFoundException extends \InvalidArgumentException implements Exce private $alternatives; /** - * @param string $message Exception message to throw - * @param array $alternatives List of similar defined names - * @param int $code Exception code - * @param \Throwable $previous Previous exception used for the exception chaining + * @param string $message Exception message to throw + * @param string[] $alternatives List of similar defined names + * @param int $code Exception code + * @param \Throwable|null $previous Previous exception used for the exception chaining */ public function __construct(string $message, array $alternatives = [], int $code = 0, \Throwable $previous = null) { @@ -34,7 +34,7 @@ class CommandNotFoundException extends \InvalidArgumentException implements Exce } /** - * @return array A list of similar defined names + * @return string[] A list of similar defined names */ public function getAlternatives() { diff --git a/src/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php b/src/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php index 65e5f8c786..f0c81111db 100644 --- a/src/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/AccessDeniedHttpException.php @@ -18,11 +18,11 @@ namespace Symfony\Component\HttpKernel\Exception; class AccessDeniedHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(403, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php b/src/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php index 7de91054b4..8eccce1e16 100644 --- a/src/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/BadRequestHttpException.php @@ -17,11 +17,11 @@ namespace Symfony\Component\HttpKernel\Exception; class BadRequestHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(400, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php b/src/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php index ebb86ba6e9..72b8aa1274 100644 --- a/src/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/ConflictHttpException.php @@ -17,11 +17,11 @@ namespace Symfony\Component\HttpKernel\Exception; class ConflictHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(409, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/GoneHttpException.php b/src/Symfony/Component/HttpKernel/Exception/GoneHttpException.php index aea283a961..6bba8159a2 100644 --- a/src/Symfony/Component/HttpKernel/Exception/GoneHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/GoneHttpException.php @@ -17,11 +17,11 @@ namespace Symfony\Component\HttpKernel\Exception; class GoneHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(410, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/HttpException.php b/src/Symfony/Component/HttpKernel/Exception/HttpException.php index d822cd5d49..f3c0c3362f 100644 --- a/src/Symfony/Component/HttpKernel/Exception/HttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/HttpException.php @@ -21,7 +21,7 @@ class HttpException extends \RuntimeException implements HttpExceptionInterface private $statusCode; private $headers; - public function __construct(int $statusCode, string $message = null, \Throwable $previous = null, array $headers = [], ?int $code = 0) + public function __construct(int $statusCode, ?string $message = '', \Throwable $previous = null, array $headers = [], ?int $code = 0) { $this->statusCode = $statusCode; $this->headers = $headers; diff --git a/src/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php b/src/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php index 44fb770b60..92f9c74daf 100644 --- a/src/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/LengthRequiredHttpException.php @@ -17,11 +17,11 @@ namespace Symfony\Component\HttpKernel\Exception; class LengthRequiredHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(411, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php b/src/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php index c15e46ffc3..665ae355b4 100644 --- a/src/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/MethodNotAllowedHttpException.php @@ -17,12 +17,12 @@ namespace Symfony\Component\HttpKernel\Exception; class MethodNotAllowedHttpException extends HttpException { /** - * @param array $allow An array of allowed methods - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string[] $allow An array of allowed methods + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int|null $code The internal exception code */ - public function __construct(array $allow, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + public function __construct(array $allow, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = []) { $headers['Allow'] = strtoupper(implode(', ', $allow)); diff --git a/src/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php b/src/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php index c5f5324b1a..a985e86b9b 100644 --- a/src/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/NotAcceptableHttpException.php @@ -17,11 +17,11 @@ namespace Symfony\Component\HttpKernel\Exception; class NotAcceptableHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(406, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php b/src/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php index 146b908a1e..3be305ee9e 100644 --- a/src/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/NotFoundHttpException.php @@ -17,11 +17,11 @@ namespace Symfony\Component\HttpKernel\Exception; class NotFoundHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(404, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php b/src/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php index e878b10ad3..bdedea143d 100644 --- a/src/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/PreconditionFailedHttpException.php @@ -17,11 +17,11 @@ namespace Symfony\Component\HttpKernel\Exception; class PreconditionFailedHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(412, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php b/src/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php index a6cb2f09a7..bc26804830 100644 --- a/src/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/PreconditionRequiredHttpException.php @@ -19,11 +19,11 @@ namespace Symfony\Component\HttpKernel\Exception; class PreconditionRequiredHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(428, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php b/src/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php index c786ccf5f7..1fb793dbf0 100644 --- a/src/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/ServiceUnavailableHttpException.php @@ -17,12 +17,12 @@ namespace Symfony\Component\HttpKernel\Exception; 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 \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param int|string|null $retryAfter The number of seconds or HTTP-date after which the request may be retried + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int|null $code The internal exception code */ - public function __construct($retryAfter = null, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + public function __construct($retryAfter = null, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = []) { if ($retryAfter) { $headers['Retry-After'] = $retryAfter; diff --git a/src/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php b/src/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php index b709f1a2f1..e1e47d048b 100644 --- a/src/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/TooManyRequestsHttpException.php @@ -19,12 +19,12 @@ namespace Symfony\Component\HttpKernel\Exception; 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 \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param int|string|null $retryAfter The number of seconds or HTTP-date after which the request may be retried + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int|null $code The internal exception code */ - public function __construct($retryAfter = null, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + public function __construct($retryAfter = null, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = []) { if ($retryAfter) { $headers['Retry-After'] = $retryAfter; diff --git a/src/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php b/src/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php index fb86c1ea95..ddb48f116f 100644 --- a/src/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/UnauthorizedHttpException.php @@ -17,12 +17,12 @@ namespace Symfony\Component\HttpKernel\Exception; class UnauthorizedHttpException extends HttpException { /** - * @param string $challenge WWW-Authenticate challenge string - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string $challenge WWW-Authenticate challenge string + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int|null $code The internal exception code */ - public function __construct(string $challenge, string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + public function __construct(string $challenge, ?string $message = '', \Throwable $previous = null, ?int $code = 0, array $headers = []) { $headers['WWW-Authenticate'] = $challenge; diff --git a/src/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php b/src/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php index 93d4bcef69..237340a574 100644 --- a/src/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/UnprocessableEntityHttpException.php @@ -17,11 +17,11 @@ namespace Symfony\Component\HttpKernel\Exception; class UnprocessableEntityHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(422, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php b/src/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php index 7cda3a6202..74ddbfccbc 100644 --- a/src/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php +++ b/src/Symfony/Component/HttpKernel/Exception/UnsupportedMediaTypeHttpException.php @@ -17,11 +17,11 @@ namespace Symfony\Component\HttpKernel\Exception; class UnsupportedMediaTypeHttpException extends HttpException { /** - * @param string $message The internal exception message - * @param \Throwable $previous The previous exception - * @param int $code The internal exception code + * @param string|null $message The internal exception message + * @param \Throwable|null $previous The previous exception + * @param int $code The internal exception code */ - public function __construct(string $message = null, \Throwable $previous = null, int $code = 0, array $headers = []) + public function __construct(?string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []) { parent::__construct(415, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/AccessDeniedHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/AccessDeniedHttpExceptionTest.php index 3a34cc47bc..6fa356e70d 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/AccessDeniedHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/AccessDeniedHttpExceptionTest.php @@ -3,10 +3,11 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; +use Symfony\Component\HttpKernel\Exception\HttpException; class AccessDeniedHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new AccessDeniedHttpException($message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php index 462fd9cb1d..231b406a9d 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/BadRequestHttpExceptionTest.php @@ -3,10 +3,11 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; +use Symfony\Component\HttpKernel\Exception\HttpException; class BadRequestHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new BadRequestHttpException($message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php index 760600a10f..c923df2ce9 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/ConflictHttpExceptionTest.php @@ -3,10 +3,11 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; use Symfony\Component\HttpKernel\Exception\ConflictHttpException; +use Symfony\Component\HttpKernel\Exception\HttpException; class ConflictHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new ConflictHttpException($message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php index 30dafe4922..dd84acac36 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/GoneHttpExceptionTest.php @@ -3,10 +3,11 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; use Symfony\Component\HttpKernel\Exception\GoneHttpException; +use Symfony\Component\HttpKernel\Exception\HttpException; class GoneHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new GoneHttpException($message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php index a9431f4b5a..827f0fce3c 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/HttpExceptionTest.php @@ -32,7 +32,7 @@ class HttpExceptionTest extends TestCase */ public function testHeadersConstructor($headers) { - $exception = new HttpException(200, null, null, $headers); + $exception = new HttpException(200, '', null, $headers); $this->assertSame($headers, $exception->getHeaders()); } @@ -50,11 +50,11 @@ class HttpExceptionTest extends TestCase { $previous = new class('Error of PHP 7+') extends \Error { }; - $exception = $this->createException(null, $previous); + $exception = $this->createException('', $previous); $this->assertSame($previous, $exception->getPrevious()); } - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new HttpException(200, $message, $previous, $headers, $code); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php index 8676d67238..dd74c81aaf 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/LengthRequiredHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\LengthRequiredHttpException; class LengthRequiredHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new LengthRequiredHttpException($message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php index efb0b50caf..8f657420ea 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/MethodNotAllowedHttpExceptionTest.php @@ -2,6 +2,7 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException; class MethodNotAllowedHttpExceptionTest extends HttpExceptionTest @@ -18,7 +19,7 @@ class MethodNotAllowedHttpExceptionTest extends HttpExceptionTest 'Cache-Control' => 'public, s-maxage=1200', ]; - $exception = new MethodNotAllowedHttpException(['get'], null, null, null, $headers); + $exception = new MethodNotAllowedHttpException(['get'], '', null, 0, $headers); $headers['Allow'] = 'GET'; @@ -35,7 +36,7 @@ class MethodNotAllowedHttpExceptionTest extends HttpExceptionTest $this->assertSame($headers, $exception->getHeaders()); } - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new MethodNotAllowedHttpException(['get'], $message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php index 021c69e289..6d163faa47 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/NotAcceptableHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\NotAcceptableHttpException; class NotAcceptableHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new NotAcceptableHttpException($message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php index 0bf369b1a0..cce9f697dd 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/NotFoundHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; class NotFoundHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new NotFoundHttpException($message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php index 04d79c499d..b75c560d9b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionFailedHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\PreconditionFailedHttpException; class PreconditionFailedHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new PreconditionFailedHttpException($message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php index 82076617a8..2b9c6777ba 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/PreconditionRequiredHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\PreconditionRequiredHttpException; class PreconditionRequiredHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new PreconditionRequiredHttpException($message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php index fac197c852..771e9492d0 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/ServiceUnavailableHttpExceptionTest.php @@ -2,6 +2,7 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\ServiceUnavailableHttpException; class ServiceUnavailableHttpExceptionTest extends HttpExceptionTest @@ -18,7 +19,7 @@ class ServiceUnavailableHttpExceptionTest extends HttpExceptionTest 'Cache-Control' => 'public, s-maxage=1337', ]; - $exception = new ServiceUnavailableHttpException(1337, null, null, null, $headers); + $exception = new ServiceUnavailableHttpException(1337, '', null, 0, $headers); $headers['Retry-After'] = 1337; @@ -35,7 +36,7 @@ class ServiceUnavailableHttpExceptionTest extends HttpExceptionTest $this->assertSame($headers, $exception->getHeaders()); } - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new ServiceUnavailableHttpException(null, $message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php index 8b59e9894a..7c2490b22e 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/TooManyRequestsHttpExceptionTest.php @@ -2,6 +2,7 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; class TooManyRequestsHttpExceptionTest extends HttpExceptionTest @@ -18,7 +19,7 @@ class TooManyRequestsHttpExceptionTest extends HttpExceptionTest 'Cache-Control' => 'public, s-maxage=69', ]; - $exception = new TooManyRequestsHttpException(69, null, null, null, $headers); + $exception = new TooManyRequestsHttpException(69, '', null, 0, $headers); $headers['Retry-After'] = 69; @@ -35,7 +36,7 @@ class TooManyRequestsHttpExceptionTest extends HttpExceptionTest $this->assertSame($headers, $exception->getHeaders()); } - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new TooManyRequestsHttpException(null, $message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php index 92d427b6e4..bd01079798 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/UnauthorizedHttpExceptionTest.php @@ -2,6 +2,7 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\UnauthorizedHttpException; class UnauthorizedHttpExceptionTest extends HttpExceptionTest @@ -18,7 +19,7 @@ class UnauthorizedHttpExceptionTest extends HttpExceptionTest 'Cache-Control' => 'public, s-maxage=1200', ]; - $exception = new UnauthorizedHttpException('Challenge', null, null, null, $headers); + $exception = new UnauthorizedHttpException('Challenge', '', null, 0, $headers); $headers['WWW-Authenticate'] = 'Challenge'; @@ -35,7 +36,7 @@ class UnauthorizedHttpExceptionTest extends HttpExceptionTest $this->assertSame($headers, $exception->getHeaders()); } - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new UnauthorizedHttpException('Challenge', $message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php index ffa4e177ee..b538a041dd 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/UnprocessableEntityHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\UnprocessableEntityHttpException; class UnprocessableEntityHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new UnprocessableEntityHttpException($message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php b/src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php index fa28bbd19b..4eeb3fa144 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Exception/UnsupportedMediaTypeHttpExceptionTest.php @@ -2,11 +2,12 @@ namespace Symfony\Component\HttpKernel\Tests\Exception; +use Symfony\Component\HttpKernel\Exception\HttpException; use Symfony\Component\HttpKernel\Exception\UnsupportedMediaTypeHttpException; class UnsupportedMediaTypeHttpExceptionTest extends HttpExceptionTest { - protected function createException(string $message = null, \Throwable $previous = null, ?int $code = 0, array $headers = []) + protected function createException(string $message = '', \Throwable $previous = null, int $code = 0, array $headers = []): HttpException { return new UnsupportedMediaTypeHttpException($message, $previous, $code, $headers); } diff --git a/src/Symfony/Component/Mailer/Exception/HttpTransportException.php b/src/Symfony/Component/Mailer/Exception/HttpTransportException.php index f672acc6f1..3428b70e07 100644 --- a/src/Symfony/Component/Mailer/Exception/HttpTransportException.php +++ b/src/Symfony/Component/Mailer/Exception/HttpTransportException.php @@ -20,7 +20,7 @@ class HttpTransportException extends TransportException { private $response; - public function __construct(string $message = null, ResponseInterface $response, int $code = 0, \Throwable $previous = null) + public function __construct(?string $message, ResponseInterface $response, int $code = 0, \Throwable $previous = null) { parent::__construct($message, $code, $previous); diff --git a/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php b/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php index b897081bd5..8a43714035 100644 --- a/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php +++ b/src/Symfony/Component/Routing/Exception/MethodNotAllowedException.php @@ -22,7 +22,10 @@ class MethodNotAllowedException extends \RuntimeException implements ExceptionIn { protected $allowedMethods = []; - public function __construct(array $allowedMethods, string $message = null, int $code = 0, \Throwable $previous = null) + /** + * @param string[] $allowedMethods + */ + public function __construct(array $allowedMethods, ?string $message = '', int $code = 0, \Throwable $previous = null) { $this->allowedMethods = array_map('strtoupper', $allowedMethods); @@ -32,7 +35,7 @@ class MethodNotAllowedException extends \RuntimeException implements ExceptionIn /** * Gets the allowed HTTP methods. * - * @return array + * @return string[] */ public function getAllowedMethods() { diff --git a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php index a80d9ab2df..bec7757a9a 100644 --- a/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php +++ b/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php @@ -97,10 +97,8 @@ class AnnotationFileLoader extends FileLoader if (\defined('T_NAME_QUALIFIED')) { $nsTokens[\T_NAME_QUALIFIED] = true; } - for ($i = 0; isset($tokens[$i]); ++$i) { $token = $tokens[$i]; - if (!isset($token[1])) { continue; } @@ -122,6 +120,9 @@ class AnnotationFileLoader extends FileLoader $skipClassToken = false; for ($j = $i - 1; $j > 0; --$j) { if (!isset($tokens[$j][1])) { + if ('(' === $tokens[$j] || ',' === $tokens[$j]) { + $skipClassToken = true; + } break; } diff --git a/src/Symfony/Component/Routing/RouteCollectionBuilder.php b/src/Symfony/Component/Routing/RouteCollectionBuilder.php index 8abb242171..d7eed31eb8 100644 --- a/src/Symfony/Component/Routing/RouteCollectionBuilder.php +++ b/src/Symfony/Component/Routing/RouteCollectionBuilder.php @@ -350,11 +350,11 @@ class RouteCollectionBuilder } if (null === $resolver = $this->loader->getResolver()) { - throw new LoaderLoadException($resource, null, null, null, $type); + throw new LoaderLoadException($resource, null, 0, null, $type); } if (false === $loader = $resolver->resolve($resource, $type)) { - throw new LoaderLoadException($resource, null, null, null, $type); + throw new LoaderLoadException($resource, null, 0, null, $type); } $collections = $loader->load($resource, $type); diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/Attributes/FooAttributes.php b/src/Symfony/Component/Routing/Tests/Fixtures/Attributes/FooAttributes.php new file mode 100644 index 0000000000..9edd0ece2e --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/Attributes/FooAttributes.php @@ -0,0 +1,16 @@ +class = $class; + $this->foo = $foo; + } +} diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamAfterCommaController.php b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamAfterCommaController.php new file mode 100644 index 0000000000..3fdf55f30c --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamAfterCommaController.php @@ -0,0 +1,18 @@ + ['foo','bar'], + 'foo' + ], + class: User::class +)] +class AttributesClassParamAfterCommaController +{ + +} diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamAfterParenthesisController.php b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamAfterParenthesisController.php new file mode 100644 index 0000000000..06edcabf6d --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamAfterParenthesisController.php @@ -0,0 +1,18 @@ + ['foo','bar'], + 'foo' + ] +)] +class AttributesClassParamAfterParenthesisController +{ + +} diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamInlineAfterCommaController.php b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamInlineAfterCommaController.php new file mode 100644 index 0000000000..4b47967f13 --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamInlineAfterCommaController.php @@ -0,0 +1,12 @@ + ['foo','bar'],'foo'],class: User::class)] +class AttributesClassParamInlineAfterCommaController +{ + +} diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamInlineAfterParenthesisController.php b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamInlineAfterParenthesisController.php new file mode 100644 index 0000000000..876cdc33f7 --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamInlineAfterParenthesisController.php @@ -0,0 +1,12 @@ + ['foo','bar'],'foo'])] +class AttributesClassParamInlineAfterParenthesisController +{ + +} diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamInlineQuotedAfterCommaController.php b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamInlineQuotedAfterCommaController.php new file mode 100644 index 0000000000..471efd305a --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamInlineQuotedAfterCommaController.php @@ -0,0 +1,12 @@ + ['foo','bar'],'foo'],class: 'Symfony\Component\Security\Core\User\User')] +class AttributesClassParamInlineQuotedAfterCommaController +{ + +} diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamInlineQuotedAfterParenthesisController.php b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamInlineQuotedAfterParenthesisController.php new file mode 100644 index 0000000000..dc0ea7a820 --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamInlineQuotedAfterParenthesisController.php @@ -0,0 +1,12 @@ + ['foo','bar'],'foo'])] +class AttributesClassParamInlineQuotedAfterParenthesisController +{ + +} diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamQuotedAfterCommaController.php b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamQuotedAfterCommaController.php new file mode 100644 index 0000000000..1d82cd1c61 --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamQuotedAfterCommaController.php @@ -0,0 +1,17 @@ + ['foo','bar'], + 'foo' + ], + class: 'Symfony\Component\Security\Core\User\User' +)] +class AttributesClassParamQuotedAfterCommaController +{ + +} diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamQuotedAfterParenthesisController.php b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamQuotedAfterParenthesisController.php new file mode 100644 index 0000000000..b1456c758a --- /dev/null +++ b/src/Symfony/Component/Routing/Tests/Fixtures/AttributesFixtures/AttributesClassParamQuotedAfterParenthesisController.php @@ -0,0 +1,17 @@ + ['foo','bar'], + 'foo' + ] +)] +class AttributesClassParamQuotedAfterParenthesisController +{ + +} diff --git a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php index ff2dd53909..ee66ef1804 100644 --- a/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php +++ b/src/Symfony/Component/Routing/Tests/Loader/AnnotationFileLoaderTest.php @@ -85,4 +85,72 @@ class AnnotationFileLoaderTest extends AbstractAnnotationLoaderTest $this->assertTrue($this->loader->supports($fixture, 'annotation'), '->supports() checks the resource type if specified'); $this->assertFalse($this->loader->supports($fixture, 'foo'), '->supports() checks the resource type if specified'); } + + /** + * @requires PHP 8 + */ + public function testLoadAttributesClassAfterComma() + { + $this->reader->expects($this->once())->method('getClassAnnotation'); + + $this->loader->load(__DIR__.'/../Fixtures/AttributesFixtures/AttributesClassParamAfterCommaController.php'); + } + + public function testLoadAttributesInlineClassAfterComma() + { + $this->reader->expects($this->once())->method('getClassAnnotation'); + + $this->loader->load(__DIR__.'/../Fixtures/AttributesFixtures/AttributesClassParamInlineAfterCommaController.php'); + } + + /** + * @requires PHP 8 + */ + public function testLoadAttributesQuotedClassAfterComma() + { + $this->reader->expects($this->once())->method('getClassAnnotation'); + + $this->loader->load(__DIR__.'/../Fixtures/AttributesFixtures/AttributesClassParamQuotedAfterCommaController.php'); + } + + public function testLoadAttributesInlineQuotedClassAfterComma() + { + $this->reader->expects($this->once())->method('getClassAnnotation'); + + $this->loader->load(__DIR__.'/../Fixtures/AttributesFixtures/AttributesClassParamInlineQuotedAfterCommaController.php'); + } + + /** + * @requires PHP 8 + */ + public function testLoadAttributesClassAfterParenthesis() + { + $this->reader->expects($this->once())->method('getClassAnnotation'); + + $this->loader->load(__DIR__.'/../Fixtures/AttributesFixtures/AttributesClassParamAfterParenthesisController.php'); + } + + public function testLoadAttributesInlineClassAfterParenthesis() + { + $this->reader->expects($this->once())->method('getClassAnnotation'); + + $this->loader->load(__DIR__.'/../Fixtures/AttributesFixtures/AttributesClassParamInlineAfterParenthesisController.php'); + } + + /** + * @requires PHP 8 + */ + public function testLoadAttributesQuotedClassAfterParenthesis() + { + $this->reader->expects($this->once())->method('getClassAnnotation'); + + $this->loader->load(__DIR__.'/../Fixtures/AttributesFixtures/AttributesClassParamQuotedAfterParenthesisController.php'); + } + + public function testLoadAttributesInlineQuotedClassAfterParenthesis() + { + $this->reader->expects($this->once())->method('getClassAnnotation'); + + $this->loader->load(__DIR__.'/../Fixtures/AttributesFixtures/AttributesClassParamInlineQuotedAfterParenthesisController.php'); + } } diff --git a/src/Symfony/Component/Yaml/Exception/ParseException.php b/src/Symfony/Component/Yaml/Exception/ParseException.php index 20b918929b..6d441e7735 100644 --- a/src/Symfony/Component/Yaml/Exception/ParseException.php +++ b/src/Symfony/Component/Yaml/Exception/ParseException.php @@ -28,7 +28,6 @@ class ParseException extends RuntimeException * @param int $parsedLine The line where the error occurred * @param string|null $snippet The snippet of code near the problem * @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, \Throwable $previous = null) {