Skip to content

Commit 62d9d86

Browse files
fix(docs): Refactor attribute documentation in traits. (#84)
1 parent f2118c7 commit 62d9d86

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+450
-576
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
- Bug #81: Migrate mixin attribute setters and tests to the simplified API (@terabytesoftw)
5555
- Bug #82: Update `ui-awesome/html-helper` requirement to use stable version constraint `^0.7` in `composer.json` (@terabytesoftw)
5656
- Enh #83: Enhance `HasAria`, `HasData`, and `HasEvents` traits to support prefix attributes `aria-`, `data-`, and `on` (@terabytesoftw)
57+
- Bug #84: Refactor attribute documentation in traits (@terabytesoftw)
5758

5859
## 0.5.2 January 29, 2026
5960

src/Element/HasAlt.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Provides an immutable API for the `alt` attribute.
1313
*
14-
* @method static setAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance.
14+
* @mixin \UIAwesome\Html\Mixin\HasAttributes
1515
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#alt
1616
*
1717
* @copyright Copyright (C) 2025 Terabytesoftw.
@@ -22,17 +22,17 @@ trait HasAlt
2222
/**
2323
* Sets the `alt` attribute.
2424
*
25-
* @param string|Stringable|UnitEnum|null $value Alternative text for the element, or `null` to remove the
26-
* attribute.
27-
*
28-
* @return static New instance with the updated `alt` attribute.
29-
*
3025
* Usage example:
3126
* ```php
3227
* $element->alt('A penguin on a beach.');
3328
* $element->alt('');
3429
* $element->alt(null);
3530
* ```
31+
*
32+
* @param string|Stringable|UnitEnum|null $value Alternative text for the element, or `null` to remove the
33+
* attribute.
34+
*
35+
* @return static New instance with the updated `alt` attribute.
3636
*/
3737
public function alt(string|Stringable|UnitEnum|null $value): static
3838
{

src/Element/HasDecoding.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Provides an immutable API for the HTML and SVG `decoding` attribute.
1515
*
16-
* @method static setAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance.
16+
* @mixin \UIAwesome\Html\Mixin\HasAttributes
1717
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#decoding
1818
* @link https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/decoding
1919
*
@@ -25,6 +25,13 @@ trait HasDecoding
2525
/**
2626
* Sets the `decoding` attribute.
2727
*
28+
* Usage example:
29+
* ```php
30+
* $element->decoding('async');
31+
* $element->decoding(Decoding::ASYNC);
32+
* $element->decoding(null);
33+
* ```
34+
*
2835
* @param string|Stringable|UnitEnum|null $value Decoding hint value. Use `async`, `sync`, or `auto`, or `null` to
2936
* remove the attribute.
3037
*
@@ -33,13 +40,6 @@ trait HasDecoding
3340
* @return static New instance with the updated `decoding` attribute.
3441
*
3542
* {@see Decoding} for predefined enum values.
36-
*
37-
* Usage example:
38-
* ```php
39-
* $element->decoding('async');
40-
* $element->decoding(Decoding::ASYNC);
41-
* $element->decoding(null);
42-
* ```
4343
*/
4444
public function decoding(string|Stringable|UnitEnum|null $value): static
4545
{

src/Element/HasHeight.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Provides an immutable API for the `height` attribute.
1313
*
14-
* @method static setAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance.
14+
* @mixin \UIAwesome\Html\Mixin\HasAttributes
1515
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#height
1616
* @link https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Attribute/height
1717
*
@@ -23,17 +23,17 @@ trait HasHeight
2323
/**
2424
* Sets the `height` attribute.
2525
*
26-
* @param int|string|Stringable|UnitEnum|null $value Height value in pixels or CSS units, or `null` to remove the
27-
* attribute.
28-
*
29-
* @return static New instance with the updated `height` attribute.
30-
*
3126
* Usage example:
3227
* ```php
3328
* $element->height(200);
3429
* $element->height('50%');
3530
* $element->height('auto');
3631
* ```
32+
*
33+
* @param int|string|Stringable|UnitEnum|null $value Height value in pixels or CSS units, or `null` to remove the
34+
* attribute.
35+
*
36+
* @return static New instance with the updated `height` attribute.
3737
*/
3838
public function height(int|string|Stringable|UnitEnum|null $value): static
3939
{

src/Element/HasHref.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Provides an immutable API for the HTML and SVG `href` attribute.
1313
*
14-
* @method static setAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance.
14+
* @mixin \UIAwesome\Html\Mixin\HasAttributes
1515
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#href
1616
* @link https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/href
1717
*
@@ -23,17 +23,17 @@ trait HasHref
2323
/**
2424
* Sets the `href` attribute.
2525
*
26-
* @param string|Stringable|UnitEnum|null $value URL, path, or fragment, or `null` to remove the attribute.
27-
*
28-
* @return static New instance with the updated `href` attribute.
29-
*
3026
* Usage example:
3127
* ```php
3228
* $element->href('https://example.com/page');
3329
* $element->href('/about');
3430
* $element->href('#section');
3531
* $element->href(null);
3632
* ```
33+
*
34+
* @param string|Stringable|UnitEnum|null $value URL, path, or fragment, or `null` to remove the attribute.
35+
*
36+
* @return static New instance with the updated `href` attribute.
3737
*/
3838
public function href(string|Stringable|UnitEnum|null $value): static
3939
{

src/Element/HasLoading.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Provides an immutable API for the `loading` attribute.
1515
*
16-
* @method static setAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance.
16+
* @mixin \UIAwesome\Html\Mixin\HasAttributes
1717
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/iframe#loading
1818
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#loading
1919
*
@@ -25,6 +25,13 @@ trait HasLoading
2525
/**
2626
* Sets the `loading` attribute.
2727
*
28+
* Usage example:
29+
* ```php
30+
* $element->loading('lazy');
31+
* $element->loading(Loading::LAZY);
32+
* $element->loading(null);
33+
* ```
34+
*
2835
* @param string|Stringable|UnitEnum|null $value Loading strategy (`eager` or `lazy`), or `null` to remove the
2936
* attribute.
3037
*
@@ -33,13 +40,6 @@ trait HasLoading
3340
* @return static New instance with the updated `loading` attribute.
3441
*
3542
* {@see Loading} for predefined enum values.
36-
*
37-
* Usage example:
38-
* ```php
39-
* $element->loading('lazy');
40-
* $element->loading(Loading::LAZY);
41-
* $element->loading(null);
42-
* ```
4343
*/
4444
public function loading(string|Stringable|UnitEnum|null $value): static
4545
{

src/Element/HasPopoverTarget.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
/**
1212
* Provides an immutable API for the `popovertarget` attribute.
1313
*
14-
* @method static setAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance.
15-
* {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array.
16-
*
14+
* @mixin \UIAwesome\Html\Mixin\HasAttributes
1715
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/popovertarget
1816
*
1917
* @copyright Copyright (C) 2026 Terabytesoftw.

src/Element/HasPopoverTargetAction.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
/**
1414
* Provides an immutable API for the `popovertargetaction` attribute.
1515
*
16-
* @method static setAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance.
17-
* {@see \UIAwesome\Html\Mixin\HasAttributes} for managing the underlying attributes array.
18-
*
16+
* @mixin \UIAwesome\Html\Mixin\HasAttributes
1917
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/button#popovertargetaction
2018
*
2119
* @copyright Copyright (C) 2026 Terabytesoftw.

src/Element/HasReferrerpolicy.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/**
1414
* Provides an immutable API for the `referrerpolicy` attribute.
1515
*
16-
* @method static setAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance.
16+
* @mixin \UIAwesome\Html\Mixin\HasAttributes
1717
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#referrerpolicy
1818
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/area#href
1919
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/iframe#referrerpolicy
@@ -29,20 +29,20 @@ trait HasReferrerpolicy
2929
/**
3030
* Sets the `referrerpolicy` attribute.
3131
*
32+
* Usage example:
33+
* ```php
34+
* $element->referrerpolicy('origin');
35+
* $element->referrerpolicy(Referrerpolicy::NO_REFERRER);
36+
* $element->referrerpolicy(null);
37+
* ```
38+
*
3239
* @param string|Stringable|UnitEnum|null $value Referrer policy token, or `null` to remove the attribute.
3340
*
3441
* @throws InvalidArgumentException If the value is not valid.
3542
*
3643
* @return static New instance with the updated `referrerpolicy` attribute.
3744
*
3845
* {@see Referrerpolicy} for predefined enum values.
39-
*
40-
* Usage example:
41-
* ```php
42-
* $element->referrerpolicy('origin');
43-
* $element->referrerpolicy(Referrerpolicy::NO_REFERRER);
44-
* $element->referrerpolicy(null);
45-
* ```
4646
*/
4747
public function referrerpolicy(string|Stringable|UnitEnum|null $value): static
4848
{

src/Element/HasSrc.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* Provides an immutable API for the `src` attribute.
1313
*
14-
* @method static setAttribute(string|UnitEnum $key, mixed $value) Adds an attribute and returns a new instance.
14+
* @mixin \UIAwesome\Html\Mixin\HasAttributes
1515
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/img#src
1616
*
1717
* @copyright Copyright (C) 2025 Terabytesoftw.
@@ -22,16 +22,16 @@ trait HasSrc
2222
/**
2323
* Sets the `src` attribute.
2424
*
25-
* @param string|Stringable|UnitEnum|null $value Image source URL or path, or `null` to remove the attribute.
26-
*
27-
* @return static New instance with the updated `src` attribute.
28-
*
2925
* Usage example:
3026
* ```php
3127
* $element->src('https://example.com/image.png');
3228
* $element->src('images/photo.jpg');
3329
* $element->src(null);
3430
* ```
31+
*
32+
* @param string|Stringable|UnitEnum|null $value Image source URL or path, or `null` to remove the attribute.
33+
*
34+
* @return static New instance with the updated `src` attribute.
3535
*/
3636
public function src(string|Stringable|UnitEnum|null $value): static
3737
{

0 commit comments

Comments
 (0)