From f2435fd1d0b54390158957a9c7948ccec3c566f2 Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Mon, 6 Jul 2015 22:53:41 +1000 Subject: [PATCH] Return `$this` from setter methods Summary: Return `$this` from setter methods for consistency. I started writing a [[https://secure.phabricator.com/differential/diff/32506/ | linter rule]] to detect this, but I don't think it is trivial to do this properly. Test Plan: Eyeball it. Reviewers: #blessed_reviewers, epriestley Reviewed By: #blessed_reviewers, epriestley Subscribers: epriestley, Korvin Differential Revision: https://secure.phabricator.com/D13422 --- .../aphlict/management/PhabricatorAphlictManagementWorkflow.php | 1 + .../differential/parser/DifferentialChangesetParser.php | 1 + src/applications/diviner/atom/DivinerAtom.php | 1 + src/applications/legalpad/editor/LegalpadDocumentEditor.php | 1 + src/applications/metamta/view/PhabricatorMetaMTAMailBody.php | 1 + src/applications/paste/view/PasteEmbedView.php | 1 + .../releeph/editor/ReleephRequestTransactionalEditor.php | 2 ++ .../releeph/field/specification/ReleephFieldSpecification.php | 1 + .../field/specification/ReleephLevelFieldSpecification.php | 1 + .../repository/engine/PhabricatorRepositoryRefEngine.php | 2 ++ .../search/engine/PhabricatorApplicationSearchEngine.php | 2 ++ .../standard/PhabricatorStandardCustomFieldPHIDs.php | 1 + 12 files changed, 15 insertions(+) diff --git a/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php b/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php index be5f6bae3c..7747a73866 100644 --- a/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php +++ b/src/applications/aphlict/management/PhabricatorAphlictManagementWorkflow.php @@ -88,6 +88,7 @@ abstract class PhabricatorAphlictManagementWorkflow final protected function setDebug($debug) { $this->debug = $debug; + return $this; } public static function requireExtensions() { diff --git a/src/applications/differential/parser/DifferentialChangesetParser.php b/src/applications/differential/parser/DifferentialChangesetParser.php index 6b5ea1c0de..b5e4545d85 100644 --- a/src/applications/differential/parser/DifferentialChangesetParser.php +++ b/src/applications/differential/parser/DifferentialChangesetParser.php @@ -257,6 +257,7 @@ final class DifferentialChangesetParser extends Phobject { $this->originalLeft = $left; $this->originalRight = $right; + return $this; } public function diffOriginals() { diff --git a/src/applications/diviner/atom/DivinerAtom.php b/src/applications/diviner/atom/DivinerAtom.php index 68a0d80cae..520a51e26b 100644 --- a/src/applications/diviner/atom/DivinerAtom.php +++ b/src/applications/diviner/atom/DivinerAtom.php @@ -370,6 +370,7 @@ final class DivinerAtom extends Phobject { public function setProperty($key, $value) { $this->properties[$key] = $value; + return $this; } public function getProperties() { diff --git a/src/applications/legalpad/editor/LegalpadDocumentEditor.php b/src/applications/legalpad/editor/LegalpadDocumentEditor.php index 27207a3aa2..5e319b5905 100644 --- a/src/applications/legalpad/editor/LegalpadDocumentEditor.php +++ b/src/applications/legalpad/editor/LegalpadDocumentEditor.php @@ -15,6 +15,7 @@ final class LegalpadDocumentEditor private function setIsContribution($is_contribution) { $this->isContribution = $is_contribution; + return $this; } private function isContribution() { diff --git a/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php b/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php index 3e0a6d9b1d..18d827f4c0 100644 --- a/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php +++ b/src/applications/metamta/view/PhabricatorMetaMTAMailBody.php @@ -20,6 +20,7 @@ final class PhabricatorMetaMTAMailBody extends Phobject { public function setViewer($viewer) { $this->viewer = $viewer; + return $this; } /* -( Composition )-------------------------------------------------------- */ diff --git a/src/applications/paste/view/PasteEmbedView.php b/src/applications/paste/view/PasteEmbedView.php index 650905c46c..e5121b496b 100644 --- a/src/applications/paste/view/PasteEmbedView.php +++ b/src/applications/paste/view/PasteEmbedView.php @@ -24,6 +24,7 @@ final class PasteEmbedView extends AphrontView { public function setLines($lines) { $this->lines = $lines; + return $this; } public function render() { diff --git a/src/applications/releeph/editor/ReleephRequestTransactionalEditor.php b/src/applications/releeph/editor/ReleephRequestTransactionalEditor.php index 17ae6fcc35..ecfa4c5b6b 100644 --- a/src/applications/releeph/editor/ReleephRequestTransactionalEditor.php +++ b/src/applications/releeph/editor/ReleephRequestTransactionalEditor.php @@ -302,6 +302,8 @@ final class ReleephRequestTransactionalEditor 'RQ'.$id)); break; } + + return $this; } } diff --git a/src/applications/releeph/field/specification/ReleephFieldSpecification.php b/src/applications/releeph/field/specification/ReleephFieldSpecification.php index c0cb64b05d..df458ced56 100644 --- a/src/applications/releeph/field/specification/ReleephFieldSpecification.php +++ b/src/applications/releeph/field/specification/ReleephFieldSpecification.php @@ -110,6 +110,7 @@ abstract class ReleephFieldSpecification $this->getRequiredStorageKey()); $this->validate($value); $this->setValue($value); + return $this; } diff --git a/src/applications/releeph/field/specification/ReleephLevelFieldSpecification.php b/src/applications/releeph/field/specification/ReleephLevelFieldSpecification.php index 7306067dc4..395636c983 100644 --- a/src/applications/releeph/field/specification/ReleephLevelFieldSpecification.php +++ b/src/applications/releeph/field/specification/ReleephLevelFieldSpecification.php @@ -118,6 +118,7 @@ abstract class ReleephLevelFieldSpecification pht("Unknown %s level name '%s'", $label, $name)); } $this->setValue($level); + return $this; } private $nameMap = array(); diff --git a/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php b/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php index 0eab00b5c9..3909cc83b0 100644 --- a/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php +++ b/src/applications/repository/engine/PhabricatorRepositoryRefEngine.php @@ -438,6 +438,8 @@ final class PhabricatorRepositoryRefEngine PhabricatorWorker::scheduleTask($class, $data); } } + + return $this; } diff --git a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php index e5eceee793..90123ee7c1 100644 --- a/src/applications/search/engine/PhabricatorApplicationSearchEngine.php +++ b/src/applications/search/engine/PhabricatorApplicationSearchEngine.php @@ -513,6 +513,8 @@ abstract class PhabricatorApplicationSearchEngine extends Phobject { PhabricatorProjectObjectHasProjectEdgeType::EDGECONST, $constraints); } + + return $this; } diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php index 82087bbaee..dc7ed2d1e4 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldPHIDs.php @@ -42,6 +42,7 @@ abstract class PhabricatorStandardCustomFieldPHIDs } } $this->setFieldValue($value); + return $this; } public function readApplicationSearchValueFromRequest( -- 2.51.2