Skip to content

Commit 7c5122e

Browse files
committed
fixes #186 RedundantDocCommentTagInspection - Skip checking array shapes
1 parent 8a53a6a commit 7c5122e

File tree

3 files changed

+42
-35
lines changed

3 files changed

+42
-35
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<!-- Keep a Changelog guide -> https://keepachangelog.com -->
22

3+
# PhpClean Changelog
4+
## [Unreleased]
5+
### Fixed
6+
- #186 RedundantDocCommentTagInspection - Skip checking array shapes
7+
8+
39
# PhpClean Changelog
410
## [2023.04.01]
511
### Fixed

src/main/kotlin/com/funivan/idea/phpClean/inspections/redundantDocCommentTag/RedundantDocCommentTagInspection.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class RedundantDocCommentTagInspection : PhpCleanInspection() {
5353
val doc = tag.type.toStringResolved()
5454
val declared = type.toStringResolved()
5555
if (doc == declared) {
56-
val skip = (tag.firstPsiChild as? PhpDocType)?.canonicalText?.contains(Regex("[<\\]]+"))
56+
val skip = (tag.firstPsiChild as? PhpDocType)?.canonicalText?.contains(Regex("[<\\]\\{]+"))
5757
if (skip == false) {
5858
holder.registerProblem(
5959
tag,

src/test/kotlin/com/funivan/idea/phpClean/inspections/redundantDocCommentTag/RedundantDocCommentTagInspectionTest.kt

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
77
@Test
88
fun testRedundantReturnType() {
99
assert(
10-
RedundantDocCommentTagInspection(),
11-
"""
10+
RedundantDocCommentTagInspection(), """
1211
<?php
1312
/**
1413
*<warning descr="Redundant PhpDoc tag">@return void</warning>
1514
*/
1615
function show(string ${'$'}message):void {}
17-
""",
18-
"""
16+
""", """
1917
<?php
2018
function show(string ${'$'}message):void {}
2119
"""
@@ -25,16 +23,14 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
2523
@Test
2624
fun testRedundantReturnTypeWithNonEmptyComment() {
2725
assert(
28-
RedundantDocCommentTagInspection(),
29-
"""
26+
RedundantDocCommentTagInspection(), """
3027
<?php
3128
/**
3229
* Hello world
3330
*<warning descr="Redundant PhpDoc tag">@return void</warning>
3431
*/
3532
function show(string ${'$'}message):void {}
36-
""",
37-
"""
33+
""", """
3834
<?php
3935
/**
4036
* Hello world
@@ -47,16 +43,14 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
4743
@Test
4844
fun testRedundantParameterTag() {
4945
assert(
50-
RedundantDocCommentTagInspection(),
51-
"""
46+
RedundantDocCommentTagInspection(), """
5247
<?php
5348
/**
5449
*<warning descr="Redundant PhpDoc tag">@param string ${'$'}message</warning>
5550
* @param string ${'$'}test
5651
*/
5752
function show(int ${'$'}a, string ${'$'}message):void {}
58-
""",
59-
"""
53+
""", """
6054
<?php
6155
/**
6256
* @param string ${'$'}test
@@ -69,8 +63,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
6963
@Test
7064
fun testRedundantParameterTagWithClassFQN() {
7165
assert(
72-
RedundantDocCommentTagInspection(),
73-
"""
66+
RedundantDocCommentTagInspection(), """
7467
<?php
7568
class A{
7669
/**
@@ -86,8 +79,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
8679
@Test
8780
fun testReturnMultipleTypes() {
8881
assert(
89-
RedundantDocCommentTagInspection(),
90-
"""
82+
RedundantDocCommentTagInspection(), """
9183
<?php
9284
/**
9385
* @return \Generator|string[]
@@ -100,8 +92,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
10092
@Test
10193
fun testCheckEmptyTag() {
10294
assert(
103-
RedundantDocCommentTagInspection(),
104-
"""
95+
RedundantDocCommentTagInspection(), """
10596
<?php
10697
/**
10798
* @return
@@ -114,8 +105,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
114105
@Test
115106
fun testCheckNullableReturnType() {
116107
assert(
117-
RedundantDocCommentTagInspection(),
118-
"""
108+
RedundantDocCommentTagInspection(), """
119109
<?php
120110
/**
121111
*<warning descr="Redundant PhpDoc tag">@return bool|null</warning>
@@ -128,8 +118,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
128118
@Test
129119
fun testCheckNullableParameterType() {
130120
assert(
131-
RedundantDocCommentTagInspection(),
132-
"""
121+
RedundantDocCommentTagInspection(), """
133122
<?php
134123
/**
135124
*<warning descr="Redundant PhpDoc tag">@param stdClass|null ${'$'}o</warning>
@@ -142,8 +131,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
142131
@Test
143132
fun testRedundantFieldTag() {
144133
assert(
145-
RedundantDocCommentTagInspection(),
146-
"""
134+
RedundantDocCommentTagInspection(), """
147135
<?php
148136
class PhpClean {
149137
/**
@@ -158,8 +146,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
158146
@Test
159147
fun testFieldTagWithClassFQN() {
160148
assert(
161-
RedundantDocCommentTagInspection(),
162-
"""
149+
RedundantDocCommentTagInspection(), """
163150
<?php
164151
class PhpClean {
165152
/**
@@ -171,11 +158,28 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
171158
)
172159
}
173160

161+
@Test
162+
fun testIgnoreArrayShapeTags() {
163+
assert(
164+
RedundantDocCommentTagInspection(), """
165+
<?php
166+
class PhpClean {
167+
/**
168+
* @param array{id: int, name: string} ${'$'}variable
169+
* @return array{id: int, name: string}
170+
*/
171+
function example(array ${'$'}variable): array{
172+
return ['id'=>123, 'name'=>'test'];
173+
}
174+
}
175+
"""
176+
)
177+
}
178+
174179
@Test
175180
fun testFieldTagWithMultipleTypes() {
176181
assert(
177-
RedundantDocCommentTagInspection(),
178-
"""
182+
RedundantDocCommentTagInspection(), """
179183
<?php
180184
class PhpClean {
181185
/**
@@ -190,8 +194,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
190194
@Test
191195
fun testFieldWithEmptyTag() {
192196
assert(
193-
RedundantDocCommentTagInspection(),
194-
"""
197+
RedundantDocCommentTagInspection(), """
195198
<?php
196199
class PhpClean {
197200
/**
@@ -206,8 +209,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
206209
@Test
207210
fun testCheckNullableFieldType() {
208211
assert(
209-
RedundantDocCommentTagInspection(),
210-
"""
212+
RedundantDocCommentTagInspection(), """
211213
<?php
212214
class PhpClean {
213215
/**
@@ -222,8 +224,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
222224
@Test
223225
fun testGenericType() {
224226
assert(
225-
RedundantDocCommentTagInspection(),
226-
"""
227+
RedundantDocCommentTagInspection(), """
227228
<?php
228229
class PhpClean {
229230
/**

0 commit comments

Comments
 (0)