Skip to content

SlevomatCodingStandard.TypeHints.ParameterTypeHint - option to disable for public/protected of classes that extend/implement #1745

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

Open
kkmuffme opened this issue Apr 27, 2025 · 0 comments

Comments

@kkmuffme
Copy link

kkmuffme commented Apr 27, 2025

SlevomatCodingStandard.TypeHints.ClassConstantTypeHint
SlevomatCodingStandard.TypeHints.PropertyTypeHint
SlevomatCodingStandard.TypeHints.ParameterTypeHint

This sniff can cause an error if you're overriding parent property which does not have typehints. In such cases add @phpcsSuppress SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint annotation to the property to have this sniff skip it.

I think it would make sense if there were an option to disable the rule for public/protected properties/functions/constants of classes that extend/implement a class/interface.

This would prevent having to add the suppress in all those files, when initially enabling this rule.
Additionally, this would still set the type hints for private properties/functions/constants - which currently does not happen, since the rule has to be completely disabled.

For SlevomatCodingStandard.TypeHints.ReturnTypeHint this isn't needed bc there that's not a problem (see #1746)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants