diff --git a/core/relationgraph.class.inc.php b/core/relationgraph.class.inc.php index 14995ec0e..504e2107f 100644 --- a/core/relationgraph.class.inc.php +++ b/core/relationgraph.class.inc.php @@ -1,5 +1,5 @@ + + /** * Data structures (i.e. PHP classes) to build and use relation graphs * - * @copyright Copyright (C) 2015-2017 Combodo SARL + * @copyright Copyright (C) 2015-2018 Combodo SARL * @license http://opensource.org/licenses/AGPL-3.0 * */ @@ -38,8 +40,12 @@ class RelationObjectNode extends GraphNode } /** - * Make a normalized ID to ensure the uniqueness of such a node - */ + * Make a normalized ID to ensure the uniqueness of such a node + * + * @param string $oObject + * + * @return string + */ public static function MakeId($oObject) { return get_class($oObject).'::'.$oObject->GetKey(); @@ -47,7 +53,11 @@ class RelationObjectNode extends GraphNode /** * Formatting for GraphViz - */ + * + * @param bool $bNoLabel + * + * @return string + */ public function GetDotAttributes($bNoLabel = false) { $sDot = parent::GetDotAttributes(); @@ -76,7 +86,10 @@ class RelationObjectNode extends GraphNode /** * Recursively mark the objects nodes as reached, unless we get stopped by a redundancy node or a 'not allowed' node - */ + * + * @param string $sProperty + * @param $value + */ public function ReachDown($sProperty, $value) { if (is_null($this->GetProperty($sProperty)) && ($this->GetProperty($sProperty.'_allowed') !== false)) @@ -104,8 +117,15 @@ class RelationRedundancyNode extends GraphNode } /** - * Make a normalized ID to ensure the uniqueness of such a node - */ + * Make a normalized ID to ensure the uniqueness of such a node + * + * @param string $sRelCode + * @param string $sNeighbourId + * @param $oSourceObject + * @param \DBObject $oSinkObject + * + * @return string + */ public static function MakeId($sRelCode, $sNeighbourId, $oSourceObject, $oSinkObject) { return 'redundancy-'.$sRelCode.'-'.$sNeighbourId.'-'.get_class($oSinkObject).'::'.$oSinkObject->GetKey(); @@ -113,7 +133,11 @@ class RelationRedundancyNode extends GraphNode /** * Formatting for GraphViz - */ + * + * @param bool $bNoLabel + * + * @return string + */ public function GetDotAttributes($bNoLabel = false) { $sDisplayThreshold = sprintf('%.1f', $this->GetProperty('threshold')); @@ -123,7 +147,10 @@ class RelationRedundancyNode extends GraphNode /** * Recursively mark the objects nodes as reached, unless we get stopped by a redundancy node - */ + * + * @param string $sProperty + * @param $value + */ public function ReachDown($sProperty, $value) { $this->SetProperty($sProperty.'_count', $this->GetProperty($sProperty.'_count', 0) + 1); @@ -145,6 +172,16 @@ class RelationRedundancyNode extends GraphNode */ class RelationEdge extends GraphEdge { + /** + * RelationEdge constructor. + * + * @param \SimpleGraph $oGraph + * @param \GraphNode $oSourceNode + * @param \GraphNode $oSinkNode + * @param bool $bMustBeUnique + * + * @throws \SimpleGraphException + */ public function __construct(SimpleGraph $oGraph, GraphNode $oSourceNode, GraphNode $oSinkNode, $bMustBeUnique = false) { $sId = $oSourceNode->GetId().'-to-'.$oSinkNode->GetId(); @@ -182,7 +219,9 @@ class RelationGraph extends SimpleGraph /** * Add an object that will be the starting point for building the relations downstream - */ + * + * @param \DBObject $oObject + */ public function AddSourceObject(DBObject $oObject) { $oSourceNode = new RelationObjectNode($this, $oObject); @@ -192,22 +231,28 @@ class RelationGraph extends SimpleGraph /** * Add an object that will be the starting point for building the relations uptream - */ + * + * @param \DBObject $oObject + */ public function AddSinkObject(DBObject$oObject) { $oSinkNode = new RelationObjectNode($this, $oObject); $oSinkNode->SetProperty('sink', true); $this->aSinkNodes[$oSinkNode->GetId()] = $oSinkNode; } - + /** * Add a 'context' OQL query, specifying extra objects to be marked as 'is_reached' * even though they are not part of the sources. - * @param string $sOQL The OQL query defining the context objects + * + * @param string $key + * @param string $sOQL The OQL query defining the context objects + * + * @throws \Exception */ public function AddContextQuery($key, $sOQL) { - if ($sOQL === '') return; + if ($sOQL === '') { return;} $oSearch = static::MakeSearch($sOQL); $aAliases = $oSearch->GetSelectedClasses(); @@ -217,7 +262,6 @@ class RelationGraph extends SimpleGraph throw new Exception("Invalid context query '$sOQL'. A context query must contain at least two columns. Columns: ".implode(', ', $aAliases).'. '); } $aAliasNames = array_keys($aAliases); - $sClassAlias = $oSearch->GetClassAlias(); $oCondition = new BinaryExpression(new FieldExpression('id', $aAliasNames[0]), '=', new VariableExpression('id')); $oSearch->AddConditionExpression($oCondition); @@ -228,11 +272,14 @@ class RelationGraph extends SimpleGraph } $this->aContextSearches[$sClass][] = array('key' => $key, 'search' => $oSearch); } - + /** * Determines if the given DBObject is part of a 'context' + * * @param DBObject $oObj + * * @return boolean + * @throws \CoreException */ public function IsPartOfContext(DBObject $oObj, &$aRootCauses) { @@ -271,7 +318,15 @@ class RelationGraph extends SimpleGraph /** * Build the graph downstream, and mark the nodes that can be reached from the source node - */ + * + * @param string $sRelCode + * @param int $iMaxDepth + * @param bool $bEnableRedundancy + * @param array $aUnreachableObjects + * + * @throws \CoreException + * @throws \Exception + */ public function ComputeRelatedObjectsDown($sRelCode, $iMaxDepth, $bEnableRedundancy, $aUnreachableObjects = array()) { //echo "