Skip to content

Commit

Permalink
[TASK] Avoid implicitly nullable method parameter (#607)
Browse files Browse the repository at this point in the history
Implicit nullable method parameters are deprecated
with PHP 8.4. The patch prepares affected method
signatures and activates an according php-cs-fixer
rule.
  • Loading branch information
lolli42 authored Aug 10, 2024
1 parent d4a6bd9 commit 0293468
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 24 deletions.
4 changes: 4 additions & 0 deletions Build/php-cs-fixer/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
'no_unused_imports' => true,
'no_useless_else' => true,
'no_useless_nullsafe_operator' => true,
'nullable_type_declaration' => [
'syntax' => 'question_mark',
],
'nullable_type_declaration_for_default_null_value' => true,
'ordered_imports' => ['imports_order' => ['class', 'function', 'const'], 'sort_algorithm' => 'alpha'],
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
'php_unit_mock_short_will_return' => true,
Expand Down
2 changes: 1 addition & 1 deletion Classes/Composer/ComposerPackageManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ final class ComposerPackageManager

private static string $publicPath = '';

private static PackageInfo|null $rootPackage = null;
private static ?PackageInfo $rootPackage = null;

/**
* @var array<string, PackageInfo>
Expand Down
2 changes: 1 addition & 1 deletion Classes/Core/BaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected function tearDown(): void
*/
protected function getAccessibleMock(
string $originalClassName,
array|null $methods = [],
?array $methods = [],
array $arguments = [],
string $mockClassName = '',
bool $callOriginalConstructor = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function createNewRecords(int $pageId, array $tableRecordData): array
* modifyRecord('tt_content', 42, ['hidden' => '1']); // Modify a single record
* modifyRecord('tt_content', 42, ['hidden' => '1'], ['tx_irre_table' => [4]]); // Modify a record and delete a child
*/
public function modifyRecord(string $tableName, int $uid, array $recordData, array $deleteTableRecordIds = null)
public function modifyRecord(string $tableName, int $uid, array $recordData, ?array $deleteTableRecordIds = null)
{
$dataMap = [
$tableName => [
Expand Down Expand Up @@ -266,7 +266,7 @@ public function clearWorkspaceRecords(array $tableRecordIds)
* Example:
* copyRecord('tt_content', 42, 5, ['header' => 'Testing #1']);
*/
public function copyRecord(string $tableName, int $uid, int $pageId, array $recordData = null): array
public function copyRecord(string $tableName, int $uid, int $pageId, ?array $recordData = null): array
{
$commandMap = [
$tableName => [
Expand Down Expand Up @@ -302,7 +302,7 @@ public function copyRecord(string $tableName, int $uid, int $pageId, array $reco
* @param array $recordData Additional record data to change when moving.
* @return array
*/
public function moveRecord(string $tableName, int $uid, int $targetUid, array $recordData = null): array
public function moveRecord(string $tableName, int $uid, int $targetUid, ?array $recordData = null): array
{
$commandMap = [
$tableName => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public function getSuggestedIds(): array
*/
private function processEntities(
array $settings,
string $nodeId = null,
string $parentId = null
?string $nodeId = null,
?string $parentId = null
): void {
foreach ($settings as $entityName => $entitySettings) {
$entityConfiguration = $this->provideEntityConfiguration($entityName);
Expand All @@ -135,8 +135,8 @@ private function processEntities(
private function processEntityItem(
EntityConfiguration $entityConfiguration,
array $itemSettings,
string $nodeId = null,
string $parentId = null
?string $nodeId = null,
?string $parentId = null
): void {
$values = $this->processEntityValues(
$entityConfiguration,
Expand Down Expand Up @@ -199,7 +199,7 @@ private function processLanguageVariantItem(
EntityConfiguration $entityConfiguration,
array $itemSettings,
array $ancestorIds,
string $nodeId = null
?string $nodeId = null
): void {
$values = $this->processEntityValues(
$entityConfiguration,
Expand Down Expand Up @@ -240,7 +240,7 @@ private function processVersionVariantItem(
EntityConfiguration $entityConfiguration,
array $itemSettings,
string $ancestorId,
string $nodeId = null
?string $nodeId = null
): void {
if (isset($itemSettings['self'])) {
throw new \LogicException(
Expand Down Expand Up @@ -284,8 +284,8 @@ private function processVersionVariantItem(
private function processEntityValues(
EntityConfiguration $entityConfiguration,
array $itemSettings,
string $nodeId = null,
string $parentId = null
?string $nodeId = null,
?string $parentId = null
): array {
if (isset($itemSettings['self']) && isset($itemSettings['version'])) {
throw new \LogicException(
Expand Down
6 changes: 3 additions & 3 deletions Classes/Core/Functional/Framework/Frontend/Collector.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function setContentObjectRenderer(ContentObjectRenderer $cObj): void
$this->cObj = $cObj;
}

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

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

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

public function attachSection(string $content, array $configuration = null): void
public function attachSection(string $content, ?array $configuration = null): void
{
$section = [
'structure' => $this->structure,
Expand Down
6 changes: 3 additions & 3 deletions Classes/Core/Functional/Framework/Frontend/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Renderer implements SingletonInterface
* @param string $content
* @param array|null $configuration
*/
public function parseValues($content, array $configuration = null)
public function parseValues($content, ?array $configuration = null)
{
if (empty($content)) {
return;
Expand Down Expand Up @@ -84,7 +84,7 @@ public function parseValues($content, array $configuration = null)
* @param string $content
* @param array|null $configuration
*/
public function renderValues($content, array $configuration = null)
public function renderValues($content, ?array $configuration = null)
{
if (empty($configuration['values.'])) {
return;
Expand Down Expand Up @@ -112,7 +112,7 @@ public function addSection(array $section, $as = null)
* @param array|null $configuration
* @return string
*/
public function renderSections($content, array $configuration = null)
public function renderSections($content, ?array $configuration = null)
{
return json_encode($this->sections);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ResponseContent

final public function __construct() {}

public static function fromString(string $data, ResponseContent $target = null): ResponseContent
public static function fromString(string $data, ?ResponseContent $target = null): ResponseContent
{
$target = $target ?? new static();
$content = json_decode($data, true);
Expand Down
2 changes: 1 addition & 1 deletion Classes/Core/Functional/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ protected function addTypoScriptToTemplateRecord(int $pageId, string $typoScript
*/
protected function executeFrontendSubRequest(
InternalRequest $request,
InternalRequestContext $context = null,
?InternalRequestContext $context = null,
bool $followRedirects = false
): ResponseInterface {
if ($context === null) {
Expand Down
6 changes: 3 additions & 3 deletions Classes/Core/PackageCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function getPackages(): array
return $this->packages;
}

public function sortPackages(DependencyOrderingService $dependencyOrderingService = null): void
public function sortPackages(?DependencyOrderingService $dependencyOrderingService = null): void
{
$sortedPackageKeys = $this->resolveSortedPackageKeys($dependencyOrderingService);
usort(
Expand All @@ -97,7 +97,7 @@ public function sortPackages(DependencyOrderingService $dependencyOrderingServic
* @param array<PackageKey, StateConfiguration> $packageStates
* @return array<PackageKey, StateConfiguration>
*/
public function sortPackageStates(array $packageStates, DependencyOrderingService $dependencyOrderingService = null): array
public function sortPackageStates(array $packageStates, ?DependencyOrderingService $dependencyOrderingService = null): array
{
$sortedPackageKeys = $this->resolveSortedPackageKeys($dependencyOrderingService);
uksort(
Expand All @@ -117,7 +117,7 @@ public function sortPackageStates(array $packageStates, DependencyOrderingServic
*
* @return list<PackageKey>
*/
public function resolveSortedPackageKeys(DependencyOrderingService $dependencyOrderingService = null): array
public function resolveSortedPackageKeys(?DependencyOrderingService $dependencyOrderingService = null): array
{
$dependencyOrderingService ??= GeneralUtility::makeInstance(DependencyOrderingService::class);
$allPackageConstraints = $this->resolveAllPackageConstraints();
Expand Down

0 comments on commit 0293468

Please sign in to comment.