Combine phpstan, cs-check, cs-fix into lint-php recipe; fix lint issues + test failures + duplicate detection bug

This commit is contained in:
Pontoporeia
2026-05-19 23:59:41 +02:00
parent 2e75a3b35c
commit 728f05502c
18 changed files with 220 additions and 229 deletions

View File

@@ -164,19 +164,19 @@ class ThesisCreateController
error_log("[ThesisCreate] Step 1 OK — thesis_id=$thesisId ($identifier) | authors=" . count($authorEntries));
$this->db->setThesisAuthors($thesisId, $authorEntries);
error_log("[ThesisCreate] Step 2 OK — authors=" . json_encode($data['authorNames']));
error_log('[ThesisCreate] Step 2 OK — authors=' . json_encode($data['authorNames']));
$this->db->setThesisJury($thesisId, $data['juryMembers']);
error_log("[ThesisCreate] Step 3 OK — jury=" . count($data['juryMembers']));
error_log('[ThesisCreate] Step 3 OK — jury=' . count($data['juryMembers']));
$this->db->setThesisLanguages($thesisId, $data['languageIds']);
error_log("[ThesisCreate] Step 4 OK — languages=" . json_encode($data['languageIds']));
error_log('[ThesisCreate] Step 4 OK — languages=' . json_encode($data['languageIds']));
$this->db->setThesisFormats($thesisId, $data['formatIds']);
error_log("[ThesisCreate] Step 5 OK — formats=" . json_encode($data['formatIds']));
error_log('[ThesisCreate] Step 5 OK — formats=' . json_encode($data['formatIds']));
$this->db->setThesisTags($thesisId, $data['keywords']);
error_log("[ThesisCreate] Step 6 OK — tags=" . json_encode($data['keywords']));
error_log('[ThesisCreate] Step 6 OK — tags=' . json_encode($data['keywords']));
$this->db->commit();
error_log("[ThesisCreate] COMMIT OK — thesis_id=$thesisId");
@@ -230,7 +230,7 @@ class ThesisCreateController
*/
public static function autofocusFieldForError(string $message): ?string
{
if (str_contains($message, "Auteur·ice")) {
if (str_contains($message, 'Auteur·ice')) {
return 'auteurice';
}
if (str_contains($message, 'Titre du TFE')) {
@@ -420,13 +420,13 @@ class ThesisCreateController
// Keywords (max 10, min 3) — lowercased, spaces collapsed, deduplicated
$keywords = [];
$normalizeTag = fn(string $t): string => strtolower(trim(preg_replace('/\s+/', ' ', $t)));
$normalizeTag = fn (string $t): string => strtolower(trim(preg_replace('/\s+/', ' ', $t)));
if (isset($post['tag']) && is_array($post['tag'])) {
$keywords = array_values(array_unique(array_map(
$normalizeTag,
array_map(fn($t) => (string)$t, $post['tag'])
array_map(fn ($t) => (string)$t, $post['tag'])
)));
$keywords = array_filter($keywords, fn($t) => $t !== '');
$keywords = array_filter($keywords, fn ($t) => $t !== '');
$keywords = array_slice($keywords, 0, 10);
} else {
$tagRaw = $this->sanitiseString($post['tag'] ?? '');
@@ -435,7 +435,7 @@ class ThesisCreateController
}
}
$keywords = array_values(array_unique($keywords));
$keywords = array_filter($keywords, fn($t) => $t !== '');
$keywords = array_filter($keywords, fn ($t) => $t !== '');
$keywords = array_slice($keywords, 0, 10);
if (count($keywords) > 10) {
throw new Exception('Maximum 10 mots-clés autorisés.');
@@ -630,7 +630,7 @@ class ThesisCreateController
null,
null
);
error_log("ThesisCreateController: PeerTube upload OK → " . $result['watchUrl']);
error_log('ThesisCreateController: PeerTube upload OK → ' . $result['watchUrl']);
} catch (\Throwable $e) {
error_log('ThesisCreateController: PeerTube upload failed — ' . $e->getMessage());
// Non-fatal: thesis already saved; admin can re-upload manually.