From c1b0f187bcc9443f0f6389bde4d86fbefd32ac69 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 6 Aug 2023 13:02:33 +0200 Subject: [PATCH] Fix warnings --- htdocs/societe/class/api_thirdparties.class.php | 13 +++++++------ phpstan.neon | 5 +++++ .../email_expire_services_to_customers.php | 2 +- .../email_expire_services_to_representatives.php | 2 +- .../invoices/email_unpaid_invoices_to_customers.php | 2 +- .../email_unpaid_invoices_to_representatives.php | 2 +- scripts/members/sync_members_ldap2dolibarr.php | 2 +- 7 files changed, 17 insertions(+), 11 deletions(-) diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 418ecb4ab83..e10571512c6 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -350,18 +350,18 @@ class Thirdparties extends DolibarrApi throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $this->companytoremove = new Societe($this->db); + $companytoremove = new Societe($this->db); - $result = $this->companytoremove->fetch($idtodelete); // include the fetch of extra fields + $result = $companytoremove->fetch($idtodelete); // include the fetch of extra fields if (!$result) { throw new RestException(404, 'Thirdparty not found'); } - if (!DolibarrApi::_checkAccessToResource('societe', $this->companytoremove->id)) { + if (!DolibarrApi::_checkAccessToResource('societe', $companytoremove->id)) { throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); } - $soc_origin = $this->companytoremove; + $soc_origin = $companytoremove; $object = $this->company; $user = DolibarrApiAccess::$user; @@ -476,7 +476,8 @@ class Thirdparties extends DolibarrApi // External modules should update their ones too if (!$error) { $parameters = array('soc_origin' => $soc_origin->id, 'soc_dest' => $object->id); - $reshook = $hookmanager->executeHooks('replaceThirdparty', $parameters, $soc_dest, $action); + $action = ''; + $reshook = $hookmanager->executeHooks('replaceThirdparty', $parameters, $object, $action); if ($reshook < 0) { //setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); @@ -509,7 +510,7 @@ class Thirdparties extends DolibarrApi if ($error) { $this->db->rollback(); - throw new RestException(500, 'Error failed to merged thirdparty '.$this->companytoremove->id.' into '.$id.'. Enable and read log file for more information.'); + throw new RestException(500, 'Error failed to merged thirdparty '.$companytoremove->id.' into '.$id.'. Enable and read log file for more information.'); } else { $this->db->commit(); } diff --git a/phpstan.neon b/phpstan.neon index 92e9e0a0f2e..b0563e135f0 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -51,6 +51,11 @@ parameters: - '#Result of function fieldList#' - '#Caught class Stripe#' - '#Function llxHeaderVierge invoked with#' + - '#If condition is always true#' + - '#always exists and is not falsy#' + - '#has no return type specified#' + - '#expression is always#' + - '#always exists and is not nullable#' internalErrorsCountLimit: 50 cache: nodesByFileCountMax: 512 diff --git a/scripts/contracts/email_expire_services_to_customers.php b/scripts/contracts/email_expire_services_to_customers.php index ef46b991b2a..cb62e853a83 100755 --- a/scripts/contracts/email_expire_services_to_customers.php +++ b/scripts/contracts/email_expire_services_to_customers.php @@ -237,7 +237,7 @@ if ($resql) { * @param string $userlang Code lang to use for email output. * @param string $oldtarget Target name * @param int $duration_value duration value - * @return int <0 if KO, >0 if OK + * @return int Int <0 if KO, >0 if OK */ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, $duration_value) { diff --git a/scripts/contracts/email_expire_services_to_representatives.php b/scripts/contracts/email_expire_services_to_representatives.php index f9129b9db80..094159f6103 100755 --- a/scripts/contracts/email_expire_services_to_representatives.php +++ b/scripts/contracts/email_expire_services_to_representatives.php @@ -186,7 +186,7 @@ if ($resql) { * @param string $userlang Code lang to use for email output. * @param string $oldtarget Target name of sale representative * @param int $duration_value Duration value - * @return int <0 if KO, >0 if OK + * @return int Int <0 if KO, >0 if OK */ function sendEmailTo($mode, $oldemail, $message, $total, $userlang, $oldtarget, $duration_value) { diff --git a/scripts/invoices/email_unpaid_invoices_to_customers.php b/scripts/invoices/email_unpaid_invoices_to_customers.php index 4657c16bd65..fec73b78213 100755 --- a/scripts/invoices/email_unpaid_invoices_to_customers.php +++ b/scripts/invoices/email_unpaid_invoices_to_customers.php @@ -239,7 +239,7 @@ if ($resql) { * @param string $total Total amount of unpayed invoices * @param string $userlang Code lang to use for email output. * @param string $oldtarget Target name - * @return int <0 if KO, >0 if OK + * @return int Int <0 if KO, >0 if OK */ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget) { diff --git a/scripts/invoices/email_unpaid_invoices_to_representatives.php b/scripts/invoices/email_unpaid_invoices_to_representatives.php index 0e84325c662..a52bccd2395 100755 --- a/scripts/invoices/email_unpaid_invoices_to_representatives.php +++ b/scripts/invoices/email_unpaid_invoices_to_representatives.php @@ -195,7 +195,7 @@ if ($resql) { * @param string $total Total amount of unpayed invoices * @param string $userlang Code lang to use for email output. * @param string $oldtarget Target name of sale representative - * @return int <0 if KO, >0 if OK + * @return int Int <0 if KO, >0 if OK */ function envoi_mail($mode, $oldemail, $message, $total, $userlang, $oldtarget) { diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index 083ae81bd3e..b9c10bdbcdd 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -98,7 +98,7 @@ if (!isset($argv[2]) || !is_numeric($argv[2])) { exit(-1); } -$typeid = $argv[2]; +$typeid = (int) $argv[2]; foreach ($argv as $key => $val) { if ($val == 'commitiferror') { $forcecommit = 1;