diff --git a/app/Controllers/AccountingController.php b/app/Controllers/AccountingController.php index b804e04..0e8b180 100644 --- a/app/Controllers/AccountingController.php +++ b/app/Controllers/AccountingController.php @@ -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; diff --git a/app/Controllers/GrantsController.php b/app/Controllers/GrantsController.php index e1fca49..6140b4b 100644 --- a/app/Controllers/GrantsController.php +++ b/app/Controllers/GrantsController.php @@ -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'); diff --git a/app/Controllers/MedicalDocumentsController.php b/app/Controllers/MedicalDocumentsController.php index 7bc7f12..698af5b 100644 --- a/app/Controllers/MedicalDocumentsController.php +++ b/app/Controllers/MedicalDocumentsController.php @@ -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 { diff --git a/app/Controllers/PublicSiteController.php b/app/Controllers/PublicSiteController.php index d181995..111f590 100644 --- a/app/Controllers/PublicSiteController.php +++ b/app/Controllers/PublicSiteController.php @@ -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'); diff --git a/app/Controllers/SettingsController.php b/app/Controllers/SettingsController.php index abe656b..f81d89b 100644 --- a/app/Controllers/SettingsController.php +++ b/app/Controllers/SettingsController.php @@ -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'); diff --git a/app/Services/AgendaService.php b/app/Services/AgendaService.php index 7b56830..a8c4ff4 100644 --- a/app/Services/AgendaService.php +++ b/app/Services/AgendaService.php @@ -198,7 +198,7 @@ final class AgendaService ? $end ->modify( $start->getTimestamp() - - new DateTimeImmutable($row['starts_at'])->getTimestamp() . + (new DateTimeImmutable($row['starts_at']))->getTimestamp() . ' seconds', ) ->format('Y-m-d H:i:s') diff --git a/app/Services/AssociationBrand.php b/app/Services/AssociationBrand.php index 2a094fd..9e9dc48 100644 --- a/app/Services/AssociationBrand.php +++ b/app/Services/AssociationBrand.php @@ -31,7 +31,7 @@ final class AssociationBrand throw new RuntimeException(t('service.logo.too_large')); } $tmp = (string) $upload['tmp_name']; - $mime = new finfo(FILEINFO_MIME_TYPE)->file($tmp); + $mime = (new finfo(FILEINFO_MIME_TYPE))->file($tmp); $extension = self::MIME_EXTENSIONS[$mime] ?? null; if (!$extension) { throw new RuntimeException(t('service.logo.format')); diff --git a/app/Services/BackupService.php b/app/Services/BackupService.php index 9c888f9..6063626 100644 --- a/app/Services/BackupService.php +++ b/app/Services/BackupService.php @@ -16,7 +16,7 @@ final class BackupService if (!is_dir($backupDir) && !mkdir($backupDir, 0775, true) && !is_dir($backupDir)) { throw new RuntimeException(t('service.backup.directory_failed')); } - $stamp = new DateTimeImmutable('now', new DateTimeZone('Europe/Paris'))->format('Ymd-His'); + $stamp = (new DateTimeImmutable('now', new DateTimeZone('Europe/Paris')))->format('Ymd-His'); $suffix = $reason === 'pre-restore' ? '-avant-restauration' : ''; $target = $backupDir . '/globinours-' . $stamp . $suffix . '.zip'; // Certains volumes synchronisés acceptent les ZIP mais SQLite ne peut pas @@ -50,7 +50,7 @@ final class BackupService $manifest = [ 'application' => 'Globinours', 'format_version' => self::FORMAT_VERSION, - 'created_at' => new DateTimeImmutable('now', new DateTimeZone('Europe/Paris'))->format( + 'created_at' => (new DateTimeImmutable('now', new DateTimeZone('Europe/Paris')))->format( DateTimeInterface::ATOM, ), 'reason' => $reason, @@ -434,7 +434,7 @@ final class BackupService private static function describe(string $path): array { - $modified = new DateTimeImmutable('@' . (filemtime($path) ?: time()))->setTimezone( + $modified = (new DateTimeImmutable('@' . (filemtime($path) ?: time())))->setTimezone( new DateTimeZone('Europe/Paris'), ); return ['name' => basename($path), 'size' => filesize($path) ?: 0, 'date' => $modified->format('d/m/Y H:i:s')]; diff --git a/app/Services/PrivacyService.php b/app/Services/PrivacyService.php index 698ed42..d0b75ef 100644 --- a/app/Services/PrivacyService.php +++ b/app/Services/PrivacyService.php @@ -84,7 +84,7 @@ final class PrivacyService 'deposited_animals' => 'SELECT internal_code,name,intake_date,intake_type,intake_reason,intake_circumstances FROM animals WHERE depositor_contact_id=? ORDER BY intake_date', ]; - $payload = ['generated_at' => new DateTimeImmutable()->format(DATE_ATOM), 'contact' => $contact]; + $payload = ['generated_at' => (new DateTimeImmutable())->format(DATE_ATOM), 'contact' => $contact]; foreach ($queries as $key => $sql) { $q = $db->prepare($sql); $q->execute([$id]); diff --git a/app/Services/PrivateMediaService.php b/app/Services/PrivateMediaService.php index 8881194..b5b7387 100644 --- a/app/Services/PrivateMediaService.php +++ b/app/Services/PrivateMediaService.php @@ -124,7 +124,7 @@ final class PrivateMediaService 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'; PrivacyService::logAccess( 'private_' . $kind, $id, diff --git a/app/Services/SystemHealthService.php b/app/Services/SystemHealthService.php index e380309..4d7b3f4 100644 --- a/app/Services/SystemHealthService.php +++ b/app/Services/SystemHealthService.php @@ -136,7 +136,7 @@ final class SystemHealthService return [ 'checks' => $checks, 'summary' => $summary, - 'generated_at' => new DateTimeImmutable('now', new DateTimeZone('Europe/Paris'))->format('d/m/Y H:i:s'), + 'generated_at' => (new DateTimeImmutable('now', new DateTimeZone('Europe/Paris')))->format('d/m/Y H:i:s'), 'php' => PHP_VERSION, 'sqlite' => (string) $db->query('SELECT sqlite_version()')->fetchColumn(), ]; @@ -181,7 +181,7 @@ final class SystemHealthService $lines = file($path, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: []; $dates = []; for ($i = 0; $i < $days; $i++) { - $dates[] = new DateTimeImmutable("-$i days")->format('d-M-Y'); + $dates[] = (new DateTimeImmutable("-$i days"))->format('d-M-Y'); } $count = 0; foreach (array_slice($lines, -1000) as $line) { diff --git a/tests/run.php b/tests/run.php index e4e96cb..58dfdfa 100644 --- a/tests/run.php +++ b/tests/run.php @@ -164,7 +164,7 @@ try { $outside = AgendaService::save([ 'item_type' => 'task', 'title' => 'Semaine suivante', - 'date' => new DateTimeImmutable('monday next week')->format('Y-m-d'), + 'date' => (new DateTimeImmutable('monday next week'))->format('Y-m-d'), 'time' => '10:00', ]); $ids = array_map('intval', array_column(AgendaService::week(new DateTimeImmutable('today')), 'id'));