Skip to content

Commit 015ddbb

Browse files
[TASK] Declare nullable types as nullable explicitly (#332)
@see https://wiki.php.net/rfc/deprecate-implicitly-nullable-types Co-authored-by: Benjamin Kott <[email protected]>
1 parent 66d0000 commit 015ddbb

File tree

4 files changed

+13
-17
lines changed

4 files changed

+13
-17
lines changed

Classes/Controller/BackendController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function setupWizardAction(): ResponseInterface
8585
return $view->renderResponse('Backend/SetupWizard');
8686
}
8787

88-
public function postsAction(int $blogSetup = null): ResponseInterface
88+
public function postsAction(?int $blogSetup = null): ResponseInterface
8989
{
9090
$query = $this->postRepository->createQuery();
9191
$querySettings = $query->getQuerySettings();
@@ -102,7 +102,7 @@ public function postsAction(int $blogSetup = null): ResponseInterface
102102
return $view->renderResponse('Backend/Posts');
103103
}
104104

105-
public function commentsAction(string $filter = null, int $blogSetup = null): ResponseInterface
105+
public function commentsAction(?string $filter = null, ?int $blogSetup = null): ResponseInterface
106106
{
107107
$view = $this->moduleTemplateFactory->create($this->request);
108108
$view->assignMultiple([
@@ -122,7 +122,7 @@ public function commentsAction(string $filter = null, int $blogSetup = null): Re
122122
return $view->renderResponse('Backend/Comments');
123123
}
124124

125-
public function updateCommentStatusAction(string $status, string $filter = null, int $blogSetup = null, array $comments = [], int $comment = null): ResponseInterface
125+
public function updateCommentStatusAction(string $status, ?string $filter = null, ?int $blogSetup = null, array $comments = [], ?int $comment = null): ResponseInterface
126126
{
127127
if ($comment !== null) {
128128
$comments['__identity'][] = $comment;
@@ -155,7 +155,7 @@ public function updateCommentStatusAction(string $status, string $filter = null,
155155
return new RedirectResponse($this->uriBuilder->reset()->uriFor('comments', ['filter' => $filter, 'blogSetup' => $blogSetup]));
156156
}
157157

158-
public function createBlogAction(array $data = null): ResponseInterface
158+
public function createBlogAction(?array $data = null): ResponseInterface
159159
{
160160
if ($data !== null && $this->setupService->createBlogSetup($data)) {
161161
$this->addFlashMessage('Your blog setup has been created.', 'Congratulation');

Classes/Domain/Repository/CommentRepository.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function findAllByPost(Post $post): QueryResultInterface
5656
return $result;
5757
}
5858

59-
public function findAllByFilter(string $filter = null, int $blogSetup = null): QueryResultInterface
59+
public function findAllByFilter(?string $filter = null, ?int $blogSetup = null): QueryResultInterface
6060
{
6161
$query = $this->createQuery();
6262
$querySettings = $query->getQuerySettings();
@@ -93,7 +93,7 @@ public function findAllByFilter(string $filter = null, int $blogSetup = null): Q
9393
return $this->createQuery()->execute();
9494
}
9595

96-
public function findActiveComments(int $limit = null, int $blogSetup = null): QueryResultInterface
96+
public function findActiveComments(?int $limit = null, ?int $blogSetup = null): QueryResultInterface
9797
{
9898
$query = $this->createQuery();
9999

Classes/Domain/Repository/PostRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public function findAllByTag(Tag $tag): QueryResultInterface
226226
return $query->matching($query->logicalAnd(...$constraints))->execute();
227227
}
228228

229-
public function findByMonthAndYear(int $year, int $month = null): QueryResultInterface
229+
public function findByMonthAndYear(int $year, ?int $month = null): QueryResultInterface
230230
{
231231
$query = $this->createQuery();
232232
$constraints = $this->defaultConstraints;

Tests/Unit/Service/Avatar/Gravatar/GravatarUriBuilderTest.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
namespace T3G\AgencyPack\Blog\Tests\Unit\Service\Avatar\Gravatar;
1212

13+
use PHPUnit\Framework\Attributes\DataProvider;
14+
use PHPUnit\Framework\Attributes\Test;
1315
use T3G\AgencyPack\Blog\Service\Avatar\Gravatar\GravatarUriBuilder;
1416
use TYPO3\CMS\Core\Http\UriFactory;
1517
use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
@@ -28,23 +30,17 @@ protected function setUp(): void
2830
$this->gravatarUriBuilder = new GravatarUriBuilder(new UriFactory());
2931
}
3032

31-
/**
32-
* @dataProvider testGetUriDataProvider
33-
* @param string $expectedUriString
34-
* @param string $email
35-
* @param int|null $size
36-
* @param string|null $rating
37-
* @param string|null $default
38-
*/
39-
public function testGetUri(string $expectedUriString, string $email, ?int $size, ?string $rating, ?string $default): void
33+
#[Test]
34+
#[DataProvider('getUriDataProvider')]
35+
public function getUri(string $expectedUriString, string $email, ?int $size, ?string $rating, ?string $default): void
4036
{
4137
self::assertSame(
4238
$expectedUriString,
4339
(string)$this->gravatarUriBuilder->getUri($email, $size, $rating, $default)
4440
);
4541
}
4642

47-
public static function testGetUriDataProvider(): \Generator
43+
public static function getUriDataProvider(): \Generator
4844
{
4945
$email = '[email protected]';
5046
yield ['https://www.gravatar.com/avatar/71803b16fcdb8ac77611d0a977b20164', $email, null, null, null];

0 commit comments

Comments
 (0)