Skip to content

Following MethodsShouldBePublicOrPrivateRule conflicts with protected methods coming from traitsΒ #15

@DamienHarper

Description

@DamienHarper

Thanks for this extension, it helps to make components better!

Though, I have a LiveComponent that uses Symfony\UX\LiveComponent\ComponentWithFormTrait where lives the abstract protected method abstract protected function instantiateForm(): FormInterface;

So I have to implement it in my component but to follow the MethodsShouldBePublicOrPrivateRule rule, I have to make it private which makes PHPStan throw a method.unused error
Method App\Twig\Component\MyComponentExample::instantiateForm() is unused.

If I keep it protected (as it was before using your extension), PHPStan does not complain about the method being unused but regarding the MethodsShouldBePublicOrPrivateRule not being followed:

Method "instantiateForm()" in a Twig component should not be protected.        
         πŸͺͺ  symfonyUX.twigComponent.methodsShouldBePublicOrPrivate                     
         πŸ’‘  Twig component methods should be either public or private, not protected. 

Edit: I currently silent PHPStan by adding the following docblock at the top of the method.

    /**
     * @phpstan-ignore method.unused (used by ComponentWithFormTrait)
     */

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions