1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-24 05:28:18 +01:00

Use assert_instances_of() in Diffusion

Summary: NOTE: This is not produced by a script so there might be errors. Please review carefully.

Test Plan: Browse around Diffusion.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran

Differential Revision: https://secure.phabricator.com/D2094
This commit is contained in:
vrana 2012-04-03 16:22:31 -07:00
parent 591d50008f
commit c241f50d77
12 changed files with 33 additions and 6 deletions

View file

@ -267,6 +267,7 @@ final class DiffusionCommitController extends DiffusionController {
PhabricatorRepositoryCommit $commit, PhabricatorRepositoryCommit $commit,
PhabricatorRepositoryCommitData $data, PhabricatorRepositoryCommitData $data,
array $parents) { array $parents) {
assert_instances_of($parents, 'PhabricatorRepositoryCommit');
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$phids = array(); $phids = array();
@ -347,7 +348,10 @@ final class DiffusionCommitController extends DiffusionController {
return $props; return $props;
} }
private function buildAuditTable($commit, $audits) { private function buildAuditTable(
PhabricatorRepositoryCommit $commit,
array $audits) {
assert_instances_of($audits, 'PhabricatorRepositoryAuditRequest');
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$view = new PhabricatorAuditListView(); $view = new PhabricatorAuditListView();
@ -369,7 +373,7 @@ final class DiffusionCommitController extends DiffusionController {
return $panel; return $panel;
} }
private function buildComments($commit) { private function buildComments(PhabricatorRepositoryCommit $commit) {
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$comments = id(new PhabricatorAuditComment())->loadAllWhere( $comments = id(new PhabricatorAuditComment())->loadAllWhere(
'targetPHID = %s ORDER BY dateCreated ASC', 'targetPHID = %s ORDER BY dateCreated ASC',
@ -402,7 +406,10 @@ final class DiffusionCommitController extends DiffusionController {
return $view; return $view;
} }
private function buildAddCommentView($commit, array $audit_requests) { private function buildAddCommentView(
PhabricatorRepositoryCommit $commit,
array $audit_requests) {
assert_instances_of($audit_requests, 'PhabricatorRepositoryAuditRequest');
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business'); $is_serious = PhabricatorEnv::getEnvConfig('phabricator.serious-business');
@ -493,6 +500,7 @@ final class DiffusionCommitController extends DiffusionController {
private function getAuditActions( private function getAuditActions(
PhabricatorRepositoryCommit $commit, PhabricatorRepositoryCommit $commit,
array $audit_requests) { array $audit_requests) {
assert_instances_of($audit_requests, 'PhabricatorRepositoryAuditRequest');
$user = $this->getRequest()->getUser(); $user = $this->getRequest()->getUser();
$user_is_author = ($commit->getAuthorPHID() == $user->getPHID()); $user_is_author = ($commit->getAuthorPHID() == $user->getPHID());

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -135,6 +135,7 @@ final class DiffusionPathChange {
} }
final public static function convertToArcanistChanges(array $changes) { final public static function convertToArcanistChanges(array $changes) {
assert_instances_of($changes, 'DiffusionPathChange');
$direct = array(); $direct = array();
$result = array(); $result = array();
foreach ($changes as $path) { foreach ($changes as $path) {
@ -158,6 +159,7 @@ final class DiffusionPathChange {
} }
final public static function convertToDifferentialChangesets(array $changes) { final public static function convertToDifferentialChangesets(array $changes) {
assert_instances_of($changes, 'DiffusionPathChange');
$arcanist_changes = self::convertToArcanistChanges($changes); $arcanist_changes = self::convertToArcanistChanges($changes);
$diff = DifferentialDiff::newFromRawChanges($arcanist_changes); $diff = DifferentialDiff::newFromRawChanges($arcanist_changes);
return $diff->getChangesets(); return $diff->getChangesets();

View file

@ -1,7 +1,7 @@
<?php <?php
/* /*
* Copyright 2011 Facebook, Inc. * Copyright 2012 Facebook, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -16,7 +16,6 @@
* limitations under the License. * limitations under the License.
*/ */
/** /**
* Query symbol information (class and function names and location), returning * Query symbol information (class and function names and location), returning
* a list of matching @{class:PhabricatorRepositorySymbol} objects and possibly * a list of matching @{class:PhabricatorRepositorySymbol} objects and possibly
@ -222,6 +221,7 @@ final class DiffusionSymbolQuery {
* @task internal * @task internal
*/ */
private function loadPaths(array $symbols) { private function loadPaths(array $symbols) {
assert_instances_of($symbols, 'PhabricatorRepositorySymbol');
$path_map = queryfx_all( $path_map = queryfx_all(
id(new PhabricatorRepository())->establishConnection('r'), id(new PhabricatorRepository())->establishConnection('r'),
'SELECT * FROM %T WHERE id IN (%Ld)', 'SELECT * FROM %T WHERE id IN (%Ld)',
@ -238,6 +238,7 @@ final class DiffusionSymbolQuery {
* @task internal * @task internal
*/ */
private function loadArcanistProjects(array $symbols) { private function loadArcanistProjects(array $symbols) {
assert_instances_of($symbols, 'PhabricatorRepositorySymbol');
$projects = id(new PhabricatorRepositoryArcanistProject())->loadAllWhere( $projects = id(new PhabricatorRepositoryArcanistProject())->loadAllWhere(
'id IN (%Ld)', 'id IN (%Ld)',
mpull($symbols, 'getArcanistProjectID')); mpull($symbols, 'getArcanistProjectID'));
@ -252,6 +253,8 @@ final class DiffusionSymbolQuery {
* @task internal * @task internal
*/ */
private function loadRepositories(array $symbols) { private function loadRepositories(array $symbols) {
assert_instances_of($symbols, 'PhabricatorRepositorySymbol');
$projects = mpull($symbols, 'getArcanistProject'); $projects = mpull($symbols, 'getArcanistProject');
$projects = array_filter($projects); $projects = array_filter($projects);

View file

@ -21,6 +21,7 @@ final class DiffusionBranchTableView extends DiffusionView {
private $branches; private $branches;
public function setBranches(array $branches) { public function setBranches(array $branches) {
assert_instances_of($branches, 'DiffusionBranchInformation');
$this->branches = $branches; $this->branches = $branches;
return $this; return $this;
} }

View file

@ -10,6 +10,7 @@ phutil_require_module('phabricator', 'applications/diffusion/view/base');
phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('DiffusionBranchTableView.php'); phutil_require_source('DiffusionBranchTableView.php');

View file

@ -27,6 +27,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
} }
public function setHandles(array $handles) { public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles; $this->handles = $handles;
return $this; return $this;
} }
@ -36,6 +37,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
array $handles, array $handles,
PhabricatorRepositoryCommit $commit = null, PhabricatorRepositoryCommit $commit = null,
PhabricatorRepositoryCommitData $data = null) { PhabricatorRepositoryCommitData $data = null) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
if ($commit) { if ($commit) {
$epoch = $commit->getEpoch(); $epoch = $commit->getEpoch();

View file

@ -13,6 +13,7 @@ phutil_require_module('phabricator', 'infrastructure/javelin/api');
phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('DiffusionBrowseTableView.php'); phutil_require_source('DiffusionBrowseTableView.php');

View file

@ -45,6 +45,7 @@ final class DiffusionCommentView extends AphrontView {
} }
public function setHandles(array $handles) { public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles; $this->handles = $handles;
return $this; return $this;
} }
@ -55,6 +56,7 @@ final class DiffusionCommentView extends AphrontView {
} }
public function setInlineComments(array $inline_comments) { public function setInlineComments(array $inline_comments) {
assert_instances_of($inline_comments, 'PhabricatorAuditInlineComment');
$this->inlineComments = $inline_comments; $this->inlineComments = $inline_comments;
return $this; return $this;
} }

View file

@ -29,11 +29,13 @@ final class DiffusionCommentListView extends AphrontView {
} }
public function setComments(array $comments) { public function setComments(array $comments) {
assert_instances_of($comments, 'PhabricatorAuditComment');
$this->comments = $comments; $this->comments = $comments;
return $this; return $this;
} }
public function setInlineComments(array $inline_comments) { public function setInlineComments(array $inline_comments) {
assert_instances_of($inline_comments, 'PhabricatorAuditInlineComment');
$this->inlineComments = $inline_comments; $this->inlineComments = $inline_comments;
return $this; return $this;
} }
@ -55,6 +57,7 @@ final class DiffusionCommentListView extends AphrontView {
} }
public function setHandles(array $handles) { public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles; $this->handles = $handles;
return $this; return $this;
} }

View file

@ -21,6 +21,7 @@ final class DiffusionCommitChangeTableView extends DiffusionView {
private $pathChanges; private $pathChanges;
public function setPathChanges(array $path_changes) { public function setPathChanges(array $path_changes) {
assert_instances_of($path_changes, 'DiffusionPathChange');
$this->pathChanges = $path_changes; $this->pathChanges = $path_changes;
return $this; return $this;
} }

View file

@ -11,6 +11,7 @@ phutil_require_module('phabricator', 'applications/diffusion/view/base');
phutil_require_module('phabricator', 'view/control/table'); phutil_require_module('phabricator', 'view/control/table');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');
phutil_require_module('phutil', 'utils');
phutil_require_source('DiffusionCommitChangeTableView.php'); phutil_require_source('DiffusionCommitChangeTableView.php');

View file

@ -24,11 +24,13 @@ final class DiffusionHistoryTableView extends DiffusionView {
private $parents; private $parents;
public function setHistory(array $history) { public function setHistory(array $history) {
assert_instances_of($history, 'DiffusionPathChange');
$this->history = $history; $this->history = $history;
return $this; return $this;
} }
public function setHandles(array $handles) { public function setHandles(array $handles) {
assert_instances_of($handles, 'PhabricatorObjectHandle');
$this->handles = $handles; $this->handles = $handles;
return $this; return $this;
} }