@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, valerio.bozzolan

Reviewed By: O1 Blessed Committers, valerio.bozzolan

Subscribers: tobiaswiese, valerio.bozzolan, Matthew, Cigaryno

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

+108
+33
src/applications/search/engineextension/PhabricatorSearchEngineExtension.php
··· 5 5 private $viewer; 6 6 private $searchEngine; 7 7 8 + /** 9 + * @return string The EXTENSIONKEY of the PhabricatorSearchEngineExtension 10 + * subclass 11 + */ 8 12 final public function getExtensionKey() { 9 13 return $this->getPhobjectClassConstant('EXTENSIONKEY'); 10 14 } ··· 14 18 return $this; 15 19 } 16 20 21 + /** 22 + * @return PhabricatorUser 23 + */ 17 24 final public function getViewer() { 18 25 return $this->viewer; 19 26 } ··· 24 31 return $this; 25 32 } 26 33 34 + /** 35 + * @return PhabricatorApplicationSearchEngine A subclass of 36 + * PhabricatorApplicationSearchEngine 37 + */ 27 38 final public function getSearchEngine() { 28 39 return $this->searchEngine; 29 40 } 30 41 42 + /** 43 + * @return bool 44 + */ 31 45 abstract public function isExtensionEnabled(); 46 + /** 47 + * @return string Description of the Search Engine Extension 48 + */ 32 49 abstract public function getExtensionName(); 50 + /** 51 + * @return bool 52 + */ 33 53 abstract public function supportsObject($object); 34 54 35 55 public function getExtensionOrder() { 36 56 return 7000; 37 57 } 38 58 59 + /** 60 + * @return array<PhabricatorSearchField> Subclasses of 61 + * PhabricatorSearchField, or an empty array 62 + */ 39 63 public function getSearchFields($object) { 40 64 return array(); 41 65 } 42 66 67 + /** 68 + * @return array<PhabricatorSearchEngineAttachment> Subclasses of 69 + * PhabricatorSearchEngineAttachment, or an empty array 70 + */ 43 71 public function getSearchAttachments($object) { 44 72 return array(); 45 73 } ··· 64 92 return array(); 65 93 } 66 94 95 + /** 96 + * @return map<string, PhabricatorSearchEngineExtension> Array of 97 + * PhabricatorSearchEngineExtension extension keys and the 98 + * PhabricatorSearchEngineExtension subclasses 99 + */ 67 100 final public static function getAllExtensions() { 68 101 return id(new PhutilClassMapQuery()) 69 102 ->setAncestorClass(__CLASS__)
+33
src/applications/search/ferret/PhabricatorFerretEngine.php
··· 6 6 private $ferretFunctions; 7 7 private $templateObject; 8 8 9 + /** 10 + * @return string Application name in lower-case, e.g. 'maniphest' 11 + */ 9 12 abstract public function getApplicationName(); 13 + /** 14 + * @return string Object name in lower-case, e.g. 'task' 15 + */ 10 16 abstract public function getScopeName(); 17 + /** 18 + * @return string New instance of the corresponding 19 + * PhabricatorApplicationSearchEngine subclass 20 + */ 11 21 abstract public function newSearchEngine(); 12 22 13 23 public function getDefaultFunctionKey() { ··· 47 57 return $this->fieldMap[$raw_name]; 48 58 } 49 59 60 + /** 61 + * @return PhutilSearchStemmer New instance of PhutilSearchStemmer 62 + */ 50 63 public function newStemmer() { 51 64 return new PhutilSearchStemmer(); 52 65 } 53 66 67 + /** 68 + * @return string 69 + */ 54 70 public function newTermsCorpus($raw_corpus) { 55 71 $term_corpus = strtr( 56 72 $raw_corpus, ··· 108 124 109 125 /* -( Schema )------------------------------------------------------------- */ 110 126 127 + /** 128 + * @return string Name of database table, e.g. 'calendar_event_fdocument' or 129 + * 'maniphest_task_fdocument' or 'phame_post_fdocument' 130 + */ 111 131 public function getDocumentTableName() { 112 132 $application = $this->getApplicationName(); 113 133 $scope = $this->getScopeName(); ··· 152 172 ); 153 173 } 154 174 175 + /** 176 + * @return string Name of database table, e.g. 'calendar_event_ffield' or 177 + * 'maniphest_task_ffield' or 'phame_post_ffield' 178 + */ 155 179 public function getFieldTableName() { 156 180 $application = $this->getApplicationName(); 157 181 $scope = $this->getScopeName(); ··· 183 207 ); 184 208 } 185 209 210 + /** 211 + * @return string Name of database table, e.g. 'calendar_event_fngrams' or 212 + * 'maniphest_task_fngrams' or 'phame_post_fngrams' 213 + */ 186 214 public function getNgramsTableName() { 187 215 $application = $this->getApplicationName(); 188 216 $scope = $this->getScopeName(); ··· 213 241 ); 214 242 } 215 243 244 + /** 245 + * @return string Name of database table, e.g. 246 + * 'calendar_event_fngrams_common' or 'maniphest_task_fngrams_common' or 247 + * 'phame_post_fngrams_common' 248 + */ 216 249 public function getCommonNgramsTableName() { 217 250 $application = $this->getApplicationName(); 218 251 $scope = $this->getScopeName();
+13
src/applications/search/ferret/PhabricatorFerretMetadata.php
··· 11 11 return $this; 12 12 } 13 13 14 + /** 15 + * @return PhabricatorFerretEngine A subclass of PhabricatorFerretEngine, 16 + * e.g. DiffusionCommitFerretEngine or ManiphestTaskFerretEngine 17 + */ 14 18 public function getEngine() { 15 19 return $this->engine; 16 20 } ··· 20 24 return $this; 21 25 } 22 26 27 + /** 28 + * @return string PHID of a search result 29 + */ 23 30 public function getPHID() { 24 31 return $this->phid; 25 32 } ··· 29 36 return $this; 30 37 } 31 38 39 + /** 40 + * @return int 41 + */ 32 42 public function getRelevance() { 33 43 return $this->relevance; 34 44 } 35 45 46 + /** 47 + * @return PhutilSortVector 48 + */ 36 49 public function getRelevanceSortVector() { 37 50 $engine = $this->getEngine(); 38 51
+29
src/applications/search/ferret/function/FerretSearchFunction.php
··· 3 3 abstract class FerretSearchFunction 4 4 extends Phobject { 5 5 6 + /** 7 + * @return string Ferret function name, e.g. 'title', 'body', 'comment', 8 + * 'core', 'all' 9 + */ 6 10 abstract public function getFerretFunctionName(); 11 + /** 12 + * @return string Ferret field key, e.g. 'titl', 'body', 'cmnt', 'core', 13 + * 'full' 14 + */ 7 15 abstract public function getFerretFieldKey(); 16 + /** 17 + * @return bool 18 + */ 8 19 abstract public function supportsObject(PhabricatorFerretInterface $object); 9 20 21 + /** 22 + * @param string $name 23 + * @return string Lower-case $name 24 + */ 10 25 final public static function getNormalizedFunctionName($name) { 11 26 return phutil_utf8_strtolower($name); 12 27 } 13 28 29 + /** 30 + * @param string $function_name 31 + * @return void 32 + * @throws Exception if $function_name is invalid 33 + */ 14 34 final public static function validateFerretFunctionName($function_name) { 15 35 if (!preg_match('/^[a-zA-Z-]+\z/', $function_name)) { 16 36 throw new Exception( ··· 22 42 } 23 43 } 24 44 45 + /** 46 + * @param string $field_key Ferret search engine field key, supposed to be 47 + * four characters and only lowercase latin letters 48 + * @return void 49 + * @throws Exception if $field_key is invalid 50 + */ 25 51 final public static function validateFerretFunctionFieldKey($field_key) { 26 52 if (!preg_match('/^[a-z]{4}\z/', $field_key)) { 27 53 throw new Exception( ··· 33 59 } 34 60 } 35 61 62 + /** 63 + * @return array<string,FerretSearchFunction> 64 + */ 36 65 final public static function newFerretSearchFunctions() { 37 66 $extensions = PhabricatorFulltextEngineExtension::getAllExtensions(); 38 67