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
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/_config.inc.php b/_config.inc.php
index f64d71c..e9bd924 100644
--- a/_config.inc.php
+++ b/_config.inc.php
@@ -1,7 +1,7 @@
preferences->pref_lang;
@@ -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
{
@@ -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
{
@@ -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);
@@ -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();
@@ -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
{
diff --git a/lib/GaletteLegalNotices/Entity/Pages.php b/lib/GaletteLegalNotices/Entity/Pages.php
index 0a46085..5edcfa4 100644
--- a/lib/GaletteLegalNotices/Entity/Pages.php
+++ b/lib/GaletteLegalNotices/Entity/Pages.php
@@ -1,7 +1,7 @@
|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 b6f8bc2..1feff99 100644
--- a/lib/GaletteLegalNotices/Entity/Settings.php
+++ b/lib/GaletteLegalNotices/Entity/Settings.php
@@ -1,7 +1,7 @@
* @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
{
@@ -304,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];
@@ -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/lib/GaletteLegalNotices/PluginGaletteLegalnotices.php b/lib/GaletteLegalNotices/PluginGaletteLegalnotices.php
index c1f1208..977ae07 100644
--- a/lib/GaletteLegalNotices/PluginGaletteLegalnotices.php
+++ b/lib/GaletteLegalNotices/PluginGaletteLegalnotices.php
@@ -1,7 +1,7 @@
.
*/
+declare(strict_types=1);
+
/**
* Bootstrap tests file for Galette Legal Notices
*