Aller au contenu

PHP 8.5 — Rebel house guide

The Rebel stack runs PHP 8.5 only. This guide covers 8.5 and nothing older. The full official change list is in upgrading-8.5.md (php/php-src, branch PHP-8.5). When a newer PHP becomes the stack, STACK.env changes and this guide is rewritten for it.

Before anything runs on a vhost

  1. The Plesk handler of the domain is PHP 8.5 — set it before an update, never during.
  2. In SSH, php is the system PHP, not Plesk's. Use the newest Plesk binary: ls -d /opt/plesk/php/*/bin/php | sort -V | tail -1
  3. composer why-not php 8.5 in the project lists the blocking packages.
  4. php -m with that binary: a missing extension is a fatal error.

What 8.5 brings (usable now)

  • Pipe operator |>: $result = $input |> trim(...) |> strtoupper(...);
  • array_first() / array_last().
  • #[\NoDiscard]: warns when a return value is ignored.
  • clone with property reassignment (clone($obj, ['prop' => $value])), useful with readonly objects.
  • #[\Deprecated] on constants, and #[\DelayedTargetValidation].

What 8.5 deprecates (fix it in our code)

  • Non-canonical casts (boolean), (integer), (double), (binary) → use (bool), (int), (float), (string).
  • Ending a case with ; instead of :.
  • The backtick operator as an alias of shell_exec().
  • null as an array offset, or in array_key_exists().
  • curl_close() (no effect anymore — remove the call).
  • __sleep() / __wakeup() are soft-deprecated → use __serialize() / __unserialize().

What 8.5 removes

  • The disable_classes INI setting.

The complete and authoritative list is upgrading-8.5.md. If something is not there, it is not a fact.


Porting older code to 8.5

Old addons and scripts written for an earlier PHP must be brought to 8.5, not kept on an older handler. Quick greps on an addon before porting (rough, but they catch the usual traps):

grep -rnE '\((boolean|integer|double|binary)\)' src/   # casts deprecated in 8.5
grep -rn  'curl_close' src/                            # deprecated in 8.5
grep -rn  '`' src/ --include=*.php                     # backtick shell_exec
grep -rnE 'function .*[a-z] \$[a-zA-Z_]+ = null' src/  # implicit nullable parameter (deprecated since 8.4)
grep -rn  '\${[a-zA-Z_]' src/                          # ${var} interpolation (deprecated since 8.2)

Dynamic properties ($obj->undeclared = ...) have been deprecated since 8.2: declare the property. utf8_encode() / utf8_decode() are deprecated since 8.2: use mb_convert_encoding().