PHP's type system dissected
summary
Explains what each PHP type actually means, how the engine checks them and how Liskov's Subtitution Principle is implemented for PHP's subtyping relation, walking through the C-level zval / ztype internals and the canonical DNF union/intersection algorithm used for subtype checks. Demonstrates ten concrete type‑juggling contexts with surprising gotchas (GMP and tidy casts, exit converting booleans to strings, deprecated float→int coercion), shows strict_types only disables scalar coercion for function args/returns/properties, and sketches proposals: function types, generics, type aliases and in/out params.
AI-written summary · about
chapters (22)
- 0:00PHP's type system intro
- 1:07Type system overview
- 3:15Primitive types explained
- 5:27Value and callable types
- 6:30Composite and DNF types
- 8:18Union vs intersection types
- 10:47Zval internals
- 12:16Subtyping and Liskov Substitution Principle
- 15:30LSP in method signatures
- 19:07Subtyping math
- 20:55Future PHP type features
- 23:43Type juggling overview
- 24:24String and int juggling
- 27:39Logical and comparison juggling
- 32:15Function type promotion
- 35:29Increment/decrement quirks
- 38:19String increment issues
- 38:39Array offset inconsistencies
- 41:52Exit function behavior
- 43:17Strict types limits
- 44:45Critique of strict types
- 45:09Q&A








