Skip to content

Commit

Permalink
Merge branch 'hotfix/14' into develop
Browse files Browse the repository at this point in the history
Forward port #14
  • Loading branch information
michalbundyra committed May 12, 2019
2 parents f3a9de5 + 3b3a346 commit e650fa1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- Nothing.
- [#14](https://github.com/webimpress/coding-standard/pull/14) `Formatting\StringClassReference` - fixes regular expression to check if string is valid FQCN

## 1.0.1 - 2019-05-11

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use function interface_exists;
use function ltrim;
use function preg_match;
use function str_replace;
use function strpos;
use function strtr;
use function substr;
use function trait_exists;

Expand All @@ -38,17 +38,8 @@ public function process(File $phpcsFile, $stackPtr)
return;
}

$name = strtr($tokens[$stackPtr]['content'], [
'"' => '',
"'" => '',
'\\\\' => '\\',
]);

if (strpos($name, '\\\\') !== false
|| preg_match('/[^\\a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]/', $name)
|| substr($name, -1) === '\\'
|| ltrim($name, '\\') === ''
) {
$name = substr(str_replace('\\\\', '\\', $tokens[$stackPtr]['content']), 1, -1);
if (! preg_match('/^(\\\\?[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*)+$/', $name)) {
return;
}

Expand Down
2 changes: 2 additions & 0 deletions test/Sniffs/Formatting/StringClassReferenceUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ $spaceAtTheEnd = ' WebimpressCodingStandardTest\\Ruleset ';

$namespaceSeparatorAtTheEnd = 'WebimpressCodingStandardTest\\Ruleset\\';
$justNamespaceSeparator = '\\';

$quotes = '"\DateTime"';
2 changes: 2 additions & 0 deletions test/Sniffs/Formatting/StringClassReferenceUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ $spaceAtTheEnd = ' WebimpressCodingStandardTest\\Ruleset ';

$namespaceSeparatorAtTheEnd = 'WebimpressCodingStandardTest\\Ruleset\\';
$justNamespaceSeparator = '\\';

$quotes = '"\DateTime"';

0 comments on commit e650fa1

Please sign in to comment.