Skip to content

Commit

Permalink
Merge branch 'hotfix/7'
Browse files Browse the repository at this point in the history
Close #7
  • Loading branch information
michalbundyra committed May 10, 2019
2 parents d73bece + c559502 commit 6b788d1
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ All notable changes to this project will be documented in this file, in reverse

- [#6](https://github.com/webimpress/coding-standard/pull/6) `Commenting\Placement` - fixes false-positive when space was required before comment in next line after PHP open tag

- [#7](https://github.com/webimpress/coding-standard/pull/7) `Commenting\DocComment` - fixes false-positive when new line was required before doc-block

## 1.0.0 - 2019-03-07

Initial release.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
use const T_DOC_COMMENT_WHITESPACE;
use const T_NAMESPACE;
use const T_OPEN_CURLY_BRACKET;
use const T_OPEN_PARENTHESIS;
use const T_OPEN_SHORT_ARRAY;
use const T_OPEN_TAG;
use const T_USE;
use const T_WHITESPACE;
Expand Down Expand Up @@ -182,8 +184,12 @@ private function checkBeforeOpen(File $phpcsFile, int $commentStart) : void
$phpcsFile->fixer->endChangeset();
}
} elseif ($tokens[$previous]['line'] === $tokens[$commentStart]['line'] - 1
&& $tokens[$previous]['code'] !== T_OPEN_TAG
&& $tokens[$previous]['code'] !== T_OPEN_CURLY_BRACKET
&& ! in_array($tokens[$previous]['code'], [
T_OPEN_CURLY_BRACKET,
T_OPEN_PARENTHESIS,
T_OPEN_SHORT_ARRAY,
T_OPEN_TAG,
], true)
) {
$error = 'Missing blank line before doc comment';
$fix = $phpcsFile->addFixableError($error, $commentStart, 'MissingBlankLine');
Expand Down
26 changes: 26 additions & 0 deletions test/Sniffs/Commenting/DocCommentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -260,4 +260,30 @@ class Foo
* bar baz
*/
public function descriptionIndentWithTags() {}

public function docCommentInArray() : array
{
return [
/**
* @param mixed $a
* @return mixed
*/
static function ($a) {
return $a;
},
];
}

public function docCommentInFunctionCall() : callable
{
$this->getName(
/**
* @param mixed $a
* @return mixed
*/
static function ($a) {
return $a;
}
);
}
}
26 changes: 26 additions & 0 deletions test/Sniffs/Commenting/DocCommentUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +262,30 @@ $c = 'xyz';
* bar baz
*/
public function descriptionIndentWithTags() {}

public function docCommentInArray() : array
{
return [
/**
* @param mixed $a
* @return mixed
*/
static function ($a) {
return $a;
},
];
}

public function docCommentInFunctionCall() : callable
{
$this->getName(
/**
* @param mixed $a
* @return mixed
*/
static function ($a) {
return $a;
}
);
}
}

0 comments on commit 6b788d1

Please sign in to comment.