From a8751e89998c328b7fbdd7ea3a5a985c83d2cc2e Mon Sep 17 00:00:00 2001 From: W0rma Date: Wed, 31 Jul 2024 10:34:55 +0200 Subject: [PATCH] Declare nullable parameter types explicitly Implicit nullable parameter types will become deprecated in PHP 8.4 --- .php-cs-fixer.php | 1 + .../Pager/Event/Subscriber/Sortable/ArraySubscriber.php | 2 +- src/Knp/Component/Pager/Paginator.php | 2 +- src/Knp/Component/Pager/PaginatorInterface.php | 2 +- tests/Test/Tool/BaseTestCaseMongoODM.php | 4 ++-- tests/Test/Tool/BaseTestCasePHPCRODM.php | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 919c3709..31c6ba72 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -18,6 +18,7 @@ 'php_unit_mock_short_will_return' => true, 'no_extra_blank_lines' => true, 'no_unused_imports' => true, + 'nullable_type_declaration_for_default_null_value' => true, ]) ->setFinder($finder) ; diff --git a/src/Knp/Component/Pager/Event/Subscriber/Sortable/ArraySubscriber.php b/src/Knp/Component/Pager/Event/Subscriber/Sortable/ArraySubscriber.php index 416d5547..257b3877 100644 --- a/src/Knp/Component/Pager/Event/Subscriber/Sortable/ArraySubscriber.php +++ b/src/Knp/Component/Pager/Event/Subscriber/Sortable/ArraySubscriber.php @@ -25,7 +25,7 @@ class ArraySubscriber implements EventSubscriberInterface private readonly ?PropertyAccessorInterface $propertyAccessor; - public function __construct(private readonly ArgumentAccessInterface $argumentAccess, PropertyAccessorInterface $accessor = null) + public function __construct(private readonly ArgumentAccessInterface $argumentAccess, ?PropertyAccessorInterface $accessor = null) { if (!$accessor && class_exists(PropertyAccess::class)) { $accessor = PropertyAccess::createPropertyAccessorBuilder()->enableMagicCall()->getPropertyAccessor(); diff --git a/src/Knp/Component/Pager/Paginator.php b/src/Knp/Component/Pager/Paginator.php index 73c24136..bf1aa3b9 100644 --- a/src/Knp/Component/Pager/Paginator.php +++ b/src/Knp/Component/Pager/Paginator.php @@ -56,7 +56,7 @@ public function setDefaultPaginatorOptions(array $options): void * * @return PaginationInterface */ - public function paginate($target, int $page = 1, int $limit = null, array $options = []): PaginationInterface + public function paginate($target, int $page = 1, ?int $limit = null, array $options = []): PaginationInterface { if ($page <= 0) { throw PageNumberInvalidException::create($page); diff --git a/src/Knp/Component/Pager/PaginatorInterface.php b/src/Knp/Component/Pager/PaginatorInterface.php index 3efec7c7..044a8723 100644 --- a/src/Knp/Component/Pager/PaginatorInterface.php +++ b/src/Knp/Component/Pager/PaginatorInterface.php @@ -45,5 +45,5 @@ interface PaginatorInterface * * @return PaginationInterface */ - public function paginate(mixed $target, int $page = 1, int $limit = null, array $options = []): PaginationInterface; + public function paginate(mixed $target, int $page = 1, ?int $limit = null, array $options = []): PaginationInterface; } diff --git a/tests/Test/Tool/BaseTestCaseMongoODM.php b/tests/Test/Tool/BaseTestCaseMongoODM.php index 505623f6..73b7662c 100644 --- a/tests/Test/Tool/BaseTestCaseMongoODM.php +++ b/tests/Test/Tool/BaseTestCaseMongoODM.php @@ -41,7 +41,7 @@ protected function tearDown(): void * DocumentManager mock object together with * annotation mapping driver and database */ - protected function getMockDocumentManager(EventManager $evm = null): DocumentManager + protected function getMockDocumentManager(?EventManager $evm = null): DocumentManager { $conn = new Connection(); $config = $this->getMockAnnotatedConfig(); @@ -59,7 +59,7 @@ protected function getMockDocumentManager(EventManager $evm = null): DocumentMan * DocumentManager mock object with * annotation mapping driver */ - protected function getMockMappedDocumentManager(EventManager $evm = null): DocumentManager + protected function getMockMappedDocumentManager(?EventManager $evm = null): DocumentManager { $conn = $this->createMock(Connection::class); $config = $this->getMockAnnotatedConfig(); diff --git a/tests/Test/Tool/BaseTestCasePHPCRODM.php b/tests/Test/Tool/BaseTestCasePHPCRODM.php index 52b15e23..c484f551 100644 --- a/tests/Test/Tool/BaseTestCasePHPCRODM.php +++ b/tests/Test/Tool/BaseTestCasePHPCRODM.php @@ -33,7 +33,7 @@ protected function tearDown(): void } } - protected function getMockDocumentManager(EventManager $evm = null): DocumentManager + protected function getMockDocumentManager(?EventManager $evm = null): DocumentManager { $config = new \Doctrine\ODM\PHPCR\Configuration(); $config->setMetadataDriverImpl($this->getMetadataDriverImplementation());