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
@@ -60,9 +60,9 @@ <h2>No config<a class="headerlink" href="#no-config" title="Permalink to this he
60
60
</div>
61
61
<p>It is also possible to provide command line options to customize rules, yet instead of using them,
62
62
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.
63
-
The file must return an instance of <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.89.1/src/ConfigInterface.php">PhpCsFixer\ConfigInterface</a>
63
+
The file must return an instance of <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.89.2/src/ConfigInterface.php">PhpCsFixer\ConfigInterface</a>
64
64
which lets you configure the rules, the files and directories that
65
-
need to be analyzed. You may also create <codeclass="docutils literal notranslate"><spanclass="pre">.php-cs-fixer.php</span></code> file, which is
65
+
need to be analysed. You may also create <codeclass="docutils literal notranslate"><spanclass="pre">.php-cs-fixer.php</span></code> file, which is
66
66
the local configuration that will be used instead of the project configuration. It
67
67
is a good practice to add that file into your <codeclass="docutils literal notranslate"><spanclass="pre">.gitignore</span></code> file.
68
68
With the <codeclass="docutils literal notranslate"><spanclass="pre">--config</span></code> option you can specify the path to the config file.</p>
@@ -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.89.1/src/Tokenizer/Tokens.php">PhpCsFixer\Tokenizer\Tokens</a> and
<aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.89.2/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.89.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.89.1/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.89.2/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.89.2/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.89.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.89.1/src/AbstractFixer.php">PhpCsFixer\AbstractFixer</a>, which fulfills the interface with some
142
-
default behavior.</p>
140
+
fixers must implement <aclass="reference external" href="https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/blob/v3.89.2/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.89.2/src/AbstractFixer.php">PhpCsFixer\AbstractFixer</a>, which fulfills the interface with some
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>
<h3>Step 2 - Using tests to define fixers behavior<aclass="headerlink" href="#step-2-using-tests-to-define-fixers-behavior" title="Permalink to this heading">¶</a></h3>
<h3>Step 2 - Using tests to define fixers behaviour<aclass="headerlink" href="#step-2-using-tests-to-define-fixers-behaviour" title="Permalink to this heading">¶</a></h3>
188
188
<p>Now that the files are created, you can start writing tests to define the
189
-
behavior of the fixer. You have to do it in two ways: first, ensuring
189
+
behaviour of the fixer. You have to do it in two ways: first, ensuring
190
190
the fixer changes what it should be changing; second, ensuring that
191
191
fixer does not change what is not supposed to change. Thus:</p>
192
192
<p>Keeping things as they are:</p>
@@ -270,7 +270,7 @@ <h3>Step 2 - Using tests to define fixers behavior<a class="headerlink" href="#s
270
270
</section>
271
271
<sectionid="step-3-implement-your-solution">
272
272
<h3>Step 3 - Implement your solution<aclass="headerlink" href="#step-3-implement-your-solution" title="Permalink to this heading">¶</a></h3>
273
-
<p>You have defined the behavior of your fixer in tests. Now it is time to
273
+
<p>You have defined the behaviour of your fixer in tests. Now it is time to
274
274
implement it.</p>
275
275
<p>First, we need to create one method to describe what this fixer does:</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.89.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.89.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.89.1/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.89.2/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.89.2/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.89.2/src/Fixer/DeprecatedFixerInterface.php">PhpCsFixer\Fixer\DeprecatedFixerInterface</a>: to deprecate a fixer.</p></li>
0 commit comments