diff --git a/src/Expression/ForClasses/IsReadonly.php b/src/Expression/ForClasses/IsReadonly.php index 8e9fbad7..dd36003d 100644 --- a/src/Expression/ForClasses/IsReadonly.php +++ b/src/Expression/ForClasses/IsReadonly.php @@ -20,7 +20,7 @@ public function describe(ClassDescription $theClass, string $because): Descripti public function evaluate(ClassDescription $theClass, Violations $violations, string $because): void { - if ($theClass->isReadonly()) { + if ($theClass->isReadonly() || $theClass->isInterface() || $theClass->isTrait() || $theClass->isEnum()) { return; } diff --git a/tests/Unit/Expressions/ForClasses/IsReadonlyTest.php b/tests/Unit/Expressions/ForClasses/IsReadonlyTest.php index 90f51378..2f52173e 100644 --- a/tests/Unit/Expressions/ForClasses/IsReadonlyTest.php +++ b/tests/Unit/Expressions/ForClasses/IsReadonlyTest.php @@ -69,7 +69,7 @@ public function test_interfaces_can_not_be_readonly_and_should_be_ignored(): voi [], null, false, - true, + false, false, true, false, @@ -90,7 +90,7 @@ public function test_traits_can_not_be_readonly_and_should_be_ignored(): void [], null, false, - true, + false, false, false, true, @@ -111,7 +111,7 @@ public function test_enums_can_not_be_readonly_and_should_be_ignored(): void [], null, false, - true, + false, false, false, false,