diff --git a/CHANGELOG.md b/CHANGELOG.md index 0875869..05d3f01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [2.1.1] - 2018-05-17 +### Changed +- Check for empty needle when calling str_pos, fixes #78 + ## [2.1.0] - 2018-04-06 ### Changed - PHPCS version 3.2.3 or later is required. diff --git a/MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php b/MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php index a442931..46b00e5 100644 --- a/MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php +++ b/MO4/Sniffs/Formatting/UnnecessaryNamespaceUsageSniff.php @@ -364,7 +364,7 @@ private function checkShorthandPossible( ); $replaceClassName = true; - } else if (strpos($fullClassName, $namespace) === 0) { + } else if ($namespace !== "" && strpos($fullClassName, $namespace) === 0) { $replacement = substr($fullClassName, strlen($namespace)); $data = [ diff --git a/MO4/Tests/Formatting/UnnecessaryNamespaceUsageUnitTest.pass.5.inc b/MO4/Tests/Formatting/UnnecessaryNamespaceUsageUnitTest.pass.5.inc new file mode 100644 index 0000000..cd5a2a2 --- /dev/null +++ b/MO4/Tests/Formatting/UnnecessaryNamespaceUsageUnitTest.pass.5.inc @@ -0,0 +1,12 @@ +