Fix PhanTypeSuspiciousStringExpression

This commit is contained in:
MDW 2024-03-16 22:53:22 +01:00
parent 187e715bc5
commit aa4b84a018
No known key found for this signature in database

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2006-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 JF FERRY <jfefe@aternatik.fr>
* Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
*
* 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
@ -82,11 +83,11 @@ $server->wsdl->addComplexType(
'all',
'',
array(
'dolibarrkey' => array('name'=>'dolibarrkey', 'type'=>'xsd:string'),
'sourceapplication' => array('name'=>'sourceapplication', 'type'=>'xsd:string'),
'login' => array('name'=>'login', 'type'=>'xsd:string'),
'password' => array('name'=>'password', 'type'=>'xsd:string'),
'entity' => array('name'=>'entity', 'type'=>'xsd:string')
'dolibarrkey' => array('name' => 'dolibarrkey', 'type' => 'xsd:string'),
'sourceapplication' => array('name' => 'sourceapplication', 'type' => 'xsd:string'),
'login' => array('name' => 'login', 'type' => 'xsd:string'),
'password' => array('name' => 'password', 'type' => 'xsd:string'),
'entity' => array('name' => 'entity', 'type' => 'xsd:string')
)
);
// Define WSDL Return object
@ -97,37 +98,37 @@ $server->wsdl->addComplexType(
'all',
'',
array(
'result_code' => array('name'=>'result_code', 'type'=>'xsd:string'),
'result_label' => array('name'=>'result_label', 'type'=>'xsd:string'),
'result_code' => array('name' => 'result_code', 'type' => 'xsd:string'),
'result_label' => array('name' => 'result_label', 'type' => 'xsd:string'),
)
);
$line_fields = array(
'id' => array('name'=>'id', 'type'=>'xsd:string'),
'type' => array('name'=>'type', 'type'=>'xsd:int'),
'fk_commande' => array('name'=>'fk_commande', 'type'=>'xsd:int'),
'fk_parent_line' => array('name'=>'fk_parent_line', 'type'=>'xsd:int'),
'desc' => array('name'=>'desc', 'type'=>'xsd:string'),
'qty' => array('name'=>'qty', 'type'=>'xsd:double'),
'price' => array('name'=>'price', 'type'=>'xsd:double'),
'unitprice' => array('name'=>'unitprice', 'type'=>'xsd:double'),
'vat_rate' => array('name'=>'vat_rate', 'type'=>'xsd:double'),
'id' => array('name' => 'id', 'type' => 'xsd:string'),
'type' => array('name' => 'type', 'type' => 'xsd:int'),
'fk_commande' => array('name' => 'fk_commande', 'type' => 'xsd:int'),
'fk_parent_line' => array('name' => 'fk_parent_line', 'type' => 'xsd:int'),
'desc' => array('name' => 'desc', 'type' => 'xsd:string'),
'qty' => array('name' => 'qty', 'type' => 'xsd:double'),
'price' => array('name' => 'price', 'type' => 'xsd:double'),
'unitprice' => array('name' => 'unitprice', 'type' => 'xsd:double'),
'vat_rate' => array('name' => 'vat_rate', 'type' => 'xsd:double'),
'remise' => array('name'=>'remise', 'type'=>'xsd:double'),
'remise_percent' => array('name'=>'remise_percent', 'type'=>'xsd:double'),
'remise' => array('name' => 'remise', 'type' => 'xsd:double'),
'remise_percent' => array('name' => 'remise_percent', 'type' => 'xsd:double'),
'total_net' => array('name'=>'total_net', 'type'=>'xsd:double'),
'total_vat' => array('name'=>'total_vat', 'type'=>'xsd:double'),
'total' => array('name'=>'total', 'type'=>'xsd:double'),
'total_net' => array('name' => 'total_net', 'type' => 'xsd:double'),
'total_vat' => array('name' => 'total_vat', 'type' => 'xsd:double'),
'total' => array('name' => 'total', 'type' => 'xsd:double'),
'date_start' => array('name'=>'date_start', 'type'=>'xsd:date'),
'date_end' => array('name'=>'date_end', 'type'=>'xsd:date'),
'date_start' => array('name' => 'date_start', 'type' => 'xsd:date'),
'date_end' => array('name' => 'date_end', 'type' => 'xsd:date'),
// From product
'product_id' => array('name'=>'product_id', 'type'=>'xsd:int'),
'product_ref' => array('name'=>'product_ref', 'type'=>'xsd:string'),
'product_label' => array('name'=>'product_label', 'type'=>'xsd:string'),
'product_desc' => array('name'=>'product_desc', 'type'=>'xsd:string')
'product_id' => array('name' => 'product_id', 'type' => 'xsd:int'),
'product_ref' => array('name' => 'product_ref', 'type' => 'xsd:string'),
'product_label' => array('name' => 'product_label', 'type' => 'xsd:string'),
'product_desc' => array('name' => 'product_desc', 'type' => 'xsd:string')
);
$elementtype = 'commandedet';
@ -149,7 +150,7 @@ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafie
} else {
$type = 'xsd:string';
}
$extrafield_line_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type);
$extrafield_line_array['options_'.$key] = array('name' => 'options_'.$key, 'type' => $type);
}
}
if (is_array($extrafield_line_array)) {
@ -198,39 +199,39 @@ $server->wsdl->addComplexType(
);
$order_fields = array(
'id' => array('name'=>'id', 'type'=>'xsd:string'),
'ref' => array('name'=>'ref', 'type'=>'xsd:string'),
'ref_client' => array('name'=>'ref_client', 'type'=>'xsd:string'),
'ref_ext' => array('name'=>'ref_ext', 'type'=>'xsd:string'),
'thirdparty_id' => array('name'=>'thirdparty_id', 'type'=>'xsd:int'),
'status' => array('name'=>'status', 'type'=>'xsd:int'),
'billed' => array('name'=>'billed', 'type'=>'xsd:string'),
'total_net' => array('name'=>'total_net', 'type'=>'xsd:double'),
'total_vat' => array('name'=>'total_vat', 'type'=>'xsd:double'),
'total_localtax1' => array('name'=>'total_localtax1', 'type'=>'xsd:double'),
'total_localtax2' => array('name'=>'total_localtax2', 'type'=>'xsd:double'),
'total' => array('name'=>'total', 'type'=>'xsd:double'),
'date' => array('name'=>'date', 'type'=>'xsd:date'),
'date_creation' => array('name'=>'date_creation', 'type'=>'xsd:dateTime'),
'date_validation' => array('name'=>'date_validation', 'type'=>'xsd:dateTime'),
'date_modification' => array('name'=>'date_modification', 'type'=>'xsd:dateTime'),
'source' => array('name'=>'source', 'type'=>'xsd:string'),
'note_private' => array('name'=>'note_private', 'type'=>'xsd:string'),
'note_public' => array('name'=>'note_public', 'type'=>'xsd:string'),
'project_id' => array('name'=>'project_id', 'type'=>'xsd:string'),
'id' => array('name' => 'id', 'type' => 'xsd:string'),
'ref' => array('name' => 'ref', 'type' => 'xsd:string'),
'ref_client' => array('name' => 'ref_client', 'type' => 'xsd:string'),
'ref_ext' => array('name' => 'ref_ext', 'type' => 'xsd:string'),
'thirdparty_id' => array('name' => 'thirdparty_id', 'type' => 'xsd:int'),
'status' => array('name' => 'status', 'type' => 'xsd:int'),
'billed' => array('name' => 'billed', 'type' => 'xsd:string'),
'total_net' => array('name' => 'total_net', 'type' => 'xsd:double'),
'total_vat' => array('name' => 'total_vat', 'type' => 'xsd:double'),
'total_localtax1' => array('name' => 'total_localtax1', 'type' => 'xsd:double'),
'total_localtax2' => array('name' => 'total_localtax2', 'type' => 'xsd:double'),
'total' => array('name' => 'total', 'type' => 'xsd:double'),
'date' => array('name' => 'date', 'type' => 'xsd:date'),
'date_creation' => array('name' => 'date_creation', 'type' => 'xsd:dateTime'),
'date_validation' => array('name' => 'date_validation', 'type' => 'xsd:dateTime'),
'date_modification' => array('name' => 'date_modification', 'type' => 'xsd:dateTime'),
'source' => array('name' => 'source', 'type' => 'xsd:string'),
'note_private' => array('name' => 'note_private', 'type' => 'xsd:string'),
'note_public' => array('name' => 'note_public', 'type' => 'xsd:string'),
'project_id' => array('name' => 'project_id', 'type' => 'xsd:string'),
'mode_reglement_id' => array('name'=>'mode_reglement_id', 'type'=>'xsd:string'),
'mode_reglement_code' => array('name'=>'mode_reglement_code', 'type'=>'xsd:string'),
'mode_reglement' => array('name'=>'mode_reglement', 'type'=>'xsd:string'),
'cond_reglement_id' => array('name'=>'cond_reglement_id', 'type'=>'xsd:string'),
'cond_reglement_code' => array('name'=>'cond_reglement_code', 'type'=>'xsd:string'),
'cond_reglement' => array('name'=>'cond_reglement', 'type'=>'xsd:string'),
'cond_reglement_doc' => array('name'=>'cond_reglement_doc', 'type'=>'xsd:string'),
'mode_reglement_id' => array('name' => 'mode_reglement_id', 'type' => 'xsd:string'),
'mode_reglement_code' => array('name' => 'mode_reglement_code', 'type' => 'xsd:string'),
'mode_reglement' => array('name' => 'mode_reglement', 'type' => 'xsd:string'),
'cond_reglement_id' => array('name' => 'cond_reglement_id', 'type' => 'xsd:string'),
'cond_reglement_code' => array('name' => 'cond_reglement_code', 'type' => 'xsd:string'),
'cond_reglement' => array('name' => 'cond_reglement', 'type' => 'xsd:string'),
'cond_reglement_doc' => array('name' => 'cond_reglement_doc', 'type' => 'xsd:string'),
'date_livraison' => array('name'=>'date_livraison', 'type'=>'xsd:date'),
'demand_reason_id' => array('name'=>'demand_reason_id', 'type'=>'xsd:string'),
'date_livraison' => array('name' => 'date_livraison', 'type' => 'xsd:date'),
'demand_reason_id' => array('name' => 'demand_reason_id', 'type' => 'xsd:string'),
'lines' => array('name'=>'lines', 'type'=>'tns:LinesArray2')
'lines' => array('name' => 'lines', 'type' => 'tns:LinesArray2')
);
$elementtype = 'commande';
@ -252,7 +253,7 @@ if (isset($extrafields->attributes[$elementtype]['label']) && is_array($extrafie
} else {
$type = 'xsd:string';
}
$extrafield_array['options_'.$key] = array('name'=>'options_'.$key, 'type'=>$type);
$extrafield_array['options_'.$key] = array('name' => 'options_'.$key, 'type' => $type);
}
}
if (is_array($extrafield_array)) {
@ -312,8 +313,8 @@ $styleuse = 'encoded'; // encoded/literal/literal wrapped
// Register WSDL
$server->register(
'getOrder',
array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'), // Entry values
array('result'=>'tns:result', 'order'=>'tns:order'), // Exit values
array('authentication' => 'tns:authentication', 'id' => 'xsd:string', 'ref' => 'xsd:string', 'ref_ext' => 'xsd:string'), // Entry values
array('result' => 'tns:result', 'order' => 'tns:order'), // Exit values
$ns,
$ns.'#getOrder',
$styledoc,
@ -323,8 +324,8 @@ $server->register(
$server->register(
'getOrdersForThirdParty',
array('authentication'=>'tns:authentication', 'idthirdparty'=>'xsd:string'), // Entry values
array('result'=>'tns:result', 'orders'=>'tns:OrdersArray2'), // Exit values
array('authentication' => 'tns:authentication', 'idthirdparty' => 'xsd:string'), // Entry values
array('result' => 'tns:result', 'orders' => 'tns:OrdersArray2'), // Exit values
$ns,
$ns.'#getOrdersForThirdParty',
$styledoc,
@ -334,8 +335,8 @@ $server->register(
$server->register(
'createOrder',
array('authentication'=>'tns:authentication', 'order'=>'tns:order'), // Entry values
array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string'), // Exit values
array('authentication' => 'tns:authentication', 'order' => 'tns:order'), // Entry values
array('result' => 'tns:result', 'id' => 'xsd:string', 'ref' => 'xsd:string'), // Exit values
$ns,
$ns.'#createOrder',
$styledoc,
@ -345,8 +346,8 @@ $server->register(
$server->register(
'updateOrder',
array('authentication'=>'tns:authentication', 'order'=>'tns:order'), // Entry values
array('result'=>'tns:result', 'id'=>'xsd:string', 'ref'=>'xsd:string', 'ref_ext'=>'xsd:string'), // Exit values
array('authentication' => 'tns:authentication', 'order' => 'tns:order'), // Entry values
array('result' => 'tns:result', 'id' => 'xsd:string', 'ref' => 'xsd:string', 'ref_ext' => 'xsd:string'), // Exit values
$ns,
$ns.'#updateOrder',
$styledoc,
@ -356,8 +357,8 @@ $server->register(
$server->register(
'validOrder',
array('authentication'=>'tns:authentication', 'id'=>'xsd:string', 'id_warehouse'=>'xsd:string'), // Entry values
array('result'=>'tns:result'), // Exit values
array('authentication' => 'tns:authentication', 'id' => 'xsd:string', 'id_warehouse' => 'xsd:string'), // Entry values
array('result' => 'tns:result'), // Exit values
$ns,
$ns.'#validOrder',
$styledoc,
@ -424,34 +425,34 @@ function getOrder($authentication, $id = 0, $ref = '', $ref_ext = '')
foreach ($order->lines as $line) {
//var_dump($line); exit;
$linesresp[] = array(
'id'=>$line->rowid,
'fk_commande'=>$line->fk_commande,
'fk_parent_line'=>$line->fk_parent_line,
'desc'=>$line->desc,
'qty'=>$line->qty,
'price'=>$line->price,
'unitprice'=>$line->subprice,
'vat_rate'=>$line->tva_tx,
'remise'=>$line->remise,
'remise_percent'=>$line->remise_percent,
'product_id'=>$line->fk_product,
'product_type'=>$line->product_type,
'total_net'=>$line->total_ht,
'total_vat'=>$line->total_tva,
'total'=>$line->total_ttc,
'date_start'=>$line->date_start,
'date_end'=>$line->date_end,
'product_ref'=>$line->product_ref,
'product_label'=>$line->product_label,
'product_desc'=>$line->product_desc
'id' => $line->rowid,
'fk_commande' => $line->fk_commande,
'fk_parent_line' => $line->fk_parent_line,
'desc' => $line->desc,
'qty' => $line->qty,
'price' => $line->price,
'unitprice' => $line->subprice,
'vat_rate' => $line->tva_tx,
'remise' => $line->remise,
'remise_percent' => $line->remise_percent,
'product_id' => $line->fk_product,
'product_type' => $line->product_type,
'total_net' => $line->total_ht,
'total_vat' => $line->total_tva,
'total' => $line->total_ttc,
'date_start' => $line->date_start,
'date_end' => $line->date_end,
'product_ref' => $line->product_ref,
'product_label' => $line->product_label,
'product_desc' => $line->product_desc
);
$i++;
}
// Create order
$objectresp = array(
'result'=>array('result_code'=>'OK', 'result_label'=>''),
'order'=>array(
'result' => array('result_code' => 'OK', 'result_label' => ''),
'order' => array(
'id' => $order->id,
'ref' => $order->ref,
'ref_client' => $order->ref_client,
@ -503,7 +504,7 @@ function getOrder($authentication, $id = 0, $ref = '', $ref_ext = '')
}
if ($error) {
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
$objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
return $objectresp;
@ -579,26 +580,26 @@ function getOrdersForThirdParty($authentication, $idthirdparty)
$linesresp = array();
foreach ($order->lines as $line) {
$linesresp[] = array(
'id'=>$line->rowid,
'type'=>$line->product_type,
'fk_commande'=>$line->fk_commande,
'fk_parent_line'=>$line->fk_parent_line,
'desc'=>$line->desc,
'qty'=>$line->qty,
'price'=>$line->price,
'unitprice'=>$line->subprice,
'tva_tx'=>$line->tva_tx,
'remise'=>$line->remise,
'remise_percent'=>$line->remise_percent,
'total_net'=>$line->total_ht,
'total_vat'=>$line->total_tva,
'total'=>$line->total_ttc,
'date_start'=>$line->date_start,
'date_end'=>$line->date_end,
'product_id'=>$line->fk_product,
'product_ref'=>$line->product_ref,
'product_label'=>$line->product_label,
'product_desc'=>$line->product_desc
'id' => $line->rowid,
'type' => $line->product_type,
'fk_commande' => $line->fk_commande,
'fk_parent_line' => $line->fk_parent_line,
'desc' => $line->desc,
'qty' => $line->qty,
'price' => $line->price,
'unitprice' => $line->subprice,
'tva_tx' => $line->tva_tx,
'remise' => $line->remise,
'remise_percent' => $line->remise_percent,
'total_net' => $line->total_ht,
'total_vat' => $line->total_tva,
'total' => $line->total_ttc,
'date_start' => $line->date_start,
'date_end' => $line->date_end,
'product_id' => $line->fk_product,
'product_ref' => $line->product_ref,
'product_label' => $line->product_label,
'product_desc' => $line->product_desc
);
}
@ -644,8 +645,8 @@ function getOrdersForThirdParty($authentication, $idthirdparty)
}
$objectresp = array(
'result'=>array('result_code'=>'OK', 'result_label'=>''),
'orders'=>$linesorders
'result' => array('result_code' => 'OK', 'result_label' => ''),
'orders' => $linesorders
);
} else {
@ -656,7 +657,7 @@ function getOrdersForThirdParty($authentication, $idthirdparty)
}
if ($error) {
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
$objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
return $objectresp;
@ -786,7 +787,7 @@ function createOrder($authentication, $order)
if ($result >= 0) {
dol_syslog("Webservice server_order:: order creation & validation succeeded, commit", LOG_DEBUG);
$db->commit();
$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''), 'id'=>$newobject->id, 'ref'=>$newobject->ref);
$objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''), 'id' => $newobject->id, 'ref' => $newobject->ref);
} else {
dol_syslog("Webservice server_order:: order creation or validation failed, rollback", LOG_ERR);
$db->rollback();
@ -797,7 +798,7 @@ function createOrder($authentication, $order)
}
if ($error) {
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
$objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
return $objectresp;
@ -865,10 +866,10 @@ function validOrder($authentication, $id = 0, $id_warehouse = 0)
}
if ($error) {
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
$objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
} else {
$db->commit();
$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''));
$objectresp = array('result' => array('result_code' => 'OK', 'result_label' => ''));
}
return $objectresp;
@ -878,7 +879,7 @@ function validOrder($authentication, $id = 0, $id_warehouse = 0)
* Update an order
*
* @param array $authentication Array of authentication information
* @param array $order Order info
* @param array{id:string,ref:string,refext:string} $order Order info
* @return array Array result
*/
function updateOrder($authentication, $order)
@ -969,10 +970,10 @@ function updateOrder($authentication, $order)
if ((!$error) && ($objectfound)) {
$db->commit();
$objectresp = array(
'result'=>array('result_code'=>'OK', 'result_label'=>''),
'id'=>$object->id,
'ref'=>$object->ref,
'ref_ext'=>$object->ref_ext
'result' => array('result_code' => 'OK', 'result_label' => ''),
'id' => $object->id,
'ref' => $object->ref,
'ref_ext' => $object->ref_ext
);
} elseif ($objectfound) {
$db->rollback();
@ -987,7 +988,7 @@ function updateOrder($authentication, $order)
}
if ($error) {
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
$objectresp = array('result' => array('result_code' => $errorcode, 'result_label' => $errorlabel));
}
return $objectresp;