Skip to content

Commit

Permalink
[TASK] Avoid implicitly nullable method parameter (#896) (#608)
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 5cc90fb commit 4d0317f
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 26 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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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 @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions Classes/Core/Functional/Framework/DataHandling/DataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
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 @@ -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);
Expand All @@ -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();

Expand Down Expand Up @@ -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,
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 @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions Classes/Core/Functional/FunctionalTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 4d0317f

Please sign in to comment.