From e7fc703d14f184a0674ff7edd517de819f7eedcc Mon Sep 17 00:00:00 2001 From: Damien ALEXANDRE Date: Wed, 25 May 2016 15:23:09 +0200 Subject: [PATCH 1/2] Fix #28, the NoSpaceBeforeComma pattern was matching digits too --- CHANGELOG.md | 6 +++++- README.md | 2 +- composer.json | 3 ++- phpunit.xml.dist | 2 +- src/JoliTypo/Fixer/NoSpaceBeforeComma.php | 2 +- tests/JoliTypo/Tests/Fixer/NoSpaceBeforeCommaTest.php | 2 ++ tests/bootstrap.php | 11 ----------- 7 files changed, 12 insertions(+), 16 deletions(-) delete mode 100644 tests/bootstrap.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 3552a86..9f99431 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ CHANGELOG ========= -### ??? ### +### Unreleased ### + +### 1.0.1 (2015-12-13) ### + +* fix #28, NoSpaceBeforeComma should not change spaces inside digits ### 1.0 (2015-12-13) ### diff --git a/README.md b/README.md index 8781fdd..8ae3edd 100644 --- a/README.md +++ b/README.md @@ -254,7 +254,7 @@ Add your own Fixer / Contribute a Fixer - You MUST write code in english; - you MUST follow PSR2 and Symfony coding standard (run `./vendor/bin/php-cs-fixer -vvv fix` on your branch); -- you MUST run the tests (run `phpunit`); +- you MUST run the tests (run `./vendor/bin/phpunit`); - you MUST comply to the MIT license; - you SHOULD write documentation. diff --git a/composer.json b/composer.json index 8dbd94c..285800f 100644 --- a/composer.json +++ b/composer.json @@ -27,6 +27,7 @@ } }, "require-dev": { - "fabpot/php-cs-fixer": "^1.11" + "fabpot/php-cs-fixer": "^1.11", + "phpunit/phpunit": "^5.3" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 59d5061..75afc07 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,5 @@ - + tests/JoliTypo/ diff --git a/src/JoliTypo/Fixer/NoSpaceBeforeComma.php b/src/JoliTypo/Fixer/NoSpaceBeforeComma.php index eabc096..bff978f 100644 --- a/src/JoliTypo/Fixer/NoSpaceBeforeComma.php +++ b/src/JoliTypo/Fixer/NoSpaceBeforeComma.php @@ -20,7 +20,7 @@ class NoSpaceBeforeComma implements FixerInterface { public function fix($content, StateBag $stateBag = null) { - $content = preg_replace('@(\w+)['.Fixer::ALL_SPACES.']*(,)['.Fixer::ALL_SPACES.']*@mu', '$1$2 ', $content); + $content = preg_replace('@([^\d\s]+)['.Fixer::ALL_SPACES.']*(,)['.Fixer::ALL_SPACES.']*@mu', '$1$2 ', $content); return $content; } diff --git a/tests/JoliTypo/Tests/Fixer/NoSpaceBeforeCommaTest.php b/tests/JoliTypo/Tests/Fixer/NoSpaceBeforeCommaTest.php index a19b1ee..44caf1a 100644 --- a/tests/JoliTypo/Tests/Fixer/NoSpaceBeforeCommaTest.php +++ b/tests/JoliTypo/Tests/Fixer/NoSpaceBeforeCommaTest.php @@ -23,5 +23,7 @@ public function testSimpleString() $this->assertEquals("Superman, you're my hero", $fixer->fix("Superman,you're my hero")); $this->assertEquals("Superman, you're my hero", $fixer->fix("Superman ,you're my hero")); $this->assertEquals("Superman, you're my hero", $fixer->fix("Superman , you're my hero")); + $this->assertEquals("F, bar", $fixer->fix("F,bar")); + $this->assertEquals("Seule 1,7 million de personnes", $fixer->fix("Seule 1,7 million de personnes")); } } diff --git a/tests/bootstrap.php b/tests/bootstrap.php deleted file mode 100644 index d215965..0000000 --- a/tests/bootstrap.php +++ /dev/null @@ -1,11 +0,0 @@ -add('JoliTypo\Tests', __DIR__); From afd696e49c8dfc088c3b3ccb7912fe45ce081aea Mon Sep 17 00:00:00 2001 From: Damien Alexandre Date: Thu, 26 May 2016 00:22:21 +0200 Subject: [PATCH 2/2] Trying to fix travis test --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 285800f..d834ca1 100644 --- a/composer.json +++ b/composer.json @@ -28,6 +28,6 @@ }, "require-dev": { "fabpot/php-cs-fixer": "^1.11", - "phpunit/phpunit": "^5.3" + "phpunit/phpunit": "@stable" } }