coding-standard
coding-standard copied to clipboard
New sniff to ensure constants being typed using native types
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