How the language is written now.
WHAT TO ADOPT
Strict types, declared per file Type declarations on parameters and returns Exceptions rather than error codes Composer and autoloading A coding standard, applied automatically
WHAT TO STOP DOING
Mixing logic and markup in one file Using globals Suppressing errors Writing your own autoloader Using functions removed from current versions
WHAT TO USE FOR STRUCTURE
Classes with clear responsibilities Interfaces where several implementations exist Dependency injection, rather than creating dependencies internally
WHY DEPENDENCY INJECTION
It makes code testable, because dependencies can be substituted.
WHAT TO PREFER
Immutable values where practical Small classes over large ones Explicit over implicit
WHAT TOOLS TO USE
A formatter, so style is consistent A static analyser, which finds errors without running the code
WHAT A STATIC ANALYSER CATCHES
Type mismatches Impossible conditions Undefined properties and methods
WHAT TO ADOPT ON ANY SHARED PROJECT
Both, run automatically.