You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -61,7 +61,7 @@ <h2>No config<a class="headerlink" href="#no-config" title="Permalink to this he
61
61
</div>
62
62
<p>While it is possible to provide command line options to configure rules,
63
63
it’s recommended to save the project configuration in a <codeclass="docutils literal notranslate"><spanclass="pre">.php-cs-fixer.dist.php</span></code> file in the root directory of your project.
64
-
The file must return an instance of <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.0/src/ConfigInterface.php">PhpCsFixer\ConfigInterface</a>,
64
+
The file must return an instance of <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.1/src/ConfigInterface.php">PhpCsFixer\ConfigInterface</a>,
65
65
which lets you configure the rules, finder (the files and directories that
66
66
need to be analysed), select output format and even configure path to <codeclass="docutils literal notranslate"><spanclass="pre">PHP</span></code>.</p>
67
67
<p>You may also create <codeclass="docutils literal notranslate"><spanclass="pre">.php-cs-fixer.php</span></code> file, which is
@@ -66,8 +66,8 @@ <h2>Background<a class="headerlink" href="#background" title="Permalink to this
66
66
discouraged - it is meant only to give more people more chance to
67
67
contribute, and to detect bugs (<aclass="reference external" href="https://en.wikipedia.org/wiki/Linus%27s_Law">Linus’s Law</a>).</p>
68
68
<p>If possible, try to get acquainted with the public interface for the
69
-
<aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.0/src/Tokenizer/Tokens.php">PhpCsFixer\Tokenizer\Tokens</a> and
<aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.1/src/Tokenizer/Tokens.php">PhpCsFixer\Tokenizer\Tokens</a> and
<h2>Assumptions<aclass="headerlink" href="#assumptions" title="Permalink to this heading">¶</a></h2>
@@ -81,8 +81,8 @@ <h2>Assumptions<a class="headerlink" href="#assumptions" title="Permalink to thi
81
81
</ul>
82
82
<p>In case you want to create a custom fixer for your own use, you can
83
83
follow this guide as well, but you will need to apply some changes on the go,
84
-
for example use <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.0/src/Fixer/FixerInterface.php">PhpCsFixer\Fixer\FixerInterface</a>
85
-
instead of <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.0/src/AbstractFixer.php">PhpCsFixer\AbstractFixer</a> (which is internal
84
+
for example use <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.1/src/Fixer/FixerInterface.php">PhpCsFixer\Fixer\FixerInterface</a>
85
+
instead of <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.1/src/AbstractFixer.php">PhpCsFixer\AbstractFixer</a> (which is internal
<p>Note how the class and file name match. Also keep in mind that all
140
-
fixers must implement <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.0/src/Fixer/FixerInterface.php">PhpCsFixer\Fixer\FixerInterface</a>. In this case, the fixer is
141
-
inheriting from <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.0/src/AbstractFixer.php">PhpCsFixer\AbstractFixer</a>, which fulfills the interface with some
140
+
fixers must implement <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.1/src/Fixer/FixerInterface.php">PhpCsFixer\Fixer\FixerInterface</a>. In this case, the fixer is
141
+
inheriting from <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.1/src/AbstractFixer.php">PhpCsFixer\AbstractFixer</a>, which fulfills the interface with some
142
142
default behaviour.</p>
143
143
<p>Now let us create the test file at
144
144
<codeclass="docutils literal notranslate"><spanclass="pre">tests/Fixer/Comment/RemoveCommentsFixerTest.php</span></code>. Put this content inside:</p>
<p>Next, we must filter what type of tokens we want to fix. Here, we are interested in code that contains <codeclass="docutils literal notranslate"><spanclass="pre">T_COMMENT</span></code> tokens:</p>
<p>If you need to enforce some specific code style rules, you can implement your
56
56
own fixers. There is a <aclass="reference internal" href="cookbook_fixers.html"><spanclass="doc">cookbook</span></a> with basic instructions on how to build a new fixer.</p>
57
57
<p>For each rule you want to add, create a class that implements
<p>There are several interfaces that your fixers can also implement if needed:</p>
80
80
<ulclass="simple">
81
-
<li><p><aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.0/src/Fixer/WhitespacesAwareFixerInterface.php">PhpCsFixer\Fixer\WhitespacesAwareFixerInterface</a>: for fixers that need to know the configured indentation and line endings;</p></li>
82
-
<li><p><aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.0/src/Fixer/ConfigurableFixerInterface.php">PhpCsFixer\Fixer\ConfigurableFixerInterface</a>: to create a configurable fixer;</p></li>
83
-
<li><p><aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.0/src/Fixer/DeprecatedFixerInterface.php">PhpCsFixer\Fixer\DeprecatedFixerInterface</a>: to deprecate a fixer.</p></li>
81
+
<li><p><aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.1/src/Fixer/WhitespacesAwareFixerInterface.php">PhpCsFixer\Fixer\WhitespacesAwareFixerInterface</a>: for fixers that need to know the configured indentation and line endings;</p></li>
82
+
<li><p><aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.1/src/Fixer/ConfigurableFixerInterface.php">PhpCsFixer\Fixer\ConfigurableFixerInterface</a>: to create a configurable fixer;</p></li>
83
+
<li><p><aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.91.1/src/Fixer/DeprecatedFixerInterface.php">PhpCsFixer\Fixer\DeprecatedFixerInterface</a>: to deprecate a fixer.</p></li>
<p>Migration rules to improve code towards the minimum <codeclass="docutils literal notranslate"><spanclass="pre">PHP</span></code> supported by your project (taken from <codeclass="docutils literal notranslate"><spanclass="pre">composer.json</span></code> file).</p>
56
56
<sectionid="warning">
57
57
<h2>Warning<aclass="headerlink" href="#warning" title="Permalink to this heading">¶</a></h2>
58
-
<sectionid="automatic-rule-set">
59
-
<h3>Automatic rule set<aclass="headerlink" href="#automatic-rule-set" title="Permalink to this heading">¶</a></h3>
60
-
<p>⚡ This rule is automatic: it’s definition depends on your project, eg “composer.json” file.</p>
58
+
<sectionid="this-rule-set-is-automatic">
59
+
<h3>This rule set is AUTOMATIC<aclass="headerlink" href="#this-rule-set-is-automatic" title="Permalink to this heading">¶</a></h3>
60
+
<p>⚡ This rule is automatic: it’s definition depends on your project, eg
<p>Migration rules to improve code towards the minimum <codeclass="docutils literal notranslate"><spanclass="pre">PHP</span></code> supported by your project (taken from <codeclass="docutils literal notranslate"><spanclass="pre">composer.json</span></code> file).</p>
56
56
<sectionid="warnings">
57
57
<h2>Warnings<aclass="headerlink" href="#warnings" title="Permalink to this heading">¶</a></h2>
<h3>This set contains rules that are risky<aclass="headerlink" href="#this-set-contains-rules-that-are-risky" title="Permalink to this heading">¶</a></h3>
60
-
<p>Using this rule set may lead to changes in your code’s logic and behaviour. Use it with caution and review changes before incorporating them into your code base.</p>
58
+
<sectionid="this-rule-set-is-risky">
59
+
<h3>This rule set is RISKY<aclass="headerlink" href="#this-rule-set-is-risky" title="Permalink to this heading">¶</a></h3>
60
+
<p>This set contains rules that are risky. Using it may lead to changes in your
61
+
code’s logic and behaviour. Use it with caution and review changes before
62
+
incorporating them into your code base.</p>
61
63
</section>
62
-
<sectionid="automatic-rule-set">
63
-
<h3>Automatic rule set<aclass="headerlink" href="#automatic-rule-set" title="Permalink to this heading">¶</a></h3>
64
-
<p>⚡ This rule is automatic: it’s definition depends on your project, eg “composer.json” file.</p>
64
+
<sectionid="this-rule-set-is-automatic">
65
+
<h3>This rule set is AUTOMATIC<aclass="headerlink" href="#this-rule-set-is-automatic" title="Permalink to this heading">¶</a></h3>
66
+
<p>⚡ This rule is automatic: it’s definition depends on your project, eg
<p>Migration rules to improve test code towards the minimum <codeclass="docutils literal notranslate"><spanclass="pre">PHPUnit</span></code> supported by your project (taken from <codeclass="docutils literal notranslate"><spanclass="pre">composer.json</span></code> file).</p>
56
56
<sectionid="warnings">
57
57
<h2>Warnings<aclass="headerlink" href="#warnings" title="Permalink to this heading">¶</a></h2>
<h3>This set contains rules that are risky<aclass="headerlink" href="#this-set-contains-rules-that-are-risky" title="Permalink to this heading">¶</a></h3>
60
-
<p>Using this rule set may lead to changes in your code’s logic and behaviour. Use it with caution and review changes before incorporating them into your code base.</p>
58
+
<sectionid="this-rule-set-is-risky">
59
+
<h3>This rule set is RISKY<aclass="headerlink" href="#this-rule-set-is-risky" title="Permalink to this heading">¶</a></h3>
60
+
<p>This set contains rules that are risky. Using it may lead to changes in your
61
+
code’s logic and behaviour. Use it with caution and review changes before
62
+
incorporating them into your code base.</p>
61
63
</section>
62
-
<sectionid="automatic-rule-set">
63
-
<h3>Automatic rule set<aclass="headerlink" href="#automatic-rule-set" title="Permalink to this heading">¶</a></h3>
64
-
<p>⚡ This rule is automatic: it’s definition depends on your project, eg “composer.json” file.</p>
64
+
<sectionid="this-rule-set-is-automatic">
65
+
<h3>This rule set is AUTOMATIC<aclass="headerlink" href="#this-rule-set-is-automatic" title="Permalink to this heading">¶</a></h3>
66
+
<p>⚡ This rule is automatic: it’s definition depends on your project, eg
<h3>This set contains rules that are risky<aclass="headerlink" href="#this-set-contains-rules-that-are-risky" title="Permalink to this heading">¶</a></h3>
60
-
<p>Using this rule set may lead to changes in your code’s logic and behaviour. Use it with caution and review changes before incorporating them into your code base.</p>
58
+
<sectionid="this-rule-set-is-risky">
59
+
<h3>This rule set is RISKY<aclass="headerlink" href="#this-rule-set-is-risky" title="Permalink to this heading">¶</a></h3>
60
+
<p>This set contains rules that are risky. Using it may lead to changes in your
61
+
code’s logic and behaviour. Use it with caution and review changes before
62
+
incorporating them into your code base.</p>
61
63
</section>
62
-
<sectionid="automatic-rule-set">
63
-
<h3>Automatic rule set<aclass="headerlink" href="#automatic-rule-set" title="Permalink to this heading">¶</a></h3>
64
-
<p>⚡ This rule is automatic: it’s definition depends on your project, eg “composer.json” file.</p>
64
+
<sectionid="this-rule-set-is-automatic">
65
+
<h3>This rule set is AUTOMATIC<aclass="headerlink" href="#this-rule-set-is-automatic" title="Permalink to this heading">¶</a></h3>
66
+
<p>⚡ This rule is automatic: it’s definition depends on your project, eg
0 commit comments