On November 20, 2025, a new major release of PHP was published - version 8.5.
This update introduces several interesting features for developers, but as always,
the question of compatibility with existing systems arises, including OpenCart.
In this material, we will review the key changes and their impact on module and
extension development for OpenCart and the system as a whole.
What’s new in PHP 8.5
- New built-in URI extension
-
PHP 8.5 includes a built-in extension for working with URIs that follows
the RFC 3986 and WHATWG URL standards. This is especially useful for e-commerce
platforms that extensively work with URLs for SEO and routing.
-
The new `|>` operator allows creating function chains without intermediate
variables. This improves code readability and can be useful when developing
OpenCart modules.
-
The `clone()` function now supports modifying properties during cloning,
simplifying the implementation of the “with-er” pattern for readonly classes.
- The #[\NoDiscard] attribute
-
This new attribute warns when a function’s return value is not used, helping
to avoid mistakes during development.
-
PHP now includes two useful functions — array_first() and array_last(), which
return the first and last elements of an array. If the array is empty, both
functions return null.
OpenCart compatibility with PHP 8.x
Before deciding whether switching to the new PHP version is possible, it is
important 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.2, 8.3, 8.4
- OpenCart 4.x — PHP 8.0+
The introduction of PHP 8.5 brings both benefits and potential issues.
Advantages include improved URL handling, a more convenient approach to data
processing via the pipe operator, and more flexible object cloning.
However, issues may arise due to deprecated functionality, stricter typing,
and incompatibility of some third-party modules. PHP 8.5 deprecates constructions
such as (boolean), (integer), (double), (binary), as well as old case variants
in switch statements and certain array behaviors. This may cause errors in older code.
For OpenCart store owners, it is advisable to stay on PHP 8.1–8.3 for the next
6–12 months. Upgrading to PHP 8.5 should only be done after testing in a separate
staging environment. It is also recommended to update the platform to at least
version 3.0.4.1 if a much older version is currently used.
Before any future upgrade, it is important to audit all installed modules,
determine their compatibility with PHP 8.5, and prepare updates or replacements
if necessary. In the code, outdated type casts should be replaced, switch
statements should be reviewed (the case variant with a semicolon is deprecated),
and array handling should be updated.
For OpenCart module developers
It is too early to widely adapt modules for PHP 8.5 because the system itself
does not yet officially support PHP 8.5, and many libraries do not either.
It is also not recommended to use features exclusive to PHP 8.5, as developers
must consider compatibility with various user environments. However, developers
can already begin testing their modules with PHP 8.5 and fix all errors and
warnings.
Examples of deprecated operators
Instead of
$bool = (boolean) $value;
$int = (integer) $value;
Use
$bool = (bool) $value;
$int = (int) $value;
Examples of new features (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(...);
PHP 8.5 introduces useful improvements, but requires a careful approach
when integrating into existing OpenCart projects. The main risks are not
related to new features, but to the removal of deprecated code and stricter
type checks. Upgrade to new PHP versions only after full testing and
preparation.