Add declare(strict_types=1) everywhere

Created on 21 July 2023, over 1 year ago

Problem/Motivation

This is slightly different from 🌱 [Meta] Implement strict typing in existing code Active which is about adding type hints to code that doesn't have it.

Steps to reproduce

I got caught out by a bool type hint accepting a string (which casts to TRUE) in a file that didn't have declare(strict_types=1).

Proposed resolution

Strict types doesn't require that every parameter/return has a type hint, it just makes the existing ones behave more strictly. So I think we can add declare(strict_types=1) everywhere in core, probably add a phpstan or phpcs rule to require it. That will make existing type hints behave strictly, and when we add new ones, it'll make sure they're correct. So we might even want to do this before trying to add a lot of new type hints everywhere.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ“Œ Task
Status

Active

Version

11.0 πŸ”₯

Component
BaseΒ  β†’

Last updated about 21 hours ago

Created by

πŸ‡¬πŸ‡§United Kingdom catch

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

Comments & Activities

Production build 0.71.5 2024