From 067b3364ee872ef97b280ea62c2b381eab59df6c Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 2 Jan 2018 14:20:02 +0000 Subject: [PATCH] Add some PHPDoc, fix some syntax (thanks to SonarLint !) SVN:trunk[5188] --- application/displayblock.class.inc.php | 35 +++++++++++++++++++++++--- core/dbsearch.class.php | 32 +++++++++++++++-------- core/oql/oqlinterpreter.class.inc.php | 1 + core/oql/oqlquery.class.inc.php | 8 +++--- 4 files changed, 58 insertions(+), 18 deletions(-) diff --git a/application/displayblock.class.inc.php b/application/displayblock.class.inc.php index 8e7915e4b..3b22de966 100644 --- a/application/displayblock.class.inc.php +++ b/application/displayblock.class.inc.php @@ -43,6 +43,7 @@ require_once(APPROOT.'/application/utils.inc.php'); class DisplayBlock { const TAG_BLOCK = 'itopblock'; + /** @var \DBSearch */ protected $m_oFilter; protected $m_aConditions; // Conditions added to the filter -> avoid duplicate conditions protected $m_sStyle; @@ -74,10 +75,17 @@ class DisplayBlock { return $this->m_oFilter; } + /** * Constructs a DisplayBlock object from a DBObjectSet already in memory - * @param $oSet DBObjectSet + * + * @param DBObjectSet $oSet + * @param string $sStyle + * @param array $aParams + * * @return DisplayBlock The DisplayBlock object, or null if the creation failed + * @throws \CoreException + * @throws \Exception */ public static function FromObjectSet(DBObjectSet $oSet, $sStyle, $aParams = array()) { @@ -1104,10 +1112,19 @@ EOF } return $sHtml; } - + /** * Add a condition (restriction) to the current DBSearch on which the display block is based * taking into account the hierarchical keys for which the condition is based on the 'below' operator + * + * @param string $sFilterCode + * @param array $condition + * @param string $sOpCode + * @param bool $bParseSearchString + * + * @throws \CoreException + * @throws \CoreWarning + * @throws \Exception */ protected function AddCondition($sFilterCode, $condition, $sOpCode = null, $bParseSearchString = false) { @@ -1336,15 +1353,25 @@ EOF * For backward compatibility 'popup' is equivalent to 'list'... */ class MenuBlock extends DisplayBlock -{ +{ /** * Renders the "Actions" popup menu for the given set of objects - * + * * Note that the menu links containing (or ending) with a hash (#) will have their fragment * part (whatever is after the hash) dynamically replaced (by javascript) when the menu is * displayed, to correspond to the current hash/fragment in the page. This allows modifying * an object in with the same tab active by default as the tab that was active when selecting * the "Modify..." action. + * + * @param \WebPage $oPage + * @param array $aExtraParams + * @param string $sId + * + * @return string + * @throws \DictExceptionMissingString + * @throws \Exception + * @throws \MissingQueryArgument + * @throws \MySQLException */ public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), $sId) { diff --git a/core/dbsearch.class.php b/core/dbsearch.class.php index e4880aff7..4b247d90c 100644 --- a/core/dbsearch.class.php +++ b/core/dbsearch.class.php @@ -294,7 +294,10 @@ abstract class DBSearch */ static public function FromOQL($sQuery, $aParams = null) { - if (empty($sQuery)) return null; + if (empty($sQuery)) + { + return null; + } // Query caching $sQueryId = md5($sQuery); @@ -366,7 +369,10 @@ abstract class DBSearch { $sSQL = $this->MakeSelectQuery($aOrderBy, $aArgs); $resQuery = CMDBSource::Query($sSQL); - if (!$resQuery) return; + if (!$resQuery) + { + return; + } if (count($aColumns) == 0) { @@ -682,7 +688,10 @@ abstract class DBSearch public static function RecordQueryTrace() { - if (!self::$m_bTraceQueries) return; + if (!self::$m_bTraceQueries) + { + return; + } $iOqlCount = count(self::$m_aQueriesLog); $iSqlCount = 0; @@ -720,6 +729,7 @@ abstract class DBSearch { // Merge the new queries into the existing log include($sAllQueries); + $aQueriesLog = array(); foreach (self::$m_aQueriesLog as $sQueryId => $aOqlData) { if (!array_key_exists($sQueryId, $aQueriesLog)) @@ -738,7 +748,10 @@ abstract class DBSearch protected static function DbgTrace($value) { - if (!self::$m_bDebugQuery) return; + if (!self::$m_bDebugQuery) + { + return; + } $aBacktrace = debug_backtrace(); $iCallStackPos = count($aBacktrace) - self::$m_bDebugQuery; $sIndent = ""; @@ -754,11 +767,7 @@ abstract class DBSearch $sCallers = "Callstack: ".implode(', ', $aCallers); $sFunction = "".$aBacktrace[1]["function"].""; - if (is_string($value)) - { - echo "$sIndent$sFunction: $value
\n"; - } - else if (is_object($value)) + if (is_object($value)) { echo "$sIndent$sFunction:\n
\n";
 			print_r($value);
@@ -814,7 +823,10 @@ abstract class DBSearch
 			$aUpdates = array();
 			foreach (MetaModel::EnumParentClasses($sFinalClass, ENUM_PARENT_CLASSES_ALL) as $sParentClass)
 			{
-				if (!MetaModel::IsValidAttCode($sParentClass, 'archive_flag')) continue;
+				if (!MetaModel::IsValidAttCode($sParentClass, 'archive_flag'))
+				{
+					continue;
+				}
 
 				$sTable = MetaModel::DBGetTable($sParentClass);
 				$aUpdates[] = "`$sTable`.`archive_flag` = $iFlag";
diff --git a/core/oql/oqlinterpreter.class.inc.php b/core/oql/oqlinterpreter.class.inc.php
index 14e38a858..d59c4bb50 100644
--- a/core/oql/oqlinterpreter.class.inc.php
+++ b/core/oql/oqlinterpreter.class.inc.php
@@ -85,6 +85,7 @@ class OqlInterpreter
 
 	/**
 	 * @return OqlQuery
+	 * @throws \OQLException
 	 */
 	public function ParseQuery()
 	{
diff --git a/core/oql/oqlquery.class.inc.php b/core/oql/oqlquery.class.inc.php
index 8aa3ab14a..b0bff7db6 100644
--- a/core/oql/oqlquery.class.inc.php
+++ b/core/oql/oqlquery.class.inc.php
@@ -283,10 +283,10 @@ abstract class OqlQuery
 	/**
 	 * Check the validity of the expression with regard to the data model
 	 * and the query in which it is used
-	 * 	 	 
-	 * @param ModelReflection $oModelReflection MetaModel to consider	 	
-	 * @throws OqlNormalizeException
-	 */	 	
+	 *
+	 * @param ModelReflection $oModelReflection MetaModel to consider
+	 * @param string $sSourceQuery
+	 */
 	abstract public function Check(ModelReflection $oModelReflection, $sSourceQuery);
 
 	/**