Skip to content

Rule 3 Types as a security layer

Edward Baitsewe edited this page Nov 9, 2026 · 1 revision

Rule 3: The type system is a security layer

Part one: wiring. Types stop the wrong kind of value at the door, before it becomes a bug or a security hole.

The short form of every rule is in BUILD_PHILOSOPHY.md, which is the version that counts. This page is the long form: why, where it shows today, and when not to use it.

Why

Slim Killer takes untrusted input from forms, uploads and webhooks. Every value that is checked once, at the edge, and then carried as a precise type cannot be wrong later. A string $role accepts "admn"; a Role $role accepts only the roles that exist.

Where it shows in Slim Killer

When not to apply it

Inside one small private function, a plain string or array is fine. The rule is about values that cross a boundary: from a form, from the database, from another class.

Words

Value object, boundary. See Glossary.

Learn more

PHP 8.5 OOP Mastery, Rule 3 in its course philosophy, taught in module 2, advanced types. Course page.


Build philosophy

Clone this wiki locally