Skip to content

Commit 6aed9ca

Browse files
authored
fixed #135 Check trait class (#136)
1 parent 94e9233 commit 6aed9ca

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

gradle.properties

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,4 @@ version=2020.06.03
66
intellijPublishChannel=""
77
intellijPublishToken=""
88
changeNotes=\
9-
- #80 New inspection: assign misused\n\
10-
- #49 New inspection: make property private\n\
11-
- #113 Check class property comments (Redundant doc comment tag)\n\
12-
- #112 Ignore generic types comments (Redundant doc comment tag)\n\
13-
- Better detection of invalid property annotation (Property annotation)
9+
- #135 [Fixed] property can be private - check trait type

src/main/kotlin/com/funivan/idea/phpClean/constrains/clazz/IsAloneClass.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class IsAloneClass : ConstrainInterface<PhpClass> {
88
override fun match(target: PhpClass): Boolean {
99
return (
1010
!target.isAbstract &&
11+
!target.isTrait &&
1112
PhpClassHierarchyUtils.getAllSubclasses(target).isEmpty()
1213
&&
1314
target.extendsList.referenceElements.isEmpty())

src/test/kotlin/com/funivan/idea/phpClean/inspections/propertyCanBePrivate/PropertyCanBePrivateInspectionTest.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,26 @@ class PropertyCanBePrivateInspectionTest : BaseInspectionTest() {
6969
"""
7070
)
7171
}
72+
fun testCheckTrait() {
73+
assert(
74+
PropertyCanBePrivateInspection(),
75+
"""<?php
76+
trait Number {
77+
protected int ${'$'}val;
78+
}
79+
"""
80+
)
81+
}
82+
83+
fun testCheckAbstractClass() {
84+
assert(
85+
PropertyCanBePrivateInspection(),
86+
"""<?php
87+
abstract class Str {
88+
protected ${'$'}fast;
89+
}
90+
"""
91+
)
92+
}
7293

7394
}

0 commit comments

Comments
 (0)