Enforce strict types in new code

Created on 12 June 2025, 2 days ago

Problem/Motivation

Postponed on 🌱 [policy, no patch] Use declare(strict_types=1) in new code Active .

As is evident in that issue, enabling strict types everywhere breaks in lots of different ways. But we can enforce it in new code. We can't use phpstan baseline for this and there is no phpcs baseline, but we can use a simple check in gitlab ci.

Steps to reproduce

Proposed resolution

Something like this in GitLab CI.

CHANGED=$(git diff --diff-filter=AM --name-only origin/11.x...HEAD | grep '\.php$' || true)
FAIL=0

for FILE in $CHANGED; do
  if ! grep -q "declare(strict_types=1);" $FILE ; then
    echo "- $FILE is missing strict_types declaration."
    FAIL=1
  fi
done

if [ "$FAIL" -eq 1 ]; then
  echo "Please add declare(strict_types=1); to all new php files."
  exit 1
fi

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

📌 Task
Status

Postponed

Version

11.0 🔥

Component

other

Created by

🇦🇺Australia mstrelan

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024