Skip to content

Commit 2fd76ef

Browse files
committed
add NoDiscard attributes
1 parent 6041010 commit 2fd76ef

6 files changed

Lines changed: 19 additions & 0 deletions

File tree

psalm.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@
1414
<directory name="vendor" />
1515
</ignoreFiles>
1616
</projectFiles>
17+
<issueHandlers>
18+
<UndefinedAttributeClass errorLevel="suppress" />
19+
</issueHandlers>
1720
</psalm>

src/Manager.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@ interface Manager
1414
/**
1515
* @return Maybe<Session>
1616
*/
17+
#[\NoDiscard]
1718
public function start(ServerRequest $request): Maybe;
1819

1920
/**
2021
* @return Maybe<SideEffect>
2122
*/
23+
#[\NoDiscard]
2224
public function save(Session $session): Maybe;
2325

2426
/**
2527
* @return Maybe<SideEffect>
2628
*/
29+
#[\NoDiscard]
2730
public function close(Session $session): Maybe;
2831
}

src/Manager/Native.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ private function __construct(?Path $save = null)
3232
}
3333
}
3434

35+
#[\NoDiscard]
3536
public static function of(?Path $save = null): self
3637
{
3738
return new self($save);

src/Session.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,19 @@ private function __construct(Id $id, Name $name, Map $values)
3838
*
3939
* @param Map<string, mixed> $values
4040
*/
41+
#[\NoDiscard]
4142
public static function of(Id $id, Name $name, Map $values): self
4243
{
4344
return new self($id, $name, $values);
4445
}
4546

47+
#[\NoDiscard]
4648
public function id(): Id
4749
{
4850
return $this->id;
4951
}
5052

53+
#[\NoDiscard]
5154
public function name(): Name
5255
{
5356
return $this->name;
@@ -58,6 +61,7 @@ public function name(): Name
5861
*
5962
* @throws LogicException
6063
*/
64+
#[\NoDiscard]
6165
public function get(string $key): mixed
6266
{
6367
return $this->maybe($key)->match(
@@ -69,16 +73,19 @@ public function get(string $key): mixed
6973
/**
7074
* @return Maybe<mixed>
7175
*/
76+
#[\NoDiscard]
7277
public function maybe(string $key): Maybe
7378
{
7479
return $this->values->get($key);
7580
}
7681

82+
#[\NoDiscard]
7783
public function contains(string $key): bool
7884
{
7985
return $this->values->contains($key);
8086
}
8187

88+
#[\NoDiscard]
8289
public function with(string $key, mixed $value): self
8390
{
8491
return new self(
@@ -95,6 +102,7 @@ public function with(string $key, mixed $value): self
95102
*
96103
* @return Map<string, mixed>
97104
*/
105+
#[\NoDiscard]
98106
public function values(): Map
99107
{
100108
return $this->values;

src/Session/Id.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,15 @@ private function __construct(string $value)
2525
*
2626
* @return Maybe<self>
2727
*/
28+
#[\NoDiscard]
2829
public static function maybe(string $value): Maybe
2930
{
3031
return Maybe::just(Str::of($value))
3132
->filter(static fn($value) => $value->matches('~^[\w\-\_]+$~'))
3233
->map(static fn($value) => new self($value->toString()));
3334
}
3435

36+
#[\NoDiscard]
3537
public function toString(): string
3638
{
3739
return $this->value;

src/Session/Name.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ private function __construct(string $value)
2626
*
2727
* @return Maybe<self>
2828
*/
29+
#[\NoDiscard]
2930
public static function maybe(string $value): Maybe
3031
{
3132
return Maybe::just(Str::of($value))
3233
->filter(static fn($value) => $value->matches('~^[\w\-\_]+$~'))
3334
->map(static fn($value) => new self($value->toString()));
3435
}
3536

37+
#[\NoDiscard]
3638
public function toString(): string
3739
{
3840
return $this->value;

0 commit comments

Comments
 (0)