Skip to content

Commit 931d0a2

Browse files
committed
handle case with tags, no description
1 parent bbe068d commit 931d0a2

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

Magento2/Sniffs/Commenting/PHPDocFormattingValidator.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ public function providesMeaning($namePtr, $commentStartPtr, $tokens)
2424
$commentCloserPtr = $tokens[$commentStartPtr]['comment_closer'];
2525
$name = strtolower(str_replace([' ', '"', '_'], '', $tokens[$namePtr]['content']));
2626

27+
$hasTags = false;
28+
$hasDescription = false;
29+
2730
for ($i = $commentStartPtr; $i <= $commentCloserPtr; $i++) {
2831
$token = $tokens[$i];
2932

@@ -34,9 +37,12 @@ public function providesMeaning($namePtr, $commentStartPtr, $tokens)
3437

3538
// Wrong kind of string
3639
if ($tokens[$i - 2]['code'] === T_DOC_COMMENT_TAG) {
40+
$hasTags = true;
3741
continue;
3842
}
3943

44+
$hasDescription = true;
45+
4046
// Comment is the same as the origin name
4147
$docComment = str_replace(['_', ' ', '.', ','], '', strtolower($token['content']));
4248
if ($docComment === $name) {
@@ -53,6 +59,11 @@ public function providesMeaning($namePtr, $commentStartPtr, $tokens)
5359
return true;
5460
}
5561

62+
// Contains nothing but the tags
63+
if ($hasTags === true && $hasDescription === false) {
64+
return true;
65+
}
66+
5667
return false;
5768
}
5869
}

Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.1.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,13 @@ class EmptyHandler
6767
class ExampleHandler
6868
{
6969

70+
}
71+
72+
/**
73+
* @api
74+
* @since 100.0.2
75+
*/
76+
class ApiHandler
77+
{
78+
7079
}

Magento2/Tests/Commenting/ClassAndInterfacePHPDocFormattingUnitTest.2.inc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,13 @@ interface EmptyHandler
6767
interface ExampleHandler
6868
{
6969

70+
}
71+
72+
/**
73+
* @api
74+
* @since 100.0.2
75+
*/
76+
interface ApiHandler
77+
{
78+
7079
}

0 commit comments

Comments
 (0)