Skip to content

Commit

Permalink
further updates
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Oct 29, 2023
1 parent 92c69ab commit dd4f49f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 27 deletions.
7 changes: 2 additions & 5 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
with this source code in the file LICENSE.
EOF;

$finder = PhpCsFixer\Finder::create()
$finder = (new PhpCsFixer\Finder())
->ignoreDotFiles(false)
->ignoreVCSIgnored(true)
->exclude(['dev-tools/phpstan', 'tests/Fixtures'])
->in(__DIR__)
;

$config = new PhpCsFixer\Config();
$config
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PHP74Migration' => true,
Expand All @@ -45,5 +44,3 @@
])
->setFinder($finder)
;

return $config;
57 changes: 35 additions & 22 deletions doc/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ The simplest config declares paths under control and rules to apply/check:
<?php
$finder = new PhpCsFixer\Finder()
$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
;
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
return (new PhpCsFixer\Config())
->setRules([
'@PER-CS' => true,
'@PHP82Migration' => true,
])
->setFinder($finder)
;
Expand All @@ -52,15 +53,21 @@ The example below will manipulate which paths to fix or not:
<?php
$finder = new PhpCsFixer\Finder()
$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude(['autogenerated_content', 'tests/fixtures'])
->notPath(['dump.php', 'src/exception_file.php'])
->exclude([
'autogenerated_content',
'tests/fixtures',
])
->notPath([
'dump.php',
'src/exception_file.php',
])
;
$config = new PhpCsFixer\Config();
return $config->setRules([
'@PSR12' => true,
return (new PhpCsFixer\Config())
->setRules([
'@PhpCsFixer' => true,
])
->setFinder($finder)
;
Expand All @@ -80,12 +87,12 @@ The example below will add two rules to the default list of PSR12 set rules:
<?php
$finder = new PhpCsFixer\Finder()
$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
;
$config = new PhpCsFixer\Config();
return $config->setRules([
return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'strict_param' => true,
'array_syntax' => ['syntax' => 'short'],
Expand All @@ -94,21 +101,20 @@ The example below will add two rules to the default list of PSR12 set rules:
;
You may also use an exclude list for the rules instead of the above shown include approach.
The following example shows how to use all ``Symfony`` rules but the ``full_opening_tag`` rule.
The following example shows how to use all ``PhpCsFixer`` rules but without the ``align_multiline_comment`` rule.

.. code-block:: php
<?php
$finder = new PhpCsFixer\Finder()
$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
->exclude('somedir')
;
$config = new PhpCsFixer\Config();
return $config->setRules([
'@Symfony' => true,
'full_opening_tag' => false,
return (new PhpCsFixer\Config())
->setRules([
'@PhpCsFixer' => true,
'comment_type' => false,
])
->setFinder($finder)
;
Expand All @@ -123,8 +129,15 @@ configure them in your config file.
<?php
$config = new PhpCsFixer\Config();
return $config
$finder = (new PhpCsFixer\Finder())
->in(__DIR__)
;
return (new PhpCsFixer\Config())
->setRules([
'@Symfony' => true,
])
->setFinder($finder)
->setIndent("\t")
->setLineEnding("\r\n")
;

0 comments on commit dd4f49f

Please sign in to comment.