diff --git a/Build/php-cs-fixer/config.php b/Build/php-cs-fixer/config.php index 57ebfa08..755b1ae4 100644 --- a/Build/php-cs-fixer/config.php +++ b/Build/php-cs-fixer/config.php @@ -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, diff --git a/Classes/Core/Functional/Framework/AssignablePropertyTrait.php b/Classes/Core/Functional/Framework/AssignablePropertyTrait.php index d32f36ed..3c752602 100644 --- a/Classes/Core/Functional/Framework/AssignablePropertyTrait.php +++ b/Classes/Core/Functional/Framework/AssignablePropertyTrait.php @@ -25,7 +25,7 @@ trait AssignablePropertyTrait * @param callable|null $cast * @return static */ - private function assign(array $data, callable $cast = null) + private function assign(array $data, ?callable $cast = null) { if ($cast !== null) { $data = array_map($cast, $data); diff --git a/Classes/Core/Functional/Framework/DataHandling/ActionService.php b/Classes/Core/Functional/Framework/DataHandling/ActionService.php index 60f0def8..828073e5 100644 --- a/Classes/Core/Functional/Framework/DataHandling/ActionService.php +++ b/Classes/Core/Functional/Framework/DataHandling/ActionService.php @@ -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 => [ @@ -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 => [ @@ -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 => [ diff --git a/Classes/Core/Functional/Framework/DataHandling/CsvWriterStreamFilter.php b/Classes/Core/Functional/Framework/DataHandling/CsvWriterStreamFilter.php index 5e4877ba..c3140c33 100644 --- a/Classes/Core/Functional/Framework/DataHandling/CsvWriterStreamFilter.php +++ b/Classes/Core/Functional/Framework/DataHandling/CsvWriterStreamFilter.php @@ -49,7 +49,7 @@ public static function register() * @param resource $stream * @param string $sequence */ - public static function apply($stream, string $sequence = null): \Closure + public static function apply($stream, ?string $sequence = null): \Closure { static::register(); if ($sequence === null) { diff --git a/Classes/Core/Functional/Framework/DataHandling/DataSet.php b/Classes/Core/Functional/Framework/DataHandling/DataSet.php index 70be2a73..c2a505b4 100644 --- a/Classes/Core/Functional/Framework/DataHandling/DataSet.php +++ b/Classes/Core/Functional/Framework/DataHandling/DataSet.php @@ -299,7 +299,7 @@ public function getElements(string $tableName) * @param int|null $padding * @deprecated Will be removed with core v12 compatible testing-framework. */ - public function persist(string $fileName, int $padding = null) + public function persist(string $fileName, ?int $padding = null) { $fileHandle = fopen($fileName, 'w'); $modifier = CsvWriterStreamFilter::apply($fileHandle); @@ -330,7 +330,7 @@ public function persist(string $fileName, int $padding = null) * @return array * @deprecated Will be removed with core v12 compatible testing-framework. */ - protected function pad(array $values, int $padding = null): array + protected function pad(array $values, ?int $padding = null): array { if ($padding === null) { return $values; diff --git a/Classes/Core/Functional/Framework/DataHandling/Scenario/DataHandlerFactory.php b/Classes/Core/Functional/Framework/DataHandling/Scenario/DataHandlerFactory.php index 3f86913c..04b8fb0d 100644 --- a/Classes/Core/Functional/Framework/DataHandling/Scenario/DataHandlerFactory.php +++ b/Classes/Core/Functional/Framework/DataHandling/Scenario/DataHandlerFactory.php @@ -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); @@ -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, @@ -199,7 +199,7 @@ private function processLanguageVariantItem( EntityConfiguration $entityConfiguration, array $itemSettings, array $ancestorIds, - string $nodeId = null + ?string $nodeId = null ): void { $values = $this->processEntityValues( $entityConfiguration, @@ -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( @@ -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( diff --git a/Classes/Core/Functional/Framework/Frontend/Collector.php b/Classes/Core/Functional/Framework/Frontend/Collector.php index 062146a5..37bcafa4 100644 --- a/Classes/Core/Functional/Framework/Frontend/Collector.php +++ b/Classes/Core/Functional/Framework/Frontend/Collector.php @@ -52,7 +52,7 @@ class Collector implements SingletonInterface */ public $cObj; - public function addRecordData($content, array $configuration = null): void + public function addRecordData($content, ?array $configuration = null): void { $recordIdentifier = $this->cObj->currentRecord; [$tableName] = explode(':', $recordIdentifier); @@ -71,7 +71,7 @@ public function addRecordData($content, array $configuration = null): void } } - public function addFileData($content, array $configuration = null): void + public function addFileData($content, ?array $configuration = null): void { $currentFile = $this->cObj->getCurrentFile(); @@ -134,7 +134,7 @@ protected function addToStructure($levelIdentifier, $recordIdentifier, array $re * @param string $content * @param array|null $configuration */ - public function attachSection($content, array $configuration = null): void + public function attachSection($content, ?array $configuration = null): void { $section = [ 'structure' => $this->structure, diff --git a/Classes/Core/Functional/Framework/Frontend/Renderer.php b/Classes/Core/Functional/Framework/Frontend/Renderer.php index e1eba67b..a53fad5d 100644 --- a/Classes/Core/Functional/Framework/Frontend/Renderer.php +++ b/Classes/Core/Functional/Framework/Frontend/Renderer.php @@ -38,7 +38,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; @@ -82,7 +82,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; @@ -110,7 +110,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); } diff --git a/Classes/Core/Functional/Framework/Frontend/RequestBootstrap.php b/Classes/Core/Functional/Framework/Frontend/RequestBootstrap.php index f8b2a40d..e5289c3c 100644 --- a/Classes/Core/Functional/Framework/Frontend/RequestBootstrap.php +++ b/Classes/Core/Functional/Framework/Frontend/RequestBootstrap.php @@ -58,7 +58,7 @@ class RequestBootstrap * @param string $documentRoot * @param array|null $this->requestArguments */ - public function __construct(string $documentRoot, array $requestArguments = null) + public function __construct(string $documentRoot, ?array $requestArguments = null) { $this->documentRoot = $documentRoot; $this->requestArguments = $requestArguments; diff --git a/Classes/Core/Functional/Framework/Frontend/ResponseContent.php b/Classes/Core/Functional/Framework/Frontend/ResponseContent.php index 92d7b264..ccba829c 100644 --- a/Classes/Core/Functional/Framework/Frontend/ResponseContent.php +++ b/Classes/Core/Functional/Framework/Frontend/ResponseContent.php @@ -43,7 +43,7 @@ class ResponseContent */ protected $scope = []; - 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); @@ -65,7 +65,7 @@ public static function fromString(string $data, ResponseContent $target = null): /** * @param Response $response (deprecated) */ - final public function __construct(Response $response = null) + final public function __construct(?Response $response = null) { if ($response instanceof Response) { static::fromString($response->getContent(), $this); diff --git a/Classes/Core/Functional/FunctionalTestCase.php b/Classes/Core/Functional/FunctionalTestCase.php index fc35fbbb..23af19dc 100644 --- a/Classes/Core/Functional/FunctionalTestCase.php +++ b/Classes/Core/Functional/FunctionalTestCase.php @@ -1117,7 +1117,7 @@ protected function addTypoScriptToTemplateRecord(int $pageId, string $typoScript */ protected function executeFrontendSubRequest( InternalRequest $request, - InternalRequestContext $context = null, + ?InternalRequestContext $context = null, bool $followRedirects = false ): InternalResponse { if ($context === null) { @@ -1285,7 +1285,7 @@ private function retrieveFrontendSubRequestResult( */ protected function executeFrontendRequest( InternalRequest $request, - InternalRequestContext $context = null, + ?InternalRequestContext $context = null, bool $followRedirects = false ): InternalResponse { if ($context === null) {