Decisions about php
Architectural decision records tagged with php
-
acceptedUse PHPStan for PHP code static analysis at level 6
Static analysis catches type errors, logic bugs, and unsafe code paths without running the application, improving code quality at low cost.
-
acceptedBreak composer install if patches don't apply
Allowing builds to succeed with failed patches can lead to malformed code or hidden errors.
-
acceptedUse local copies of patch files
When using cweagans/composer-patches, it is important that patch sources are consistent and do not change between builds.
-
acceptedStore Composer Patches configuration in composer.json
Validating a complete Composer configuration is important to ensuring build issues are caught early.
-
acceptedConfigure Composer Patches to Use `-p2` as `patchLevel` for Drupal core
Drupal's git repository has a different directory structure than projects built on Drupal. Default Composer Patches settings can cause Drupal patches to be silently misapplied.
-
deprecatedComposer patches configuration and best practices
Default
composer-patchessettings can lead to misapplied patches or hidden errors. Using a consistent configuration across projects will reduce errors and save time. -
acceptedUse PHPUnit for unit testing PHP code
-
acceptedAlways use typehints in new PHP code
Following stricter typing where available can significantly reduce bugs, and simplify maintainability. This has been proven by several studies across different disciplines.
-
acceptedUse strict types in PHP code
PHP's type coercion can cause logical errors within a program. For example, when a float is cast to an int, the decimal portion is lost. We aim to reduce these errors in our code, but they can easily slip through manual code review. Following stricter typing where available can significantly reduce bugs, as shown by Python's urllib3 type hinting case study.