Description
Notes
- this procedure is a rework of PHP 8.3 compatibility #90
- always test (outside production) with highest PHP error reporting (
E_ALL
) - many changes, abandonned features of newst versions of PHP are marked "Deprecated" in previous versions to anticipate transition
Procedure
- update dependencies
- preview with
composer why-not php 8.4
- run local version on php 8.4 then in
composer.json
pass to"php" : "8.4.*",
and in a shell with php 8.4, executecomposer update --with-all-dependencies
and test; for libraries not compatible :- try to find a version compatible on https://packagist.org/
- if it isn't already compatible :
- check in its master branch if it's already done or planned
- check in Issues and Pull requests if this php version is mentioned, to find indices, reasons or workarounds
- think to contribute...
- find an alternative library
- eventually try
"platform": {"php": "8.4"}
in composer.json - look for dependencies versions in
composer.json
candidate to upgrade with help of https://packagist.org/ then upgrade in your env :composer require "vendor/package:2.*" vendor/package2:dev-master
- for libraries updated to a significative version, check if it contains backward incompatibilities with their Release notes or CHANGELOG; eventually adapt the code of the application accordingly
- preview with
- pass your IDE php version
- check with php analyzers configured to target this version of PHP (their usage is explained in README) and apply fixes & refactoring
- PHPCompatibility check
- PHPStan
- Psalm
- Phan
./vendor/bin/phan --progress-bar -o phan.txt
- Rector config is in
rector.php
(with for ex.LevelSetList::UP_TO_PHP_84
); preview changes :vendor/bin/rector process --dry-run
; apply change :vendor/bin/rector process
- (Qodana)
- from PHP doc Appendices note possibles incompatibilities focused on application's usage of PHP; see "À vérifier" below
- tests (with Whoops enabled : because it breaks the rendering of the page, many problems triggered by the interpreter will cause the test to fail) & fixes
- fixes & tests
- (test on staging)
- push
develop
to github & deploy it to staging (already running php 8.4) - tests & fixes
- push
- update README, doc, config...
- deployment : before, D-day, after
À vérifier
Changements non rétrocompatibles
Changement du comportement de exit()
Suppression du niveau d'erreur E_STRICT
Gd
imagejpeg(), imagewebp(), imagepng(), imageavif() lancent désormais une ValueError si un quality invalide est passé.
Standard
La fonction round() vérifie désormais la valeur du mode et lance une ValueError pour les modes invalides. Auparavant, les modes invalides auraient été interprétés comme PHP_ROUND_HALF_UP.
La fonction str_getcsv() lance désormais une ValueError si les arguments separator et enclosure ne font pas un octet de long, ou si l'argument escape
n'est pas un octet de long ou une chaîne vide. Cela aligne le comportement pour être identique à celui de fputcsv() et fgetcsv().
MBString
En cas de chaines invalides (celles avec des erreurs d'encodage), mb_substr() interprète désormais les indices de caractères de la même manière que la plupart des autres fonctions mbstring. Cela signifie que les indices de caractères retournés par mb_strpos() peuvent être passés à mb_substr().
MySQLi
La constante non utilisée et non documentée MYSQLI_SET_CHARSET_DIR a été supprimée.
SimpleXML
SimpleXMLElement n'est pas seulement une représentation d'un élément XML, mais c'est aussi un RecursiveIterator. Avant PHP 8.4.0, certaines de ses méthodes (par exemple SimpleXMLElement::asXML() ou SimpleXMLElement::getName()) et le casting de telles instances en chaîne de caractères réinitialisaient implicitement l'itérateur.
Fonctionnalités dépréciées
PHP Core
Implicitly nullable parameter
A parameter's type is implicitly widened to accept null if the default value for it is null.
Utiliser trigger_error() avec E_USER_ERROR
Appeler trigger_error() avec error_level égal à E_USER_ERROR est désormais déprécié.
Session
Appeler session_set_save_handler() avec plus de deux arguments est désormais déprécié. Utiliser la signature à deux arguments à la place.