From 8813c7be0e39a4727dd9a0dc833223a433380ebc Mon Sep 17 00:00:00 2001 From: vrana Date: Tue, 3 Apr 2012 12:10:45 -0700 Subject: [PATCH] Use assert_instances_of() everywhere but Differential and Diffusion Summary: NOTE: This is not produced by a script so there might be errors. Please review carefully. Test Plan: Browse around. Reviewers: epriestley Reviewed By: epriestley CC: aran Differential Revision: https://secure.phabricator.com/D2091 --- .../editor/comment/PhabricatorAuditCommentEditor.php | 4 ++++ .../commitlist/PhabricatorAuditCommitListView.php | 2 ++ .../audit/view/list/PhabricatorAuditListView.php | 3 +++ .../log/PhabricatorConduitLogController.php | 3 +++ ...uitAPI_differential_parsecommitmessage_Method.php | 1 + .../ConduitAPI_diffusion_getcommits_Method.php | 1 + .../maniphest/base/ConduitAPI_maniphest_Method.php | 1 + .../project/base/ConduitAPI_project_Method.php | 1 + .../PhabricatorDaemonLogEventsView.php | 1 + .../daemonloglist/PhabricatorDaemonLogListView.php | 1 + .../daemon/view/daemonloglist/__init__.php | 1 + .../editor/revision/DifferentialRevisionEditor.php | 1 + .../DifferentialRevisionDetailView.php | 1 + .../main/PhabricatorDirectoryMainController.php | 11 ++++++++--- .../feed/builder/feed/PhabricatorFeedBuilder.php | 1 + .../feed/story/base/PhabricatorFeedStory.php | 1 + .../flag/view/list/PhabricatorFlagListView.php | 1 + src/applications/flag/view/list/__init__.php | 1 + .../herald/adapter/commit/HeraldCommitAdapter.php | 1 + .../herald/adapter/dryrun/HeraldDryRunAdapter.php | 1 + src/applications/herald/adapter/dryrun/__init__.php | 2 ++ .../herald/engine/engine/HeraldEngine.php | 3 +++ src/applications/herald/storage/rule/HeraldRule.php | 7 +++++++ .../view/edithistory/HeraldRuleEditHistoryView.php | 1 + .../herald/view/rulelist/HeraldRuleListView.php | 2 ++ src/applications/herald/view/rulelist/__init__.php | 1 + .../controller/report/ManiphestReportController.php | 2 +- .../transaction/ManiphestTransactionEditor.php | 9 ++++++++- .../maniphest/query/ManiphestTaskQuery.php | 1 + .../view/tasklist/ManiphestTaskListView.php | 2 ++ .../maniphest/view/tasklist/__init__.php | 2 ++ .../view/taskprojects/ManiphestTaskProjectsView.php | 1 + .../view/tasksummary/ManiphestTaskSummaryView.php | 1 + .../ManiphestTransactionDetailView.php | 3 +++ .../transactionlist/ManiphestTransactionListView.php | 3 +++ .../maniphest/view/transactionlist/__init__.php | 2 ++ .../base/PhabricatorMailReplyHandler.php | 3 +++ .../metamta/storage/mail/PhabricatorMetaMTAMail.php | 2 ++ .../list/PhabricatorOwnersListController.php | 1 + .../owners/storage/owner/PhabricatorOwnersOwner.php | 1 + .../controller/diff/PhrictionDiffController.php | 1 + .../profile/PhabricatorProjectProfileController.php | 1 + .../editor/project/PhabricatorProjectEditor.php | 1 + .../project/storage/project/PhabricatorProject.php | 1 + .../storage/commit/PhabricatorRepositoryCommit.php | 2 ++ ...habricatorRepositoryCommitMessageParserWorker.php | 2 ++ .../PhabricatorRepositoryCommitHeraldWorker.php | 1 + .../poll/PhabricatorSlowvotePollController.php | 12 ++++++++++++ .../PhabricatorObjectSelectorDialog.php | 1 + src/view/control/objectselector/__init__.php | 1 + 50 files changed, 105 insertions(+), 5 deletions(-) diff --git a/src/applications/audit/editor/comment/PhabricatorAuditCommentEditor.php b/src/applications/audit/editor/comment/PhabricatorAuditCommentEditor.php index 2fa6cd5764..aa990e2ff0 100644 --- a/src/applications/audit/editor/comment/PhabricatorAuditCommentEditor.php +++ b/src/applications/audit/editor/comment/PhabricatorAuditCommentEditor.php @@ -257,6 +257,9 @@ final class PhabricatorAuditCommentEditor { PhabricatorAuditComment $comment, array $other_comments, array $inline_comments) { + assert_instances_of($other_comments, 'PhabricatorAuditComment'); + assert_instances_of($inline_comments, 'PhabricatorAuditInlineComment'); + $commit = $this->commit; $data = $commit->loadCommitData(); @@ -347,6 +350,7 @@ final class PhabricatorAuditCommentEditor { PhabricatorObjectHandle $handle, PhabricatorMailReplyHandler $reply_handler, array $inline_comments) { + assert_instances_of($inline_comments, 'PhabricatorAuditInlineComment'); $commit = $this->commit; $user = $this->user; diff --git a/src/applications/audit/view/commitlist/PhabricatorAuditCommitListView.php b/src/applications/audit/view/commitlist/PhabricatorAuditCommitListView.php index 58be5cbbdc..715293c32a 100644 --- a/src/applications/audit/view/commitlist/PhabricatorAuditCommitListView.php +++ b/src/applications/audit/view/commitlist/PhabricatorAuditCommitListView.php @@ -34,11 +34,13 @@ final class PhabricatorAuditCommitListView extends AphrontView { } public function setCommits(array $commits) { + assert_instances_of($commits, 'PhabricatorRepositoryCommit'); $this->commits = $commits; return $this; } public function setHandles(array $handles) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } diff --git a/src/applications/audit/view/list/PhabricatorAuditListView.php b/src/applications/audit/view/list/PhabricatorAuditListView.php index b98a016bac..8df1a80727 100644 --- a/src/applications/audit/view/list/PhabricatorAuditListView.php +++ b/src/applications/audit/view/list/PhabricatorAuditListView.php @@ -27,11 +27,13 @@ final class PhabricatorAuditListView extends AphrontView { private $showDescriptions = true; public function setAudits(array $audits) { + assert_instances_of($audits, 'PhabricatorRepositoryAuditRequest'); $this->audits = $audits; return $this; } public function setHandles(array $handles) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } @@ -51,6 +53,7 @@ final class PhabricatorAuditListView extends AphrontView { } public function setCommits(array $commits) { + assert_instances_of($commits, 'PhabricatorRepositoryCommit'); $this->commits = mpull($commits, null, 'getPHID'); return $this; } diff --git a/src/applications/conduit/controller/log/PhabricatorConduitLogController.php b/src/applications/conduit/controller/log/PhabricatorConduitLogController.php index 009c372cdf..7734c5c38b 100644 --- a/src/applications/conduit/controller/log/PhabricatorConduitLogController.php +++ b/src/applications/conduit/controller/log/PhabricatorConduitLogController.php @@ -67,6 +67,9 @@ final class PhabricatorConduitLogController } private function renderCallTable(array $calls, array $conns) { + assert_instances_of($calls, 'PhabricatorConduitMethodCallLog'); + assert_instances_of($conns, 'PhabricatorConduitConnectionLog'); + $user = $this->getRequest()->getUser(); $rows = array(); diff --git a/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php b/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php index 0785e28cc0..a25d977652 100644 --- a/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php +++ b/src/applications/conduit/method/differential/parsecommitmessage/ConduitAPI_differential_parsecommitmessage_Method.php @@ -96,6 +96,7 @@ final class ConduitAPI_differential_parsecommitmessage_Method } private function buildLabelMap(array $aux_fields) { + assert_instances_of($aux_fields, 'DifferentialFieldSpecification'); $label_map = array(); foreach ($aux_fields as $key => $aux_field) { $labels = $aux_field->getSupportedCommitMessageLabels(); diff --git a/src/applications/conduit/method/diffusion/getcommits/ConduitAPI_diffusion_getcommits_Method.php b/src/applications/conduit/method/diffusion/getcommits/ConduitAPI_diffusion_getcommits_Method.php index f6f228e162..3147edf992 100644 --- a/src/applications/conduit/method/diffusion/getcommits/ConduitAPI_diffusion_getcommits_Method.php +++ b/src/applications/conduit/method/diffusion/getcommits/ConduitAPI_diffusion_getcommits_Method.php @@ -156,6 +156,7 @@ final class ConduitAPI_diffusion_getcommits_Method * Retrieve primary commit information for all referenced commits. */ private function queryCommitInformation(array $commits, array $repos) { + assert_instances_of($repos, 'PhabricatorRepository'); $conn_r = id(new PhabricatorRepositoryCommit())->establishConnection('r'); $repos = mpull($repos, null, 'getID'); diff --git a/src/applications/conduit/method/maniphest/base/ConduitAPI_maniphest_Method.php b/src/applications/conduit/method/maniphest/base/ConduitAPI_maniphest_Method.php index 48c7d947a6..517caae2cb 100644 --- a/src/applications/conduit/method/maniphest/base/ConduitAPI_maniphest_Method.php +++ b/src/applications/conduit/method/maniphest/base/ConduitAPI_maniphest_Method.php @@ -172,6 +172,7 @@ abstract class ConduitAPI_maniphest_Method extends ConduitAPIMethod { } protected function buildTaskInfoDictionaries(array $tasks) { + assert_instances_of($tasks, 'ManiphestTask'); if (!$tasks) { return array(); } diff --git a/src/applications/conduit/method/project/base/ConduitAPI_project_Method.php b/src/applications/conduit/method/project/base/ConduitAPI_project_Method.php index ca3d642828..a5762bcaa7 100644 --- a/src/applications/conduit/method/project/base/ConduitAPI_project_Method.php +++ b/src/applications/conduit/method/project/base/ConduitAPI_project_Method.php @@ -27,6 +27,7 @@ abstract class ConduitAPI_project_Method extends ConduitAPIMethod { } protected function buildProjectInfoDictionaries(array $projects) { + assert_instances_of($projects, 'PhabricatorProject'); if (!$projects) { return array(); } diff --git a/src/applications/daemon/view/daemonlogevents/PhabricatorDaemonLogEventsView.php b/src/applications/daemon/view/daemonlogevents/PhabricatorDaemonLogEventsView.php index c33b5f746d..ba55442742 100644 --- a/src/applications/daemon/view/daemonlogevents/PhabricatorDaemonLogEventsView.php +++ b/src/applications/daemon/view/daemonlogevents/PhabricatorDaemonLogEventsView.php @@ -23,6 +23,7 @@ final class PhabricatorDaemonLogEventsView extends AphrontView { private $user; public function setEvents(array $events) { + assert_instances_of($events, 'PhabricatorDaemonLogEvent'); $this->events = $events; return $this; } diff --git a/src/applications/daemon/view/daemonloglist/PhabricatorDaemonLogListView.php b/src/applications/daemon/view/daemonloglist/PhabricatorDaemonLogListView.php index 02ae2b4557..8c637fb95c 100644 --- a/src/applications/daemon/view/daemonloglist/PhabricatorDaemonLogListView.php +++ b/src/applications/daemon/view/daemonloglist/PhabricatorDaemonLogListView.php @@ -22,6 +22,7 @@ final class PhabricatorDaemonLogListView extends AphrontView { private $user; public function setDaemonLogs(array $daemon_logs) { + assert_instances_of($daemon_logs, 'PhabricatorDaemonLog'); $this->daemonLogs = $daemon_logs; return $this; } diff --git a/src/applications/daemon/view/daemonloglist/__init__.php b/src/applications/daemon/view/daemonloglist/__init__.php index c476f15cd3..982400ce70 100644 --- a/src/applications/daemon/view/daemonloglist/__init__.php +++ b/src/applications/daemon/view/daemonloglist/__init__.php @@ -12,6 +12,7 @@ phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/utils'); phutil_require_module('phutil', 'markup'); +phutil_require_module('phutil', 'utils'); phutil_require_source('PhabricatorDaemonLogListView.php'); diff --git a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php index f7b2b1889c..2e2a4899b5 100644 --- a/src/applications/differential/editor/revision/DifferentialRevisionEditor.php +++ b/src/applications/differential/editor/revision/DifferentialRevisionEditor.php @@ -100,6 +100,7 @@ final class DifferentialRevisionEditor { } public function setAuxiliaryFields(array $auxiliary_fields) { + assert_instances_of($auxiliary_fields, 'DifferentialAuxiliaryField'); $this->auxiliaryFields = $auxiliary_fields; return $this; } diff --git a/src/applications/differential/view/revisiondetail/DifferentialRevisionDetailView.php b/src/applications/differential/view/revisiondetail/DifferentialRevisionDetailView.php index 3013828282..5c52c767b0 100644 --- a/src/applications/differential/view/revisiondetail/DifferentialRevisionDetailView.php +++ b/src/applications/differential/view/revisiondetail/DifferentialRevisionDetailView.php @@ -39,6 +39,7 @@ final class DifferentialRevisionDetailView extends AphrontView { } public function setAuxiliaryFields(array $fields) { + assert_instances_of($fields, 'DifferentialAuxiliaryField'); $this->auxiliaryFields = $fields; return $this; } diff --git a/src/applications/directory/controller/main/PhabricatorDirectoryMainController.php b/src/applications/directory/controller/main/PhabricatorDirectoryMainController.php index e170b9a08c..d5a69044a5 100644 --- a/src/applications/directory/controller/main/PhabricatorDirectoryMainController.php +++ b/src/applications/directory/controller/main/PhabricatorDirectoryMainController.php @@ -63,7 +63,9 @@ final class PhabricatorDirectoryMainController } - private function buildMainResponse($nav, $projects) { + private function buildMainResponse($nav, array $projects) { + assert_instances_of($projects, 'PhabricatorProject'); + if (PhabricatorEnv::getEnvConfig('maniphest.enabled')) { $unbreak_panel = $this->buildUnbreakNowPanel(); $triage_panel = $this->buildNeedsTriagePanel($projects); @@ -131,7 +133,8 @@ final class PhabricatorDirectoryMainController )); } - private function buildFeedResponse($nav, $projects) { + private function buildFeedResponse($nav, array $projects) { + assert_instances_of($projects, 'PhabricatorProject'); $subnav = new AphrontSideNavFilterView(); $subnav->setBaseURI(new PhutilURI('/feed/')); @@ -234,6 +237,8 @@ final class PhabricatorDirectoryMainController } private function buildNeedsTriagePanel(array $projects) { + assert_instances_of($projects, 'PhabricatorProject'); + $user = $this->getRequest()->getUser(); $user_phid = $user->getPHID(); @@ -368,8 +373,8 @@ final class PhabricatorDirectoryMainController return $panel; } - private function buildTaskListView(array $tasks) { + assert_instances_of($tasks, 'ManiphestTask'); $user = $this->getRequest()->getUser(); $phids = array_merge( diff --git a/src/applications/feed/builder/feed/PhabricatorFeedBuilder.php b/src/applications/feed/builder/feed/PhabricatorFeedBuilder.php index b51a42e722..f326c32aeb 100644 --- a/src/applications/feed/builder/feed/PhabricatorFeedBuilder.php +++ b/src/applications/feed/builder/feed/PhabricatorFeedBuilder.php @@ -22,6 +22,7 @@ final class PhabricatorFeedBuilder { private $framed; public function __construct(array $stories) { + assert_instances_of($stories, 'PhabricatorFeedStory'); $this->stories = $stories; } diff --git a/src/applications/feed/story/base/PhabricatorFeedStory.php b/src/applications/feed/story/base/PhabricatorFeedStory.php index 7bc3a46cb0..fb466b9439 100644 --- a/src/applications/feed/story/base/PhabricatorFeedStory.php +++ b/src/applications/feed/story/base/PhabricatorFeedStory.php @@ -43,6 +43,7 @@ abstract class PhabricatorFeedStory { } final public function setHandles(array $handles) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } diff --git a/src/applications/flag/view/list/PhabricatorFlagListView.php b/src/applications/flag/view/list/PhabricatorFlagListView.php index a367737d32..8b26658f27 100644 --- a/src/applications/flag/view/list/PhabricatorFlagListView.php +++ b/src/applications/flag/view/list/PhabricatorFlagListView.php @@ -22,6 +22,7 @@ final class PhabricatorFlagListView extends AphrontView { private $user; public function setFlags(array $flags) { + assert_instances_of($flags, 'PhabricatorFlag'); $this->flags = $flags; return $this; } diff --git a/src/applications/flag/view/list/__init__.php b/src/applications/flag/view/list/__init__.php index affe0c6169..2ea2704cda 100644 --- a/src/applications/flag/view/list/__init__.php +++ b/src/applications/flag/view/list/__init__.php @@ -14,6 +14,7 @@ phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/utils'); phutil_require_module('phutil', 'markup'); +phutil_require_module('phutil', 'utils'); phutil_require_source('PhabricatorFlagListView.php'); diff --git a/src/applications/herald/adapter/commit/HeraldCommitAdapter.php b/src/applications/herald/adapter/commit/HeraldCommitAdapter.php index 2ad6ce5dce..e872bbb725 100644 --- a/src/applications/herald/adapter/commit/HeraldCommitAdapter.php +++ b/src/applications/herald/adapter/commit/HeraldCommitAdapter.php @@ -190,6 +190,7 @@ final class HeraldCommitAdapter extends HeraldObjectAdapter { } public function applyHeraldEffects(array $effects) { + assert_instances_of($effects, 'HeraldEffect'); $result = array(); foreach ($effects as $effect) { diff --git a/src/applications/herald/adapter/dryrun/HeraldDryRunAdapter.php b/src/applications/herald/adapter/dryrun/HeraldDryRunAdapter.php index 9755eef022..fcb68c01b6 100644 --- a/src/applications/herald/adapter/dryrun/HeraldDryRunAdapter.php +++ b/src/applications/herald/adapter/dryrun/HeraldDryRunAdapter.php @@ -35,6 +35,7 @@ final class HeraldDryRunAdapter extends HeraldObjectAdapter { } public function applyHeraldEffects(array $effects) { + assert_instances_of($effects, 'HeraldEffect'); $results = array(); foreach ($effects as $effect) { $results[] = new HeraldApplyTranscript( diff --git a/src/applications/herald/adapter/dryrun/__init__.php b/src/applications/herald/adapter/dryrun/__init__.php index 9983a8a9c9..9804f7bb1a 100644 --- a/src/applications/herald/adapter/dryrun/__init__.php +++ b/src/applications/herald/adapter/dryrun/__init__.php @@ -9,5 +9,7 @@ phutil_require_module('phabricator', 'applications/herald/adapter/base'); phutil_require_module('phabricator', 'applications/herald/storage/transcript/apply'); +phutil_require_module('phutil', 'utils'); + phutil_require_source('HeraldDryRunAdapter.php'); diff --git a/src/applications/herald/engine/engine/HeraldEngine.php b/src/applications/herald/engine/engine/HeraldEngine.php index a9e4f6c3af..c7af631b7f 100644 --- a/src/applications/herald/engine/engine/HeraldEngine.php +++ b/src/applications/herald/engine/engine/HeraldEngine.php @@ -40,6 +40,7 @@ final class HeraldEngine { } public function applyRules(array $rules, HeraldObjectAdapter $object) { + assert_instances_of($rules, 'HeraldRule'); $t_start = microtime(true); $rules = mpull($rules, null, 'getID'); @@ -122,6 +123,8 @@ final class HeraldEngine { array $effects, HeraldObjectAdapter $object, array $rules) { + assert_instances_of($effects, 'HeraldEffect'); + assert_instances_of($rules, 'HeraldRule'); $this->transcript->setDryRun($object instanceof HeraldDryRunAdapter); diff --git a/src/applications/herald/storage/rule/HeraldRule.php b/src/applications/herald/storage/rule/HeraldRule.php index dd6e199c00..87d0592c29 100644 --- a/src/applications/herald/storage/rule/HeraldRule.php +++ b/src/applications/herald/storage/rule/HeraldRule.php @@ -79,6 +79,7 @@ final class HeraldRule extends HeraldDAO { } private static function flagDisabledUserRules(array $rules) { + assert_instances_of($rules, 'HeraldRule'); $users = array(); foreach ($rules as $rule) { @@ -124,6 +125,7 @@ final class HeraldRule extends HeraldDAO { } public function attachConditions(array $conditions) { + assert_instances_of($conditions, 'HeraldCondition'); $this->conditions = $conditions; return $this; } @@ -144,6 +146,7 @@ final class HeraldRule extends HeraldDAO { public function attachActions(array $actions) { // TODO: validate actions have been attached. + assert_instances_of($actions, 'HeraldAction'); $this->actions = $actions; return $this; } @@ -173,18 +176,22 @@ final class HeraldRule extends HeraldDAO { } public function saveConditions(array $conditions) { + assert_instances_of($conditions, 'HeraldCondition'); return $this->saveChildren( id(new HeraldCondition())->getTableName(), $conditions); } public function saveActions(array $actions) { + assert_instances_of($actions, 'HeraldAction'); return $this->saveChildren( id(new HeraldAction())->getTableName(), $actions); } protected function saveChildren($table_name, array $children) { + assert_instances_of($children, 'HeraldDAO'); + if (!$this->getID()) { throw new Exception("Save rule before saving children."); } diff --git a/src/applications/herald/view/edithistory/HeraldRuleEditHistoryView.php b/src/applications/herald/view/edithistory/HeraldRuleEditHistoryView.php index 0305f10ac6..e8545e6003 100644 --- a/src/applications/herald/view/edithistory/HeraldRuleEditHistoryView.php +++ b/src/applications/herald/view/edithistory/HeraldRuleEditHistoryView.php @@ -31,6 +31,7 @@ final class HeraldRuleEditHistoryView extends AphrontView { } public function setHandles(array $handles) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } diff --git a/src/applications/herald/view/rulelist/HeraldRuleListView.php b/src/applications/herald/view/rulelist/HeraldRuleListView.php index d1726742c2..cdefcf30bd 100644 --- a/src/applications/herald/view/rulelist/HeraldRuleListView.php +++ b/src/applications/herald/view/rulelist/HeraldRuleListView.php @@ -26,11 +26,13 @@ final class HeraldRuleListView extends AphrontView { private $user; public function setRules(array $rules) { + assert_instances_of($rules, 'HeraldRule'); $this->rules = $rules; return $this; } public function setHandles(array $handles) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } diff --git a/src/applications/herald/view/rulelist/__init__.php b/src/applications/herald/view/rulelist/__init__.php index 69a972726d..bd042d9859 100644 --- a/src/applications/herald/view/rulelist/__init__.php +++ b/src/applications/herald/view/rulelist/__init__.php @@ -12,6 +12,7 @@ phutil_require_module('phabricator', 'view/base'); phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phutil', 'markup'); +phutil_require_module('phutil', 'utils'); phutil_require_source('HeraldRuleListView.php'); diff --git a/src/applications/maniphest/controller/report/ManiphestReportController.php b/src/applications/maniphest/controller/report/ManiphestReportController.php index e226a5184f..711f366aaa 100644 --- a/src/applications/maniphest/controller/report/ManiphestReportController.php +++ b/src/applications/maniphest/controller/report/ManiphestReportController.php @@ -321,7 +321,6 @@ final class ManiphestReportController extends ManiphestController { $request = $this->getRequest(); $user = $request->getUser(); - $form = id(new AphrontFormView()) ->setUser($user) ->appendChild( @@ -744,6 +743,7 @@ final class ManiphestReportController extends ManiphestController { } private function renderOldest(array $tasks) { + assert_instances_of($tasks, 'ManiphestTask'); $oldest = null; foreach ($tasks as $id => $task) { if (($oldest === null) || diff --git a/src/applications/maniphest/editor/transaction/ManiphestTransactionEditor.php b/src/applications/maniphest/editor/transaction/ManiphestTransactionEditor.php index a0c463c86e..ac22b5ee54 100644 --- a/src/applications/maniphest/editor/transaction/ManiphestTransactionEditor.php +++ b/src/applications/maniphest/editor/transaction/ManiphestTransactionEditor.php @@ -25,6 +25,7 @@ final class ManiphestTransactionEditor { private $auxiliaryFields = array(); public function setAuxiliaryFields(array $fields) { + assert_instances_of($fields, 'ManiphestAuxiliaryFieldSpecification'); $this->auxiliaryFields = $fields; return $this; } @@ -34,7 +35,8 @@ final class ManiphestTransactionEditor { return $this; } - public function applyTransactions($task, array $transactions) { + public function applyTransactions(ManiphestTask $task, array $transactions) { + assert_instances_of($transactions, 'ManiphestTransaction'); $email_cc = $task->getCCPHIDs(); @@ -302,6 +304,8 @@ final class ManiphestTransactionEditor { } private function publishFeedStory(ManiphestTask $task, array $transactions) { + assert_instances_of($transactions, 'ManiphestTransaction'); + $actions = array(ManiphestAction::ACTION_UPDATE); $comments = null; foreach ($transactions as $transaction) { @@ -355,6 +359,7 @@ final class ManiphestTransactionEditor { } private function isCreate(array $transactions) { + assert_instances_of($transactions, 'ManiphestTransaction'); $is_create = false; foreach ($transactions as $transaction) { $type = $transaction->getTransactionType(); @@ -368,6 +373,8 @@ final class ManiphestTransactionEditor { } private function getMailTags(array $transactions) { + assert_instances_of($transactions, 'ManiphestTransaction'); + $tags = array(); foreach ($transactions as $xaction) { switch ($xaction->getTransactionType()) { diff --git a/src/applications/maniphest/query/ManiphestTaskQuery.php b/src/applications/maniphest/query/ManiphestTaskQuery.php index d967dc1bae..27ee4d5d44 100644 --- a/src/applications/maniphest/query/ManiphestTaskQuery.php +++ b/src/applications/maniphest/query/ManiphestTaskQuery.php @@ -486,6 +486,7 @@ final class ManiphestTaskQuery { * TODO: Move this all to the database. */ private function applyGroupByProject(array $tasks) { + assert_instances_of($tasks, 'ManiphestTask'); $project_phids = array(); foreach ($tasks as $task) { diff --git a/src/applications/maniphest/view/tasklist/ManiphestTaskListView.php b/src/applications/maniphest/view/tasklist/ManiphestTaskListView.php index b8572def03..9c3425ca70 100644 --- a/src/applications/maniphest/view/tasklist/ManiphestTaskListView.php +++ b/src/applications/maniphest/view/tasklist/ManiphestTaskListView.php @@ -28,11 +28,13 @@ final class ManiphestTaskListView extends ManiphestView { private $showSubpriorityControls; public function setTasks(array $tasks) { + assert_instances_of($tasks, 'ManiphestTask'); $this->tasks = $tasks; return $this; } public function setHandles(array $handles) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } diff --git a/src/applications/maniphest/view/tasklist/__init__.php b/src/applications/maniphest/view/tasklist/__init__.php index be0ea53278..de618c9c54 100644 --- a/src/applications/maniphest/view/tasklist/__init__.php +++ b/src/applications/maniphest/view/tasklist/__init__.php @@ -9,5 +9,7 @@ phutil_require_module('phabricator', 'applications/maniphest/view/base'); phutil_require_module('phabricator', 'applications/maniphest/view/tasksummary'); +phutil_require_module('phutil', 'utils'); + phutil_require_source('ManiphestTaskListView.php'); diff --git a/src/applications/maniphest/view/taskprojects/ManiphestTaskProjectsView.php b/src/applications/maniphest/view/taskprojects/ManiphestTaskProjectsView.php index 2dfd97a808..d8b3fa48aa 100644 --- a/src/applications/maniphest/view/taskprojects/ManiphestTaskProjectsView.php +++ b/src/applications/maniphest/view/taskprojects/ManiphestTaskProjectsView.php @@ -24,6 +24,7 @@ final class ManiphestTaskProjectsView extends ManiphestView { private $handles; public function setHandles(array $handles) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } diff --git a/src/applications/maniphest/view/tasksummary/ManiphestTaskSummaryView.php b/src/applications/maniphest/view/tasksummary/ManiphestTaskSummaryView.php index 9eaf0f3dff..e2dff15f90 100644 --- a/src/applications/maniphest/view/tasksummary/ManiphestTaskSummaryView.php +++ b/src/applications/maniphest/view/tasksummary/ManiphestTaskSummaryView.php @@ -33,6 +33,7 @@ final class ManiphestTaskSummaryView extends ManiphestView { } public function setHandles(array $handles) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } diff --git a/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php b/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php index b94dbd262f..82ca8c0de1 100644 --- a/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php +++ b/src/applications/maniphest/view/transactiondetail/ManiphestTransactionDetailView.php @@ -36,6 +36,7 @@ final class ManiphestTransactionDetailView extends ManiphestView { private $auxiliaryFields; public function setAuxiliaryFields(array $fields) { + assert_instances_of($fields, 'ManiphestAuxiliaryFieldSpecification'); $this->auxiliaryFields = mpull($fields, null, 'getAuxiliaryKey'); return $this; } @@ -45,11 +46,13 @@ final class ManiphestTransactionDetailView extends ManiphestView { } public function setTransactionGroup(array $transactions) { + assert_instances_of($transactions, 'ManiphestTransaction'); $this->transactions = $transactions; return $this; } public function setHandles(array $handles) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } diff --git a/src/applications/maniphest/view/transactionlist/ManiphestTransactionListView.php b/src/applications/maniphest/view/transactionlist/ManiphestTransactionListView.php index 01b84cbc9d..1e5e5718d8 100644 --- a/src/applications/maniphest/view/transactionlist/ManiphestTransactionListView.php +++ b/src/applications/maniphest/view/transactionlist/ManiphestTransactionListView.php @@ -29,11 +29,13 @@ final class ManiphestTransactionListView extends ManiphestView { private $auxiliaryFields; public function setTransactions(array $transactions) { + assert_instances_of($transactions, 'ManiphestTransaction'); $this->transactions = $transactions; return $this; } public function setHandles(array $handles) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } @@ -54,6 +56,7 @@ final class ManiphestTransactionListView extends ManiphestView { } public function setAuxiliaryFields(array $fields) { + assert_instances_of($fields, 'ManiphestAuxiliaryFieldSpecification'); $this->auxiliaryFields = $fields; return $this; } diff --git a/src/applications/maniphest/view/transactionlist/__init__.php b/src/applications/maniphest/view/transactionlist/__init__.php index 9f8ccfe06d..4d98cfa8a7 100644 --- a/src/applications/maniphest/view/transactionlist/__init__.php +++ b/src/applications/maniphest/view/transactionlist/__init__.php @@ -13,5 +13,7 @@ phutil_require_module('phabricator', 'applications/maniphest/view/transactiondet phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/javelin/api'); +phutil_require_module('phutil', 'utils'); + phutil_require_source('ManiphestTransactionListView.php'); diff --git a/src/applications/metamta/replyhandler/base/PhabricatorMailReplyHandler.php b/src/applications/metamta/replyhandler/base/PhabricatorMailReplyHandler.php index 91acd8ebe7..c4d7afa79b 100644 --- a/src/applications/metamta/replyhandler/base/PhabricatorMailReplyHandler.php +++ b/src/applications/metamta/replyhandler/base/PhabricatorMailReplyHandler.php @@ -75,6 +75,8 @@ abstract class PhabricatorMailReplyHandler { PhabricatorMetaMTAMail $mail_template, array $to_handles, array $cc_handles) { + assert_instances_of($to_handles, 'PhabricatorObjectHandle'); + assert_instances_of($cc_handles, 'PhabricatorObjectHandle'); $result = array(); @@ -149,6 +151,7 @@ abstract class PhabricatorMailReplyHandler { } protected function formatPHIDList(array $handles) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $list = array(); foreach ($handles as $handle) { $list[] = '<'.$handle->getPHID().'>'; diff --git a/src/applications/metamta/storage/mail/PhabricatorMetaMTAMail.php b/src/applications/metamta/storage/mail/PhabricatorMetaMTAMail.php index b5193031e8..458c7545c0 100644 --- a/src/applications/metamta/storage/mail/PhabricatorMetaMTAMail.php +++ b/src/applications/metamta/storage/mail/PhabricatorMetaMTAMail.php @@ -129,6 +129,7 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { } public function setAttachments(array $attachments) { + assert_instances_of($attachments, 'PhabricatorMetaMTAAttachment'); $this->setParam('attachments', $attachments); return $this; } @@ -614,6 +615,7 @@ final class PhabricatorMetaMTAMail extends PhabricatorMetaMTADAO { array $phids, array $handles, array $exclude) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $emails = array(); foreach ($phids as $phid) { diff --git a/src/applications/owners/controller/list/PhabricatorOwnersListController.php b/src/applications/owners/controller/list/PhabricatorOwnersListController.php index 5930a7b85c..06fea5393c 100644 --- a/src/applications/owners/controller/list/PhabricatorOwnersListController.php +++ b/src/applications/owners/controller/list/PhabricatorOwnersListController.php @@ -204,6 +204,7 @@ final class PhabricatorOwnersListController } private function renderPackageTable(array $packages, $header, $nodata) { + assert_instances_of($packages, 'PhabricatorOwnersPackage'); if ($packages) { $package_ids = mpull($packages, 'getID'); diff --git a/src/applications/owners/storage/owner/PhabricatorOwnersOwner.php b/src/applications/owners/storage/owner/PhabricatorOwnersOwner.php index 4d1cef4ecc..ab61a556ca 100644 --- a/src/applications/owners/storage/owner/PhabricatorOwnersOwner.php +++ b/src/applications/owners/storage/owner/PhabricatorOwnersOwner.php @@ -28,6 +28,7 @@ final class PhabricatorOwnersOwner extends PhabricatorOwnersDAO { } public static function loadAllForPackages(array $packages) { + assert_instances_of($packages, 'PhabricatorOwnersPackage'); if (!$packages) { return array(); } diff --git a/src/applications/phriction/controller/diff/PhrictionDiffController.php b/src/applications/phriction/controller/diff/PhrictionDiffController.php index 9d31e53983..c5af468c5a 100644 --- a/src/applications/phriction/controller/diff/PhrictionDiffController.php +++ b/src/applications/phriction/controller/diff/PhrictionDiffController.php @@ -233,6 +233,7 @@ final class PhrictionDiffController } private function renderComparisonTable(array $content) { + assert_instances_of($content, 'PhrictionContent'); $user = $this->getRequest()->getUser(); diff --git a/src/applications/project/controller/profile/PhabricatorProjectProfileController.php b/src/applications/project/controller/profile/PhabricatorProjectProfileController.php index c2ed64909e..07919ba71d 100644 --- a/src/applications/project/controller/profile/PhabricatorProjectProfileController.php +++ b/src/applications/project/controller/profile/PhabricatorProjectProfileController.php @@ -270,6 +270,7 @@ final class PhabricatorProjectProfileController } private function renderStories(array $stories) { + assert_instances_of($stories, 'PhabricatorFeedStory'); $builder = new PhabricatorFeedBuilder($stories); $builder->setUser($this->getRequest()->getUser()); diff --git a/src/applications/project/editor/project/PhabricatorProjectEditor.php b/src/applications/project/editor/project/PhabricatorProjectEditor.php index 00ee8478e8..63190d6cee 100644 --- a/src/applications/project/editor/project/PhabricatorProjectEditor.php +++ b/src/applications/project/editor/project/PhabricatorProjectEditor.php @@ -35,6 +35,7 @@ final class PhabricatorProjectEditor { } public function applyTransactions(array $transactions) { + assert_instances_of($transactions, 'PhabricatorProjectTransaction'); if (!$this->user) { throw new Exception('Call setUser() before save()!'); } diff --git a/src/applications/project/storage/project/PhabricatorProject.php b/src/applications/project/storage/project/PhabricatorProject.php index fd54c93edc..429558cafc 100644 --- a/src/applications/project/storage/project/PhabricatorProject.php +++ b/src/applications/project/storage/project/PhabricatorProject.php @@ -63,6 +63,7 @@ final class PhabricatorProject extends PhabricatorProjectDAO { } public function attachAffiliations(array $affiliations) { + assert_instances_of($affiliations, 'PhabricatorProjectAffiliation'); $this->affiliations = $affiliations; return $this; } diff --git a/src/applications/repository/storage/commit/PhabricatorRepositoryCommit.php b/src/applications/repository/storage/commit/PhabricatorRepositoryCommit.php index 91d08983d2..243daa8c9c 100644 --- a/src/applications/repository/storage/commit/PhabricatorRepositoryCommit.php +++ b/src/applications/repository/storage/commit/PhabricatorRepositoryCommit.php @@ -86,6 +86,8 @@ final class PhabricatorRepositoryCommit extends PhabricatorRepositoryDAO { * triggers. */ public function updateAuditStatus(array $requests) { + assert_instances_of($requests, 'PhabricatorRepositoryAuditRequest'); + $any_concern = false; $any_accept = false; $any_need = false; diff --git a/src/applications/repository/worker/commitmessageparser/base/PhabricatorRepositoryCommitMessageParserWorker.php b/src/applications/repository/worker/commitmessageparser/base/PhabricatorRepositoryCommitMessageParserWorker.php index ec1b7fa2ce..cc1dbda6bc 100644 --- a/src/applications/repository/worker/commitmessageparser/base/PhabricatorRepositoryCommitMessageParserWorker.php +++ b/src/applications/repository/worker/commitmessageparser/base/PhabricatorRepositoryCommitMessageParserWorker.php @@ -120,6 +120,7 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker * committed or abandoned revision as a last resort. */ private function identifyBestRevision(array $revisions) { + assert_instances_of($revisions, 'DifferentialRevision'); // get the simplest, common case out of the way if (count($revisions) == 1) { return reset($revisions); @@ -165,6 +166,7 @@ abstract class PhabricatorRepositoryCommitMessageParserWorker * updated time. This is ostensibly the most recent revision. */ private function identifyMostRecentRevision(array $revisions) { + assert_instances_of($revisions, 'DifferentialRevision'); $revisions = msort($revisions, 'getDateModified'); return end($revisions); } diff --git a/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php b/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php index ebf2bf86b0..ad35e89df2 100644 --- a/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php +++ b/src/applications/repository/worker/herald/PhabricatorRepositoryCommitHeraldWorker.php @@ -183,6 +183,7 @@ EOBODY; PhabricatorRepositoryCommit $commit, array $map, array $rules) { + assert_instances_of($rules, 'HeraldRule'); $requests = id(new PhabricatorRepositoryAuditRequest())->loadAllWhere( 'commitPHID = %s', diff --git a/src/applications/slowvote/controller/poll/PhabricatorSlowvotePollController.php b/src/applications/slowvote/controller/poll/PhabricatorSlowvotePollController.php index f046b4cb24..12ca241ae9 100644 --- a/src/applications/slowvote/controller/poll/PhabricatorSlowvotePollController.php +++ b/src/applications/slowvote/controller/poll/PhabricatorSlowvotePollController.php @@ -208,6 +208,9 @@ final class PhabricatorSlowvotePollController } private function renderComments(array $comments, array $handles) { + assert_instances_of($comments, 'PhabricatorSlowvoteComment'); + assert_instances_of($handles, 'PhabricatorObjectHandle'); + $viewer = $this->getRequest()->getUser(); $engine = PhabricatorMarkupEngine::newSlowvoteMarkupEngine(); @@ -253,6 +256,7 @@ final class PhabricatorSlowvotePollController PhabricatorSlowvotePoll $poll, array $viewer_choices, PhabricatorSlowvoteOption $option) { + assert_instances_of($viewer_choices, 'PhabricatorSlowvoteChoice'); $id = $option->getID(); switch ($poll->getMethod()) { @@ -325,6 +329,8 @@ final class PhabricatorSlowvotePollController PhabricatorSlowvotePoll $poll, array $choices, array $chosen) { + assert_instances_of($choices, 'PhabricatorSlowvoteChoice'); + assert_instances_of($chosen, 'PhabricatorSlowvoteChoice'); switch ($poll->getMethod()) { case PhabricatorSlowvotePoll::METHOD_PLURALITY: @@ -357,6 +363,12 @@ final class PhabricatorSlowvotePollController array $comments_by_option, array $handles, array $objects) { + assert_instances_of($options, 'PhabricatorSlowvoteOption'); + assert_instances_of($choices, 'PhabricatorSlowvoteChoice'); + assert_instances_of($comments, 'PhabricatorSlowvoteComment'); + assert_instances_of($viewer_choices, 'PhabricatorSlowvoteChoice'); + assert_instances_of($handles, 'PhabricatorObjectHandle'); + assert_instances_of($objects, 'PhabricatorLiskDAO'); $viewer_phid = $this->getRequest()->getUser()->getPHID(); diff --git a/src/view/control/objectselector/PhabricatorObjectSelectorDialog.php b/src/view/control/objectselector/PhabricatorObjectSelectorDialog.php index ffc29369be..7f44dab14a 100644 --- a/src/view/control/objectselector/PhabricatorObjectSelectorDialog.php +++ b/src/view/control/objectselector/PhabricatorObjectSelectorDialog.php @@ -47,6 +47,7 @@ final class PhabricatorObjectSelectorDialog { } public function setHandles(array $handles) { + assert_instances_of($handles, 'PhabricatorObjectHandle'); $this->handles = $handles; return $this; } diff --git a/src/view/control/objectselector/__init__.php b/src/view/control/objectselector/__init__.php index 319c6a84a3..931cb614b9 100644 --- a/src/view/control/objectselector/__init__.php +++ b/src/view/control/objectselector/__init__.php @@ -13,6 +13,7 @@ phutil_require_module('phabricator', 'infrastructure/javelin/markup'); phutil_require_module('phabricator', 'view/dialog'); phutil_require_module('phutil', 'markup'); +phutil_require_module('phutil', 'utils'); phutil_require_source('PhabricatorObjectSelectorDialog.php');