Skip to content
Snippets Groups Projects
Commit be80f834 authored by Benjamin Mack's avatar Benjamin Mack Committed by Christian Kuhn
Browse files

[TASK] Add PSR-2 related Code Sniffer configuration

Add a configuration file to automatically change all TYPO3 Core
code to the PSR-2 standard plus some minor additions.

To be called like this:
$ composer global require fabpot/php-cs-fixer
$ php-cs-fixer fix --config-file Build/.php_cs

Resolves: #70506
Releases: master
Change-Id: Ibe48bbc4160697524fa89d130ff3ce3530337d0e
Reviewed-on: http://review.typo3.org/43729


Reviewed-by: default avatarOliver Hader <oliver.hader@typo3.org>
Tested-by: default avatarOliver Hader <oliver.hader@typo3.org>
Reviewed-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: default avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 752a5954
Branches
Tags
No related merge requests found
<?php
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
/**
* This file represents the configuration for Code Sniffing PSR-2-related
* automatic checks of coding guidelines
* Install @fabpot's great php-cs-fixer tool via
*
* $ composer global require fabpot/php-cs-fixer
*
* And then simply run
*
* $ php-cs-fixer fix --config-file Build/.php_cs
*
* inside the TYPO3 directory. Warning: This may take up to 10 minutes.
*
* For more information read:
* 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()
->exclude('vendor')
->exclude('typo3conf')
->exclude('typo3temp')
->exclude('adodb')
->exclude('php-openid')
->in(__DIR__ . '/../');
// Return a Code Sniffing configuration using
// all sniffers needed for PSR-2
// and additionally:
// - Remove leading slashes in use clauses.
// - PHP single-line arrays should not have trailing comma.
// - Single-line whitespace before closing semicolon are prohibited.
// - 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([
'remove_leading_slash_use',
'single_array_no_trailing_comma',
'spaces_before_semicolon',
'unused_use',
'concat_with_spaces',
'whitespacy_lines'
])
->finder($finder);
\ No newline at end of file
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