- last update
over 1 year ago 29,374 pass - π³πΏNew Zealand quietone
The constants in the search.module were removed in #3261239: Remove deprecations from search module β . I think that the sniff can be enabled now.
- Status changed to Needs work
over 1 year ago 11:22pm 5 May 2023 - πΊπΈUnited States smustgrave
Assuming I tested correctly
I applied the patch in #33
Added define('TEST', 'Hello'); to the action.module and ran the commit-code-check.sh script. It caught the error
But if I changed it to CONST TEST = 'Hello'; it does not catch it and shows it passed.
- Status changed to Postponed
over 1 year ago 3:08am 6 May 2023 - π³πΏNew Zealand quietone
The doc bloc for the sniff explains that it only checks
define
. And the earlier comments in the issue reflect that, there is no discussion about sniffing constants defined with 'const'.I made an issue in coder to get some information. I am postponing this until there is feedback there to inform what to do next here.
β¨ Add checking 'const' to Drupal.Semantics.ConstantName.ConstantStart Fixed - Status changed to Active
7 months ago 12:50pm 12 June 2024 - π³πΏNew Zealand quietone
The related issue was fixed over a year ago.
However, the test run in #33 passed despite there being constants PREG_CLASS_NUMBERS is the search module, in
The constant PREG_CLASS_NUMBERS in core/modules/search/src/SearchTextProcessorInterface.php is not reported as an error. The coding standards β state "Module-defined constant names should also be prefixed by an uppercase spelling of the module that defines them." so that should be detected, I think.
I tested again with the constant, DOG, in search.module and that wasn't detected either.
- Status changed to Postponed
2 months ago 7:23am 29 October 2024 - Status changed to Active
2 days ago 5:46pm 3 January 2025 - π¦πΉAustria klausi π¦πΉ Vienna
The constant PREG_CLASS_NUMBERS is defined on an interface - so it does not need to be prefixed with the module name.
Only global constants must be prefixed with the module name.
Note that we must not introduce any new global constants. All constants need to be defined on classes/interfaces for autoloading.
Maybe the coding standards need to be updated to clarify that? "Global constants are forbidden in the global scope for new code. Constants must be defined on interfaces or classes. Old global module-defined constants that cannot be removed for compatibility reasons should also be prefixed by an uppercase spelling of the module that defines them."