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

More Search-related PhpDoc additions

Summary: I'm still trying to understand search a bit better. As a side effect I add PhpDocs.

Test Plan: Inspect parameter and return formats, types, content while searching in Phorge.

Reviewers: O1 Blessed Committers, mainframe98

Reviewed By: O1 Blessed Committers, mainframe98

Subscribers: mainframe98, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

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

+60 -5
+33 -4
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 481 481 abstract public function getResultTypeDescription(); 482 482 483 483 484 + /** 485 + * @return PhabricatorSavedQuery New instance of PhabricatorSavedQuery 486 + */ 484 487 public function newSavedQuery() { 485 488 return id(new PhabricatorSavedQuery()) 486 489 ->setEngineClassName(get_class($this)); ··· 515 518 return $this; 516 519 } 517 520 521 + /** 522 + * @return array<string,PhabricatorNamedQuery> Array with pairs of the query 523 + * name (e.g. 'all' or 'open') and the corresponding PhabricatorNamedQuery 524 + */ 518 525 public function loadAllNamedQueries() { 519 526 $viewer = $this->requireViewer(); 520 527 $builtin = $this->getBuiltinQueries(); ··· 553 560 return $this->namedQueries + $builtin; 554 561 } 555 562 563 + /** 564 + * @return array<string,PhabricatorNamedQuery> Array with pairs of the query 565 + * name (e.g. 'all' or 'open') and the corresponding PhabricatorNamedQuery 566 + */ 556 567 public function loadEnabledNamedQueries() { 557 568 $named_queries = $this->loadAllNamedQueries(); 558 569 foreach ($named_queries as $key => $named_query) { ··· 563 574 return $named_queries; 564 575 } 565 576 577 + /** 578 + * @return string Name of the default query (e.g. 'all' or 'open') when not 579 + * passing a query key, e.g. by going to generic /search/ or /maniphest/ 580 + */ 566 581 public function getDefaultQueryKey() { 567 582 $viewer = $this->requireViewer(); 568 583 ··· 618 633 return $this->getApplication()->getApplicationURI($path); 619 634 } 620 635 636 + /** 637 + * @return PhabricatorApplication A PhabricatorApplication subclass 638 + */ 621 639 protected function getApplication() { 622 640 if (!$this->application) { 623 641 $class = $this->getApplicationClassName(); ··· 674 692 675 693 676 694 /** 695 + * @return array<string,PhabricatorNamedQuery> Array with pairs of the query 696 + * name (e.g. 'all' or 'open') and the corresponding PhabricatorNamedQuery 697 + * 677 698 * @task builtin 678 699 */ 679 700 public function getBuiltinQueries() { ··· 1000 1021 return idx($buckets, $key); 1001 1022 } 1002 1023 1003 - 1024 + /** 1025 + * @return int 1026 + */ 1004 1027 public function getPageSize(PhabricatorSavedQuery $saved) { 1005 1028 $bucket = $this->getResultBucket($saved); 1006 1029 ··· 1025 1048 return false; 1026 1049 } 1027 1050 1028 - 1051 + /** 1052 + * @return AphrontCursorPagerView|PHUIPagerView 1053 + */ 1029 1054 public function newPagerForSavedQuery(PhabricatorSavedQuery $saved) { 1030 1055 if ($this->shouldUseOffsetPaging()) { 1031 1056 $pager = new PHUIPagerView(); ··· 1047 1072 return $pager; 1048 1073 } 1049 1074 1050 - 1075 + /** 1076 + * @return array<string,PhabricatorObjectHandle> $results Array of pairs of 1077 + * the object's PHID as key and the corresponding PhabricatorObjectHandle 1078 + */ 1051 1079 public function executeQuery( 1052 1080 PhabricatorPolicyAwareQuery $query, 1053 1081 AphrontView $pager) { ··· 1662 1690 * Load from object and from storage, and updates Custom Fields instances 1663 1691 * that are attached to each object. 1664 1692 * 1665 - * @return map Map of of loaded fields (PHID to PhabricatorCustomFieldList). 1693 + * @return array<string, PhabricatorCustomFieldList> Map of loaded fields 1694 + * (PHID to PhabricatorCustomFieldList). 1666 1695 * @task custom 1667 1696 */ 1668 1697 protected function loadCustomFields(array $objects, $role) {
+17
src/applications/search/query/PhabricatorSearchApplicationSearchEngine.php
··· 43 43 return $saved; 44 44 } 45 45 46 + /** 47 + * @param PhabricatorSavedQuery $saved 48 + * @return PhabricatorSearchDocumentQuery 49 + */ 46 50 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 47 51 $query = new PhabricatorSearchDocumentQuery(); 48 52 ··· 182 186 ); 183 187 } 184 188 189 + /** 190 + * @return PhabricatorSavedQuery 191 + */ 185 192 public function buildSavedQueryFromBuiltin($query_key) { 186 193 $query = $this->newSavedQuery(); 187 194 $query->setQueryKey($query_key); ··· 200 207 return parent::buildSavedQueryFromBuiltin($query_key); 201 208 } 202 209 210 + /** 211 + * @return array<string,string> PHIDType and its description, for example 212 + * 'TASK => Maniphest Task' or 'DREV => Differential Revision' 213 + */ 203 214 public static function getIndexableDocumentTypes( 204 215 ?PhabricatorUser $viewer = null) { 205 216 ··· 240 251 return true; 241 252 } 242 253 254 + /** 255 + * @param array<string,PhabricatorObjectHandle> $results Array of pairs of 256 + * the object's PHID as key and the corresponding PhabricatorObjectHandle 257 + * @param PhabricatorSavedQuery $query 258 + * @param array<string,PhabricatorObjectHandle> $handles Unused. 259 + */ 243 260 protected function renderResultList( 244 261 array $results, 245 262 PhabricatorSavedQuery $query,
+10 -1
src/applications/search/view/PhabricatorSearchResultView.php
··· 11 11 return $this; 12 12 } 13 13 14 + /** 15 + * @param array<PhabricatorFulltextToken> $tokens 16 + * @return $this 17 + */ 14 18 public function setTokens(array $tokens) { 15 19 assert_instances_of($tokens, 'PhabricatorFulltextToken'); 16 20 $this->tokens = $tokens; ··· 22 26 return $this; 23 27 } 24 28 29 + /** 30 + * Render a search result item 31 + * 32 + * @return PHUIObjectItemView|null 33 + */ 25 34 public function render() { 26 35 $handle = $this->handle; 27 36 if (!$handle->isComplete()) { 28 - return; 37 + return null; 29 38 } 30 39 31 40 require_celerity_resource('phabricator-search-results-css');