From be80f834c040d2a287529f3cebcfdecf096d45d9 Mon Sep 17 00:00:00 2001
From: Benjamin Mack <benni@typo3.org>
Date: Fri, 2 Oct 2015 10:08:21 +0200
Subject: [PATCH] [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: Oliver Hader <oliver.hader@typo3.org>
Tested-by: Oliver Hader <oliver.hader@typo3.org>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 Build/.php_cs | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 Build/.php_cs

diff --git a/Build/.php_cs b/Build/.php_cs
new file mode 100644
index 000000000000..5260d4acfec9
--- /dev/null
+++ b/Build/.php_cs
@@ -0,0 +1,65 @@
+<?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
-- 
GitLab