Why this matters
Type hints improve readability, tooling, and runtime safety.
Add scalar/union/nullable type hints and return types to functions, methods, and properties; prefer interfaces over mixed.
Type hints improve readability, tooling, and runtime safety.
Side-by-side examples engineers can pattern-match during review.
function save($id, $data) { /* ... */ }function save(string $id, array $data): bool { /* ... */ }function f($x){...}function f(int $x): string { ... }From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.