Skip to content

Commit 4da89b4

Browse files
fixing only one public method named rule, by adding the only one public method to the test set
1 parent eec74ed commit 4da89b4

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
namespace Kununu\ArchitectureSniffer\Configuration\Rules;
5+
6+
use Kununu\ArchitectureSniffer\Configuration\ArchitectureLibrary;
7+
use Kununu\ArchitectureSniffer\Configuration\Group;
8+
use PHPat\Rule\Assertion\Declaration\ShouldHaveOnlyOnePublicMethodNamed\ShouldHaveOnlyOnePublicMethodNamed;
9+
use PHPat\Test\Builder\Rule;
10+
11+
final readonly class MustOnlyHaveOnePublicMethod extends AbstractRule
12+
{
13+
public static function createRule(
14+
Group $group,
15+
ArchitectureLibrary $library,
16+
): Rule {
17+
return self::buildDependencyRule(
18+
group: $group,
19+
specificRule: ShouldHaveOnlyOnePublicMethodNamed::class,
20+
because: "$group->name should only have one public method named $group->mustOnlyHaveOnePublicMethodName.",
21+
);
22+
}
23+
}

Kununu/ArchitectureSniffer/Helper/RuleBuilder.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public static function getRules(Group $group, ArchitectureLibrary $library): ite
6262
$group,
6363
$library
6464
);
65+
yield Rules\MustOnlyHaveOnePublicMethod::createRule(
66+
$group,
67+
$library
68+
);
6569
}
6670
}
6771
}

Kununu/ArchitectureSniffer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ This logic applies to all properties that accept patterns or references, such as
230230
- Check for typos in group names and references.
231231
- For a clean static analysis run, use:
232232
```sh
233-
php vendor/bin/phpstan clear-result && php vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 240M
233+
`php vendor/bin/phpstan clear-result && php vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 240M`
234234
```
235235
- For more help, see [PHPAT issues](https://github.com/carlosas/phpat/issues).
236236

0 commit comments

Comments
 (0)