New PHP 8.5 and OpenCart
On November 20, 2025, another major PHP release was published — version 8.5. This release brings interesting new features for developers, but as always, the question of compatibility with existing sys…
On November 20, 2025, another major PHP release was published — version 8.5. This release brings interesting new features for developers, but as always, the question of compatibility with existing systems arises, including OpenCart. In this article we will review the key changes and their impact on developing modules and extensions for OpenCart, and on the system as a whole.
What's new in PHP 8.5
- New built-in URI extension
- PHP 8.5 received a built-in extension for working with URIs, compliant with the RFC 3986 and WHATWG URL standards. This is especially useful for handling URLs for SEO and routing.
- Pipe operator
- The new `|>` operator lets you build function chains without intermediate variables. This improves code readability and may be useful when developing OpenCart modules in the future.
- Improved object cloning
- The `clone()` function now supports modifying properties during cloning, which simplifies implementing the "with-er" pattern for readonly classes.
- The #[\NoDiscard] attribute
- The new attribute warns when a function's return value is not used, which helps avoid bugs during development.
- New functions
- PHP gained useful functions — array_first() and array_last(), which return the first or last element of an array respectively. If the array is empty, both functions return null.
OpenCart compatibility with PHP 8.x
Before considering whether it's even possible to move to a new PHP version, you need to understand the current state of PHP 8.x support in OpenCart:
- OpenCart 3.0.3.9-3.0.4.1 — PHP 7.4, 8.0, 8.1, 8.2, 8.3
- OpenCart 3.0.5.0 (planned) — PHP 8.1, 8.1, 8.2, 8.3, 8.4
- OpenCart 4.x — PHP 8.0+
Adopting PHP 8.5 will have both positive and potentially problematic consequences. The advantages include improved URL handling, a more convenient approach to data processing via the pipe operator, and more flexible object cloning. However, possible difficulties are tied to deprecated functionality, stricter typing, and incompatibility of some third-party modules. PHP 8.5 deprecates constructs such as (boolean), (integer), (double), (binary), as well as old case variants in switch and some array-handling specifics. This can cause errors in legacy code.
For OpenCart store owners, over the next 6-12 months it is reasonable to stay on PHP 8.1–8.3. Moving to PHP 8.5 is recommended only after testing on a separate staging environment. It is also worth updating the platform to at least 3.0.4.1 if a significantly older version is in use.
Before a future upgrade, it is important to audit all installed modules,
determine their compatibility with PHP 8.5, and prepare updates or
replacements as needed. In your code, it is advisable to replace deprecated type casts
in advance, review switch constructs (case with semicolons is deprecated) and update
array handling.
For OpenCart module developers
Mass-adapting modules for PHP 8.5 is still premature, since the system itself does not yet officially support PHP 8.5, and neither do many libraries. Using constructs that only PHP 8.5 supports is also not advisable, because developers must consider compatibility of their products with various user systems. But developers can already test their modules with PHP 8.5 and at least fix all the errors and warnings.
Examples of some deprecated operators
Instead of
$bool = (boolean) $value;
$int = (integer) $value;
Use
$bool = (bool) $value;
$int = (int) $value;
Examples of using the new capabilities (PHP 8.5 only)
Using the new URI extension
use Uri\Rfc3986\Uri;
$uri = new Uri($url);
$cleanHost = $uri->getHost();
Pipe operator for data processing
$cleanTitle = $title
|> trim(...)
|> str_replace(' ', '-', ...)
|> strtolower(...);
The PHP 8.5 release is undoubtedly great news, but its use requires a cautious approach in existing OpenCart projects. The main risks are tied not to the new functionality, but to the removal of deprecated code and stricter type checks. Move to new PHP versions only after thorough testing and preparation.