Skip to content

Commit

Permalink
Declare nullable parameter types explicitly
Browse files Browse the repository at this point in the history
Implicit nullable parameter types will become deprecated in PHP 8.4
  • Loading branch information
W0rma committed Jul 31, 2024
1 parent d0a84e4 commit a8751e8
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
;
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/Knp/Component/Pager/Paginator.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function setDefaultPaginatorOptions(array $options): void
*
* @return PaginationInterface<int, mixed>
*/
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);
Expand Down
2 changes: 1 addition & 1 deletion src/Knp/Component/Pager/PaginatorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ interface PaginatorInterface
*
* @return PaginationInterface<int, mixed>
*/
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;
}
4 changes: 2 additions & 2 deletions tests/Test/Tool/BaseTestCaseMongoODM.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/Test/Tool/BaseTestCasePHPCRODM.php
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit a8751e8

Please sign in to comment.