Problem/Motivation
From the PHP manual:
By default, PHP will coerce values of the wrong type into the expected scalar type declaration if possible. For example, a function that is given an int for a parameter that expects a string will get a variable of type string.
This silent type-casting is often unintentional and can result in bugs.
If we set declare(strict_types=1); at the top of a file, then "only a value corresponding exactly to the type declaration will be accepted, otherwise a TypeError will be thrown. The only exception to this rule is that an int value will pass a float type declaration."
Proposed resolution
Set declare(strict_types=1); in the module files that we don't get do that. Review variable usage in those files before committing. Make sure tests still pass afterwards.
As of commit c3f1e98 from 2026-05-06, there are 21 PHP files in this module that we do not declare strict types in (using ripgrep, rg -g '*.php' --files-without-match -i -F -e 'declare(strict_types=1);' will find the list of files.
Remaining tasks
Merge request- merge request !16 created by @mparker17 in #2Community/Maintainer review- skipped by @mparker17 in #3Commit- merged by @mparker17 in #4- Release
User interface changes
None.
API changes
None.
Data model changes
None.
Issue fork feedback-3588845
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 #3
mparker17Created merge request !16. Skipping community/maintainer review because this was written by a maintainer. Merging shortly.
Comment #5
mparker17Merged. I will update this when it gets released.