Skip to content

Commit

Permalink
Replace static with self
Browse files Browse the repository at this point in the history
All these classes are final so static and self are always the same
class. The word self is easier to read.
  • Loading branch information
martijngastkemper committed Oct 16, 2023
1 parent e8a02e0 commit 0acb720
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion types/All.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class All implements Semigroup, Setoid, Monoid {
public $value;

public static function empty(): Monoid {
return new static(true);
return new self(true);
}

public function __construct(bool $value) {
Expand Down
2 changes: 1 addition & 1 deletion types/Any.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class Any implements Semigroup, Setoid, Monoid {
public $value;

public static function empty(): Monoid {
return new static(false);
return new self(false);
}

public function __construct(bool $value) {
Expand Down
2 changes: 1 addition & 1 deletion types/Max.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class Max implements Semigroup, Setoid, Monoid {
public $value;

public static function empty(): Monoid {
return new static(PHP_INT_MIN);
return new self(PHP_INT_MIN);
}

public function __construct(float $value) {
Expand Down
2 changes: 1 addition & 1 deletion types/Min.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class Min implements Semigroup, Setoid, Monoid {
public $value;

public static function empty(): Monoid {
return new static(PHP_INT_MAX);
return new self(PHP_INT_MAX);
}

public function __construct(float $value) {
Expand Down
4 changes: 2 additions & 2 deletions types/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class Product implements Semigroup, Setoid, Monoid {
public $value;

public static function empty(): Monoid {
return new static(1);
return new self(1);
}

public function __construct(float $value) {
Expand All @@ -34,7 +34,7 @@ public function concat(Semigroup $that): Semigroup {
if (!$that instanceof self) {
throw new \LogicException('Semigroup cannot concatenate two distinct types.');
}
return new Product($this->value * $that->value);
return new self($this->value * $that->value);
}

}
Expand Down
2 changes: 1 addition & 1 deletion types/StringM.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class StringM implements Ord, Semigroup, Monoid {
public $value;

public static function empty(): Monoid {
return new static('');
return new self('');
}

public function __construct(string $value) {
Expand Down
4 changes: 2 additions & 2 deletions types/Sum.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class Sum implements Semigroup, Setoid, Monoid {
public $value;

public static function empty(): Monoid {
return new static(0);
return new self(0);
}

public function __construct(float $value) {
Expand All @@ -34,7 +34,7 @@ public function concat(Semigroup $that): Semigroup {
if (!$that instanceof self) {
throw new \LogicException('Semigroup cannot concatenate two distinct types.');
}
return new Sum($this->value + $that->value);
return new self($this->value + $that->value);
}

}

0 comments on commit 0acb720

Please sign in to comment.