Skip to content

Commit

Permalink
Merge pull request #29 from jolicode/fix/28
Browse files Browse the repository at this point in the history
Fix #28, the NoSpaceBeforeComma pattern was matching digits too
  • Loading branch information
damienalexandre committed May 25, 2016
2 parents 2bf3a5d + afd696e commit 7e5b849
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
6 changes: 5 additions & 1 deletion 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) ###

Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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.

Expand Down
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -27,6 +27,7 @@
}
},
"require-dev": {
"fabpot/php-cs-fixer": "^1.11"
"fabpot/php-cs-fixer": "^1.11",
"phpunit/phpunit": "@stable"
}
}
2 changes: 1 addition & 1 deletion phpunit.xml.dist
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<phpunit bootstrap="vendor/autoload.php" colors="true">
<testsuites>
<testsuite name="JoliTypo Test Suite">
<directory>tests/JoliTypo/</directory>
Expand Down
2 changes: 1 addition & 1 deletion src/JoliTypo/Fixer/NoSpaceBeforeComma.php
Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/JoliTypo/Tests/Fixer/NoSpaceBeforeCommaTest.php
Expand Up @@ -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"));
}
}
11 changes: 0 additions & 11 deletions tests/bootstrap.php

This file was deleted.

0 comments on commit 7e5b849

Please sign in to comment.