Rétablir la compatibilité avec PHP 8.2

This commit is contained in:
Alexandre NOEL 2026-09-03 22:43:59 +02:00
commit 63224d8b06
12 changed files with 16 additions and 16 deletions

View file

@ -215,7 +215,7 @@ final class AccountingController
if (($f['error'] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_OK || ($f['size'] ?? 0) > 20 * 1024 * 1024) {
throw new RuntimeException(t('accounting.document_invalid'));
}
$mime = new finfo(FILEINFO_MIME_TYPE)->file($f['tmp_name']);
$mime = (new finfo(FILEINFO_MIME_TYPE))->file($f['tmp_name']);
$ext =
['application/pdf' => 'pdf', 'image/jpeg' => 'jpg', 'image/png' => 'png', 'image/webp' => 'webp'][$mime] ??
null;

View file

@ -144,7 +144,7 @@ final class GrantsController
header('Location: /admin/grants?year=' . $year . '&error=document');
return;
}
$mime = new finfo(FILEINFO_MIME_TYPE)->file($f['tmp_name']) ?: 'application/octet-stream';
$mime = (new finfo(FILEINFO_MIME_TYPE))->file($f['tmp_name']) ?: 'application/octet-stream';
$allowed = ['application/pdf' => 'pdf', 'application/vnd.oasis.opendocument.text' => 'odt'];
if (!isset($allowed[$mime])) {
header('Location: /admin/grants?year=' . $year . '&error=format');

View file

@ -288,7 +288,7 @@ final class MedicalDocumentsController
if (($f['error'] ?? 1) !== UPLOAD_ERR_OK || ($f['size'] ?? 0) <= 0 || $f['size'] > self::MAX_BYTES) {
throw new RuntimeException(t('medical_document.file_invalid'));
}
$mime = new finfo(FILEINFO_MIME_TYPE)->file($f['tmp_name']);
$mime = (new finfo(FILEINFO_MIME_TYPE))->file($f['tmp_name']);
if (!isset(self::TYPES[$mime])) {
throw new RuntimeException(t('medical_document.file_type'));
}
@ -319,7 +319,7 @@ final class MedicalDocumentsController
}
private static function fr(string $date): string
{
return new DateTimeImmutable($date)->format('d/m/Y');
return (new DateTimeImmutable($date))->format('d/m/Y');
}
private static function fail(string $message): void
{

View file

@ -229,7 +229,7 @@ final class PublicSiteController
http_response_code(404);
return;
}
$mime = new finfo(FILEINFO_MIME_TYPE)->file($path) ?: 'application/octet-stream';
$mime = (new finfo(FILEINFO_MIME_TYPE))->file($path) ?: 'application/octet-stream';
header('Content-Type: ' . $mime);
header('Content-Length: ' . filesize($path));
header('Cache-Control: public,max-age=3600');

View file

@ -91,7 +91,7 @@ final class SettingsController
http_response_code(404);
return;
}
$mime = new finfo(FILEINFO_MIME_TYPE)->file($path) ?: 'application/octet-stream';
$mime = (new finfo(FILEINFO_MIME_TYPE))->file($path) ?: 'application/octet-stream';
header('Content-Type: ' . $mime);
header('Content-Length: ' . filesize($path));
header('Cache-Control: private, max-age=3600');