Browse Source

Fix warnings

Laurent Destailleur 2 years ago
parent
commit
6c110fb2b5

+ 1 - 1
htdocs/comm/propal/card.php

@@ -2850,7 +2850,7 @@ if ($action == 'create') {
 
 	print '<div class="div-table-responsive-no-min">';
 	if (!empty($object->lines) || ($object->statut == Propal::STATUS_DRAFT && $usercancreate && $action != 'selectlines' && $action != 'editline')) {
-		print '<table id="tablelines" class="noborder noshadow" width="100%">';
+		print '<table id="tablelines" class="noborder noshadow centpercent">';
 	}
 
 	if (!empty($object->lines)) {

+ 6 - 8
htdocs/core/class/commonobject.class.php

@@ -4967,9 +4967,9 @@ abstract class CommonObject
 	 *	But for the moment we don't know if it's possible as we keep a method available on overloaded objects.
 	 *
 	 *	@param	string		$action				Action code
-	 *	@param  string		$seller            	Object of seller third party
-	 *	@param  string  	$buyer             	Object of buyer third party
-	 *	@param	int			$selected		   	Object line selected
+	 *	@param  Societe		$seller            	Object of seller third party
+	 *	@param  Societe  	$buyer             	Object of buyer third party
+	 *	@param	int			$selected		   	ID line selected
 	 *	@param  int	    	$dateSelector      	1=Show also date range input fields
 	 *  @param	string		$defaulttpldir		Directory where to find the template
 	 *	@return	void
@@ -5058,9 +5058,9 @@ abstract class CommonObject
 	 *	@param  int		    		$num               	Number of line (0)
 	 *	@param  int		    		$i					I
 	 *	@param  int		    		$dateSelector      	1=Show also date range input fields
-	 *	@param  string	    		$seller            	Object of seller third party
-	 *	@param  string	    		$buyer             	Object of buyer third party
-	 *	@param	int					$selected		   	Object line selected
+	 *	@param  Societe	    		$seller            	Object of seller third party
+	 *	@param  Societe	    		$buyer             	Object of buyer third party
+	 *	@param	int					$selected		   	ID line selected
 	 *  @param  Extrafields			$extrafields		Object of extrafields
 	 *  @param	string				$defaulttpldir		Directory where to find the template (deprecated)
 	 *	@return	void
@@ -5073,8 +5073,6 @@ abstract class CommonObject
 
 		$object_rights = $this->getRights();
 
-		$element = $this->element;
-
 		$text = '';
 		$description = '';
 

+ 7 - 7
htdocs/core/class/fileupload.class.php

@@ -266,7 +266,7 @@ class FileUpload
 	protected function getFileObject($file_name)
 	{
 		if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) {
-			return;
+			return null;
 		}
 
 		$file_path = $this->options['upload_dir'].$file_name;
@@ -310,7 +310,7 @@ class FileUpload
 		global $maxwidthmini, $maxheightmini;
 
 		if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) {
-			return;
+			return false;
 		}
 
 		$file_path = $this->options['upload_dir'].$file_name;
@@ -345,7 +345,7 @@ class FileUpload
 	protected function validate($uploaded_file, $file, $error, $index)
 	{
 		if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) {
-			return;
+			return false;
 		}
 
 		if ($error) {
@@ -459,12 +459,12 @@ class FileUpload
 	 * @param 	string		$type				Type
 	 * @param 	string		$error				Error
 	 * @param	string		$index				Index
-	 * @return stdClass
+	 * @return stdClass|null
 	 */
 	protected function handleFileUpload($uploaded_file, $name, $size, $type, $error, $index)
 	{
 		if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) {
-			return;
+			return null;
 		}
 
 		$file = new stdClass();
@@ -590,12 +590,12 @@ class FileUpload
 	/**
 	 * Delete uploaded file
 	 *
-	 * @return	string
+	 * @return	string|null
 	 */
 	public function delete()
 	{
 		if (!getDolGlobalInt('MAIN_USE_JQUERY_FILEUPLOAD')) {
-			return;
+			return null;
 		}
 
 		$file_name = isset($_REQUEST['file']) ?

+ 2 - 2
htdocs/core/class/html.form.class.php

@@ -10211,9 +10211,9 @@ class Form
 				$out .= '</select>';
 			}
 
-			return $out;
-
 			$this->db->free($resql);
+
+			return $out;
 		} else {
 			dol_print_error($this->db);
 			return '';

+ 2 - 2
htdocs/core/class/html.formprojet.class.php

@@ -58,7 +58,7 @@ class FormProjets
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 
 	/**
-	 *    Output a combo list with projects qualified for a third party / user
+	 * Output a combo list with projects qualified for a third party / user
 	 *
 	 * @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
 	 * @param string|Project $selected Id of preselected project or Project (or ''). Note: If you know the ref, you can also provide it into $selected_input_value to save one request in some cases.
@@ -145,7 +145,7 @@ class FormProjets
 	 * @param int $htmlid Html id to use instead of htmlname
 	 * @param string $morecss More CSS
 	 * @param string $morefilter More filters (Must be a sql sanitized string)
-	 * @return int                           Nb of project if OK, <0 if KO
+	 * @return int|string|array                           HTML string or array of option or <0 if KO
 	 */
 	public function select_projects_list($socid = -1, $selected = '', $htmlname = 'projectid', $maxlength = 24, $option_only = 0, $show_empty = 1, $discard_closed = 0, $forcefocus = 0, $disabled = 0, $mode = 0, $filterkey = '', $nooutput = 0, $forceaddid = 0, $htmlid = '', $morecss = 'maxwidth500', $morefilter = '')
 	{

+ 2 - 1
htdocs/core/class/html.formsetup.class.php

@@ -339,7 +339,7 @@ class FormSetup
 	 * Method used to test  module builder convertion to this form usage
 	 *
 	 * @param 	array 	$params 	an array of arrays of params from old modulBuilder params
-	 * @return 	void
+	 * @return 	boolean
 	 */
 	public function addItemsFromParamsArray($params)
 	{
@@ -347,6 +347,7 @@ class FormSetup
 		foreach ($params as $confKey => $param) {
 			$this->addItemFromParams($confKey, $param); // todo manage error
 		}
+		return true;
 	}
 
 

+ 2 - 2
htdocs/core/customreports.php

@@ -1,5 +1,5 @@
 <?php
-/* Copyright (C) 2020 Laurent Destailleur  <eldy@users.sourceforge.net>
+/* Copyright (C) 2020-2023 Laurent Destailleur  <eldy@users.sourceforge.net>
  *
  * 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
@@ -98,7 +98,7 @@ $arrayoftype = array(
 	'proposal' => array('label' => 'Proposals', 'picto'=>'proposal', 'ObjectClassName' => 'Propal', 'enabled' => isModEnabled('propal'), 'ClassPath' => "/comm/propal/class/propal.class.php"),
 	'order' => array('label' => 'Orders', 'picto'=>'order', 'ObjectClassName' => 'Commande', 'enabled' => isModEnabled('commande'), 'ClassPath' => "/commande/class/commande.class.php"),
 	'invoice' => array('langs'=>'facture', 'label' => 'Invoices', 'picto'=>'bill', 'ObjectClassName' => 'Facture', 'enabled' => isModEnabled('facture'), 'ClassPath' => "/compta/facture/class/facture.class.php"),
-	'invoice_template'=>array('langs'=>'facture', 'label' => 'PredefinedInvoices', 'picto'=>'bill', 'ObjectClassName' => 'FactureRec', 'enabled' => isModEnabled('facture'), 'ClassPath' => "/compta/class/facturerec.class.php", 'langs'=>'bills'),
+	'invoice_template'=>array('label' => 'PredefinedInvoices', 'picto'=>'bill', 'ObjectClassName' => 'FactureRec', 'enabled' => isModEnabled('facture'), 'ClassPath' => "/compta/class/facturerec.class.php", 'langs'=>'bills'),
 	'contract' => array('label' => 'Contracts', 'picto'=>'contract', 'ObjectClassName' => 'Contrat', 'enabled' => isModEnabled('contrat'), 'ClassPath' => "/contrat/class/contrat.class.php", 'langs'=>'contracts'),
 	'contractdet' => array('label' => 'ContractLines', 'picto'=>'contract', 'ObjectClassName' => 'ContratLigne', 'enabled' => isModEnabled('contrat'), 'ClassPath' => "/contrat/class/contrat.class.php", 'langs'=>'contracts'),
 	'bom' => array('label' => 'BOM', 'picto'=>'bom', 'ObjectClassName' => 'Bom', 'enabled' => isModEnabled('bom')),

+ 2 - 2
htdocs/debugbar/class/DebugBar.php

@@ -24,7 +24,6 @@
 dol_include_once('/debugbar/class/autoloader.php');
 
 use \DebugBar\DebugBar;
-use \DebugBar\DataCollector\PhpInfoCollector;
 
 dol_include_once('/debugbar/class/DataCollector/DolMessagesCollector.php');
 dol_include_once('/debugbar/class/DataCollector/DolRequestDataCollector.php');
@@ -71,7 +70,7 @@ class DolibarrDebugBar extends DebugBar
 	/**
 	 * Returns a JavascriptRenderer for this instance
 	 *
-	 * @return DebugBar\JavascriptRenderer      String content
+	 * @return \DebugBar\JavascriptRenderer      String content
 	 */
 	public function getRenderer()
 	{
@@ -80,6 +79,7 @@ class DolibarrDebugBar extends DebugBar
 		$renderer->disableVendor('fontawesome');	// We already have fontawesome loaded globally by the main.inc.php
 		$renderer->disableVendor('highlightjs');	// We don't need this
 		$renderer->setEnableJqueryNoConflict(false);	// We don't need no conflict
+
 		return $renderer;
 	}
 }

+ 11 - 14
htdocs/delivery/class/delivery.class.php

@@ -281,7 +281,6 @@ class Delivery extends CommonObject
 		// phpcs:enable
 		$error = 0;
 		$idprod = $fk_product;
-		$j = 0;
 
 		$sql = "INSERT INTO ".MAIN_DB_PREFIX."deliverydet (fk_delivery, fk_origin_line,";
 		$sql .= " fk_product, description, qty)";
@@ -317,8 +316,6 @@ class Delivery extends CommonObject
 	 */
 	public function fetch($id)
 	{
-		global $conf;
-
 		$sql = "SELECT l.rowid, l.fk_soc, l.date_creation, l.date_valid, l.ref, l.ref_customer, l.fk_user_author,";
 		$sql .= " l.total_ht, l.fk_statut, l.fk_user_valid, l.note_private, l.note_public";
 		$sql .= ", l.date_delivery, l.fk_address, l.model_pdf";
@@ -396,7 +393,8 @@ class Delivery extends CommonObject
 	 */
 	public function valid($user, $notrigger = 0)
 	{
-		global $conf, $langs;
+		global $conf;
+
 		require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
 
 		dol_syslog(get_class($this)."::valid begin");
@@ -532,9 +530,9 @@ class Delivery extends CommonObject
 	/**
 	 * 	Creating the delivery slip from an existing shipment
 	 *
-	 *	@param	User	$user            User who creates
-	 *	@param  int		$sending_id      Id of the expedition that serves as a model
-	 *	@return	integer
+	 *	@param	User	$user           User who creates
+	 *	@param  int		$sending_id		Id of the expedition that serves as a model
+	 *	@return	integer					<=0 if KO, >0 if OK
 	 */
 	public function create_from_sending($user, $sending_id)
 	{
@@ -543,6 +541,9 @@ class Delivery extends CommonObject
 
 		$expedition = new Expedition($this->db);
 		$result = $expedition->fetch($sending_id);
+		if ($result <= 0) {
+			return $result;
+		}
 
 		$this->lines = array();
 
@@ -737,7 +738,7 @@ class Delivery extends CommonObject
 	 */
 	public function getTooltipContentArray($params)
 	{
-		global $conf, $langs;
+		global $langs;
 
 		$datas = [];
 
@@ -944,8 +945,6 @@ class Delivery extends CommonObject
 	 */
 	public function initAsSpecimen()
 	{
-		global $user, $langs, $conf;
-
 		$now = dol_now();
 
 		// Load array of products prodids
@@ -994,13 +993,11 @@ class Delivery extends CommonObject
 	/**
 	 *  Renvoie la quantite de produit restante a livrer pour une commande
 	 *
-	 *  @return     array		Product remaining to be delivered
+	 *  @return     array|int		Product remaining to be delivered or <0 if KO
 	 *  TODO use new function
 	 */
 	public function getRemainingDelivered()
 	{
-		global $langs;
-
 		// Get the linked object
 		$this->fetchObjectLinked('', '', $this->id, $this->element);
 		//var_dump($this->linkedObjectsIds);
@@ -1098,7 +1095,7 @@ class Delivery extends CommonObject
 	 */
 	public function generateDocument($modele, $outputlangs = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
 	{
-		global $conf, $user, $langs;
+		global $conf, $langs;
 
 		$langs->load("deliveries");
 		$outputlangs->load("products");

+ 1 - 1
htdocs/societe/class/societe.class.php

@@ -2415,7 +2415,7 @@ class Societe extends CommonObject
 	 *  @param	int			$mode			0=Array with properties, 1=Array of id.
 	 *  @param	string		$sortfield		List of sort fields, separated by comma. Example: 't1.fielda,t2.fieldb'
 	 *  @param	string		$sortorder		Sort order, separated by comma. Example: 'ASC,DESC';
-	 *  @return array       				Array of sales representatives of third party
+	 *  @return array|int      				Array of sales representatives of third party or <0 if KO
 	 */
 	public function getSalesRepresentatives(User $user, $mode = 0, $sortfield = null, $sortorder = null)
 	{

+ 4 - 4
htdocs/stripe/class/stripe.class.php

@@ -151,7 +151,7 @@ class Stripe extends CommonObject
 	 * @param	string	$key							''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect
 	 * @param	int		$status							Status (0=test, 1=live)
 	 * @param	int		$createifnotlinkedtostripe		1=Create the stripe customer and the link if the thirdparty is not yet linked to a stripe customer
-	 * @return 	\Stripe\StripeCustomer|null 			Stripe Customer or null if not found
+	 * @return 	\Stripe\Customer|null 					Stripe Customer or null if not found
 	 */
 	public function customerStripe(Societe $object, $key = '', $status = 0, $createifnotlinkedtostripe = 0)
 	{
@@ -783,12 +783,12 @@ class Stripe extends CommonObject
 	/**
 	 * Get the Stripe card of a company payment mode (option to create it on Stripe if not linked yet is no more available on new Stripe API)
 	 *
-	 * @param	\Stripe\StripeCustomer	$cu								Object stripe customer.
+	 * @param	\Stripe\Customer		$cu								Object stripe customer.
 	 * @param	CompanyPaymentMode		$object							Object companypaymentmode to check, or create on stripe (create on stripe also update the societe_rib table for current entity)
 	 * @param	string					$stripeacc						''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect
 	 * @param	int						$status							Status (0=test, 1=live)
 	 * @param	int						$createifnotlinkedtostripe		1=Create the stripe card and the link if the card is not yet linked to a stripe card. Deprecated with new Stripe API and SCA.
-	 * @return 	\Stripe\StripeCard|\Stripe\PaymentMethod|null 			Stripe Card or null if not found
+	 * @return 	\Stripe\Card|\Stripe\PaymentMethod|null 				Stripe Card or null if not found
 	 */
 	public function cardStripe($cu, CompanyPaymentMode $object, $stripeacc = '', $status = 0, $createifnotlinkedtostripe = 0)
 	{
@@ -935,7 +935,7 @@ class Stripe extends CommonObject
 	/**
 	 * Get the Stripe SEPA of a company payment mode
 	 *
-	 * @param	\Stripe\StripeCustomer	$cu								Object stripe customer.
+	 * @param	\Stripe\Customer		$cu								Object stripe customer.
 	 * @param	CompanyPaymentMode		$object							Object companypaymentmode to check, or create on stripe (create on stripe also update the societe_rib table for current entity)
 	 * @param	string					$stripeacc						''=Use common API. If not '', it is the Stripe connect account 'acc_....' to use Stripe connect
 	 * @param	int						$status							Status (0=test, 1=live)