Skip to content

Commit

Permalink
Merge pull request #165 from funivan/PhpClean-163-final-anonymous
Browse files Browse the repository at this point in the history
#163 MethodShouldBeFinal should not apply to anonymous classes
  • Loading branch information
funivan authored Aug 30, 2022
2 parents 8752dac + 519a3c9 commit b08c116
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<!-- Keep a Changelog guide -> https://keepachangelog.com -->

# PhpClean Changelog
## [2022.08.05]
## [2022.08.30]
### Changed
- #163 Skip "final check" for anonymous classes
- #151 Fix property visibility inspection for php8.1
- #156 Skip Virtual type check for generic types

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pluginGroup = com.funivan.idea.phpClean
pluginName_ = PhpClean
name = PhpClean
pluginVersion = 2020.06.03
pluginVersion = 2022.08.30
pluginSinceBuild = 211
#pluginUntilBuild = 203.*
# Plugin Verifier integration -> https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class MethodShouldBeFinalInspection : PhpCleanInspection() {
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor {
return object : PhpElementVisitor() {
override fun visitPhpClass(phpClass: PhpClass) {
if (!phpClass.isFinal && !phpClass.isInterface) {
if (!phpClass.isFinal && !phpClass.isInterface && !phpClass.isAnonymous) {
for (method in methods(phpClass)) {
holder.registerProblem(
method.nameIdentifier ?: method,
Expand All @@ -35,4 +35,4 @@ class MethodShouldBeFinalInspection : PhpCleanInspection() {
&& !magic.match(it)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ class MethodShouldBeFinalInspectionTest : BaseInspectionTest() {
"""
)
}
@Test
fun testIgnoreAnonumousClass() {
assert(
MethodShouldBeFinalInspection(),
"""<?php
return new class {
public function I_do_not_have_to_be_final () : void
{
}
};
"""
)
}


@Test
Expand Down

0 comments on commit b08c116

Please sign in to comment.