Skip to content

Commit

Permalink
Merge pull request #32075 from frederic34/phpstan_fix_20241123
Browse files Browse the repository at this point in the history
fix phpstan
  • Loading branch information
eldy authored Dec 24, 2024
2 parents 1aa8b04 + fc22db1 commit ac08dc3
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 86 deletions.
42 changes: 0 additions & 42 deletions build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -948,12 +948,6 @@ parameters:
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
count: 1
path: ../../htdocs/adherents/class/adherent.class.php

-
message: '#^Property Adherent\:\:\$last_subscription_amount \(int\|string\) in isset\(\) is not nullable\.$#'
identifier: isset.property
Expand Down Expand Up @@ -1104,12 +1098,6 @@ parameters:
count: 1
path: ../../htdocs/adherents/messaging.php

-
message: '#^Variable \$socid might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/adherents/messaging.php

-
message: '#^Property Partnership\:\:\$entity \(int\) in isset\(\) is not nullable\.$#'
identifier: isset.property
Expand All @@ -1122,42 +1110,12 @@ parameters:
count: 1
path: ../../htdocs/adherents/partnership.php

-
message: '#^Negated boolean expression is always true\.$#'
identifier: booleanNot.alwaysTrue
count: 1
path: ../../htdocs/adherents/subscription.php

-
message: '#^Variable \$bankline in empty\(\) always exists and is not falsy\.$#'
identifier: empty.variable
count: 1
path: ../../htdocs/adherents/subscription/card.php

-
message: '#^Empty array passed to foreach\.$#'
identifier: foreach.emptyArray
count: 1
path: ../../htdocs/adherents/subscription/list.php

-
message: '#^If condition is always false\.$#'
identifier: if.alwaysFalse
count: 2
path: ../../htdocs/adherents/subscription/list.php

-
message: '#^Result of && is always false\.$#'
identifier: booleanAnd.alwaysFalse
count: 1
path: ../../htdocs/adherents/subscription/list.php

-
message: '#^Right side of && is always false\.$#'
identifier: booleanAnd.rightAlwaysFalse
count: 1
path: ../../htdocs/adherents/subscription/list.php

-
message: '#^Variable \$object might not be defined\.$#'
identifier: variable.undefined
Expand Down
16 changes: 8 additions & 8 deletions htdocs/adherents/class/adherent.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,12 @@ class Adherent extends CommonObject
public $need_subscription;

/**
* @var int user_id
* @var int|null user_id
*/
public $user_id;

/**
* @var string user_login
* @var string|null user_login
*/
public $user_login;

Expand All @@ -254,32 +254,32 @@ class Adherent extends CommonObject
// Fields loaded by fetch_subscriptions() from member table

/**
* @var int|string date
* @var int|string|null date
*/
public $first_subscription_date;

/**
* @var int|string date
* @var int|string|null date
*/
public $first_subscription_date_start;

/**
* @var int|string date
* @var int|string|null date
*/
public $first_subscription_date_end;

/**
* @var int|string date
* @var int|string|null date
*/
public $first_subscription_amount;

/**
* @var int|string date
* @var int|string|null date
*/
public $last_subscription_date;

/**
* @var int|string date
* @var int|string|null date
*/
public $last_subscription_date_start;

Expand Down
8 changes: 4 additions & 4 deletions htdocs/adherents/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@
$massaction = '';
}

$permissiontoread = ($user->hasRight('adherent', 'lire') == 1);
$permissiontodelete = ($user->hasRight('adherent', 'supprimer') == 1);
$permissiontoadd = ($user->hasRight('adherent', 'creer') == 1);
$uploaddir = $conf->adherent->dir_output;
$permissiontoread = $user->hasRight('adherent', 'lire');
$permissiontodelete = $user->hasRight('adherent', 'supprimer');
$permissiontoadd = $user->hasRight('adherent', 'creer');
$uploaddir = $conf->member->dir_output;
$error = 0;

$parameters = array('socid' => isset($socid) ? $socid : null, 'arrayfields' => &$arrayfields);
Expand Down
5 changes: 4 additions & 1 deletion htdocs/adherents/messaging.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,10 @@
if (!$sortorder) {
$sortorder = 'DESC,DESC';
}

$socid = GETPOSTINT('socid');
if ($user->socid > 0) {
$socid = $user->socid;
}
// Initialize a technical object to manage hooks of page. Note that conf->hooks_modules contains an array of hook context
$hookmanager->initHooks(array('agendathirdparty', 'globalcard'));

Expand Down
44 changes: 21 additions & 23 deletions htdocs/adherents/subscription.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,35 +179,33 @@

