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 @@
*
* The TYPO3 project - inspiring people to share!
*/
/**
* This file represents the configuration for Code Sniffing PSR-2-related
* automatic checks of coding guidelines
......@@ -21,7 +20,7 @@
*
* 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.
*
......@@ -29,18 +28,16 @@
* http://www.php-fig.org/psr/psr-2/
* http://cs.sensiolabs.org
*/
if (PHP_SAPI !== 'cli') {
die('This script supports command line usage only. Please check your command.');
}
// 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 = Symfony\CS\Finder\DefaultFinder::create()
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->exclude('typo3conf')
->exclude('typo3temp')
->in(__DIR__ . '/../');
// Return a Code Sniffing configuration using
// all sniffers needed for PSR-2
// and additionally:
......@@ -50,34 +47,32 @@ $finder = Symfony\CS\Finder\DefaultFinder::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 Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->fixers([
// If changes to the fixers are done, please sync them with typo3/sysext/core/Build/Scripts/cglFixMyCommit.sh
'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'
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'no_leading_import_slash' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_unused_imports' => true,
'concat_space' => ['spacing' => 'one'],
'no_whitespace_in_blank_line' => true,
'ordered_imports' => true,
'single_quote' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'phpdoc_no_package' => true,
'phpdoc_scalar' => true,
'no_blank_lines_after_phpdoc' => true,
'array_syntax' => ['syntax' => 'short'],
'whitespace_after_comma_in_array' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'no_alias_functions' => true,
'lowercase_cast' => true,
'no_leading_namespace_whitespace' => true,
'native_function_casing' => true,
'self_accessor' => true,
'no_short_bool_cast' => true,
'no_unneeded_control_parentheses' => true
])
->finder($finder);
->setFinder($finder);
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "b74e1b0a1511a9a01531bbe16ee8a570",
"content-hash": "2acb42e35d36e35f70942355d0b8e669",
"packages": [
{
"name": "cogpowered/finediff",
......@@ -1688,16 +1688,16 @@
},
{
"name": "friendsofphp/php-cs-fixer",
"version": "v1.13.1",
"version": "v2.0.0",
"source": {
"type": "git",
"url": "https://github.com/FriendsOfPHP/PHP-CS-Fixer.git",
"reference": "0ea4f7ed06ca55da1d8fc45da26ff87f261c4088"
"reference": "f3baf72eb2f58bf275b372540f5b47d25aed910f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/0ea4f7ed06ca55da1d8fc45da26ff87f261c4088",
"reference": "0ea4f7ed06ca55da1d8fc45da26ff87f261c4088",
"url": "https://api.github.com/repos/FriendsOfPHP/PHP-CS-Fixer/zipball/f3baf72eb2f58bf275b372540f5b47d25aed910f",
"reference": "f3baf72eb2f58bf275b372540f5b47d25aed910f",
"shasum": ""
},
"require": {
......@@ -1706,8 +1706,9 @@
"sebastian/diff": "^1.1",
"symfony/console": "^2.3 || ^3.0",
"symfony/event-dispatcher": "^2.1 || ^3.0",
"symfony/filesystem": "^2.1 || ^3.0",
"symfony/finder": "^2.1 || ^3.0",
"symfony/filesystem": "^2.4 || ^3.0",
"symfony/finder": "^2.2 || ^3.0",
"symfony/polyfill-php54": "^1.0",
"symfony/process": "^2.3 || ^3.0",
"symfony/stopwatch": "^2.5 || ^3.0"
},
......@@ -1715,6 +1716,7 @@
"hhvm": "<3.9"
},
"require-dev": {
"gecko-packages/gecko-php-unit": "^2.0",
"phpunit/phpunit": "^4.5|^5",
"satooshi/php-coveralls": "^1.0"
},
......@@ -1722,9 +1724,14 @@
"php-cs-fixer"
],
"type": "application",
"extra": {
"branch-alias": {
"dev-master": "2.0-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\CS\\": "Symfony/CS/"
"PhpCsFixer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
......@@ -1742,7 +1749,7 @@
}
],
"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",
......@@ -3253,6 +3260,64 @@
"homepage": "https://symfony.com",
"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",
"version": "v3.2.0",
......
......@@ -16,11 +16,9 @@ COUNTER=0
for FILE in $(git diff-tree --no-commit-id --name-only -r HEAD | grep '.php$'); do
if [ -e $FILE ]
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 \
-v \
--level=psr2 \
--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
--config=Build/.php_cs
if [ "$?" = "1" ]
then
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