1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 23:02:42 +01:00

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
This commit is contained in:
vrana 2012-04-03 12:10:45 -07:00
parent 5623abecbf
commit 8813c7be0e
50 changed files with 105 additions and 5 deletions

View file

@ -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;

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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();

View file

@ -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();

View file

@ -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');

View file

@ -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();
}

View file

@ -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();
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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');

View file

@ -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;
}

View file

@ -39,6 +39,7 @@ final class DifferentialRevisionDetailView extends AphrontView {
}
public function setAuxiliaryFields(array $fields) {
assert_instances_of($fields, 'DifferentialAuxiliaryField');
$this->auxiliaryFields = $fields;
return $this;
}

View file

@ -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(

View file

@ -22,6 +22,7 @@ final class PhabricatorFeedBuilder {
private $framed;
public function __construct(array $stories) {
assert_instances_of($stories, 'PhabricatorFeedStory');
$this->stories = $stories;
}

View file

@ -43,6 +43,7 @@ abstract class PhabricatorFeedStory {
}
final public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}

View file

@ -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;
}

View file

@ -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');

View file

@ -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) {

View file

@ -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(

View file

@ -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');

View file

@ -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);

View file

@ -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.");
}

View file

@ -31,6 +31,7 @@ final class HeraldRuleEditHistoryView extends AphrontView {
}
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}

View file

@ -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;
}

View file

@ -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');

View file

@ -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) ||

View file

@ -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()) {

View file

@ -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) {

View file

@ -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;
}

View file

@ -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');

View file

@ -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;
}

View file

@ -33,6 +33,7 @@ final class ManiphestTaskSummaryView extends ManiphestView {
}
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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');

View file

@ -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().'>';

View file

@ -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) {

View file

@ -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');

View file

@ -28,6 +28,7 @@ final class PhabricatorOwnersOwner extends PhabricatorOwnersDAO {
}
public static function loadAllForPackages(array $packages) {
assert_instances_of($packages, 'PhabricatorOwnersPackage');
if (!$packages) {
return array();
}

View file

@ -233,6 +233,7 @@ final class PhrictionDiffController
}
private function renderComparisonTable(array $content) {
assert_instances_of($content, 'PhrictionContent');
$user = $this->getRequest()->getUser();

View file

@ -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());

View file

@ -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()!');
}

View file

@ -63,6 +63,7 @@ final class PhabricatorProject extends PhabricatorProjectDAO {
}
public function attachAffiliations(array $affiliations) {
assert_instances_of($affiliations, 'PhabricatorProjectAffiliation');
$this->affiliations = $affiliations;
return $this;
}

View file

@ -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;

View file

@ -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);
}

View file

@ -183,6 +183,7 @@ EOBODY;
PhabricatorRepositoryCommit $commit,
array $map,
array $rules) {
assert_instances_of($rules, 'HeraldRule');
$requests = id(new PhabricatorRepositoryAuditRequest())->loadAllWhere(
'commitPHID = %s',

View file

@ -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();

View file

@ -47,6 +47,7 @@ final class PhabricatorObjectSelectorDialog {
}
public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles;
return $this;
}

View file

@ -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');