From a9cec46fdf783d370ec7bb245c0b53b09c4eb31a Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Sat, 3 Jan 2026 19:07:22 +0100 Subject: [PATCH 1/8] Update tests namespace --- tests/GaletteLegalNotices/Entity/tests/units/Pages.php | 2 +- tests/GaletteLegalNotices/Entity/tests/units/Settings.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/GaletteLegalNotices/Entity/tests/units/Pages.php b/tests/GaletteLegalNotices/Entity/tests/units/Pages.php index fc63014..6b47007 100644 --- a/tests/GaletteLegalNotices/Entity/tests/units/Pages.php +++ b/tests/GaletteLegalNotices/Entity/tests/units/Pages.php @@ -23,7 +23,7 @@ namespace GaletteLegalNotices\Entity\tests\units; -use Galette\GaletteTestCase; +use Galette\Tests\GaletteTestCase; use Laminas\Db\Adapter\Adapter; /** diff --git a/tests/GaletteLegalNotices/Entity/tests/units/Settings.php b/tests/GaletteLegalNotices/Entity/tests/units/Settings.php index 9abb1cd..4aac457 100644 --- a/tests/GaletteLegalNotices/Entity/tests/units/Settings.php +++ b/tests/GaletteLegalNotices/Entity/tests/units/Settings.php @@ -23,7 +23,7 @@ namespace GaletteLegalNotices\Entity\tests\units; -use Galette\GaletteTestCase; +use Galette\Tests\GaletteTestCase; /** * Settings tests From f1d482d0f79693bf5232b45e79efd2103f1a3a68 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Sat, 3 Jan 2026 19:07:39 +0100 Subject: [PATCH 2/8] Fix core composer path --- .github/workflows/ci-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 50e1b20..f67ed00 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -64,7 +64,7 @@ jobs: - name: Install dependencies run: | - cd galette-core/galette + cd galette-core composer install --ignore-platform-reqs - name: CS From e81b38d44e2ad8da3fc13634d9743f7db9c5ece3 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Sat, 3 Jan 2026 19:08:17 +0100 Subject: [PATCH 3/8] =?UTF-8?q?Update=20=C2=A9=20date?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _config.inc.php | 2 +- _define.php | 2 +- _routes.php | 2 +- lib/GaletteLegalNotices/Controllers/MainController.php | 2 +- lib/GaletteLegalNotices/Entity/Pages.php | 2 +- lib/GaletteLegalNotices/Entity/Settings.php | 2 +- lib/GaletteLegalNotices/PluginGaletteLegalnotices.php | 2 +- tests/GaletteLegalNotices/Entity/tests/units/Pages.php | 2 +- tests/GaletteLegalNotices/Entity/tests/units/Settings.php | 2 +- tests/TestsBootstrap.php | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/_config.inc.php b/_config.inc.php index f64d71c..e9bd924 100644 --- a/_config.inc.php +++ b/_config.inc.php @@ -1,7 +1,7 @@ Date: Sat, 3 Jan 2026 19:11:40 +0100 Subject: [PATCH 4/8] Update cs-fixer and phpcodesniffer configurations --- .php-cs-fixer.dist.php | 53 ++++++++++++++++++- .phpcs.xml | 24 ++++++++- .../Controllers/MainController.php | 12 ----- lib/GaletteLegalNotices/Entity/Pages.php | 22 ++------ lib/GaletteLegalNotices/Entity/Settings.php | 43 +++++---------- .../Entity/tests/units/Pages.php | 8 --- .../Entity/tests/units/Settings.php | 10 ---- tests/TestsBootstrap.php | 2 + 8 files changed, 92 insertions(+), 82 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 54dd015..dad16e4 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -15,9 +15,58 @@ '@PER-CS' => true, '@PHP8x2Migration' => true, 'trailing_comma_in_multiline' => false, - 'cast_spaces' => false, + 'cast_spaces' => ['space' => 'none'], 'single_line_empty_body' => false, - 'no_unused_imports' => true + 'no_unused_imports' => true, + // rules for phpdoc + // Removes @param, @return and @var tags that don't provide any useful information - https://mlocati.github.io/php-cs-fixer-configurator/#version:3.90|fixer:no_superfluous_phpdoc_tags + 'no_superfluous_phpdoc_tags' => [ + 'allow_mixed' => true, + 'remove_inheritdoc' => true, + ], + // require phpdoc for non typed arguments - https://mlocati.github.io/php-cs-fixer-configurator/#version:3.90|fixer:phpdoc_add_missing_param_annotation + 'phpdoc_add_missing_param_annotation' => true, + // no @access - https://mlocati.github.io/php-cs-fixer-configurator/#version:3.90|fixer:phpdoc_no_access + 'phpdoc_no_access' => true, + // no @package - https://mlocati.github.io/php-cs-fixer-configurator/#version:3.90|fixer:phpdoc_no_package + 'phpdoc_no_package' => true, + // order phpdoc tags - https://mlocati.github.io/php-cs-fixer-configurator/#version:3.90|fixer:phpdoc_order + 'phpdoc_order' => ['order' => ['since', 'var', 'see', 'param', 'return', 'throw', 'todo', 'deprecated']], + // phpdoc param in same order as signature - https://mlocati.github.io/php-cs-fixer-configurator/#version:3.90|fixer:phpdoc_param_order + 'phpdoc_param_order' => true, + // align tags - https://mlocati.github.io/php-cs-fixer-configurator/#version:3.90|fixer:phpdoc_align + 'phpdoc_align' => [ + 'align' => 'vertical', + 'tags' => [ + 'param', + 'property', + 'property-read', + 'property-write', + 'phpstan-param', + 'phpstan-property', + 'phpstan-property-read', + 'phpstan-property-write', + 'phpstan-assert', + 'phpstan-assert-if-true', + 'phpstan-assert-if-false', + 'psalm-param', + 'psalm-param-out', + 'psalm-property', + 'psalm-property-read', + 'psalm-property-write', + 'psalm-assert', + 'psalm-assert-if-true', + 'psalm-assert-if-false' + ], + ], + // Check types case - https://mlocati.github.io/php-cs-fixer-configurator/#version:3.90|fixer:phpdoc_types + 'phpdoc_types' => true, + // Use native scalar types - https://mlocati.github.io/php-cs-fixer-configurator/#version:3.90|fixer:phpdoc_scalar + 'phpdoc_scalar' => true, + // remove extra empty lines - https://mlocati.github.io/php-cs-fixer-configurator/#version:3.90|fixer:phpdoc_trim + 'phpdoc_trim' => true, + // remove empty lines inside phpdoc block - https://mlocati.github.io/php-cs-fixer-configurator/#version:3.90|fixer:phpdoc_trim_consecutive_blank_line_separation + 'phpdoc_trim_consecutive_blank_line_separation' => true, ]) ->setFinder($finder) ; diff --git a/.phpcs.xml b/.phpcs.xml index e7cc457..4a33a69 100644 --- a/.phpcs.xml +++ b/.phpcs.xml @@ -16,6 +16,8 @@ + + @@ -23,6 +25,26 @@ - + + + + + + + + + + + + + + + + + + + + + diff --git a/lib/GaletteLegalNotices/Controllers/MainController.php b/lib/GaletteLegalNotices/Controllers/MainController.php index 5ac6829..3284f38 100644 --- a/lib/GaletteLegalNotices/Controllers/MainController.php +++ b/lib/GaletteLegalNotices/Controllers/MainController.php @@ -53,8 +53,6 @@ class MainController extends AbstractPluginController * @param Response $response PSR Response * @param ?string $lang Language * @param ?string $name Page name - * - * @return Response */ public function listPages(Request $request, Response $response, ?string $lang = null, ?string $name = null): Response { @@ -94,8 +92,6 @@ public function listPages(Request $request, Response $response, ?string $lang = * * @param Request $request PSR Request * @param Response $response PSR Response - * - * @return Response */ public function changePage(Request $request, Response $response): Response { @@ -119,8 +115,6 @@ public function changePage(Request $request, Response $response): Response * * @param Request $request PSR Request * @param Response $response PSR Response - * - * @return Response */ public function editPage(Request $request, Response $response): Response { @@ -178,8 +172,6 @@ public function editPage(Request $request, Response $response): Response * @param Request $request PSR Request * @param Response $response PSR Response * @param string|null $name One of 'legal-information', 'terms-of-service' or 'privacy-policy' - * - * @return Response */ public function viewPage(Request $request, Response $response, ?string $name = null): Response { @@ -243,8 +235,6 @@ public function viewPage(Request $request, Response $response, ?string $name = n * * @param Request $request PSR Request * @param Response $response PSR Response - * - * @return Response */ public function settings(Request $request, Response $response): Response { @@ -282,8 +272,6 @@ public function settings(Request $request, Response $response): Response * * @param Request $request PSR Request * @param Response $response PSR Response - * - * @return Response */ public function storeSettings(Request $request, Response $response): Response { diff --git a/lib/GaletteLegalNotices/Entity/Pages.php b/lib/GaletteLegalNotices/Entity/Pages.php index d48bde2..5edcfa4 100644 --- a/lib/GaletteLegalNotices/Entity/Pages.php +++ b/lib/GaletteLegalNotices/Entity/Pages.php @@ -93,7 +93,7 @@ public function __construct(Preferences $preferences, ?RouteParser $routeparser /** * Get patterns for pages * - * @param boolean $legacy Whether to load legacy patterns + * @param bool $legacy Whether to load legacy patterns * * @return array|string>> */ @@ -115,8 +115,6 @@ protected function getPagesPatterns(bool $legacy = true): array /** * Set pages replacements - * - * @return self */ public function setPagesPatterns(): self { @@ -155,9 +153,9 @@ public function setPagesPatterns(): self /** * Initialize pages at install time * - * @param boolean $check_first Check first if it seems initialized + * @param bool $check_first Check first if it seems initialized * - * @return boolean false if no need to initialize, true if data has been initialized, Exception if error + * @return bool false if no need to initialize, true if data has been initialized, Exception if error * @throws Throwable */ public function installInit(bool $check_first = true): bool @@ -210,8 +208,6 @@ public function installInit(bool $check_first = true): bool /** * Checks for missing pages in the database - * - * @return boolean */ private function checkUpdate(): bool { @@ -266,8 +262,6 @@ private function checkUpdate(): bool /** * Checks for translated pages in the database - * - * @return bool */ private function checkTranslated(): bool { @@ -400,8 +394,6 @@ public function getPages(string $name, string $lang): ArrayObject * @param string $lang Page language to locate * @param string $body Page body to store * @param string $url Page external URL to store - * - * @return bool */ public function storePageContent(string $name, string $lang, string $body, string $url): bool { @@ -469,8 +461,6 @@ public function getNames(string $lang = I18n::DEFAULT_LANG): array /** * Get the page body, with all replacements done - * - * @return string */ public function getBody(): string { @@ -481,8 +471,6 @@ public function getBody(): string * Insert values in database * * @param array $values Values to insert - * - * @return void */ private function insert(array $values): void { @@ -611,8 +599,6 @@ public function getLegend(): array * Set translated pages * * @param array $pages array of translated pages - * - * @return void */ public function setTranslated(array $pages): void { @@ -623,8 +609,6 @@ public function setTranslated(array $pages): void * Check if the specified page is translated * * @param int $id page identifier - * - * @return boolean */ public function isTranslated(int $id): bool { diff --git a/lib/GaletteLegalNotices/Entity/Settings.php b/lib/GaletteLegalNotices/Entity/Settings.php index 83c1afd..cce2e57 100644 --- a/lib/GaletteLegalNotices/Entity/Settings.php +++ b/lib/GaletteLegalNotices/Entity/Settings.php @@ -34,17 +34,17 @@ * @author Johan Cwiklinski * @author Guillaume AGNIERAY * - * @property boolean $enable_legal_information Enable Legal Information page - * @property boolean $enable_terms_of_service Enable Terms & Conditions page - * @property boolean $enable_privacy_policy Enable Privacy Policy page - * @property boolean $publicpage_links Link pages in the public pages menu - * @property boolean $fallback_language Language used for all untranslated pages - * @property boolean $enable_cmp Enable the consent management plateform - * @property boolean $hide_accept_all Hide the "Accept all" button - * @property boolean $hide_decline_all Hide the "I decline" button - * @property integer $cookie_expiration Cookie lifetime - * @property string $cookie_domain Change the cookie domain - * @property string $enable_localstorage Store consent information in the browser with localStorage + * @property bool $enable_legal_information Enable Legal Information page + * @property bool $enable_terms_of_service Enable Terms & Conditions page + * @property bool $enable_privacy_policy Enable Privacy Policy page + * @property bool $publicpage_links Link pages in the public pages menu + * @property bool $fallback_language Language used for all untranslated pages + * @property bool $enable_cmp Enable the consent management plateform + * @property bool $hide_accept_all Hide the "Accept all" button + * @property bool $hide_decline_all Hide the "I decline" button + * @property int $cookie_expiration Cookie lifetime + * @property string $cookie_domain Change the cookie domain + * @property string $enable_localstorage Store consent information in the browser with localStorage */ class Settings @@ -92,8 +92,8 @@ class Settings /** * Main constructor * - * @param Db $zdb Database instance - * @param boolean $load Automatically load preferences on load + * @param Db $zdb Database instance + * @param bool $load Automatically load preferences on load * * @return void */ @@ -109,8 +109,6 @@ public function __construct(Db $zdb, bool $load = true) /** * Check if all fields referenced in the default array does exists, * create them if not - * - * @return boolean */ private function checkUpdate(): bool { @@ -168,8 +166,6 @@ private function checkUpdate(): bool /** * Load settings from the database - * - * @return boolean */ public function load(): bool { @@ -198,7 +194,6 @@ public function load(): bool /** * Initialize settings at install time * - * @return boolean * @throws Throwable */ public function installInit(): bool @@ -256,8 +251,6 @@ public function getFieldsNames(): array * Check values * * @param array $values Values - * - * @return void */ public function check(array $values): void { @@ -288,8 +281,6 @@ public function check(array $values): void /** * Store values in the database - * - * @return boolean */ public function store(): bool { @@ -391,8 +382,6 @@ public function __get(string $name): mixed * Required for twig to access properties via __get * * @param string $name name of the property we want to retrieve - * - * @return bool */ public function __isset(string $name): bool { @@ -422,8 +411,6 @@ public function getDefaults(): array * * @param string $name name of the property we want to assign a value to * @param mixed $value a relevant value for the property - * - * @return void */ public function __set(string $name, mixed $value): void { @@ -453,8 +440,6 @@ public function getSettings(): array /** * Get fallback language - * - * @return string */ public function getFallbackLanguage(): string { @@ -465,8 +450,6 @@ public function getFallbackLanguage(): string * Check if the specified page is disabled * * @param string $name page name - * - * @return boolean */ public function isPageEnabled(string $name): bool { diff --git a/tests/GaletteLegalNotices/Entity/tests/units/Pages.php b/tests/GaletteLegalNotices/Entity/tests/units/Pages.php index dffd25b..77ce852 100644 --- a/tests/GaletteLegalNotices/Entity/tests/units/Pages.php +++ b/tests/GaletteLegalNotices/Entity/tests/units/Pages.php @@ -36,8 +36,6 @@ class Pages extends GaletteTestCase { /** * Cleanup after each test method - * - * @return void */ public function tearDown(): void { @@ -48,8 +46,6 @@ public function tearDown(): void /** * Test getList - * - * @return void */ public function testGetList(): void { @@ -97,8 +93,6 @@ public function testGetList(): void /** * Test expected patterns - * - * @return void */ public function testExpectedPatterns(): void { @@ -127,8 +121,6 @@ public function testExpectedPatterns(): void /** * Test page replacements - * - * @return void */ public function testReplacements(): void { diff --git a/tests/GaletteLegalNotices/Entity/tests/units/Settings.php b/tests/GaletteLegalNotices/Entity/tests/units/Settings.php index 452ebf3..de4fa4d 100644 --- a/tests/GaletteLegalNotices/Entity/tests/units/Settings.php +++ b/tests/GaletteLegalNotices/Entity/tests/units/Settings.php @@ -35,8 +35,6 @@ class Settings extends GaletteTestCase { /** * Cleanup after each test method - * - * @return void */ public function tearDown(): void { @@ -47,8 +45,6 @@ public function tearDown(): void /** * Test preferences initialization - * - * @return void */ public function testInstallInit(): void { @@ -102,8 +98,6 @@ public function testInstallInit(): void /** * Test fields names - * - * @return void */ public function testFieldsNames(): void { @@ -120,8 +114,6 @@ public function testFieldsNames(): void /** * Test settings updating when some are missing - * - * @return void */ public function testUpdate(): void { @@ -160,8 +152,6 @@ public function testUpdate(): void /** * Test __isset - * - * @return void */ public function testIsset(): void { diff --git a/tests/TestsBootstrap.php b/tests/TestsBootstrap.php index 57853c4..41e2721 100644 --- a/tests/TestsBootstrap.php +++ b/tests/TestsBootstrap.php @@ -19,6 +19,8 @@ * along with Galette. If not, see . */ +declare(strict_types=1); + /** * Bootstrap tests file for Galette Legal Notices * From f99924b4b7a93dcc3df16d2d2f06b91d6403f568 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Sat, 3 Jan 2026 19:14:00 +0100 Subject: [PATCH 5/8] Remove useless phpdoc and parameters --- .../Controllers/MainController.php | 26 ++++--------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/lib/GaletteLegalNotices/Controllers/MainController.php b/lib/GaletteLegalNotices/Controllers/MainController.php index 3284f38..a034da6 100644 --- a/lib/GaletteLegalNotices/Controllers/MainController.php +++ b/lib/GaletteLegalNotices/Controllers/MainController.php @@ -49,12 +49,10 @@ class MainController extends AbstractPluginController /** * List pages * - * @param Request $request PSR Request - * @param Response $response PSR Response - * @param ?string $lang Language - * @param ?string $name Page name + * @param ?string $lang Language + * @param ?string $name Page name */ - public function listPages(Request $request, Response $response, ?string $lang = null, ?string $name = null): Response + public function listPages(Response $response, ?string $lang = null, ?string $name = null): Response { if ($lang === null) { $lang = $this->preferences->pref_lang; @@ -89,9 +87,6 @@ public function listPages(Request $request, Response $response, ?string $lang = /** * Change page - * - * @param Request $request PSR Request - * @param Response $response PSR Response */ public function changePage(Request $request, Response $response): Response { @@ -112,9 +107,6 @@ public function changePage(Request $request, Response $response): Response /** * Edit page - * - * @param Request $request PSR Request - * @param Response $response PSR Response */ public function editPage(Request $request, Response $response): Response { @@ -169,9 +161,7 @@ public function editPage(Request $request, Response $response): Response /** * View page * - * @param Request $request PSR Request - * @param Response $response PSR Response - * @param string|null $name One of 'legal-information', 'terms-of-service' or 'privacy-policy' + * @param string|null $name One of 'legal-information', 'terms-of-service' or 'privacy-policy' */ public function viewPage(Request $request, Response $response, ?string $name = null): Response { @@ -232,11 +222,8 @@ public function viewPage(Request $request, Response $response, ?string $name = n /** * Settings - * - * @param Request $request PSR Request - * @param Response $response PSR Response */ - public function settings(Request $request, Response $response): Response + public function settings(Response $response): Response { $plugin_settings = new Settings($this->zdb); $settings_fields = $plugin_settings->getFieldsNames(); @@ -269,9 +256,6 @@ public function settings(Request $request, Response $response): Response /** * Store Settings - * - * @param Request $request PSR Request - * @param Response $response PSR Response */ public function storeSettings(Request $request, Response $response): Response { From bfcb3b8c49c44775da39cb27fef3de287e97369d Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Sat, 3 Jan 2026 19:14:08 +0100 Subject: [PATCH 6/8] Use DI instead of globals --- lib/GaletteLegalNotices/Controllers/MainController.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/GaletteLegalNotices/Controllers/MainController.php b/lib/GaletteLegalNotices/Controllers/MainController.php index a034da6..3c478b5 100644 --- a/lib/GaletteLegalNotices/Controllers/MainController.php +++ b/lib/GaletteLegalNotices/Controllers/MainController.php @@ -163,10 +163,8 @@ public function editPage(Request $request, Response $response): Response * * @param string|null $name One of 'legal-information', 'terms-of-service' or 'privacy-policy' */ - public function viewPage(Request $request, Response $response, ?string $name = null): Response + public function viewPage(Request $request, Response $response, I18n $i18n, ?string $name = null): Response { - /** @var I18n $i18n */ - global $i18n; $lang = $i18n->getID(); $login = $this->login; $pages = new Pages($this->preferences, $this->routeparser); From a39a82ffb9f17f998b0d64626bf98a9018c747f0 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Sat, 3 Jan 2026 19:14:46 +0100 Subject: [PATCH 7/8] phpstan lvl 6 --- phpstan.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index a8e52ab..1950380 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,7 @@ parameters: parallel: maximumNumberOfProcesses: 2 - level: 5 + level: 6 paths: - lib/ scanFiles: From b14a0e56950c730de68bde36f809b722f8502af2 Mon Sep 17 00:00:00 2001 From: Johan Cwiklinski Date: Sat, 3 Jan 2026 19:17:04 +0100 Subject: [PATCH 8/8] Fix unused variables --- lib/GaletteLegalNotices/Entity/Settings.php | 2 +- lib/GaletteLegalNotices/PluginGaletteLegalnotices.php | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/GaletteLegalNotices/Entity/Settings.php b/lib/GaletteLegalNotices/Entity/Settings.php index cce2e57..1feff99 100644 --- a/lib/GaletteLegalNotices/Entity/Settings.php +++ b/lib/GaletteLegalNotices/Entity/Settings.php @@ -295,7 +295,7 @@ public function store(): bool $stmt = $this->zdb->sql->prepareStatementForSqlObject($update); - foreach (self::$defaults as $k => $v) { + foreach (array_keys(self::$defaults) as $k) { Analog::log('Storing Legal Notices ' . $k, Analog::DEBUG); $value = $this->settings[$k]; diff --git a/lib/GaletteLegalNotices/PluginGaletteLegalnotices.php b/lib/GaletteLegalNotices/PluginGaletteLegalnotices.php index f48d5f3..977ae07 100644 --- a/lib/GaletteLegalNotices/PluginGaletteLegalnotices.php +++ b/lib/GaletteLegalNotices/PluginGaletteLegalnotices.php @@ -49,7 +49,6 @@ public static function getMenusContents(): array global $login; /** @var Db $zdb */ global $zdb; - $settings = new Settings($zdb); $menus = []; $items = [];