Skip to content

Instantly share code, notes, and snippets.

@ykocaman
Last active August 10, 2019 11:57
Show Gist options
  • Save ykocaman/0972fd1228565533e08e8385db48bbb7 to your computer and use it in GitHub Desktop.
Save ykocaman/0972fd1228565533e08e8385db48bbb7 to your computer and use it in GitHub Desktop.
<?php
// Symfony 2.8
require __DIR__.'/vendor/autoload.php';
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PhpCsFixer\Fixer\Import\OrderedImportsFixer;
return \PhpCsFixer\Config::create()
->setFinder(\PhpCsFixer\Finder::create()->in(__DIR__.'/src'))
->setUsingCache(false)
->setRiskyAllowed(true)
->setRules([
'psr0' => true,
'psr4' => true,
'ordered_imports' => ['sortAlgorithm' => OrderedImportsFixer::SORT_LENGTH],
'binary_operator_spaces' => ['align_equals' => true, 'align_double_arrow' => true],
]);
@ykocaman
Copy link
Author

ykocaman commented Aug 10, 2019

.php_cs for Symfony 4

<?php
$finder = Symfony\Component\Finder\Finder::create()
    ->in(__DIR__.'/src')
    ->name('*.php')
    ->notName('*.twig.php')
    ->ignoreDotFiles(true)
    ->ignoreVCS(true)
;

return PhpCsFixer\Config::create()
    ->setFinder($finder)
    ->setUsingCache(false)
    ->setRiskyAllowed(true)
    ->setRules(array(
        '@Symfony' => true,
        'array_syntax' => ['syntax' => 'short'],
        'binary_operator_spaces' => ['align_equals' => true, 'align_double_arrow' => true],
        'linebreak_after_opening_tag' => true,
        'not_operator_with_successor_space' => true,
        'ordered_imports' => ['sortAlgorithm' => PhpCsFixer\Fixer\Import\OrderedImportsFixer::SORT_LENGTH],
        'phpdoc_order' => true,
        'psr0' => true,
        'psr4' => true,
    ))
;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment