mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-08 17:02:34 +01:00
clean code (#35683)
* clean code * clean code * clean code --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
@@ -1182,12 +1182,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../htdocs/ai/admin/setup.php
|
||||
|
||||
-
|
||||
message: '#^Call to function is_object\(\) with ActionComm\|Adherent\|Commande\|CommandeFournisseur\|Contact\|Contrat\|Expedition\|ExpenseReport\|Facture\|FactureFournisseur\|Fichinter\|Mo\|Product\|Project\|Propal\|Task will always evaluate to true\.$#'
|
||||
identifier: function.alreadyNarrowedType
|
||||
count: 2
|
||||
path: ../../../htdocs/api/class/api_documents.class.php
|
||||
|
||||
-
|
||||
message: '#^Variable \$modulepart in empty\(\) always exists and is not falsy\.$#'
|
||||
identifier: empty.variable
|
||||
|
||||
@@ -907,19 +907,18 @@ class Documents extends DolibarrApi
|
||||
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
|
||||
}
|
||||
|
||||
if (is_object($object)) {
|
||||
if ($fetchbyid) {
|
||||
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
|
||||
$result = $object->fetch((int) $ref);
|
||||
} else {
|
||||
$result = $object->fetch(0, $ref);
|
||||
}
|
||||
// at this step $object is always an object
|
||||
if ($fetchbyid) {
|
||||
// @phan-suppress-next-line PhanPluginSuspiciousParamPosition
|
||||
$result = $object->fetch((int) $ref);
|
||||
} else {
|
||||
$result = $object->fetch(0, $ref);
|
||||
}
|
||||
|
||||
if ($result == 0) {
|
||||
throw new RestException(404, "Object with ref '".$ref."' was not found.");
|
||||
} elseif ($result < 0) {
|
||||
throw new RestException(500, 'Error while fetching object: '.$object->error);
|
||||
}
|
||||
if ($result == 0) {
|
||||
throw new RestException(404, "Object with ref '".$ref."' was not found.");
|
||||
} elseif ($result < 0) {
|
||||
throw new RestException(500, 'Error while fetching object: '.$object->error);
|
||||
}
|
||||
|
||||
if (!($object->id > 0)) {
|
||||
@@ -1056,7 +1055,8 @@ class Documents extends DolibarrApi
|
||||
}
|
||||
|
||||
$moreinfo = array('note_private' => 'File uploaded using API /documents from IP '.getUserRemoteIP());
|
||||
if (!empty($object) && is_object($object) && $object->id > 0) {
|
||||
// $object may be null
|
||||
if (is_object($object) && $object->id > 0) {
|
||||
$moreinfo['src_object_type'] = $object->table_element;
|
||||
$moreinfo['src_object_id'] = $object->id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user