- Issue created by @pfrenssen
This was previously discussed in #3407995-10: Add sniff for declare(strict_types=1); → .
We introduced a standards check for declare(strict_types=1)
in
✨
Add sniff for declare(strict_types=1);
Needs review
by leveraging the SlevomatCodingStandard.TypeHints.DeclareStrictTypes
sniff. Since we don't (yet) want to require the presence of the strict types declaration in every file, the SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing
check was excluded.
However the exclusion of this check now makes it unclear for contrib modules and Drupal projects how they can enforce the inclusion of the strict types declaration. Before this change a contrib / project could add the following to their ruleset, but this doesn't work any more:
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes" />
The problem can be worked around by adding the following rule, but this is not self-evident:
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.DeclareStrictTypesMissing">
<severity>5</severity>
</rule>
Maybe we can propose a toggle to allow setting a coding standard for declare(strict_types=1)
but not require it in the Slevomat project? Alternatively we can extend their DeclareStrictTypesSniff
class or copy over the logic.
Active
8.3
Coder Sniffer