Skip to content

Commit

Permalink
[TASK] Avoid implicitly nullable class method parameter (#2500)
Browse files Browse the repository at this point in the history
With PHP 8.4 marking method parameter implicitly nullable
is deprecated and will emit a `E_DEPRECATED` warning. One
recommended way to resolve this, is making it explicitly
nullable using the `?` nullable operator or adding a null
type to an union type definition. [[1]](https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated)

This prepares the way towards PHP 8.4 compatibility.

* [[1] https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated](https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated)
  • Loading branch information
sbuerk authored Jul 1, 2024
1 parent 9c74fd8 commit 1a996ae
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Classes/Controller/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CategoryController extends NewsController
/**
* List categories
*/
public function listAction(array $overwriteDemand = null): ResponseInterface
public function listAction(?array $overwriteDemand = null): ResponseInterface
{
$demand = $this->createDemandObjectFromSettings($this->settings);
$demand->setActionAndClass(__METHOD__, __CLASS__);
Expand Down
10 changes: 5 additions & 5 deletions Classes/Controller/NewsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ protected function overwriteDemandObject(NewsDemand $demand, array $overwriteDem
*
* @param array|null $overwriteDemand
*/
public function listAction(array $overwriteDemand = null): ResponseInterface
public function listAction(?array $overwriteDemand = null): ResponseInterface
{
$possibleRedirect = $this->forwardToDetailActionWhenRequested();
if ($possibleRedirect) {
Expand Down Expand Up @@ -356,7 +356,7 @@ public function selectedListAction(): ResponseInterface
* @param News $news news item
* @param int $currentPage current page for optional pagination
*/
public function detailAction(News $news = null, $currentPage = 1): ResponseInterface
public function detailAction(?News $news = null, $currentPage = 1): ResponseInterface
{
if ($news === null || ($this->settings['isShortcut'] ?? false)) {
$previewNewsId = (int)($this->settings['singleNews'] ?? 0);
Expand Down Expand Up @@ -463,7 +463,7 @@ protected function isPreviewOfHiddenRecordsEnabled(): bool
/**
* Render a menu by dates, e.g. years, months or dates
*/
public function dateMenuAction(array $overwriteDemand = null): ResponseInterface
public function dateMenuAction(?array $overwriteDemand = null): ResponseInterface
{
$demand = $this->createDemandObjectFromSettings($this->settings);
$demand->setActionAndClass(__METHOD__, __CLASS__);
Expand Down Expand Up @@ -512,7 +512,7 @@ public function dateMenuAction(array $overwriteDemand = null): ResponseInterface
* Display the search form
*/
public function searchFormAction(
Search $search = null,
?Search $search = null,
array $overwriteDemand = []
): ResponseInterface {
$demand = $this->createDemandObjectFromSettings($this->settings);
Expand Down Expand Up @@ -544,7 +544,7 @@ public function searchFormAction(
* Displays the search result
*/
public function searchResultAction(
Search $search = null,
?Search $search = null,
array $overwriteDemand = []
): ResponseInterface {
$demand = $this->createDemandObjectFromSettings($this->settings);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Controller/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
class TagController extends NewsController
{
public function listAction(array $overwriteDemand = null): ResponseInterface
public function listAction(?array $overwriteDemand = null): ResponseInterface
{
// Default value is wrong for tags
if ($this->settings['orderBy'] === 'datetime') {
Expand Down
2 changes: 1 addition & 1 deletion Classes/Domain/Model/Dto/NewsDemand.php
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ public function getSearch(): ?Search
* @param Search|null $search search object
* @return NewsDemand
*/
public function setSearch(Search $search = null): NewsDemand
public function setSearch(?Search $search = null): NewsDemand
{
$this->search = $search;
return $this;
Expand Down
2 changes: 1 addition & 1 deletion Classes/Seo/NewsXmlSitemapDataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class NewsXmlSitemapDataProvider extends AbstractXmlSitemapDataProvider
* @param ContentObjectRenderer|null $cObj
* @throws MissingConfigurationException
*/
public function __construct(ServerRequestInterface $request, string $key, array $config = [], ContentObjectRenderer $cObj = null)
public function __construct(ServerRequestInterface $request, string $key, array $config = [], ?ContentObjectRenderer $cObj = null)
{
parent::__construct($request, $key, $config, $cObj);

Expand Down
2 changes: 1 addition & 1 deletion Classes/Utility/ClassCacheManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class ClassCacheManager
/**
* @param PhpFrontend $classCache
*/
public function __construct(PhpFrontend $classCache = null)
public function __construct(?PhpFrontend $classCache = null)
{
if ($classCache === null) {
$cacheManager = GeneralUtility::makeInstance(CacheManager::class);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Utility/ClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ClassLoader implements SingletonInterface
*
* @param PhpFrontend $classCache
*/
public function __construct(PhpFrontend $classCache = null, ClassCacheManager $classCacheManager = null)
public function __construct(?PhpFrontend $classCache = null, ?ClassCacheManager $classCacheManager = null)
{
$versionInformation = GeneralUtility::makeInstance(Typo3Version::class);
if ($versionInformation->getMajorVersion() === 10) {
Expand Down

0 comments on commit 1a996ae

Please sign in to comment.