From 5cb2f19ea04cb9c2bef6dc3f1d1d2336a396f332 Mon Sep 17 00:00:00 2001 From: Molkobain Date: Tue, 20 Dec 2022 10:55:56 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B04756=20-=20Improve=20PHPDoc=20and=20type?= =?UTF-8?q?=20hints?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/cmdbabstract.class.inc.php | 81 +++++++++++++--------- core/dbobject.class.php | 95 ++++++++++++++++++++++---- 2 files changed, 129 insertions(+), 47 deletions(-) diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 4f4145a4a..f0b9e11f4 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -5644,115 +5644,124 @@ JS } /** - * @return void + * @inheritDoc * @throws \CoreException */ - final protected function EventInsertRequested() + final protected function EventInsertRequested(): void { $this->FireEvent(EVENT_SERVICE_DB_INSERT_REQUESTED); } /** - * @return void + * @inheritDoc * @throws \CoreException */ - final protected function EventInsertBefore() + final protected function EventInsertBefore(): void { $this->FireEvent(EVENT_SERVICE_DB_ABOUT_TO_INSERT); } /** - * @return void + * @inheritDoc * @throws \CoreException */ - final protected function EventInsertAfter() + final protected function EventInsertAfter(): void { $this->FireEvent(EVENT_SERVICE_DB_INSERT_DONE); } - final protected function EventComputeValues() + /** + * @inheritDoc + * @throws \CoreException + */ + final protected function EventComputeValues(): void { $this->FireEvent(EVENT_SERVICE_DB_COMPUTE_VALUES); } /** - * @return void + * @inheritDoc * @throws \CoreException */ - final protected function EventCheckToWrite() + final protected function EventCheckToWrite(): void { $this->FireEvent(EVENT_SERVICE_DB_CHECK_TO_WRITE); } /** - * @return void + * @inheritDoc * @throws \CoreException */ - final protected function EventCheckToDelete() + final protected function EventCheckToDelete(): void { $this->FireEvent(EVENT_SERVICE_DB_CHECK_TO_DELETE); } /** - * @return void + * @inheritDoc * @throws \CoreException */ - final protected function EventUpdateRequested() + final protected function EventUpdateRequested(): void { $this->FireEvent(EVENT_SERVICE_DB_UPDATE_REQUESTED); } /** - * @return void + * @inheritDoc * @throws \CoreException */ - final protected function EventUpdateBefore() + final protected function EventUpdateBefore(): void { $this->FireEvent(EVENT_SERVICE_DB_ABOUT_TO_UPDATE); } /** - * @param array $aEventData - * - * @return void + * @inheritDoc * @throws \CoreException */ - final protected function EventUpdateAfter(array $aEventData) + final protected function EventUpdateAfter(array $aEventData): void { $this->FireEvent(EVENT_SERVICE_DB_UPDATE_DONE, $aEventData); } /** - * @return void + * @inheritDoc * @throws \CoreException */ - final protected function EventDeleteBefore() + final protected function EventDeleteBefore(): void { $this->FireEvent(EVENT_SERVICE_DB_ABOUT_TO_DELETE); } /** - * @return void + * @inheritDoc * @throws \CoreException */ - final protected function EventDeleteAfter() + final protected function EventDeleteAfter(): void { $this->FireEvent(EVENT_SERVICE_DB_DELETE_DONE); } - - final protected function EventArchive() + /** + * @inheritDoc + * @throws \CoreException + */ + final protected function EventArchive(): void { $this->FireEvent(EVENT_SERVICE_DB_ARCHIVE); } - final protected function EventUnarchive() + /** + * @inheritDoc + * @throws \CoreException + */ + final protected function EventUnarchive(): void { $this->FireEvent(EVENT_SERVICE_DB_UNARCHIVE); } /** - * Append attribute flags + * Append $iFlags to $sAttCode attribute in $sTargetState * * @param string $sAttCode * @param int $iFlags @@ -5762,7 +5771,7 @@ JS * @return void * @since 3.1.0 */ - final public function AddAttributeFlags(string $sAttCode, int $iFlags, string $sTargetState = '', string $sReason = null) + final public function AddAttributeFlags(string $sAttCode, int $iFlags, string $sTargetState = '', string $sReason = null): void { if (!isset($this->aAttributesFlags[$sTargetState])) { $this->aAttributesFlags[$sTargetState] = []; @@ -5774,7 +5783,7 @@ JS } /** - * Force attribute state + * Force $iFlags to $sAttCode attribute in $sTargetState * * @param string $sAttCode * @param int $iFlags @@ -5784,7 +5793,7 @@ JS * @return void * @since 3.1.0 */ - final public function ForceAttributeFlags(string $sAttCode, int $iFlags, string $sTargetState = '', string $sReason = null) + final public function ForceAttributeFlags(string $sAttCode, int $iFlags, string $sTargetState = '', string $sReason = null): void { if (!isset($this->aAttributesFlags[$sTargetState])) { $this->aAttributesFlags[$sTargetState] = []; @@ -5795,6 +5804,10 @@ JS } } + /** + * @inheritDoc + * @throws \CoreException + */ final protected function GetExtensionsAttributeFlags(string $sAttCode, array &$aReasons, string $sTargetState): int { if (!isset($this->aAttributesFlags[$sTargetState])) { @@ -5812,7 +5825,7 @@ JS /** - * Append attribute flags + * Append $iFlags to $sAttCode attribute in initial state * * @param string $sAttCode * @param int $iFlags @@ -5833,7 +5846,7 @@ JS } /** - * Force attribute state + * Force $iFlags to $sAttCode attribute in initial state * * @param string $sAttCode * @param int $iFlags @@ -5853,6 +5866,10 @@ JS } } + /** + * @inheritDoc + * @throws \CoreException + */ final protected function GetExtensionsInitialStateAttributeFlags(string $sAttCode, array &$aReasons): int { if (!isset($this->aInitialAttributesFlags)) { diff --git a/core/dbobject.class.php b/core/dbobject.class.php index b567fa601..d129feec6 100644 --- a/core/dbobject.class.php +++ b/core/dbobject.class.php @@ -5844,13 +5844,15 @@ abstract class DBObject implements iDisplay } /** - * @param $sEvent + * @param string $sEvent * @param array $aEventData + * @return void * * @throws \CoreException * @throws \Exception + * @since 3.1.0 */ - public function FireEvent($sEvent, $aEventData = array()) + public function FireEvent(string $sEvent, array $aEventData = array()): void { if (EventService::IsEventRegistered($sEvent)) { $aEventData['debug_info'] = 'from: '.get_class($this).':'.$this->GetKey(); @@ -5863,64 +5865,127 @@ abstract class DBObject implements iDisplay } } - protected function EventInsertRequested() + /** + * @return void + * @since 3.1.0 + */ + protected function EventInsertRequested(): void { } - protected function EventInsertBefore() + /** + * @return void + * @since 3.1.0 + */ + protected function EventInsertBefore(): void { } - protected function EventInsertAfter() + protected function EventInsertAfter(): void { } - protected function EventComputeValues() + /** + * @return void + * @since 3.1.0 + */ + protected function EventComputeValues(): void { } - protected function EventCheckToWrite() + /** + * @return void + * @since 3.1.0 + */ + protected function EventCheckToWrite(): void { } - protected function EventCheckToDelete() + /** + * @return void + * @since 3.1.0 + */ + protected function EventCheckToDelete(): void { } - protected function EventUpdateRequested() + /** + * @return void + * @since 3.1.0 + */ + protected function EventUpdateRequested(): void { } - protected function EventUpdateBefore() + /** + * @return void + * @since 3.1.0 + */ + protected function EventUpdateBefore(): void { } - protected function EventUpdateAfter(array $aEventData) + /** + * @return void + * @since 3.1.0 + */ + protected function EventUpdateAfter(array $aEventData): void { } - protected function EventDeleteBefore() + /** + * @return void + * @since 3.1.0 + */ + protected function EventDeleteBefore(): void { } - protected function EventDeleteAfter() + /** + * @return void + * @since 3.1.0 + */ + protected function EventDeleteAfter(): void { } - protected function EventArchive() + /** + * @return void + * @since 3.1.0 + */ + protected function EventArchive(): void { } - protected function EventUnarchive() + /** + * @return void + * @since 3.1.0 + */ + protected function EventUnarchive(): void { } + /** + * @param string $sAttCode + * @param array $aReasons + * @param string $sTargetState + * + * @return int + * @since 3.1.0 + */ protected function GetExtensionsAttributeFlags(string $sAttCode, array &$aReasons, string $sTargetState): int { return 0; } + /** + * @param string $sAttCode + * @param array $aReasons + * + * @return int + * @since 3.1.0 + */ protected function GetExtensionsInitialStateAttributeFlags(string $sAttCode, array &$aReasons): int { return 0;