Skip to content

Commit

Permalink
fix phpstan (Dolibarr#32185)
Browse files Browse the repository at this point in the history
* fix phpstan

* remove multiple fetch not needed
  • Loading branch information
frederic34 authored Dec 1, 2024
1 parent 8f48659 commit 51c2e89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 62 deletions.
36 changes: 0 additions & 36 deletions build/phpstan/phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -17940,42 +17940,6 @@ parameters:
count: 1
path: ../../htdocs/document.php

-
message: '#^Variable \$hidedesc might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/don/card.php

-
message: '#^Variable \$hidedetails might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/don/card.php

-
message: '#^Variable \$hideref might not be defined\.$#'
identifier: variable.undefined
count: 1
path: ../../htdocs/don/card.php

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

-
message: '#^Variable \$soc might not be defined\.$#'
identifier: variable.undefined
count: 8
path: ../../htdocs/don/card.php

-
message: '#^Variable \$totalpaid might not be defined\.$#'
identifier: variable.undefined
count: 2
path: ../../htdocs/don/card.php

-
message: '#^Method Donations\:\:_validate\(\) has parameter \$data with no value type specified in iterable type array\.$#'
identifier: missingType.iterableValue
Expand Down
33 changes: 7 additions & 26 deletions htdocs/don/card.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,16 +140,14 @@

// Action reopen object
if ($action == 'confirm_reopen' && $confirm == 'yes' && $permissiontoadd) {
$object->fetch($id);

$result = $object->reopen($user);
if ($result >= 0) {
// Define output language
if (!getDolGlobalString('MAIN_DISABLE_PDF_AUTOUPDATE')) {
if (method_exists($object, 'generateDocument')) {
$outputlangs = $langs;
$newlang = '';
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang) && GETPOST('lang_id', 'aZ09')) {
if (getDolGlobalInt('MAIN_MULTILANGS') && GETPOST('lang_id', 'aZ09')) {
$newlang = GETPOST('lang_id', 'aZ09');
}
if (getDolGlobalInt('MAIN_MULTILANGS') && empty($newlang)) {
Expand All @@ -161,7 +159,9 @@
}
$model = $object->model_pdf;
$ret = $object->fetch($id); // Reload to get new records

$hidedetails = 0;
$hidedesc = 0;
$hideref = 0;
$object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
}
Expand Down Expand Up @@ -289,7 +289,6 @@

// Action delete object
if ($action == 'confirm_delete' && GETPOST("confirm") == "yes" && $permissiontodelete) {
$object->fetch($id);
$result = $object->delete($user);
if ($result > 0) {
header("Location: index.php");
Expand All @@ -302,7 +301,6 @@

// Action validation
if ($action == 'valid_promesse' && $permissiontoadd) {
$object->fetch($id);
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
if ($object->valid_promesse($id, $user->id) >= 0) {
setEventMessages($langs->trans("DonationValidated", $object->ref), null);
Expand All @@ -314,7 +312,6 @@

// Action cancel
if ($action == 'set_cancel' && $permissiontoadd) {
$object->fetch($id);
if ($object->set_cancel($id) >= 0) {
$action = '';
} else {
Expand All @@ -325,21 +322,16 @@
// Action set paid
if ($action == 'set_paid' && $permissiontoadd) {
$modepayment = GETPOSTINT('modepayment');

$object->fetch($id);
if ($object->setPaid($id, $modepayment) >= 0) {
$action = '';
} else {
setEventMessages($object->error, $object->errors, 'errors');
}
} elseif ($action == 'classin' && $user->hasRight('don', 'creer')) {
$object->fetch($id);
$object->setProject($projectid);
}

if ($action == 'update_extras' && $permissiontoadd) {
$object->fetch($id);

$object->oldcopy = dol_clone($object, 2);

// Fill array 'array_options' with data from update form
Expand Down Expand Up @@ -405,7 +397,7 @@
// Company
if (isModEnabled("societe") && getDolGlobalString('DONATION_USE_THIRDPARTIES')) {
// Thirdparty
if ($soc->id > 0) {
if (!empty($soc) && $soc->id > 0) {
print '<td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>';
print '<td>';
print $soc->getNomUrl(1);
Expand All @@ -427,7 +419,7 @@
print '<td class="fieldrequired">'.$langs->trans('ThirdParty').'</td>';
print '<td>';
$filter = '((s.client:IN:1,2,3) AND (status:=:1))';
print $form->select_company($soc->id, 'socid', $filter, 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
print $form->select_company('', 'socid', $filter, 'SelectThirdParty', 0, 0, null, 0, 'minwidth300');
// Option to reload page to retrieve customer information. Note, this clear other input
if (getDolGlobalString('RELOAD_PAGE_ON_CUSTOMER_CHANGE_DISABLED')) {
print '<script type="text/javascript">
Expand Down Expand Up @@ -551,17 +543,6 @@
/* ************************************************************ */

if (!empty($id) && $action == 'edit') {
$result = $object->fetch($id);
if ($result < 0) {
dol_print_error($db, $object->error);
exit;
}
$result = $object->fetch_optionals();
if ($result < 0) {
dol_print_error($db);
exit;
}

$hselected = 'card';
$head = donation_prepare_head($object);

Expand Down Expand Up @@ -683,6 +664,7 @@
/* */
/* ************************************************************ */
if (!empty($id) && $action != 'edit') {
$totalpaid = 0;
$formconfirm = "";
// Confirmation delete
if ($action == 'delete') {
Expand Down Expand Up @@ -821,7 +803,6 @@
$num = $db->num_rows($resql);
$i = 0;

$totalpaid = 0;
print '<table class="noborder paymenttable centpercent">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("RefPayment").'</td>';
Expand Down

0 comments on commit 51c2e89

Please sign in to comment.