From 8c0c033e49e62bc55d6bc6c4bfec2e7bba22039e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 13 Nov 2024 15:27:26 +0100 Subject: [PATCH] add phpdoc in mailing modules (#31786) * add phpdoc * add phpdoc * add phpdoc * add phpdoc * add phpdoc * add phpdoc * add phpdoc * add phpdoc * test * test * test * test --- .github/workflows/phpstan_baseline.yml | 7 +- .pre-commit-config.yaml | 4 +- build/phpstan/phpstan-baseline.neon | 66 ------------------- htdocs/core/class/commonobject.class.php | 6 +- .../mailings/advthirdparties.modules.php | 25 +++++-- .../modules/mailings/contacts1.modules.php | 4 ++ .../mailings/eventorganization.modules.php | 20 ++++-- .../core/modules/mailings/fraise.modules.php | 7 +- .../modules/mailings/partnership.modules.php | 29 ++++++-- .../core/modules/mailings/pomme.modules.php | 25 +++++-- .../modules/mailings/thirdparties.modules.php | 23 ++++++- .../thirdparties_services_expired.modules.php | 22 ++++++- .../task/doc/doc_generic_task_odt.modules.php | 4 +- 13 files changed, 140 insertions(+), 102 deletions(-) diff --git a/.github/workflows/phpstan_baseline.yml b/.github/workflows/phpstan_baseline.yml index 54791225558d1..1ad3a0b49f728 100644 --- a/.github/workflows/phpstan_baseline.yml +++ b/.github/workflows/phpstan_baseline.yml @@ -1,9 +1,9 @@ -name: 'PHPStan' +name: 'PHPStan baseline' on: - # Every Monday we want to refresh the baseline + # Every Thursday we want to refresh the baseline schedule: - - cron: '0 6 * * 1' + - cron: '0 6 * * 4' # We want to be able to manually refresh the baseline too workflow_dispatch: @@ -61,6 +61,7 @@ jobs: commit_message: PHPStan > Update baseline target_branch: develop pr_create: ${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'schedule') && 1 || 0 }} + # pr_create: 1 pr_title: PHPStan > Update baseline pr_reviewer: eldy pr_body: | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 01430ba721293..e6953f0457828 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: - id: end-of-file-fixer # Check that there are no completely merged file conflicts - id: check-merge-conflict - stages: [commit, pre-rebase, pre-commit, pre-merge-commit] + stages: [pre-rebase, pre-commit, pre-merge-commit] # Check that files with shebangs have the executable bit set (in git) - id: check-executables-have-shebangs # Check that shell files are executables @@ -252,7 +252,7 @@ repos: rev: 3.1.0 hooks: - id: sqlfluff-lint - stages: [commit, manual] # manual needed for ci + stages: [pre-commit, manual] # manual needed for ci exclude: (?x)^ (dev/initdemo/mysqldump_.*\.sql |htdocs/core/menus/init_menu_auguria\.sql diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index ad46ed29a8056..e198622d68597 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -15450,18 +15450,6 @@ parameters: count: 1 path: ../../htdocs/core/modules/import/import_xlsx.modules.php - - - message: '#^Property mailing_advthirdparties\:\:\$require_admin has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../htdocs/core/modules/mailings/advthirdparties.modules.php - - - - message: '#^Property mailing_advthirdparties\:\:\$require_module has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../htdocs/core/modules/mailings/advthirdparties.modules.php - - message: '#^Property mailing_contacts1\:\:\$require_admin has no type specified\.$#' identifier: missingType.property @@ -15522,60 +15510,6 @@ parameters: count: 1 path: ../../htdocs/core/modules/mailings/modules_mailings.php - - - message: '#^Property mailing_partnership\:\:\$require_admin has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../htdocs/core/modules/mailings/partnership.modules.php - - - - message: '#^Property mailing_partnership\:\:\$require_module has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../htdocs/core/modules/mailings/partnership.modules.php - - - - message: '#^Property mailing_pomme\:\:\$require_admin has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../htdocs/core/modules/mailings/pomme.modules.php - - - - message: '#^Property mailing_pomme\:\:\$require_module has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../htdocs/core/modules/mailings/pomme.modules.php - - - - message: '#^Property mailing_thirdparties\:\:\$require_admin has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../htdocs/core/modules/mailings/thirdparties.modules.php - - - - message: '#^Property mailing_thirdparties\:\:\$require_module has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../htdocs/core/modules/mailings/thirdparties.modules.php - - - - message: '#^Property mailing_thirdparties_services_expired\:\:\$arrayofproducts has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../htdocs/core/modules/mailings/thirdparties_services_expired.modules.php - - - - message: '#^Property mailing_thirdparties_services_expired\:\:\$require_admin has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../htdocs/core/modules/mailings/thirdparties_services_expired.modules.php - - - - message: '#^Property mailing_thirdparties_services_expired\:\:\$require_module has no type specified\.$#' - identifier: missingType.property - count: 1 - path: ../../htdocs/core/modules/mailings/thirdparties_services_expired.modules.php - - message: '#^Property mailing_xinputfile\:\:\$require_admin has no type specified\.$#' identifier: missingType.property diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cc406277aefae..e8a2c0986ff4c 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -571,19 +571,19 @@ abstract class CommonObject public $fk_account; /** - * @var string Public note + * @var ?string Public note * @see update_note() */ public $note_public; /** - * @var string Private note + * @var ?string Private note * @see update_note() */ public $note_private; /** - * @var string + * @var ?string * @deprecated Use $note_private instead. * @see $note_private */ diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index e7903ba6b36f3..8844c96a874f2 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -1,7 +1,8 @@ - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2024 MDW +/* Copyright (C) 2005-2010 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This file is an example to follow to add your own email selector inside * the Dolibarr email tool. @@ -26,11 +27,24 @@ */ class mailing_advthirdparties extends MailingTargets { + /** + * @var string name of mailing module + */ public $name = 'ThirdPartyAdvancedTargeting'; - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + + /** + * @var string This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + */ public $desc = "Third parties"; + + /** + * @var int + */ public $require_admin = 0; + /** + * @var string[] + */ public $require_module = array("none"); // This module should not be displayed as Selector in mailing /** @@ -38,6 +52,9 @@ class mailing_advthirdparties extends MailingTargets */ public $picto = 'company'; + /** + * @var string condition to enable module + */ public $enabled = 'isModEnabled("societe")'; diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 00229230540c5..e8eca88cf4fec 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2009 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,6 +40,9 @@ class mailing_contacts1 extends MailingTargets public $require_module = array("societe"); // Module mailing actif si modules require_module actifs public $require_admin = 0; // Module mailing actif pour user admin ou non + /** + * @var string condition to enable module + */ public $enabled = 'isModEnabled("societe")'; /** diff --git a/htdocs/core/modules/mailings/eventorganization.modules.php b/htdocs/core/modules/mailings/eventorganization.modules.php index 444b8e8402b69..528072d76e9de 100644 --- a/htdocs/core/modules/mailings/eventorganization.modules.php +++ b/htdocs/core/modules/mailings/eventorganization.modules.php @@ -1,8 +1,9 @@ - * Copyright (C) 2005-2010 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2024 MDW +/* Copyright (C) 2018-2018 Andre Schild + * Copyright (C) 2005-2010 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This file is an example to follow to add your own email selector inside * the Dolibarr email tool. @@ -31,15 +32,24 @@ class mailing_eventorganization extends MailingTargets public $name = 'AttendeesOfOrganizedEvent'; public $desc = "Attendees of an organized event"; + /** + * @var int + */ public $require_admin = 0; - public $require_module = array(); // This module allows to select by categories must be also enabled if category module is not activated + /** + * @var string[] This module allows to select by categories must be also enabled if category module is not activated + */ + public $require_module = array(); /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png */ public $picto = 'conferenceorbooth'; + /** + * @var string condition to enable module + */ public $enabled = 'isModEnabled("eventorganization")'; diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index f8e72582e53f0..a551cebab4934 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -1,8 +1,8 @@ * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2018-2023 Frédéric France - * Copyright (C) 2024 MDW + * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2024 MDW * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -42,6 +42,9 @@ class mailing_fraise extends MailingTargets public $require_module = array('adherent'); + /** + * @var string condition to enable module + */ public $enabled = 'isModEnabled("member")'; /** diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php index 0835fc313bdd5..cbfe9ec60a184 100644 --- a/htdocs/core/modules/mailings/partnership.modules.php +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -1,8 +1,9 @@ - * Copyright (C) 2005-2010 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2024 MDW +/* Copyright (C) 2018-2018 Andre Schild + * Copyright (C) 2005-2010 Laurent Destailleur + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This file is an example to follow to add your own email selector inside * the Dolibarr email tool. @@ -27,12 +28,25 @@ */ class mailing_partnership extends MailingTargets { - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + /** + * @var string name of mailing module + */ public $name = 'PartnershipThirdpartiesOrMembers'; + + /** + * @var string This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + */ public $desc = "Thirdparties or members included into a partnership program"; + /** + * @var int + */ public $require_admin = 0; + /** + * @var string[] + * + */ public $require_module = array('partnership'); // This module allows to select by categories must be also enabled if category module is not activated /** @@ -40,6 +54,9 @@ class mailing_partnership extends MailingTargets */ public $picto = 'partnership'; + /** + * @var string condition to enable module + */ public $enabled = 'isModEnabled("partnership")'; @@ -50,7 +67,7 @@ class mailing_partnership extends MailingTargets */ public function __construct($db) { - global $conf, $langs; + global $langs; $langs->load('companies'); $this->db = $db; diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index eecf24118870e..7597b2c2ce30a 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -31,11 +32,25 @@ */ class mailing_pomme extends MailingTargets { - public $name = 'DolibarrUsers'; // Identifiant du module mailing - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found - public $desc = 'Dolibarr users with emails'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouv�e - public $require_module = array(); // Module mailing actif si modules require_module actifs - public $require_admin = 1; // Module mailing actif pour user admin ou non + /** + * @var string name of mailing module + */ + public $name = 'DolibarrUsers'; + + /** + * @var string This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + */ + public $desc = 'Dolibarr users with emails'; // Libelle utilise si aucune traduction pour MailingModuleDescXXX ou XXX=name trouvée + + /** + * @var string[] Module mailing actif si modules require_module actifs + */ + public $require_module = array(); + + /** + * @var int Module mailing actif pour user admin ou non + */ + public $require_admin = 1; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index 51328c6862001..583d0aec20601 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -3,6 +3,7 @@ * Copyright (C) 2005-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This file is an example to follow to add your own email selector inside * the Dolibarr email tool. @@ -25,13 +26,29 @@ */ class mailing_thirdparties extends MailingTargets { + /** + * @var string name of mailing module + */ public $name = 'ThirdPartiesByCategories'; - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + + /** + * @var string This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + */ public $desc = "Third parties (by categories)"; + + /** + * @var int + */ public $require_admin = 0; - public $require_module = array("societe"); // This module allows to select by categories must be also enabled if category module is not activated + /** + * @var string[] This module allows to select by categories must be also enabled if category module is not activated + */ + public $require_module = array("societe"); + /** + * @var string condition to enable module + */ public $enabled = 'isModEnabled("societe")'; /** @@ -47,7 +64,7 @@ class mailing_thirdparties extends MailingTargets */ public function __construct($db) { - global $conf, $langs; + global $langs; $langs->load("companies"); $this->db = $db; diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 4a76510e55c1e..32154603dad5d 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -1,6 +1,7 @@ * Copyright (C) 2024 MDW + * Copyright (C) 2024 Frédéric France * * This file is an example to follow to add your own email selector inside * the Dolibarr email tool. @@ -23,13 +24,29 @@ */ class mailing_thirdparties_services_expired extends MailingTargets { + /** + * @var string name of mailing module + */ public $name = 'DolibarrContractsLinesExpired'; - // This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + + /** + * @var string This label is used if no translation is found for key XXX neither MailingModuleDescXXX where XXX=name is found + */ public $desc = 'Third parties with expired contract\'s lines'; + + /** + * @var int + */ public $require_admin = 0; + /** + * @var string[] This module allows to select by categories must be also enabled if category module is not activated + */ public $require_module = array('contrat'); + /** + * @var string condition to enable module + */ public $enabled = 'isModEnabled("societe")'; /** @@ -37,6 +54,9 @@ class mailing_thirdparties_services_expired extends MailingTargets */ public $picto = 'company'; + /** + * @var array + */ public $arrayofproducts = array(); diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index aeb0576cc6fdf..a20c933500a73 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -208,8 +208,8 @@ public function get_substitutionarray_tasks($task, $outputlangs, $array_key = 't 'task_public' => $task->public, 'task_date_start' => dol_print_date($task->date_start, 'day'), 'task_date_end' => dol_print_date($task->date_end, 'day'), - 'task_note_private' => $task->note_private, - 'task_note_public' => $task->note_public + 'task_note_private' => (string) $task->note_private, + 'task_note_public' => (string) $task->note_public ); // Retrieve extrafields