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

  1. https://www.drupal.org/u/{userid} (yyyy-mm-dd they added support)
  2. https://www.drupal.org/u/{userid} (yyyy-mm-dd they added support)
  3. https://www.drupal.org/u/{userid} (yyyy-mm-dd they added support)

Proposed changes

Create an MR with all proposed changes.

Remaining tasks

  1. Create this issue in the Coding Standards queue, using the defined template
  2. Add supporters
  3. Create a Change Record
  4. Review by the Coding Standards Committee
  5. Coding Standards Committee takes action as required
  6. Discussed at a Core Committee meeting, if it impacts Drupal Core
  7. Final review by Coding Standards Committee
  8. Documentation updates
    1. Commit the MR
    2. Publish change record
    3. Remove 'Needs documentation edits' tag
  9. If applicable, create follow-up issues for PHPCS rules/sniffs changes

For a full explanation of these steps see the Coding Standards project page

Command icon 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

quietone created an issue. See original summary.

wkr1shna’s picture

Assigned: Unassigned » wkr1shna

would love to work on this, assigning to myself!

wkr1shna’s picture

Status: Active » Needs review

I'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.