File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 3030 */
3131final class IsSuperTypeOfResult
3232{
33+ private static self $ YES ;
34+
35+ private static self $ MAYBE ;
36+
37+ private static self $ NO ;
38+
3339
3440 /**
3541 * @api
@@ -71,18 +77,21 @@ public function no(): bool
7177
7278 public static function createYes (): self
7379 {
74- return new self (TrinaryLogic::createYes (), []);
80+ return self :: $ YES ??= new self (TrinaryLogic::createYes (), []);
7581 }
7682
7783 /** @param list<string> $reasons */
7884 public static function createNo (array $ reasons = []): self
7985 {
86+ if ($ reasons === []) {
87+ return self ::$ NO ??= new self (TrinaryLogic::createNo (), $ reasons );
88+ }
8089 return new self (TrinaryLogic::createNo (), $ reasons );
8190 }
8291
8392 public static function createMaybe (): self
8493 {
85- return new self (TrinaryLogic::createMaybe (), []);
94+ return self :: $ MAYBE ??= new self (TrinaryLogic::createMaybe (), []);
8695 }
8796
8897 public static function createFromBoolean (bool $ value ): self
You can’t perform that action at this time.
0 commit comments