-
Notifications
You must be signed in to change notification settings - Fork 0
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
Require typed class constants #87
Comments
Requires a bump to phpstan/phpdoc-parser and slevomat/coding-standard. |
+1 to this |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://wiki.php.net/rfc/typed_class_constants
Since PHP 8.3, class constants can be typed.
Seems to make sense, considering you can subclass and override constants. Typing a constant enforces it down the line. Particularly useful in tests.
Rule:
SlevomatCodingStandard.TypeHints.ClassConstantTypeHint
New rule introduced in the latest version of
slevomat/coding-standard
Mostly autofixable. In scenarios where a constant isnt subclasses,
phpcbf
can add types. However things like bools, the autofixer might addtrue
orfalse
, but not pick up hierarchy and set tobool
. It also seems like if a constant is a classnameCLASS::class
, string isnt added, but thats an easy fix.The text was updated successfully, but these errors were encountered: