Skip to content

Fix: Improve return type hints and return docblocks for query classes #470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 42 additions & 42 deletions src/Query/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ public function getByUidLowerThan(int $uid): MessageCollection {
*
* @return $this
*/
public function leaveUnread(): Query {
public function leaveUnread(): static {
$this->setFetchOptions(IMAP::FT_PEEK);

return $this;
Expand All @@ -651,7 +651,7 @@ public function leaveUnread(): Query {
*
* @return $this
*/
public function markAsRead(): Query {
public function markAsRead(): static {
$this->setFetchOptions(IMAP::FT_UID);

return $this;
Expand All @@ -663,7 +663,7 @@ public function markAsRead(): Query {
*
* @return $this
*/
public function setSequence(int $sequence): Query {
public function setSequence(int $sequence): static {
$this->sequence = $sequence;

return $this;
Expand Down Expand Up @@ -699,7 +699,7 @@ public function getClient(): Client {
*
* @return $this
*/
public function limit(int $limit, int $page = 1): Query {
public function limit(int $limit, int $page = 1): static {
if ($page >= 1) $this->page = $page;
$this->limit = $limit;

Expand All @@ -719,9 +719,9 @@ public function getQuery(): Collection {
* Set all query parameters
* @param array $query
*
* @return Query
* @return $this
*/
public function setQuery(array $query): Query {
public function setQuery(array $query): static {
$this->query = new Collection($query);
return $this;
}
Expand All @@ -739,9 +739,9 @@ public function getRawQuery(): string {
* Set the raw query
* @param string $raw_query
*
* @return Query
* @return $this
*/
public function setRawQuery(string $raw_query): Query {
public function setRawQuery(string $raw_query): static {
$this->raw_query = $raw_query;
return $this;
}
Expand All @@ -759,9 +759,9 @@ public function getExtensions(): array {
* Set all extensions that should be used
* @param string[] $extensions
*
* @return Query
* @return $this
*/
public function setExtensions(array $extensions): Query {
public function setExtensions(array $extensions): static {
$this->extensions = $extensions;
if (count($this->extensions) > 0) {
if (in_array("UID", $this->extensions) === false) {
Expand All @@ -775,9 +775,9 @@ public function setExtensions(array $extensions): Query {
* Set the client instance
* @param Client $client
*
* @return Query
* @return $this
*/
public function setClient(Client $client): Query {
public function setClient(Client $client): static {
$this->client = $client;
return $this;
}
Expand All @@ -795,9 +795,9 @@ public function getLimit(): ?int {
* Set the fetch limit
* @param int $limit
*
* @return Query
* @return $this
*/
public function setLimit(int $limit): Query {
public function setLimit(int $limit): static {
$this->limit = $limit <= 0 ? null : $limit;
return $this;
}
Expand All @@ -815,9 +815,9 @@ public function getPage(): int {
* Set the page
* @param int $page
*
* @return Query
* @return $this
*/
public function setPage(int $page): Query {
public function setPage(int $page): static {
$this->page = $page;
return $this;
}
Expand All @@ -826,9 +826,9 @@ public function setPage(int $page): Query {
* Set the fetch option flag
* @param int $fetch_options
*
* @return Query
* @return $this
*/
public function setFetchOptions(int $fetch_options): Query {
public function setFetchOptions(int $fetch_options): static {
$this->fetch_options = $fetch_options;
return $this;
}
Expand All @@ -837,9 +837,9 @@ public function setFetchOptions(int $fetch_options): Query {
* Set the fetch option flag
* @param int $fetch_options
*
* @return Query
* @return $this
*/
public function fetchOptions(int $fetch_options): Query {
public function fetchOptions(int $fetch_options): static {
return $this->setFetchOptions($fetch_options);
}

Expand All @@ -865,9 +865,9 @@ public function getFetchBody(): bool {
* Set the fetch body flag
* @param boolean $fetch_body
*
* @return Query
* @return $this
*/
public function setFetchBody(bool $fetch_body): Query {
public function setFetchBody(bool $fetch_body): static {
$this->fetch_body = $fetch_body;
return $this;
}
Expand All @@ -876,9 +876,9 @@ public function setFetchBody(bool $fetch_body): Query {
* Set the fetch body flag
* @param boolean $fetch_body
*
* @return Query
* @return $this
*/
public function fetchBody(bool $fetch_body): Query {
public function fetchBody(bool $fetch_body): static {
return $this->setFetchBody($fetch_body);
}

Expand All @@ -895,9 +895,9 @@ public function getFetchFlags(): bool {
* Set the fetch flag
* @param bool $fetch_flags
*
* @return Query
* @return $this
*/
public function setFetchFlags(bool $fetch_flags): Query {
public function setFetchFlags(bool $fetch_flags): static {
$this->fetch_flags = $fetch_flags;
return $this;
}
Expand All @@ -906,9 +906,9 @@ public function setFetchFlags(bool $fetch_flags): Query {
* Set the fetch order
* @param string $fetch_order
*
* @return Query
* @return $this
*/
public function setFetchOrder(string $fetch_order): Query {
public function setFetchOrder(string $fetch_order): static {
$fetch_order = strtolower($fetch_order);

if (in_array($fetch_order, ['asc', 'desc'])) {
Expand All @@ -922,9 +922,9 @@ public function setFetchOrder(string $fetch_order): Query {
* Set the fetch order
* @param string $fetch_order
*
* @return Query
* @return $this
*/
public function fetchOrder(string $fetch_order): Query {
public function fetchOrder(string $fetch_order): static {
return $this->setFetchOrder($fetch_order);
}

Expand All @@ -940,56 +940,56 @@ public function getFetchOrder(): string {
/**
* Set the fetch order to ascending
*
* @return Query
* @return $this
*/
public function setFetchOrderAsc(): Query {
public function setFetchOrderAsc(): static {
return $this->setFetchOrder('asc');
}

/**
* Set the fetch order to ascending
*
* @return Query
* @return $this
*/
public function fetchOrderAsc(): Query {
public function fetchOrderAsc(): static {
return $this->setFetchOrderAsc();
}

/**
* Set the fetch order to descending
*
* @return Query
* @return $this
*/
public function setFetchOrderDesc(): Query {
public function setFetchOrderDesc(): static {
return $this->setFetchOrder('desc');
}

/**
* Set the fetch order to descending
*
* @return Query
* @return $this
*/
public function fetchOrderDesc(): Query {
public function fetchOrderDesc(): static {
return $this->setFetchOrderDesc();
}

/**
* Set soft fail mode
* @var boolean $state
*
* @return Query
* @return $this
*/
public function softFail(bool $state = true): Query {
public function softFail(bool $state = true): static {
return $this->setSoftFail($state);
}

/**
* Set soft fail mode
*
* @var boolean $state
* @return Query
* @return $this
*/
public function setSoftFail(bool $state = true): Query {
public function setSoftFail(bool $state = true): static {
$this->soft_fail = $state;

return $this;
Expand Down
Loading