haphpiness

These are things in PHP which make me genuinely_happy();

PHP has changed. The language that powered the early web grew up, learned from its mistakes, and became something genuinely great. These are real, objective improvements that make PHP a joy to write — features I use every day and never want to give up.

Inspired by PHP Sadness — but this time, we're smiling.

Excellent Error Reporting

#1 PHP 8 named arguments — no more positional confusion 8.0 #2 Union types and intersection types 8.0+ #3 Enums — finally, proper enumerations 8.1 #37 #[\Deprecated] attribute — deprecate your own code properly 8.4 #42 #[\NoDiscard] — warn when return values are ignored 8.5 #44 Fatal error backtraces — stack traces on fatal errors 8.5

Consistency Wins

#4 str_contains(), str_starts_with(), str_ends_with() — finally consistent 8.0 #5 Array unpacking with string keys 8.1 #6 Fibers — proper async primitives 8.1 #41 array_first() and array_last() 8.5 #75 Constants in traits 8.2

Things That Just Work

#7 Composer — best-in-class dependency management #8 Built-in development server (php -S) 5.4+ #9 PDO — clean, consistent database abstraction

Modern Elegance

#10 Arrow functions 7.4 #11 match expressions 8.0 #12 Null coalescing operator ?? and ??= 7.0+ #39 Pipe operator |> — left-to-right function chaining 8.5

Crystal Clear

#13 Typed properties 7.4 #14 Constructor property promotion 8.0 #15 Readonly properties and classes 8.1+ #33 Typed class constants 8.3 #35 Asymmetric visibility — public private(set) 8.4 #76 new in initializers — real default objects 8.1 #73 void return type — functions that return nothing 7.1

No Limits

#16 First-class callable syntax 8.1 #17 Attributes — native metadata 8.0 #18 Named arguments 8.0 #43 Closures in constant expressions 8.5 #71 Variadic functions and argument unpacking 5.6

Functional Joy

#19 array_map, array_filter, array_reduce — the functional trio #20 Closures and variable binding with use() #21 Generators and yield 5.5+ #36 array_find(), array_any(), array_all() — expressive array search 8.4

Batteries Included

#22 Built-in JSON support #23 DateTime and DateTimeImmutable #24 password_hash() and password_verify() 5.5+ #31 json_validate() — validate without decoding 8.3 #45 URI extension — proper URL parsing at last 8.5

OOP Done Right

#25 Interfaces, traits, and abstract classes #26 Late static binding 5.3+ #27 Anonymous classes 7.0 #32 #[\Override] attribute — safe method overriding 8.3 #34 Property hooks — get/set without the boilerplate 8.4 #40 Clone with — modify properties while cloning 8.5 #70 Lazy objects — deferred initialization, built into core 8.4

Parser Perfection

#28 Heredoc/Nowdoc flexibility 7.3 #29 Trailing commas everywhere 8.0 #30 Nullsafe operator ?-> 8.0 #38 new without parentheses — chain on construction 8.4

Warp Speed

#46 JIT compilation — PHP has a JIT compiler 8.0 #47 OPcache — bytecode caching in the box 5.5+

True to Form

#48 never return type — functions that never return 8.1 #49 array_is_list() — finally answer "is this sequential?" 8.1

Beyond PHP

#50 FFI — call C libraries directly from PHP 7.4

Chaos Under Control

#51 Random\Randomizer — a proper CSPRNG API 8.2 #52 WeakMap — object keys that don't leak memory 8.0 #74 Multi-catch — one block, many exception types 7.1

Pattern Matching

#53 Named capture groups in preg_match #54 Spaceship operator <=> — three-way comparison 7.0 #55 Array destructuring with keys — pattern matching for arrays

Behind the Curtain

#56 Stream wrappers & php:// — virtual file handles

World Ready

#57 intl MessageFormatter — ICU-backed proper i18n

Trust but Verify

#58 PHPStan & Psalm — static analysis as a first-class citizen #72 #[\SensitiveParameter] — keep secrets out of stack traces 8.2

Elegance in Brevity

#59 Numeric literal separators — 1_000_000 7.4

The Numbers Don't Lie

#60 71% of the web runs on PHP #61 189 billion Packagist installs — the ecosystem is astronomical #62 10 clockwork annual releases — every November since 2015 #63 The performance glow-up — WooCommerce is 61% faster on PHP 8.5 #64 549 million Laravel installs — one framework, half a billion #65 WordPress powers 41% of all websites — and it's all PHP #66 From zero types to full type algebra in 10 years #67 5.2 million developers and 40K GitHub stars on php-src

Framework Ecosystem

#68 Symfony — 21 years of engineering excellence and the components that power everything #69 NativePHP — desktop and mobile apps, all in PHP

Coming in PHP 8.6

#77 Partial function application — the callback you meant to write 8.6 #78 The Polling API — the I/O primitive Fibers were waiting for 8.6 #79 clamp() — the three-line helper everyone rewrites 8.6