diff --git a/src/ArchPresets/Laravel.php b/src/ArchPresets/Laravel.php index 971aea63..e76be4b8 100644 --- a/src/ArchPresets/Laravel.php +++ b/src/ArchPresets/Laravel.php @@ -37,7 +37,9 @@ final class Laravel extends AbstractPreset $this->expectations[] = expect('App\Http\Controllers') ->classes() - ->toHaveSuffix('Controller') + ->toHaveSuffix('Controller'); + + $this->expectations[] = expect('App\Http\Controllers') ->not->toHavePublicMethodsBesides(['__construct', '__invoke', 'index', 'show', 'create', 'store', 'edit', 'update', 'destroy']); $this->expectations[] = expect('App\Http\Middleware') diff --git a/src/Expectations/OppositeExpectation.php b/src/Expectations/OppositeExpectation.php index 7444c176..f424f373 100644 --- a/src/Expectations/OppositeExpectation.php +++ b/src/Expectations/OppositeExpectation.php @@ -226,6 +226,8 @@ final class OppositeExpectation /** * Asserts that the given expectation target not to have the public methods besides the given methods. + * + * @param array|string $methods */ public function toHavePublicMethodsBesides(array|string $methods): ArchExpectation { @@ -246,7 +248,7 @@ final class OppositeExpectation return true; }, - count($methods) === 0 + $methods === [] ? 'not to have public methods' : sprintf("not to have public methods besides '%s'", implode("', '", $methods)), FileLineFinder::where(fn (string $line): bool => str_contains($line, 'public function')), @@ -255,6 +257,8 @@ final class OppositeExpectation /** * Asserts that the given expectation target not to have the protected methods besides the given methods. + * + * @param array|string $methods */ public function toHaveProtectedMethodsBesides(array|string $methods): ArchExpectation { @@ -275,7 +279,7 @@ final class OppositeExpectation return true; }, - count($methods) === 0 + $methods === [] ? 'not to have protected methods' : sprintf("not to have protected methods besides '%s'", implode("', '", $methods)), FileLineFinder::where(fn (string $line): bool => str_contains($line, 'protected function')), @@ -284,6 +288,8 @@ final class OppositeExpectation /** * Asserts that the given expectation target not to have the private methods besides the given methods. + * + * @param array|string $methods */ public function toHavePrivateMethodsBesides(array|string $methods): ArchExpectation { @@ -304,7 +310,7 @@ final class OppositeExpectation return true; }, - count($methods) === 0 + $methods === [] ? 'not to have private methods' : sprintf("not to have private methods besides '%s'", implode("', '", $methods)), FileLineFinder::where(fn (string $line): bool => str_contains($line, 'private function')),