Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* @see https://hackernoon.com/how-to-configure-phpstorm-to-use-php-cs-fixer-1844991e521f
*/

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

require __DIR__ . '/vendor/autoload.php';

$finder = (new Finder())
->files()
->name('*.php')
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
;

/**
* Cache file for PHP-CS
*/
$cacheFilePath = sprintf('%s%sphp_cs.cache-%s', sys_get_temp_dir(), DIRECTORY_SEPARATOR, md5(__DIR__));

/**
* Configuration
*
* @see https://mlocati.github.io/php-cs-fixer-configurator/#
*/
return (new Config('pecee-pixie'))
->setCacheFile($cacheFilePath)
->setRiskyAllowed(true)
->setRules([
// default
'@PSR2' => true,
'@Symfony' => true,
// additionally
'array_syntax' => ['syntax' => 'short'],
'concat_space' => false,
'cast_spaces' => false,
'no_unused_imports' => false,
'no_useless_else' => true,
'no_useless_return' => true,
'no_superfluous_phpdoc_tags' => false,
'ordered_imports' => true,
'phpdoc_align' => true,
'phpdoc_order' => true,
'phpdoc_trim' => true,
'phpdoc_summary' => false,
'simplified_null_return' => false,
'ternary_to_null_coalescing' => true,
'binary_operator_spaces' => ['default' => 'align'],
])
->setFinder($finder)
;
10 changes: 9 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"require-dev": {
"phpunit/phpunit": "^6.0",
"mockery/mockery": "^1",
"ext-pdo_sqlite": "*"
"ext-pdo_sqlite": "*",
"friendsofphp/php-cs-fixer": "^2"
},
"suggest": {
"ext-pdo_sqlite": "Add extension for SQLite support"
Expand All @@ -49,5 +50,12 @@
"psr-4": {
"Pecee\\Pixie\\": "src/Pecee/Pixie/"
}
},
"scripts": {
"test": [
"@lint"
],
"fixer": "php-cs-fixer fix --diff --show-progress=dots",
"lint": "php-cs-fixer fix --diff --dry-run"
}
}
Loading