php-cs-fixer : configuration et formatage initial
Installe friendsofphp/php-cs-fixer en require-dev, configure le style PSR-12 avec guillemets simples et alignement des =>, et formate les fichiers PHP existants. Ajoute la config VS Codium pour le format on save. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
310af2325d
commit
e7ff6b6518
14 changed files with 2414 additions and 72 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -20,7 +20,7 @@ CLAUDE.md
|
|||
# (sensitive workspace files)
|
||||
# ---------------------------
|
||||
*.sublime-workspace
|
||||
/.vscode
|
||||
/.vscode/*.code-workspace
|
||||
/.idea
|
||||
|
||||
# -------------SECURITY-------------
|
||||
|
|
@ -32,6 +32,7 @@ CLAUDE.md
|
|||
|
||||
/site/cache/*
|
||||
!/site/cache/index.html
|
||||
.php-cs-fixer.cache
|
||||
|
||||
# Accounts
|
||||
# ---------------
|
||||
|
|
|
|||
29
.php-cs-fixer.php
Normal file
29
.php-cs-fixer.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
$finder = PhpCsFixer\Finder::create()
|
||||
->in([
|
||||
__DIR__ . '/site/models',
|
||||
__DIR__ . '/site/config',
|
||||
__DIR__ . '/site/templates',
|
||||
__DIR__ . '/site/snippets',
|
||||
])
|
||||
->append([__DIR__ . '/index.php'])
|
||||
->notPath('picture.php') // bug php-cs-fixer : statement_indentation dans ce fichier
|
||||
->ignoreDotFiles(true);
|
||||
|
||||
return (new PhpCsFixer\Config())
|
||||
->setRules([
|
||||
'@PSR12' => true,
|
||||
'single_quote' => true,
|
||||
'array_syntax' => ['syntax' => 'short'],
|
||||
'no_unused_imports' => true,
|
||||
'ordered_imports' => ['sort_algorithm' => 'alpha'],
|
||||
'no_extra_blank_lines' => ['tokens' => ['extra', 'throw', 'use']],
|
||||
'trailing_comma_in_multiline' => true,
|
||||
'binary_operator_spaces' => [
|
||||
'default' => 'single_space',
|
||||
'operators' => ['=>' => 'align_single_space_minimal'],
|
||||
],
|
||||
])
|
||||
->setFinder($finder)
|
||||
->setCacheFile(__DIR__ . '/.php-cs-fixer.cache');
|
||||
5
.vscode/extensions.json
vendored
Normal file
5
.vscode/extensions.json
vendored
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"recommendations": [
|
||||
"junstyle.php-cs-fixer"
|
||||
]
|
||||
}
|
||||
11
.vscode/settings.json
vendored
Normal file
11
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"php-cs-fixer.executablePath": "${workspaceFolder}/vendor/bin/php-cs-fixer",
|
||||
"php-cs-fixer.config": "${workspaceFolder}/.php-cs-fixer.php",
|
||||
"php-cs-fixer.onsave": true,
|
||||
"php-cs-fixer.formatHtml": false,
|
||||
"php-cs-fixer.documentFormattingProvider": true,
|
||||
"[php]": {
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "junstyle.php-cs-fixer"
|
||||
}
|
||||
}
|
||||
|
|
@ -35,5 +35,8 @@
|
|||
"Composer\\Config::disableProcessTimeout",
|
||||
"@php -S localhost:8000 kirby/router.php"
|
||||
]
|
||||
},
|
||||
"require-dev": {
|
||||
"friendsofphp/php-cs-fixer": "^3.95"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2299
composer.lock
generated
2299
composer.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -2,4 +2,4 @@
|
|||
|
||||
require 'kirby/bootstrap.php';
|
||||
|
||||
echo (new Kirby)->render();
|
||||
echo (new Kirby())->render();
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
|
||||
return [
|
||||
'debug' => true,
|
||||
'locale' => 'fr_FR.UTF-8',
|
||||
'debug' => true,
|
||||
'locale' => 'fr_FR.UTF-8',
|
||||
'date.handler' => 'intl',
|
||||
'thumbs' => [
|
||||
'thumbs' => [
|
||||
'quality' => 80,
|
||||
'srcsets' => array_merge(
|
||||
require __DIR__ . '/thumbs/events-grid.php',
|
||||
require __DIR__ . '/thumbs/event-slideshow.php',
|
||||
require __DIR__ . '/thumbs/events-grid.php',
|
||||
require __DIR__ . '/thumbs/event-slideshow.php',
|
||||
),
|
||||
],
|
||||
];
|
||||
];
|
||||
|
|
|
|||
|
|
@ -6,26 +6,32 @@ class EventPage extends Page
|
|||
{
|
||||
$dateRanges = $this->dates()->toStructure();
|
||||
|
||||
if ($dateRanges->isEmpty()) return '';
|
||||
if ($dateRanges->isEmpty()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$allFromDates = [];
|
||||
$allToDates = [];
|
||||
$allToDates = [];
|
||||
|
||||
foreach ($dateRanges as $range) {
|
||||
$from = $range->from()->value();
|
||||
if (empty($from)) continue;
|
||||
if (empty($from)) {
|
||||
continue;
|
||||
}
|
||||
$allFromDates[] = $from;
|
||||
// to est optionnel : date ponctuelle si absent
|
||||
$allToDates[] = $range->to()->value() ?: $from;
|
||||
}
|
||||
|
||||
if (empty($allFromDates)) return '';
|
||||
if (empty($allFromDates)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$earliestFrom = min($allFromDates);
|
||||
$latestTo = max($allToDates);
|
||||
$latestTo = max($allToDates);
|
||||
|
||||
$formattedFrom = date('d/m/y', strtotime($earliestFrom));
|
||||
$formattedTo = date('d/m/y', strtotime($latestTo));
|
||||
$formattedTo = date('d/m/y', strtotime($latestTo));
|
||||
|
||||
if ($earliestFrom === $latestTo) {
|
||||
return 'le ' . $formattedFrom;
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title><?= $page->isHomePage() ? $site->title() : $page->title() . " | " . $site->title() ?></title>
|
||||
<title><?= $page->isHomePage() ? $site->title() : $page->title() . ' | ' . $site->title() ?></title>
|
||||
<meta name="robots" content="none">
|
||||
|
||||
<link rel="stylesheet" href="<?= url('assets/css/style.css') ?>">
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
<h1><?= e($page->isHomePage(), 'Compagnie de théâtre', $page->title()) ?></h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<?php foreach($site->children()->listed()->without($page) as $navItem): ?>
|
||||
<?php foreach ($site->children()->listed()->without($page) as $navItem): ?>
|
||||
<li><a href="<?= $navItem->url() ?>"><?= $navItem->title() ?></a><hr></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<?php if (isset($file)): ?>
|
||||
<?php
|
||||
$alt = $alt ?? $file->alt() ?? '';
|
||||
$lazy = $lazy ?? true;
|
||||
$alt = $alt ?? $file->alt() ?? '';
|
||||
$lazy = $lazy ?? true;
|
||||
$classAttr = isset($class) ? ' class="' . htmlspecialchars($class) . '"' : '';
|
||||
$spanAttr = isset($span) ? ' style="--span: ' . htmlspecialchars($span) . ';"' : '';
|
||||
$spanAttr = isset($span) ? ' style="--span: ' . htmlspecialchars($span) . ';"' : '';
|
||||
?>
|
||||
<?php if ($file->mime() === 'image/gif'): ?>
|
||||
<picture<?= $classAttr ?><?= $spanAttr ?> data-id="<?= $file->uuid() ?>" orientation="<?= $file->orientation() ?>" data-mime="<?= $file->mime() ?>">
|
||||
|
|
@ -26,22 +26,22 @@
|
|||
$sizesAttr = '(min-width: 1085px) 50vw, 100vw';
|
||||
}
|
||||
|
||||
$srcsetName = $srcsetName ?? 'default';
|
||||
$webpName = $srcsetName . '-webp';
|
||||
$crop = $crop ?? false;
|
||||
$srcsetName = $srcsetName ?? 'default';
|
||||
$webpName = $srcsetName . '-webp';
|
||||
$crop = $crop ?? false;
|
||||
|
||||
// Vérifie si un srcset webp nommé existe en config, sinon fallback sur 'webp'
|
||||
$kirbyThumbs = kirby()->option('thumbs.srcsets', []);
|
||||
$webpSrcset = isset($kirbyThumbs[$webpName])
|
||||
$webpSrcset = isset($kirbyThumbs[$webpName])
|
||||
? $file->srcset($webpName)
|
||||
: $file->srcset('webp');
|
||||
|
||||
$srcset = $file->srcset($srcsetName);
|
||||
$src = $file->url();
|
||||
$src = $file->url();
|
||||
|
||||
$resized = $file->resize(1800);
|
||||
$width = $resized ? $resized->width() : $file->width();
|
||||
$height = $resized ? $resized->height() : $file->height();
|
||||
$width = $resized ? $resized->width() : $file->width();
|
||||
$height = $resized ? $resized->height() : $file->height();
|
||||
?>
|
||||
<picture<?= $classAttr ?><?= $spanAttr ?> data-id="<?= $file->uuid() ?>" orientation="<?= $file->orientation() ?>" data-mime="<?= $file->mime() ?>">
|
||||
<source srcset="<?= $webpSrcset ?>" sizes="<?= $sizesAttr ?>" type="image/webp">
|
||||
|
|
|
|||
|
|
@ -4,56 +4,48 @@
|
|||
<?php $galleryImages = $page->gallery()->toFiles() ?>
|
||||
|
||||
<?php if ($galleryImages->count()): ?>
|
||||
<div class="slideshow">
|
||||
<div class="slides">
|
||||
<?php $dirs = ['up', 'right', 'down'] ?>
|
||||
<?php $images = array_values(iterator_to_array($galleryImages)) ?>
|
||||
<?php $pendingCartouche = null ?>
|
||||
<?php foreach($images as $index => $image): ?>
|
||||
|
||||
<div class="slide <?= $image->isPortrait() ? 'is-portrait' : 'is-landscape' ?><?= e($index === 0, ' active', ' next ' . $dirs[array_rand($dirs)]) ?>">
|
||||
<?php snippet('picture', [
|
||||
'file' => $image,
|
||||
'srcsetName' => 'event-slideshow',
|
||||
'sizes' => '100vw',
|
||||
'alt' => $image->alt()->or($page->title())->value(),
|
||||
'lazy' => $index > 0,
|
||||
]) ?>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$nextImage = $images[$index + 1] ?? null;
|
||||
$isFirstOfPortraitPair = $image->isPortrait() && $nextImage?->isPortrait();
|
||||
if ($isFirstOfPortraitPair):
|
||||
$pendingCartouche = $cartouches[$index] ?? null;
|
||||
else:
|
||||
?>
|
||||
<?php foreach(array_filter([$pendingCartouche, $cartouches[$index] ?? null]) as $c): ?>
|
||||
<div class="slide is-insert next <?= $dirs[array_rand($dirs)] ?>">
|
||||
<div class="insert" style="top: <?= rand(15, 60) ?>%; left: <?= rand(2, 20) ?>%">
|
||||
<?php if ($c['type'] === 'title'): ?>
|
||||
<h1><?= $c['text'] ?></h1>
|
||||
<?php else: ?>
|
||||
<dl>
|
||||
<dt><?= $c['label'] ?></dt>
|
||||
<dd><?= $c['value'] ?></dd>
|
||||
</dl>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
<?php $pendingCartouche = null ?>
|
||||
<?php endif ?>
|
||||
|
||||
<?php endforeach ?>
|
||||
<div class="gallery">
|
||||
<div class="slides">
|
||||
|
||||
<div
|
||||
class="slide"
|
||||
data-type="title"
|
||||
>
|
||||
<h1><?= $page->title() ?></h1>
|
||||
</div>
|
||||
|
||||
<?php foreach ($page->gallery()->toFiles() as $index => $image): ?>
|
||||
<div
|
||||
class="slide"
|
||||
data-orientation="<?= $image->orientation() ?>"
|
||||
data-type="image"
|
||||
>
|
||||
<?php snippet('picture', [
|
||||
'file' => $image,
|
||||
'srcsetName' => 'event-slideshow',
|
||||
'sizes' => '100vw',
|
||||
'alt' => $image->alt()->or($page->title())->value(),
|
||||
'lazy' => $index > 0,
|
||||
]) ?>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
|
||||
<?php foreach ($page->mainCredits()->toStructure() as $credit): ?>
|
||||
<div class="slide" data-type="insert">
|
||||
<dl>
|
||||
<dt><?= $credit->label() ?></dt>
|
||||
<dd><?= $credit->value() ?></dd>
|
||||
</dl>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
<div class="main-infos bottom-tab">
|
||||
<ul>
|
||||
<li><?= $page->schedule() ?></li>
|
||||
<?php foreach($page->mainCredits()->toStructure() as $mainCredit): ?>
|
||||
<?php foreach ($page->mainCredits()->toStructure() as $mainCredit): ?>
|
||||
<li><?= $mainCredit->label() ?> : <?= $mainCredit->value() ?></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<?php snippet('header') ?>
|
||||
|
||||
<ul class="events-grid">
|
||||
<?php foreach($page->children() as $event): ?>
|
||||
<?php foreach ($page->children() as $event): ?>
|
||||
<li class="event-card" data-company="<?= $event->isFromCompany() ?>">
|
||||
<a href="<?= $event->url() ?>">
|
||||
<h2><?= $event->title() ?></h2>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue