Skip to content

Commit

Permalink
Replace self return type with static return type of implementations
Browse files Browse the repository at this point in the history
This improves static code analysis and IDE experience.
  • Loading branch information
dakujem committed Oct 16, 2023
1 parent 694ed9f commit 6bec042
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Http/GenericClientHttpException.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function suggestStatusCode(): int
return $this->httpStatusCode ?? $this->defaultStatusCode();
}

public function setHttpStatus(?int $code): self
public function setHttpStatus(?int $code): static
{
$this->httpStatusCode = $code;
return $this;
Expand Down
4 changes: 2 additions & 2 deletions src/Support/SupportInternalContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait SupportInternalContext
*
* Passing `null` with a key will remove the information under the key.
*/
public function pin(mixed $value, string|int|null $key = null): self
public function pin(mixed $value, string|int|null $key = null): static
{
if ($value === null) {
if ($key !== null) {
Expand All @@ -51,7 +51,7 @@ public function context(): array
/**
* Replace current context with given one.
*/
public function replaceContext(array $context): self
public function replaceContext(array $context): static
{
$this->context = $context;
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Support/SupportInternalExplanation.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait SupportInternalExplanation
/**
* Add an explanation for internal purposes (logging, debugging, etc.).
*/
public function explain(?string $explanation): self
public function explain(?string $explanation): static
{
$this->explanation = $explanation;
return $this;
Expand Down
4 changes: 2 additions & 2 deletions src/Support/SupportPublicContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait SupportPublicContext
*
* Passing `null` with a key will remove the information under the key.
*/
public function pass(mixed $value, string|int|null $key = null): self
public function pass(mixed $value, string|int|null $key = null): static
{
if ($value === null) {
if ($key !== null) {
Expand All @@ -49,7 +49,7 @@ public function publicContext(): array
/**
* Completely replace current client-facing context with given one.
*/
public function replacePublicContext(array $context): self
public function replacePublicContext(array $context): static
{
$this->publicContext = $context;
return $this;
Expand Down
2 changes: 1 addition & 1 deletion src/Support/SupportPublicConveying.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function convey(
mixed $meta = null,
?int $status = null,
?string $code = null,
): self {
): static {
return $this->pass(new ErrorContainer(
message: $message ?? $this->getDefaultMessageToConvey(),
source: $source,
Expand Down
4 changes: 2 additions & 2 deletions src/Support/SupportTagging.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait SupportTagging
*
* Both plain string tags and key-tag pairs are supported.
*/
public function tag(string $tag, string|int|null $key = null): self
public function tag(string $tag, string|int|null $key = null): static
{
if ($key !== null) {
$this->tags[$key] = $tag;
Expand All @@ -43,7 +43,7 @@ public function tags(): array
/**
* Replace current tags with given ones.
*/
public function replaceTags(array $tags): self
public function replaceTags(array $tags): static
{
$this->tags = [];
// iterate over the keys for type safety
Expand Down

0 comments on commit 6bec042

Please sign in to comment.