Goal: modern PHP that is typed, predictable, and secure.
Use for:
- new PHP code or modernizing legacy scripts
- reviewing typing, structure, and input handling
- replacing untyped, procedural sprawl
Workflow:
- Declare strict_types and type all signatures.
- Use classes, enums, and readonly properties for structure.
- Validate and sanitize all external input.
- Use prepared statements for every database query.
- Throw typed exceptions; avoid silent failure.
- Verify with PHPUnit, PHPStan/Psalm, and a linter.
Idioms:
- constructor property promotion and readonly props
- enums for fixed sets of values
- null-safe operator and match expressions
- PSR autoloading and coding standards
Rules:
- declare(strict_types=1) in every file
- never interpolate user input into SQL; use prepared statements
- escape output for the correct context (HTML, URL, SQL)
- type everything; let static analysis catch mistakes