N°8772 - Compiler: Add errors check

This commit is contained in:
Eric Espie
2025-12-11 12:16:14 +01:00
parent 94fed54529
commit 41d15f1b33
9 changed files with 202 additions and 31 deletions

View File

@@ -16,13 +16,14 @@ use utils;
*/
abstract class AbstractProperty
{
protected ?AbstractProperty $oParent;
protected string $sId;
protected ?string $sLabel;
/** @var array<AbstractProperty> */
protected array $aChildren = [];
protected ?AbstractValueType $oValueType;
protected ?string $sParentId;
protected ?string $sIdWithPath;
/**
* Init property tree node from xml dom node
@@ -34,14 +35,15 @@ abstract class AbstractProperty
* @throws \DOMFormatException
* @throws \Combodo\iTop\PropertyTree\PropertyTreeException
*/
public function InitFromDomNode(DesignElement $oDomNode, string $sParentId = ''): void
public function InitFromDomNode(DesignElement $oDomNode, ?AbstractProperty $oParent = null): void
{
if (utils::IsNotNullOrEmptyString($sParentId)) {
$this->sId = $sParentId.'__';
$this->oParent = $oParent;
$this->sId = $oDomNode->getAttribute('id');
if (is_null($oParent)) {
$this->sIdWithPath = $this->sId;
} else {
$this->sId = '';
$this->sIdWithPath = $oParent->sIdWithPath.'__'.$this->sId;
}
$this->sId .= $oDomNode->getAttribute('id');
$this->sLabel = $oDomNode->GetChildText('label');
}
@@ -61,4 +63,19 @@ abstract class AbstractProperty
{
return $this->aChildren;
}
public function GetSibling(string $sId): ?AbstractProperty
{
if (is_null($this->oParent)) {
return null;
}
foreach ($this->oParent->GetChildren() as $oSibling) {
if ($oSibling->sId == $sId) {
return $oSibling;
}
}
return null;
}
}