Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:

- name: Install dependencies
run: |
cd galette-core/galette
cd galette-core
composer install --ignore-platform-reqs

- name: CS
Expand Down
53 changes: 51 additions & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
;
24 changes: 23 additions & 1 deletion .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,35 @@
<!-- Include the whole PSR12 standard -->
<rule ref="PSR12"/>

<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>

<!-- Comments rules from PEAR standard -->
<rule ref="PEAR.Commenting.ClassComment">
<exclude name="PEAR.Commenting.ClassComment.MissingCategoryTag"/>
<exclude name="PEAR.Commenting.ClassComment.MissingPackageTag"/>
<exclude name="PEAR.Commenting.ClassComment.MissingLicenseTag"/>
<exclude name="PEAR.Commenting.ClassComment.MissingLinkTag"/>
</rule>
<rule ref="PEAR.Commenting.FunctionComment"/>
<rule ref="Galette.Commenting.FunctionComment"/>
<rule ref="PEAR.Commenting.InlineComment"/>

<!-- Type hinting -->
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>
<!-- Force native typehint on methods properties -->
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>
<!-- Force native typehint on methods return -->
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="spacesCountAroundEqualsSign" value="0"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.LongTypeHints"/>
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
</ruleset>
2 changes: 1 addition & 1 deletion _config.inc.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright © 2003-2025 The Galette Team
* Copyright © 2003-2026 The Galette Team
*
* This file is part of Galette Legal Notices plugin (https://galette-community.github.io/plugin-legalnotices).
*
Expand Down
2 changes: 1 addition & 1 deletion _define.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright © 2003-2025 The Galette Team
* Copyright © 2003-2026 The Galette Team
*
* This file is part of Galette Legal Notices plugin (https://galette-community.github.io/plugin-legalnotices).
*
Expand Down
2 changes: 1 addition & 1 deletion _routes.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright © 2003-2025 The Galette Team
* Copyright © 2003-2026 The Galette Team
*
* This file is part of Galette Legal Notices plugin (https://galette-community.github.io/plugin-legalnotices).
*
Expand Down
44 changes: 7 additions & 37 deletions lib/GaletteLegalNotices/Controllers/MainController.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright © 2003-2025 The Galette Team
* Copyright © 2003-2026 The Galette Team
*
* This file is part of Galette Legal Notices plugin (https://galette-community.github.io/plugin-legalnotices).
*
Expand Down Expand Up @@ -49,14 +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
*
* @return Response
* @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;
Expand Down Expand Up @@ -91,11 +87,6 @@ public function listPages(Request $request, Response $response, ?string $lang =

/**
* Change page
*
* @param Request $request PSR Request
* @param Response $response PSR Response
*
* @return Response
*/
public function changePage(Request $request, Response $response): Response
{
Expand All @@ -116,11 +107,6 @@ public function changePage(Request $request, Response $response): Response

/**
* Edit page
*
* @param Request $request PSR Request
* @param Response $response PSR Response
*
* @return Response
*/
public function editPage(Request $request, Response $response): Response
{
Expand Down Expand Up @@ -175,16 +161,10 @@ 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'
*
* @return 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);
Expand Down Expand Up @@ -240,13 +220,8 @@ public function viewPage(Request $request, Response $response, ?string $name = n

/**
* Settings
*
* @param Request $request PSR Request
* @param Response $response PSR Response
*
* @return 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();
Expand Down Expand Up @@ -279,11 +254,6 @@ public function settings(Request $request, Response $response): Response

/**
* Store Settings
*
* @param Request $request PSR Request
* @param Response $response PSR Response
*
* @return Response
*/
public function storeSettings(Request $request, Response $response): Response
{
Expand Down
24 changes: 4 additions & 20 deletions lib/GaletteLegalNotices/Entity/Pages.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* Copyright © 2003-2025 The Galette Team
* Copyright © 2003-2026 The Galette Team
*
* This file is part of Galette Legal Notices plugin (https://galette-community.github.io/plugin-legalnotices).
*
Expand Down Expand Up @@ -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, array<string, list<string>|string>>
*/
Expand All @@ -115,8 +115,6 @@ protected function getPagesPatterns(bool $legacy = true): array

/**
* Set pages replacements
*
* @return self
*/
public function setPagesPatterns(): self
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -266,8 +262,6 @@ private function checkUpdate(): bool

/**
* Checks for translated pages in the database
*
* @return bool
*/
private function checkTranslated(): bool
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -481,8 +471,6 @@ public function getBody(): string
* Insert values in database
*
* @param array<int, mixed> $values Values to insert
*
* @return void
*/
private function insert(array $values): void
{
Expand Down Expand Up @@ -611,8 +599,6 @@ public function getLegend(): array
* Set translated pages
*
* @param array<int, string> $pages array of translated pages
*
* @return void
*/
public function setTranslated(array $pages): void
{
Expand All @@ -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
{
Expand Down
Loading