Problem/Motivation
The core issue, #3250827: [policy, no patch] Use declare(strict_types=1) in new code, has approved a requirement that declare(strict_types=1) is used in new code. That is stricter that the current standard.
Strict type declaration
If you define strict types for a PHP file, place the declare statement on a new line after the opening PHP tag surrounded by empty newlines. If the PHP file has a file level DocBlock the declare statement should be positioned after that. The declare statement is written without spaces around the equals sign.
Benefits
If we adopted this change, the Drupal Project would benefit by ...
Three supporters required
- https://www.drupal.org/u/{userid} (yyyy-mm-dd they added support)
- https://www.drupal.org/u/{userid} (yyyy-mm-dd they added support)
- https://www.drupal.org/u/{userid} (yyyy-mm-dd they added support)
Proposed changes
Create an MR with all proposed changes.
Remaining tasks
Create this issue in the Coding Standards queue, using the defined template- Add supporters
- Create a Change Record
- Review by the Coding Standards Committee
- Coding Standards Committee takes action as required
- Discussed at a Core Committee meeting, if it impacts Drupal Core
- Final review by Coding Standards Committee
- Documentation updates
- Commit the MR
- Publish change record
- Remove 'Needs documentation edits' tag
- If applicable, create follow-up issues for PHPCS rules/sniffs changes
For a full explanation of these steps see the Coding Standards project page
Issue fork coding_standards-3630579
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wkr1shna commentedwould love to work on this, assigning to myself!
Comment #4
wkr1shna commentedI've opened [MR !21] to document the requirement for `declare(strict_types=1);` in new PHP files, following core issue #3250827.
The documentation build (`mkdocs build --strict`) passes, and the latest GitLab pipeline completed successfully. The change is limited to the strict-types guidance and the spelling allowlist adjustment needed for the repository-wide CSpell check.
I've also prepared the benefits summary and draft change record for review. Feedback on the wording and remaining issue-template requirements would be appreciated.