浏览代码

Fix phpcs

Laurent Destailleur 1 年之前
父节点
当前提交
3487b76052
共有 3 个文件被更改,包括 43 次插入17 次删除
  1. 18 8
      dev/tools/apstats.php
  2. 24 8
      htdocs/salaries/class/salary.class.php
  3. 1 1
      phpstan.neon

+ 18 - 8
dev/tools/apstats.php

@@ -38,6 +38,8 @@ error_reporting(E_ALL & ~E_DEPRECATED);
 define('PRODUCT', "apstats");
 define('VERSION', "1.0");
 
+$phpstanlevel = 2;
+
 
 print '***** '.constant('PRODUCT').' - '.constant('VERSION').' *****'."\n";
 if (empty($argv[1])) {
@@ -71,6 +73,7 @@ while ($i < $argc) {
 	$i++;
 }
 
+$timestart = time();
 
 // Count lines of code of Dolibarr itself
 /*
@@ -102,7 +105,7 @@ exec($commandcheck, $output_arrdep, $resexecdep);
 
 
 // Get technical debt
-$commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan -v analyze -a build/phpstan/bootstrap.php --memory-limit 5G --error-format=github';
+$commandcheck = ($dirphpstan ? $dirphpstan.'/' : '').'phpstan --level='.$phpstanlevel.' -v analyze -a build/phpstan/bootstrap.php --memory-limit 5G --error-format=github';
 print 'Execute PHPStan to get the technical debt: '.$commandcheck."\n";
 $output_arrtd = array();
 $resexectd = 0;
@@ -169,6 +172,8 @@ foreach (array('proj', 'dep') as $source) {
 	}
 }
 
+$timeend = time();
+
 
 /*
  * View
@@ -293,7 +298,7 @@ $html .= '<body>'."\n";
 $html .= '<header>'."\n";
 $html .= '<h1>Advanced Project Statistics</h1>'."\n";
 $currentDate = date("Y-m-d H:i:s"); // Format: Year-Month-Day Hour:Minute:Second
-$html .= '<span class="opacity">Generated on '.$currentDate.'</span>'."\n";
+$html .= '<span class="opacity">Generated on '.$currentDate.' in '.($timeend - $timestart).' seconds</span>'."\n";
 $html .= '</header>'."\n";
 
 $html .= '<section class="chapter" id="linesofcode">'."\n";
@@ -372,19 +377,24 @@ $html .= '<b>'.formatNumber($arraycocomo['proj']['people'] * $arraycocomo['proj'
 $html .= ' monthes people</b><br>';
 $html .= '</section>'."\n";
 
-$html .= '<section class="chapter" id="technicaldebt">'."\n";
-$html .= '<h2>Technical debt ('.count($output_arrtd).')</h2><br>'."\n";
-$html .= '<div class="div-table-responsive">'."\n";
-$html .= '<table class="list_technical_debt">'."\n";
-$html .= '<tr><td>File</td><td>Line</td><td>Type</td></tr>'."\n";
+$tmp = '';
+$nblines = 0;
 foreach ($output_arrtd as $line) {
 	$reg = array();
 	//print $line."\n";
 	preg_match('/^::error file=(.*),line=(\d+),col=(\d+)::(.*)$/', $line, $reg);
 	if (!empty($reg[1])) {
-		$html .= '<tr><td>'.$reg[1].'</td><td>'.$reg[2].'</td><td>'.$reg[4].'</td></tr>'."\n";
+		$tmp .= '<tr><td>'.$reg[1].'</td><td>'.$reg[2].'</td><td>'.$reg[4].'</td></tr>'."\n";
+		$nblines++;
 	}
 }
+
+$html .= '<section class="chapter" id="technicaldebt">'."\n";
+$html .= '<h2>Technical debt - PHPStan level '.$phpstanlevel.' ('.$nblines.')</h2><br>'."\n";
+$html .= '<div class="div-table-responsive">'."\n";
+$html .= '<table class="list_technical_debt">'."\n";
+$html .= '<tr><td>File</td><td>Line</td><td>Type</td></tr>'."\n";
+$html .= $tmp;
 $html .= '</table>';
 $html .= '</div>';
 $html .= '</section>'."\n";

+ 24 - 8
htdocs/salaries/class/salary.class.php

@@ -597,31 +597,47 @@ class Salary extends CommonObject
 	/**
 	 * 	Return amount of payments already done
 	 *
-	 *	@return		int		Amount of payment already done, <0 if KO
+	 *  @param 		int 			$multicurrency 		Return multicurrency_amount instead of amount. -1=Return both.
+	 *	@return		float|int|array						Amount of payment already done, <0 and set ->error if KO
 	 */
-	public function getSommePaiement()
+	public function getSommePaiement($multicurrency = 0)
 	{
 		$table = 'payment_salary';
 		$field = 'fk_salary';
 
 		$sql = "SELECT sum(amount) as amount";
+		//sum(multicurrency_amount) as multicurrency_amount		// Not yet supported
 		$sql .= " FROM ".MAIN_DB_PREFIX.$table;
 		$sql .= " WHERE ".$field." = ".((int) $this->id);
 
 		dol_syslog(get_class($this)."::getSommePaiement", LOG_DEBUG);
+
 		$resql = $this->db->query($sql);
 
 		if ($resql) {
-			$amount = 0;
-
 			$obj = $this->db->fetch_object($resql);
-			if ($obj) {
-				$amount = $obj->amount ? $obj->amount : 0;
-			}
 
 			$this->db->free($resql);
-			return $amount;
+
+			if ($obj) {
+				if ($multicurrency < 0) {
+					//$this->sumpayed = $obj->amount;
+					//$this->sumpayed_multicurrency = $obj->multicurrency_amount;
+					//return array('alreadypaid'=>(float) $obj->amount, 'alreadypaid_multicurrency'=>(float) $obj->multicurrency_amount);
+					return array();	// Not yet supported
+				} elseif ($multicurrency) {
+					//$this->sumpayed_multicurrency = $obj->multicurrency_amount;
+					//return (float) $obj->multicurrency_amount;
+					return -1;		// Not yet supported
+				} else {
+					//$this->sumpayed = $obj->amount;
+					return (float) $obj->amount;
+				}
+			} else {
+				return 0;
+			}
 		} else {
+			$this->error = $this->db->lasterror();
 			return -1;
 		}
 	}

+ 1 - 1
phpstan.neon

@@ -1,6 +1,6 @@
 parameters:
 	customRulesetUsed: true
-	level: 1
+	level: 2
 	fileExtensions:
 		- php
 	paths: