Technical Mid Level

How have typed properties and enums changed the way you write PHP? Give an example of where each improves code quality.

Quick Tip

Show a before/after: "Previously I used string constants for order status. Now I use a backed enum, which gives me type safety, autocomplete, and easy database serialisation."

What good answers include

Good answers explain that typed properties (PHP 7.4+) eliminate the need for manual type checks in setters and make code self-documenting. Enums (PHP 8.1) replace magic strings and class constants with proper type-safe values. Strong candidates give concrete examples: enums for status fields, typed properties in DTOs, and discuss how both improve IDE support and static analysis.

What interviewers are looking for

Tests awareness of modern PHP. Candidates stuck on PHP 5.x patterns are a concern. Look for practical understanding, not just feature awareness.

← All PHP questions