Commit 81288cdf authored by Benni Mack's avatar Benni Mack
Browse files

[TASK] Add support for PHP-CS-Fixer 3.0

This change raises the dev dependency PHP-CS-Fixer
to 2.19 (forward-compatible to 3.0) and 3.0,
allowing to run PHP-CS-Fixer with PHP8.

This change adapts the config file to use
the latest syntax. Using PSR-12 will be
handled in a separate followup.

Used composer commands:
- composer req friendsofphp/php-cs-fixer:"^2.19 || ^3.0" --dev
- composer req friendsofphp/php-cs-fixer:"^2.19 || ^3.0" -d typo3/sysext/core --dev --no-update

Resolves: #94053
Releases: master, 10.4
Change-Id: I47d4ca1b09728599782883fb4958908446fd7cfe
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/68989


Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Benni Mack's avatarBenni Mack <benni@typo3.org>
parent 3720fb09
@ECHO OFF
FOR /F %%i in ('git diff-tree --no-commit-id --name-only -r HEAD ^| findstr -i ".*\.php"') DO (
bin\php-cs-fixer.bat fix --path-mode intersection --config=Build/.php_cs %%i
bin\php-cs-fixer.bat fix --path-mode intersection --config=Build/php-cs-fixer.php %%i
)
......@@ -139,7 +139,7 @@ exist_php_executable
php_no_xdebug ./bin/php-cs-fixer fix \
-v ${DRYRUN} \
--path-mode intersection \
--config=Build/.php_cs \
--config=Build/php-cs-fixer.php \
`echo ${DETECTED_FILES} | xargs ls -d 2>/dev/null`
exit $?
......@@ -20,7 +20,7 @@
*
* And then simply run
*
* $ ./bin/php-cs-fixer fix --config ./Build/.php_cs
* $ ./bin/php-cs-fixer fix --config ./Build/php-cs-fixer.php
*
* inside the TYPO3 directory. Warning: This may take up to 10 minutes.
*
......@@ -33,7 +33,7 @@ if (PHP_SAPI !== 'cli') {
}
// Define in which folders to search and which folders to exclude
// Exclude some directories that are excluded by Git anyways to speed up the sniffing
$finder = PhpCsFixer\Finder::create()
$finder = (new PhpCsFixer\Finder())
->exclude('vendor')
->exclude('typo3conf')
->exclude('typo3temp')
......@@ -50,7 +50,7 @@ $finder = PhpCsFixer\Finder::create()
// - Remove unused use statements in the PHP source code
// - Ensure Concatenation to have at least one whitespace around
// - Remove trailing whitespace at the end of blank lines.
return PhpCsFixer\Config::create()
return (new \PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@DoctrineAnnotation' => true,
......@@ -64,7 +64,6 @@ return PhpCsFixer\Config::create()
'declare_equal_normalize' => ['space' => 'none'],
'dir_constant' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'lowercase_cast' => true,
'method_argument_space' => ['on_multiline' => 'ensure_fully_multiline'],
'modernize_types_casting' => true,
......@@ -74,7 +73,7 @@ return PhpCsFixer\Config::create()
'no_blank_lines_after_phpdoc' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'no_extra_blank_lines' => true,
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_null_property_initialization' => true,
......@@ -87,7 +86,7 @@ return PhpCsFixer\Config::create()
'no_useless_else' => true,
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'php_unit_construct' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame'],
'php_unit_construct' => ['assertions' => ['assertEquals', 'assertSame', 'assertNotEquals', 'assertNotSame']],
'php_unit_mock_short_will_return' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'self'],
'phpdoc_no_access' => true,
......@@ -99,6 +98,7 @@ return PhpCsFixer\Config::create()
'phpdoc_types_order' => ['null_adjustment' => 'always_last', 'sort_algorithm' => 'none'],
'return_type_declaration' => ['space_before' => 'none'],
'single_quote' => true,
'single_line_comment_style' => ['comment_types' => ['hash']],
'single_trait_insert_per_statement' => true,
'whitespace_after_comma_in_array' => true,
])
......
......@@ -490,7 +490,7 @@ services:
set -x
fi
php -dxdebug.mode=off bin/php-cs-fixer fix -v ${CGLCHECK_DRY_RUN} --path-mode intersection \
--config=Build/.php_cs typo3/
--config=Build/php-cs-fixer.php typo3/
"
check_annotations:
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "72c9bd7f95121f76e50162d63220c78d",
"content-hash": "4390a6e57c728319dcaf5e270aade6f5",
"packages": [
{
"name": "bacon/bacon-qr-code",
......@@ -5348,21 +5348,21 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v2.17.3",
"version": "v2.19.0",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "bd32f5dd72cdfc7b53f54077f980e144bfa2f595"
"reference": "d5b8a9d852b292c2f8a035200fa6844b1f82300b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/bd32f5dd72cdfc7b53f54077f980e144bfa2f595",
"reference": "bd32f5dd72cdfc7b53f54077f980e144bfa2f595",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/d5b8a9d852b292c2f8a035200fa6844b1f82300b",
"reference": "d5b8a9d852b292c2f8a035200fa6844b1f82300b",
"shasum": ""
},
"require": {
"composer/semver": "^1.4 || ^2.0 || ^3.0",
"composer/xdebug-handler": "^1.2",
"composer/xdebug-handler": "^1.2 || ^2.0",
"doctrine/annotations": "^1.2",
"ext-json": "*",
"ext-tokenizer": "*",
......@@ -5379,7 +5379,6 @@
"symfony/stopwatch": "^3.0 || ^4.0 || ^5.0"
},
"require-dev": {
"johnkary/phpunit-speedtrap": "^1.1 || ^2.0 || ^3.0",
"justinrainbow/json-schema": "^5.0",
"keradus/cli-executor": "^1.4",
"mikey179/vfsstream": "^1.6",
......@@ -5388,11 +5387,11 @@
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.2",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.2.1",
"phpspec/prophecy-phpunit": "^1.1 || ^2.0",
"phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.13 || ^9.4.4 <9.5",
"phpunit/phpunit": "^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.13 || ^9.5",
"phpunitgoodpractices/polyfill": "^1.5",
"phpunitgoodpractices/traits": "^1.9.1",
"sanmai/phpunit-legacy-adapter": "^6.4 || ^8.2.1",
"symfony/phpunit-bridge": "^5.1",
"symfony/phpunit-bridge": "^5.2.1",
"symfony/yaml": "^3.0 || ^4.0 || ^5.0"
},
"suggest": {
......@@ -5406,6 +5405,11 @@
"php-cs-fixer"
],
"type": "application",
"extra": {
"branch-alias": {
"dev-master": "2.19-dev"
}
},
"autoload": {
"psr-4": {
"PhpCsFixer\\": "src/"
......@@ -5420,6 +5424,7 @@
"tests/Test/IntegrationCaseFactoryInterface.php",
"tests/Test/InternalIntegrationCaseFactory.php",
"tests/Test/IsIdenticalConstraint.php",
"tests/Test/TokensWithObservedTransformers.php",
"tests/TestCase.php"
]
},
......@@ -5440,7 +5445,7 @@
"description": "A tool to automatically fix PHP code style",
"support": {
"issues": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/issues",
"source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v2.17.3"
"source": "https://github.com/FriendsOfPHP/PHP-CS-Fixer/tree/v2.19.0"
},
"funding": [
{
......@@ -5448,7 +5453,7 @@
"type": "github"
}
],
"time": "2020-12-24T11:14:44+00:00"
"time": "2021-05-03T21:43:24+00:00"
},
{
"name": "friendsoftypo3/phpstan-typo3",
......
......@@ -71,7 +71,7 @@
"codeception/module-asserts": "^1.3.1",
"codeception/module-filesystem": "^1.0.3",
"codeception/module-webdriver": "^1.1.4",
"friendsofphp/php-cs-fixer": "^2.17.3",
"friendsofphp/php-cs-fixer": "^2.19 || ^3.0",
"php-webdriver/webdriver": "^1.9.0",
"phpspec/prophecy": "^1.12.2",
"phpstan/phpstan": "^0.12.64",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment