@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Replace all "attach first..." exceptions with `assertAttached()`

Summary:
Ref T3599
Go through everything, grep a bit, replace some bits.

Test Plan: Navigate around a bit

Reviewers: epriestley

Reviewed By: epriestley

CC: Korvin, aran

Maniphest Tasks: T3599

Differential Revision: https://secure.phabricator.com/D6871

authored by

Gareth Evans and committed by
epriestley
fcba0c74 4e12a375

+100 -235
+12 -44
src/applications/conpherence/storage/ConpherenceThread.php
··· 13 13 protected $recentParticipantPHIDs = array(); 14 14 protected $mailKey; 15 15 16 - private $participants; 17 - private $transactions; 18 - private $handles; 19 - private $filePHIDs; 20 - private $widgetData; 16 + private $participants = self::ATTACHABLE; 17 + private $transactions = self::ATTACHABLE; 18 + private $handles = self::ATTACHABLE; 19 + private $filePHIDs = self::ATTACHABLE; 20 + private $widgetData = self::ATTACHABLE; 21 21 private $images = array(); 22 22 23 23 public function getConfiguration() { ··· 47 47 return $this; 48 48 } 49 49 public function getParticipants() { 50 - if ($this->participants === null) { 51 - throw new Exception( 52 - 'You must attachParticipants first!' 53 - ); 54 - } 55 - return $this->participants; 50 + return $this->assertAttached($this->participants); 56 51 } 57 52 public function getParticipant($phid) { 58 53 $participants = $this->getParticipants(); ··· 69 64 return $this; 70 65 } 71 66 public function getHandles() { 72 - if ($this->handles === null) { 73 - throw new Exception( 74 - 'You must attachHandles first!' 75 - ); 76 - } 77 - return $this->handles; 67 + return $this->assertAttached($this->handles); 78 68 } 79 69 80 70 public function attachTransactions(array $transactions) { ··· 83 73 return $this; 84 74 } 85 75 public function getTransactions() { 86 - if ($this->transactions === null) { 87 - throw new Exception( 88 - 'You must attachTransactions first!' 89 - ); 90 - } 91 - return $this->transactions; 76 + return $this->assertAttached($this->transactions); 92 77 } 93 78 94 79 public function getTransactionsFrom($begin = 0, $amount = null) { 95 80 $length = count($this->transactions); 96 - if ($amount === null) { 97 - $amount === $length; 98 - } 99 - if ($this->transactions === null) { 100 - throw new Exception( 101 - 'You must attachTransactions first!' 102 - ); 103 - } 81 + 104 82 return array_slice( 105 - $this->transactions, 83 + $this->getTransactions(), 106 84 $length - $begin - $amount, 107 85 $amount); 108 86 } ··· 112 90 return $this; 113 91 } 114 92 public function getFilePHIDs() { 115 - if ($this->filePHIDs === null) { 116 - throw new Exception( 117 - 'You must attachFilePHIDs first!' 118 - ); 119 - } 120 - return $this->filePHIDs; 93 + return $this->assertAttached($this->filePHIDs); 121 94 } 122 95 123 96 public function attachWidgetData(array $widget_data) { ··· 125 98 return $this; 126 99 } 127 100 public function getWidgetData() { 128 - if ($this->widgetData === null) { 129 - throw new Exception( 130 - 'You must attachWidgetData first!' 131 - ); 132 - } 133 - return $this->widgetData; 101 + return $this->assertAttached($this->widgetData); 134 102 } 135 103 136 104 public function getDisplayData(PhabricatorUser $user) {
+3 -6
src/applications/differential/storage/DifferentialChangeset.php
··· 15 15 protected $delLines; 16 16 17 17 private $unsavedHunks = array(); 18 - private $hunks; 18 + private $hunks = self::ATTACHABLE; 19 19 20 20 const TABLE_CACHE = 'differential_changeset_parse_cache'; 21 21 ··· 40 40 } 41 41 42 42 public function getHunks() { 43 - if ($this->hunks === null) { 44 - throw new Exception("Must load and attach hunks first!"); 45 - } 46 - return $this->hunks; 43 + return $this->assertAttached($this->hunks); 47 44 } 48 45 49 46 public function getDisplayFilename() { ··· 55 52 } 56 53 57 54 public function addUnsavedHunk(DifferentialHunk $hunk) { 58 - if ($this->hunks === null) { 55 + if ($this->hunks === self::ATTACHABLE) { 59 56 $this->hunks = array(); 60 57 } 61 58 $this->hunks[] = $hunk;
+2 -5
src/applications/differential/storage/DifferentialDiff.php
··· 30 30 protected $description; 31 31 32 32 private $unsavedChangesets = array(); 33 - private $changesets; 33 + private $changesets = self::ATTACHABLE; 34 34 35 35 public function addUnsavedChangeset(DifferentialChangeset $changeset) { 36 36 if ($this->changesets === null) { ··· 48 48 } 49 49 50 50 public function getChangesets() { 51 - if ($this->changesets === null) { 52 - throw new Exception("Must load and attach changesets first!"); 53 - } 54 - return $this->changesets; 51 + return $this->assertAttached($this->changesets); 55 52 } 56 53 57 54 public function loadChangesets() {
+12 -31
src/applications/differential/storage/DifferentialRevision.php
··· 26 26 protected $branchName; 27 27 protected $arcanistProjectPHID; 28 28 29 - private $relationships; 30 - private $commits; 31 - private $activeDiff = false; 32 - private $diffIDs; 33 - private $hashes; 29 + private $relationships = self::ATTACHABLE; 30 + private $commits = self::ATTACHABLE; 31 + private $activeDiff = self::ATTACHABLE; 32 + private $diffIDs = self::ATTACHABLE; 33 + private $hashes = self::ATTACHABLE; 34 34 35 - private $reviewerStatus; 35 + private $reviewerStatus = self::ATTACHABLE; 36 36 37 37 const RELATIONSHIP_TABLE = 'differential_relationship'; 38 38 const TABLE_COMMIT = 'differential_commit'; ··· 86 86 } 87 87 88 88 public function getCommitPHIDs() { 89 - if ($this->commits === null) { 90 - throw new Exception("Must attach commits first!"); 91 - } 92 - return $this->commits; 89 + return $this->assertAttached($this->commits); 93 90 } 94 91 95 92 public function getActiveDiff() { ··· 98 95 // It would be good to get rid of this once we make diff-attaching 99 96 // transactional. 100 97 101 - if ($this->activeDiff === false) { 102 - throw new Exception("Must attach active diff first!"); 103 - } 104 - return $this->activeDiff; 98 + return $this->assertAttached($this->activeDiff); 105 99 } 106 100 107 101 public function attachActiveDiff($diff) { ··· 110 104 } 111 105 112 106 public function getDiffIDs() { 113 - if ($this->diffIDs === null) { 114 - throw new Exception("Must attach diff IDs first!"); 115 - } 116 - return $this->diffIDs; 107 + return $this->assertAttached($this->diffIDs); 117 108 } 118 109 119 110 public function attachDiffIDs(array $ids) { ··· 256 247 } 257 248 258 249 private function getRelatedPHIDs($relation) { 259 - if ($this->relationships === null) { 260 - throw new Exception("Must load relationships!"); 261 - } 250 + $this->assertAttached($this->relationships); 262 251 263 252 return ipull($this->getRawRelations($relation), 'objectPHID'); 264 253 } ··· 304 293 } 305 294 306 295 public function getHashes() { 307 - if ($this->hashes === null) { 308 - throw new Exception("Call attachHashes() before getHashes()!"); 309 - } 310 - return $this->hashes; 296 + return $this->assertAttached($this->hashes); 311 297 } 312 298 313 299 public function attachHashes(array $hashes) { ··· 337 323 } 338 324 339 325 public function getReviewerStatus() { 340 - if ($this->reviewerStatus === null) { 341 - throw new Exception( 342 - "Call attachReviewerStatus() before getReviewerStatus()!" 343 - ); 344 - } 345 - return $this->reviewerStatus; 326 + return $this->assertAttached($this->reviewerStatus); 346 327 } 347 328 348 329 public function attachReviewerStatus(array $reviewers) {
+2 -5
src/applications/drydock/storage/DrydockLease.php
··· 10 10 protected $status = DrydockLeaseStatus::STATUS_PENDING; 11 11 protected $taskID; 12 12 13 - private $resource; 13 + private $resource = self::ATTACHABLE; 14 14 private $releaseOnDestruction; 15 15 16 16 /** ··· 64 64 } 65 65 66 66 public function getResource() { 67 - if ($this->resource === null) { 68 - throw new Exception("Resource is not yet loaded."); 69 - } 70 - return $this->resource; 67 + return $this->assertAttached($this->resource); 71 68 } 72 69 73 70 public function attachResource(DrydockResource $resource) {
+5 -5
src/applications/herald/storage/HeraldRule.php
··· 15 15 16 16 protected $configVersion = 9; 17 17 18 - private $ruleApplied = array(); // phids for which this rule has been applied 18 + private $ruleApplied = self::ATTACHABLE; // phids for which this rule has been applied 19 19 private $validAuthor = self::ATTACHABLE; 20 20 private $conditions; 21 21 private $actions; ··· 31 31 } 32 32 33 33 public function getRuleApplied($phid) { 34 - if (idx($this->ruleApplied, $phid) === null) { 35 - throw new Exception("Call setRuleApplied() before getRuleApplied()!"); 36 - } 37 - return $this->ruleApplied[$phid]; 34 + return $this->assertAttachedKey($this->ruleApplied, $phid); 38 35 } 39 36 40 37 public function setRuleApplied($phid, $applied) { 38 + if ($this->ruleApplied === self::ATTACHABLE) { 39 + $this->ruleApplied = array(); 40 + } 41 41 $this->ruleApplied[$phid] = $applied; 42 42 return $this; 43 43 }
+4 -14
src/applications/legalpad/storage/LegalpadDocument.php
··· 20 20 protected $editPolicy; 21 21 protected $mailKey; 22 22 23 - private $documentBody; 24 - private $contributors; 23 + private $documentBody = self::ATTACHABLE; 24 + private $contributors = self::ATTACHABLE; 25 25 26 26 public function getConfiguration() { 27 27 return array( ··· 38 38 } 39 39 40 40 public function getDocumentBody() { 41 - if ($this->documentBody === null) { 42 - throw new Exception( 43 - 'You must attachDocumentBody before you can getDocumentBody.'); 44 - } 45 - 46 - return $this->documentBody; 41 + return $this->assertAttached($this->documentBody); 47 42 } 48 43 49 44 public function attachDocumentBody(LegalpadDocumentBody $body) { ··· 52 47 } 53 48 54 49 public function getContributors() { 55 - if ($this->contributors === null) { 56 - throw new Exception( 57 - 'You must attachContributors before you can getContributors.'); 58 - } 59 - 60 - return $this->contributors; 50 + return $this->assertAttached($this->contributors); 61 51 } 62 52 63 53 public function attachContributors(array $contributors) {
+2 -6
src/applications/macro/storage/PhabricatorFileImageMacro.php
··· 12 12 protected $name; 13 13 protected $isDisabled = 0; 14 14 15 - private $file; 15 + private $file = self::ATTACHABLE; 16 16 17 17 public function attachFile(PhabricatorFile $file) { 18 18 $this->file = $file; ··· 20 20 } 21 21 22 22 public function getFile() { 23 - if (!$this->file) { 24 - throw new Exception("Attach a file with attachFile() first!"); 25 - } 26 - 27 - return $this->file; 23 + return $this->assertAttached($this->file); 28 24 } 29 25 30 26 public function getConfiguration() {
+4 -7
src/applications/maniphest/storage/ManiphestTask.php
··· 34 34 35 35 protected $ownerOrdering; 36 36 37 - private $auxiliaryAttributes; 37 + private $auxiliaryAttributes = self::ATTACHABLE; 38 38 private $auxiliaryDirty = array(); 39 39 40 40 public function getConfiguration() { ··· 95 95 } 96 96 97 97 public function getAuxiliaryAttribute($key, $default = null) { 98 - if ($this->auxiliaryAttributes === null) { 99 - throw new Exception("Attach auxiliary attributes before getting them!"); 100 - } 98 + $this->assertAttached($this->auxiliaryAttributes); 101 99 return idx($this->auxiliaryAttributes, $key, $default); 102 100 } 103 101 104 102 public function setAuxiliaryAttribute($key, $val) { 105 - if ($this->auxiliaryAttributes === null) { 106 - throw new Exception("Attach auxiliary attributes before setting them!"); 107 - } 103 + $this->assertAttached($this->auxiliaryAttributes); 104 + 108 105 $this->auxiliaryAttributes[$key] = $val; 109 106 $this->auxiliaryDirty[$key] = true; 110 107 return $this;
+4 -10
src/applications/paste/storage/PhabricatorPaste.php
··· 18 18 protected $viewPolicy; 19 19 protected $mailKey; 20 20 21 - private $content; 22 - private $rawContent; 21 + private $content = self::ATTACHABLE; 22 + private $rawContent = self::ATTACHABLE; 23 23 24 24 public function getURI() { 25 25 return '/P'.$this->getID(); ··· 70 70 } 71 71 72 72 public function getContent() { 73 - if ($this->content === null) { 74 - throw new Exception("Call attachContent() before getContent()!"); 75 - } 76 - return $this->content; 73 + return $this->assertAttached($this->content); 77 74 } 78 75 79 76 public function attachContent($content) { ··· 82 79 } 83 80 84 81 public function getRawContent() { 85 - if ($this->rawContent === null) { 86 - throw new Exception("Call attachRawContent() before getRawContent()!"); 87 - } 88 - return $this->rawContent; 82 + return $this->assertAttached($this->rawContent); 89 83 } 90 84 91 85 public function attachRawContent($raw_content) {
+2 -5
src/applications/people/storage/PhabricatorExternalAccount.php
··· 17 17 protected $profileImagePHID; 18 18 protected $properties = array(); 19 19 20 - private $profileImageFile; 20 + private $profileImageFile = self::ATTACHABLE; 21 21 22 22 public function getProfileImageFile() { 23 - if ($this->profileImageFile === null) { 24 - throw new Exception("Call attachProfileImageFile() first!"); 25 - } 26 - return $this->profileImageFile; 23 + return $this->assertAttached($this->profileImageFile); 27 24 } 28 25 29 26 public function attachProfileImageFile(PhabricatorFile $file) {
+4 -16
src/applications/phame/storage/PhameBlog.php
··· 21 21 protected $editPolicy; 22 22 protected $joinPolicy; 23 23 24 - private $bloggerPHIDs; 25 - private $bloggers; 24 + private $bloggerPHIDs = self::ATTACHABLE; 25 + private $bloggers = self::ATTACHABLE; 26 26 27 27 static private $requestBlog; 28 28 ··· 110 110 } 111 111 112 112 public function getBloggerPHIDs() { 113 - if ($this->bloggerPHIDs === null) { 114 - throw new Exception( 115 - 'You must loadBloggerPHIDs before you can getBloggerPHIDs!' 116 - ); 117 - } 118 - 119 - return $this->bloggerPHIDs; 113 + return $this->assertAttached($this->bloggerPHIDs); 120 114 } 121 115 122 116 public function loadBloggers() { ··· 149 143 } 150 144 151 145 public function getBloggers() { 152 - if ($this->bloggers === null) { 153 - throw new Exception( 154 - 'You must loadBloggers or attachBloggers before you can getBloggers!' 155 - ); 156 - } 157 - 158 - return $this->bloggers; 146 + return $this->assertAttached($this->bloggers); 159 147 } 160 148 161 149 public function getSkin() {
+2 -5
src/applications/phortune/storage/PhortuneAccount.php
··· 12 12 protected $name; 13 13 protected $balanceInCents = 0; 14 14 15 - private $memberPHIDs; 15 + private $memberPHIDs = self::ATTACHABLE; 16 16 17 17 public function getConfiguration() { 18 18 return array( ··· 26 26 } 27 27 28 28 public function getMemberPHIDs() { 29 - if ($this->memberPHIDs === null) { 30 - throw new Exception("Call attachMemberPHIDs() before getMemberPHIDs()!"); 31 - } 32 - return $this->memberPHIDs; 29 + return $this->assertAttached($this->memberPHIDs); 33 30 } 34 31 35 32 public function attachMemberPHIDs(array $phids) {
+2 -5
src/applications/phortune/storage/PhortuneCart.php
··· 6 6 protected $ownerPHID; 7 7 protected $metadata; 8 8 9 - private $purchases; 9 + private $purchases = self::ATTACHABLE; 10 10 11 11 public function getConfiguration() { 12 12 return array( ··· 33 33 } 34 34 35 35 public function getPurchases() { 36 - if ($this->purchases === null) { 37 - throw new Exception("Purchases not attached to cart!"); 38 - } 39 - return $this->purchases; 36 + return $this->assertAttached($this->purchases); 40 37 } 41 38 42 39 }
+2 -5
src/applications/phortune/storage/PhortunePaymentMethod.php
··· 22 22 protected $providerType; 23 23 protected $providerDomain; 24 24 25 - private $account; 25 + private $account = self::ATTACHABLE; 26 26 27 27 public function getConfiguration() { 28 28 return array( ··· 44 44 } 45 45 46 46 public function getAccount() { 47 - if (!$this->account) { 48 - throw new Exception("Call attachAccount() before getAccount()!"); 49 - } 50 - return $this->account; 47 + return $this->assertAttached($this->account); 51 48 } 52 49 53 50 public function getDescription() {
+7 -11
src/applications/project/storage/PhabricatorProject.php
··· 15 15 protected $joinPolicy; 16 16 17 17 private $subprojectsNeedUpdate; 18 - private $memberPHIDs; 19 - private $sparseMembers = array(); 18 + private $memberPHIDs = self::ATTACHABLE; 19 + private $sparseMembers = self::ATTACHABLE; 20 20 21 21 public function getCapabilities() { 22 22 return array( ··· 61 61 } 62 62 63 63 public function isUserMember($user_phid) { 64 - if (!isset($this->sparseMembers[$user_phid])) { 65 - throw new Exception( 66 - "Call setIsUserMember() before isUserMember()!"); 67 - } 68 - return $this->sparseMembers[$user_phid]; 64 + return $this->assertAttachedKey($this->sparseMembers, $user_phid); 69 65 } 70 66 71 67 public function setIsUserMember($user_phid, $is_member) { 68 + if ($this->sparseMembers === self::ATTACHABLE) { 69 + $this->sparseMembers = array(); 70 + } 72 71 $this->sparseMembers[$user_phid] = $is_member; 73 72 return $this; 74 73 } ··· 100 99 } 101 100 102 101 public function getMemberPHIDs() { 103 - if ($this->memberPHIDs === null) { 104 - throw new Exception("Call attachMemberPHIDs() first!"); 105 - } 106 - return $this->memberPHIDs; 102 + return $this->assertAttached($this->memberPHIDs); 107 103 } 108 104 109 105 public function loadMemberPHIDs() {
+2 -6
src/applications/releeph/storage/ReleephRequest.php
··· 22 22 protected $commitPHID; 23 23 24 24 // Pre-populated handles that we'll bulk load in ReleephBranch 25 - private $handles; 25 + private $handles = self::ATTACHABLE; 26 26 private $customFields = self::ATTACHABLE; 27 27 28 28 ··· 148 148 } 149 149 150 150 public function getHandles() { 151 - if (!$this->handles) { 152 - throw new Exception( 153 - "You must call ReleephBranch::populateReleephRequestHandles() first"); 154 - } 155 - return $this->handles; 151 + return $this->assertAttached($this->handles); 156 152 } 157 153 158 154 public function getDetail($key, $default = null) {
+2 -5
src/applications/repository/storage/PhabricatorRepositoryCommit.php
··· 15 15 protected $auditStatus = PhabricatorAuditCommitStatusConstants::NONE; 16 16 protected $summary = ''; 17 17 18 - private $commitData; 18 + private $commitData = self::ATTACHABLE; 19 19 private $audits; 20 20 private $isUnparsed; 21 21 private $repository = self::ATTACHABLE; ··· 65 65 } 66 66 67 67 public function getCommitData() { 68 - if (!$this->commitData) { 69 - throw new Exception("Attach commit data with attachCommitData() first!"); 70 - } 71 - return $this->commitData; 68 + return $this->assertAttached($this->commitData); 72 69 } 73 70 74 71 public function attachAudits(array $audits) {
+6 -16
src/applications/repository/storage/PhabricatorRepositorySymbol.php
··· 18 18 protected $pathID; 19 19 protected $lineNumber; 20 20 21 - private $path = false; 22 - private $arcanistProject = false; 23 - private $repository = false; 21 + private $path = self::ATTACHABLE; 22 + private $arcanistProject = self::ATTACHABLE; 23 + private $repository = self::ATTACHABLE; 24 24 25 25 public function getConfiguration() { 26 26 return array( ··· 51 51 } 52 52 53 53 public function getPath() { 54 - if ($this->path === false) { 55 - throw new Exception('Call attachPath() before getPath()!'); 56 - } 57 - return $this->path; 54 + return $this->assertAttached($this->path); 58 55 } 59 56 60 57 public function attachPath($path) { ··· 63 60 } 64 61 65 62 public function getRepository() { 66 - if ($this->repository === false) { 67 - throw new Exception('Call attachRepository() before getRepository()!'); 68 - } 69 - return $this->repository; 63 + return $this->assertAttached($this->repository); 70 64 } 71 65 72 66 public function attachRepository($repository) { ··· 75 69 } 76 70 77 71 public function getArcanistProject() { 78 - if ($this->arcanistProject === false) { 79 - throw new Exception( 80 - 'Call attachArcanistProject() before getArcanistProject()!'); 81 - } 82 - return $this->arcanistProject; 72 + return $this->assertAttached($this->arcanistProject); 83 73 } 84 74 85 75 public function attachArcanistProject($project) {
+9 -16
src/applications/slowvote/storage/PhabricatorSlowvotePoll.php
··· 24 24 protected $method; 25 25 protected $viewPolicy; 26 26 27 - private $options; 28 - private $choices; 29 - private $viewerChoices = array(); 27 + private $options = self::ATTACHABLE; 28 + private $choices = self::ATTACHABLE; 29 + private $viewerChoices = self::ATTACHABLE; 30 30 31 31 public function getConfiguration() { 32 32 return array( ··· 40 40 } 41 41 42 42 public function getOptions() { 43 - if ($this->options === null) { 44 - throw new Exception("Call attachOptions() before getOptions()!"); 45 - } 46 - return $this->options; 43 + return $this->assertAttached($this->options); 47 44 } 48 45 49 46 public function attachOptions(array $options) { ··· 53 50 } 54 51 55 52 public function getChoices() { 56 - if ($this->choices === null) { 57 - throw new Exception("Call attachChoices() before getChoices()!"); 58 - } 59 - return $this->choices; 53 + return $this->assertAttached($this->choices); 60 54 } 61 55 62 56 public function attachChoices(array $choices) { ··· 66 60 } 67 61 68 62 public function getViewerChoices(PhabricatorUser $viewer) { 69 - if (idx($this->viewerChoices, $viewer->getPHID()) === null) { 70 - throw new Exception( 71 - "Call attachViewerChoices() before getViewerChoices()!"); 72 - } 73 - return idx($this->viewerChoices, $viewer->getPHID()); 63 + return $this->assertAttachedKey($this->viewerChoices, $viewer->getPHID()); 74 64 } 75 65 76 66 public function attachViewerChoices(PhabricatorUser $viewer, array $choices) { 67 + if ($this->viewerChoices === self::ATTACHABLE) { 68 + $this->viewerChoices = array(); 69 + } 77 70 assert_instances_of($choices, 'PhabricatorSlowvoteChoice'); 78 71 $this->viewerChoices[$viewer->getPHID()] = $choices; 79 72 return $this;
+2 -5
src/applications/tokens/storage/PhabricatorTokenGiven.php
··· 7 7 protected $objectPHID; 8 8 protected $tokenPHID; 9 9 10 - private $object; 10 + private $object = self::ATTACHABLE; 11 11 12 12 public function attachObject(PhabricatorTokenReceiverInterface $object) { 13 13 $this->object = $object; ··· 15 15 } 16 16 17 17 public function getObject() { 18 - if ($this->object === null) { 19 - throw new Exception("Call attachObject() before getObject()!"); 20 - } 21 - return $this->object; 18 + return $this->assertAttached($this->object); 22 19 } 23 20 24 21 public function getCapabilities() {
+10 -7
src/infrastructure/storage/lisk/PhabricatorLiskDAO.php
··· 6 6 */ 7 7 abstract class PhabricatorLiskDAO extends LiskDAO { 8 8 9 - private $edges = array(); 9 + private $edges = self::ATTACHABLE; 10 10 private static $namespaceStack = array(); 11 11 12 12 const ATTACHABLE = "<attachable>"; ··· 29 29 * @task edges 30 30 */ 31 31 public function getEdges($type) { 32 - $edges = idx($this->edges, $type); 33 - if ($edges === null) { 34 - throw new Exception("Call attachEdges() before getEdges()!"); 35 - } 36 - return $edges; 32 + return $this->assertAttachedKey($this->edges, $type); 37 33 } 38 34 39 35 ··· 208 204 return $result; 209 205 } 210 206 211 - 212 207 protected function assertAttached($property) { 213 208 if ($property === self::ATTACHABLE) { 214 209 throw new PhabricatorDataNotAttachedException($this); 215 210 } 216 211 return $property; 212 + } 213 + 214 + protected function assertAttachedKey($value, $key) { 215 + $this->assertAttached($value); 216 + if (!array_key_exists($key, $value)) { 217 + throw new PhabricatorDataNotAttachedException($this); 218 + } 219 + return $value[$key]; 217 220 } 218 221 219 222 }