-
-
Notifications
You must be signed in to change notification settings - Fork 0
Tweak MethodsShouldBePublicOrPrivateRule to accept abstract protected methods
#19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...mponent/MethodsShouldBePublicOrPrivateRule/Fixture/ComponentWithDuplicateTraitMethods.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Kocal\PHPStanSymfonyUX\Tests\Rules\TwigComponent\MethodsShouldBePublicOrPrivateRule\Fixture; | ||
|
|
||
| use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; | ||
|
|
||
| #[AsTwigComponent] | ||
| class ComponentWithDuplicateTraitMethods | ||
| { | ||
| use TraitA; | ||
| use TraitB; | ||
|
|
||
| public string $name = ''; | ||
|
|
||
| protected function duplicateAbstractMethod(): void | ||
| { | ||
| // Implementation of abstract method from both traits - should NOT trigger an error | ||
| } | ||
|
|
||
| // duplicateConcreteMethod() comes from both traits - should trigger only ONE error | ||
| } |
17 changes: 17 additions & 0 deletions
17
...hodsShouldBePublicOrPrivateRule/Fixture/ComponentWithProtectedConcreteMethodFromTrait.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Kocal\PHPStanSymfonyUX\Tests\Rules\TwigComponent\MethodsShouldBePublicOrPrivateRule\Fixture; | ||
|
|
||
| use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; | ||
|
|
||
| #[AsTwigComponent] | ||
| class ComponentWithProtectedConcreteMethodFromTrait | ||
| { | ||
| use TestTraitWithConcreteMethod; | ||
|
|
||
| public string $name = ''; | ||
|
|
||
| // protectedConcreteTraitMethod() comes from the trait and is NOT abstract - SHOULD trigger an error | ||
| } |
20 changes: 20 additions & 0 deletions
20
...nent/MethodsShouldBePublicOrPrivateRule/Fixture/ComponentWithProtectedMethodFromTrait.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Kocal\PHPStanSymfonyUX\Tests\Rules\TwigComponent\MethodsShouldBePublicOrPrivateRule\Fixture; | ||
|
|
||
| use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; | ||
|
|
||
| #[AsTwigComponent] | ||
| class ComponentWithProtectedMethodFromTrait | ||
| { | ||
| use TestTraitWithAbstractMethod; | ||
|
|
||
| public string $name = ''; | ||
|
|
||
| protected function protectedAbstractTraitMethod(): void | ||
| { | ||
| // Implementation of abstract method from trait - should NOT trigger an error | ||
| } | ||
| } |
17 changes: 17 additions & 0 deletions
17
...ShouldBePublicOrPrivateRule/Fixture/LiveComponentWithProtectedConcreteMethodFromTrait.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Kocal\PHPStanSymfonyUX\Tests\Rules\TwigComponent\MethodsShouldBePublicOrPrivateRule\Fixture; | ||
|
|
||
| use Symfony\UX\LiveComponent\Attribute\AsLiveComponent; | ||
|
|
||
| #[AsLiveComponent] | ||
| class LiveComponentWithProtectedConcreteMethodFromTrait | ||
| { | ||
| use TestTraitWithConcreteMethod; | ||
|
|
||
| public string $name = ''; | ||
|
|
||
| // protectedConcreteTraitMethod() comes from the trait and is NOT abstract - SHOULD trigger an error | ||
| } |
20 changes: 20 additions & 0 deletions
20
.../MethodsShouldBePublicOrPrivateRule/Fixture/LiveComponentWithProtectedMethodFromTrait.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Kocal\PHPStanSymfonyUX\Tests\Rules\TwigComponent\MethodsShouldBePublicOrPrivateRule\Fixture; | ||
|
|
||
| use Symfony\UX\LiveComponent\Attribute\AsLiveComponent; | ||
|
|
||
| #[AsLiveComponent] | ||
| class LiveComponentWithProtectedMethodFromTrait | ||
| { | ||
| use TestTraitWithAbstractMethod; | ||
|
|
||
| public string $name = ''; | ||
|
|
||
| protected function protectedAbstractTraitMethod(): void | ||
| { | ||
| // Implementation of abstract method from trait - should NOT trigger an error | ||
| } | ||
| } |
10 changes: 10 additions & 0 deletions
10
.../TwigComponent/MethodsShouldBePublicOrPrivateRule/Fixture/TestTraitWithAbstractMethod.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Kocal\PHPStanSymfonyUX\Tests\Rules\TwigComponent\MethodsShouldBePublicOrPrivateRule\Fixture; | ||
|
|
||
| trait TestTraitWithAbstractMethod | ||
| { | ||
| abstract protected function protectedAbstractTraitMethod(): void; | ||
| } |
12 changes: 12 additions & 0 deletions
12
.../TwigComponent/MethodsShouldBePublicOrPrivateRule/Fixture/TestTraitWithConcreteMethod.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Kocal\PHPStanSymfonyUX\Tests\Rules\TwigComponent\MethodsShouldBePublicOrPrivateRule\Fixture; | ||
|
|
||
| trait TestTraitWithConcreteMethod | ||
| { | ||
| protected function protectedConcreteTraitMethod(): void | ||
| { | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
tests/Rules/TwigComponent/MethodsShouldBePublicOrPrivateRule/Fixture/TraitA.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Kocal\PHPStanSymfonyUX\Tests\Rules\TwigComponent\MethodsShouldBePublicOrPrivateRule\Fixture; | ||
|
|
||
| trait TraitA | ||
| { | ||
| abstract protected function duplicateAbstractMethod(): void; | ||
|
|
||
| protected function duplicateConcreteMethod(): void | ||
| { | ||
| } | ||
| } |
14 changes: 14 additions & 0 deletions
14
tests/Rules/TwigComponent/MethodsShouldBePublicOrPrivateRule/Fixture/TraitB.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Kocal\PHPStanSymfonyUX\Tests\Rules\TwigComponent\MethodsShouldBePublicOrPrivateRule\Fixture; | ||
|
|
||
| trait TraitB | ||
| { | ||
| abstract protected function duplicateAbstractMethod(): void; | ||
|
|
||
| protected function duplicateConcreteMethod(): void | ||
| { | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment "already handled above" is slightly misleading. Abstract methods are not "handled" in the earlier loop - they are intentionally allowed and skipped. Consider rephrasing to something like "Skip if method is abstract (abstract methods are allowed to be protected)" to better reflect the actual behavior.