Commit f7b7507c authored by Benni Mack's avatar Benni Mack
Browse files

[TASK] Enforce trailing commas in multi line arrays with PHP CS Fixer

The rule trailing_comma_in_multiline is added to the PHP CS fixer
configuration.

This reduces possible merge conflicts in the future.

The commands to apply the rules over the code base was

./bin/php-cs-fixer fix \
    --path-mode intersection \
    --config=Build/php-cs-fixer.php \
    typo3/sysext

And then:
./bin/php-cs-fixer fix --config=Build/php-cs-fixer.php

Resolves: #94553
Releases: master
Change-Id: I0ebbfa9edbbcde19aaeb44219a71f2f093ab705e
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/69825

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Andreas Fernandez's avatarAndreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Wouter Wolters's avatarWouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent f57ecf70
......@@ -74,7 +74,7 @@ class NodeVisitor extends NodeVisitorAbstract
// Extension scanner
'extensionScannerIgnoreFile', 'extensionScannerIgnoreLine',
// static code analysis
'template', 'implements', 'extends'
'template', 'implements', 'extends',
];
$matches = [];
......
......@@ -62,7 +62,7 @@ class checkIntegrityComposer
'type',
'Dependency',
'should be',
'actually is'
'actually is',
]);
foreach ($this->testResults as $extKey => $results) {
foreach ($results as $result) {
......@@ -71,7 +71,7 @@ class checkIntegrityComposer
$result['type'],
$result['dependency'],
$result['shouldBe'],
$result['actuallyIs']
$result['actuallyIs'],
]);
}
}
......@@ -114,7 +114,7 @@ class checkIntegrityComposer
'type' => 'require',
'dependency' => $requireKey,
'shouldBe' => $requireItem,
'actuallyIs' => $extensionComposerJson['require'][$requireKey]
'actuallyIs' => $extensionComposerJson['require'][$requireKey],
];
}
}
......@@ -126,7 +126,7 @@ class checkIntegrityComposer
'type' => 'require-dev',
'dependency' => $requireDevKey,
'shouldBe' => $requireDevItem,
'actuallyIs' => $extensionComposerJson['require-dev'][$requireDevKey]
'actuallyIs' => $extensionComposerJson['require-dev'][$requireDevKey],
];
}
}
......
......@@ -37,7 +37,7 @@ $finder->files()
->in([
__DIR__ . '/../../typo3/sysext/*/Tests/Unit/',
__DIR__ . '/../../typo3/sysext/*/Tests/UnitDeprecated/',
__DIR__ . '/../../typo3/sysext/*/Tests/Functional/'
__DIR__ . '/../../typo3/sysext/*/Tests/Functional/',
])
->name('/Test\.php$/');
......
......@@ -100,6 +100,7 @@ return (new \PhpCsFixer\Config())
'single_quote' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'single_trait_insert_per_statement' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
'whitespace_after_comma_in_array' => true,
])
->setFinder($finder);
......@@ -55,7 +55,7 @@ return PhpCsFixer\Config::create()
'header' => $headerComment,
'comment_type' => 'comment',
'separate' => 'both',
'location' => 'after_declare_strict'
'location' => 'after_declare_strict',
],
])
->setFinder($finder);
......@@ -20,92 +20,92 @@ if (PHP_MAJOR_VERSION === 7) {
[
'message' => '#^Parameter \\#2 \\$algo of function password_hash expects string\\|null, int\\|string\\|null given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/core/Classes/Crypto/PasswordHashing/AbstractArgon2PasswordHash.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#2 \\$algo of function password_needs_rehash expects string\\|null, int\\|string\\|null given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/core/Classes/Crypto/PasswordHashing/AbstractArgon2PasswordHash.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#1 \\$im of function imagecolorallocate expects resource, resource\\|false given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/install/Classes/Controller/EnvironmentController.php',
'count' => 6
'count' => 6,
],
[
'message' => '#^Parameter \\#1 \\$im of function imagefilledrectangle expects resource, resource\\|false given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/install/Classes/Controller/EnvironmentController.php',
'count' => 4
'count' => 4,
],
[
'message' => '#^Parameter \\#1 \\$im of function imagegif expects resource, resource\\|false given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/install/Classes/Controller/EnvironmentController.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#1 \\$im of function imagettftext expects resource, resource\\|false given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/install/Classes/Controller/EnvironmentController.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#6 \\$col of function imagefilledrectangle expects int, int\\|false given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/install/Classes/Controller/EnvironmentController.php',
'count' => 4
'count' => 4,
],
[
'message' => '#^Parameter \\#6 \\$col of function imagettftext expects int, int\\|false given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/install/Classes/Controller/EnvironmentController.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#1 \\$im of function imagedestroy expects resource, resource\\|false given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/install/Classes/SystemEnvironment/Check.php',
'count' => 3
'count' => 3,
],
[
'message' => '#^Parameter \\#2 \\$col of function imagecolortransparent expects int, int\\|false given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/frontend/Classes/Imaging/GifBuilder.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#1 \\$parser of function xml_parse expects resource, XMLParser given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#1 \\$parser of function xml_set_object expects resource, XMLParser given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#1 \\$parser of function xml_parser_free expects resource, XMLParser given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#1 \\$parser of function xml_parser_set_option expects resource, XMLParser given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 3
'count' => 3,
],
[
'message' => '#^Parameter \\#1 \\$parser of function xml_set_character_data_handler expects resource, XMLParser given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#1 \\$parser of function xml_set_element_handler expects resource, XMLParser given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Access to undefined constant ReflectionAttribute\\:\\:IS_INSTANCEOF\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/core/Classes/DependencyInjection/LoggerAwarePass.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Access to undefined constant ReflectionAttribute\\:\\:IS_INSTANCEOF\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/core/Classes/DependencyInjection/LoggerInterfacePass.php',
'count' => 2
'count' => 2,
],
];
}
......
......@@ -54,37 +54,37 @@ if (PHP_MAJOR_VERSION === 8) {
[
'message' => '#^Parameter \\#1 \\$parser of function xml_parse expects XMLParser, resource given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#1 \\$parser of function xml_parser_free expects XMLParser, resource given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#1 \\$parser of function xml_parser_set_option expects XMLParser, resource given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 3
'count' => 3,
],
[
'message' => '#^Parameter \\#1 \\$parser of function xml_set_character_data_handler expects XMLParser, resource given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#1 \\$parser of function xml_set_element_handler expects XMLParser, resource given\\.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/extensionmanager/Classes/Parser/ExtensionXmlParser.php',
'count' => 1
'count' => 1,
],
[
'message' => '#^Parameter \\#1 \\$separator of function explode expects non-empty-string, string given\\.$#',
'path' => '%currentWorkingDirectory%/',
'count' => 8
'count' => 8,
],
[
'message' => '#^Ternary operator condition is always true.$#',
'path' => '%currentWorkingDirectory%/typo3/sysext/core/Classes/Utility/GeneralUtility.php',
'count' => 3
'count' => 3,
],
];
......
......@@ -76,7 +76,7 @@ class DoctrineSqlLogger implements SQLLogger, LoggerAwareInterface
'params' => $params,
'types' => $types,
'executionMS' => 0,
'backtrace' => $backtrace
'backtrace' => $backtrace,
];
}
}
......
......@@ -67,13 +67,13 @@ class PageTitle extends AbstractSubModule implements DataProviderInterface
public function getDataToStore(ServerRequestInterface $request): ModuleData
{
$data = [
'cacheEnabled' => true
'cacheEnabled' => true,
];
if ($this->isNoCacheEnabled()) {
$data = [
'orderedProviders' => [],
'usedProvider' => null,
'skippedProviders' => []
'skippedProviders' => [],
];
$log = InMemoryLogWriter::$log;
......
......@@ -57,7 +57,7 @@ class UserIntInformation extends AbstractSubModule implements DataProviderInterf
{
return new ModuleData(
[
'userIntInfo' => $this->getUserIntInfo()
'userIntInfo' => $this->getUserIntInfo(),
]
);
}
......
......@@ -128,7 +128,7 @@ class TypoScriptWaterfall extends AbstractSubModule implements RequestEnricherIn
'content' => (int)$this->getConfigurationOption('displayContent'),
],
'trackContentRendering' => (int)$this->getConfigurationOption('LR'),
'forceTemplateParsing' => (int)$this->getConfigurationOption('forceTemplateParsing')
'forceTemplateParsing' => (int)$this->getConfigurationOption('forceTemplateParsing'),
]
);
......
......@@ -7,10 +7,10 @@
return [
'adminPanel_saveForm' => [
'path' => '/adminpanel/form/save',
'target' => \TYPO3\CMS\Adminpanel\Controller\AjaxController::class . '::saveDataAction'
'target' => \TYPO3\CMS\Adminpanel\Controller\AjaxController::class . '::saveDataAction',
],
'adminPanel_toggle' => [
'path' => '/adminpanel/toggleActiveState',
'target' => \TYPO3\CMS\Adminpanel\Controller\AjaxController::class . '::toggleActiveState'
'target' => \TYPO3\CMS\Adminpanel\Controller\AjaxController::class . '::toggleActiveState',
],
];
......@@ -20,7 +20,7 @@ return [
'after' => [
'typo3/cms-frontend/authentication',
'typo3/cms-frontend/backend-user-authentication',
]
],
],
'typo3/cms-adminpanel/sql-logging' => [
'target' => \TYPO3\CMS\Adminpanel\Middleware\SqlLogging::class,
......@@ -29,23 +29,23 @@ return [
'typo3/cms-frontend/backend-user-authentication',
],
'before' => [
'typo3/cms-frontend/tsfe'
]
'typo3/cms-frontend/tsfe',
],
],
'typo3/cms-adminpanel/data-persister' => [
'target' => \TYPO3\CMS\Adminpanel\Middleware\AdminPanelDataPersister::class,
'after' => [
'typo3/cms-adminpanel/initiator',
'typo3/cms-frontend/content-length-headers',
'typo3/cms-adminpanel/renderer'
'typo3/cms-adminpanel/renderer',
],
],
'typo3/cms-adminpanel/renderer' => [
'target' => \TYPO3\CMS\Adminpanel\Middleware\AdminPanelRenderer::class,
'after' => [
'typo3/cms-adminpanel/initiator',
'typo3/cms-frontend/content-length-headers'
]
'typo3/cms-frontend/content-length-headers',
],
],
]
],
];
......@@ -55,8 +55,8 @@ class AdminPanelInitiatorTest extends UnitTestCase
];
$uc = [
'AdminPanel' => [
'display_top' => true
]
'display_top' => true,
],
];
$userAuthentication = $this->prophesize(FrontendBackendUserAuthentication::class);
$userAuthentication->getTSConfig()->willReturn($tsConfig);
......@@ -94,8 +94,8 @@ class AdminPanelInitiatorTest extends UnitTestCase
];
$uc = [
'AdminPanel' => [
'display_top' => false
]
'display_top' => false,
],
];
$this->checkAdminPanelDoesNotCallInitialize($tsConfig, $uc);
}
......@@ -110,8 +110,8 @@ class AdminPanelInitiatorTest extends UnitTestCase
];
$uc = [
'AdminPanel' => [
'display_top' => true
]
'display_top' => true,
],
];
$this->checkAdminPanelDoesNotCallInitialize($tsConfig, $uc);
}
......
......@@ -85,7 +85,7 @@ class ModuleLoaderTest extends UnitTestCase
[
'modulename' => ['module' => \stdClass::class],
],
]
],
];
}
......@@ -110,8 +110,8 @@ class ModuleLoaderTest extends UnitTestCase
{
$config = [
'module1' => [
'module' => MainModuleFixture::class
]
'module' => MainModuleFixture::class,
],
];
$dependencyOrderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
......@@ -131,11 +131,11 @@ class ModuleLoaderTest extends UnitTestCase
{
$config = [
'module1' => [
'module' => MainModuleFixture::class
'module' => MainModuleFixture::class,
],
'module2' => [
'module' => DisabledMainModuleFixture::class
]
'module' => DisabledMainModuleFixture::class,
],
];
$dependencyOrderingServiceProphecy = $this->prophesize(DependencyOrderingService::class);
......
......@@ -54,20 +54,20 @@ class StateUtilityTest extends UnitTestCase
[
'admPanel.' => [
'enable.' => [
'preview' => 1
]
]
]
'preview' => 1,
],
],
],
],
'all modules enabled' => [
[
'admPanel.' => [
'enable.' => [
'all' => 1
]
]
]
]
'all' => 1,
],
],
],
],
];
}
......@@ -89,22 +89,22 @@ class StateUtilityTest extends UnitTestCase
{
return [
'no config set' => [
[]
[],
],
'all modules disabled' => [
'admPanel.' => [
'enable.' => [
'all' => 0
]
]
'all' => 0,
],
],
],
'single module configured, disabled' => [
'admPanel.' => [
'enable.' => [
'preview' => 0
]
]
]
'preview' => 0,
],
],
],
];
}
......@@ -127,24 +127,24 @@ class StateUtilityTest extends UnitTestCase
return [
'no config set' => [
[],
false
false,
],
'defined as not hidden' => [
[
'admPanel.' => [
'hide' => '0'
]
'hide' => '0',
],
],
false
false,
],
'defined as hidden' => [
[
'admPanel.' => [
'hide' => '1'
]
'hide' => '1',
],
],
true
]
true,
],
];
}
......@@ -178,23 +178,23 @@ class StateUtilityTest extends UnitTestCase
return [
'no config set' => [
[],
false
false,
],
'defined as display_top=false' => [
[
'AdminPanel' => [
'display_top' => false
]
'display_top' => false,
],
],
false
false,
],
'defined as display_top=true' => [
[
'AdminPanel' => [
'display_top' => true
]
'display_top' => true,
],
],
true
true,
],
];
}
......@@ -229,23 +229,23 @@ class StateUtilityTest extends UnitTestCase
return [
'no config set' => [
[],
false
false,
],
'Admin Panel is disabled' => [
[
'config' => [
'admPanel' => '0'
]
'admPanel' => '0',
],
],
false
false,
],
'Admin Panel is enabled' => [
[
'config' => [
'admPanel' => '1'
]
'admPanel' => '1',
],
],
true
true,
],
];
}
......
......@@ -73,7 +73,7 @@ $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules'] = [
],
'events' => [
'module' => Events::class,
]
],
],
],
];
......
......@@ -166,7 +166,7 @@ class PasswordReset implements LoggerAwareInterface
SystemLogErrorClassification::WARNING,
0,
[
'email' => $emailAddress
'email' => $emailAddress,
],
NormalizedParams::createFromRequest($request)->getRemoteAddress(),
$context
......@@ -205,7 +205,7 @@ class PasswordReset implements LoggerAwareInterface
SystemLogErrorClassification::SECURITY_NOTICE,
(int)$user['uid'],
[
'email' => $user['email']
'email' => $user['email'],
],
NormalizedParams::createFromRequest($request)->getRemoteAddress(),
$context
......@@ -246,7 +246,7 @@ class PasswordReset implements LoggerAwareInterface
// "expiration date"
'e' => $expiresOn->getTimestamp(),
// "identity"
'i' => hash('sha1', $emailAddress . (string)$userId)
'i' => hash('sha1', $emailAddress . (string)$userId),
],
UriBuilder::ABSOLUTE_URL
);
......@@ -350,7 +350,7 @@ class PasswordReset implements LoggerAwareInterface
$userId,
[
'email' => $user['email'],
'user' => $userId
'user' => $userId,
],
NormalizedParams::createFromRequest($request)->getRemoteAddress(),
$context
......@@ -427,7 +427,7 @@ class PasswordReset implements LoggerAwareInterface
'tstamp' => $context->getAspect('date')->get('timestamp'),
'event_pid' => 0,
'NEWid' => '',
'workspace' => 0
'workspace' => 0,
];
$connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('sys_log');
......