The Developer-Friendly Upgrade You’ve Been Waiting For
PHP 8.5 is out soon, and honestly, it’s one of those releases that makes me excited as a developer. Some of the features are small, but they just feel so right, you know? I’m talking about stuff that just makes your life easier every single day. Let me take you through it.
Pipe Operator: No More Temporary Variables
The pipe operator, you’ve probably seen it floating around in tweets and RFCs. And yes, it’s actually useful.
Imagine this: you have a function called sendEmail
. It takes an email address, but before you send it, you want to clean it up. Trim spaces, make it lowercase… usual stuff. Before PHP 8.5, you might do something like this:
$email = " TEST@EXAMPLE.COM "; $email = trim($email); $email = strtolower($email); sendEmail($email);
Temporary variables, reassignments, all that noise. Now with the pipe operator:
" TEST@EXAMPLE.COM " |> trim() |> strtolower() |> sendEmail();
No temporary variables, everything flows left to right. Makes your code so much cleaner.
No Discard Attribute: Stop Ignoring Return Values
Next up, #[NoDiscard]
. This is actually amazing. Sometimes you call a function, and you must use the return value, but people (or even yourself) might forget. PHP 8.5 can now warn you if you ignore it.
#[NoDiscard] function getName(): string { return "Nuno"; }
If you do this:
getName(); // PHP will warn you: "Hey, you should use the return value!"
It forces you to handle the result or explicitly cast to void if you really mean to ignore it. Honestly, this one is top three features for me. You combine this with the pipe operator, and you can write clean, safe chains without warnings.
Closures in Constant Expressions
PHP 8.5 now lets you use static closures in places that only accept compile-time values. Class constants, default property values, attribute arguments… you can now use closures in all of them.
class Example { public const VALIDATOR = static function($value) { return !empty($value); }; }
Before, this would fail, now it works. You can literally attach reusable logic directly to constants or attributes. This is huge for frameworks like Laravel that use a lot of validation or metadata.
Array Helpers: array_first()
and array_last()
You know how annoying it was to get the first or last element of an array? I mean, PHP has reset()
and end()
, but they move the internal pointer. Now we have:
$users = ["Adrian", "Maria", "Pedro"];
$first = array_first($users); // Adrian $last = array_last($users); // Pedro
It’s simple, intuitive, and doesn’t mess with your array pointer. Little change, big difference.
Global Constants with Attributes
Another subtle one. PHP 8.5 now lets you add attributes to global constants. Before, this was impossible. Now, you can do something like:
#[Deprecated("Use NEW_CONSTANT instead")] const OLD_CONSTANT = 42;
Try echoing it:
echo OLD_CONSTANT; // 42 + deprecation warning
It’s basically metadata for constants. If your framework or package uses constants for configuration, you can now attach extra info cleanly.
Get Exception Handler
For framework developers, this one is neat. PHP 8.5 introduces get_exception_handler()
. If you’ve ever used set_exception_handler()
, you know it’s hard to inspect the existing closure. Now, you can actually grab it:
set_exception_handler(fn($e) => echo "Caught: " . $e->getMessage()); $handler = get_exception_handler(); var_dump($handler);
Perfect for logging, debugging, or even modifying exception handling at runtime. Frameworks like Laravel could make real use of this for global error handling.
Intel List Formatter
And here’s a fun one: IntlListFormatter
. Not something you’d use every day, but when you need it, it’s perfect. You can take a list and format it according to locale rules.
$formatter = new \Intl\IntlListFormatter('en', \Intl\IntlListFormatter::TYPE_AND); echo $formatter->format(['Lisbon', 'Porto', 'Coimbra']); // "Lisbon, Porto, and Coimbra"
It handles “and”, “or”, and other localized ways of formatting lists automatically. Nice little quality-of-life improvement for internationalized apps.
Minor Internal and CLI-Only Improvements
Even the small improvements in PHP 8.5 make a difference, especially if you work with the CLI or care about internal debugging and configuration.
1. php.ini
Diff (PHP-IN-DIFF
)
Ever wish you could quickly see which settings you’ve changed from the default PHP configuration? PHP 8.5 makes this super easy with a new CLI command:
php -i --diff
This shows you exactly which php.ini
options differ from the defaults. For example, I always increase memory limits and disable timeouts for scripts while testing:
memory_limit = -1 max_execution_time = 0
Before, you had to manually compare or scroll through phpinfo()
. Now it’s literally built-in. Such a small, but life-saving improvement for anyone debugging PHP setups.
2. PHP Build Date Constant
PHP 8.5 introduces a new constant that tells you exactly when the binary was built. Want to check?
echo PHP_BUILD_DATE;
Output:
2025-09-17 14:32:00
It’s perfect if you’re running multiple PHP binaries or want to verify the version/build you’re using. Nothing groundbreaking, but again, quality-of-life.
3. Final Property Promotion
PHP 8.5 improves property promotion with the ability to mark individual properties as final
. You could already make an entire class final, but now you can target specific properties in your constructor:
class User { public function __construct( final public string $username, public string $email ) {} }
Now $username
cannot be overridden in subclasses. It’s subtle, but for codebases where immutability matters, this is a huge clarity win.
4. CLI and Debugging Tweaks
Other minor improvements include:
- Better default error reporting when using
php -d
overrides. - Cleaner warnings for deprecated features in CLI mode.
- Small optimizations under the hood that make scripts run slightly faster or consume less memory in edge cases.
None of these require code changes, but if you’re a framework developer or DevOps person, they make day-to-day PHP usage smoother.
Why Even Minor Changes Matter
Here’s the thing: PHP 8.5 isn’t just about flashy features. Even small internal improvements and CLI tweaks reduce friction in your workflow. That’s the real magic here, less time fighting configuration, more time writing code that actually does something.
Final Thoughts
PHP 8.5 is packed with quality-of-life features. Not every one of them will change your world, but together they make the language smoother, safer, and more enjoyable.
- Pipe operator: clean chains, no temp variables.
- NoDiscard: never ignore important return values again.
- Closures in constants: attach logic anywhere at compile time.
- Array helpers: easy access to first and last elements.
- Attributes on constants: add metadata cleanly.
- Exception handler inspection: framework-friendly.
- Intl list formatter: smart, localized lists.
PHP 8.5 feels like one of those releases that makes you happy to write PHP again. It’s not flashy, but it’s clever, practical, and developer-first.
If you haven’t checked it out yet, start testing the beta. I guarantee some of these features will make their way straight into your daily coding habits.
— — — — — — — — — — — — — — — — — — — — — —
Did you learn something good today?
Then show some love. 🫰
© Muhammad Usman LinkedIn
WordPress Developer | Website Strategist | SEO Specialist
Don’t forget to subscribe to Developer’s Journey to show your support.
Top comments (2)
“Closures in Constant Expressions” Hell Yeah!
PHP 8.5 is bringing some amazing quality-of-life updates.
Which one excites you the most?