PHP / Advanced: reliable models and runtime evidence / Lesson 18
Runtime versions, feature boundaries, and compatibility
Read support schedules and migration guides as maintained evidence. Compare labeled PHP 8.4 and 8.5 features without silently raising the course’s PHP 8.3 syntax baseline.
On this page
Lesson goals
- Distinguish syntax compatibility, support, and deployment configuration.
- Explain explicit PHP 8.4 and 8.5 feature boundaries.
- Design a focused compatibility and release evidence set.
A teaching baseline is not a timeless support claim
This course uses PHP 8.3-compatible syntax except the explicitly version-labeled demonstrations in this chapter. All complete programs were executed on PHP 8.5.12 CLI, not on a matrix of older engines. As reviewed on 2026-10-25, the official schedule lists PHP 8.3 in security-only support through 2027-12-31; support status and dates must be rechecked when making a deployment decision. Syntax compatibility, available extensions, dependency constraints, operating-system packages, and active security maintenance are related but distinct concerns. Do not infer a production upgrade plan from a tutorial’s minimum language version.
PHP 8.4 property hooks are a new syntax boundary
PHP 8.4 introduced property hooks and asymmetric property visibility among other changes. Hooks can attach logic to get or set behavior, which may make property access less trivial than a direct field read. The example normalizes a title through a set hook; it is deliberately labeled PHP 8.4 or later and must not be placed in a file an 8.3 parser must load. A runtime if cannot shield unsupported syntax from parsing. Use new syntax when its contract improves clarity, and still validate the domain rather than assuming a hook’s existence makes every assigned value correct.
<?php
declare(strict_types=1);
final class CourseTitle {
public string $value { set => trim($value); }
public function __construct(string $value) { $this->value = $value; }
}
echo (new CourseTitle(" PHP "))->value, PHP_EOL;
PHP
The installed PHP 8.5 CLI validates this output. This snippet is outside the course’s default 8.3 syntax baseline.
PHP 8.5 pipes compose calls, not deployment guarantees
PHP 8.5 introduced the pipe operator, which passes a value through a sequence of callable transformations. It can improve readability for a suitable data pipeline, but it does not create asynchronous work, add validation automatically, or remove errors. The example applies two ordinary text functions and prints their known result. It requires PHP 8.5 syntax and is tested only on the installed 8.5 CLI. An equivalent nested call can serve older baselines. Decide whether adopting the operator is worth changing the supported runtime contract rather than inserting it casually into a shared library.
<?php
declare(strict_types=1);
$title = " php " |> trim(...) |> strtoupper(...);
echo $title, PHP_EOL;
PHP
trim removes the spaces, then strtoupper produces PHP. No concurrency, service, or package is involved.
Read incompatibilities and deprecations, not only features
A migration review includes backward-incompatible changes, deprecated behavior, extension changes, and dependency support. A program can parse but still change warning behavior or fail at a runtime boundary. Compare CLI and web configurations deliberately because they may use different binaries, ini files, or extensions. Do not hide deprecations to call the upgrade complete; classify them and plan repairs with an owner. Use a clean locked dependency install in the real project workflow and inspect platform requirements without exposing secrets. Keep language-feature experiments isolated from application upgrades so a failed experiment cannot alter a configured service.
Finish with a bounded release argument
A compatibility report states the tested runtime, extensions, dependency set, entry points, and representative behaviors. Include syntax checks, exact domain examples, error paths, isolated database behavior, session lifecycle, and actual HTTP checks when the feature depends on them. Reuse evidence only while its assumptions remain true. A newer CLI passing local snippets does not prove every application route or older supported branch works. Communicate remaining gaps and choose a deliberate next check that can change the decision. Maintainable PHP comes from explicit contracts, owned effects, and reviewed evidence, not a version number or a framework badge.
Common errors and fixes
A minimum version is confused with current support
- Why it happens
- Language syntax policy replaces a maintained security decision.
- How to fix it
- Check the official support schedule for the actual deployment date.
- Prevent it next time
- Record review date and runtime policy separately.
New syntax is hidden behind a runtime condition
- Why it happens
- Parsing occurs before that branch can protect execution.
- How to fix it
- Separate version-specific files or raise the declared minimum intentionally.
- Prevent it next time
- Lint with every runtime actually claimed as supported.
Only new features are reviewed during upgrade
- Why it happens
- Deprecations and incompatible behavior are ignored.
- How to fix it
- Review the complete migration guide and dependency platform requirements.
- Prevent it next time
- Test errors and integration boundaries as well as successful syntax.
Check your understanding
1. Can the PHP 8.4 hook example be loaded safely on 8.3 inside if (PHP_VERSION_ID >= 80400)?
Show worked solution
No. The older parser must parse the file before evaluating the condition. Put newer syntax in files excluded from older parsing paths or raise the minimum version. Do not claim 8.3 compatibility for a file containing an unsupported hook.
2. What should accompany a report that all examples pass on PHP 8.5.12 CLI?
Show worked solution
State that exact tested host and extensions, identify the 8.4/8.5-only examples, and disclose that older engines and real HTTP/session-cookie paths were not validated by that run. Include output comparisons and controlled SQLite evidence rather than implying a complete application or runtime matrix test.
Key takeaways
- Version-specific syntax and support status need explicit reviewed boundaries.
- Report only the runtimes and behaviors actually validated.