aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/FullTextSearch/Model
diff options
context:
space:
mode:
authorFaraz Samapoor <f.samapoor@gmail.com>2023-10-10 10:10:21 +0330
committerFaraz Samapoor <f.samapoor@gmail.com>2024-01-15 10:36:02 +0330
commit28450718541b331f6db6da92cb22dd44879f7727 (patch)
tree33e7f373505170697f1551d5b2b10edf186a59c8 /lib/private/FullTextSearch/Model
parentc14f024fa2dae97fd716ad9f3dac958a6896f51a (diff)
downloadnextcloud-server-28450718541b331f6db6da92cb22dd44879f7727.tar.gz
nextcloud-server-28450718541b331f6db6da92cb22dd44879f7727.zip
Refactors lib/private/FullTextSearch.
Mainly using PHP8's constructor property promotion. Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com> Co-authored-by: Côme Chilliet <91878298+come-nc@users.noreply.github.com>
Diffstat (limited to 'lib/private/FullTextSearch/Model')
-rw-r--r--lib/private/FullTextSearch/Model/DocumentAccess.php84
-rw-r--r--lib/private/FullTextSearch/Model/IndexDocument.php250
-rw-r--r--lib/private/FullTextSearch/Model/SearchOption.php75
-rw-r--r--lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php37
-rw-r--r--lib/private/FullTextSearch/Model/SearchTemplate.php56
5 files changed, 54 insertions, 448 deletions
diff --git a/lib/private/FullTextSearch/Model/DocumentAccess.php b/lib/private/FullTextSearch/Model/DocumentAccess.php
index cb2b95284f1..eecd038ca03 100644
--- a/lib/private/FullTextSearch/Model/DocumentAccess.php
+++ b/lib/private/FullTextSearch/Model/DocumentAccess.php
@@ -49,23 +49,17 @@ use OCP\FullTextSearch\Model\IDocumentAccess;
* @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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* Get the Owner of the document.
*
* @since 16.0.0
- *
- * @return string
*/
public function getOwnerId(): string {
return $this->ownerId;
@@ -113,10 +99,6 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* Get the viewer of the document.
*
* @since 16.0.0
- *
- * @return string
*/
public function getViewerId(): string {
return $this->viewerId;
@@ -140,10 +120,6 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
* 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 @@ final class DocumentAccess implements IDocumentAccess, JsonSerializable {
/**
* @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 74788463693..76638e23894 100644
--- a/lib/private/FullTextSearch/Model/IndexDocument.php
+++ b/lib/private/FullTextSearch/Model/IndexDocument.php
@@ -47,62 +47,41 @@ use OCP\FullTextSearch\Model\IIndexDocument;
* @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;
- /** @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 +91,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 +104,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Returns the Id of the original document.
*
* @since 15.0.0
- *
- * @return string
*/
final public function getId(): string {
return $this->id;
@@ -138,8 +114,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Returns the Id of the provider.
*
* @since 15.0.0
- *
- * @return string
*/
final public function getProviderId(): string {
return $this->providerId;
@@ -152,10 +126,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* @see IIndex
*
* @since 15.0.0
- *
- * @param IIndex $index
- *
- * @return IIndexDocument
*/
final public function setIndex(IIndex $index): IIndexDocument {
$this->index = $index;
@@ -167,8 +137,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Get the Index.
*
* @since 15.0.0
- *
- * @return IIndex
*/
final public function getIndex(): IIndex {
return $this->index;
@@ -178,22 +146,15 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* return if Index is defined.
*
* @since 16.0.0
- *
- * @return bool
*/
final public function hasIndex(): bool {
- return ($this->index !== null);
+ return isset($this->index);
}
-
/**
* 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 +166,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Get the modified time of the original document.
*
* @since 15.0.0
- *
- * @return int
*/
final public function getModifiedTime(): int {
return $this->modifiedTime;
@@ -216,10 +175,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +187,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* @see IDocumentAccess
*
* @since 15.0.0
- *
- * @param IDocumentAccess $access
- *
- * @return $this
*/
final public function setAccess(IDocumentAccess $access): IIndexDocument {
$this->access = $access;
@@ -247,8 +198,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Get the IDocumentAccess related to the original document.
*
* @since 15.0.0
- *
- * @return IDocumentAccess
*/
final public function getAccess(): IDocumentAccess {
return $this->access;
@@ -259,10 +208,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +219,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +230,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +240,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +251,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +262,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +272,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +288,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +301,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* dimensional array.
*
* @since 15.0.0
- *
- * @param bool $formatted
- *
- * @return array
*/
final public function getSubTags(bool $formatted = false): array {
if ($formatted === false) {
@@ -408,10 +324,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +335,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Get the source of the original document.
*
* @since 15.0.0
- *
- * @return string
*/
final public function getSource(): string {
return $this->source;
@@ -435,10 +345,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +356,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Get the title of the original document.
*
* @since 15.0.0
- *
- * @return string
*/
final public function getTitle(): string {
return $this->title;
@@ -464,11 +368,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +380,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Get the content of the original document.
*
* @since 15.0.0
- *
- * @return string
*/
final public function getContent(): string {
return $this->content;
@@ -492,8 +389,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +398,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Return the size of the content.
*
* @since 15.0.0
- *
- * @return int
*/
final public function getContentSize(): int {
return strlen($this->getContent());
@@ -512,11 +405,9 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
/**
- * 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 +423,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +434,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Get the hash of the original document.
*
* @since 15.0.0
- *
- * @return string
*/
final public function getHash(): string {
return $this->hash;
@@ -562,11 +447,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* $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 +458,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +469,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Get all parts of the IIndexDocument.
*
* @since 15.0.0
- *
- * @return array
*/
final public function getParts(): array {
return $this->parts;
@@ -605,10 +479,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +490,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Get the link.
*
* @since 15.0.0
- *
- * @return string
*/
final public function getLink(): string {
return $this->link;
@@ -632,10 +500,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +511,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Get more information.
*
* @since 15.0.0
- *
- * @return array
*/
final public function getMore(): array {
return $this->more;
@@ -660,11 +522,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +538,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +557,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +566,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Clean excerpt.
*
* @since 16.0.0
- *
- * @param string $excerpt
- * @return string
*/
private function cleanExcerpt(string $excerpt): string {
$excerpt = str_replace("\\n", ' ', $excerpt);
@@ -736,10 +584,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* request.
*
* @since 15.0.0
- *
- * @param string $score
- *
- * @return IIndexDocument
*/
final public function setScore(string $score): IIndexDocument {
$this->score = $score;
@@ -751,8 +595,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* Get the score.
*
* @since 15.0.0
- *
- * @return string
*/
final public function getScore(): string {
return $this->score;
@@ -767,11 +609,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +620,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +637,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +648,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +665,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +676,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +693,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +704,6 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 +717,11 @@ class IndexDocument implements IIndexDocument, JsonSerializable {
* 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 91f45db5fb4..c8fa2b22a24 100644
--- a/lib/private/FullTextSearch/Model/SearchOption.php
+++ b/lib/private/FullTextSearch/Model/SearchOption.php
@@ -36,22 +36,6 @@ use OCP\FullTextSearch\Model\ISearchOption;
* @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 @@ final class SearchOption implements ISearchOption, JsonSerializable {
* Get the name/key of the option.
*
* @since 15.0.0
- *
- * @return string
*/
public function getName(): string {
return $this->name;
@@ -158,10 +131,6 @@ final class SearchOption implements ISearchOption, JsonSerializable {
* 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 @@ final class SearchOption implements ISearchOption, JsonSerializable {
* Get the title of the option.
*
* @since 15.0.0
- *
- * @return string
*/
public function getTitle(): string {
return $this->title;
@@ -186,10 +153,6 @@ final class SearchOption implements ISearchOption, JsonSerializable {
* $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 @@ final class SearchOption implements ISearchOption, JsonSerializable {
* Get the type of the option.
*
* @since 15.0.0
- *
- * @return string
*/
public function getType(): string {
return $this->type;
@@ -214,10 +175,6 @@ final class SearchOption implements ISearchOption, JsonSerializable {
* 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 @@ final class SearchOption implements ISearchOption, JsonSerializable {
* 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 @@ final class SearchOption implements ISearchOption, JsonSerializable {
* 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 c58d55b9b55..25887cd90ac 100644
--- a/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php
+++ b/lib/private/FullTextSearch/Model/SearchRequestSimpleQuery.php
@@ -37,34 +37,24 @@ use OCP\FullTextSearch\Model\ISearchRequestSimpleQuery;
* @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 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS
/**
* Get the field to apply query
*
- * @return string
* @since 17.0.0
*/
public function getField(): string {
@@ -85,9 +74,6 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS
/**
* 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 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS
/**
* Get the value to compare (string)
*
- * @return array
* @since 17.0.0
*/
public function getValues(): array {
@@ -111,9 +96,6 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS
/**
* Add value to compare (string)
*
- * @param string $value
- *
- * @return ISearchRequestSimpleQuery
* @since 17.0.0
*/
public function addValue(string $value): ISearchRequestSimpleQuery {
@@ -125,9 +107,6 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS
/**
* Add value to compare (int)
*
- * @param int $value
- *
- * @return ISearchRequestSimpleQuery
* @since 17.0.0
*/
public function addValueInt(int $value): ISearchRequestSimpleQuery {
@@ -139,9 +118,6 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS
/**
* Add value to compare (array)
*
- * @param array $value
- *
- * @return ISearchRequestSimpleQuery
* @since 17.0.0
*/
public function addValueArray(array $value): ISearchRequestSimpleQuery {
@@ -153,9 +129,6 @@ final class SearchRequestSimpleQuery implements ISearchRequestSimpleQuery, JsonS
/**
* 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 4bb56f24b58..f1ecc0709e5 100644
--- a/lib/private/FullTextSearch/Model/SearchTemplate.php
+++ b/lib/private/FullTextSearch/Model/SearchTemplate.php
@@ -56,21 +56,13 @@ use OCP\FullTextSearch\Model\ISearchTemplate;
* @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 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable {
* 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 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable {
/**
* Get the class of the icon.
- *
- * @since 15.0.0
- *
- * @return string
*/
public function getIcon(): string {
return $this->icon;
@@ -121,10 +103,6 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable {
* 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 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable {
* Get the path of the CSS file.
*
* @since 15.0.0
- *
- * @return string
*/
public function getCss(): string {
return $this->css;
@@ -151,10 +127,6 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable {
* 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 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable {
* Get the path of the template file.
*
* @since 15.0.0
- *
- * @return string
*/
public function getTemplate(): string {
return $this->template;
@@ -181,10 +151,6 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable {
* @see ISearchOption
*
* @since 15.0.0
- *
- * @param ISearchOption $option
- *
- * @return ISearchTemplate
*/
public function addPanelOption(ISearchOption $option): ISearchTemplate {
$this->panelOptions[] = $option;
@@ -210,10 +176,6 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable {
* @see ISearchOption
*
* @since 15.0.0
- *
- * @param ISearchOption $option
- *
- * @return ISearchTemplate
*/
public function addNavigationOption(ISearchOption $option): ISearchTemplate {
$this->navigationOptions[] = $option;
@@ -225,8 +187,6 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable {
* 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 @@ final class SearchTemplate implements ISearchTemplate, JsonSerializable {
/**
* @since 15.0.0
- *
- * @return array
*/
public function jsonSerialize(): array {
return [