From c1a8b83bd7ea3951f4daef2e678d5f77a62ad6f5 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Thu, 16 May 2024 16:41:44 +0200 Subject: [PATCH] Correct PHPDoc or add default return for numerous methods Summary: Correct PHPDoc when none of the method calls try to handle a return value. Add missing fallback `return` statements (which may never be reached if previous condition checks were always true). This reduces the amount of errors reported by static code analysis tools. Test Plan: Carefully read the code and check all places in which a function gets called whether a return value is expected. Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Differential Revision: https://we.phorge.it/D25650 --- src/aphront/configuration/AphrontApplicationConfiguration.php | 1 + src/applications/people/storage/PhabricatorUserEmail.php | 1 - src/applications/phame/storage/PhamePost.php | 1 + src/infrastructure/daemon/workers/PhabricatorWorker.php | 1 - src/infrastructure/edges/editor/PhabricatorEdgeEditor.php | 1 - support/startup/PhabricatorStartup.php | 1 - 6 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/aphront/configuration/AphrontApplicationConfiguration.php b/src/aphront/configuration/AphrontApplicationConfiguration.php index 3bdd2c00bc..3198bb9fd4 100644 --- a/src/aphront/configuration/AphrontApplicationConfiguration.php +++ b/src/aphront/configuration/AphrontApplicationConfiguration.php @@ -523,6 +523,7 @@ final class AphrontApplicationConfiguration return array($result->getController(), $result->getURIData()); } } + return null; } private function buildSiteForRequest(AphrontRequest $request) { diff --git a/src/applications/people/storage/PhabricatorUserEmail.php b/src/applications/people/storage/PhabricatorUserEmail.php index d9866f2c43..47c2911601 100644 --- a/src/applications/people/storage/PhabricatorUserEmail.php +++ b/src/applications/people/storage/PhabricatorUserEmail.php @@ -231,7 +231,6 @@ final class PhabricatorUserEmail * * @param PhabricatorUser The user sending the notification. * @param PhabricatorUserEmail New primary email address. - * @return this * @task email */ public function sendOldPrimaryEmail( diff --git a/src/applications/phame/storage/PhamePost.php b/src/applications/phame/storage/PhamePost.php index 5291bcd465..9b4a6ba01a 100644 --- a/src/applications/phame/storage/PhamePost.php +++ b/src/applications/phame/storage/PhamePost.php @@ -268,6 +268,7 @@ final class PhamePost extends PhameDAO case self::MARKUP_FIELD_BODY: return $this->getBody(); } + return null; } public function didMarkupText( diff --git a/src/infrastructure/daemon/workers/PhabricatorWorker.php b/src/infrastructure/daemon/workers/PhabricatorWorker.php index c62fde447f..2b1e650485 100644 --- a/src/infrastructure/daemon/workers/PhabricatorWorker.php +++ b/src/infrastructure/daemon/workers/PhabricatorWorker.php @@ -262,7 +262,6 @@ abstract class PhabricatorWorker extends Phobject { * you are using queues to improve locking behavior). * * @param map Optional default options. - * @return this */ final public function flushTaskQueue($defaults = array()) { foreach ($this->getQueuedTasks() as $task) { diff --git a/src/infrastructure/edges/editor/PhabricatorEdgeEditor.php b/src/infrastructure/edges/editor/PhabricatorEdgeEditor.php index 588b5267b4..d019c7d0fe 100644 --- a/src/infrastructure/edges/editor/PhabricatorEdgeEditor.php +++ b/src/infrastructure/edges/editor/PhabricatorEdgeEditor.php @@ -90,7 +90,6 @@ final class PhabricatorEdgeEditor extends Phobject { * (e.g., adds followed by removals) if their outcomes are not dependent, * since transactions will not be held open as long. * - * @return this * @task edit */ public function save() { diff --git a/support/startup/PhabricatorStartup.php b/support/startup/PhabricatorStartup.php index 10c6295587..2ae5993dfb 100644 --- a/support/startup/PhabricatorStartup.php +++ b/support/startup/PhabricatorStartup.php @@ -317,7 +317,6 @@ final class PhabricatorStartup { * @param Throwable The exception itself. * @param bool True if it's okay to show the exception's stack trace * to the user. The trace will always be logged. - * @return exit This method **does not return**. * * @task apocalypse */