Skip to content

SlevomatCodingStandard.TypeHints.ClassConstantTypeHint: fixing only private constants #1755

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

Conversation

maryo
Copy link
Contributor

@maryo maryo commented May 23, 2025

It is dangerous to automatically add typehints for other than private constants as the type might not be compatible with constants in the inheritance chain or implemented interfaces.

Or if you prefered this to be configurable, I could make it configurable.

@maryo maryo force-pushed the class-constant-typehint-no-dangerous-fix branch from 0935511 to 249b563 Compare May 23, 2025 17:15
@slevomatjenkins
Copy link

Yes, please add new option because this change is also a BC break

@maryo maryo force-pushed the class-constant-typehint-no-dangerous-fix branch from 249b563 to 4b7dd5c Compare May 23, 2025 20:33
@maryo
Copy link
Contributor Author

maryo commented May 23, 2025

OK, I added fixableNativeTypeHint: yes/no/private. I used yes/no simmilar to SlevomatCodingStandard.TypeHints.DNFTypeHintFormat so all possibilities are strings instead of string|bool
but I can change it if you prefer different configuration values or name.

@kukulich
Copy link
Contributor

Thanks.

@kukulich kukulich enabled auto-merge (rebase) May 27, 2025 21:05
@kukulich kukulich force-pushed the class-constant-typehint-no-dangerous-fix branch from 4b7dd5c to beba0ad Compare May 27, 2025 21:06
@kukulich kukulich merged commit 24667fa into slevomat:master May 27, 2025
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants