Commit 1a318ec3 authored by Anja Leichsenring's avatar Anja Leichsenring Committed by Christian Kuhn
Browse files

[TASK] Update php-cs-fixer to version 2.0

Change-Id: Ia32a61238bdf46c01a3856376c0a94d9d09339ee
Resolves: #79361
Releases: master
Reviewed-on: https://review.typo3.org/51423


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Jan Helke's avatarJan Helke <typo3@helke.de>
Tested-by: Jan Helke's avatarJan Helke <typo3@helke.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 606d1841
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
* *
* The TYPO3 project - inspiring people to share! * The TYPO3 project - inspiring people to share!
*/ */
/** /**
* This file represents the configuration for Code Sniffing PSR-2-related * This file represents the configuration for Code Sniffing PSR-2-related
* automatic checks of coding guidelines * automatic checks of coding guidelines
...@@ -21,7 +20,7 @@ ...@@ -21,7 +20,7 @@
* *
* And then simply run * And then simply run
* *
* $ php-cs-fixer fix --config-file Build/.php_cs * $ php-cs-fixer fix --config ../Build/.php_cs
* *
* inside the TYPO3 directory. Warning: This may take up to 10 minutes. * inside the TYPO3 directory. Warning: This may take up to 10 minutes.
* *
...@@ -29,18 +28,16 @@ ...@@ -29,18 +28,16 @@
* http://www.php-fig.org/psr/psr-2/ * http://www.php-fig.org/psr/psr-2/
* http://cs.sensiolabs.org * http://cs.sensiolabs.org
*/ */
if (PHP_SAPI !== 'cli') { if (PHP_SAPI !== 'cli') {
die('This script supports command line usage only. Please check your command.'); die('This script supports command line usage only. Please check your command.');
} }
// Define in which folders to search and which folders to exclude // 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 // Exclude some directories that are excluded by Git anyways to speed up the sniffing
$finder = Symfony\CS\Finder\DefaultFinder::create() $finder = PhpCsFixer\Finder::create()
->exclude('vendor') ->exclude('vendor')
->exclude('typo3conf') ->exclude('typo3conf')
->exclude('typo3temp') ->exclude('typo3temp')
->in(__DIR__ . '/../'); ->in(__DIR__ . '/../');
// Return a Code Sniffing configuration using // Return a Code Sniffing configuration using
// all sniffers needed for PSR-2 // all sniffers needed for PSR-2
// and additionally: // and additionally:
...@@ -50,34 +47,32 @@ $finder = Symfony\CS\Finder\DefaultFinder::create() ...@@ -50,34 +47,32 @@ $finder = Symfony\CS\Finder\DefaultFinder::create()
// - Remove unused use statements in the PHP source code // - Remove unused use statements in the PHP source code
// - Ensure Concatenation to have at least one whitespace around // - Ensure Concatenation to have at least one whitespace around
// - Remove trailing whitespace at the end of blank lines. // - Remove trailing whitespace at the end of blank lines.
return Symfony\CS\Config\Config::create() return PhpCsFixer\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL) ->setRules([
->fixers([ '@PSR2' => true,
// If changes to the fixers are done, please sync them with typo3/sysext/core/Build/Scripts/cglFixMyCommit.sh 'no_leading_import_slash' => true,
'remove_leading_slash_use', 'no_trailing_comma_in_singleline_array' => true,
'single_array_no_trailing_comma', 'no_singleline_whitespace_before_semicolons' => true,
'spaces_before_semicolon', 'no_unused_imports' => true,
'unused_use', 'concat_space' => ['spacing' => 'one'],
'concat_with_spaces', 'no_whitespace_in_blank_line' => true,
'whitespacy_lines', 'ordered_imports' => true,
'ordered_use', 'single_quote' => true,
'single_quote', 'no_empty_statement' => true,
'duplicate_semicolon', 'no_extra_consecutive_blank_lines' => true,
'extra_empty_lines', 'phpdoc_no_package' => true,
'phpdoc_no_package', 'phpdoc_scalar' => true,
'phpdoc_scalar', 'no_blank_lines_after_phpdoc' => true,
'no_empty_lines_after_phpdocs', 'array_syntax' => ['syntax' => 'short'],
'short_array_syntax', 'whitespace_after_comma_in_array' => true,
'array_element_white_space_after_comma', 'function_typehint_space' => true,
'function_typehint_space', 'hash_to_slash_comment' => true,
'hash_to_slash_comment', 'no_alias_functions' => true,
'join_function', 'lowercase_cast' => true,
'lowercase_cast', 'no_leading_namespace_whitespace' => true,
'namespace_no_leading_whitespace', 'native_function_casing' => true,
'native_function_casing', 'self_accessor' => true,
'no_empty_statement', 'no_short_bool_cast' => true,
'self_accessor', 'no_unneeded_control_parentheses' => true
'short_bool_cast',
'unneeded_control_parentheses'
]) ])
->finder($finder); ->setFinder($finder);
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "b74e1b0a1511a9a01531bbe16ee8a570", "content-hash": "2acb42e35d36e35f70942355d0b8e669",
"packages": [ "packages": [
{ {
"name": "cogpowered/finediff", "name": "cogpowered/finediff",
...@@ -1688,16 +1688,16 @@ ...@@ -1688,16 +1688,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v1.13.1", "version": "v2.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git", "url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "0ea4f7ed06ca55da1d8fc45da26ff87f261c4088" "reference": "f3baf72eb2f58bf275b372540f5b47d25aed910f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/0ea4f7ed06ca55da1d8fc45da26ff87f261c4088", "url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/f3baf72eb2f58bf275b372540f5b47d25aed910f",
"reference": "0ea4f7ed06ca55da1d8fc45da26ff87f261c4088", "reference": "f3baf72eb2f58bf275b372540f5b47d25aed910f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -1706,8 +1706,9 @@ ...@@ -1706,8 +1706,9 @@
"sebastian/diff": "^1.1", "sebastian/diff": "^1.1",
"symfony/console": "^2.3 || ^3.0", "symfony/console": "^2.3 || ^3.0",
"symfony/event-dispatcher": "^2.1 || ^3.0", "symfony/event-dispatcher": "^2.1 || ^3.0",
"symfony/filesystem": "^2.1 || ^3.0", "symfony/filesystem": "^2.4 || ^3.0",
"symfony/finder": "^2.1 || ^3.0", "symfony/finder": "^2.2 || ^3.0",
"symfony/polyfill-php54": "^1.0",
"symfony/process": "^2.3 || ^3.0", "symfony/process": "^2.3 || ^3.0",
"symfony/stopwatch": "^2.5 || ^3.0" "symfony/stopwatch": "^2.5 || ^3.0"
}, },
...@@ -1715,6 +1716,7 @@ ...@@ -1715,6 +1716,7 @@
"hhvm": "<3.9" "hhvm": "<3.9"
}, },
"require-dev": { "require-dev": {
"gecko-packages/gecko-php-unit": "^2.0",
"phpunit/phpunit": "^4.5|^5", "phpunit/phpunit": "^4.5|^5",
"satooshi/php-coveralls": "^1.0" "satooshi/php-coveralls": "^1.0"
}, },
...@@ -1722,9 +1724,14 @@ ...@@ -1722,9 +1724,14 @@
"php-cs-fixer" "php-cs-fixer"
], ],
"type": "application", "type": "application",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": { "autoload": {
"psr-4": { "psr-4": {
"Symfony\\CS\\": "Symfony/CS/" "PhpCsFixer\\": "src/"
} }
}, },
"notification-url": "https://packagist.org/downloads/", "notification-url": "https://packagist.org/downloads/",
...@@ -1742,7 +1749,7 @@ ...@@ -1742,7 +1749,7 @@
} }
], ],
"description": "A tool to automatically fix PHP code style", "description": "A tool to automatically fix PHP code style",
"time": "2016-12-01T00:05:05+00:00" "time": "2016-12-01T06:18:06+00:00"
}, },
{ {
"name": "mikey179/vfsStream", "name": "mikey179/vfsStream",
...@@ -3253,6 +3260,64 @@ ...@@ -3253,6 +3260,64 @@
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2016-11-24T00:46:43+00:00" "time": "2016-11-24T00:46:43+00:00"
}, },
{
"name": "symfony/polyfill-php54",
"version": "v1.3.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php54.git",
"reference": "90e085822963fdcc9d1c5b73deb3d2e5783b16a0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php54/zipball/90e085822963fdcc9d1c5b73deb3d2e5783b16a0",
"reference": "90e085822963fdcc9d1c5b73deb3d2e5783b16a0",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.3-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Polyfill\\Php54\\": ""
},
"files": [
"bootstrap.php"
],
"classmap": [
"Resources/stubs"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"polyfill",
"portable",
"shim"
],
"time": "2016-11-14T01:06:16+00:00"
},
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v3.2.0", "version": "v3.2.0",
......
...@@ -16,11 +16,9 @@ COUNTER=0 ...@@ -16,11 +16,9 @@ COUNTER=0
for FILE in $(git diff-tree --no-commit-id --name-only -r HEAD | grep '.php$'); do for FILE in $(git diff-tree --no-commit-id --name-only -r HEAD | grep '.php$'); do
if [ -e $FILE ] if [ -e $FILE ]
then then
# If changes to the fixers are done, please sync them with Build/.php_cs from core root directory
./bin/php-cs-fixer fix $FILE \ ./bin/php-cs-fixer fix $FILE \
-v \ -v \
--level=psr2 \ --config=Build/.php_cs
--fixers=remove_leading_slash_use,single_array_no_trailing_comma,spaces_before_semicolon,unused_use,concat_with_spaces,whitespacy_lines,ordered_use,single_quote,duplicate_semicolon,extra_empty_lines,phpdoc_no_package,phpdoc_scalar,no_empty_lines_after_phpdocs,short_array_syntax,array_element_white_space_after_comma,function_typehint_space,hash_to_slash_comment,join_function,lowercase_cast,namespace_no_leading_whitespace,native_function_casing,no_empty_statement,self_accessor,short_bool_cast,unneeded_control_parentheses
if [ "$?" = "1" ] if [ "$?" = "1" ]
then then
COUNTER=$((COUNTER+1)) COUNTER=$((COUNTER+1))
......
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