if (empty($reshook) && $action == 'setsocid' && $permissiontoaddmember) {
$error = 0;
if (!$error) {
if (GETPOSTINT('socid') != $object->socid) { // If link differs from currently in database
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
$sql .= " WHERE fk_soc = ".((int) GETPOSTINT('socid'));
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj && $obj->rowid > 0) {
$othermember = new Adherent($db);
$othermember->fetch($obj->rowid);
$thirdparty = new Societe($db);
$thirdparty->fetch(GETPOSTINT('socid'));
$error++;
setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors');
}
if (GETPOSTINT('socid') != $object->socid) { // If link differs from currently in database
$sql = "SELECT rowid FROM " . MAIN_DB_PREFIX . "adherent";
$sql .= " WHERE fk_soc = " . ((int) GETPOSTINT('socid'));
$resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
if ($obj && $obj->rowid > 0) {
$othermember = new Adherent($db);
$othermember->fetch($obj->rowid);
$thirdparty = new Societe($db);
$thirdparty->fetch(GETPOSTINT('socid'));
$error++;
setEventMessages($langs->trans("ErrorMemberIsAlreadyLinkedToThisThirdParty", $othermember->getFullName($langs), $othermember->login, $thirdparty->name), null, 'errors');
}
}

if (!$error) {
$result = $object->setThirdPartyId(GETPOSTINT('socid'));
if ($result < 0) {
dol_print_error(null, $object->error);
}
$action = '';
if (!$error) {
$result = $object->setThirdPartyId(GETPOSTINT('socid'));
if ($result < 0) {
dol_print_error(null, $object->error);
}
$action = '';
}
}
}

if ($user->hasRight('adherent', 'cotisation', 'creer') && $action == 'subscription' && !$cancel) {
if (empty($reshook) && $user->hasRight('adherent', 'cotisation', 'creer') && $action == 'subscription' && !$cancel) {
$error = 0;

$langs->load("banks");
Expand Down Expand Up @@ -701,7 +699,7 @@
if ($action != 'addsubscription' && $action != 'create_thirdparty') {
print '<div class="tabsAction">';

if ($object->statut > 0) {
if ($object->status > 0) {
print '<div class="inline-block divButAction"><a class="butAction" href="'.$_SERVER["PHP_SELF"].'?rowid='.$rowid.'&action=addsubscription&token='.newToken().'">'.$langs->trans("AddSubscription")."</a></div>";
} else {
print '<div class="inline-block divButAction"><a class="butActionRefused classfortooltip" href="#" title="'.dol_escape_htmltag($langs->trans("ValidateBefore")).'">'.$langs->trans("AddSubscription").'</a></div>';
Expand Down
17 changes: 9 additions & 8 deletions htdocs/adherents/subscription/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
$search_note = GETPOST('search_note', 'alpha');
$search_account = GETPOST('search_account', 'alpha');
$search_amount = GETPOST('search_amount', 'alpha');
$search_all = '';
$search_all = trim(GETPOST('search_all', 'alphanohtml'));

$date_select = GETPOST("date_select", 'alpha');

Expand Down Expand Up @@ -98,14 +98,16 @@

// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
'c.rowid' => 'Ref',
'c.note' => "Label",
);
$arrayfields = array(
'd.ref' => array('label' => "Ref", 'checked' => 1),
'd.fk_type' => array('label' => "Type", 'checked' => 1),
'd.lastname' => array('label' => "Lastname", 'checked' => 1),
'd.firstname' => array('label' => "Firstname", 'checked' => 1),
'd.login' => array('label' => "Login", 'checked' => 1),
't.libelle' => array('label' => "Label", 'checked' => 1),
'c.note' => array('label' => "Label", 'checked' => 1),
'd.bank' => array('label' => "BankAccount", 'checked' => 1, 'enabled' => (isModEnabled('bank'))),
/*'d.note_public'=>array('label'=>"NotePublic", 'checked'=>0),
'd.note_private'=>array('label'=>"NotePrivate", 'checked'=>0),*/
Expand Down Expand Up @@ -166,7 +168,7 @@
// Mass actions
$objectclass = 'Subscription';
$objectlabel = 'Subscription';
$uploaddir = $conf->adherent->dir_output;
$uploaddir = $conf->member->dir_output;
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}

Expand Down Expand Up @@ -395,7 +397,6 @@

if ($search_all) {
$setupstring = '';
// @phan-suppress-next-line PhanEmptyForeach
foreach ($fieldstosearchall as $key => $val) {
$fieldstosearchall[$key] = $langs->trans($val);
$setupstring .= $key."=".$val.";";
Expand Down Expand Up @@ -474,7 +475,7 @@
print '<input class="flat maxwidth75" type="text" name="search_login" value="'.dol_escape_htmltag($search_login).'"></td>';
}

if (!empty($arrayfields['t.libelle']['checked'])) {
if (!empty($arrayfields['c.note']['checked'])) {
print '<td class="liste_titre">';
print '';
print '</td>';
Expand Down Expand Up @@ -557,8 +558,8 @@
print_liste_field_titre($arrayfields['d.login']['label'], $_SERVER["PHP_SELF"], "d.login", $param, "", "", $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['t.libelle']['checked'])) {
print_liste_field_titre($arrayfields['t.libelle']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder);
if (!empty($arrayfields['c.note']['checked'])) {
print_liste_field_titre($arrayfields['c.note']['label'], $_SERVER["PHP_SELF"], "c.note", $param, "", '', $sortfield, $sortorder);
$totalarray['nbfield']++;
}
if (!empty($arrayfields['d.bank']['checked'])) {
Expand Down Expand Up @@ -725,7 +726,7 @@
}

// Label
if (!empty($arrayfields['t.libelle']['checked'])) {
if (!empty($arrayfields['c.note']['checked'])) {
print '<td class="tdoverflowmax400" title="'.dol_escape_htmltag($obj->note_private).'">';
print dol_escape_htmltag(dolGetFirstLineOfText($obj->note_private));
print '</td>';
Expand Down

0 comments on commit ac08dc3

Please sign in to comment.