Skip to content

Commit 99e84e9

Browse files
committed
[WebLink] Add NoDiscard and phpdoc types
1 parent dff2ff8 commit 99e84e9

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

src/Symfony/Component/WebLink/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.3
5+
---
6+
7+
* Add `#[NoDiscard]` attribute to `Link` and `GenericLinkProvider` with methods
8+
49
4.4.0
510
-----
611

src/Symfony/Component/WebLink/GenericLinkProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public function getLinksByRel(string $rel): array
5353
return $links;
5454
}
5555

56+
#[\NoDiscard]
5657
public function withLink(LinkInterface $link): static
5758
{
5859
$that = clone $this;
@@ -61,6 +62,7 @@ public function withLink(LinkInterface $link): static
6162
return $that;
6263
}
6364

65+
#[\NoDiscard]
6466
public function withoutLink(LinkInterface $link): static
6567
{
6668
$that = clone $this;

src/Symfony/Component/WebLink/Link.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,17 @@ public function getRels(): array
175175
return array_values($this->rel);
176176
}
177177

178+
/**
179+
* Returns a list of attributes that describe the target URI.
180+
*
181+
* @return array<string, scalar|\Stringable|list<scalar|\Stringable>>
182+
*/
178183
public function getAttributes(): array
179184
{
180185
return $this->attributes;
181186
}
182187

188+
#[\NoDiscard]
183189
public function withHref(string|\Stringable $href): static
184190
{
185191
$that = clone $this;
@@ -188,6 +194,7 @@ public function withHref(string|\Stringable $href): static
188194
return $that;
189195
}
190196

197+
#[\NoDiscard]
191198
public function withRel(string $rel): static
192199
{
193200
$that = clone $this;
@@ -196,6 +203,7 @@ public function withRel(string $rel): static
196203
return $that;
197204
}
198205

206+
#[\NoDiscard]
199207
public function withoutRel(string $rel): static
200208
{
201209
$that = clone $this;
@@ -204,6 +212,15 @@ public function withoutRel(string $rel): static
204212
return $that;
205213
}
206214

215+
/**
216+
* Returns an instance with the specified attribute added.
217+
*
218+
* If the specified attribute is already present, it will be overwritten
219+
* with the new value.
220+
*
221+
* @param scalar|\Stringable|list<scalar|\Stringable> $value
222+
*/
223+
#[\NoDiscard]
207224
public function withAttribute(string $attribute, string|\Stringable|int|float|bool|array $value): static
208225
{
209226
$that = clone $this;
@@ -212,6 +229,7 @@ public function withAttribute(string $attribute, string|\Stringable|int|float|bo
212229
return $that;
213230
}
214231

232+
#[\NoDiscard]
215233
public function withoutAttribute(string $attribute): static
216234
{
217235
$that = clone $this;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy