mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°8796 - Add PHP code style validation in iTop and extensions (#757)
* poc php-cs-fixer * PSR2 for now * PSR12 + array short * move php-cs-fixer stuff in tests/php-code-style * add README * fix php-cs-fixer move into php-code-style * illustrate code reformatting on webservices folder * phpstan: change composer php requirements * indent with tabs + inception style applied everywhere even php-cs-fixer itself * use tabs for code style indentation * format concat with spaces * finalize included/excluded folders to formatting tool * add trailing_comma_in_multiline option * adapt composer.json requirements * Revert changes on webservices folder
This commit is contained in:
25
tests/php-code-style/.php-cs-fixer.dist.php
Normal file
25
tests/php-code-style/.php-cs-fixer.dist.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
$APPROOT = dirname(__DIR__, 2);
|
||||
|
||||
echo $APPROOT;
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in($APPROOT)
|
||||
->exclude(['oql', 'data', 'extensions'])
|
||||
->notPath(['/env-*/', '/cache-*/', 'lib', 'vendor', 'node_modules'])
|
||||
;
|
||||
|
||||
$config = new PhpCsFixer\Config();
|
||||
return $config->setRiskyAllowed(true)
|
||||
->setRules([
|
||||
'@PSR12' => true,
|
||||
'indentation_type' => true,
|
||||
'no_extra_blank_lines' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'concat_space' => true,
|
||||
'trailing_comma_in_multiline' => true,
|
||||
])
|
||||
->setIndent("\t")
|
||||
->setLineEnding("\n")
|
||||
->setFinder($finder)
|
||||
;
|
||||
17
tests/php-code-style/README.md
Normal file
17
tests/php-code-style/README.md
Normal file
@@ -0,0 +1,17 @@
|
||||
Code formatting tool used by iTop is PHP-CS-Fixer:
|
||||
https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/master
|
||||
|
||||
|
||||
to check code style issues (no path provided means whole iTop code base):
|
||||
|
||||
```
|
||||
cd tests/php-code-style/; composer install; cd -
|
||||
tests/php-code-style/vendor/bin/php-cs-fixer check --config tests/php-code-style/.php-cs-fixer.dist.php [PATH]
|
||||
```
|
||||
|
||||
to respect iTop code standards and re-format (no path provided means whole iTop code base):
|
||||
|
||||
```
|
||||
tests/php-code-style/vendor/bin/php-cs-fixer fix --config tests/php-code-style/.php-cs-fixer.dist.php [PATH]
|
||||
|
||||
```
|
||||
7
tests/php-code-style/composer.json
Normal file
7
tests/php-code-style/composer.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"require-dev": {
|
||||
"php": "^7.0 || ^8.0",
|
||||
"friendsofphp/php-cs-fixer": "^3.89",
|
||||
"phpstan/phpstan": "^2.1"
|
||||
}
|
||||
}
|
||||
2792
tests/php-code-style/composer.lock
generated
Normal file
2792
tests/php-code-style/composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user