Skip to content

Commit

Permalink
Install, configure & use PHP-CS-Fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicLuidold committed Apr 1, 2024
1 parent 4ff744f commit 47d967e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@
/vendor/
/composer.phar
/composer.lock
/.php_cs.cache
/.php_cs
/phpunit.xml
/.phpunit
/.phpunit.result.cache
/Tests/Functional/cache
/Tests/Functional/logs
.idea

###> friendsofphp/php-cs-fixer ###
/.php-cs-fixer.php
/.php-cs-fixer.cache
###< friendsofphp/php-cs-fixer ###
15 changes: 7 additions & 8 deletions .php_cs.dist → .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<?php

$finder = PhpCsFixer\Finder::create()
declare(strict_types=1);

$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude('var')
->exclude('Tests/Functional/cache')
;
->exclude('tests/Functional/cache');

return PhpCsFixer\Config::create()
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
'header_comment' => [
'header' => <<<HEADER
This file is part of the NelmioApiDocBundle package.
Expand All @@ -21,6 +20,6 @@
file that was distributed with this source code.
HEADER
],
'nullable_type_declaration_for_default_null_value' => false,
])
->setFinder($finder)
;
->setFinder($finder);
7 changes: 6 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"composer/package-versions-deprecated": "1.11.99.1",

"phpunit/phpunit": "^8.5|^9.6",
"doctrine/annotations": "^2.0"
"doctrine/annotations": "^2.0",
"friendsofphp/php-cs-fixer": "^3.52"
},
"conflict": {
"zircote/swagger-php": "4.8.7"
Expand Down Expand Up @@ -91,9 +92,13 @@
}
},
"scripts-descriptions": {
"phpcs-check": "Run PHP-CS-Fixer in dry-run mode",
"phpcs-fix": "Run PHP-CS-Fixer",
"phpunit": "Run phpunit"
},
"scripts": {
"phpcs-check": "vendor/bin/php-cs-fixer check -v --diff",
"phpcs-fix": "vendor/bin/php-cs-fixer fix -v",
"phpunit": "phpunit"
}
}

0 comments on commit 47d967e

Please sign in to comment.