Skip to content

Commit 0293468

Browse files
authored
[TASK] Avoid implicitly nullable method parameter (#607)
Implicit nullable method parameters are deprecated with PHP 8.4. The patch prepares affected method signatures and activates an according php-cs-fixer rule.
1 parent d4a6bd9 commit 0293468

File tree

10 files changed

+28
-24
lines changed

10 files changed

+28
-24
lines changed

Build/php-cs-fixer/config.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@
5656
'no_unused_imports' => true,
5757
'no_useless_else' => true,
5858
'no_useless_nullsafe_operator' => true,
59+
'nullable_type_declaration' => [
60+
'syntax' => 'question_mark',
61+
],
62+
'nullable_type_declaration_for_default_null_value' => true,
5963
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
6064
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
6165
'php_unit_mock_short_will_return' => true,

Classes/Composer/ComposerPackageManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ final class ComposerPackageManager
4747

4848
private static string $publicPath = '';
4949

50-
private static PackageInfo|null $rootPackage = null;
50+
private static ?PackageInfo $rootPackage = null;
5151

5252
/**
5353
* @var array<string, PackageInfo>

Classes/Core/BaseTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected function tearDown(): void
108108
*/
109109
protected function getAccessibleMock(
110110
string $originalClassName,
111-
array|null $methods = [],
111+
?array $methods = [],
112112
array $arguments = [],
113113
string $mockClassName = '',
114114
bool $callOriginalConstructor = true,

Classes/Core/Functional/Framework/DataHandling/ActionService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function createNewRecords(int $pageId, array $tableRecordData): array
111111
* modifyRecord('tt_content', 42, ['hidden' => '1']); // Modify a single record
112112
* modifyRecord('tt_content', 42, ['hidden' => '1'], ['tx_irre_table' => [4]]); // Modify a record and delete a child
113113
*/
114-
public function modifyRecord(string $tableName, int $uid, array $recordData, array $deleteTableRecordIds = null)
114+
public function modifyRecord(string $tableName, int $uid, array $recordData, ?array $deleteTableRecordIds = null)
115115
{
116116
$dataMap = [
117117
$tableName => [
@@ -266,7 +266,7 @@ public function clearWorkspaceRecords(array $tableRecordIds)
266266
* Example:
267267
* copyRecord('tt_content', 42, 5, ['header' => 'Testing #1']);
268268
*/
269-
public function copyRecord(string $tableName, int $uid, int $pageId, array $recordData = null): array
269+
public function copyRecord(string $tableName, int $uid, int $pageId, ?array $recordData = null): array
270270
{
271271
$commandMap = [
272272
$tableName => [
@@ -302,7 +302,7 @@ public function copyRecord(string $tableName, int $uid, int $pageId, array $reco
302302
* @param array $recordData Additional record data to change when moving.
303303
* @return array
304304
*/
305-
public function moveRecord(string $tableName, int $uid, int $targetUid, array $recordData = null): array
305+
public function moveRecord(string $tableName, int $uid, int $targetUid, ?array $recordData = null): array
306306
{
307307
$commandMap = [
308308
$tableName => [

Classes/Core/Functional/Framework/DataHandling/Scenario/DataHandlerFactory.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ public function getSuggestedIds(): array
110110
*/
111111
private function processEntities(
112112
array $settings,
113-
string $nodeId = null,
114-
string $parentId = null
113+
?string $nodeId = null,
114+
?string $parentId = null
115115
): void {
116116
foreach ($settings as $entityName => $entitySettings) {
117117
$entityConfiguration = $this->provideEntityConfiguration($entityName);
@@ -135,8 +135,8 @@ private function processEntities(
135135
private function processEntityItem(
136136
EntityConfiguration $entityConfiguration,
137137
array $itemSettings,
138-
string $nodeId = null,
139-
string $parentId = null
138+
?string $nodeId = null,
139+
?string $parentId = null
140140
): void {
141141
$values = $this->processEntityValues(
142142
$entityConfiguration,
@@ -199,7 +199,7 @@ private function processLanguageVariantItem(
199199
EntityConfiguration $entityConfiguration,
200200
array $itemSettings,
201201
array $ancestorIds,
202-
string $nodeId = null
202+
?string $nodeId = null
203203
): void {
204204
$values = $this->processEntityValues(
205205
$entityConfiguration,
@@ -240,7 +240,7 @@ private function processVersionVariantItem(
240240
EntityConfiguration $entityConfiguration,
241241
array $itemSettings,
242242
string $ancestorId,
243-
string $nodeId = null
243+
?string $nodeId = null
244244
): void {
245245
if (isset($itemSettings['self'])) {
246246
throw new \LogicException(
@@ -284,8 +284,8 @@ private function processVersionVariantItem(
284284
private function processEntityValues(
285285
EntityConfiguration $entityConfiguration,
286286
array $itemSettings,
287-
string $nodeId = null,
288-
string $parentId = null
287+
?string $nodeId = null,
288+
?string $parentId = null
289289
): array {
290290
if (isset($itemSettings['self']) && isset($itemSettings['version'])) {
291291
throw new \LogicException(

Classes/Core/Functional/Framework/Frontend/Collector.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function setContentObjectRenderer(ContentObjectRenderer $cObj): void
4444
$this->cObj = $cObj;
4545
}
4646

47-
public function addRecordData($content, array $configuration = null, ServerRequestInterface $request): void
47+
public function addRecordData($content, ?array $configuration = null, ?ServerRequestInterface $request = null): void
4848
{
4949
$recordIdentifier = $this->cObj->currentRecord;
5050
[$tableName] = explode(':', $recordIdentifier);
@@ -63,7 +63,7 @@ public function addRecordData($content, array $configuration = null, ServerReque
6363
}
6464
}
6565

66-
public function addFileData($content, array $configuration = null, ServerRequestInterface $request): void
66+
public function addFileData($content, ?array $configuration = null, ?ServerRequestInterface $request = null): void
6767
{
6868
$currentFile = $this->cObj->getCurrentFile();
6969

@@ -84,7 +84,7 @@ public function addFileData($content, array $configuration = null, ServerRequest
8484
$this->addToStructure($levelIdentifier, $recordIdentifier, $recordData);
8585
}
8686

87-
public function attachSection(string $content, array $configuration = null): void
87+
public function attachSection(string $content, ?array $configuration = null): void
8888
{
8989
$section = [
9090
'structure' => $this->structure,

Classes/Core/Functional/Framework/Frontend/Renderer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class Renderer implements SingletonInterface
4040
* @param string $content
4141
* @param array|null $configuration
4242
*/
43-
public function parseValues($content, array $configuration = null)
43+
public function parseValues($content, ?array $configuration = null)
4444
{
4545
if (empty($content)) {
4646
return;
@@ -84,7 +84,7 @@ public function parseValues($content, array $configuration = null)
8484
* @param string $content
8585
* @param array|null $configuration
8686
*/
87-
public function renderValues($content, array $configuration = null)
87+
public function renderValues($content, ?array $configuration = null)
8888
{
8989
if (empty($configuration['values.'])) {
9090
return;
@@ -112,7 +112,7 @@ public function addSection(array $section, $as = null)
112112
* @param array|null $configuration
113113
* @return string
114114
*/
115-
public function renderSections($content, array $configuration = null)
115+
public function renderSections($content, ?array $configuration = null)
116116
{
117117
return json_encode($this->sections);
118118
}

Classes/Core/Functional/Framework/Frontend/ResponseContent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ResponseContent
4747

4848
final public function __construct() {}
4949

50-
public static function fromString(string $data, ResponseContent $target = null): ResponseContent
50+
public static function fromString(string $data, ?ResponseContent $target = null): ResponseContent
5151
{
5252
$target = $target ?? new static();
5353
$content = json_decode($data, true);

Classes/Core/Functional/FunctionalTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ protected function addTypoScriptToTemplateRecord(int $pageId, string $typoScript
898898
*/
899899
protected function executeFrontendSubRequest(
900900
InternalRequest $request,
901-
InternalRequestContext $context = null,
901+
?InternalRequestContext $context = null,
902902
bool $followRedirects = false
903903
): ResponseInterface {
904904
if ($context === null) {

Classes/Core/PackageCollection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function getPackages(): array
8282
return $this->packages;
8383
}
8484

85-
public function sortPackages(DependencyOrderingService $dependencyOrderingService = null): void
85+
public function sortPackages(?DependencyOrderingService $dependencyOrderingService = null): void
8686
{
8787
$sortedPackageKeys = $this->resolveSortedPackageKeys($dependencyOrderingService);
8888
usort(
@@ -97,7 +97,7 @@ public function sortPackages(DependencyOrderingService $dependencyOrderingServic
9797
* @param array<PackageKey, StateConfiguration> $packageStates
9898
* @return array<PackageKey, StateConfiguration>
9999
*/
100-
public function sortPackageStates(array $packageStates, DependencyOrderingService $dependencyOrderingService = null): array
100+
public function sortPackageStates(array $packageStates, ?DependencyOrderingService $dependencyOrderingService = null): array
101101
{
102102
$sortedPackageKeys = $this->resolveSortedPackageKeys($dependencyOrderingService);
103103
uksort(
@@ -117,7 +117,7 @@ public function sortPackageStates(array $packageStates, DependencyOrderingServic
117117
*
118118
* @return list<PackageKey>
119119
*/
120-
public function resolveSortedPackageKeys(DependencyOrderingService $dependencyOrderingService = null): array
120+
public function resolveSortedPackageKeys(?DependencyOrderingService $dependencyOrderingService = null): array
121121
{
122122
$dependencyOrderingService ??= GeneralUtility::makeInstance(DependencyOrderingService::class);
123123
$allPackageConstraints = $this->resolveAllPackageConstraints();

0 commit comments

Comments
 (0)