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

PhabricatorTestDataGenerator documentation: minor refactor, minor PHPDoc

Summary:
Minor refactor in loadPhabricatorUserPHID() to do not reinvent the wheel.

Minor improvement of the PHPDoc.

Set methods as final, since nothing overrides them and nothing should.

Adopt the '::class' thing, which is just semantically more appropriate to get exactly the same string.

Test Plan:
Trigger the data generator:

./bin/lipsum generate all

It still works.

Optionally, add a `phlog('yup I am executed')` in one of the touched methods,
and repeat the lipsum generation, so you are 100% sure that the code works.

Optionally, run this:

var_dump(PhabricatorUser::class === 'PhabricatorUser');
true

So, no regressions. Sigh of relief.

-----

Look for code extending the touched methods:

grep -FR 'function loadPhabricatorUser' src/

Absolutely nothing else extends them. So, has sense to mark as final.

Reviewers: O1 Blessed Committers, aklapper

Reviewed By: O1 Blessed Committers, aklapper

Subscribers: aklapper, tobiaswiese, Matthew, Cigaryno

Differential Revision: https://we.phorge.it/D26279

+22 -6
+20 -4
src/applications/lipsum/generator/PhabricatorTestDataGenerator.php
··· 94 94 return $xaction; 95 95 } 96 96 97 + /** 98 + * Get one random object by its PHP class name. 99 + * 100 + * @param string $classname PHP class name. 101 + * @return string 102 + */ 97 103 public function loadOneRandom($classname) { 98 104 try { 99 105 return newv($classname, array()) ··· 108 114 } 109 115 } 110 116 111 - public function loadPhabricatorUserPHID() { 112 - return $this->loadOneRandom('PhabricatorUser')->getPHID(); 117 + /** 118 + * Get the PHID of a random Phabricator user. 119 + * 120 + * @return string 121 + */ 122 + final public function loadPhabricatorUserPHID() { 123 + return $this->loadPhabricatorUser()->getPHID(); 113 124 } 114 125 115 - public function loadPhabricatorUser() { 116 - return $this->loadOneRandom('PhabricatorUser'); 126 + /** 127 + * Get a random PhabricatorUser object. 128 + * 129 + * @return PhabricatorUser 130 + */ 131 + final public function loadPhabricatorUser() { 132 + return $this->loadOneRandom(PhabricatorUser::class); 117 133 } 118 134 119 135 }
+1 -1
src/applications/maniphest/lipsum/PhabricatorManiphestTaskTestDataGenerator.php
··· 72 72 public function getProjectPHIDs() { 73 73 $projects = array(); 74 74 for ($i = 0; $i < rand(1, 4);$i++) { 75 - $project = $this->loadOneRandom('PhabricatorProject'); 75 + $project = $this->loadOneRandom(PhabricatorProject::class); 76 76 if ($project) { 77 77 $projects[] = $project->getPHID(); 78 78 }
+1 -1
src/applications/owners/lipsum/PhabricatorOwnersPackageTestDataGenerator.php
··· 55 55 $paths = explode("\n", $paths); 56 56 $paths = array_unique($paths); 57 57 58 - $repository = $this->loadOneRandom('PhabricatorRepository'); 58 + $repository = $this->loadOneRandom(PhabricatorRepository::class); 59 59 if (!$repository) { 60 60 throw new Exception( 61 61 pht(