Decode Ioncube & Sourceguardian
Decode Ioncube & Sourceguardian

Php 8.5.0 was released!

Date: 21/11/25

PHP 8.5 is Here: Modernizing the Language with Key Innovations

The release of PHP 8.5 continues the language's rapid evolution, introducing powerful features that make code more readable, expressive, and efficient. Here’s a look at the most significant innovations like the pipe operator |> in PHP is syntactic sugar that introduces a pipeline-style syntax for function calls, allowing you to chain operations in a more readable, left-to-right manner. Look for other improvements below.

1. The New URI Extension: Robust URL Parsing

A major addition is the always-available URI extension, which provides a modern, object-oriented API for working with URIs and URLs, compliant with both RFC 3986 and WHATWG URL standards.

PHP 8.4 and older:

php
$components = parse_url('https://php.net/releases/8.4/en.php');
var_dump($components['host']); // string(7) "php.net"
// parse_url returns an array, which can be fragile and error-prone.

PHP 8.5:

php
use UriRfc3986Uri;

$uri = new Uri('https://php.net/releases/8.5/en.php');
var_dump($uri->getHost()); // string(7) "php.net"
// A clean, object-oriented interface for parsing and manipulation.

2. The Pipe Operator |>: Fluent Function Chaining

This new operator allows you to chain function calls in a readable, left-to-right manner, eliminating the need for deeply nested code or intermediate variables. Instead of nesting functions like h(g(f($value))), you can write $value |> f(...) |> g(...) |> h(...), where each step passes the result of the previous expression as the first argument to the next callable. This operator doesn’t add new runtime functionality—it simply rewrites the pipeline into standard function calls during compilation—but it significantly improves code clarity when applying sequential transformations, making complex chains easier to write, read, and maintain.

PHP 8.4 and older (nested calls):

php
$title = ' PHP 8.5 Released ';
$slug = strtolower(
    str_replace('.', '',
        str_replace(' ', '-',
            trim($title)
        )
    )
);
// Hard to read and modify.

PHP 8.5 (fluent chain):

php
$title = ' PHP 8.5 Released ';
$slug = $title
    |> trim(...)
    |> (fn($str) => str_replace(' ', '-', $str))
    |> (fn($str) => str_replace('.', '', $str))
    |> strtolower(...);
// Reads like a sequence of steps: trim, then replace spaces, then remove dots, then lowercase.

3. Clone With: The "With-er" Pattern Made Easy

The clone operator now accepts an array of properties to modify during the cloning process. This is a game-changer for immutable readonly classes.

PHP 8.4 and older (verbose):

php
readonly class Color {
    public function withAlpha(int $alpha): self {
        $values = get_object_vars($this);
        $values['alpha'] = $alpha;
        return new self(...$values); // Manually reconstructing the object
    }
}

PHP 8.5 (concise and clear):

php
readonly class Color {
    public function withAlpha(int $alpha): self {
        return clone($this, [
            'alpha' => $alpha, // Directly specify the change during clone
        ]);
    }
}

4. The #[NoDiscard] Attribute: Preventing Ignored Return Values

This new attribute ensures that a function's return value is not accidentally ignored, improving the safety of APIs where the result is critical.

PHP 8.5:

php
#[NoDiscard]
function getCriticalConfig(): array {
    return ['key' => 'value'];
}

getCriticalConfig(); // This now triggers a warning!
// Warning: The return value of getCriticalConfig() should be used...

To intentionally ignore the value, use a (void) cast: (void) getCriticalConfig();.

5. array_first() and array_last(): Simple Array Accessors

These new global functions provide a convenient and safe way to get the first or last element of an array.

PHP 8.4 and older:

php
$lastEvent = $events === [] ? null : $events[array_key_last($events)];

PHP 8.5:

php
$lastEvent = array_last($events); // Returns null if the array is empty.
$firstEvent = array_first($events);

6. Persistent cURL Share Handles: Boosting Performance

The new curl_share_init_persistent() function allows cURL handles to be reused across multiple requests in a persistent SAPI (like PHP-FPM), significantly reducing connection overhead.

PHP 8.5:

php
// This handle can persist and be reused, saving DNS and connection setup time.
$sh = curl_share_init_persistent([
    CURL_LOCK_DATA_DNS,
    CURL_LOCK_DATA_CONNECT,
]);

7. Closures in Constant Expressions: More Dynamic Metadata

Static closures and first-class callables can now be used in constant expressions, such as attribute arguments, making them much more powerful.

PHP 8.5:

php
final class PostsController {
    #[AccessControl(static function (Request $request, Post $post): bool {
        return $request->user === $post->getAuthor(); // Logic directly in the attribute
    })]
    public function update(Request $request, Post $post): Response { ... }
}

Conclusion

PHP 8.5 is a significant release that directly addresses common developer pain points. With the Pipe Operator for readable chains, clone with for immutability, a robust URI extension, and performance boosts like persistent cURL, the language continues to mature into a modern, powerful, and efficient tool for web development.


Written by: AI
Share this news:

Contacts


Chat 24/7, Social links

► Send files and Chat:

1. Sign up
2. Get the Element app or Web-version
3. Click or find us there: Deioncube

► Social links:

deYoutube link deRutube link rss
Deioncube qr-code link

Contacts


► Send files and Chat:

1. Sign up
2. Get the Element app or Web-version
3. Click or find us there: Deioncube
Deioncube qr-code link

► Social links:

deYoutube link deRutube link rss