From f6fec506b18f20578f3c9ff37889461bcbc08ee3 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 20 Feb 2024 11:55:37 +0100 Subject: [PATCH] :bulb: Some PHPDoc hints on value types to pass to DBObject::Set --- core/attributedef.class.inc.php | 17 +++++++++++++---- core/dbobject.class.php | 5 +++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index daef7ac06..fa61300da 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -2695,6 +2695,11 @@ class AttributeObjectKey extends AttributeDBFieldVoid return ($proposedValue == 0); } + /** + * @inheritDoc + * + * @param int|DBObject $proposedValue Object key or valid ({@see MetaModel::IsValidObject()}) datamodel object + */ public function MakeRealValue($proposedValue, $oHostObj) { if (is_null($proposedValue)) @@ -2707,7 +2712,6 @@ class AttributeObjectKey extends AttributeDBFieldVoid } if (MetaModel::IsValidObject($proposedValue)) { - /** @var \DBObject $proposedValue */ return $proposedValue->GetKey(); } @@ -5940,6 +5944,11 @@ class AttributeDateTime extends AttributeDBField } } + /** + * @inheritDoc + * + * @param int|string $proposedValue timestamp ({@see DateTime::getTimestamp()) or date as string, following the {@see GetInternalFormat} format. + */ public function MakeRealValue($proposedValue, $oHostObj) { if (is_null($proposedValue)) @@ -7655,9 +7664,9 @@ class AttributeBlob extends AttributeDefinition } /** - * Users can provide the document from an URL (including an URL on iTop itself) - * for CSV import. Administrators can even provide the path to a local file - * {@inheritDoc} + * {@inheritDoc} + * + * @param string $proposedValue Can be an URL (including an URL to iTop itself), or a local path (CSV import) * * @see AttributeDefinition::MakeRealValue() */ diff --git a/core/dbobject.class.php b/core/dbobject.class.php index d4f2535cb..34aa86437 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -532,11 +532,10 @@ abstract class DBObject implements iDisplay * Attributes setter * * Set $sAttCode to $value. - * The value must be valid according to the type of attribute. + * The value must be valid according to the type of attribute : see the different {@see AttributeDefinition::MakeRealValue()} implementations * The value will not be recorded into the DB until DBObject::DBWrite() is called. * * @api - * @see DBWrite() * * @param string $sAttCode * @param mixed $value @@ -544,6 +543,8 @@ abstract class DBObject implements iDisplay * @return bool * @throws CoreException * @throws CoreUnexpectedValue + * + * @see DBWrite() */ public function Set($sAttCode, $value) {