Re:Modern PHP features explained – PHP 8.0 and 8.1
by TheCapeGreek on Thursday October 27, 2022 @11:47AM
(#33359352)
Others have explained how PHP can be statically typed. Here's how to enforce it:
Set up a linting rule that every project PHP file (with some exceptions, like templating files) needs to have the `declare(strict_types=1);` directive. Then you can also have PHPCS fix it or just generally have linting checks on PRs.
For large legacy apps you can still add exceptions.
Set up a linting rule that every project PHP file (with some exceptions, like templating files) needs to have the `declare(strict_types=1);` directive. Then you can also have PHPCS fix it or just generally have linting checks on PRs.
For large legacy apps you can still add exceptions.