Skip to content

Commit

Permalink
fixes #186 RedundantDocCommentTagInspection - Skip checking array sha…
Browse files Browse the repository at this point in the history
…pes (#187)
  • Loading branch information
funivan authored Dec 16, 2023
1 parent 8a53a6a commit bf0b1b1
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 35 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<!-- Keep a Changelog guide -> https://keepachangelog.com -->

# PhpClean Changelog
## [Unreleased]
### Fixed
- #186 RedundantDocCommentTagInspection - Skip checking array shapes


# PhpClean Changelog
## [2023.04.01]
### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RedundantDocCommentTagInspection : PhpCleanInspection() {
val doc = tag.type.toStringResolved()
val declared = type.toStringResolved()
if (doc == declared) {
val skip = (tag.firstPsiChild as? PhpDocType)?.canonicalText?.contains(Regex("[<\\]]+"))
val skip = (tag.firstPsiChild as? PhpDocType)?.canonicalText?.contains(Regex("[<\\]\\{]+"))
if (skip == false) {
holder.registerProblem(
tag,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testRedundantReturnType() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
/**
*<warning descr="Redundant PhpDoc tag">@return void</warning>
*/
function show(string ${'$'}message):void {}
""",
"""
""", """
<?php
function show(string ${'$'}message):void {}
"""
Expand All @@ -25,16 +23,14 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testRedundantReturnTypeWithNonEmptyComment() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
/**
* Hello world
*<warning descr="Redundant PhpDoc tag">@return void</warning>
*/
function show(string ${'$'}message):void {}
""",
"""
""", """
<?php
/**
* Hello world
Expand All @@ -47,16 +43,14 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testRedundantParameterTag() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
/**
*<warning descr="Redundant PhpDoc tag">@param string ${'$'}message</warning>
* @param string ${'$'}test
*/
function show(int ${'$'}a, string ${'$'}message):void {}
""",
"""
""", """
<?php
/**
* @param string ${'$'}test
Expand All @@ -69,8 +63,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testRedundantParameterTagWithClassFQN() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
class A{
/**
Expand All @@ -86,8 +79,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testReturnMultipleTypes() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
/**
* @return \Generator|string[]
Expand All @@ -100,8 +92,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testCheckEmptyTag() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
/**
* @return
Expand All @@ -114,8 +105,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testCheckNullableReturnType() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
/**
*<warning descr="Redundant PhpDoc tag">@return bool|null</warning>
Expand All @@ -128,8 +118,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testCheckNullableParameterType() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
/**
*<warning descr="Redundant PhpDoc tag">@param stdClass|null ${'$'}o</warning>
Expand All @@ -142,8 +131,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testRedundantFieldTag() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
class PhpClean {
/**
Expand All @@ -158,8 +146,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testFieldTagWithClassFQN() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
class PhpClean {
/**
Expand All @@ -171,11 +158,28 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
)
}

@Test
fun testIgnoreArrayShapeTags() {
assert(
RedundantDocCommentTagInspection(), """
<?php
class PhpClean {
/**
* @param array{id: int, name: string} ${'$'}variable
* @return array{id: int, name: string}
*/
function example(array ${'$'}variable): array{
return ['id'=>123, 'name'=>'test'];
}
}
"""
)
}

@Test
fun testFieldTagWithMultipleTypes() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
class PhpClean {
/**
Expand All @@ -190,8 +194,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testFieldWithEmptyTag() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
class PhpClean {
/**
Expand All @@ -206,8 +209,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testCheckNullableFieldType() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
class PhpClean {
/**
Expand All @@ -222,8 +224,7 @@ class RedundantDocCommentTagInspectionTest : BaseInspectionTest() {
@Test
fun testGenericType() {
assert(
RedundantDocCommentTagInspection(),
"""
RedundantDocCommentTagInspection(), """
<?php
class PhpClean {
/**
Expand Down

0 comments on commit bf0b1b1

Please sign in to comment.