@@ -21,8 +21,8 @@ contribute, and to detect bugs ([Linus'
2121Law] ( http://en.wikipedia.org/wiki/Linus%27s_Law ) ).
2222
2323If possible, try to get acquainted with the public interface for the
24- [ Tokens class] ( Symfony/CS /Tokenizer/Tokens.php)
25- and [ Token class] ( Symfony/CS /Tokenizer/Token.php)
24+ [ Tokens class] ( /src /Tokenizer/Tokens.php)
25+ and [ Token class] ( /src /Tokenizer/Token.php)
2626classes.
2727
2828## Assumptions
@@ -31,7 +31,7 @@ classes.
3131* Forked FriendsOfPHP/PHP-CS-Fixer into your own Github Account.
3232* Cloned your forked repository locally.
3333* Installed the dependencies of PHP CS Fixer using [ Composer] ( https://getcomposer.org/ ) .
34- * You have read [ ` CONTRIBUTING.md ` ] ( CONTRIBUTING.md ) .
34+ * You have read [ ` CONTRIBUTING.md ` ] ( / CONTRIBUTING.md) .
3535
3636## Step by step
3737
@@ -43,8 +43,7 @@ We are calling it `remove_comments` (code name), or,
4343
4444### Step 1 - Creating files
4545
46- Create a new file in
47- ` PHP-CS-Fixer/Symfony/CS/Fixer/Contrib/RemoveCommentsFixer.php ` .
46+ Create a new file in ` src/Fixer/Comment/RemoveCommentsFixer.php ` .
4847Put this content inside:
4948``` php
5049<?php
@@ -92,8 +91,7 @@ inheriting from `AbstractFixer`, which fulfills the interface with some
9291default behavior.
9392
9493Now let us create the test file at
95- ` Symfony/CS/Tests/Fixer/Contrib/RemoveCommentsFixerTest.php ` . Put this
96- content inside:
94+ ` tests/Fixer/Comment/RemoveCommentsFixerTest.php ` . Put this content inside:
9795
9896``` php
9997<?php
@@ -147,7 +145,7 @@ the fixer changes what it should be changing; second, ensuring that
147145fixer does not change what is not supposed to change. Thus:
148146
149147#### Keeping things as they are:
150- ` Symfony/CS/Tests/ Fixer/Contrib /RemoveCommentsFixerTest.php` @provideFixCases:
148+ ` tests/ Fixer/Comment /RemoveCommentsFixerTest.php` @provideFixCases:
151149``` php
152150 ...
153151 public function provideFixCases()
@@ -160,7 +158,7 @@ fixer does not change what is not supposed to change. Thus:
160158```
161159
162160#### Ensuring things change:
163- ` Symfony/CS/Tests/ Fixer/Contrib /RemoveCommentsFixerTest.php` @provideFixCases:
161+ ` tests/ Fixer/Comment /RemoveCommentsFixerTest.php` @provideFixCases:
164162``` php
165163 ...
166164 public function provideFixCases()
@@ -179,7 +177,7 @@ Note that expected outputs are **always** tested alone to ensure your fixer will
179177
180178We want to have a failing test to start with, so the test file now looks
181179like:
182- ` Symfony/CS/Tests/ Fixer/Contrib /RemoveCommentsFixerTest.php`
180+ ` tests/ Fixer/Comment /RemoveCommentsFixerTest.php`
183181``` php
184182<?php
185183
@@ -230,7 +228,7 @@ You have defined the behavior of your fixer in tests. Now it is time to
230228implement it.
231229
232230We need first to create one method to describe what this fixer does:
233- ` Symfony/CS/ Fixer/Contrib /RemoveCommentsFixer.php` :
231+ ` src/ Fixer/Comment /RemoveCommentsFixer.php` :
234232``` php
235233final class RemoveCommentsFixer extends AbstractFixer
236234{
@@ -245,7 +243,7 @@ final class RemoveCommentsFixer extends AbstractFixer
245243```
246244
247245Next, we must filter what type of tokens we want to fix. Here, we are interested in code that contains ` T_COMMENT ` tokens:
248- ` Symfony/CS/ Fixer/Contrib /RemoveCommentsFixer.php` :
246+ ` src/ Fixer/Comment /RemoveCommentsFixer.php` :
249247``` php
250248final class RemoveCommentsFixer extends AbstractFixer
251249{
@@ -261,7 +259,7 @@ final class RemoveCommentsFixer extends AbstractFixer
261259```
262260
263261For now, let us just make a fixer that applies no modification:
264- ` Symfony/CS/ Fixer/Contrib /RemoveCommentsFixer.php` :
262+ ` src/ Fixer/Comment /RemoveCommentsFixer.php` :
265263``` php
266264class RemoveCommentsFixer extends AbstractFixer
267265{
@@ -276,7 +274,7 @@ class RemoveCommentsFixer extends AbstractFixer
276274}
277275```
278276
279- Run ` $ phpunit Symfony/CS/Tests/ Fixer/Contrib /RemoveCommentsFixerTest.php ` .
277+ Run ` $ phpunit tests/ Fixer/Comment /RemoveCommentsFixerTest.php ` .
280278You are going to see that the tests fails.
281279
282280### Break
@@ -300,7 +298,7 @@ defined by the PHP compiler. It is the ["List of Parser
300298Tokens"] ( http://php.net/manual/en/tokens.php ) .
301299
302300Internally, PHP CS Fixer transforms some of PHP native tokens into custom
303- tokens through the use of [ Transfomers] ( Symfony/CS /Tokenizer/Transformer) ,
301+ tokens through the use of [ Transfomers] ( /src /Tokenizer/Transformer) ,
304302they aim to help you reason about the changes you may want to do in the
305303fixers.
306304
@@ -311,7 +309,7 @@ one symbol name: `T_COMMENT`.
311309
312310We do not want all symbols to be analysed. Only ` T_COMMENT ` . So let us
313311iterate the token(s) we are interested in.
314- ` Symfony/CS/ Fixer/Contrib /RemoveCommentsFixer.php` :
312+ ` src/ Fixer/Comment /RemoveCommentsFixer.php` :
315313``` php
316314final class RemoveCommentsFixer extends AbstractFixer
317315{
@@ -334,7 +332,7 @@ final class RemoveCommentsFixer extends AbstractFixer
334332
335333OK, now for each ` T_COMMENT ` , all we need to do is check if the previous
336334token is a semicolon.
337- ` Symfony/CS/ Fixer/Contrib /RemoveCommentsFixer.php` :
335+ ` src/ Fixer/Comment /RemoveCommentsFixer.php` :
338336``` php
339337final class RemoveCommentsFixer extends AbstractFixer
340338{
@@ -352,7 +350,7 @@ final class RemoveCommentsFixer extends AbstractFixer
352350 $prevToken = $tokens[$prevTokenIndex];
353351
354352 if($prevToken->equals(';')){
355- $token->clear( );
353+ $tokens->clearAt($index );
356354 }
357355 }
358356 }
@@ -446,8 +444,7 @@ behavior mistakes of fixers. Expect to write few more tests to cater for
446444the reviews.
4474452 . People will discuss the relevance of your fixer. If it is
448446something that goes along with Symfony style standards, or PSR-1/PSR-2
449- standards, they will ask you to move from Symfony/CS/Fixers/Contrib to
450- Symfony/CS/Fixers/{Symfony, PSR2, etc}.
447+ standards, they will ask you to add it to existing ruleset.
4514483 . People will also discuss whether your fixer is idempotent or not.
452449If they understand that your fixer must always run before or after a
453450certain fixer, they will ask you to override a method named
0 commit comments