Skip to content
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

New sniff to ensure constants being typed using native types #1701

Open
DaDeather opened this issue Oct 14, 2024 · 0 comments · May be fixed by #1702
Open

New sniff to ensure constants being typed using native types #1701

DaDeather opened this issue Oct 14, 2024 · 0 comments · May be fixed by #1702

Comments

@DaDeather
Copy link

Currently there's no sniff to ensure that constants are typed through native types.

I'd like to introduce a sniff that enables this and ensures the following:

class A
{

	const null AA = null;
	const true AAA = true;
	const false AAAA = false;
	const string AAAAA = 'aa';
	const int AAAAAA = 123;
	const float AAAAAAA = 123.456;
	const array AAAAAAAA = ['php'];
	const int AAAAAAAAA = -123;
	const float AAAAAAAAAA = -123.456;

}

This is available since PHP 8.3. See: https://wiki.php.net/rfc/typed_class_constants

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

Successfully merging a pull request may close this issue.

1 participant