From 0acb7207c5cbb8221e18075924fb59809233a5ae Mon Sep 17 00:00:00 2001 From: Martijn Gastkemper Date: Fri, 13 Oct 2023 23:52:35 +0200 Subject: [PATCH] Replace static with self All these classes are final so static and self are always the same class. The word self is easier to read. --- types/All.php | 2 +- types/Any.php | 2 +- types/Max.php | 2 +- types/Min.php | 2 +- types/Product.php | 4 ++-- types/StringM.php | 2 +- types/Sum.php | 4 ++-- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/types/All.php b/types/All.php index 0aba72b..80c802d 100644 --- a/types/All.php +++ b/types/All.php @@ -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) { diff --git a/types/Any.php b/types/Any.php index db26532..876476f 100644 --- a/types/Any.php +++ b/types/Any.php @@ -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) { diff --git a/types/Max.php b/types/Max.php index 7d9ba69..520a2f7 100644 --- a/types/Max.php +++ b/types/Max.php @@ -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) { diff --git a/types/Min.php b/types/Min.php index 53667ed..1e2bbc1 100644 --- a/types/Min.php +++ b/types/Min.php @@ -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) { diff --git a/types/Product.php b/types/Product.php index e56b5d5..d5d0c7f 100644 --- a/types/Product.php +++ b/types/Product.php @@ -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) { @@ -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); } } diff --git a/types/StringM.php b/types/StringM.php index 29a8837..37073d7 100644 --- a/types/StringM.php +++ b/types/StringM.php @@ -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) { diff --git a/types/Sum.php b/types/Sum.php index a1e0627..2cf2a70 100644 --- a/types/Sum.php +++ b/types/Sum.php @@ -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) { @@ -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); } }