diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 59d91e2..bf858c9 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 2bb24d2..9a45b35 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,4 +1,4 @@ -in([ @@ -13,11 +13,60 @@ ->setRules([ '@PSR12' => true, '@PER-CS' => true, - '@PHP82Migration' => 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/_config.inc.php b/_config.inc.php index f9dcb3b..3962cd5 100644 --- a/_config.inc.php +++ b/_config.inc.php @@ -1,7 +1,7 @@ register( 'Galette Activities', //Name 'Activities management', //Short description diff --git a/_routes.php b/_routes.php index e15d17a..85b4af0 100644 --- a/_routes.php +++ b/_routes.php @@ -1,7 +1,7 @@ $args Route arguments */ public function redirectUri(array $args): string { @@ -324,9 +310,7 @@ public function redirectUri(array $args): string /** * Get form URI * - * @param array $args Route arguments - * - * @return string + * @param array $args Route arguments */ public function formUri(array $args): string { @@ -339,9 +323,7 @@ public function formUri(array $args): string /** * Get confirmation removal page title * - * @param array $args Route arguments - * - * @return string + * @param array $args Route arguments */ public function confirmRemoveTitle(array $args): string { @@ -356,10 +338,8 @@ public function confirmRemoveTitle(array $args): string /** * Remove object * - * @param array $args Route arguments - * @param array $post POST values - * - * @return bool + * @param array $args Route arguments + * @param array $post POST values */ protected function doDelete(array $args, array $post): bool { @@ -372,8 +352,6 @@ protected function doDelete(array $args, array $post): bool /** * Get default filter name - * - * @return string */ public static function getDefaultFilterName(): string { diff --git a/lib/GaletteActivities/Controllers/Crud/SubscriptionsController.php b/lib/GaletteActivities/Controllers/Crud/SubscriptionsController.php index 2c9a034..a1c8c4d 100644 --- a/lib/GaletteActivities/Controllers/Crud/SubscriptionsController.php +++ b/lib/GaletteActivities/Controllers/Crud/SubscriptionsController.php @@ -1,7 +1,7 @@ $args Route arguments */ public function redirectUri(array $args): string { @@ -461,9 +447,7 @@ public function redirectUri(array $args): string /** * Get form URI * - * @param array $args Route arguments - * - * @return string + * @param array $args Route arguments */ public function formUri(array $args): string { @@ -476,9 +460,7 @@ public function formUri(array $args): string /** * Get confirmation removal page title * - * @param array $args Route arguments - * - * @return string + * @param array $args Route arguments */ public function confirmRemoveTitle(array $args): string { @@ -496,10 +478,8 @@ public function confirmRemoveTitle(array $args): string /** * Remove object * - * @param array $args Route arguments - * @param array $post POST values - * - * @return bool + * @param array $args Route arguments + * @param array $post POST values */ protected function doDelete(array $args, array $post): bool { @@ -512,8 +492,6 @@ protected function doDelete(array $args, array $post): bool /** * Get default filter name - * - * @return string */ public static function getDefaultFilterName(): string { diff --git a/lib/GaletteActivities/Entity/Activity.php b/lib/GaletteActivities/Entity/Activity.php index 313f009..b87effc 100644 --- a/lib/GaletteActivities/Entity/Activity.php +++ b/lib/GaletteActivities/Entity/Activity.php @@ -1,7 +1,7 @@ $r the resultset row - * - * @return void */ private function loadFromRS(ArrayObject $r): void { @@ -129,8 +125,6 @@ private function loadFromRS(ArrayObject $r): void /** * Remove specified activity - * - * @return bool */ public function remove(): bool { @@ -170,8 +164,6 @@ public function remove(): bool * * @param array $values All values to check, basically the $_POST array * after sending the form - * - * @return bool */ public function check(array $values): bool { @@ -227,8 +219,6 @@ public function check(array $values): bool /** * Store the activity - * - * @return bool */ public function store(): bool { @@ -305,8 +295,6 @@ public function store(): bool /** * Get activity id - * - * @return ?int */ public function getId(): ?int { @@ -315,8 +303,6 @@ public function getId(): ?int /** * Get activity name - * - * @return string */ public function getName(): string { @@ -325,8 +311,6 @@ public function getName(): string /** * Get activity type - * - * @return string */ public function getType(): string { @@ -337,8 +321,6 @@ public function getType(): string * Get creation date * * @param bool $formatted Return date formatted, raw if false - * - * @return string */ public function getCreationDate(bool $formatted = true): string { @@ -347,8 +329,6 @@ public function getCreationDate(bool $formatted = true): string /** * Get price - * - * @return ?float */ public function getPrice(): ?float { @@ -357,8 +337,6 @@ public function getPrice(): ?float /** * Get Group - * - * @return ?Group */ public function getGroup(): ?Group { @@ -367,8 +345,6 @@ public function getGroup(): ?Group /** * Get table's name - * - * @return string */ protected function getTableName(): string { @@ -377,8 +353,6 @@ protected function getTableName(): string /** * Get comment - * - * @return string */ public function getComment(): string { @@ -397,8 +371,6 @@ public function getErrors(): array /** * Set fields, must populate $this->fields - * - * @return self */ protected function setFields(): self { diff --git a/lib/GaletteActivities/Entity/Subscription.php b/lib/GaletteActivities/Entity/Subscription.php index 28a148c..1b25c67 100644 --- a/lib/GaletteActivities/Entity/Subscription.php +++ b/lib/GaletteActivities/Entity/Subscription.php @@ -1,7 +1,7 @@ $r the resultset row - * - * @return void */ private function loadFromRS(ArrayObject $r): void { @@ -135,8 +131,6 @@ private function loadFromRS(ArrayObject $r): void /** * Remove specified subscription - * - * @return bool */ public function remove(): bool { @@ -176,8 +170,6 @@ public function remove(): bool * * @param array $values All values to check, basically the $_POST array * after sending the form - * - * @return bool */ public function check(array $values): bool { @@ -248,8 +240,6 @@ public function check(array $values): bool /** * Store the subscription - * - * @return bool */ public function store(): bool { @@ -340,8 +330,6 @@ public function store(): bool /** * Get activity id - * - * @return ?int */ public function getId(): ?int { @@ -350,8 +338,6 @@ public function getId(): ?int /** * Get activity id - * - * @return ?int */ public function getActivityId(): ?int { @@ -360,8 +346,6 @@ public function getActivityId(): ?int /** * Get activity - * - * @return ?Activity */ public function getActivity(): ?Activity { @@ -373,8 +357,6 @@ public function getActivity(): ?Activity /** * Get amount from activity - * - * @return float|null */ public function getAmountFromActivity(): ?float { @@ -387,8 +369,6 @@ public function getAmountFromActivity(): ?float /** * Get member id - * - * @return ?int */ public function getMemberId(): ?int { @@ -397,8 +377,6 @@ public function getMemberId(): ?int /** * Get member - * - * @return ?Adherent */ public function getMember(): ?Adherent { @@ -410,8 +388,6 @@ public function getMember(): ?Adherent /** * Is subscription paid? - * - * @return bool */ public function isPaid(): bool { @@ -420,8 +396,6 @@ public function isPaid(): bool /** * Get amount - * - * @return ?float */ public function getAmount(): ?float { @@ -430,8 +404,6 @@ public function getAmount(): ?float /** * Get payment method - * - * @return int */ public function getPaymentMethod(): int { @@ -440,8 +412,6 @@ public function getPaymentMethod(): int /** * Get payment method name - * - * @return string */ public function getPaymentMethodName(): string { @@ -453,8 +423,6 @@ public function getPaymentMethodName(): string * Get creation date * * @param bool $formatted Return date formatted, raw if false - * - * @return string */ public function getCreationDate(bool $formatted = true): string { @@ -465,8 +433,6 @@ public function getCreationDate(bool $formatted = true): string * Get subscription date * * @param bool $formatted Return date formatted, raw if false - * - * @return string */ public function getSubscriptionDate(bool $formatted = true): string { @@ -477,8 +443,6 @@ public function getSubscriptionDate(bool $formatted = true): string * Get end date * * @param bool $formatted Return date formatted, raw if false - * - * @return string */ public function getEndDate(bool $formatted = true): string { @@ -489,8 +453,6 @@ public function getEndDate(bool $formatted = true): string * Set activity * * @param int $activity Activity id - * - * @return self */ public function setActivity(int $activity): self { @@ -503,8 +465,6 @@ public function setActivity(int $activity): self * Set member * * @param int $member Member id - * - * @return self */ public function setMember(int $member): self { @@ -515,8 +475,6 @@ public function setMember(int $member): self /** * Get table's name - * - * @return string */ protected function getTableName(): string { @@ -525,8 +483,6 @@ protected function getTableName(): string /** * Get comment - * - * @return string */ public function getComment(): string { @@ -549,8 +505,6 @@ public function getRowClass(bool $public = false): string /** * Set fields, must populate $this->fields - * - * @return self */ protected function setFields(): self { diff --git a/lib/GaletteActivities/Filters/ActivitiesList.php b/lib/GaletteActivities/Filters/ActivitiesList.php index 7d80add..798a005 100644 --- a/lib/GaletteActivities/Filters/ActivitiesList.php +++ b/lib/GaletteActivities/Filters/ActivitiesList.php @@ -1,7 +1,7 @@ * - * @property ?string $start_date_filter - * @property ?string $end_date_filter - * @property ?string $rstart_date_filter - * @property ?string $rend_date_filter - * @property ?int $activity_filter - * @property ?int $member_filter - * @property int $paid_filter - * @property int $payment_type_filter - * @property int $date_field + * @property ?string $start_date_filter + * @property ?string $end_date_filter + * @property ?string $rstart_date_filter + * @property ?string $rend_date_filter + * @property ?int $activity_filter + * @property ?int $member_filter + * @property int $paid_filter + * @property int $payment_type_filter + * @property int $date_field * @property array $selected - * @property string $query + * @property string $query */ class SubscriptionsList extends Pagination { @@ -105,8 +105,6 @@ protected function getDefaultOrder(): int|string /** * Return the default direction for ordering - * - * @return SQLOrder */ protected function getDefaultDirection(): SQLOrder { @@ -115,8 +113,6 @@ protected function getDefaultDirection(): SQLOrder /** * Reinit default parameters - * - * @return void */ public function reinit(): void { @@ -173,8 +169,6 @@ public function __get(string $name): mixed * * @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 { diff --git a/lib/GaletteActivities/PluginGaletteActivities.php b/lib/GaletteActivities/PluginGaletteActivities.php index d56804c..69d444c 100644 --- a/lib/GaletteActivities/PluginGaletteActivities.php +++ b/lib/GaletteActivities/PluginGaletteActivities.php @@ -1,7 +1,7 @@ $fields Fields list to ensure ORDER clause + * references selected fields. Optional. * * @return array SQL ORDER clauses */ @@ -132,8 +132,6 @@ private function buildOrderClause(?array $fields = null): array * Count activities from the query * * @param Select $select Original select - * - * @return void */ private function proceedCount(Select $select): void { @@ -184,8 +182,6 @@ private function proceedCount(Select $select): void /** * Get count for current query - * - * @return int */ public function getCount(): int { @@ -196,8 +192,6 @@ public function getCount(): int * Add default activities in database * * @param bool $check_first Check first if it seems initialized - * - * @return bool */ public function installInit(bool $check_first = true): bool { diff --git a/lib/GaletteActivities/Repository/Subscriptions.php b/lib/GaletteActivities/Repository/Subscriptions.php index aaa1484..89a2d99 100644 --- a/lib/GaletteActivities/Repository/Subscriptions.php +++ b/lib/GaletteActivities/Repository/Subscriptions.php @@ -1,7 +1,7 @@ $fields SELECTE'ed fields - * - * @return bool */ private function canOrderBy(string $field_name, ?array $fields): bool { @@ -362,8 +356,6 @@ private function buildOrderClause(?array $fields = null): array * Count activities from the query * * @param Select $select Original select - * - * @return void */ private function proceedCount(Select $select): void { @@ -414,8 +406,6 @@ private function proceedCount(Select $select): void /** * Get count for current query - * - * @return int */ public function getCount(): int { @@ -424,8 +414,6 @@ public function getCount(): int /** * Get sum - * - * @return double */ public function getSum(): float { diff --git a/phpstan.neon b/phpstan.neon index 9817277..299cd45 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,7 +1,7 @@ parameters: parallel: maximumNumberOfProcesses: 2 - level: 5 + level: 6 paths: - lib/ scanFiles: diff --git a/tests/GaletteActivities/Entity/tests/units/Activity.php b/tests/GaletteActivities/Entity/tests/units/Activity.php index 96c263b..54eef7f 100644 --- a/tests/GaletteActivities/Entity/tests/units/Activity.php +++ b/tests/GaletteActivities/Entity/tests/units/Activity.php @@ -23,7 +23,7 @@ namespace GaletteActivities\tests\units; -use Galette\GaletteTestCase; +use Galette\Tests\GaletteTestCase; /** * Activity tests @@ -36,8 +36,6 @@ class Activity extends GaletteTestCase /** * Cleanup after each test method - * - * @return void */ public function tearDown(): void { @@ -52,8 +50,6 @@ public function tearDown(): void /** * Test empty - * - * @return void */ public function testEmpty(): void { @@ -68,8 +64,6 @@ public function testEmpty(): void /** * Test add and update - * - * @return void */ public function testCrud(): void { @@ -160,8 +154,6 @@ public function testCrud(): void /** * Test load error - * - * @return void */ public function testLoadError(): void { diff --git a/tests/GaletteActivities/Entity/tests/units/Subscription.php b/tests/GaletteActivities/Entity/tests/units/Subscription.php index c0ee68f..e14882a 100644 --- a/tests/GaletteActivities/Entity/tests/units/Subscription.php +++ b/tests/GaletteActivities/Entity/tests/units/Subscription.php @@ -23,7 +23,7 @@ namespace GaletteActivities\tests\units; -use Galette\GaletteTestCase; +use Galette\Tests\GaletteTestCase; /** * Subscription tests @@ -36,8 +36,6 @@ class Subscription extends GaletteTestCase /** * Cleanup after each test method - * - * @return void */ public function tearDown(): void { @@ -58,8 +56,6 @@ public function tearDown(): void /** * Test empty - * - * @return void */ public function testEmpty(): void { @@ -83,8 +79,6 @@ public function testEmpty(): void /** * Test add and update - * - * @return void */ public function testCrud(): void { @@ -291,8 +285,6 @@ public function testCrud(): void /** * Test load error - * - * @return void */ public function testLoadError(): void {