Skip to content

Commit

Permalink
Merge branch 'hotfix/19' into develop
Browse files Browse the repository at this point in the history
Forward port #19
  • Loading branch information
michalbundyra committed May 14, 2019
2 parents 95e282e + 2cc7c49 commit 8a66ce6
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ All notable changes to this project will be documented in this file, in reverse

- [#18](https://github.com/webimpress/coding-standard/pull/18) `Commenting\DocComment` - fixes requiring content straight after doc-block - allows empty line when next content is another doc-block

- [#19](https://github.com/webimpress/coding-standard/pull/19) `Commenting\DocComment` - fixes issue with doc-block after colon (for example in switch statement) - empty line is no longer required before doc-block in that case

## 1.0.2 - 2019-05-12

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use function substr;
use function trim;

use const T_COLON;
use const T_DOC_COMMENT_CLOSE_TAG;
use const T_DOC_COMMENT_OPEN_TAG;
use const T_DOC_COMMENT_STAR;
Expand Down Expand Up @@ -189,6 +190,7 @@ private function checkBeforeOpen(File $phpcsFile, int $commentStart) : void
T_OPEN_PARENTHESIS,
T_OPEN_SHORT_ARRAY,
T_OPEN_TAG,
T_COLON,
], true)
) {
$error = 'Missing blank line before doc comment';
Expand Down
21 changes: 20 additions & 1 deletion test/Sniffs/Commenting/DocCommentUnitTest.inc
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ class Foo
];
}

public function docCommentInFunctionCall() : callable
public function docCommentInFunctionCall() : void
{
$this->getName(
/**
Expand All @@ -287,6 +287,25 @@ class Foo
);
}

public function docCommentInSwitch(string $a)
{
switch ($a) {
case 'foo':
/** @var string $var */
$var = $this->getName();

return $var[0];
default:
/**
* @param int[] $a
* @return int
*/
return static function (array $a) {
return PHP_INT_MAX;
};
}
}

/**
* FIRST DOC-BLOCK COMMENT
*/
Expand Down
21 changes: 20 additions & 1 deletion test/Sniffs/Commenting/DocCommentUnitTest.inc.fixed
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ $c = 'xyz';
];
}

public function docCommentInFunctionCall() : callable
public function docCommentInFunctionCall() : void
{
$this->getName(
/**
Expand All @@ -289,6 +289,25 @@ $c = 'xyz';
);
}

public function docCommentInSwitch(string $a)
{
switch ($a) {
case 'foo':
/** @var string $var */
$var = $this->getName();

return $var[0];
default:
/**
* @param int[] $a
* @return int
*/
return static function (array $a) {
return PHP_INT_MAX;
};
}
}

/**
* FIRST DOC-BLOCK COMMENT
*/
Expand Down

0 comments on commit 8a66ce6

Please sign in to comment.