From 564ba6de3ad2daaf9f67b6aca6c94838288f69b6 Mon Sep 17 00:00:00 2001 From: Geert Broekmans Date: Wed, 28 Feb 2024 13:17:42 +0100 Subject: [PATCH] Add ShouldNotBeReadonly assertion --- .github/workflows/integrate.yaml | 4 ++ docs/CHANGELOG.md | 3 ++ .../ShouldNotBeReadonly/IsReadonlyRule.php | 15 ++++++ .../ShouldNotBeReadonly.php | 49 +++++++++++++++++++ 4 files changed, 71 insertions(+) create mode 100644 src/Rule/Assertion/Declaration/ShouldNotBeReadonly/IsReadonlyRule.php create mode 100644 src/Rule/Assertion/Declaration/ShouldNotBeReadonly/ShouldNotBeReadonly.php diff --git a/.github/workflows/integrate.yaml b/.github/workflows/integrate.yaml index dcc5b536..a77f1b04 100644 --- a/.github/workflows/integrate.yaml +++ b/.github/workflows/integrate.yaml @@ -23,6 +23,7 @@ jobs: - "7.4" - "8.0" - "8.1" + - "8.2" dependencies: - "highest" steps: @@ -60,6 +61,7 @@ jobs: - "7.4" - "8.0" - "8.1" + - "8.2" dependencies: - "highest" steps: @@ -95,6 +97,7 @@ jobs: - "7.4" - "8.0" - "8.1" + - "8.2" dependencies: - "highest" steps: @@ -132,6 +135,7 @@ jobs: - "7.4" - "8.0" - "8.1" + - "8.2" dependencies: - "highest" steps: diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 4d0d1d29..6c4ce424 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog All notable changes to this project will be documented in this file. +## 0.10.15 +* Add `shouldNotBeReadonly` assertion. + ## 0.10.14 * Add `shouldInclude()` and `shouldNotInclude` assertions. * Detect catch blocks in dependency assertions. diff --git a/src/Rule/Assertion/Declaration/ShouldNotBeReadonly/IsReadonlyRule.php b/src/Rule/Assertion/Declaration/ShouldNotBeReadonly/IsReadonlyRule.php new file mode 100644 index 00000000..a20fd796 --- /dev/null +++ b/src/Rule/Assertion/Declaration/ShouldNotBeReadonly/IsReadonlyRule.php @@ -0,0 +1,15 @@ + + */ +final class IsReadonlyRule extends ShouldNotBeReadonly implements Rule +{ + use ReadonlyExtractor; +} diff --git a/src/Rule/Assertion/Declaration/ShouldNotBeReadonly/ShouldNotBeReadonly.php b/src/Rule/Assertion/Declaration/ShouldNotBeReadonly/ShouldNotBeReadonly.php new file mode 100644 index 00000000..5507d177 --- /dev/null +++ b/src/Rule/Assertion/Declaration/ShouldNotBeReadonly/ShouldNotBeReadonly.php @@ -0,0 +1,49 @@ + $tips + * @return array + */ + protected function applyValidation(string $ruleName, ClassReflection $subject, bool $meetsDeclaration, array $tips, array $params = []): array + { + return $this->applyShouldNot($ruleName, $subject, $meetsDeclaration, $tips, $params); + } + + protected function getMessage(string $ruleName, string $subject, array $params = []): string + { + return $this->prepareMessage( + $ruleName, + sprintf('%s should not be readonly', $subject) + ); + } +}