From 75400611e1d3d7415e26a3d2163c55e9f5e91d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 21 Nov 2024 22:36:00 +0100 Subject: [PATCH] fix phpstan (#32040) * fix phpstan * fix * fix * fix * fix * fix * fix --- build/phpstan/phpstan-baseline.neon | 300 +--------------------- htdocs/adherents/class/adherent.class.php | 4 +- htdocs/adherents/subscription.php | 2 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/class/commonpeople.class.php | 32 ++- htdocs/core/lib/project.lib.php | 10 +- htdocs/societe/class/societe.class.php | 15 +- 7 files changed, 36 insertions(+), 329 deletions(-) diff --git a/build/phpstan/phpstan-baseline.neon b/build/phpstan/phpstan-baseline.neon index f08d62540be8b..9b055ffc31c7f 100644 --- a/build/phpstan/phpstan-baseline.neon +++ b/build/phpstan/phpstan-baseline.neon @@ -972,12 +972,6 @@ parameters: count: 2 path: ../../htdocs/adherents/class/adherent.class.php - - - message: '#^Call to function is_array\(\) with array\{\}\|array\{mixed\} will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../htdocs/adherents/class/adherent.class.php - - message: '#^Call to function method_exists\(\) with \$this\(Adherent\) and ''getLibStatut'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -1014,36 +1008,12 @@ parameters: count: 5 path: ../../htdocs/adherents/class/adherent.class.php - - - message: '#^PHPDoc tag @var with type Contact is not subtype of native type \$this\(Adherent\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/adherents/class/adherent.class.php - - - - message: '#^PHPDoc tag @var with type Societe is not subtype of native type \$this\(Adherent\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/adherents/class/adherent.class.php - - - - message: '#^PHPDoc tag @var with type User is not subtype of native type \$this\(Adherent\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/adherents/class/adherent.class.php - - message: '#^Parameter \#1 \$substitutionarray of function complete_substitutions_array expects array\, array\ given\.$#' identifier: argument.type count: 1 path: ../../htdocs/adherents/class/adherent.class.php - - - message: '#^Property Adherent\:\:\$email \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../htdocs/adherents/class/adherent.class.php - - message: '#^Property Adherent\:\:\$first_subscription_amount \(int\|string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -1056,16 +1026,10 @@ parameters: count: 1 path: ../../htdocs/adherents/class/adherent.class.php - - - message: '#^Property Adherent\:\:\$societe \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../htdocs/adherents/class/adherent.class.php - - message: '#^Ternary operator condition is always false\.$#' identifier: ternary.alwaysFalse - count: 2 + count: 1 path: ../../htdocs/adherents/class/adherent.class.php - @@ -5280,12 +5244,6 @@ parameters: count: 2 path: ../../htdocs/compta/bank/bankentries_list.php - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 2 - path: ../../htdocs/compta/bank/bankentries_list.php - - message: '#^Left side of && is always true\.$#' identifier: booleanAnd.leftAlwaysTrue @@ -5568,12 +5526,6 @@ parameters: count: 3 path: ../../htdocs/compta/bank/list.php - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 2 - path: ../../htdocs/compta/bank/releve.php - - message: '#^Variable \$buttonreconcile might not be defined\.$#' identifier: variable.undefined @@ -7860,12 +7812,6 @@ parameters: count: 1 path: ../../htdocs/contact/card.php - - - message: '#^Call to function is_array\(\) with array\{\}\|array\{mixed\} will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../htdocs/contact/class/contact.class.php - - message: '#^Call to function method_exists\(\) with \$this\(Contact\) and ''getLibStatut'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -7902,33 +7848,9 @@ parameters: count: 3 path: ../../htdocs/contact/class/contact.class.php - - - message: '#^PHPDoc tag @var with type Contact is not subtype of native type \$this\(Contact\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/contact/class/contact.class.php - - - - message: '#^PHPDoc tag @var with type Societe is not subtype of native type \$this\(Contact\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/contact/class/contact.class.php - - - - message: '#^PHPDoc tag @var with type User is not subtype of native type \$this\(Contact\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/contact/class/contact.class.php - - message: '#^Property CommonObject\:\:\$entity \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property - count: 2 - path: ../../htdocs/contact/class/contact.class.php - - - - message: '#^Property Contact\:\:\$email \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property count: 1 path: ../../htdocs/contact/class/contact.class.php @@ -7944,12 +7866,6 @@ parameters: count: 1 path: ../../htdocs/contact/class/contact.class.php - - - message: '#^Ternary operator condition is always false\.$#' - identifier: ternary.alwaysFalse - count: 1 - path: ../../htdocs/contact/class/contact.class.php - - message: '#^Variable \$url in empty\(\) always exists and is not falsy\.$#' identifier: empty.variable @@ -12324,24 +12240,6 @@ parameters: count: 1 path: ../../htdocs/core/lib/project.lib.php - - - message: '#^Parameter \#1 \$inc of function projectLinesPerDay expects string, \(float\|int\) given\.$#' - identifier: argument.type - count: 1 - path: ../../htdocs/core/lib/project.lib.php - - - - message: '#^Parameter \#1 \$inc of function projectLinesPerMonth expects string, \(float\|int\) given\.$#' - identifier: argument.type - count: 1 - path: ../../htdocs/core/lib/project.lib.php - - - - message: '#^Parameter \#1 \$inc of function projectLinesPerWeek expects string, \(float\|int\) given\.$#' - identifier: argument.type - count: 1 - path: ../../htdocs/core/lib/project.lib.php - - message: '#^Property Task\:\:\$progress \(int\|string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -17970,12 +17868,6 @@ parameters: count: 2 path: ../../htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php - - - message: '#^Negated boolean expression is always false\.$#' - identifier: booleanNot.alwaysFalse - count: 2 - path: ../../htdocs/core/triggers/interface_50_modTicket_TicketEmail.class.php - - message: '#^Variable \$old_MAIN_MAIL_AUTOCOPY_TO might not be defined\.$#' identifier: variable.undefined @@ -18432,12 +18324,6 @@ parameters: count: 1 path: ../../htdocs/don/class/api_donations.class.php - - - message: '#^Call to function is_array\(\) with array\{\}\|array\{mixed\} will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../htdocs/don/class/don.class.php - - message: '#^Call to function method_exists\(\) with \$this\(Don\) and ''LibStatut'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -18474,42 +18360,12 @@ parameters: count: 1 path: ../../htdocs/don/class/don.class.php - - - message: '#^PHPDoc tag @var with type Contact is not subtype of native type \$this\(Don\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/don/class/don.class.php - - - - message: '#^PHPDoc tag @var with type Societe is not subtype of native type \$this\(Don\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/don/class/don.class.php - - - - message: '#^PHPDoc tag @var with type User is not subtype of native type \$this\(Don\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/don/class/don.class.php - - - - message: '#^Property Don\:\:\$email \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../htdocs/don/class/don.class.php - - message: '#^Property Don\:\:\$societe \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property count: 1 path: ../../htdocs/don/class/don.class.php - - - message: '#^Ternary operator condition is always false\.$#' - identifier: ternary.alwaysFalse - count: 1 - path: ../../htdocs/don/class/don.class.php - - message: '#^Negated boolean expression is always true\.$#' identifier: booleanNot.alwaysTrue @@ -19104,12 +18960,6 @@ parameters: count: 1 path: ../../htdocs/eventorganization/class/conferenceorboothattendee.class.php - - - message: '#^Property CommonObject\:\:\$name \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../htdocs/eventorganization/class/conferenceorboothattendee.class.php - - message: '#^Property ConferenceOrBoothAttendee\:\:\$lastname \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -28368,12 +28218,6 @@ parameters: count: 1 path: ../../htdocs/projet/activity/perday.php - - - message: '#^Parameter \#1 \$inc of function projectLinesPerDay expects string, int given\.$#' - identifier: argument.type - count: 1 - path: ../../htdocs/projet/activity/perday.php - - message: '#^Parameter \#11 \$isavailable of function projectLinesPerDay expects array\, afternoon\: int\<0, 1\>\}\>, non\-empty\-array\ given\.$#' identifier: argument.type @@ -28452,12 +28296,6 @@ parameters: count: 1 path: ../../htdocs/projet/activity/permonth.php - - - message: '#^Parameter \#1 \$inc of function projectLinesPerMonth expects string, int given\.$#' - identifier: argument.type - count: 1 - path: ../../htdocs/projet/activity/permonth.php - - message: '#^Parameter \#14 \$arrayfields of function projectLinesPerMonth expects array\, array\\> given\.$#' identifier: argument.type @@ -28512,12 +28350,6 @@ parameters: count: 1 path: ../../htdocs/projet/activity/perweek.php - - - message: '#^Parameter \#1 \$inc of function projectLinesPerWeek expects string, int given\.$#' - identifier: argument.type - count: 1 - path: ../../htdocs/projet/activity/perweek.php - - message: '#^Parameter \#11 \$isavailable of function projectLinesPerWeek expects array\, afternoon\: int\<0, 1\>\}\>, non\-empty\-array\ given\.$#' identifier: argument.type @@ -29184,12 +29016,6 @@ parameters: count: 1 path: ../../htdocs/projet/tasks.php - - - message: '#^Parameter \#1 \$inc of function projectLinesa expects string, int given\.$#' - identifier: argument.type - count: 1 - path: ../../htdocs/projet/tasks.php - - message: '#^Parameter \#13 \$arrayfields of function projectLinesa expects array\, array\\> given\.$#' identifier: argument.type @@ -31410,12 +31236,6 @@ parameters: count: 1 path: ../../htdocs/recruitment/class/recruitmentcandidature.class.php - - - message: '#^Call to function property_exists\(\) with \$this\(RecruitmentCandidature\) and ''phone'' will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../htdocs/recruitment/class/recruitmentcandidature.class.php - - message: '#^Call to function property_exists\(\) with RecruitmentCandidature and ''date_creation'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -31458,24 +31278,12 @@ parameters: count: 1 path: ../../htdocs/recruitment/class/recruitmentcandidature.class.php - - - message: '#^Property CommonObject\:\:\$name \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../htdocs/recruitment/class/recruitmentcandidature.class.php - - message: '#^Property RecruitmentCandidature\:\:\$fields \(array\\|string, position\: int, notnull\?\: int, visible\: int\<\-2, 5\>\|string, noteditable\?\: int\<0, 1\>, default\?\: string, \.\.\.\}\>\) does not accept default value of type array\{rowid\: array\{type\: ''integer'', label\: ''TechnicalID'', enabled\: 1, position\: 1, notnull\: 1, visible\: 0, noteditable\: 1, index\: 1, \.\.\.\}, entity\: array\{type\: ''integer'', label\: ''Entity'', enabled\: 1, visible\: 0, position\: 5, notnull\: 1, default\: ''1'', index\: 1\}, ref\: array\{type\: ''varchar\(128\)'', label\: ''Ref'', enabled\: 1, position\: 10, notnull\: 1, visible\: 4, noteditable\: 1, default\: ''\(PROV\)'', \.\.\.\}, fk_recruitmentjobposition\: array\{type\: ''integer…'', label\: ''Job'', enabled\: 1, position\: 15, notnull\: 0, visible\: 1, index\: 1, picto\: ''recruitmentjobposit…'', \.\.\.\}, note_public\: array\{type\: ''html'', label\: ''NotePublic'', enabled\: 1, position\: 61, notnull\: 0, visible\: 0\}, note_private\: array\{type\: ''html'', label\: ''NotePrivate'', enabled\: 1, position\: 62, notnull\: 0, visible\: 0\}, fk_user_creat\: array\{type\: ''integer\:User\:user…'', label\: ''UserAuthor'', enabled\: 1, position\: 510, notnull\: \-1, visible\: \-2, foreignkey\: ''user\.rowid'', csslist\: ''tdoverflowmax100''\}, fk_user_modif\: array\{type\: ''integer\:User\:user…'', label\: ''UserModif'', enabled\: 1, position\: 511, notnull\: \-1, visible\: \-2, csslist\: ''tdoverflowmax100''\}, \.\.\.\}\.$#' identifier: property.defaultValue count: 1 path: ../../htdocs/recruitment/class/recruitmentcandidature.class.php - - - message: '#^Property RecruitmentCandidature\:\:\$lastname \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../htdocs/recruitment/class/recruitmentcandidature.class.php - - message: '#^Property RecruitmentCandidature\:\:\$status \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -31830,30 +31638,6 @@ parameters: count: 1 path: ../../htdocs/resource/card.php - - - message: '#^Call to function is_array\(\) with array\{\}\|array\{mixed\} will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../htdocs/resource/class/dolresource.class.php - - - - message: '#^PHPDoc tag @var with type Contact is not subtype of native type \$this\(Dolresource\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/resource/class/dolresource.class.php - - - - message: '#^PHPDoc tag @var with type Societe is not subtype of native type \$this\(Dolresource\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/resource/class/dolresource.class.php - - - - message: '#^PHPDoc tag @var with type User is not subtype of native type \$this\(Dolresource\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/resource/class/dolresource.class.php - - message: '#^Property CommonObject\:\:\$ref \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -31893,7 +31677,7 @@ parameters: - message: '#^Property Dolresource\:\:\$email \(string\) in isset\(\) is not nullable\.$#' identifier: isset.property - count: 3 + count: 2 path: ../../htdocs/resource/class/dolresource.class.php - @@ -31938,12 +31722,6 @@ parameters: count: 2 path: ../../htdocs/resource/class/dolresource.class.php - - - message: '#^Ternary operator condition is always false\.$#' - identifier: ternary.alwaysFalse - count: 1 - path: ../../htdocs/resource/class/dolresource.class.php - - message: '#^Call to function is_numeric\(\) with float\|int\\|int\<1, max\>\|\(non\-falsy\-string&numeric\-string\) will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -32718,12 +32496,6 @@ parameters: count: 2 path: ../../htdocs/societe/class/companybankaccount.class.php - - - message: '#^Call to function is_array\(\) with array\{\}\|array\{mixed\} will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../htdocs/societe/class/societe.class.php - - message: '#^Call to function method_exists\(\) with \$this\(Societe\) and ''getLibStatut'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -32760,24 +32532,6 @@ parameters: count: 6 path: ../../htdocs/societe/class/societe.class.php - - - message: '#^PHPDoc tag @var with type Contact is not subtype of native type \$this\(Societe\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/societe/class/societe.class.php - - - - message: '#^PHPDoc tag @var with type Societe is not subtype of native type \$this\(Societe\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/societe/class/societe.class.php - - - - message: '#^PHPDoc tag @var with type User is not subtype of native type \$this\(Societe\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/societe/class/societe.class.php - - message: '#^Property Contact\:\:\$roles \(array\\) does not accept non\-empty\-list\\.$#' identifier: assign.propertyType @@ -32796,16 +32550,10 @@ parameters: count: 1 path: ../../htdocs/societe/class/societe.class.php - - - message: '#^Property Societe\:\:\$email \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../htdocs/societe/class/societe.class.php - - message: '#^Property Societe\:\:\$entity \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property - count: 3 + count: 2 path: ../../htdocs/societe/class/societe.class.php - @@ -32844,12 +32592,6 @@ parameters: count: 1 path: ../../htdocs/societe/class/societe.class.php - - - message: '#^Ternary operator condition is always false\.$#' - identifier: ternary.alwaysFalse - count: 1 - path: ../../htdocs/societe/class/societe.class.php - - message: '#^Property SocieteAccount\:\:\$fields \(array\\|string, position\: int, notnull\?\: int, visible\: int\<\-2, 5\>\|string, noteditable\?\: int\<0, 1\>, default\?\: string, \.\.\.\}\>\) does not accept default value of type array\{rowid\: array\{type\: ''integer'', label\: ''TechnicalID'', visible\: \-2, enabled\: 1, position\: 1, notnull\: 1, index\: 1, comment\: ''Id''\}, entity\: array\{type\: ''integer'', label\: ''Entity'', visible\: 0, enabled\: 1, position\: 5, default\: 1\}, login\: array\{type\: ''varchar\(64\)'', label\: ''Login'', visible\: 1, enabled\: 1, notnull\: 1, position\: 10, showoncombobox\: 1, autofocusoncreate\: 1\}, pass_encoding\: array\{type\: ''varchar\(24\)'', label\: ''PassEncoding'', visible\: 0, enabled\: 1, position\: 30\}, pass_crypted\: array\{type\: ''password'', label\: ''Password'', visible\: \-1, enabled\: 1, position\: 31, notnull\: 1\}, pass_temp\: array\{type\: ''varchar\(128\)'', label\: ''Temp'', visible\: 0, enabled\: 0, position\: 32, notnull\: \-1\}, fk_soc\: array\{type\: ''integer\:Societe…'', label\: ''ThirdParty'', visible\: 1, enabled\: 1, position\: 40, notnull\: \-1, index\: 1, picto\: ''company'', \.\.\.\}, site\: array\{type\: ''varchar\(128\)'', label\: ''WebsiteTypeLabel'', visible\: 0, enabled\: 0, position\: 41, notnull\: 1, default\: '''', help\: ''Name of the website…'', \.\.\.\}, \.\.\.\}\.$#' identifier: property.defaultValue @@ -34512,12 +34254,6 @@ parameters: count: 1 path: ../../htdocs/user/class/api_users.class.php - - - message: '#^Call to function is_array\(\) with array\{\}\|array\{mixed\} will always evaluate to true\.$#' - identifier: function.alreadyNarrowedType - count: 1 - path: ../../htdocs/user/class/user.class.php - - message: '#^Call to function method_exists\(\) with \$this\(User\) and ''getLibStatut'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -34542,36 +34278,12 @@ parameters: count: 3 path: ../../htdocs/user/class/user.class.php - - - message: '#^PHPDoc tag @var with type Contact is not subtype of native type \$this\(User\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/user/class/user.class.php - - - - message: '#^PHPDoc tag @var with type Societe is not subtype of native type \$this\(User\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/user/class/user.class.php - - - - message: '#^PHPDoc tag @var with type User is not subtype of native type \$this\(User\)\.$#' - identifier: varTag.nativeType - count: 1 - path: ../../htdocs/user/class/user.class.php - - message: '#^Parameter \#1 \$array of function dol_sort_array contains unresolvable type\.$#' identifier: argument.unresolvableType count: 1 path: ../../htdocs/user/class/user.class.php - - - message: '#^Property User\:\:\$email \(string\) in isset\(\) is not nullable\.$#' - identifier: isset.property - count: 1 - path: ../../htdocs/user/class/user.class.php - - message: '#^Property User\:\:\$entity \(int\) in isset\(\) is not nullable\.$#' identifier: isset.property @@ -34638,12 +34350,6 @@ parameters: count: 1 path: ../../htdocs/user/class/user.class.php - - - message: '#^Ternary operator condition is always false\.$#' - identifier: ternary.alwaysFalse - count: 1 - path: ../../htdocs/user/class/user.class.php - - message: '#^Variable \$whereforadd in empty\(\) always exists and is not falsy\.$#' identifier: empty.variable diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index 452bd835d11ce..e2353b82af68a 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -112,14 +112,14 @@ class Adherent extends CommonObject public $civility; /** - * @var string company name + * @var ?string company name * @deprecated Use $company * @see $company */ public $societe; /** - * @var string company name + * @var ?string company name */ public $company; diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 0f882fb1d5356..3b7b80d6935cf 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -638,7 +638,7 @@ print ''; print ''; } else { - if ($object->socid > O) { + if ($object->socid > 0) { $company = new Societe($db); $result = $company->fetch($object->socid); print $company->getNomUrl(1); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 37a0c324dfba2..71cc203b2d899 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -637,7 +637,7 @@ abstract class CommonObject public $comments = array(); /** - * @var string The name + * @var ?string The name */ public $name; diff --git a/htdocs/core/class/commonpeople.class.php b/htdocs/core/class/commonpeople.class.php index 8bd31082ba7bb..dae9ff582bc57 100644 --- a/htdocs/core/class/commonpeople.class.php +++ b/htdocs/core/class/commonpeople.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2024 MDW +/* Copyright (C) 2023-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 @@ -152,9 +152,9 @@ public function getCivilityLabel() /** * Return full address for banner * - * @param string $htmlkey HTML id to make banner content unique - * @param Object $object Object (thirdparty, thirdparty of contact for contact, null for a member) - * @return string Full address string + * @param string $htmlkey HTML id to make banner content unique + * @param CommonObject $object Object (thirdparty, thirdparty of contact for contact, null for a member) + * @return string Full address string */ public function getBannerAddress($htmlkey, $object) { @@ -165,20 +165,24 @@ public function getBannerAddress($htmlkey, $object) $contactid = 0; $thirdpartyid = 0; $elementforaltlanguage = $this->element; - if ($this->element == 'societe') { - /** @var Societe $this */ + if ($this->element == 'societe' && $this instanceof Societe) { $thirdpartyid = $this->id; } - if ($this->element == 'contact') { - /** @var Contact $this */ + if ($this->element == 'contact' && $this instanceof Contact) { $contactid = $this->id; $thirdpartyid = empty($this->fk_soc) ? 0 : $this->fk_soc; } - if ($this->element == 'user') { - /** @var User $this */ + if ($this->element == 'member' && $this instanceof Adherent) { + $contactid = $this->id; + $thirdpartyid = empty($this->socid) ? 0 : $this->socid; + } + if ($this->element == 'user' && $this instanceof User) { $contactid = $this->contact_id; $thirdpartyid = empty($object->fk_soc) ? 0 : $object->fk_soc; } + if ($this->element == 'recruitmentcandidature' && $this instanceof RecruitmentCandidature) { + $thirdpartyid = 0; + } $out = ''; @@ -210,7 +214,7 @@ public function getBannerAddress($htmlkey, $object) $arrayoflangcode[] = getDolGlobalString('PDF_USE_ALSO_LANGUAGE_CODE'); } - if (is_array($arrayoflangcode) && count($arrayoflangcode)) { + if (/* is_array($arrayoflangcode) && */count($arrayoflangcode)) { if (!is_object($extralanguages)) { include_once DOL_DOCUMENT_ROOT.'/core/class/extralanguages.class.php'; $extralanguages = new ExtraLanguages($this->db); @@ -258,7 +262,7 @@ public function getBannerAddress($htmlkey, $object) // Phones $outphonedone = 0; if (!empty($this->phone) && empty($this->phone_pro)) { // For objects that store pro phone into ->phone - $out .= ($outphonedone ? ' ' : ''); + // $out .= ($outphonedone ? ' ' : ''); $out .= dol_print_phone($this->phone, $this->country_code, $contactid, $thirdpartyid, 'AC_TEL', ' ', 'phone', $langs->trans("PhonePro")); $outdone++; $outphonedone++; @@ -387,7 +391,7 @@ public function setUpperOrLowerCase() $this->address = dol_strtoupper($this->address); $this->town = dol_strtoupper($this->town); } - if (isset($this->email)) { + if (!empty($this->email)) { $this->email = dol_strtolower($this->email); } if (isset($this->personal_email)) { diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 95566b86a531e..2383a86619fc9 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -581,7 +581,7 @@ function project_admin_prepare_head() /** * Show task lines with a particular parent * - * @param string $inc Line number (start to 0, then increased by recursive call) + * @param int $inc Line number (start to 0, then increased by recursive call) * @param int $parent Id of parent task to show (0 to show all) * @param Task[] $lines Array of lines * @param int $level Level (start to 0, then increased/decrease by recursive call), or -1 to show all level in order of $lines without the recursive groupment feature. @@ -1168,7 +1168,7 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t /** * Output a task line into a pertime input mode * - * @param string $inc Line number (start to 0, then increased by recursive call) + * @param int $inc Line number (start to 0, then increased by recursive call) * @param int $parent Id of parent task to show (0 to show all) * @param ?User $fuser Restrict list to user if defined * @param Task[] $lines Array of lines @@ -1398,7 +1398,7 @@ function projectLinesPerAction(&$inc, $parent, $fuser, $lines, &$level, &$projec /** * Output a task line into a pertime input mode * - * @param string $inc Line number (start to 0, then increased by recursive call) + * @param int $inc Line number (start to 0, then increased by recursive call) * @param int $parent Id of parent task to show (0 to show all) * @param ?User $fuser Restrict list to user if defined * @param Task[] $lines Array of lines @@ -1801,7 +1801,7 @@ function projectLinesPerDay(&$inc, $parent, $fuser, $lines, &$level, &$projectsr /** * Output a task line into a perday input mode * - * @param string $inc Line output identificator (start to 0, then increased by recursive call) + * @param int $inc Line output identificator (start to 0, then increased by recursive call) * @param int $firstdaytoshow First day to show * @param ?User $fuser Restrict list to user if defined * @param int $parent Id of parent task to show (0 to show all) @@ -2207,7 +2207,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$ /** * Output a task line into a perday input mode * - * @param string $inc Line output identificator (start to 0, then increased by recursive call) + * @param int $inc Line output identificator (start to 0, then increased by recursive call) * @param int $firstdaytoshow First day to show * @param User|null $fuser Restrict list to user if defined * @param int $parent Id of parent task to show (0 to show all) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 35b5d930548c4..b3922c073120f 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -273,14 +273,14 @@ class Societe extends CommonObject /** * Thirdparty name - * @var string + * @var ?string * @deprecated Use $name instead * @see $name */ public $nom; /** - * @var string Thirdparty name + * @var ?string Thirdparty name */ public $name; @@ -1212,14 +1212,13 @@ public function create_individual(User $user, $no_email = 0, $tags = array(), $n $this->setUpperOrLowerCase(); $contact->phone_pro = $this->phone; if (getDolGlobalString('CONTACTS_DEFAULT_ROLES')) { - $contact->roles = explode(',', getDolGlobalString('CONTACTS_DEFAULT_ROLES')); + $contact->roles = explode(',', getDolGlobalString('CONTACTS_DEFAULT_ROLES')); } $contactId = $contact->create($user, $notrigger); if ($contactId < 0) { $error++; - $this->error = $contact->error; - $this->errors = $contact->errors; + $this->setErrorsFromObject($contact); dol_syslog(get_class($this)."::create_individual ERROR:".$this->error, LOG_ERR); } @@ -1227,8 +1226,7 @@ public function create_individual(User $user, $no_email = 0, $tags = array(), $n $result = $contact->setCategories($tags); if ($result < 0) { $error++; - $this->error = $contact->error; - $this->errors = array_merge($this->errors, $contact->errors); + $this->setErrorsFromObject($contact); dol_syslog(get_class($this)."::create_individual Affect Tag ERROR:".$this->error, LOG_ERR); $contactId = $result; } @@ -1237,8 +1235,7 @@ public function create_individual(User $user, $no_email = 0, $tags = array(), $n if (empty($error) && isModEnabled('mailing') && !empty($contact->email) && isset($no_email)) { $result = $contact->setNoEmail($no_email); if ($result < 0) { - $this->error = $contact->error; - $this->errors = array_merge($this->errors, $contact->errors); + $this->setErrorsFromObject($contact); dol_syslog(get_class($this)."::create_individual set mailing status ERROR:".$this->error, LOG_ERR); $contactId = $result; }