diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index 63ba07e2e4fc5..e92725d814bd2 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -422,6 +422,7 @@ 'OCP\\Files\\UnseekableException' => $baseDir . '/lib/public/Files/UnseekableException.php', 'OCP\\Files_FullTextSearch\\Model\\AFilesDocument' => $baseDir . '/lib/public/Files_FullTextSearch/Model/AFilesDocument.php', 'OCP\\FullTextSearch\\Exceptions\\FullTextSearchAppNotAvailableException' => $baseDir . '/lib/public/FullTextSearch/Exceptions/FullTextSearchAppNotAvailableException.php', + 'OCP\\FullTextSearch\\Exceptions\\FullTextSearchIndexNotAvailableException' => $baseDir . '/lib/public/FullTextSearch/Exceptions/FullTextSearchIndexNotAvailableException.php', 'OCP\\FullTextSearch\\IFullTextSearchManager' => $baseDir . '/lib/public/FullTextSearch/IFullTextSearchManager.php', 'OCP\\FullTextSearch\\IFullTextSearchPlatform' => $baseDir . '/lib/public/FullTextSearch/IFullTextSearchPlatform.php', 'OCP\\FullTextSearch\\IFullTextSearchProvider' => $baseDir . '/lib/public/FullTextSearch/IFullTextSearchProvider.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index bf1a13d49dec0..0746fa5c9b0f9 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -455,6 +455,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2 'OCP\\Files\\UnseekableException' => __DIR__ . '/../../..' . '/lib/public/Files/UnseekableException.php', 'OCP\\Files_FullTextSearch\\Model\\AFilesDocument' => __DIR__ . '/../../..' . '/lib/public/Files_FullTextSearch/Model/AFilesDocument.php', 'OCP\\FullTextSearch\\Exceptions\\FullTextSearchAppNotAvailableException' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Exceptions/FullTextSearchAppNotAvailableException.php', + 'OCP\\FullTextSearch\\Exceptions\\FullTextSearchIndexNotAvailableException' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/Exceptions/FullTextSearchIndexNotAvailableException.php', 'OCP\\FullTextSearch\\IFullTextSearchManager' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/IFullTextSearchManager.php', 'OCP\\FullTextSearch\\IFullTextSearchPlatform' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/IFullTextSearchPlatform.php', 'OCP\\FullTextSearch\\IFullTextSearchProvider' => __DIR__ . '/../../..' . '/lib/public/FullTextSearch/IFullTextSearchProvider.php', diff --git a/lib/private/FullTextSearch/FullTextSearchManager.php b/lib/private/FullTextSearch/FullTextSearchManager.php index 8d850513949c5..acaf519209b62 100644 --- a/lib/private/FullTextSearch/FullTextSearchManager.php +++ b/lib/private/FullTextSearch/FullTextSearchManager.php @@ -39,47 +39,35 @@ * @package OC\FullTextSearch */ class FullTextSearchManager implements IFullTextSearchManager { - /** @var IProviderService */ - private $providerService; + private ?IProviderService $providerService; - /** @var IIndexService */ - private $indexService; - - /** @var ISearchService */ - private $searchService; + private ?IIndexService $indexService; + private ?ISearchService $searchService; /** * @since 15.0.0 - * - * @param IProviderService $providerService */ - public function registerProviderService(IProviderService $providerService) { + public function registerProviderService(IProviderService $providerService): void { $this->providerService = $providerService; } /** * @since 15.0.0 - * - * @param IIndexService $indexService */ - public function registerIndexService(IIndexService $indexService) { + public function registerIndexService(IIndexService $indexService): void { $this->indexService = $indexService; } /** * @since 15.0.0 - * - * @param ISearchService $searchService */ - public function registerSearchService(ISearchService $searchService) { + public function registerSearchService(ISearchService $searchService): void { $this->searchService = $searchService; } /** * @since 16.0.0 - * - * @return bool */ public function isAvailable(): bool { if ($this->indexService === null || @@ -93,7 +81,6 @@ public function isAvailable(): bool { /** - * @return IProviderService * @throws FullTextSearchAppNotAvailableException */ private function getProviderService(): IProviderService { @@ -106,7 +93,6 @@ private function getProviderService(): IProviderService { /** - * @return IIndexService * @throws FullTextSearchAppNotAvailableException */ private function getIndexService(): IIndexService { @@ -119,7 +105,6 @@ private function getIndexService(): IIndexService { /** - * @return ISearchService * @throws FullTextSearchAppNotAvailableException */ private function getSearchService(): ISearchService { @@ -134,15 +119,12 @@ private function getSearchService(): ISearchService { /** * @throws FullTextSearchAppNotAvailableException */ - public function addJavascriptAPI() { + public function addJavascriptAPI(): void { $this->getProviderService()->addJavascriptAPI(); } /** - * @param string $providerId - * - * @return bool * @throws FullTextSearchAppNotAvailableException */ public function isProviderIndexed(string $providerId): bool { @@ -151,9 +133,6 @@ public function isProviderIndexed(string $providerId): bool { /** - * @param string $providerId - * @param string $documentId - * @return IIndex * @throws FullTextSearchAppNotAvailableException */ public function getIndex(string $providerId, string $documentId): IIndex { @@ -161,46 +140,45 @@ public function getIndex(string $providerId, string $documentId): IIndex { } /** - * @param string $providerId - * @param string $documentId - * @param string $userId - * @param int $status - * * @see IIndex for available value for $status. * - * @return IIndex * @throws FullTextSearchAppNotAvailableException */ - public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex { + public function createIndex( + string $providerId, + string $documentId, + string $userId, + int $status = 0, + ): IIndex { return $this->getIndexService()->createIndex($providerId, $documentId, $userId, $status); } /** - * @param string $providerId - * @param string $documentId - * @param int $status - * @param bool $reset - * * @see IIndex for available value for $status. * * @throws FullTextSearchAppNotAvailableException */ - public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false) { + public function updateIndexStatus( + string $providerId, + string $documentId, + int $status, + bool $reset = false, + ): void { $this->getIndexService()->updateIndexStatus($providerId, $documentId, $status, $reset); } /** - * @param string $providerId - * @param array $documentIds - * @param int $status - * @param bool $reset - * * @see IIndex for available value for $status. * * @throws FullTextSearchAppNotAvailableException */ - public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false) { + public function updateIndexesStatus( + string $providerId, + array $documentIds, + int $status, + bool $reset = false, + ): void { $this->getIndexService()->updateIndexesStatus($providerId, $documentIds, $status, $reset); } @@ -210,15 +188,12 @@ public function updateIndexesStatus(string $providerId, array $documentIds, int * * @throws FullTextSearchAppNotAvailableException */ - public function updateIndexes(array $indexes) { + public function updateIndexes(array $indexes): void { $this->getIndexService()->updateIndexes($indexes); } /** - * @param array $request - * @param string $userId - * * @return ISearchResult[] * @throws FullTextSearchAppNotAvailableException */ diff --git a/lib/private/FullTextSearch/Model/DocumentAccess.php b/lib/private/FullTextSearch/Model/DocumentAccess.php index cb2b95284f1d7..eecd038ca036b 100644 --- a/lib/private/FullTextSearch/Model/DocumentAccess.php +++ b/lib/private/FullTextSearch/Model/DocumentAccess.php @@ -49,23 +49,17 @@ * @package OC\FullTextSearch\Model */ final class DocumentAccess implements IDocumentAccess, JsonSerializable { - /** @var string */ - private $ownerId; + private string $ownerId; - /** @var string */ - private $viewerId = ''; + private string $viewerId = ''; - /** @var array */ - private $users = []; + private array $users = []; - /** @var array */ - private $groups = []; + private array $groups = []; - /** @var array */ - private $circles = []; + private array $circles = []; - /** @var array */ - private $links = []; + private array $links = []; /** @@ -74,8 +68,6 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable { * @since 16.0.0 * * IDocumentAccess constructor. - * - * @param string $ownerId */ public function __construct(string $ownerId = '') { $this->setOwnerId($ownerId); @@ -86,10 +78,6 @@ public function __construct(string $ownerId = '') { * Set the Owner of the document. * * @since 16.0.0 - * - * @param string $ownerId - * - * @return IDocumentAccess */ public function setOwnerId(string $ownerId): IDocumentAccess { $this->ownerId = $ownerId; @@ -101,8 +89,6 @@ public function setOwnerId(string $ownerId): IDocumentAccess { * Get the Owner of the document. * * @since 16.0.0 - * - * @return string */ public function getOwnerId(): string { return $this->ownerId; @@ -113,10 +99,6 @@ public function getOwnerId(): string { * Set the viewer of the document. * * @since 16.0.0 - * - * @param string $viewerId - * - * @return IDocumentAccess */ public function setViewerId(string $viewerId): IDocumentAccess { $this->viewerId = $viewerId; @@ -128,8 +110,6 @@ public function setViewerId(string $viewerId): IDocumentAccess { * Get the viewer of the document. * * @since 16.0.0 - * - * @return string */ public function getViewerId(): string { return $this->viewerId; @@ -140,10 +120,6 @@ public function getViewerId(): string { * Set the list of users that have read access to the document. * * @since 16.0.0 - * - * @param array $users - * - * @return IDocumentAccess */ public function setUsers(array $users): IDocumentAccess { $this->users = $users; @@ -155,10 +131,6 @@ public function setUsers(array $users): IDocumentAccess { * Add an entry to the list of users that have read access to the document. * * @since 16.0.0 - * - * @param string $user - * - * @return IDocumentAccess */ public function addUser(string $user): IDocumentAccess { $this->users[] = $user; @@ -171,10 +143,6 @@ public function addUser(string $user): IDocumentAccess { * document. * * @since 16.0.0 - * - * @param array $users - * - * @return IDocumentAccess */ public function addUsers($users): IDocumentAccess { $this->users = array_merge($this->users, $users); @@ -186,8 +154,6 @@ public function addUsers($users): IDocumentAccess { * Get the complete list of users that have read access to the document. * * @since 16.0.0 - * - * @return array */ public function getUsers(): array { return $this->users; @@ -198,10 +164,6 @@ public function getUsers(): array { * Set the list of groups that have read access to the document. * * @since 16.0.0 - * - * @param array $groups - * - * @return IDocumentAccess */ public function setGroups(array $groups): IDocumentAccess { $this->groups = $groups; @@ -213,10 +175,6 @@ public function setGroups(array $groups): IDocumentAccess { * Add an entry to the list of groups that have read access to the document. * * @since 16.0.0 - * - * @param string $group - * - * @return IDocumentAccess */ public function addGroup(string $group): IDocumentAccess { $this->groups[] = $group; @@ -229,12 +187,8 @@ public function addGroup(string $group): IDocumentAccess { * document. * * @since 16.0.0 - * - * @param array $groups - * - * @return IDocumentAccess */ - public function addGroups(array $groups) { + public function addGroups(array $groups): IDocumentAccess { $this->groups = array_merge($this->groups, $groups); return $this; @@ -244,8 +198,6 @@ public function addGroups(array $groups) { * Get the complete list of groups that have read access to the document. * * @since 16.0.0 - * - * @return array */ public function getGroups(): array { return $this->groups; @@ -256,10 +208,6 @@ public function getGroups(): array { * Set the list of circles that have read access to the document. * * @since 16.0.0 - * - * @param array $circles - * - * @return IDocumentAccess */ public function setCircles(array $circles): IDocumentAccess { $this->circles = $circles; @@ -271,10 +219,6 @@ public function setCircles(array $circles): IDocumentAccess { * Add an entry to the list of circles that have read access to the document. * * @since 16.0.0 - * - * @param string $circle - * - * @return IDocumentAccess */ public function addCircle(string $circle): IDocumentAccess { $this->circles[] = $circle; @@ -287,10 +231,6 @@ public function addCircle(string $circle): IDocumentAccess { * document. * * @since 16.0.0 - * - * @param array $circles - * - * @return IDocumentAccess */ public function addCircles(array $circles): IDocumentAccess { $this->circles = array_merge($this->circles, $circles); @@ -302,8 +242,6 @@ public function addCircles(array $circles): IDocumentAccess { * Get the complete list of circles that have read access to the document. * * @since 16.0.0 - * - * @return array */ public function getCircles(): array { return $this->circles; @@ -314,10 +252,6 @@ public function getCircles(): array { * Set the list of links that have read access to the document. * * @since 16.0.0 - * - * @param array $links - * - * @return IDocumentAccess */ public function setLinks(array $links): IDocumentAccess { $this->links = $links; @@ -329,8 +263,6 @@ public function setLinks(array $links): IDocumentAccess { * Get the list of links that have read access to the document. * * @since 16.0.0 - * - * @return array */ public function getLinks(): array { return $this->links; @@ -339,8 +271,6 @@ public function getLinks(): array { /** * @since 16.0.0 - * - * @return array */ public function jsonSerialize(): array { return [ diff --git a/lib/private/FullTextSearch/Model/IndexDocument.php b/lib/private/FullTextSearch/Model/IndexDocument.php index 74788463693ad..1b2e0eb58962f 100644 --- a/lib/private/FullTextSearch/Model/IndexDocument.php +++ b/lib/private/FullTextSearch/Model/IndexDocument.php @@ -26,6 +26,7 @@ namespace OC\FullTextSearch\Model; use JsonSerializable; +use OCP\FullTextSearch\Exceptions\FullTextSearchIndexNotAvailableException; use OCP\FullTextSearch\Model\IDocumentAccess; use OCP\FullTextSearch\Model\IIndex; use OCP\FullTextSearch\Model\IIndexDocument; @@ -47,62 +48,41 @@ * @package OC\FullTextSearch\Model */ class IndexDocument implements IIndexDocument, JsonSerializable { - /** @var string */ - protected $id = ''; + protected string $id = ''; - /** @var string */ - protected $providerId = ''; + protected DocumentAccess $access; - /** @var DocumentAccess */ - protected $access; + protected ?IIndex $index = null; - /** @var IIndex */ - protected $index; + protected int $modifiedTime = 0; - /** @var int */ - protected $modifiedTime = 0; + protected string $source = ''; - /** @var string */ - protected $source = ''; + protected array $tags = []; - /** @var array */ - protected $tags = []; + protected array $metaTags = []; - /** @var array */ - protected $metaTags = []; + protected array $subTags = []; - /** @var array */ - protected $subTags = []; + protected string $title = ''; - /** @var string */ - protected $title = ''; + protected string $content = ''; - /** @var string */ - protected $content = ''; + protected string $hash = ''; - /** @var string */ - protected $hash = ''; + protected array $parts = []; - /** @var array */ - protected $parts = []; + protected string $link = ''; - /** @var string */ - protected $link = ''; + protected array $more = []; - /** @var array */ - protected $more = []; + protected array $excerpts = []; - /** @var array */ - protected $excerpts = []; + protected string $score = ''; - /** @var string */ - protected $score = ''; + protected array $info = []; - /** @var array */ - protected $info = []; - - /** @var int */ - protected $contentEncoded = 0; + protected int $contentEncoded = 0; /** @@ -112,12 +92,11 @@ class IndexDocument implements IIndexDocument, JsonSerializable { * and the Id of the original document. * * @since 15.0.0 - * - * @param string $providerId - * @param string $documentId */ - public function __construct(string $providerId, string $documentId) { - $this->providerId = $providerId; + public function __construct( + protected string $providerId, + string $documentId, + ) { $this->id = $documentId; } @@ -126,8 +105,6 @@ public function __construct(string $providerId, string $documentId) { * Returns the Id of the original document. * * @since 15.0.0 - * - * @return string */ final public function getId(): string { return $this->id; @@ -138,8 +115,6 @@ final public function getId(): string { * Returns the Id of the provider. * * @since 15.0.0 - * - * @return string */ final public function getProviderId(): string { return $this->providerId; @@ -152,10 +127,6 @@ final public function getProviderId(): string { * @see IIndex * * @since 15.0.0 - * - * @param IIndex $index - * - * @return IIndexDocument */ final public function setIndex(IIndex $index): IIndexDocument { $this->index = $index; @@ -166,11 +137,14 @@ final public function setIndex(IIndex $index): IIndexDocument { /** * Get the Index. * + * @throws FullTextSearchIndexNotAvailableException * @since 15.0.0 - * - * @return IIndex */ final public function getIndex(): IIndex { + if ($this->index === null) { + throw new FullTextSearchIndexNotAvailableException('No IIndex generated'); + } + return $this->index; } @@ -178,22 +152,15 @@ final public function getIndex(): IIndex { * return if Index is defined. * * @since 16.0.0 - * - * @return bool */ final public function hasIndex(): bool { - return ($this->index !== null); + return $this->index !== null; } - /** * Set the modified time of the original document. * * @since 15.0.0 - * - * @param int $modifiedTime - * - * @return IIndexDocument */ final public function setModifiedTime(int $modifiedTime): IIndexDocument { $this->modifiedTime = $modifiedTime; @@ -205,8 +172,6 @@ final public function setModifiedTime(int $modifiedTime): IIndexDocument { * Get the modified time of the original document. * * @since 15.0.0 - * - * @return int */ final public function getModifiedTime(): int { return $this->modifiedTime; @@ -216,10 +181,6 @@ final public function getModifiedTime(): int { * Check if the original document of the IIndexDocument is older than $time. * * @since 15.0.0 - * - * @param int $time - * - * @return bool */ final public function isOlderThan(int $time): bool { return ($this->modifiedTime < $time); @@ -232,10 +193,6 @@ final public function isOlderThan(int $time): bool { * @see IDocumentAccess * * @since 15.0.0 - * - * @param IDocumentAccess $access - * - * @return $this */ final public function setAccess(IDocumentAccess $access): IIndexDocument { $this->access = $access; @@ -247,8 +204,6 @@ final public function setAccess(IDocumentAccess $access): IIndexDocument { * Get the IDocumentAccess related to the original document. * * @since 15.0.0 - * - * @return IDocumentAccess */ final public function getAccess(): IDocumentAccess { return $this->access; @@ -259,10 +214,6 @@ final public function getAccess(): IDocumentAccess { * Add a tag to the list. * * @since 15.0.0 - * - * @param string $tag - * - * @return IIndexDocument */ final public function addTag(string $tag): IIndexDocument { $this->tags[] = $tag; @@ -274,10 +225,6 @@ final public function addTag(string $tag): IIndexDocument { * Set the list of tags assigned to the original document. * * @since 15.0.0 - * - * @param array $tags - * - * @return IIndexDocument */ final public function setTags(array $tags): IIndexDocument { $this->tags = $tags; @@ -289,8 +236,6 @@ final public function setTags(array $tags): IIndexDocument { * Get the list of tags assigned to the original document. * * @since 15.0.0 - * - * @return array */ final public function getTags(): array { return $this->tags; @@ -301,10 +246,6 @@ final public function getTags(): array { * Add a meta tag to the list. * * @since 15.0.0 - * - * @param string $tag - * - * @return IIndexDocument */ final public function addMetaTag(string $tag): IIndexDocument { $this->metaTags[] = $tag; @@ -316,10 +257,6 @@ final public function addMetaTag(string $tag): IIndexDocument { * Set the list of meta tags assigned to the original document. * * @since 15.0.0 - * - * @param array $tags - * - * @return IIndexDocument */ final public function setMetaTags(array $tags): IIndexDocument { $this->metaTags = $tags; @@ -331,8 +268,6 @@ final public function setMetaTags(array $tags): IIndexDocument { * Get the list of meta tags assigned to the original document. * * @since 15.0.0 - * - * @return array */ final public function getMetaTags(): array { return $this->metaTags; @@ -343,11 +278,6 @@ final public function getMetaTags(): array { * Add a sub tag to the list. * * @since 15.0.0 - * - * @param string $sub - * @param string $tag - * - * @return IIndexDocument */ final public function addSubTag(string $sub, string $tag): IIndexDocument { if (!array_key_exists($sub, $this->subTags)) { @@ -364,10 +294,6 @@ final public function addSubTag(string $sub, string $tag): IIndexDocument { * Set the list of sub tags assigned to the original document. * * @since 15.0.0 - * - * @param array $tags - * - * @return IIndexDocument */ final public function setSubTags(array $tags): IIndexDocument { $this->subTags = $tags; @@ -381,10 +307,6 @@ final public function setSubTags(array $tags): IIndexDocument { * dimensional array. * * @since 15.0.0 - * - * @param bool $formatted - * - * @return array */ final public function getSubTags(bool $formatted = false): array { if ($formatted === false) { @@ -408,10 +330,6 @@ final public function getSubTags(bool $formatted = false): array { * Set the source of the original document. * * @since 15.0.0 - * - * @param string $source - * - * @return IIndexDocument */ final public function setSource(string $source): IIndexDocument { $this->source = $source; @@ -423,8 +341,6 @@ final public function setSource(string $source): IIndexDocument { * Get the source of the original document. * * @since 15.0.0 - * - * @return string */ final public function getSource(): string { return $this->source; @@ -435,10 +351,6 @@ final public function getSource(): string { * Set the title of the original document. * * @since 15.0.0 - * - * @param string $title - * - * @return IIndexDocument */ final public function setTitle(string $title): IIndexDocument { $this->title = $title; @@ -450,8 +362,6 @@ final public function setTitle(string $title): IIndexDocument { * Get the title of the original document. * * @since 15.0.0 - * - * @return string */ final public function getTitle(): string { return $this->title; @@ -464,11 +374,6 @@ final public function getTitle(): string { * encoded in base64. * * @since 15.0.0 - * - * @param string $content - * @param int $encoded - * - * @return IIndexDocument */ final public function setContent(string $content, int $encoded = 0): IIndexDocument { $this->content = $content; @@ -481,8 +386,6 @@ final public function setContent(string $content, int $encoded = 0): IIndexDocum * Get the content of the original document. * * @since 15.0.0 - * - * @return string */ final public function getContent(): string { return $this->content; @@ -492,8 +395,6 @@ final public function getContent(): string { * Returns the type of the encoding on the content. * * @since 15.0.0 - * - * @return int */ final public function isContentEncoded(): int { return $this->contentEncoded; @@ -503,8 +404,6 @@ final public function isContentEncoded(): int { * Return the size of the content. * * @since 15.0.0 - * - * @return int */ final public function getContentSize(): int { return strlen($this->getContent()); @@ -512,11 +411,9 @@ final public function getContentSize(): int { /** - * Generate an hash, based on the content of the original document. + * Generate a hash, based on the content of the original document. * * @since 15.0.0 - * - * @return IIndexDocument */ final public function initHash(): IIndexDocument { if ($this->getContent() === '' || is_null($this->getContent())) { @@ -532,10 +429,6 @@ final public function initHash(): IIndexDocument { * Set the hash of the original document. * * @since 15.0.0 - * - * @param string $hash - * - * @return IIndexDocument */ final public function setHash(string $hash): IIndexDocument { $this->hash = $hash; @@ -547,8 +440,6 @@ final public function setHash(string $hash): IIndexDocument { * Get the hash of the original document. * * @since 15.0.0 - * - * @return string */ final public function getHash(): string { return $this->hash; @@ -562,11 +453,6 @@ final public function getHash(): string { * $part string. * * @since 15.0.0 - * - * @param string $part - * @param string $content - * - * @return IIndexDocument */ final public function addPart(string $part, string $content): IIndexDocument { $this->parts[$part] = $content; @@ -578,10 +464,6 @@ final public function addPart(string $part, string $content): IIndexDocument { * Set all parts and their content. * * @since 15.0.0 - * - * @param array $parts - * - * @return IIndexDocument */ final public function setParts(array $parts): IIndexDocument { $this->parts = $parts; @@ -593,8 +475,6 @@ final public function setParts(array $parts): IIndexDocument { * Get all parts of the IIndexDocument. * * @since 15.0.0 - * - * @return array */ final public function getParts(): array { return $this->parts; @@ -605,10 +485,6 @@ final public function getParts(): array { * Add a link, usable by the frontend. * * @since 15.0.0 - * - * @param string $link - * - * @return IIndexDocument */ final public function setLink(string $link): IIndexDocument { $this->link = $link; @@ -620,8 +496,6 @@ final public function setLink(string $link): IIndexDocument { * Get the link. * * @since 15.0.0 - * - * @return string */ final public function getLink(): string { return $this->link; @@ -632,10 +506,6 @@ final public function getLink(): string { * Set more information that couldn't be set using other method. * * @since 15.0.0 - * - * @param array $more - * - * @return IIndexDocument */ final public function setMore(array $more): IIndexDocument { $this->more = $more; @@ -647,8 +517,6 @@ final public function setMore(array $more): IIndexDocument { * Get more information. * * @since 15.0.0 - * - * @return array */ final public function getMore(): array { return $this->more; @@ -660,11 +528,6 @@ final public function getMore(): array { * on the search request. * * @since 16.0.0 - * - * @param string $source - * @param string $excerpt - * - * @return IIndexDocument */ final public function addExcerpt(string $source, string $excerpt): IIndexDocument { $this->excerpts[] = @@ -681,10 +544,6 @@ final public function addExcerpt(string $source, string $excerpt): IIndexDocumen * Set all excerpts of the content of the original document. * * @since 16.0.0 - * - * @param array $excerpts - * - * @return IIndexDocument */ final public function setExcerpts(array $excerpts): IIndexDocument { $new = []; @@ -704,8 +563,6 @@ final public function setExcerpts(array $excerpts): IIndexDocument { * Get all excerpts of the content of the original document. * * @since 15.0.0 - * - * @return array */ final public function getExcerpts(): array { return $this->excerpts; @@ -715,9 +572,6 @@ final public function getExcerpts(): array { * Clean excerpt. * * @since 16.0.0 - * - * @param string $excerpt - * @return string */ private function cleanExcerpt(string $excerpt): string { $excerpt = str_replace("\\n", ' ', $excerpt); @@ -736,10 +590,6 @@ private function cleanExcerpt(string $excerpt): string { * request. * * @since 15.0.0 - * - * @param string $score - * - * @return IIndexDocument */ final public function setScore(string $score): IIndexDocument { $this->score = $score; @@ -751,8 +601,6 @@ final public function setScore(string $score): IIndexDocument { * Get the score. * * @since 15.0.0 - * - * @return string */ final public function getScore(): string { return $this->score; @@ -767,11 +615,6 @@ final public function getScore(): string { * indexing. * * @since 15.0.0 - * - * @param string $info - * @param string $value - * - * @return IIndexDocument */ final public function setInfo(string $info, string $value): IIndexDocument { $this->info[$info] = $value; @@ -783,11 +626,6 @@ final public function setInfo(string $info, string $value): IIndexDocument { * Get an information about a document. (string) * * @since 15.0.0 - * - * @param string $info - * @param string $default - * - * @return string */ final public function getInfo(string $info, string $default = ''): string { if (!key_exists($info, $this->info)) { @@ -805,11 +643,6 @@ final public function getInfo(string $info, string $default = ''): string { * indexing. * * @since 15.0.0 - * - * @param string $info - * @param array $value - * - * @return IIndexDocument */ final public function setInfoArray(string $info, array $value): IIndexDocument { $this->info[$info] = $value; @@ -821,11 +654,6 @@ final public function setInfoArray(string $info, array $value): IIndexDocument { * Get an information about a document. (array) * * @since 15.0.0 - * - * @param string $info - * @param array $default - * - * @return array */ final public function getInfoArray(string $info, array $default = []): array { if (!key_exists($info, $this->info)) { @@ -843,11 +671,6 @@ final public function getInfoArray(string $info, array $default = []): array { * indexing. * * @since 15.0.0 - * - * @param string $info - * @param int $value - * - * @return IIndexDocument */ final public function setInfoInt(string $info, int $value): IIndexDocument { $this->info[$info] = $value; @@ -859,11 +682,6 @@ final public function setInfoInt(string $info, int $value): IIndexDocument { * Get an information about a document. (int) * * @since 15.0.0 - * - * @param string $info - * @param int $default - * - * @return int */ final public function getInfoInt(string $info, int $default = 0): int { if (!key_exists($info, $this->info)) { @@ -881,11 +699,6 @@ final public function getInfoInt(string $info, int $default = 0): int { * indexing. * * @since 15.0.0 - * - * @param string $info - * @param bool $value - * - * @return IIndexDocument */ final public function setInfoBool(string $info, bool $value): IIndexDocument { $this->info[$info] = $value; @@ -897,11 +710,6 @@ final public function setInfoBool(string $info, bool $value): IIndexDocument { * Get an information about a document. (bool) * * @since 15.0.0 - * - * @param string $info - * @param bool $default - * - * @return bool */ final public function getInfoBool(string $info, bool $default = false): bool { if (!key_exists($info, $this->info)) { @@ -915,13 +723,11 @@ final public function getInfoBool(string $info, bool $default = false): bool { * Get all info. * * @since 15.0.0 - * - * @return array */ final public function getInfoAll(): array { $info = []; foreach ($this->info as $k => $v) { - if (substr($k, 0, 1) === '_') { + if (str_starts_with($k, '_')) { continue; } diff --git a/lib/private/FullTextSearch/Model/SearchOption.php b/lib/private/FullTextSearch/Model/SearchOption.php index 91f45db5fb481..c8fa2b22a2469 100644 --- a/lib/private/FullTextSearch/Model/SearchOption.php +++ b/lib/private/FullTextSearch/Model/SearchOption.php @@ -36,22 +36,6 @@ * @package OC\FullTextSearch\Model */ final class SearchOption implements ISearchOption, JsonSerializable { - /** @var string */ - private $name = ''; - - /** @var string */ - private $title = ''; - - /** @var string */ - private $type = ''; - - /** @var string */ - private $size = ''; - - /** @var string */ - private $placeholder = ''; - - /** * * * @@ -104,37 +88,28 @@ final class SearchOption implements ISearchOption, JsonSerializable { /** * ISearchOption constructor. * - * Some value can be setduring the creation of the object. + * Some value can be set during the creation of the object. * * @since 15.0.0 - * - * @param string $name - * @param string $title - * @param string $type - * @param string $size - * @param string $placeholder */ - public function __construct(string $name = '', string $title = '', string $type = '', string $size = '', string $placeholder = '') { - $this->name = $name; - $this->title = $title; - $this->type = $type; - $this->size = $size; - $this->placeholder = $placeholder; + public function __construct( + private string $name = '', + private string $title = '', + private string $type = '', + private string $size = '', + private string $placeholder = '', + ) { } /** * Set the name/key of the option. - * The string should only contains alphanumerical chars and underscore. - * The key can be retrieve when using ISearchRequest::getOption + * The string should only contain alphanumerical chars and underscore. + * The key can be retrieved when using ISearchRequest::getOption * * @see ISearchRequest::getOption * * @since 15.0.0 - * - * @param string $name - * - * @return ISearchOption */ public function setName(string $name): ISearchOption { $this->name = $name; @@ -146,8 +121,6 @@ public function setName(string $name): ISearchOption { * Get the name/key of the option. * * @since 15.0.0 - * - * @return string */ public function getName(): string { return $this->name; @@ -158,10 +131,6 @@ public function getName(): string { * Set the title/display name of the option. * * @since 15.0.0 - * - * @param string $title - * - * @return ISearchOption */ public function setTitle(string $title): ISearchOption { $this->title = $title; @@ -173,8 +142,6 @@ public function setTitle(string $title): ISearchOption { * Get the title of the option. * * @since 15.0.0 - * - * @return string */ public function getTitle(): string { return $this->title; @@ -186,10 +153,6 @@ public function getTitle(): string { * $type can be ISearchOption::CHECKBOX or ISearchOption::INPUT * * @since 15.0.0 - * - * @param string $type - * - * @return ISearchOption */ public function setType(string $type): ISearchOption { $this->type = $type; @@ -201,8 +164,6 @@ public function setType(string $type): ISearchOption { * Get the type of the option. * * @since 15.0.0 - * - * @return string */ public function getType(): string { return $this->type; @@ -214,10 +175,6 @@ public function getType(): string { * Value can be ISearchOption::INPUT_SMALL or not defined. * * @since 15.0.0 - * - * @param string $size - * - * @return ISearchOption */ public function setSize(string $size): ISearchOption { $this->size = $size; @@ -229,23 +186,16 @@ public function setSize(string $size): ISearchOption { * Get the size of the INPUT. * * @since 15.0.0 - * - * @return string */ public function getSize(): string { return $this->size; } - /** * In case of Type is , set the placeholder to be displayed in the input * field. * * @since 15.0.0 - * - * @param string $placeholder - * - * @return ISearchOption */ public function setPlaceholder(string $placeholder): ISearchOption { $this->placeholder = $placeholder; @@ -257,18 +207,13 @@ public function setPlaceholder(string $placeholder): ISearchOption { * Get the placeholder. * * @since 15.0.0 - * - * @return string */ public function getPlaceholder(): string { return $this->placeholder; } - /** * @since 15.0.0 - * - * @return array */ public function jsonSerialize(): array { return [ diff --git a/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php b/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php index c58d55b9b5531..25887cd90ac3d 100644 --- a/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php +++ b/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php @@ -37,34 +37,24 @@ * @package OC\FullTextSearch\Model */ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonSerializable { - /** @var int */ - private $type = 0; - - /** @var string */ - private $field = ''; - - /** @var array */ - private $values = []; + private array $values = []; /** * SearchRequestQuery constructor. * - * @param $type - * @param $field - * * @since 17.0.0 */ - public function __construct(string $field, int $type) { - $this->field = $field; - $this->type = $type; + public function __construct( + private string $field, + private int $type, + ) { } /** * Get the compare type of the query * - * @return int * @since 17.0.0 */ public function getType(): int { @@ -75,7 +65,6 @@ public function getType(): int { /** * Get the field to apply query * - * @return string * @since 17.0.0 */ public function getField(): string { @@ -85,9 +74,6 @@ public function getField(): string { /** * Set the field to apply query * - * @param string $field - * - * @return ISearchRequestSimpleQuery * @since 17.0.0 */ public function setField(string $field): ISearchRequestSimpleQuery { @@ -100,7 +86,6 @@ public function setField(string $field): ISearchRequestSimpleQuery { /** * Get the value to compare (string) * - * @return array * @since 17.0.0 */ public function getValues(): array { @@ -111,9 +96,6 @@ public function getValues(): array { /** * Add value to compare (string) * - * @param string $value - * - * @return ISearchRequestSimpleQuery * @since 17.0.0 */ public function addValue(string $value): ISearchRequestSimpleQuery { @@ -125,9 +107,6 @@ public function addValue(string $value): ISearchRequestSimpleQuery { /** * Add value to compare (int) * - * @param int $value - * - * @return ISearchRequestSimpleQuery * @since 17.0.0 */ public function addValueInt(int $value): ISearchRequestSimpleQuery { @@ -139,9 +118,6 @@ public function addValueInt(int $value): ISearchRequestSimpleQuery { /** * Add value to compare (array) * - * @param array $value - * - * @return ISearchRequestSimpleQuery * @since 17.0.0 */ public function addValueArray(array $value): ISearchRequestSimpleQuery { @@ -153,9 +129,6 @@ public function addValueArray(array $value): ISearchRequestSimpleQuery { /** * Add value to compare (bool) * - * @param bool $value - * - * @return ISearchRequestSimpleQuery * @since 17.0.0 */ public function addValueBool(bool $value): ISearchRequestSimpleQuery { diff --git a/lib/private/FullTextSearch/Model/SearchTemplate.php b/lib/private/FullTextSearch/Model/SearchTemplate.php index 4bb56f24b58a6..f1ecc0709e5ea 100644 --- a/lib/private/FullTextSearch/Model/SearchTemplate.php +++ b/lib/private/FullTextSearch/Model/SearchTemplate.php @@ -56,21 +56,13 @@ * @package OC\FullTextSearch\Model */ final class SearchTemplate implements ISearchTemplate, JsonSerializable { - /** @var string */ - private $icon = ''; - - /** @var string */ - private $css = ''; - - /** @var string */ - private $template = ''; + private string $template = ''; /** @var SearchOption[] */ - private $panelOptions = []; + private array $panelOptions = []; /** @var SearchOption[] */ - private $navigationOptions = []; - + private array $navigationOptions = []; /** * ISearchTemplate constructor. @@ -79,13 +71,11 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable { * creation of the object. * * @since 15.0.0 - * - * @param string $icon - * @param string $css */ - public function __construct(string $icon = '', string $css = '') { - $this->icon = $icon; - $this->css = $css; + public function __construct( + private string $icon = '', + private string $css = '', + ) { } @@ -94,10 +84,6 @@ public function __construct(string $icon = '', string $css = '') { * FullTextSearch navigation page, in front of the related Content Provider. * * @since 15.0.0 - * - * @param string $class - * - * @return ISearchTemplate */ public function setIcon(string $class): ISearchTemplate { $this->icon = $class; @@ -107,10 +93,6 @@ public function setIcon(string $class): ISearchTemplate { /** * Get the class of the icon. - * - * @since 15.0.0 - * - * @return string */ public function getIcon(): string { return $this->icon; @@ -121,10 +103,6 @@ public function getIcon(): string { * Set the path of a CSS file that will be loaded when needed. * * @since 15.0.0 - * - * @param string $css - * - * @return ISearchTemplate */ public function setCss(string $css): ISearchTemplate { $this->css = $css; @@ -136,8 +114,6 @@ public function setCss(string $css): ISearchTemplate { * Get the path of the CSS file. * * @since 15.0.0 - * - * @return string */ public function getCss(): string { return $this->css; @@ -151,10 +127,6 @@ public function getCss(): string { * a way not generated by FullTextSearch * * @since 15.0.0 - * - * @param string $template - * - * @return ISearchTemplate */ public function setTemplate(string $template): ISearchTemplate { $this->template = $template; @@ -166,8 +138,6 @@ public function setTemplate(string $template): ISearchTemplate { * Get the path of the template file. * * @since 15.0.0 - * - * @return string */ public function getTemplate(): string { return $this->template; @@ -181,10 +151,6 @@ public function getTemplate(): string { * @see ISearchOption * * @since 15.0.0 - * - * @param ISearchOption $option - * - * @return ISearchTemplate */ public function addPanelOption(ISearchOption $option): ISearchTemplate { $this->panelOptions[] = $option; @@ -210,10 +176,6 @@ public function getPanelOptions(): array { * @see ISearchOption * * @since 15.0.0 - * - * @param ISearchOption $option - * - * @return ISearchTemplate */ public function addNavigationOption(ISearchOption $option): ISearchTemplate { $this->navigationOptions[] = $option; @@ -225,8 +187,6 @@ public function addNavigationOption(ISearchOption $option): ISearchTemplate { * Get all options to be displayed in the FullTextSearch navigation page. * * @since 15.0.0 - * - * @return array */ public function getNavigationOptions(): array { return $this->navigationOptions; @@ -235,8 +195,6 @@ public function getNavigationOptions(): array { /** * @since 15.0.0 - * - * @return array */ public function jsonSerialize(): array { return [ diff --git a/lib/public/FullTextSearch/Exceptions/FullTextSearchIndexNotAvailableException.php b/lib/public/FullTextSearch/Exceptions/FullTextSearchIndexNotAvailableException.php new file mode 100644 index 0000000000000..cf3c59051359b --- /dev/null +++ b/lib/public/FullTextSearch/Exceptions/FullTextSearchIndexNotAvailableException.php @@ -0,0 +1,35 @@ + + * + * @author Faraz Samapoor + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ +namespace OCP\FullTextSearch\Exceptions; + +/** + * @since 28.0.0 + * + * Class FullTextSearchIndexNotAvailableException + * + */ +class FullTextSearchIndexNotAvailableException extends \Exception { +}