A comprehensive tour of PHP's anonymous constructs, covering anonymous classes (introduced in PHP 7.0), anonymous catch blocks (PHP 8.0), closures with explicit `use` capture, arrow functions with automatic scope capture (PHP 7.4), the `__invoke()` magic method for callable objects, and literal values as anonymous constants. Each construct is explained with code examples, practical use cases, and guidance on when to prefer one form over another. The post also clarifies which PHP structures must always be named (variables, traits, interfaces, enums) and why.
Sort:
