diff --git a/.github/linters/.codespellrc b/.github/linters/.codespellrc new file mode 100644 index 0000000..0379ac4 --- /dev/null +++ b/.github/linters/.codespellrc @@ -0,0 +1,3 @@ +[codespell] +ignore-words-list = CanBe +skip = */tests/*,tests/**,*/composer.lock,*/composer.json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3254d3d..a9f1ae5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,6 +17,8 @@ permissions: jobs: phpunit: - uses: yii2-framework/actions/.github/workflows/phpunit.yml@main + uses: yii2-framework/actions/.github/workflows/phpunit.yml@v1 secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + with: + php-version: '["8.3","8.4","8.5"]' diff --git a/.github/workflows/dependency-check.yml b/.github/workflows/dependency-check.yml index e69d7d1..294a347 100644 --- a/.github/workflows/dependency-check.yml +++ b/.github/workflows/dependency-check.yml @@ -18,4 +18,4 @@ permissions: jobs: composer-require-checker: - uses: yii2-framework/actions/.github/workflows/composer-require-checker.yml@main + uses: yii2-framework/actions/.github/workflows/composer-require-checker.yml@v1 diff --git a/.github/workflows/ecs.yml b/.github/workflows/ecs.yml index e18f15c..4f8e0f7 100644 --- a/.github/workflows/ecs.yml +++ b/.github/workflows/ecs.yml @@ -18,4 +18,6 @@ permissions: jobs: easy-coding-standard: - uses: yii2-framework/actions/.github/workflows/ecs.yml@main + uses: yii2-framework/actions/.github/workflows/ecs.yml@v1 + with: + php-version: '["8.3"]' diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 99d7c1c..cc1c99d 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -18,4 +18,4 @@ permissions: jobs: phpstan: - uses: yii2-framework/actions/.github/workflows/phpstan.yml@main + uses: yii2-framework/actions/.github/workflows/phpstan.yml@v1 diff --git a/.styleci.yml b/.styleci.yml index 40c1c55..8995a69 100644 --- a/.styleci.yml +++ b/.styleci.yml @@ -1,7 +1,7 @@ preset: psr12 risky: true -version: 8.1 +version: 8.3 finder: exclude: diff --git a/CHANGELOG.md b/CHANGELOG.md index f241e87..8a8a4b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,123 +1,79 @@ -# ChangeLog +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on Keep a Changelog, and this project adheres to Semantic Versioning. ## 0.6.0 Under development -- Enh #32: Add `HasBlocking` trait and `blocking()` method to manage `blocking` attribute for HTML elements (@terabytesoftw) -- Enh #33: Add `HasMedia` trait and `media()` method to manage `media` attribute for HTML elements (@terabytesoftw) -- Enh #34: Add `HasType` trait and `type()` method to manage `type` attribute for HTML elements (@terabytesoftw) -- Enh #35: Add `HasNonce` trait and `nonce()` method to manage `nonce` attribute for HTML elements (@terabytesoftw) -- Bug #36: Clarify documentation for various HTML attributes to specify value types for better understanding (@terabytesoftw) -- Enh #37: Add `HasIntegrity` trait and `integrity()` method to manage `integrity` attribute for HTML elements (@terabytesoftw) -- Enh #38: Add `HasReferrerpolicy` trait and `referrerpolicy()` method to manage `referrerpolicy` attribute for HTML elements (@terabytesoftw) -- Enh #39: Add `HasSrc` trait and `src()` method to manage `src` attribute for HTML elements (@terabytesoftw) -- Bug #40: Enhance documentation for HTML attributes (@terabytesoftw) -- Enh #41: Add `HasTarget` trait and `target()` method to manage `target` attribute for HTML elements (@terabytesoftw) -- Enh #42: Add `HasAs` trait and `as()` method to manage `as` attribute for HTML elements (@terabytesoftw) -- Bug #43: Update copyright year to `2026` in multiple files (@terabytesoftw) -- Enh #44: Add `HasDisabled` trait and `disabled()` method to manage `disabled` attribute for HTML elements (@terabytesoftw) -- Enh #45: Add `HasHreflang` trait and `hreflang()` method to manage `hreflang` attribute for HTML elements (@terabytesoftw) -- Enh #46: Add `HasImagesizes` trait and `imagesizes()` method to manage `imagesizes` attribute for HTML elements (@terabytesoftw) -- Enh #47: Add `HasImagesrcset` trait and `imagesrcset()` method to manage `imagesrcset` attribute for HTML elements (@terabytesoftw) -- Enh #48: Add `HasSizes` trait and `sizes()` method to manage `sizes` attribute for HTML elements (@terabytesoftw) -- Enh #49: Add `HasCharset` trait and `charset()` method to manage `charset` attribute for HTML elements (@terabytesoftw) -- Enh #50: Add `HasContent` trait and `content()` method to manage `content` attribute for HTML elements (@terabytesoftw) -- Enh #51: Add `HasHttpEquiv` trait and `httpEquiv()` method to manage `http-equiv` attribute for HTML elements (@terabytesoftw) -- Enh #52: Add `HasName` trait and `name()` method to manage `name` attribute for HTML elements (@terabytesoftw) -- Bug #53: Update documentation for various HTML attributes and their usage in elements (@terabytesoftw) -- Enh #54: Add `HasDownload` trait and `download()` method to manage `download` attribute for HTML elements (@terabytesoftw) -- Enh #55: Add `HasPing` trait and `ping()` method to manage `ping` attribute for HTML elements (@terabytesoftw) -- Enh #56: Add `HasLoading` trait and `loading()` method to manage `loading` attribute for HTML elements (@terabytesoftw) -- Enh #57: Add `HasSrcset` trait and `srcset()` method to manage `srcset` attribute for HTML elements (@terabytesoftw) -- Enh #58: Add `HasUsemap` trait and `usemap()` method to manage `usemap` attribute for HTML elements (@terabytesoftw) -- Enh #59: Add `HasValue` trait and `value()` method to manage `value` attribute for HTML elements (@terabytesoftw) -- Enh #60: Add `HasForm` trait and `form()` method to manage `form` attribute for HTML elements (@terabytesoftw) -- Enh #61: Add `Type` enum for common `type` attribute values (@terabytesoftw) -- Enh #62: Add `HasMax`, `HasMin` traits and `max()`, `min()` methods to manage `max` and `min` attributes for HTML elements (@terabytesoftw) -- Enh #63: Add `HasReadonly`, `HasStep` traits and `readonly()`, `step()` methods to manage `readonly` and `step` attributes for HTML elements (@terabytesoftw) -- Enh #64: Add `HasMaxlength`, `HasMinlength` traits and `maxlength()`, `minlength()` methods to manage `maxlength` and `minlength` attributes for HTML elements (@terabytesoftw) -- Enh #65: Add `HasRequired` trait and `required()` method to manage `required` attribute for HTML elements (@terabytesoftw) -- Bug #66: Enhance HTML attribute element handling with Stringable and UnitEnum support (@terabytesoftw) -- Enh #67: Add `HasAccept`, `HasAutocomplete` traits and `accept()`, `autocomplete()` methods to manage `accept` and `autocomplete` attributes for HTML elements (@terabytesoftw) -- Enh #68: Add `HasChecked`, `HasDirname` traits and `checked()`, `dirname()` methods to manage `checked` and `dirname` attributes for HTML elements (@terabytesoftw) -- Enh #69: Add `HasList`, `HasMultiple` traits and `list()`, `multiple()` methods to manage `list` and `multiple` attributes for HTML elements (@terabytesoftw) -- Enh #70: Add `HasPattern`, `HasPlaceholder`, `HasSize` traits and `pattern()`, `placeholder()`, `size()` methods to manage `pattern`, `placeholder`, and `size` attributes for HTML elements (@terabytesoftw) -- Bug #71: Move HTML attribute traits to `Form` namespace and update related imports accordingly (@terabytesoftw) -- Bug #72: Update documentation for HTML attribute elements in `Element` namespace (@terabytesoftw) -- Bug #73: Standardize PHPDoc headers across src directory files (@terabytesoftw) -- Bug #74: Remove directory `tests\Stub` and move `tests\Support\Provider` to `tests\Provider` in tests (@terabytesoftw) -- Bug #75: Standardize PHPDoc headers for test classes (@terabytesoftw) -- Bug #76: Move `HasDisabled` trait to `UIAwesome\Html\Attribute` namespace and update related imports accordingly (@terabytesoftw) -- Enh #77: Add `Autocomplete` enum and update `AutocompleteProvider` to add test data (@terabytesoftw) -- Enh #78: Add `HasPopover`, `HasPopoverTarget`, `HasPopoverTargetAction` traits and `popover()`, `popoverTarget()`, `popoverTargetAction()` methods to manage popover attributes for HTML elements (@terabytesoftw) -- Enh #79: Add `HasInputmode` trait and `inputmode()` method to manage `inputmode` attribute for HTML elements (@terabytesoftw) -- Bug #80: Update `value()` method in `HasValue` trait to accept boolean values and adjust related tests and data provider (@terabytesoftw) -- Bug #81: Migrate mixin attribute setters and tests to the simplified API (@terabytesoftw) -- Bug #82: Update `ui-awesome/html-helper` requirement to use stable version constraint `^0.7` in `composer.json` (@terabytesoftw) -- Enh #83: Enhance `HasAria`, `HasData`, and `HasEvents` traits to support prefix attributes `aria-`, `data-`, and `on` (@terabytesoftw) -- Bug #84: Refactor attribute documentation in traits (@terabytesoftw) -- Bug #85: Bug `#85`: Rename boolean attribute traits from `Has*` prefix to improve naming clarity (@terabytesoftw) -- Enh #86: Add `HasAutocapitalize` and `HasAutocorrect` traits and `autocapitalize()`, `autocorrect()` methods to manage `autocapitalize` and `autocorrect` attributes for HTML elements (@terabytesoftw) -- Bug #87: Update test method names for clarity by removing redundant `Value` suffix (@terabytesoftw) -- Enh #88: Add `CanBeSelected`, `HasLabel` traits and `selected()`, `label()` methods to manage `selected` and `label` attributes for HTML elements (@terabytesoftw) -- Enh #89: Add `HasFor` trait and `for()` method to manage `for` attribute for HTML elements (@terabytesoftw) +- feat: add common attribute traits for blocking, media, type, nonce, integrity, referrer policy, source, target, link preload, metadata, form, and selectable attributes. +- feat: add enum values for autocomplete, type, and shared attribute allow-lists. +- feat: add prefixed `aria-*`, `data-*`, and `on*` attribute support. +- feat: add autocapitalize, autocorrect, selected, label, and for attribute APIs. +- fix: support `Stringable`, `UnitEnum`, and boolean values consistently in attribute setters. +- refactor: migrate attribute setters and tests to the simplified `addAttribute()` API. +- refactor: remove element, form, media, and interactive element-specific traits now owned by `ui-awesome/html`. +- refactor: move element-specific enum cases from `Attribute` to `ElementAttribute`. +- refactor: rename boolean attribute traits from `Has*` to `CanBe*` for clearer API names. +- refactor: rename image size traits to `HasImageSizes` and `HasImageSrcSet`. +- docs: standardize attribute PHPDoc and clarify value types across traits and enums. +- test: standardize test PHPDoc, provider organization, exception names, and attribute assertions. +- chore: update `ui-awesome/html-helper` to the stable `^0.7` constraint. +- refactor: align attributes, docs, tests, and release tooling with the current package scope. ## 0.5.2 January 29, 2026 -- Enh #28: Add `php-forge/coding-standard` to development dependencies for code quality checks (@terabytesoftw) -- Bug #29: Add section for automated refactoring using `Rector` in testing documentation (@terabytesoftw) -- Bug #30: Update examples in `testing.md` for running Composer script with arguments and update `.styleci.yml` accordingly (@terabytesoftw) -- Bug #31: Remove redundant ignore rule in `actionlint.yml` configuration and update Rector command in `composer.json` to remove unnecessary `src` argument (@terabytesoftw) +- chore: add `php-forge/coding-standard` to development dependencies for code quality checks. +- docs: add automated refactoring guidance with Rector to the testing documentation. +- docs: update testing examples for running Composer scripts with arguments and align `.styleci.yml`. +- chore: remove the redundant `actionlint` ignore rule and simplify the Rector Composer script. ## 0.5.1 January 20, 2026 -- Enh #27: Add `php-forge/support` as a development dependency and update related test classes (@terabytesoftw) +- chore: add `php-forge/support` as a development dependency and update related tests. ## 0.5.0 January 19, 2026 -- Enh #14: Add `HasHref` trait and `href()` method to manage `href` attribute for HTML elements (@terabytesoftw) -- Enh #15: Add `HasCrossorigin` trait and `crossorigin()` method to manage `crossorigin` attribute for HTML elements (@terabytesoftw) -- Enh #16: Use package `ui-awesome/html-mixin` for mixin traits and update related imports accordingly (@terabytesoftw) -- Enh #17: Add development guide and sync metadata instructions and update testing documentation (@terabytesoftw) -- Enh #18: Move attribute traits from `ui-awesome/html-core` package and update related imports accordingly (@terabytesoftw) -- Bug #19: Update alert content in SVGs to reflect accurate descriptions for MDN standards compliance and specific & lightweight features (@terabytesoftw) -- Enh #20: Add `HasDecoding` trait and `decoding()` method to manage `decoding` attribute for HTML elements (@terabytesoftw) -- Enh #21: Add `HasFetchpriority` trait and `fetchpriority()` method to manage `fetchpriority` attribute for HTML elements (@terabytesoftw) -- Bug #22: Update documentation for `Crossorigin` and `ElementAttribute` enums to clarify attribute representation and compliance with MDN standards (@terabytesoftw) -- Bug #23: Update attribute retrieval in tests to use `getAttribute()` method for consistency (@terabytesoftw) -- Bug #24: Update documentation traits and enums for clarity and consistency (@terabytesoftw) -- Bug #25: Update documentation tests classes for clarity and consistency (@terabytesoftw) -- Bug #26: Improve `testing.md` for clarity and consistency in Composer script usage (@terabytesoftw) +- feat: add href, crossorigin, decoding, fetchpriority, and other element attribute traits. +- feat: add attribute traits moved from `ui-awesome/html-core`. +- feat: add `HasForm` and shared form-related attribute APIs. +- docs: add development guide, sync metadata instructions, and improved testing documentation. +- docs: refresh SVG feature descriptions for MDN alignment. +- docs: clarify `Crossorigin` and `ElementAttribute` enum documentation. +- docs: standardize trait, enum, and test documentation. +- fix: use `getAttribute()` consistently in tests. +- chore: update `ui-awesome/html-helper` to `0.2`. ## 0.4.0 December 27, 2025 -- Dep #13: Update `ui-awesome/html-helper` version constraint to `^0.6` in `composer.json` (@terabytesoftw) +- chore: update `ui-awesome/html-helper` constraint to `^0.6`. ## 0.3.0 December 26, 2025 -- Bug #10: Refactor codebase to improve performance and maintainability (@terabytesoftw) -- Bug #11: Improve test suite documentation for HTML attributes with detailed descriptions and coverage (@terabytesoftw) -- Bug #12: Add `StyleCI` badge to `README.md` for code style checks (@terabytesoftw) +- refactor: improve codebase performance and maintainability. +- docs: improve HTML attribute test suite documentation. +- docs: add the StyleCI badge to `README.md`. ## 0.2.0 March 30, 2024 -- Enh #9: Update `ui-awesome/html-helper` to `0.2` (@terabytesoftw) +- chore: update `ui-awesome/html-helper` to `0.2`. ## 0.1.3 March 16, 2024 -- Bug #8: Fix all `data` attributes for accept `true` value when `id` attribute is used (@terabytesoftw) +- fix: allow `data-*` attributes to accept `true` values when the `id` attribute is used. ## 0.1.2 March 14, 2024 -- Bug #3: Change visibility property `attributes` to `public` in tests (@terabytesoftw) -- Enh #4: Add `HasAriaCurrent` trait and `ariaCurrent()` method (@terabytesoftw) -- Bug #5: Remove dead code in `HasAriaCurrent` trait (@terabytesoftw) -- Bug #6: Change branch alias to `1.0-dev` in `composer.json` (@terabytesoftw) -- Bug #7: Remove redundant abstract method in `data` classes (@terabytesoftw) +- feat: add `HasAriaCurrent` trait and `ariaCurrent()` method. +- fix: change test attribute visibility to public. +- fix: remove dead code from `HasAriaCurrent`. +- fix: change the branch alias to `1.0-dev` in `composer.json`. +- fix: remove redundant abstract methods from data classes. ## 0.1.1 March 7, 2024 -- Bug #2: Add bool typehint to `dataBsToggle()` method and add default value to `true` in `dataBsTarget()`, `dataBstoggle()`, `dataDismissTarget()`, `dataDrawerTarget()`, `dataDrawerTarget()`,`dataDropdownToggle()` and `dataToggle()` (@terabytesoftw) +- fix: add boolean typing and default values to data attribute helper methods. ## 0.1.0 March 5, 2024 -- Initial release +- feat: initial `ui-awesome/html-attribute` package structure. diff --git a/README.md b/README.md index 7dc9e43..e9a4529 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,9 @@

- - - UI Awesome + UI Awesome -

Html attribute

+

Html Attribute


@@ -37,12 +35,12 @@ ### Installation ```bash -composer require ui-awesome/html-attribute:^0.3 +composer require ui-awesome/html-attribute:^0.6 ``` ### Quick start -Below are concise examples showing common attribute tasks. +Compose reusable attribute APIs by combining the package traits with the immutable attribute mixin. ```php getAttributes()); + } } + +$attributes = (new LinkAttributes()) + ->id('documentation') + ->class('nav-link') + ->class('is-active') + ->rel(Rel::NOOPENER) + ->addDataAttribute('tracking', 'docs'); + +echo 'render() . ' href="/docs">Documentation'; ``` ### Documentation @@ -65,11 +84,10 @@ final class ImageComponent For detailed configuration options and advanced usage see: - 🧪 [Testing Guide](docs/testing.md) -- 🛠️ [Development Guide](docs/development.md) ## Package information -[![PHP](https://img.shields.io/badge/%3E%3D8.1-777BB4.svg?style=for-the-badge&logo=php&logoColor=white)](https://www.php.net/releases/8.1/en.php) +[![PHP](https://img.shields.io/badge/%3E%3D8.3-777BB4.svg?style=for-the-badge&logo=php&logoColor=white)](https://www.php.net/releases/8.3/en.php) [![Latest Stable Version](https://img.shields.io/packagist/v/ui-awesome/html-attribute.svg?style=for-the-badge&logo=packagist&logoColor=white&label=Stable)](https://packagist.org/packages/ui-awesome/html-attribute) [![Total Downloads](https://img.shields.io/packagist/dt/ui-awesome/html-attribute.svg?style=for-the-badge&logo=composer&logoColor=white&label=Downloads)](https://packagist.org/packages/ui-awesome/html-attribute) diff --git a/composer.json b/composer.json index b7b9c8f..2cae5c7 100644 --- a/composer.json +++ b/composer.json @@ -1,29 +1,35 @@ { "name": "ui-awesome/html-attribute", "type": "library", - "description": "UI Awesome HTML Attribute Library for PHP.", + "description": "Type-safe traits and backed enums for HTML attribute composition: global attributes, ARIA, data-*, events, and element-specific setters.", "keywords": [ "ui-awesome", "html", - "attribute", - "library", + "html-attribute", + "traits", + "enums", + "attributes", + "aria", + "data-attributes", + "events", + "value-objects", "php" ], "license": "BSD-3-Clause", "require": { - "php": "^8.1", + "php": "^8.3", "ui-awesome/html-helper": "^0.7", - "ui-awesome/html-mixin": "^0.4" + "ui-awesome/html-mixin": "^0.5" }, "require-dev": { - "infection/infection": "^0.27|^0.32", + "infection/infection": "^0.32", "maglnet/composer-require-checker": "^4.1", "php-forge/coding-standard": "^0.1", "php-forge/support": "^0.3", "phpstan/extension-installer": "^1.4", "phpstan/phpstan": "^2.1", - "phpstan/phpstan-strict-rules": "^2.0.3", - "phpunit/phpunit": "^10.5" + "phpstan/phpstan-strict-rules": "^2.0", + "phpunit/phpunit": "^12.5" }, "autoload": { "psr-4": { @@ -54,15 +60,6 @@ "mutation-static": "./vendor/bin/infection --threads=4 --ignore-msi-with-no-mutations --min-msi=100 --min-covered-msi=100 --static-analysis-tool=phpstan --static-analysis-tool-options='--memory-limit=-1'", "rector": "./vendor/bin/rector process", "static": "./vendor/bin/phpstan --memory-limit=-1", - "sync-metadata": [ - "curl -fsSL -o .editorconfig https://raw.githubusercontent.com/yii2-extensions/template/main/.editorconfig", - "curl -fsSL -o .gitattributes https://raw.githubusercontent.com/yii2-extensions/template/main/.gitattributes", - "curl -fsSL -o .gitignore https://raw.githubusercontent.com/yii2-extensions/template/main/.gitignore", - "curl -fsSL -o .styleci.yml https://raw.githubusercontent.com/yii2-extensions/template/main/.styleci.yml", - "curl -fsSL -o infection.json5 https://raw.githubusercontent.com/yii2-extensions/template/main/infection.json5", - "curl -fsSL -o phpstan.neon https://raw.githubusercontent.com/yii2-extensions/template/main/phpstan.neon", - "curl -fsSL -o phpunit.xml.dist https://raw.githubusercontent.com/yii2-extensions/template/main/phpunit.xml.dist" - ], "tests": "./vendor/bin/phpunit" } } diff --git a/docs/development.md b/docs/development.md deleted file mode 100644 index 0e75489..0000000 --- a/docs/development.md +++ /dev/null @@ -1,42 +0,0 @@ -# Development - -This document describes development workflows and maintenance tasks for the project. - -## Sync Metadata - -To keep configuration files synchronized with the latest template updates, use the `sync-metadata` command. This command -downloads the latest configuration files from the template repository. - -```bash -composer sync-metadata -``` - -### Updated Files - -This command updates the following configuration files: - -| File | Purpose | -| ------------------ | -------------------------------------------- | -| `.editorconfig` | Editor settings and code style configuration | -| `.gitattributes` | Git attributes and file handling rules | -| `.gitignore` | Git ignore patterns and exclusions | -| `.styleci.yml` | StyleCI code style analysis configuration | -| `infection.json5` | Infection mutation testing configuration | -| `phpstan.neon` | PHPStan static analysis configuration | -| `phpunit.xml.dist` | PHPUnit test configuration | - -### When to Run - -Run this command in the following scenarios: - -- **Periodic Updates** - Monthly or quarterly to benefit from template improvements. -- **After Template Updates** - When the template repository has new configuration improvements. -- **Before Major Releases** - Ensure your project uses the latest best practices. -- **When Issues Occur** - If configuration files become outdated or incompatible. - -### Important Notes - -- This command overwrites existing configuration files with the latest versions from the template. -- Ensure you have committed any custom configuration changes before running this command. -- Review the updated files after syncing to ensure they work with your specific project needs. -- Some projects may require customizations after syncing configuration files. diff --git a/docs/svgs/features-mobile.svg b/docs/svgs/features-mobile.svg index 0f746e3..092fd0f 100644 --- a/docs/svgs/features-mobile.svg +++ b/docs/svgs/features-mobile.svg @@ -1,59 +1,52 @@ - - - -
- - /* Light mode */ - @media (prefers-color-scheme: light) { - .alert-title { color: #000000; } - .alert-content { color: #333333; } - .alert-box { background: rgba(31, 136, 61, 0.1); } - } - - /* Dark mode */ - @media (prefers-color-scheme: dark) { - .alert-title { color: #ffffff; } - .alert-content { color: #ffffff; } - .alert-box { background: rgba(31, 136, 61, 0.2); } - } - -
-
-

MDN Standards Compliant

-

Organized by Element • Global • Values

-
-
-

Specific & Lightweight

-

Attributes • Clean Architecture • Focused Traits

-
-
-
-
+ + + + Attribute APIs + Focused traits for shared HTML attributes and immutable setters + Built on addAttribute() with null removal semantics + + + + + ElementAttribute Enum + Element-specific attribute names without element trait duplication + Keeps ownership in ui-awesome/html while sharing constants + + + + + Global Attributes + class, id, lang, role, style, tabindex and related global APIs + Enum-backed values for consistent rendering and validation + + + + + Prefix Attributes + aria-*, data-* and on* helpers with prefix normalization + Safe removal and batch assignment through attribute bags + + + + + Typed Values + Stringable, UnitEnum, scalar and null support across setters + Dedicated enums for rel, target, crossorigin, direction and more + + + + + Validation + oneOf() checks and numeric constraints for strict attribute values + Deterministic exception messages for reliable test coverage +
diff --git a/docs/svgs/features.svg b/docs/svgs/features.svg index 4b437fe..27b52aa 100644 --- a/docs/svgs/features.svg +++ b/docs/svgs/features.svg @@ -1,56 +1,56 @@ - - -
- - /* Light mode */ - @media (prefers-color-scheme: light) { - .alert-title { color: #000000; } - .alert-content { color: #333333; } - .alert-box { background: rgba(31, 136, 61, 0.1); } - } + + + + Attribute APIs + Focused traits for shared HTML attributes and immutable setters + Built on addAttribute() with null removal semantics + - /* Dark mode */ - @media (prefers-color-scheme: dark) { - .alert-title { color: #ffffff; } - .alert-content { color: #ffffff; } - .alert-box { background: rgba(31, 136, 61, 0.2); } - } - -
-
-

MDN Standards Compliant

-

Organized by Element • Global • Values

-
-
-

Specific & Lightweight

-

Attributes • Clean Architecture • Focused Traits

-
-
-
-
+ + + + ElementAttribute Enum + Element-specific attribute names without element trait duplication + Keeps ownership in ui-awesome/html while sharing constants + + + + + + Global Attributes + class, id, lang, role, style, tabindex and related global APIs + Enum-backed values for consistent rendering and validation + + + + + + Prefix Attributes + aria-*, data-* and on* helpers with prefix normalization + Safe removal and batch assignment through attribute bags + + + + + + Typed Values + Stringable, UnitEnum, scalar and null support across setters + Dedicated enums for rel, target, crossorigin, direction and more + + + + + + Validation + oneOf() checks and numeric constraints for strict attribute values + Deterministic exception messages for reliable test coverage +
diff --git a/docs/testing.md b/docs/testing.md index e0e9d88..f1ad2a0 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -80,3 +80,7 @@ Run PHPStan with a different memory limit. ```bash composer static -- --memory-limit=512M ``` + +## Next steps + +- 📖 [Readme](../README.md) diff --git a/src/CanBeDisabled.php b/src/CanBeDisabled.php index d3988ba..aee53e1 100644 --- a/src/CanBeDisabled.php +++ b/src/CanBeDisabled.php @@ -33,6 +33,6 @@ trait CanBeDisabled */ public function disabled(bool|null $value): static { - return $this->setAttribute(Attribute::DISABLED, $value); + return $this->addAttribute(Attribute::DISABLED, $value); } } diff --git a/src/CanBeSelected.php b/src/CanBeSelected.php index 4df3b48..7e14660 100644 --- a/src/CanBeSelected.php +++ b/src/CanBeSelected.php @@ -4,7 +4,7 @@ namespace UIAwesome\Html\Attribute; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\ElementAttribute; /** * Provides an immutable API for the `selected` attribute. @@ -33,6 +33,6 @@ trait CanBeSelected */ public function selected(bool|null $value): static { - return $this->setAttribute(Attribute::SELECTED, $value); + return $this->addAttribute(ElementAttribute::SELECTED, $value); } } diff --git a/src/Element/HasAlt.php b/src/Element/HasAlt.php deleted file mode 100644 index 0f7ee05..0000000 --- a/src/Element/HasAlt.php +++ /dev/null @@ -1,41 +0,0 @@ -alt('A penguin on a beach.'); - * $element->alt(''); - * $element->alt(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Alternative text for the element, or `null` to remove the - * attribute. - * - * @return static New instance with the updated `alt` attribute. - */ - public function alt(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(ElementAttribute::ALT, $value); - } -} diff --git a/src/Element/HasDecoding.php b/src/Element/HasDecoding.php deleted file mode 100644 index de79d9a..0000000 --- a/src/Element/HasDecoding.php +++ /dev/null @@ -1,50 +0,0 @@ -decoding('async'); - * $element->decoding(Decoding::ASYNC); - * $element->decoding(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Decoding hint value. Use `async`, `sync`, or `auto`, or `null` to - * remove the attribute. - * - * @throws InvalidArgumentException If the value is not valid. - * - * @return static New instance with the updated `decoding` attribute. - * - * {@see Decoding} for predefined enum values. - */ - public function decoding(string|Stringable|UnitEnum|null $value): static - { - Validator::oneOf($value, Decoding::cases(), ElementAttribute::DECODING); - - return $this->setAttribute(ElementAttribute::DECODING, $value); - } -} diff --git a/src/Element/HasHeight.php b/src/Element/HasHeight.php deleted file mode 100644 index 9706ba1..0000000 --- a/src/Element/HasHeight.php +++ /dev/null @@ -1,42 +0,0 @@ -height(200); - * $element->height('50%'); - * $element->height('auto'); - * ``` - * - * @param int|string|Stringable|UnitEnum|null $value Height value in pixels or CSS units, or `null` to remove the - * attribute. - * - * @return static New instance with the updated `height` attribute. - */ - public function height(int|string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(ElementAttribute::HEIGHT, $value); - } -} diff --git a/src/Element/HasHref.php b/src/Element/HasHref.php deleted file mode 100644 index 65c97c4..0000000 --- a/src/Element/HasHref.php +++ /dev/null @@ -1,42 +0,0 @@ -href('https://example.com/page'); - * $element->href('/about'); - * $element->href('#section'); - * $element->href(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value URL, path, or fragment, or `null` to remove the attribute. - * - * @return static New instance with the updated `href` attribute. - */ - public function href(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(ElementAttribute::HREF, $value); - } -} diff --git a/src/Element/HasLoading.php b/src/Element/HasLoading.php deleted file mode 100644 index 27c0b15..0000000 --- a/src/Element/HasLoading.php +++ /dev/null @@ -1,50 +0,0 @@ -loading('lazy'); - * $element->loading(Loading::LAZY); - * $element->loading(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Loading strategy (`eager` or `lazy`), or `null` to remove the - * attribute. - * - * @throws InvalidArgumentException If the value is not valid. - * - * @return static New instance with the updated `loading` attribute. - * - * {@see Loading} for predefined enum values. - */ - public function loading(string|Stringable|UnitEnum|null $value): static - { - Validator::oneOf($value, Loading::cases(), ElementAttribute::LOADING); - - return $this->setAttribute(ElementAttribute::LOADING, $value); - } -} diff --git a/src/Element/HasPopoverTarget.php b/src/Element/HasPopoverTarget.php deleted file mode 100644 index 8b3b9e9..0000000 --- a/src/Element/HasPopoverTarget.php +++ /dev/null @@ -1,40 +0,0 @@ -popoverTarget('popover-id'); - * $element->popoverTarget($targetId); - * $element->popoverTarget(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Popover target ID, or `null` to remove the attribute. - * - * @return static New instance with the updated `popovertarget` attribute. - */ - public function popoverTarget(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(ElementAttribute::POPOVERTARGET, $value); - } -} diff --git a/src/Element/HasPopoverTargetAction.php b/src/Element/HasPopoverTargetAction.php deleted file mode 100644 index 1a3baf0..0000000 --- a/src/Element/HasPopoverTargetAction.php +++ /dev/null @@ -1,47 +0,0 @@ -popoverTargetAction('toggle'); - * $element->popoverTargetAction($action); - * $element->popoverTargetAction(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Popover target action (`hide`, `show`, `toggle`), or `null` to - * remove the attribute. - * - * @throws InvalidArgumentException If the provided value is not valid. - * - * @return static New instance with the updated `popovertargetaction` attribute. - */ - public function popoverTargetAction(string|Stringable|UnitEnum|null $value): static - { - Validator::oneOf($value, PopoverTargetAction::cases(), ElementAttribute::POPOVERTARGETACTION); - - return $this->setAttribute(ElementAttribute::POPOVERTARGETACTION, $value); - } -} diff --git a/src/Element/HasReferrerpolicy.php b/src/Element/HasReferrerpolicy.php deleted file mode 100644 index 856a9e5..0000000 --- a/src/Element/HasReferrerpolicy.php +++ /dev/null @@ -1,53 +0,0 @@ -referrerpolicy('origin'); - * $element->referrerpolicy(Referrerpolicy::NO_REFERRER); - * $element->referrerpolicy(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Referrer policy token, or `null` to remove the attribute. - * - * @throws InvalidArgumentException If the value is not valid. - * - * @return static New instance with the updated `referrerpolicy` attribute. - * - * {@see Referrerpolicy} for predefined enum values. - */ - public function referrerpolicy(string|Stringable|UnitEnum|null $value): static - { - Validator::oneOf($value, Referrerpolicy::cases(), ElementAttribute::REFERRERPOLICY); - - return $this->setAttribute(ElementAttribute::REFERRERPOLICY, $value); - } -} diff --git a/src/Element/HasSrc.php b/src/Element/HasSrc.php deleted file mode 100644 index 46b4c81..0000000 --- a/src/Element/HasSrc.php +++ /dev/null @@ -1,40 +0,0 @@ -src('https://example.com/image.png'); - * $element->src('images/photo.jpg'); - * $element->src(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Image source URL or path, or `null` to remove the attribute. - * - * @return static New instance with the updated `src` attribute. - */ - public function src(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(ElementAttribute::SRC, $value); - } -} diff --git a/src/Element/HasSrcset.php b/src/Element/HasSrcset.php deleted file mode 100644 index 1b436d6..0000000 --- a/src/Element/HasSrcset.php +++ /dev/null @@ -1,42 +0,0 @@ -srcset('small.jpg 480w, medium.jpg 800w, large.jpg 1200w'); - * $element->srcset('image-1x.jpg 1x, image-2x.jpg 2x'); - * $element->srcset(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Comma-separated image URLs with size descriptors, or `null` to - * remove the attribute. - * - * @return static New instance with the updated `srcset` attribute. - */ - public function srcset(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute('srcset', $value); - } -} diff --git a/src/Element/HasUsemap.php b/src/Element/HasUsemap.php deleted file mode 100644 index 05db080..0000000 --- a/src/Element/HasUsemap.php +++ /dev/null @@ -1,40 +0,0 @@ -usemap('#imagemap'); - * $element->usemap(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Hash-name reference to a `map` element, or `null` to remove the - * attribute. - * - * @return static New instance with the updated `usemap` attribute. - */ - public function usemap(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(ElementAttribute::USEMAP, $value); - } -} diff --git a/src/Element/HasWidth.php b/src/Element/HasWidth.php deleted file mode 100644 index 8eda341..0000000 --- a/src/Element/HasWidth.php +++ /dev/null @@ -1,43 +0,0 @@ -width(400); - * $element->width('50%'); - * $element->width('auto'); - * $element->width(null); - * ``` - * - * @param int|string|Stringable|UnitEnum|null $value Width value in pixels or CSS units, or `null` to remove the - * attribute. - * - * @return static New instance with the updated `width` attribute. - */ - public function width(int|string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(ElementAttribute::WIDTH, $value); - } -} diff --git a/src/Exception/Message.php b/src/Exception/Message.php index 0f8a99e..83fac49 100644 --- a/src/Exception/Message.php +++ b/src/Exception/Message.php @@ -9,7 +9,7 @@ /** * Represents error message templates for attribute exceptions. * - * Use {@see Message::getMessage()} to format the template with `sprintf()` arguments. + * Use {@see Message::getMessage()} to format the template with {@see sprintf()} arguments. * * @copyright Copyright (C) 2025 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. @@ -24,7 +24,7 @@ enum Message: string case ATTRIBUTE_INVALID_VALUE = "Invalid value '%s' for attribute '%s'. Expected: '%s'."; /** - * Error when an attribute value is not a `scalar` or `Closure`. + * Error when an attribute value is not a scalar or Closure. * * Format: "Attribute value must be of type 'scalar' or 'Closure', '%s' given." */ diff --git a/src/Form/CanBeChecked.php b/src/Form/CanBeChecked.php deleted file mode 100644 index 2b64edd..0000000 --- a/src/Form/CanBeChecked.php +++ /dev/null @@ -1,38 +0,0 @@ -checked(true); - * $element->checked(null); - * ``` - * - * @param bool|null $value Checked state. Use `true` to check, `false` to uncheck, or `null` to remove the - * attribute. - * - * @return static New instance with the updated `checked` attribute. - */ - public function checked(bool|null $value): static - { - return $this->setAttribute(Attribute::CHECKED, $value); - } -} diff --git a/src/Form/CanBeMultiple.php b/src/Form/CanBeMultiple.php deleted file mode 100644 index 0d6a77e..0000000 --- a/src/Form/CanBeMultiple.php +++ /dev/null @@ -1,38 +0,0 @@ -multiple(true); - * $element->multiple(null); - * ``` - * - * @param bool|null $value Multiple state. Use `true` to allow multiple values, `false` to disallow, or `null` to - * remove the attribute. - * - * @return static New instance with the updated `multiple` attribute. - */ - public function multiple(bool|null $value): static - { - return $this->setAttribute(Attribute::MULTIPLE, $value); - } -} diff --git a/src/Form/CanBeReadonly.php b/src/Form/CanBeReadonly.php deleted file mode 100644 index 9a14232..0000000 --- a/src/Form/CanBeReadonly.php +++ /dev/null @@ -1,38 +0,0 @@ -readonly(true); - * $element->readonly(null); - * ``` - * - * @param bool|null $value Readonly state. Use `true` to make readonly, `false` to make editable, or `null` to - * remove the attribute. - * - * @return static New instance with the updated `readonly` attribute. - */ - public function readonly(bool|null $value): static - { - return $this->setAttribute(Attribute::READONLY, $value); - } -} diff --git a/src/Form/CanBeRequired.php b/src/Form/CanBeRequired.php deleted file mode 100644 index c8c71e0..0000000 --- a/src/Form/CanBeRequired.php +++ /dev/null @@ -1,38 +0,0 @@ -required(true); - * $element->required(null); - * ``` - * - * @param bool|null $value Required state. Use `true` to require a value, `false` to make it optional, or `null` to - * remove the attribute. - * - * @return static New instance with the updated `required` attribute. - */ - public function required(bool|null $value): static - { - return $this->setAttribute(Attribute::REQUIRED, $value); - } -} diff --git a/src/Form/HasAccept.php b/src/Form/HasAccept.php deleted file mode 100644 index 93effa5..0000000 --- a/src/Form/HasAccept.php +++ /dev/null @@ -1,41 +0,0 @@ -accept('image/*'); - * $element->accept('.jpg,.png,.pdf'); - * $element->accept('image/jpeg,application/pdf'); - * $element->accept(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Accept value, or `null` to remove the attribute. - * - * @return static New instance with the updated `accept` attribute. - */ - public function accept(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(Attribute::ACCEPT, $value); - } -} diff --git a/src/Form/HasAutocomplete.php b/src/Form/HasAutocomplete.php deleted file mode 100644 index 72197c0..0000000 --- a/src/Form/HasAutocomplete.php +++ /dev/null @@ -1,41 +0,0 @@ -autocomplete('on'); - * $element->autocomplete('email'); - * $element->autocomplete('new-password'); - * $element->autocomplete(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Autocomplete value, or `null` to remove the attribute. - * - * @return static New instance with the updated `autocomplete` attribute. - */ - public function autocomplete(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(Attribute::AUTOCOMPLETE, $value); - } -} diff --git a/src/Form/HasDirname.php b/src/Form/HasDirname.php deleted file mode 100644 index 11935cc..0000000 --- a/src/Form/HasDirname.php +++ /dev/null @@ -1,40 +0,0 @@ -dirname('comment-dir'); - * $element->dirname('text-direction'); - * $element->dirname(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Dirname value, or `null` to remove the attribute. - * - * @return static New instance with the updated `dirname` attribute. - */ - public function dirname(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(Attribute::DIRNAME, $value); - } -} diff --git a/src/Form/HasForm.php b/src/Form/HasForm.php deleted file mode 100644 index 9d27165..0000000 --- a/src/Form/HasForm.php +++ /dev/null @@ -1,40 +0,0 @@ -form('myForm'); - * $element->form($formId); - * $element->form(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Form ID, or `null` to remove the attribute. - * - * @return static New instance with the updated `form` attribute. - */ - public function form(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(Attribute::FORM, $value); - } -} diff --git a/src/Form/HasList.php b/src/Form/HasList.php deleted file mode 100644 index 519dcea..0000000 --- a/src/Form/HasList.php +++ /dev/null @@ -1,40 +0,0 @@ -list('suggestions'); - * $element->list('countries-list'); - * $element->list(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Datalist ID, or `null` to remove the attribute. - * - * @return static New instance with the updated `list` attribute. - */ - public function list(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(Attribute::LIST, $value); - } -} diff --git a/src/Form/HasMax.php b/src/Form/HasMax.php deleted file mode 100644 index bc3ee41..0000000 --- a/src/Form/HasMax.php +++ /dev/null @@ -1,41 +0,0 @@ -max(100); - * $element->max('2024-12-31'); - * $element->max('23:59'); - * $element->max(null); - * ``` - * - * @param float|int|string|Stringable|UnitEnum|null $value Maximum value, or `null` to remove the attribute. - * - * @return static New instance with the updated `max` attribute. - */ - public function max(float|int|string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(Attribute::MAX, $value); - } -} diff --git a/src/Form/HasMaxlength.php b/src/Form/HasMaxlength.php deleted file mode 100644 index 5b3f3df..0000000 --- a/src/Form/HasMaxlength.php +++ /dev/null @@ -1,60 +0,0 @@ -maxlength(50); - * $element->maxlength(255); - * $element->maxlength(null); - * ``` - * - * @param int|string|Stringable|UnitEnum|null $value Maximum length. Must be `>= 0`, or `null` to remove the - * attribute. - * - * @throws InvalidArgumentException if the value is not an integer-like value `>= 0`. - * - * @return static New instance with the updated `maxlength` attribute. - */ - public function maxlength(int|string|Stringable|UnitEnum|null $value): static - { - if ($value instanceof UnitEnum) { - $value = Enum::normalizeValue($value); - } - - if ($value !== null && Validator::intLike($value) === false) { - throw new InvalidArgumentException( - Message::ATTRIBUTE_INVALID_VALUE->getMessage( - (string) $value, - Attribute::MAXLENGTH->value, - 'value >= 0', - ), - ); - } - - return $this->setAttribute(Attribute::MAXLENGTH, $value); - } -} diff --git a/src/Form/HasMin.php b/src/Form/HasMin.php deleted file mode 100644 index d974d4f..0000000 --- a/src/Form/HasMin.php +++ /dev/null @@ -1,41 +0,0 @@ -min(0); - * $element->min('2024-01-01'); - * $element->min('08:00'); - * $element->min(null); - * ``` - * - * @param float|int|string|Stringable|UnitEnum|null $value Minimum value, or `null` to remove the attribute. - * - * @return static New instance with the updated `min` attribute. - */ - public function min(float|int|string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(Attribute::MIN, $value); - } -} diff --git a/src/Form/HasMinlength.php b/src/Form/HasMinlength.php deleted file mode 100644 index 5e20cfe..0000000 --- a/src/Form/HasMinlength.php +++ /dev/null @@ -1,60 +0,0 @@ -minlength(3); - * $element->minlength(8); - * $element->minlength(null); - * ``` - * - * @param int|string|Stringable|UnitEnum|null $value Minimum length. Must be `>= 0`, or `null` to remove the - * attribute. - * - * @throws InvalidArgumentException if the value is not an integer-like value `>= 0`. - * - * @return static New instance with the updated `minlength` attribute. - */ - public function minlength(int|string|Stringable|UnitEnum|null $value): static - { - if ($value instanceof UnitEnum) { - $value = Enum::normalizeValue($value); - } - - if ($value !== null && Validator::intLike($value) === false) { - throw new InvalidArgumentException( - Message::ATTRIBUTE_INVALID_VALUE->getMessage( - (string) $value, - Attribute::MINLENGTH->value, - 'value >= 0', - ), - ); - } - - return $this->setAttribute(Attribute::MINLENGTH, $value); - } -} diff --git a/src/Form/HasPattern.php b/src/Form/HasPattern.php deleted file mode 100644 index d601eab..0000000 --- a/src/Form/HasPattern.php +++ /dev/null @@ -1,40 +0,0 @@ -pattern('[0-9]{3}-[0-9]{2}-[0-9]{4}'); - * $element->pattern('[a-z]+'); - * $element->pattern(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Pattern value, or `null` to remove the attribute. - * - * @return static New instance with the updated `pattern` attribute. - */ - public function pattern(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(Attribute::PATTERN, $value); - } -} diff --git a/src/Form/HasPlaceholder.php b/src/Form/HasPlaceholder.php deleted file mode 100644 index 0839cac..0000000 --- a/src/Form/HasPlaceholder.php +++ /dev/null @@ -1,40 +0,0 @@ -placeholder('Enter your email'); - * $element->placeholder('for example, John Doe'); - * $element->placeholder(null); - * ``` - * - * @param string|Stringable|UnitEnum|null $value Placeholder text, or `null` to remove the attribute. - * - * @return static New instance with the updated `placeholder` attribute. - */ - public function placeholder(string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(Attribute::PLACEHOLDER, $value); - } -} diff --git a/src/Form/HasSize.php b/src/Form/HasSize.php deleted file mode 100644 index cde284c..0000000 --- a/src/Form/HasSize.php +++ /dev/null @@ -1,59 +0,0 @@ -size(10); - * $element->size(50); - * $element->size(null); - * ``` - * - * @param int|string|Stringable|UnitEnum|null $value Size value. Must be `>= 0`, or `null` to remove the attribute. - * - * @throws InvalidArgumentException if the value is not an integer-like value `>= 0`. - * - * @return static New instance with the updated `size` attribute. - */ - public function size(int|string|Stringable|UnitEnum|null $value): static - { - if ($value instanceof UnitEnum) { - $value = Enum::normalizeValue($value); - } - - if ($value !== null && Validator::intLike($value) === false) { - throw new InvalidArgumentException( - Message::ATTRIBUTE_INVALID_VALUE->getMessage( - (string) $value, - Attribute::SIZE->value, - 'value >= 0', - ), - ); - } - - return $this->setAttribute(Attribute::SIZE, $value); - } -} diff --git a/src/Form/HasStep.php b/src/Form/HasStep.php deleted file mode 100644 index 5e56b14..0000000 --- a/src/Form/HasStep.php +++ /dev/null @@ -1,42 +0,0 @@ -step(1); - * $element->step(0.5); - * $element->step('any'); - * $element->step(null); - * ``` - * - * @param float|int|string|Stringable|UnitEnum|null $value Step value. Use `any` for no stepping restriction, or - * `null` to remove the attribute. - * - * @return static New instance with the updated `step` attribute. - */ - public function step(float|int|string|Stringable|UnitEnum|null $value): static - { - return $this->setAttribute(Attribute::STEP, $value); - } -} diff --git a/src/Global/CanBeAutofocus.php b/src/Global/CanBeAutofocus.php index 8c7cf52..cae5d2f 100644 --- a/src/Global/CanBeAutofocus.php +++ b/src/Global/CanBeAutofocus.php @@ -32,6 +32,6 @@ trait CanBeAutofocus */ public function autofocus(bool|null $value): static { - return $this->setAttribute(GlobalAttribute::AUTOFOCUS, $value); + return $this->addAttribute(GlobalAttribute::AUTOFOCUS, $value); } } diff --git a/src/Global/CanBeHidden.php b/src/Global/CanBeHidden.php index 6cb57e1..c49b0bb 100644 --- a/src/Global/CanBeHidden.php +++ b/src/Global/CanBeHidden.php @@ -33,6 +33,6 @@ trait CanBeHidden */ public function hidden(bool|null $value): static { - return $this->setAttribute(GlobalAttribute::HIDDEN, $value); + return $this->addAttribute(GlobalAttribute::HIDDEN, $value); } } diff --git a/src/Global/HasAccesskey.php b/src/Global/HasAccesskey.php index 4278817..50d176e 100644 --- a/src/Global/HasAccesskey.php +++ b/src/Global/HasAccesskey.php @@ -34,6 +34,6 @@ trait HasAccesskey */ public function accesskey(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(GlobalAttribute::ACCESSKEY, $value); + return $this->addAttribute(GlobalAttribute::ACCESSKEY, $value); } } diff --git a/src/Global/HasAria.php b/src/Global/HasAria.php index e7e5a44..d776534 100644 --- a/src/Global/HasAria.php +++ b/src/Global/HasAria.php @@ -7,6 +7,7 @@ use Closure; use InvalidArgumentException; use Stringable; +use UIAwesome\Html\Helper\AttributeBag; use UnitEnum; /** @@ -35,20 +36,18 @@ trait HasAria * ``` * * @param string|UnitEnum $key Aria attribute key without the `aria-` prefix. - * @param bool|Closure|float|int|string|Stringable|UnitEnum|null $value Aria attribute value, or `null` to remove - * the attribute. + * @param bool|Closure(): mixed|float|int|string|Stringable|UnitEnum|null $value Aria attribute value, or `null` to + * remove the attribute. * * @throws InvalidArgumentException if one or more arguments are invalid, of incorrect type or format. * * @return static New instance with the updated `aria-*` attribute. - * - * @phpstan-param scalar|Stringable|UnitEnum|Closure(): mixed $value */ public function addAriaAttribute( string|UnitEnum $key, bool|float|int|string|Closure|Stringable|UnitEnum|null $value, ): static { - return $this->setAttribute($key, $value, 'aria-'); + return $this->addAttribute(AttributeBag::normalizeKey($key, 'aria-'), $value); } /** @@ -70,18 +69,22 @@ public function addAriaAttribute( * ); * ``` * - * @param array $values Associative array of aria keys and values. Values may be scalar, `Stringable`, `UnitEnum`, - * `Closure`, or `null` to remove the attribute. + * @param mixed[] $values Associative array of aria keys and values. Values may be scalar, Stringable, UnitEnum, + * Closure, or `null` to remove the attribute. * * @throws InvalidArgumentException if one or more arguments are invalid, of incorrect type or format. * * @return static New instance with the updated `aria-*` attributes. - * - * @phpstan-param mixed[] $values */ public function ariaAttributes(array $values): static { - return $this->attributes($values, 'aria-'); + $new = $this; + + foreach ($values as $key => $value) { + $new = $new->addAttribute(AttributeBag::normalizeKey($key, 'aria-'), $value); + } + + return $new; } /** @@ -99,6 +102,6 @@ public function ariaAttributes(array $values): static */ public function removeAriaAttribute(string|UnitEnum $key): static { - return $this->removeAttribute($key, 'aria-'); + return $this->addAttribute(AttributeBag::normalizeKey($key, 'aria-'), null); } } diff --git a/src/Global/HasAutocapitalize.php b/src/Global/HasAutocapitalize.php index 789d268..86c84f6 100644 --- a/src/Global/HasAutocapitalize.php +++ b/src/Global/HasAutocapitalize.php @@ -29,8 +29,8 @@ trait HasAutocapitalize * $element->autocapitalize(\UIAwesome\Html\Attribute\Values\Autocapitalize::SENTENCES)->render(); * ``` * - * @param string|UnitEnum|null $value Capitalization behavior (`none`, `off`, `sentences`, `on`, `words`, - * `characters`), or `null` to remove the attribute. + * @param string|UnitEnum|null $value Capitalization behavior ('none', 'off', 'sentences', 'on', 'words', + * 'characters'), or `null` to remove the attribute. * * @throws InvalidArgumentException if the provided value is not valid. * @@ -42,6 +42,6 @@ public function autocapitalize(string|UnitEnum|null $value): static { Validator::oneOf($value, Autocapitalize::cases(), 'autocapitalize'); - return $this->setAttribute('autocapitalize', $value); + return $this->addAttribute('autocapitalize', $value); } } diff --git a/src/Global/HasAutocorrect.php b/src/Global/HasAutocorrect.php index d1e4692..6ca65bf 100644 --- a/src/Global/HasAutocorrect.php +++ b/src/Global/HasAutocorrect.php @@ -29,7 +29,7 @@ trait HasAutocorrect * $element->autocorrect(\UIAwesome\Html\Attribute\Values\Autocorrect::ON)->render(); * ``` * - * @param string|UnitEnum|null $value Autocorrect behavior (`on` or `off`), or `null` to remove the attribute. + * @param string|UnitEnum|null $value Autocorrect behavior ('on' or 'off'), or `null` to remove the attribute. * * @throws InvalidArgumentException if the provided value is not valid. * @@ -41,6 +41,6 @@ public function autocorrect(string|UnitEnum|null $value): static { Validator::oneOf($value, Autocorrect::cases(), 'autocorrect'); - return $this->setAttribute('autocorrect', $value); + return $this->addAttribute('autocorrect', $value); } } diff --git a/src/Global/HasContentEditable.php b/src/Global/HasContentEditable.php index 0ac5fff..c59a5fe 100644 --- a/src/Global/HasContentEditable.php +++ b/src/Global/HasContentEditable.php @@ -32,7 +32,7 @@ trait HasContentEditable * $element->contentEditable(ContentEditable::TRUE); * ``` * - * @param bool|string|UnitEnum|null $value Content editability value. Use `true`, `false`, or `plaintext-only`, or + * @param bool|string|UnitEnum|null $value Content editability value. Use `true`, `false`, or 'plaintext-only', or * `null` to remove the attribute. * * @throws InvalidArgumentException If the value is not valid. @@ -49,6 +49,6 @@ public function contentEditable(bool|string|UnitEnum|null $value): static Validator::oneOf($value, ContentEditable::cases(), GlobalAttribute::CONTENTEDITABLE); - return $this->setAttribute(GlobalAttribute::CONTENTEDITABLE, $value); + return $this->addAttribute(GlobalAttribute::CONTENTEDITABLE, $value); } } diff --git a/src/Global/HasData.php b/src/Global/HasData.php index 67798e2..c365a66 100644 --- a/src/Global/HasData.php +++ b/src/Global/HasData.php @@ -7,6 +7,7 @@ use Closure; use InvalidArgumentException; use Stringable; +use UIAwesome\Html\Helper\AttributeBag; use UnitEnum; /** @@ -33,20 +34,18 @@ trait HasData * ``` * * @param string|UnitEnum $key Data attribute key without the `data-` prefix. - * @param bool|Closure|float|int|string|Stringable|UnitEnum|null $value Data attribute value, or `null` to remove - * the attribute. + * @param bool|Closure(): mixed|float|int|string|Stringable|UnitEnum|null $value Data attribute value, or `null` to + * remove the attribute. * * @throws InvalidArgumentException if one or more arguments are invalid, of incorrect type or format. * * @return static New instance with the updated `data-*` attribute. - * - * @phpstan-param scalar|Stringable|UnitEnum|Closure(): mixed $value */ public function addDataAttribute( string|UnitEnum $key, bool|float|int|string|Closure|Stringable|UnitEnum|null $value, ): static { - return $this->setAttribute($key, $value, 'data-'); + return $this->addAttribute(AttributeBag::normalizeKey($key, 'data-'), $value); } /** @@ -67,18 +66,22 @@ public function addDataAttribute( * ); * ``` * - * @param array $values Associative array of data keys and values. Values may be scalar, `Stringable`, `UnitEnum`, - * `Closure`, or `null` to remove the attribute. + * @param mixed[] $values Associative array of data keys and values. Values may be scalar, Stringable, UnitEnum, + * Closure, or `null` to remove the attribute. * * @throws InvalidArgumentException if one or more arguments are invalid, of incorrect type or format. * * @return static New instance with the updated `data-*` attributes. - * - * @phpstan-param mixed[] $values */ public function dataAttributes(array $values): static { - return $this->attributes($values, 'data-'); + $new = $this; + + foreach ($values as $key => $value) { + $new = $new->addAttribute(AttributeBag::normalizeKey($key, 'data-'), $value); + } + + return $new; } /** @@ -96,6 +99,6 @@ public function dataAttributes(array $values): static */ public function removeDataAttribute(string|UnitEnum $key): static { - return $this->removeAttribute($key, 'data-'); + return $this->addAttribute(AttributeBag::normalizeKey($key, 'data-'), null); } } diff --git a/src/Global/HasDir.php b/src/Global/HasDir.php index 2077a28..67d6543 100644 --- a/src/Global/HasDir.php +++ b/src/Global/HasDir.php @@ -30,7 +30,7 @@ trait HasDir * $element->dir(Direction::AUTO); * ``` * - * @param string|UnitEnum|null $value Directionality value. Use `ltr`, `rtl`, or `auto`, or `null` to remove the + * @param string|UnitEnum|null $value Directionality value. Use 'ltr', 'rtl', or 'auto', or `null` to remove the * attribute. * * @throws InvalidArgumentException If the value is not valid. @@ -43,6 +43,6 @@ public function dir(string|UnitEnum|null $value): static { Validator::oneOf($value, Direction::cases(), GlobalAttribute::DIR); - return $this->setAttribute(GlobalAttribute::DIR, $value); + return $this->addAttribute(GlobalAttribute::DIR, $value); } } diff --git a/src/Global/HasDraggable.php b/src/Global/HasDraggable.php index 6d946d8..557c527 100644 --- a/src/Global/HasDraggable.php +++ b/src/Global/HasDraggable.php @@ -48,6 +48,6 @@ public function draggable(bool|string|UnitEnum|null $value): static Validator::oneOf($value, Draggable::cases(), GlobalAttribute::DRAGGABLE); - return $this->setAttribute(GlobalAttribute::DRAGGABLE, $value); + return $this->addAttribute(GlobalAttribute::DRAGGABLE, $value); } } diff --git a/src/Global/HasEvents.php b/src/Global/HasEvents.php index 11a1c83..d71fcb1 100644 --- a/src/Global/HasEvents.php +++ b/src/Global/HasEvents.php @@ -7,6 +7,7 @@ use Closure; use InvalidArgumentException; use Stringable; +use UIAwesome\Html\Helper\AttributeBag; use UnitEnum; /** @@ -32,17 +33,16 @@ trait HasEvents * ``` * * @param string|UnitEnum $key Event attribute key with or without the leading `on` prefix. - * @param Closure|string|Stringable|UnitEnum|null $value JavaScript handler code, or `null` to remove the attribute. + * @param Closure(): mixed|string|Stringable|UnitEnum|null $value JavaScript handler code, or `null` to remove the + * attribute. * * @throws InvalidArgumentException if one or more arguments are invalid, of incorrect type or format. * * @return static New instance with the updated `on*` event attribute. - * - * @phpstan-param Closure(): mixed|string|Stringable|UnitEnum|null $value */ public function addEvent(string|UnitEnum $key, string|Closure|Stringable|UnitEnum|null $value): static { - return $this->setAttribute($key, $value, 'on'); + return $this->addAttribute(AttributeBag::normalizeKey($key, 'on'), $value); } /** @@ -58,18 +58,22 @@ public function addEvent(string|UnitEnum $key, string|Closure|Stringable|UnitEnu * ); * ``` * - * @param array $values Associative array of event keys and handlers. Values may be `Stringable`, `Closure`, - * `string`, or `null` to remove the attribute. + * @param mixed[] $values Associative array of event keys and handlers. Values may be Stringable, Closure, string, + * or `null` to remove the attribute. * * @throws InvalidArgumentException if one or more arguments are invalid, of incorrect type or format. * * @return static New instance with the updated `on*` event attributes. - * - * @phpstan-param mixed[] $values */ public function events(array $values): static { - return $this->attributes($values, 'on'); + $new = $this; + + foreach ($values as $key => $value) { + $new = $new->addAttribute(AttributeBag::normalizeKey($key, 'on'), $value); + } + + return $new; } /** @@ -89,6 +93,6 @@ public function events(array $values): static */ public function removeEvent(string|UnitEnum $key): static { - return $this->removeAttribute($key, 'on'); + return $this->addAttribute(AttributeBag::normalizeKey($key, 'on'), null); } } diff --git a/src/Global/HasId.php b/src/Global/HasId.php index 2fb9de1..c015634 100644 --- a/src/Global/HasId.php +++ b/src/Global/HasId.php @@ -34,6 +34,6 @@ trait HasId */ public function id(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(GlobalAttribute::ID, $value); + return $this->addAttribute(GlobalAttribute::ID, $value); } } diff --git a/src/Global/HasInputMode.php b/src/Global/HasInputMode.php index c41cc36..7939114 100644 --- a/src/Global/HasInputMode.php +++ b/src/Global/HasInputMode.php @@ -29,8 +29,8 @@ trait HasInputMode * $element->inputMode('numeric'); * ``` * - * @param string|UnitEnum|null $value Input mode value (`decimal`, `email`, `none`, `numeric`, `search`, `tel`, - * `text`, `url`, or `null` to remove the attribute). + * @param string|UnitEnum|null $value Input mode value ('decimal', 'email', 'none', 'numeric', 'search', 'tel', + * 'text', 'url', or `null` to remove the attribute). * * @throws InvalidArgumentException If the provided value is not valid. * @@ -40,6 +40,6 @@ public function inputMode(string|UnitEnum|null $value): static { Validator::oneOf($value, InputMode::cases(), GlobalAttribute::INPUTMODE); - return $this->setAttribute(GlobalAttribute::INPUTMODE, $value); + return $this->addAttribute(GlobalAttribute::INPUTMODE, $value); } } diff --git a/src/Global/HasLang.php b/src/Global/HasLang.php index cb24370..d9234a5 100644 --- a/src/Global/HasLang.php +++ b/src/Global/HasLang.php @@ -43,6 +43,6 @@ public function lang(string|Stringable|UnitEnum|null $value): static { Validator::oneOf($value, Language::cases(), GlobalAttribute::LANG); - return $this->setAttribute(GlobalAttribute::LANG, $value); + return $this->addAttribute(GlobalAttribute::LANG, $value); } } diff --git a/src/Global/HasMicroData.php b/src/Global/HasMicroData.php index 9a4ec21..2ea69ed 100644 --- a/src/Global/HasMicroData.php +++ b/src/Global/HasMicroData.php @@ -35,7 +35,7 @@ trait HasMicroData */ public function itemId(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(GlobalAttribute::ITEMID, $value); + return $this->addAttribute(GlobalAttribute::ITEMID, $value); } /** @@ -55,7 +55,7 @@ public function itemId(string|Stringable|UnitEnum|null $value): static */ public function itemProp(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(GlobalAttribute::ITEMPROP, $value); + return $this->addAttribute(GlobalAttribute::ITEMPROP, $value); } /** @@ -75,7 +75,7 @@ public function itemProp(string|Stringable|UnitEnum|null $value): static */ public function itemRef(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(GlobalAttribute::ITEMREF, $value); + return $this->addAttribute(GlobalAttribute::ITEMREF, $value); } /** @@ -95,7 +95,7 @@ public function itemRef(string|Stringable|UnitEnum|null $value): static */ public function itemScope(bool|null $value): static { - return $this->setAttribute(GlobalAttribute::ITEMSCOPE, $value); + return $this->addAttribute(GlobalAttribute::ITEMSCOPE, $value); } /** @@ -115,6 +115,6 @@ public function itemScope(bool|null $value): static */ public function itemType(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(GlobalAttribute::ITEMTYPE, $value); + return $this->addAttribute(GlobalAttribute::ITEMTYPE, $value); } } diff --git a/src/Global/HasNonce.php b/src/Global/HasNonce.php index ffa51bb..ae564be 100644 --- a/src/Global/HasNonce.php +++ b/src/Global/HasNonce.php @@ -34,6 +34,6 @@ trait HasNonce */ public function nonce(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(GlobalAttribute::NONCE, $value); + return $this->addAttribute(GlobalAttribute::NONCE, $value); } } diff --git a/src/Global/HasPopover.php b/src/Global/HasPopover.php index e662b8e..ae911c0 100644 --- a/src/Global/HasPopover.php +++ b/src/Global/HasPopover.php @@ -29,7 +29,7 @@ trait HasPopover * $element->popover(Popover::AUTO); * ``` * - * @param string|UnitEnum|null $value Popover state (`auto`, `hint`, `manual`), or `null` to remove the attribute. + * @param string|UnitEnum|null $value Popover state ('auto', 'hint', 'manual'), or `null` to remove the attribute. * * @throws InvalidArgumentException If the provided value is not valid. * @@ -41,6 +41,6 @@ public function popover(string|UnitEnum|null $value): static { Validator::oneOf($value, Popover::cases(), GlobalAttribute::POPOVER); - return $this->setAttribute(GlobalAttribute::POPOVER, $value); + return $this->addAttribute(GlobalAttribute::POPOVER, $value); } } diff --git a/src/Global/HasRole.php b/src/Global/HasRole.php index ac6166b..432cce3 100644 --- a/src/Global/HasRole.php +++ b/src/Global/HasRole.php @@ -43,6 +43,6 @@ public function role(string|Stringable|UnitEnum|null $value): static { Validator::oneOf($value, Role::cases(), GlobalAttribute::ROLE); - return $this->setAttribute(GlobalAttribute::ROLE, $value); + return $this->addAttribute(GlobalAttribute::ROLE, $value); } } diff --git a/src/Global/HasSpellcheck.php b/src/Global/HasSpellcheck.php index 5b2e9c8..6c2f1d2 100644 --- a/src/Global/HasSpellcheck.php +++ b/src/Global/HasSpellcheck.php @@ -44,6 +44,6 @@ public function spellcheck(bool|string|null $value): static Validator::oneOf($value, ['false', 'true'], GlobalAttribute::SPELLCHECK); - return $this->setAttribute(GlobalAttribute::SPELLCHECK, $value); + return $this->addAttribute(GlobalAttribute::SPELLCHECK, $value); } } diff --git a/src/Global/HasStyle.php b/src/Global/HasStyle.php index 69a774a..7769e07 100644 --- a/src/Global/HasStyle.php +++ b/src/Global/HasStyle.php @@ -43,15 +43,13 @@ trait HasStyle * $element->style(null); * ``` * - * @param array|string|Stringable|UnitEnum|null $value Style value as a CSS `string`, an associative array of CSS + * @param mixed[]|string|Stringable|UnitEnum|null $value Style value as a CSS string, an associative array of CSS * property-value pairs, or `null` to remove the attribute. * * @return static New instance with the updated `style` attribute. - * - * @phpstan-param mixed[]|string|Stringable|UnitEnum|null $value */ public function style(array|string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(GlobalAttribute::STYLE, $value); + return $this->addAttribute(GlobalAttribute::STYLE, $value); } } diff --git a/src/Global/HasTabindex.php b/src/Global/HasTabindex.php index 2bfddea..6db8205 100644 --- a/src/Global/HasTabindex.php +++ b/src/Global/HasTabindex.php @@ -30,11 +30,10 @@ trait HasTabindex * $element->tabIndex(1); * ``` * - * @param int|string|null $value Tab order value as an `integer` or `string` of `-1` or greater, or `null` to remove + * @param int|string|null $value Tab order value as an integer or string of '-1' or greater, or `null` to remove * the attribute. * - * @throws InvalidArgumentException if the value is not a valid `integer` or `string` representation of `-1` or - * greater. + * @throws InvalidArgumentException if the value is not a valid integer or string representation of '-1' or greater. * @return static New instance with the updated `tabindex` attribute. */ public function tabIndex(int|string|null $value): static @@ -45,6 +44,6 @@ public function tabIndex(int|string|null $value): static ); } - return $this->setAttribute(GlobalAttribute::TABINDEX, $value); + return $this->addAttribute(GlobalAttribute::TABINDEX, $value); } } diff --git a/src/Global/HasTitle.php b/src/Global/HasTitle.php index 1e91cde..1aaa748 100644 --- a/src/Global/HasTitle.php +++ b/src/Global/HasTitle.php @@ -34,6 +34,6 @@ trait HasTitle */ public function title(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(GlobalAttribute::TITLE, $value); + return $this->addAttribute(GlobalAttribute::TITLE, $value); } } diff --git a/src/Global/HasTranslate.php b/src/Global/HasTranslate.php index ae0216b..a6e2d94 100644 --- a/src/Global/HasTranslate.php +++ b/src/Global/HasTranslate.php @@ -31,7 +31,7 @@ trait HasTranslate * $element->translate(Translate::NO); * ``` * - * @param bool|string|UnitEnum|null $value Translation behavior. Use `yes`, `no`, `true`, `false`, or `null` to + * @param bool|string|UnitEnum|null $value Translation behavior. Use 'yes', 'no', `true`, `false`, or `null` to * remove the attribute. * * @throws InvalidArgumentException If the value is not valid. @@ -54,6 +54,6 @@ public function translate(bool|string|UnitEnum|null $value): static Validator::oneOf($value, Translate::cases(), GlobalAttribute::TRANSLATE); - return $this->setAttribute(GlobalAttribute::TRANSLATE, $value); + return $this->addAttribute(GlobalAttribute::TRANSLATE, $value); } } diff --git a/src/HasAs.php b/src/HasAs.php index d6c7bf2..dc7ad98 100644 --- a/src/HasAs.php +++ b/src/HasAs.php @@ -6,7 +6,7 @@ use InvalidArgumentException; use Stringable; -use UIAwesome\Html\Attribute\Values\{AsValue, Attribute}; +use UIAwesome\Html\Attribute\Values\{AsValue, ElementAttribute}; use UIAwesome\Html\Helper\Validator; use UnitEnum; @@ -43,8 +43,8 @@ trait HasAs */ public function as(string|Stringable|UnitEnum|null $value): static { - Validator::oneOf($value, AsValue::cases(), Attribute::AS); + Validator::oneOf($value, AsValue::cases(), ElementAttribute::AS); - return $this->setAttribute(Attribute::AS, $value); + return $this->addAttribute(ElementAttribute::AS, $value); } } diff --git a/src/HasBlocking.php b/src/HasBlocking.php index cede7ba..e30a92b 100644 --- a/src/HasBlocking.php +++ b/src/HasBlocking.php @@ -5,7 +5,7 @@ namespace UIAwesome\Html\Attribute; use InvalidArgumentException; -use UIAwesome\Html\Attribute\Values\{Attribute, Blocking}; +use UIAwesome\Html\Attribute\Values\{Blocking, ElementAttribute}; use UIAwesome\Html\Helper\Validator; use UnitEnum; @@ -42,8 +42,8 @@ trait HasBlocking */ public function blocking(string|UnitEnum|null $value): static { - Validator::oneOf($value, Blocking::cases(), Attribute::BLOCKING); + Validator::oneOf($value, Blocking::cases(), ElementAttribute::BLOCKING); - return $this->setAttribute(Attribute::BLOCKING, $value); + return $this->addAttribute(ElementAttribute::BLOCKING, $value); } } diff --git a/src/HasCharset.php b/src/HasCharset.php index 458fba8..8e0c258 100644 --- a/src/HasCharset.php +++ b/src/HasCharset.php @@ -6,7 +6,7 @@ use InvalidArgumentException; use Stringable; -use UIAwesome\Html\Attribute\Values\{Attribute, Charset}; +use UIAwesome\Html\Attribute\Values\{Charset, ElementAttribute}; use UIAwesome\Html\Helper\Validator; use UnitEnum; @@ -43,8 +43,8 @@ trait HasCharset */ public function charset(string|Stringable|UnitEnum|null $value): static { - Validator::oneOf($value, Charset::cases(), Attribute::CHARSET); + Validator::oneOf($value, Charset::cases(), ElementAttribute::CHARSET); - return $this->setAttribute(Attribute::CHARSET, $value); + return $this->addAttribute(ElementAttribute::CHARSET, $value); } } diff --git a/src/HasContent.php b/src/HasContent.php index 1eb5fed..094d2f7 100644 --- a/src/HasContent.php +++ b/src/HasContent.php @@ -37,6 +37,6 @@ trait HasContent */ public function content(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::CONTENT, $value); + return $this->addAttribute(Attribute::CONTENT, $value); } } diff --git a/src/HasCrossorigin.php b/src/HasCrossorigin.php index 44890d1..970ad98 100644 --- a/src/HasCrossorigin.php +++ b/src/HasCrossorigin.php @@ -44,6 +44,6 @@ public function crossorigin(string|UnitEnum|null $value): static { Validator::oneOf($value, Crossorigin::cases(), Attribute::CROSSORIGIN); - return $this->setAttribute(Attribute::CROSSORIGIN, $value); + return $this->addAttribute(Attribute::CROSSORIGIN, $value); } } diff --git a/src/HasDownload.php b/src/HasDownload.php index 6185d83..a88728b 100644 --- a/src/HasDownload.php +++ b/src/HasDownload.php @@ -5,7 +5,7 @@ namespace UIAwesome\Html\Attribute; use Stringable; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\ElementAttribute; use UnitEnum; /** @@ -40,6 +40,6 @@ trait HasDownload */ public function download(bool|string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::DOWNLOAD, $value); + return $this->addAttribute(ElementAttribute::DOWNLOAD, $value); } } diff --git a/src/HasFetchpriority.php b/src/HasFetchpriority.php index 92a6d28..befcd61 100644 --- a/src/HasFetchpriority.php +++ b/src/HasFetchpriority.php @@ -44,6 +44,6 @@ public function fetchpriority(string|UnitEnum|null $value): static { Validator::oneOf($value, Fetchpriority::cases(), Attribute::FETCHPRIORITY); - return $this->setAttribute(Attribute::FETCHPRIORITY, $value); + return $this->addAttribute(Attribute::FETCHPRIORITY, $value); } } diff --git a/src/HasFor.php b/src/HasFor.php index b9293bc..22df4e3 100644 --- a/src/HasFor.php +++ b/src/HasFor.php @@ -36,6 +36,6 @@ trait HasFor */ public function for(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::FOR, $value); + return $this->addAttribute(Attribute::FOR, $value); } } diff --git a/src/HasHreflang.php b/src/HasHreflang.php index 669094f..2954cef 100644 --- a/src/HasHreflang.php +++ b/src/HasHreflang.php @@ -5,7 +5,7 @@ namespace UIAwesome\Html\Attribute; use Stringable; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\ElementAttribute; use UnitEnum; /** @@ -37,6 +37,6 @@ trait HasHreflang */ public function hreflang(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::HREFLANG, $value); + return $this->addAttribute(ElementAttribute::HREFLANG, $value); } } diff --git a/src/HasHttpEquiv.php b/src/HasHttpEquiv.php index 91550f4..f4eb2c3 100644 --- a/src/HasHttpEquiv.php +++ b/src/HasHttpEquiv.php @@ -6,7 +6,7 @@ use InvalidArgumentException; use Stringable; -use UIAwesome\Html\Attribute\Values\{Attribute, HttpEquiv}; +use UIAwesome\Html\Attribute\Values\{ElementAttribute, HttpEquiv}; use UIAwesome\Html\Helper\Validator; use UnitEnum; @@ -43,8 +43,8 @@ trait HasHttpEquiv */ public function httpEquiv(string|Stringable|UnitEnum|null $value): static { - Validator::oneOf($value, HttpEquiv::cases(), Attribute::HTTP_EQUIV); + Validator::oneOf($value, HttpEquiv::cases(), ElementAttribute::HTTP_EQUIV); - return $this->setAttribute(Attribute::HTTP_EQUIV, $value); + return $this->addAttribute(ElementAttribute::HTTP_EQUIV, $value); } } diff --git a/src/HasImagesizes.php b/src/HasImageSizes.php similarity index 87% rename from src/HasImagesizes.php rename to src/HasImageSizes.php index 4453d22..461ae3c 100644 --- a/src/HasImagesizes.php +++ b/src/HasImageSizes.php @@ -5,7 +5,7 @@ namespace UIAwesome\Html\Attribute; use Stringable; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\ElementAttribute; use UnitEnum; /** @@ -17,7 +17,7 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -trait HasImagesizes +trait HasImageSizes { /** * Sets the `imagesizes` attribute. @@ -37,6 +37,6 @@ trait HasImagesizes */ public function imagesizes(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::IMAGESIZES, $value); + return $this->addAttribute(ElementAttribute::IMAGESIZES, $value); } } diff --git a/src/HasImagesrcset.php b/src/HasImageSrcSet.php similarity index 87% rename from src/HasImagesrcset.php rename to src/HasImageSrcSet.php index 063ba85..213e7a2 100644 --- a/src/HasImagesrcset.php +++ b/src/HasImageSrcSet.php @@ -5,7 +5,7 @@ namespace UIAwesome\Html\Attribute; use Stringable; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\ElementAttribute; use UnitEnum; /** @@ -17,7 +17,7 @@ * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -trait HasImagesrcset +trait HasImageSrcSet { /** * Sets the `imagesrcset` attribute. @@ -37,6 +37,6 @@ trait HasImagesrcset */ public function imagesrcset(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::IMAGESRCSET, $value); + return $this->addAttribute(ElementAttribute::IMAGESRCSET, $value); } } diff --git a/src/HasIntegrity.php b/src/HasIntegrity.php index d20176d..be52e16 100644 --- a/src/HasIntegrity.php +++ b/src/HasIntegrity.php @@ -37,6 +37,6 @@ trait HasIntegrity */ public function integrity(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::INTEGRITY, $value); + return $this->addAttribute(Attribute::INTEGRITY, $value); } } diff --git a/src/HasLabel.php b/src/HasLabel.php index 4cac77e..8ae242f 100644 --- a/src/HasLabel.php +++ b/src/HasLabel.php @@ -5,7 +5,7 @@ namespace UIAwesome\Html\Attribute; use Stringable; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\ElementAttribute; use UnitEnum; /** @@ -34,6 +34,6 @@ trait HasLabel */ public function label(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::LABEL, $value); + return $this->addAttribute(ElementAttribute::LABEL, $value); } } diff --git a/src/HasMedia.php b/src/HasMedia.php index 0565243..94f8fcc 100644 --- a/src/HasMedia.php +++ b/src/HasMedia.php @@ -37,6 +37,6 @@ trait HasMedia */ public function media(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::MEDIA, $value); + return $this->addAttribute(Attribute::MEDIA, $value); } } diff --git a/src/HasName.php b/src/HasName.php index 2a25cb7..ed2ade9 100644 --- a/src/HasName.php +++ b/src/HasName.php @@ -5,7 +5,7 @@ namespace UIAwesome\Html\Attribute; use Stringable; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\ElementAttribute; use UnitEnum; /** @@ -39,6 +39,6 @@ trait HasName */ public function name(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::NAME, $value); + return $this->addAttribute(ElementAttribute::NAME, $value); } } diff --git a/src/HasPing.php b/src/HasPing.php index eaeacd8..ed578fc 100644 --- a/src/HasPing.php +++ b/src/HasPing.php @@ -5,7 +5,7 @@ namespace UIAwesome\Html\Attribute; use Stringable; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\ElementAttribute; use UnitEnum; /** @@ -37,6 +37,6 @@ trait HasPing */ public function ping(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::PING, $value); + return $this->addAttribute(ElementAttribute::PING, $value); } } diff --git a/src/HasReferrerpolicy.php b/src/HasReferrerpolicy.php index 8a4040d..ccf275d 100644 --- a/src/HasReferrerpolicy.php +++ b/src/HasReferrerpolicy.php @@ -45,6 +45,6 @@ public function referrerpolicy(string|Stringable|UnitEnum|null $value): static { Validator::oneOf($value, Referrerpolicy::cases(), Attribute::REFERRERPOLICY); - return $this->setAttribute(Attribute::REFERRERPOLICY, $value); + return $this->addAttribute(Attribute::REFERRERPOLICY, $value); } } diff --git a/src/HasRel.php b/src/HasRel.php index 97924da..e29b4d3 100644 --- a/src/HasRel.php +++ b/src/HasRel.php @@ -45,6 +45,6 @@ public function rel(string|Stringable|UnitEnum|null $value): static { Validator::oneOf($value, Rel::cases(), Attribute::REL); - return $this->setAttribute(Attribute::REL, $value); + return $this->addAttribute(Attribute::REL, $value); } } diff --git a/src/HasSizes.php b/src/HasSizes.php index 8ca6b34..6908e95 100644 --- a/src/HasSizes.php +++ b/src/HasSizes.php @@ -5,7 +5,7 @@ namespace UIAwesome\Html\Attribute; use Stringable; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\ElementAttribute; use UnitEnum; /** @@ -31,12 +31,12 @@ trait HasSizes * $element->sizes(null); * ``` * - * @param string|Stringable|UnitEnum|null $value Icon size list or `any` token, or `null` to remove the attribute. + * @param string|Stringable|UnitEnum|null $value Icon size list or 'any' token, or `null` to remove the attribute. * * @return static New instance with the updated `sizes` attribute. */ public function sizes(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::SIZES, $value); + return $this->addAttribute(ElementAttribute::SIZES, $value); } } diff --git a/src/HasSrc.php b/src/HasSrc.php index f8f110a..7b6862f 100644 --- a/src/HasSrc.php +++ b/src/HasSrc.php @@ -37,6 +37,6 @@ trait HasSrc */ public function src(string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::SRC, $value); + return $this->addAttribute(Attribute::SRC, $value); } } diff --git a/src/HasTarget.php b/src/HasTarget.php index 5748a81..a2519ab 100644 --- a/src/HasTarget.php +++ b/src/HasTarget.php @@ -44,6 +44,6 @@ public function target(string|UnitEnum|null $value): static { Validator::oneOf($value, Target::cases(), Attribute::TARGET); - return $this->setAttribute(Attribute::TARGET, $value); + return $this->addAttribute(Attribute::TARGET, $value); } } diff --git a/src/HasType.php b/src/HasType.php index b99ae31..110ca03 100644 --- a/src/HasType.php +++ b/src/HasType.php @@ -45,6 +45,6 @@ public function type(string|Stringable|UnitEnum|null $value): static { Validator::oneOf($value, Type::cases(), Attribute::TYPE); - return $this->setAttribute(Attribute::TYPE, $value); + return $this->addAttribute(Attribute::TYPE, $value); } } diff --git a/src/HasValue.php b/src/HasValue.php index ae2b0ea..b135342 100644 --- a/src/HasValue.php +++ b/src/HasValue.php @@ -5,7 +5,7 @@ namespace UIAwesome\Html\Attribute; use Stringable; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\ElementAttribute; use UnitEnum; /** @@ -34,13 +34,13 @@ trait HasValue * $element->value(null); * ``` * - * @param bool|float|int|string|Stringable|UnitEnum|null $value Element value as `bool`, `int`, `float`, `string`, - * `Stringable`, `UnitEnum`, or `null` to remove the attribute. + * @param bool|float|int|string|Stringable|UnitEnum|null $value Element value as bool, int, float, string, + * Stringable, UnitEnum, or `null` to remove the attribute. * * @return static New instance with the updated `value` attribute. */ public function value(bool|float|int|string|Stringable|UnitEnum|null $value): static { - return $this->setAttribute(Attribute::VALUE, $value); + return $this->addAttribute(ElementAttribute::VALUE, $value); } } diff --git a/src/Values/Attribute.php b/src/Values/Attribute.php index 9e8940a..317da81 100644 --- a/src/Values/Attribute.php +++ b/src/Values/Attribute.php @@ -21,13 +21,6 @@ enum Attribute: string */ case ACCEPT = 'accept'; - /** - * `as` — Specifies the type of content being loaded by the link element. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#as - */ - case AS = 'as'; - /** * `autocomplete` — Indicates whether controls can have their values automatically completed. * @@ -35,13 +28,6 @@ enum Attribute: string */ case AUTOCOMPLETE = 'autocomplete'; - /** - * `blocking` — Indicates that certain operations should be blocked on the fetching of an external resource. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/style#blocking - */ - case BLOCKING = 'blocking'; - /** * `capture` — Media capture hint for file inputs. * @@ -49,13 +35,6 @@ enum Attribute: string */ case CAPTURE = 'capture'; - /** - * `charset` — Declares the document's character encoding. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta#charset - */ - case CHARSET = 'charset'; - /** * `checked` — Indicates whether the command or control is checked. * @@ -91,13 +70,6 @@ enum Attribute: string */ case DISABLED = 'disabled'; - /** - * `download` — Indicates that the hyperlink is to be used for downloading a resource. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#download - */ - case DOWNLOAD = 'download'; - /** * `elementtiming` — Marks the element for observation by the `PerformanceElementTiming` API. * @@ -126,34 +98,6 @@ enum Attribute: string */ case FORM = 'form'; - /** - * `hreflang` — Indicates the language of the linked resource. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#hreflang - */ - case HREFLANG = 'hreflang'; - - /** - * `http-equiv` — Defines a pragma directive for processing the document. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta/http-equiv - */ - case HTTP_EQUIV = 'http-equiv'; - - /** - * `imagesizes` — Specifies the image sizes for preload. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#imagesizes - */ - case IMAGESIZES = 'imagesizes'; - - /** - * `imagesrcset` — Specifies the image srcset for preload. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#imagesrcset - */ - case IMAGESRCSET = 'imagesrcset'; - /** * `integrity` — Contains inline metadata that a user agent can use to verify that a fetched resource has been * delivered without unexpected manipulation (Subresource Integrity). @@ -162,20 +106,6 @@ enum Attribute: string */ case INTEGRITY = 'integrity'; - /** - * `label` — Text used as a label for an option or option group. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/option#label - */ - case LABEL = 'label'; - - /** - * `list` — Identifies a `` element that provides predefined options to suggest to the user. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#list - */ - case LIST = 'list'; - /** * `max` — Indicates the maximum value allowed. * @@ -218,13 +148,6 @@ enum Attribute: string */ case MULTIPLE = 'multiple'; - /** - * `name` — Specifies the metadata name for the meta element. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta/name - */ - case NAME = 'name'; - /** * `pattern` — Defines a regular expression which the element's value will be validated against. * @@ -232,13 +155,6 @@ enum Attribute: string */ case PATTERN = 'pattern'; - /** - * `ping` — A space-separated list of URLs to which the browser will send POST requests when the link is followed. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#ping - */ - case PING = 'ping'; - /** * `placeholder` — Provides a hint to the user of what can be entered in the field. * @@ -274,13 +190,6 @@ enum Attribute: string */ case REQUIRED = 'required'; - /** - * `selected` — Indicates whether an option is initially selected. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/option#selected - */ - case SELECTED = 'selected'; - /** * `size` — Defines the width of the element (in pixels). * @@ -288,13 +197,6 @@ enum Attribute: string */ case SIZE = 'size'; - /** - * `sizes` — Defines the sizes of icons for visual media. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#sizes - */ - case SIZES = 'sizes'; - /** * `src` — Specifies the URL of the resource. * @@ -322,11 +224,4 @@ enum Attribute: string * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/type */ case TYPE = 'type'; - - /** - * `value` — Indicates the current ordinal value of the list item. - * - * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/li#value - */ - case VALUE = 'value'; } diff --git a/src/Values/ElementAttribute.php b/src/Values/ElementAttribute.php index 037d5b5..de1d786 100644 --- a/src/Values/ElementAttribute.php +++ b/src/Values/ElementAttribute.php @@ -21,6 +21,55 @@ enum ElementAttribute: string */ case ALT = 'alt'; + /** + * `as` — Specifies the type of content being loaded by the link element. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#as + */ + case AS = 'as'; + + /** + * `autoplay` — Indicates that media should begin playback automatically when it can. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/audio#autoplay + */ + case AUTOPLAY = 'autoplay'; + + /** + * `blocking` — Indicates that certain operations should be blocked on the fetching of an external resource. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/style#blocking + */ + case BLOCKING = 'blocking'; + + /** + * `charset` — Declares the document's character encoding. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta#charset + */ + case CHARSET = 'charset'; + + /** + * `closedby` — Specifies which user actions can close a `` element. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/dialog#closedby + */ + case CLOSEDBY = 'closedby'; + + /** + * `controls` — Indicates that browser playback controls should be displayed for media. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/audio#controls + */ + case CONTROLS = 'controls'; + + /** + * `controlslist` — Hints which built-in controls should be shown for media elements. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/audio#controlslist + */ + case CONTROLSLIST = 'controlslist'; + /** * `decoding` — Provides a hint to the browser for image decoding behavior. * @@ -28,6 +77,27 @@ enum ElementAttribute: string */ case DECODING = 'decoding'; + /** + * `default` — Indicates the default track to enable for media playback. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/track#default + */ + case DEFAULT = 'default'; + + /** + * `disableremoteplayback` — Disables remote playback controls and capability for media. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/audio#disableremoteplayback + */ + case DISABLEREMOTEPLAYBACK = 'disableremoteplayback'; + + /** + * `download` — Indicates that the hyperlink is to be used for downloading a resource. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#download + */ + case DOWNLOAD = 'download'; + /** * `height` — Specifies the height of certain elements. * @@ -44,6 +114,55 @@ enum ElementAttribute: string */ case HREF = 'href'; + /** + * `hreflang` — Indicates the language of the linked resource. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#hreflang + */ + case HREFLANG = 'hreflang'; + + /** + * `http-equiv` — Defines a pragma directive for processing the document. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta/http-equiv + */ + case HTTP_EQUIV = 'http-equiv'; + + /** + * `imagesizes` — Specifies the image sizes for preload. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#imagesizes + */ + case IMAGESIZES = 'imagesizes'; + + /** + * `imagesrcset` — Specifies the image srcset for preload. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#imagesrcset + */ + case IMAGESRCSET = 'imagesrcset'; + + /** + * `kind` — Indicates how a text track should be used. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/track#kind + */ + case KIND = 'kind'; + + /** + * `label` — Text used as a label for an option or option group. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/option#label + */ + case LABEL = 'label'; + + /** + * `list` — Identifies a `` element that provides predefined options to suggest to the user. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input#list + */ + case LIST = 'list'; + /** * `loading` — Indicates how the browser should load the image. * @@ -52,6 +171,41 @@ enum ElementAttribute: string */ case LOADING = 'loading'; + /** + * `loop` — Indicates that media should restart automatically after reaching the end. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/audio#loop + */ + case LOOP = 'loop'; + + /** + * `muted` — Indicates that media output is initially silenced. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/audio#muted + */ + case MUTED = 'muted'; + + /** + * `name` — Specifies the metadata name for the meta element. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/meta/name + */ + case NAME = 'name'; + + /** + * `open` — Indicates whether the contents of the details element are visible. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/details#open + */ + case OPEN = 'open'; + + /** + * `ping` — A space-separated list of URLs to which the browser will send POST requests when the link is followed. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/a#ping + */ + case PING = 'ping'; + /** * `popovertarget` — Identifies the popover element that is associated with the current element. * @@ -66,6 +220,13 @@ enum ElementAttribute: string */ case POPOVERTARGETACTION = 'popovertargetaction'; + /** + * `preload` — Provides a hint about preloading behavior for media resources. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/audio#preload + */ + case PRELOAD = 'preload'; + /** * `referrerpolicy` — Referrer information to send when fetching the resource. * @@ -73,6 +234,20 @@ enum ElementAttribute: string */ case REFERRERPOLICY = 'referrerpolicy'; + /** + * `selected` — Indicates whether an option is initially selected. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/option#selected + */ + case SELECTED = 'selected'; + + /** + * `sizes` — Defines the sizes of icons for visual media. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/link#sizes + */ + case SIZES = 'sizes'; + /** * `src` — URL of embeddable content. * @@ -80,6 +255,12 @@ enum ElementAttribute: string */ case SRC = 'src'; + /** + * `srclang` — Language of text track data. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/track#srclang + */ + case SRCLANG = 'srclang'; /** * `srcset` — Defines a set of images for the browser to choose from. @@ -97,6 +278,13 @@ enum ElementAttribute: string */ case USEMAP = 'usemap'; + /** + * `value` — Indicates the current ordinal value of the list item. + * + * @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/li#value + */ + case VALUE = 'value'; + /** * `width` — Specifies the width of certain elements. * diff --git a/tests/CanBeDisabledTest.php b/tests/CanBeDisabledTest.php index 8393309..9c06843 100644 --- a/tests/CanBeDisabledTest.php +++ b/tests/CanBeDisabledTest.php @@ -75,7 +75,7 @@ public function testSetDisabledAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::DISABLED, ''), + $instance->getAttribute(Attribute::DISABLED), $message, ); self::assertSame( diff --git a/tests/CanBeSelectedTest.php b/tests/CanBeSelectedTest.php index bda3355..97a740d 100644 --- a/tests/CanBeSelectedTest.php +++ b/tests/CanBeSelectedTest.php @@ -8,7 +8,7 @@ use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\CanBeSelected; use UIAwesome\Html\Attribute\Tests\Provider\SelectedProvider; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\ElementAttribute; use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Mixin\HasAttributes; @@ -75,7 +75,7 @@ public function testSetSelectedAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::SELECTED, ''), + $instance->getAttribute(ElementAttribute::SELECTED), $message, ); self::assertSame( diff --git a/tests/Element/HasAltTest.php b/tests/Element/HasAltTest.php deleted file mode 100644 index 474c136..0000000 --- a/tests/Element/HasAltTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingAltAttribute(): void - { - $instance = new class { - use HasAlt; - use HasAttributes; - }; - - self::assertNotSame( - $instance, - $instance->alt(''), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(AltProvider::class, 'values')] - public function testSetAltAttributeValue( - string|Stringable|UnitEnum|null $alt, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttribute, - string $message, - ): void { - $instance = new class { - use HasAlt; - use HasAttributes; - }; - - $instance = $instance->attributes($attributes)->alt($alt); - - self::assertSame( - $expectedValue, - $instance->getAttribute(ElementAttribute::ALT, ''), - $message, - ); - self::assertSame( - $expectedRenderAttribute, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Element/HasDecodingTest.php b/tests/Element/HasDecodingTest.php deleted file mode 100644 index 48a37f3..0000000 --- a/tests/Element/HasDecodingTest.php +++ /dev/null @@ -1,111 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingDecodingAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasDecoding; - }; - - self::assertNotSame( - $instance, - $instance->decoding(''), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(DecodingProvider::class, 'values')] - public function testSetDecodingAttributeValue( - string|Stringable|UnitEnum|null $decoding, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasDecoding; - }; - - $instance = $instance->attributes($attributes)->decoding($decoding); - - self::assertSame( - $expectedValue, - $instance->getAttribute(ElementAttribute::DECODING, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } - - public function testThrowInvalidArgumentExceptionWhenSettingDecoding(): void - { - $instance = new class { - use HasAttributes; - use HasDecoding; - }; - - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage( - Message::VALUE_NOT_IN_LIST->getMessage( - 'invalid-value', - ElementAttribute::DECODING->value, - implode("', '", Enum::normalizeArray(Decoding::cases())), - ), - ); - - $instance->decoding('invalid-value'); - } -} diff --git a/tests/Element/HasHeightTest.php b/tests/Element/HasHeightTest.php deleted file mode 100644 index 20e45a7..0000000 --- a/tests/Element/HasHeightTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingHeightAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasHeight; - }; - - self::assertNotSame( - $instance, - $instance->height(''), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(HeightProvider::class, 'values')] - public function testSetHeightAttributeValue( - string|Stringable|UnitEnum|null $height, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttribute, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasHeight; - }; - - $instance = $instance->attributes($attributes)->height($height); - - self::assertSame( - $expectedValue, - $instance->getAttribute(ElementAttribute::HEIGHT, ''), - $message, - ); - self::assertSame( - $expectedRenderAttribute, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Element/HasHrefTest.php b/tests/Element/HasHrefTest.php deleted file mode 100644 index be86c13..0000000 --- a/tests/Element/HasHrefTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingHrefAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasHref; - }; - - self::assertNotSame( - $instance, - $instance->href('https://example.com'), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(HrefProvider::class, 'values')] - public function testSetHrefAttributeValue( - string|Stringable|UnitEnum|null $href, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttribute, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasHref; - }; - - $instance = $instance->attributes($attributes)->href($href); - - self::assertSame( - $expectedValue, - $instance->getAttribute(ElementAttribute::HREF, ''), - $message, - ); - self::assertSame( - $expectedRenderAttribute, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Element/HasLoadingTest.php b/tests/Element/HasLoadingTest.php deleted file mode 100644 index 6c11a24..0000000 --- a/tests/Element/HasLoadingTest.php +++ /dev/null @@ -1,111 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingLoadingAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasLoading; - }; - - self::assertNotSame( - $instance, - $instance->loading(''), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(LoadingProvider::class, 'values')] - public function testSetLoadingAttributeValue( - string|Stringable|UnitEnum|null $loading, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttribute, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasLoading; - }; - - $instance = $instance->attributes($attributes)->loading($loading); - - self::assertSame( - $expectedValue, - $instance->getAttribute(ElementAttribute::LOADING, ''), - $message, - ); - self::assertSame( - $expectedRenderAttribute, - Attributes::render($instance->getAttributes()), - $message, - ); - } - - public function testThrowInvalidArgumentExceptionWhenSettingLoading(): void - { - $instance = new class { - use HasAttributes; - use HasLoading; - }; - - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage( - Message::VALUE_NOT_IN_LIST->getMessage( - 'invalid-value', - ElementAttribute::LOADING->value, - implode("', '", Enum::normalizeArray(Loading::cases())), - ), - ); - - $instance->loading('invalid-value'); - } -} diff --git a/tests/Element/HasPopoverTargetActionTest.php b/tests/Element/HasPopoverTargetActionTest.php deleted file mode 100644 index 1a8db91..0000000 --- a/tests/Element/HasPopoverTargetActionTest.php +++ /dev/null @@ -1,111 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingPopoverTargetActionAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasPopoverTargetAction; - }; - - self::assertNotSame( - $instance, - $instance->popoverTargetAction(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(PopoverTargetActionProvider::class, 'values')] - public function testSetPopoverTargetActionAttributeValue( - string|Stringable|UnitEnum|null $popoverTargetAction, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasPopoverTargetAction; - }; - - $instance = $instance->attributes($attributes)->popoverTargetAction($popoverTargetAction); - - self::assertSame( - $expectedValue, - $instance->getAttribute(ElementAttribute::POPOVERTARGETACTION, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } - - public function testThrowInvalidArgumentExceptionWhenSettingPopoverTargetAction(): void - { - $instance = new class { - use HasAttributes; - use HasPopoverTargetAction; - }; - - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage( - Message::VALUE_NOT_IN_LIST->getMessage( - 'invalid-value', - ElementAttribute::POPOVERTARGETACTION->value, - implode("', '", Enum::normalizeArray(PopoverTargetAction::cases())), - ), - ); - - $instance->popoverTargetAction('invalid-value'); - } -} diff --git a/tests/Element/HasPopoverTargetTest.php b/tests/Element/HasPopoverTargetTest.php deleted file mode 100644 index b1cb723..0000000 --- a/tests/Element/HasPopoverTargetTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingPopoverTargetAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasPopoverTarget; - }; - - self::assertNotSame( - $instance, - $instance->popoverTarget(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(PopoverTargetProvider::class, 'values')] - public function testSetPopoverTargetAttributeValue( - string|Stringable|UnitEnum|null $popoverTarget, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasPopoverTarget; - }; - - $instance = $instance->attributes($attributes)->popoverTarget($popoverTarget); - - self::assertSame( - $expectedValue, - $instance->getAttribute(ElementAttribute::POPOVERTARGET, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Element/HasReferrerpolicyTest.php b/tests/Element/HasReferrerpolicyTest.php deleted file mode 100644 index 283952d..0000000 --- a/tests/Element/HasReferrerpolicyTest.php +++ /dev/null @@ -1,111 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingReferrerpolicyAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasReferrerpolicy; - }; - - self::assertNotSame( - $instance, - $instance->referrerpolicy(''), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(ReferrerpolicyProvider::class, 'values')] - public function testSetReferrerpolicyAttributeValue( - string|Stringable|UnitEnum|null $referrerpolicy, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttribute, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasReferrerpolicy; - }; - - $instance = $instance->attributes($attributes)->referrerpolicy($referrerpolicy); - - self::assertSame( - $expectedValue, - $instance->getAttribute(ElementAttribute::REFERRERPOLICY, ''), - $message, - ); - self::assertSame( - $expectedRenderAttribute, - Attributes::render($instance->getAttributes()), - $message, - ); - } - - public function testThrowInvalidArgumentExceptionWhenSettingReferrerpolicy(): void - { - $instance = new class { - use HasAttributes; - use HasReferrerpolicy; - }; - - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage( - Message::VALUE_NOT_IN_LIST->getMessage( - 'invalid-value', - ElementAttribute::REFERRERPOLICY->value, - implode("', '", Enum::normalizeArray(Referrerpolicy::cases())), - ), - ); - - $instance->referrerpolicy('invalid-value'); - } -} diff --git a/tests/Element/HasSrcTest.php b/tests/Element/HasSrcTest.php deleted file mode 100644 index 63e72a4..0000000 --- a/tests/Element/HasSrcTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingSrcAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasSrc; - }; - - self::assertNotSame( - $instance, - $instance->src(''), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(SrcProvider::class, 'values')] - public function testSetSrcAttributeValue( - string|Stringable|UnitEnum|null $src, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttribute, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasSrc; - }; - - $instance = $instance->attributes($attributes)->src($src); - - self::assertSame( - $expectedValue, - $instance->getAttribute(ElementAttribute::SRC, ''), - $message, - ); - self::assertSame( - $expectedRenderAttribute, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Element/HasSrcsetTest.php b/tests/Element/HasSrcsetTest.php deleted file mode 100644 index c29d301..0000000 --- a/tests/Element/HasSrcsetTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingSrcsetAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasSrcset; - }; - - self::assertNotSame( - $instance, - $instance->srcset(''), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(SrcsetProvider::class, 'values')] - public function testSetSrcsetAttributeValue( - string|Stringable|UnitEnum|null $srcset, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttribute, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasSrcset; - }; - - $instance = $instance->attributes($attributes)->srcset($srcset); - - self::assertSame( - $expectedValue, - $instance->getAttribute(ElementAttribute::SRCSET, ''), - $message, - ); - self::assertSame( - $expectedRenderAttribute, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Element/HasUsemapTest.php b/tests/Element/HasUsemapTest.php deleted file mode 100644 index a65c8c8..0000000 --- a/tests/Element/HasUsemapTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingUsemapAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasUsemap; - }; - - self::assertNotSame( - $instance, - $instance->usemap(''), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(UsemapProvider::class, 'values')] - public function testSetUsemapAttributeValue( - string|Stringable|UnitEnum|null $usemap, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttribute, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasUsemap; - }; - - $instance = $instance->attributes($attributes)->usemap($usemap); - - self::assertSame( - $expectedValue, - $instance->getAttribute(ElementAttribute::USEMAP, ''), - $message, - ); - self::assertSame( - $expectedRenderAttribute, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Element/HasWidthTest.php b/tests/Element/HasWidthTest.php deleted file mode 100644 index 7120a70..0000000 --- a/tests/Element/HasWidthTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingWidthAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasWidth; - }; - - self::assertNotSame( - $instance, - $instance->width(''), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(WidthProvider::class, 'values')] - public function testSetWidthAttributeValue( - string|Stringable|UnitEnum|null $width, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttribute, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasWidth; - }; - - $instance = $instance->attributes($attributes)->width($width); - - self::assertSame( - $expectedValue, - $instance->getAttribute(ElementAttribute::WIDTH, ''), - $message, - ); - self::assertSame( - $expectedRenderAttribute, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/CanBeCheckedTest.php b/tests/Form/CanBeCheckedTest.php deleted file mode 100644 index ad54a2d..0000000 --- a/tests/Form/CanBeCheckedTest.php +++ /dev/null @@ -1,87 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingCheckedAttribute(): void - { - $instance = new class { - use CanBeChecked; - use HasAttributes; - }; - - self::assertNotSame( - $instance, - $instance->checked(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(CheckedProvider::class, 'values')] - public function testSetCheckedAttributeValue( - bool|null $checked, - array $attributes, - bool|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use CanBeChecked; - use HasAttributes; - }; - - $instance = $instance->attributes($attributes)->checked($checked); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::CHECKED, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/CanBeMultipleTest.php b/tests/Form/CanBeMultipleTest.php deleted file mode 100644 index efb92ac..0000000 --- a/tests/Form/CanBeMultipleTest.php +++ /dev/null @@ -1,87 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingMultipleAttribute(): void - { - $instance = new class { - use CanBeMultiple; - use HasAttributes; - }; - - self::assertNotSame( - $instance, - $instance->multiple(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(MultipleProvider::class, 'values')] - public function testSetMultipleAttributeValue( - bool|null $multiple, - array $attributes, - bool|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use CanBeMultiple; - use HasAttributes; - }; - - $instance = $instance->attributes($attributes)->multiple($multiple); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::MULTIPLE, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/CanBeReadonlyTest.php b/tests/Form/CanBeReadonlyTest.php deleted file mode 100644 index 5930cb3..0000000 --- a/tests/Form/CanBeReadonlyTest.php +++ /dev/null @@ -1,87 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingReadonlyAttribute(): void - { - $instance = new class { - use CanBeReadonly; - use HasAttributes; - }; - - self::assertNotSame( - $instance, - $instance->readonly(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(ReadonlyProvider::class, 'values')] - public function testSetReadonlyAttributeValue( - bool|null $readonly, - array $attributes, - bool|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use CanBeReadonly; - use HasAttributes; - }; - - $instance = $instance->attributes($attributes)->readonly($readonly); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::READONLY, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/CanBeRequiredTest.php b/tests/Form/CanBeRequiredTest.php deleted file mode 100644 index 517fd29..0000000 --- a/tests/Form/CanBeRequiredTest.php +++ /dev/null @@ -1,87 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingRequiredAttribute(): void - { - $instance = new class { - use CanBeRequired; - use HasAttributes; - }; - - self::assertNotSame( - $instance, - $instance->required(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(RequiredProvider::class, 'values')] - public function testSetRequiredAttributeValue( - bool|null $required, - array $attributes, - bool|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use CanBeRequired; - use HasAttributes; - }; - - $instance = $instance->attributes($attributes)->required($required); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::REQUIRED, null), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/HasAcceptTest.php b/tests/Form/HasAcceptTest.php deleted file mode 100644 index 9dcf92a..0000000 --- a/tests/Form/HasAcceptTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingAcceptAttribute(): void - { - $instance = new class { - use HasAccept; - use HasAttributes; - }; - - self::assertNotSame( - $instance, - $instance->accept(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(AcceptProvider::class, 'values')] - public function testSetAcceptAttributeValue( - string|Stringable|UnitEnum|null $accept, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAccept; - use HasAttributes; - }; - - $instance = $instance->attributes($attributes)->accept($accept); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::ACCEPT, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/HasAutocompleteTest.php b/tests/Form/HasAutocompleteTest.php deleted file mode 100644 index 7987846..0000000 --- a/tests/Form/HasAutocompleteTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingAutocompleteAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasAutocomplete; - }; - - self::assertNotSame( - $instance, - $instance->autocomplete(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(AutocompleteProvider::class, 'values')] - public function testSetAutocompleteAttributeValue( - string|Stringable|UnitEnum|null $autocomplete, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasAutocomplete; - }; - - $instance = $instance->attributes($attributes)->autocomplete($autocomplete); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::AUTOCOMPLETE, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/HasDirnameTest.php b/tests/Form/HasDirnameTest.php deleted file mode 100644 index 356bc6e..0000000 --- a/tests/Form/HasDirnameTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingDirnameAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasDirname; - }; - - self::assertNotSame( - $instance, - $instance->dirname(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(DirnameProvider::class, 'values')] - public function testSetDirnameAttributeValue( - string|Stringable|UnitEnum|null $dirname, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasDirname; - }; - - $instance = $instance->attributes($attributes)->dirname($dirname); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::DIRNAME, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/HasFormTest.php b/tests/Form/HasFormTest.php deleted file mode 100644 index 76fc0f6..0000000 --- a/tests/Form/HasFormTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingFormAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasForm; - }; - - self::assertNotSame( - $instance, - $instance->form(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(FormProvider::class, 'values')] - public function testSetFormAttributeValue( - string|Stringable|UnitEnum|null $form, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasForm; - }; - - $instance = $instance->attributes($attributes)->form($form); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::FORM, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/HasListTest.php b/tests/Form/HasListTest.php deleted file mode 100644 index f9082b5..0000000 --- a/tests/Form/HasListTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingListAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasList; - }; - - self::assertNotSame( - $instance, - $instance->list(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(ListProvider::class, 'values')] - public function testSetListAttributeValue( - string|Stringable|UnitEnum|null $list, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasList; - }; - - $instance = $instance->attributes($attributes)->list($list); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::LIST, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/HasMaxTest.php b/tests/Form/HasMaxTest.php deleted file mode 100644 index 8a35aff..0000000 --- a/tests/Form/HasMaxTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingMaxAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasMax; - }; - - self::assertNotSame( - $instance, - $instance->max(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(MaxProvider::class, 'values')] - public function testSetMaxAttributeValue( - float|int|string|Stringable|UnitEnum|null $max, - array $attributes, - float|int|string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasMax; - }; - - $instance = $instance->attributes($attributes)->max($max); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::MAX, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/HasMaxlengthTest.php b/tests/Form/HasMaxlengthTest.php deleted file mode 100644 index 6494962..0000000 --- a/tests/Form/HasMaxlengthTest.php +++ /dev/null @@ -1,117 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingMaxlengthAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasMaxlength; - }; - - self::assertNotSame( - $instance, - $instance->maxlength(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(MaxlengthProvider::class, 'values')] - public function testSetMaxlengthAttributeValue( - int|string|Stringable|UnitEnum|null $maxlength, - array $attributes, - int|string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasMaxlength; - }; - - $instance = $instance->attributes($attributes)->maxlength($maxlength); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::MAXLENGTH, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } - - #[DataProviderExternal(MaxlengthProvider::class, 'invalidValues')] - public function testThrowInvalidArgumentExceptionWhenSettingMaxlength( - int|string|Stringable|UnitEnum $maxlength, - ): void { - $instance = new class { - use HasAttributes; - use HasMaxlength; - }; - - if ($maxlength instanceof UnitEnum) { - $maxlength = Enum::normalizeValue($maxlength); - } - - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage( - Message::ATTRIBUTE_INVALID_VALUE->getMessage( - (string) $maxlength, - Attribute::MAXLENGTH->value, - 'value >= 0', - ), - ); - - $instance->maxlength($maxlength); - } -} diff --git a/tests/Form/HasMinTest.php b/tests/Form/HasMinTest.php deleted file mode 100644 index 5b435f0..0000000 --- a/tests/Form/HasMinTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingMinAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasMin; - }; - - self::assertNotSame( - $instance, - $instance->min(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(MinProvider::class, 'values')] - public function testSetMinAttributeValue( - float|int|string|Stringable|UnitEnum|null $min, - array $attributes, - float|int|string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasMin; - }; - - $instance = $instance->attributes($attributes)->min($min); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::MIN, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/HasMinlengthTest.php b/tests/Form/HasMinlengthTest.php deleted file mode 100644 index ae8ecf7..0000000 --- a/tests/Form/HasMinlengthTest.php +++ /dev/null @@ -1,117 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingMinlengthAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasMinlength; - }; - - self::assertNotSame( - $instance, - $instance->minlength(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(MinlengthProvider::class, 'values')] - public function testSetMinlengthAttributeValue( - int|string|Stringable|UnitEnum|null $minlength, - array $attributes, - int|string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasMinlength; - }; - - $instance = $instance->attributes($attributes)->minlength($minlength); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::MINLENGTH, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } - - #[DataProviderExternal(MinlengthProvider::class, 'invalidValues')] - public function testThrowInvalidArgumentExceptionWhenSettingMinlength( - int|string|Stringable|UnitEnum $minlength, - ): void { - $instance = new class { - use HasAttributes; - use HasMinlength; - }; - - if ($minlength instanceof UnitEnum) { - $minlength = Enum::normalizeValue($minlength); - } - - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage( - Message::ATTRIBUTE_INVALID_VALUE->getMessage( - (string) $minlength, - Attribute::MINLENGTH->value, - 'value >= 0', - ), - ); - - $instance->minlength($minlength); - } -} diff --git a/tests/Form/HasPatternTest.php b/tests/Form/HasPatternTest.php deleted file mode 100644 index 87e0106..0000000 --- a/tests/Form/HasPatternTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingPatternAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasPattern; - }; - - self::assertNotSame( - $instance, - $instance->pattern(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(PatternProvider::class, 'values')] - public function testSetPatternAttributeValue( - string|Stringable|UnitEnum|null $pattern, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasPattern; - }; - - $instance = $instance->attributes($attributes)->pattern($pattern); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::PATTERN, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/HasPlaceholderTest.php b/tests/Form/HasPlaceholderTest.php deleted file mode 100644 index 73f03da..0000000 --- a/tests/Form/HasPlaceholderTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingPlaceholderAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasPlaceholder; - }; - - self::assertNotSame( - $instance, - $instance->placeholder(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(PlaceholderProvider::class, 'values')] - public function testSetPlaceholderAttributeValue( - string|Stringable|UnitEnum|null $placeholder, - array $attributes, - string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasPlaceholder; - }; - - $instance = $instance->attributes($attributes)->placeholder($placeholder); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::PLACEHOLDER, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/HasSizeTest.php b/tests/Form/HasSizeTest.php deleted file mode 100644 index 6838578..0000000 --- a/tests/Form/HasSizeTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingSizeAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasSize; - }; - - self::assertNotSame( - $instance, - $instance->size(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(SizeProvider::class, 'values')] - public function testSetSizeAttributeValue( - int|string|Stringable|UnitEnum|null $size, - array $attributes, - int|string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasSize; - }; - - $instance = $instance->attributes($attributes)->size($size); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::SIZE, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Form/HasStepTest.php b/tests/Form/HasStepTest.php deleted file mode 100644 index ea9686f..0000000 --- a/tests/Form/HasStepTest.php +++ /dev/null @@ -1,89 +0,0 @@ -getAttributes(), - 'Should have no attributes set when no attribute is provided.', - ); - } - - public function testReturnNewInstanceWhenSettingStepAttribute(): void - { - $instance = new class { - use HasAttributes; - use HasStep; - }; - - self::assertNotSame( - $instance, - $instance->step(null), - 'Should return a new instance when setting the attribute, ensuring immutability.', - ); - } - - /** - * @phpstan-param mixed[] $attributes - */ - #[DataProviderExternal(StepProvider::class, 'values')] - public function testSetStepAttributeValue( - float|int|string|Stringable|UnitEnum|null $step, - array $attributes, - float|int|string|Stringable|UnitEnum|null $expectedValue, - string $expectedRenderAttributes, - string $message, - ): void { - $instance = new class { - use HasAttributes; - use HasStep; - }; - - $instance = $instance->attributes($attributes)->step($step); - - self::assertSame( - $expectedValue, - $instance->getAttribute(Attribute::STEP, ''), - $message, - ); - self::assertSame( - $expectedRenderAttributes, - Attributes::render($instance->getAttributes()), - $message, - ); - } -} diff --git a/tests/Global/CanBeAutofocusTest.php b/tests/Global/CanBeAutofocusTest.php index f8517b0..8418517 100644 --- a/tests/Global/CanBeAutofocusTest.php +++ b/tests/Global/CanBeAutofocusTest.php @@ -75,7 +75,7 @@ public function testSetAutofocusAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::AUTOFOCUS, ''), + $instance->getAttribute(GlobalAttribute::AUTOFOCUS), $message, ); self::assertSame( diff --git a/tests/Global/CanBeHiddenTest.php b/tests/Global/CanBeHiddenTest.php index 1ae6ef7..37f3e8d 100644 --- a/tests/Global/CanBeHiddenTest.php +++ b/tests/Global/CanBeHiddenTest.php @@ -75,7 +75,7 @@ public function testSetHiddenAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::HIDDEN, ''), + $instance->getAttribute(GlobalAttribute::HIDDEN), $message, ); self::assertSame( diff --git a/tests/Global/HasAccesskeyTest.php b/tests/Global/HasAccesskeyTest.php index 68fb7d8..98d66b9 100644 --- a/tests/Global/HasAccesskeyTest.php +++ b/tests/Global/HasAccesskeyTest.php @@ -77,7 +77,7 @@ public function testSetAccesskeyAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::ACCESSKEY, ''), + $instance->getAttribute(GlobalAttribute::ACCESSKEY), $message, ); self::assertSame( diff --git a/tests/Global/HasAutocapitalizeTest.php b/tests/Global/HasAutocapitalizeTest.php index be5f206..9647264 100644 --- a/tests/Global/HasAutocapitalizeTest.php +++ b/tests/Global/HasAutocapitalizeTest.php @@ -10,7 +10,7 @@ use UIAwesome\Html\Attribute\Global\HasAutocapitalize; use UIAwesome\Html\Attribute\Tests\Provider\Global\AutocapitalizeProvider; use UIAwesome\Html\Attribute\Values\{Autocapitalize, GlobalAttribute}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -79,7 +79,7 @@ public function testSetAutocapitalizeAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::AUTOCAPITALIZE, ''), + $instance->getAttribute(GlobalAttribute::AUTOCAPITALIZE), $message, ); self::assertSame( @@ -101,7 +101,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingAutocapitalize(): vo Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', GlobalAttribute::AUTOCAPITALIZE->value, - implode("', '", Enum::normalizeArray(Autocapitalize::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Autocapitalize::cases())), ), ); diff --git a/tests/Global/HasAutocorrectTest.php b/tests/Global/HasAutocorrectTest.php index b30effa..4b36d46 100644 --- a/tests/Global/HasAutocorrectTest.php +++ b/tests/Global/HasAutocorrectTest.php @@ -10,7 +10,7 @@ use UIAwesome\Html\Attribute\Global\HasAutocorrect; use UIAwesome\Html\Attribute\Tests\Provider\Global\AutocorrectProvider; use UIAwesome\Html\Attribute\Values\{Autocorrect, GlobalAttribute}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -79,7 +79,7 @@ public function testSetAutocorrectAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::AUTOCORRECT, ''), + $instance->getAttribute(GlobalAttribute::AUTOCORRECT), $message, ); self::assertSame( @@ -101,7 +101,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingAutocorrect(): void Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', GlobalAttribute::AUTOCORRECT->value, - implode("', '", Enum::normalizeArray(Autocorrect::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Autocorrect::cases())), ), ); diff --git a/tests/Global/HasClassTest.php b/tests/Global/HasClassTest.php index cd3700d..76437f5 100644 --- a/tests/Global/HasClassTest.php +++ b/tests/Global/HasClassTest.php @@ -83,7 +83,7 @@ public function testSetClassAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::CLASS_CSS, ''), + $instance->getAttribute(GlobalAttribute::CLASS_CSS), $message, ); self::assertSame( diff --git a/tests/Global/HasContentEditableTest.php b/tests/Global/HasContentEditableTest.php index 8dde21d..6493d20 100644 --- a/tests/Global/HasContentEditableTest.php +++ b/tests/Global/HasContentEditableTest.php @@ -10,7 +10,7 @@ use UIAwesome\Html\Attribute\Global\HasContentEditable; use UIAwesome\Html\Attribute\Tests\Provider\Global\ContentEditableProvider; use UIAwesome\Html\Attribute\Values\{ContentEditable, GlobalAttribute}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -79,7 +79,7 @@ public function testSetContentEditableAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::CONTENTEDITABLE, ''), + $instance->getAttribute(GlobalAttribute::CONTENTEDITABLE), $message, ); self::assertSame( @@ -101,7 +101,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingContentEditable(): v Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', GlobalAttribute::CONTENTEDITABLE->value, - implode("', '", Enum::normalizeArray(ContentEditable::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, ContentEditable::cases())), ), ); diff --git a/tests/Global/HasDirTest.php b/tests/Global/HasDirTest.php index f366ed5..5e00f5a 100644 --- a/tests/Global/HasDirTest.php +++ b/tests/Global/HasDirTest.php @@ -10,7 +10,7 @@ use UIAwesome\Html\Attribute\Global\HasDir; use UIAwesome\Html\Attribute\Tests\Provider\Global\DirProvider; use UIAwesome\Html\Attribute\Values\{Direction, GlobalAttribute}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -79,7 +79,7 @@ public function testSetDirAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::DIR, ''), + $instance->getAttribute(GlobalAttribute::DIR), $message, ); self::assertSame( @@ -101,7 +101,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingDir(): void Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', GlobalAttribute::DIR->value, - implode("', '", Enum::normalizeArray(Direction::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Direction::cases())), ), ); diff --git a/tests/Global/HasDraggableTest.php b/tests/Global/HasDraggableTest.php index 5d2a923..ef46ea5 100644 --- a/tests/Global/HasDraggableTest.php +++ b/tests/Global/HasDraggableTest.php @@ -10,7 +10,7 @@ use UIAwesome\Html\Attribute\Global\HasDraggable; use UIAwesome\Html\Attribute\Tests\Provider\Global\DraggableProvider; use UIAwesome\Html\Attribute\Values\{Draggable, GlobalAttribute}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -79,7 +79,7 @@ public function testSetDraggableAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::DRAGGABLE, ''), + $instance->getAttribute(GlobalAttribute::DRAGGABLE), $message, ); self::assertSame( @@ -101,7 +101,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingDraggable(): void Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', GlobalAttribute::DRAGGABLE->value, - implode("', '", Enum::normalizeArray(Draggable::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Draggable::cases())), ), ); diff --git a/tests/Global/HasIdTest.php b/tests/Global/HasIdTest.php index 853cf55..420ef0b 100644 --- a/tests/Global/HasIdTest.php +++ b/tests/Global/HasIdTest.php @@ -77,7 +77,7 @@ public function testSetIdAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::ID, ''), + $instance->getAttribute(GlobalAttribute::ID), $message, ); self::assertSame( diff --git a/tests/Global/HasInputModeTest.php b/tests/Global/HasInputModeTest.php index f949525..d555fd3 100644 --- a/tests/Global/HasInputModeTest.php +++ b/tests/Global/HasInputModeTest.php @@ -10,7 +10,7 @@ use UIAwesome\Html\Attribute\Global\HasInputMode; use UIAwesome\Html\Attribute\Tests\Provider\Global\InputModeProvider; use UIAwesome\Html\Attribute\Values\{GlobalAttribute, InputMode}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -79,7 +79,7 @@ public function testSetInputModeAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::INPUTMODE, ''), + $instance->getAttribute(GlobalAttribute::INPUTMODE), $message, ); self::assertSame( @@ -101,7 +101,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingInputMode(): void Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', GlobalAttribute::INPUTMODE->value, - implode("', '", Enum::normalizeArray(InputMode::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, InputMode::cases())), ), ); diff --git a/tests/Global/HasLangTest.php b/tests/Global/HasLangTest.php index 7f31753..851cbab 100644 --- a/tests/Global/HasLangTest.php +++ b/tests/Global/HasLangTest.php @@ -11,7 +11,7 @@ use UIAwesome\Html\Attribute\Global\HasLang; use UIAwesome\Html\Attribute\Tests\Provider\Global\LangProvider; use UIAwesome\Html\Attribute\Values\{GlobalAttribute, Language}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -80,7 +80,7 @@ public function testSetLangAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::LANG, ''), + $instance->getAttribute(GlobalAttribute::LANG), $message, ); self::assertSame( @@ -102,7 +102,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingLang(): void Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', 'lang', - implode("', '", Enum::normalizeArray(Language::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Language::cases())), ), ); diff --git a/tests/Global/HasMicroDataTest.php b/tests/Global/HasMicroDataTest.php index 1ae0883..e56aecd 100644 --- a/tests/Global/HasMicroDataTest.php +++ b/tests/Global/HasMicroDataTest.php @@ -140,7 +140,7 @@ public function testSetItemIdAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::ITEMID, ''), + $instance->getAttribute(GlobalAttribute::ITEMID), $message, ); self::assertSame( @@ -170,7 +170,7 @@ public function testSetItemPropAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::ITEMPROP, ''), + $instance->getAttribute(GlobalAttribute::ITEMPROP), $message, ); self::assertSame( @@ -200,7 +200,7 @@ public function testSetItemRefAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::ITEMREF, ''), + $instance->getAttribute(GlobalAttribute::ITEMREF), $message, ); self::assertSame( @@ -230,7 +230,7 @@ public function testSetItemScopeAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::ITEMSCOPE, ''), + $instance->getAttribute(GlobalAttribute::ITEMSCOPE), $message, ); self::assertSame( @@ -260,7 +260,7 @@ public function testSetItemTypeAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::ITEMTYPE, ''), + $instance->getAttribute(GlobalAttribute::ITEMTYPE), $message, ); self::assertSame( diff --git a/tests/Global/HasNonceTest.php b/tests/Global/HasNonceTest.php index d6e7f6a..bb06261 100644 --- a/tests/Global/HasNonceTest.php +++ b/tests/Global/HasNonceTest.php @@ -77,7 +77,7 @@ public function testSetNonceAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::NONCE, ''), + $instance->getAttribute(GlobalAttribute::NONCE), $message, ); self::assertSame( diff --git a/tests/Global/HasPopoverTest.php b/tests/Global/HasPopoverTest.php index b8f96f9..a0997a3 100644 --- a/tests/Global/HasPopoverTest.php +++ b/tests/Global/HasPopoverTest.php @@ -10,7 +10,7 @@ use UIAwesome\Html\Attribute\Global\HasPopover; use UIAwesome\Html\Attribute\Tests\Provider\Global\PopoverProvider; use UIAwesome\Html\Attribute\Values\{GlobalAttribute, Popover}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -79,7 +79,7 @@ public function testSetPopoverAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::POPOVER, ''), + $instance->getAttribute(GlobalAttribute::POPOVER), $message, ); self::assertSame( @@ -101,7 +101,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingPopover(): void Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', GlobalAttribute::POPOVER->value, - implode("', '", Enum::normalizeArray(Popover::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Popover::cases())), ), ); diff --git a/tests/Global/HasRoleTest.php b/tests/Global/HasRoleTest.php index d355975..65423f2 100644 --- a/tests/Global/HasRoleTest.php +++ b/tests/Global/HasRoleTest.php @@ -11,7 +11,7 @@ use UIAwesome\Html\Attribute\Global\HasRole; use UIAwesome\Html\Attribute\Tests\Provider\Global\RoleProvider; use UIAwesome\Html\Attribute\Values\{GlobalAttribute, Role}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -80,7 +80,7 @@ public function testSetRoleAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::ROLE, ''), + $instance->getAttribute(GlobalAttribute::ROLE), $message, ); self::assertSame( @@ -102,7 +102,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingRole(): void Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', GlobalAttribute::ROLE->value, - implode("', '", Enum::normalizeArray(Role::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Role::cases())), ), ); diff --git a/tests/Global/HasSpellcheckTest.php b/tests/Global/HasSpellcheckTest.php index 2c5a2e0..ffe7b66 100644 --- a/tests/Global/HasSpellcheckTest.php +++ b/tests/Global/HasSpellcheckTest.php @@ -78,7 +78,7 @@ public function testSetSpellcheckAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::SPELLCHECK, ''), + $instance->getAttribute(GlobalAttribute::SPELLCHECK), $message, ); self::assertSame( diff --git a/tests/Global/HasStyleTest.php b/tests/Global/HasStyleTest.php index d52aa65..0bf6a97 100644 --- a/tests/Global/HasStyleTest.php +++ b/tests/Global/HasStyleTest.php @@ -79,7 +79,7 @@ public function testSetStyleAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::STYLE, ''), + $instance->getAttribute(GlobalAttribute::STYLE), $message, ); self::assertSame( diff --git a/tests/Global/HasTabIndexTest.php b/tests/Global/HasTabIndexTest.php index 75dc995..1e4e7fb 100644 --- a/tests/Global/HasTabIndexTest.php +++ b/tests/Global/HasTabIndexTest.php @@ -79,7 +79,7 @@ public function testSetTabIndexAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::TABINDEX, ''), + $instance->getAttribute(GlobalAttribute::TABINDEX), $message, ); self::assertSame( diff --git a/tests/Global/HasTitleTest.php b/tests/Global/HasTitleTest.php index 6d67ec5..f40d58b 100644 --- a/tests/Global/HasTitleTest.php +++ b/tests/Global/HasTitleTest.php @@ -77,7 +77,7 @@ public function testSetTitleAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::TITLE, ''), + $instance->getAttribute(GlobalAttribute::TITLE), $message, ); self::assertSame( diff --git a/tests/Global/HasTranslateTest.php b/tests/Global/HasTranslateTest.php index 8a06a84..d49d9b5 100644 --- a/tests/Global/HasTranslateTest.php +++ b/tests/Global/HasTranslateTest.php @@ -10,7 +10,7 @@ use UIAwesome\Html\Attribute\Global\HasTranslate; use UIAwesome\Html\Attribute\Tests\Provider\Global\TranslateProvider; use UIAwesome\Html\Attribute\Values\{GlobalAttribute, Translate}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -79,7 +79,7 @@ public function testSetTranslateAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(GlobalAttribute::TRANSLATE, ''), + $instance->getAttribute(GlobalAttribute::TRANSLATE), $message, ); self::assertSame( @@ -101,7 +101,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingTranslate(): void Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', GlobalAttribute::TRANSLATE->value, - implode("', '", Enum::normalizeArray(Translate::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Translate::cases())), ), ); diff --git a/tests/HasAsTest.php b/tests/HasAsTest.php index 41c9d97..9569cd2 100644 --- a/tests/HasAsTest.php +++ b/tests/HasAsTest.php @@ -10,8 +10,8 @@ use Stringable; use UIAwesome\Html\Attribute\HasAs; use UIAwesome\Html\Attribute\Tests\Provider\AsProvider; -use UIAwesome\Html\Attribute\Values\{AsValue, Attribute}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Attribute\Values\{AsValue, ElementAttribute}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -80,7 +80,7 @@ public function testSetAsAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::AS, ''), + $instance->getAttribute(ElementAttribute::AS), $message, ); self::assertSame( @@ -101,8 +101,8 @@ public function testThrowInvalidArgumentExceptionWhenSettingAsValue(): void $this->expectExceptionMessage( Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', - Attribute::AS->value, - implode("', '", Enum::normalizeArray(AsValue::cases())), + ElementAttribute::AS->value, + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, AsValue::cases())), ), ); diff --git a/tests/HasBlockingTest.php b/tests/HasBlockingTest.php index 5b53244..da15ba0 100644 --- a/tests/HasBlockingTest.php +++ b/tests/HasBlockingTest.php @@ -9,8 +9,8 @@ use PHPUnit\Framework\TestCase; use UIAwesome\Html\Attribute\HasBlocking; use UIAwesome\Html\Attribute\Tests\Provider\BlockingProvider; -use UIAwesome\Html\Attribute\Values\{Attribute, Blocking}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Attribute\Values\{Blocking, ElementAttribute}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -79,7 +79,7 @@ public function testSetBlockingAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::BLOCKING, ''), + $instance->getAttribute(ElementAttribute::BLOCKING), $message, ); self::assertSame( @@ -100,8 +100,8 @@ public function testThrowInvalidArgumentExceptionWhenSettingBlockingValue(): voi $this->expectExceptionMessage( Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', - Attribute::BLOCKING->value, - implode("', '", Enum::normalizeArray(Blocking::cases())), + ElementAttribute::BLOCKING->value, + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Blocking::cases())), ), ); diff --git a/tests/HasCharsetTest.php b/tests/HasCharsetTest.php index aed8648..4aaf866 100644 --- a/tests/HasCharsetTest.php +++ b/tests/HasCharsetTest.php @@ -10,8 +10,8 @@ use Stringable; use UIAwesome\Html\Attribute\HasCharset; use UIAwesome\Html\Attribute\Tests\Provider\CharsetProvider; -use UIAwesome\Html\Attribute\Values\{Attribute, Charset}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Attribute\Values\{Charset, ElementAttribute}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -80,7 +80,7 @@ public function testSetCharsetAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::CHARSET, ''), + $instance->getAttribute(ElementAttribute::CHARSET), $message, ); self::assertSame( @@ -101,8 +101,8 @@ public function testThrowInvalidArgumentExceptionWhenSettingCharsetValue(): void $this->expectExceptionMessage( Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', - Attribute::CHARSET->value, - implode("', '", Enum::normalizeArray(Charset::cases())), + ElementAttribute::CHARSET->value, + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Charset::cases())), ), ); diff --git a/tests/HasContentTest.php b/tests/HasContentTest.php index a7ff73b..3d3fec5 100644 --- a/tests/HasContentTest.php +++ b/tests/HasContentTest.php @@ -77,7 +77,7 @@ public function testSetContentAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::CONTENT, ''), + $instance->getAttribute(Attribute::CONTENT), $message, ); self::assertSame( diff --git a/tests/HasCrossoriginTest.php b/tests/HasCrossoriginTest.php index c35e246..0546043 100644 --- a/tests/HasCrossoriginTest.php +++ b/tests/HasCrossoriginTest.php @@ -10,7 +10,7 @@ use UIAwesome\Html\Attribute\HasCrossorigin; use UIAwesome\Html\Attribute\Tests\Provider\CrossoriginProvider; use UIAwesome\Html\Attribute\Values\{Attribute, Crossorigin}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -79,7 +79,7 @@ public function testSetCrossoriginAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::CROSSORIGIN, ''), + $instance->getAttribute(Attribute::CROSSORIGIN), $message, ); self::assertSame( @@ -101,7 +101,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingCrossoriginValue(): Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', Attribute::CROSSORIGIN->value, - implode("', '", Enum::normalizeArray(Crossorigin::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Crossorigin::cases())), ), ); diff --git a/tests/HasDownloadTest.php b/tests/HasDownloadTest.php index f822056..9130dd4 100644 --- a/tests/HasDownloadTest.php +++ b/tests/HasDownloadTest.php @@ -9,7 +9,7 @@ use Stringable; use UIAwesome\Html\Attribute\HasDownload; use UIAwesome\Html\Attribute\Tests\Provider\DownloadProvider; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\{Attribute, ElementAttribute}; use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -77,7 +77,7 @@ public function testSetDownloadAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::DOWNLOAD, ''), + $instance->getAttribute(ElementAttribute::DOWNLOAD), $message, ); self::assertSame( diff --git a/tests/HasFetchpriorityTest.php b/tests/HasFetchpriorityTest.php index 1e85f4e..0f4d48b 100644 --- a/tests/HasFetchpriorityTest.php +++ b/tests/HasFetchpriorityTest.php @@ -10,7 +10,7 @@ use UIAwesome\Html\Attribute\HasFetchpriority; use UIAwesome\Html\Attribute\Tests\Provider\FetchpriorityProvider; use UIAwesome\Html\Attribute\Values\{Attribute, Fetchpriority}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -79,7 +79,7 @@ public function testSetFetchpriorityAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::FETCHPRIORITY, ''), + $instance->getAttribute(Attribute::FETCHPRIORITY), $message, ); self::assertSame( @@ -101,7 +101,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingFetchpriority(): voi Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', Attribute::FETCHPRIORITY->value, - implode("', '", Enum::normalizeArray(Fetchpriority::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Fetchpriority::cases())), ), ); diff --git a/tests/HasForTest.php b/tests/HasForTest.php index 00fffc9..b0927ab 100644 --- a/tests/HasForTest.php +++ b/tests/HasForTest.php @@ -77,7 +77,7 @@ public function testSetForAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::FOR, ''), + $instance->getAttribute(Attribute::FOR), $message, ); self::assertSame( diff --git a/tests/HasHreflangTest.php b/tests/HasHreflangTest.php index 764564a..0e902c4 100644 --- a/tests/HasHreflangTest.php +++ b/tests/HasHreflangTest.php @@ -9,7 +9,7 @@ use Stringable; use UIAwesome\Html\Attribute\HasHreflang; use UIAwesome\Html\Attribute\Tests\Provider\HreflangProvider; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\{Attribute, ElementAttribute}; use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -77,7 +77,7 @@ public function testSetHreflangAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::HREFLANG, ''), + $instance->getAttribute(ElementAttribute::HREFLANG), $message, ); self::assertSame( diff --git a/tests/HasHttpEquivTest.php b/tests/HasHttpEquivTest.php index 8d3e7d4..e03622a 100644 --- a/tests/HasHttpEquivTest.php +++ b/tests/HasHttpEquivTest.php @@ -10,8 +10,8 @@ use Stringable; use UIAwesome\Html\Attribute\HasHttpEquiv; use UIAwesome\Html\Attribute\Tests\Provider\HttpEquivProvider; -use UIAwesome\Html\Attribute\Values\{Attribute, HttpEquiv}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Attribute\Values\{ElementAttribute, HttpEquiv}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -80,7 +80,7 @@ public function testSetHttpEquivAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::HTTP_EQUIV, ''), + $instance->getAttribute(ElementAttribute::HTTP_EQUIV), $message, ); self::assertSame( @@ -101,8 +101,8 @@ public function testThrowInvalidArgumentExceptionWhenSettingHttpEquiv(): void $this->expectExceptionMessage( Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', - Attribute::HTTP_EQUIV->value, - implode("', '", Enum::normalizeArray(HttpEquiv::cases())), + ElementAttribute::HTTP_EQUIV->value, + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, HttpEquiv::cases())), ), ); diff --git a/tests/HasImagesizesTest.php b/tests/HasImageSizesTest.php similarity index 83% rename from tests/HasImagesizesTest.php rename to tests/HasImageSizesTest.php index 461b1f4..936887d 100644 --- a/tests/HasImagesizesTest.php +++ b/tests/HasImageSizesTest.php @@ -7,15 +7,15 @@ use PHPUnit\Framework\Attributes\{DataProviderExternal, Group}; use PHPUnit\Framework\TestCase; use Stringable; -use UIAwesome\Html\Attribute\HasImagesizes; -use UIAwesome\Html\Attribute\Tests\Provider\ImagesizesProvider; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\HasImageSizes; +use UIAwesome\Html\Attribute\Tests\Provider\ImageSizesProvider; +use UIAwesome\Html\Attribute\Values\ElementAttribute; use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; /** - * Unit tests for the {@see HasImagesizes} trait managing the `imagesizes` HTML attribute. + * Unit tests for the {@see HasImageSizes} trait managing the `imagesizes` HTML attribute. * * Test coverage. * - Ensures fluent setters return new instances (immutability). @@ -28,13 +28,13 @@ * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ #[Group('attribute')] -final class HasImagesizesTest extends TestCase +final class HasImageSizesTest extends TestCase { public function testReturnEmptyWhenImagesizesAttributeNotSet(): void { $instance = new class { use HasAttributes; - use HasImagesizes; + use HasImageSizes; }; self::assertEmpty( @@ -47,7 +47,7 @@ public function testReturnNewInstanceWhenSettingImagesizesAttribute(): void { $instance = new class { use HasAttributes; - use HasImagesizes; + use HasImageSizes; }; self::assertNotSame( @@ -70,14 +70,14 @@ public function testSetImagesizesAttributeValue( ): void { $instance = new class { use HasAttributes; - use HasImagesizes; + use HasImageSizes; }; $instance = $instance->attributes($attributes)->imagesizes($imagesizes); self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::IMAGESIZES, ''), + $instance->getAttribute(ElementAttribute::IMAGESIZES), $message, ); self::assertSame( diff --git a/tests/HasImagesrcsetTest.php b/tests/HasImageSrcSetTest.php similarity index 83% rename from tests/HasImagesrcsetTest.php rename to tests/HasImageSrcSetTest.php index 12aa17c..99a9cba 100644 --- a/tests/HasImagesrcsetTest.php +++ b/tests/HasImageSrcSetTest.php @@ -7,15 +7,15 @@ use PHPUnit\Framework\Attributes\{DataProviderExternal, Group}; use PHPUnit\Framework\TestCase; use Stringable; -use UIAwesome\Html\Attribute\HasImagesrcset; -use UIAwesome\Html\Attribute\Tests\Provider\ImagesrcsetProvider; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\HasImageSrcSet; +use UIAwesome\Html\Attribute\Tests\Provider\ImageSrcSetProvider; +use UIAwesome\Html\Attribute\Values\ElementAttribute; use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; /** - * Unit tests for the {@see HasImagesrcset} trait managing the `imagesrcset` HTML attribute. + * Unit tests for the {@see HasImageSrcSet} trait managing the `imagesrcset` HTML attribute. * * Test coverage. * - Ensures fluent setters return new instances (immutability). @@ -28,13 +28,13 @@ * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ #[Group('attribute')] -final class HasImagesrcsetTest extends TestCase +final class HasImageSrcSetTest extends TestCase { public function testReturnEmptyWhenImagesrcsetAttributeNotSet(): void { $instance = new class { use HasAttributes; - use HasImagesrcset; + use HasImageSrcSet; }; self::assertEmpty( @@ -47,7 +47,7 @@ public function testReturnNewInstanceWhenSettingImagesrcsetAttribute(): void { $instance = new class { use HasAttributes; - use HasImagesrcset; + use HasImageSrcSet; }; self::assertNotSame( @@ -70,14 +70,14 @@ public function testSetImagesrcsetAttributeValue( ): void { $instance = new class { use HasAttributes; - use HasImagesrcset; + use HasImageSrcSet; }; $instance = $instance->attributes($attributes)->imagesrcset($imagesrcset); self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::IMAGESRCSET, ''), + $instance->getAttribute(ElementAttribute::IMAGESRCSET), $message, ); self::assertSame( diff --git a/tests/HasIntegrityTest.php b/tests/HasIntegrityTest.php index 21a373f..f076adb 100644 --- a/tests/HasIntegrityTest.php +++ b/tests/HasIntegrityTest.php @@ -77,7 +77,7 @@ public function testSetIntegrityAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::INTEGRITY, ''), + $instance->getAttribute(Attribute::INTEGRITY), $message, ); self::assertSame( diff --git a/tests/HasLabelTest.php b/tests/HasLabelTest.php index e94c2a3..ddeabc1 100644 --- a/tests/HasLabelTest.php +++ b/tests/HasLabelTest.php @@ -9,7 +9,7 @@ use Stringable; use UIAwesome\Html\Attribute\HasLabel; use UIAwesome\Html\Attribute\Tests\Provider\LabelProvider; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\{Attribute, ElementAttribute}; use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -77,7 +77,7 @@ public function testSetLabelAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::LABEL, ''), + $instance->getAttribute(ElementAttribute::LABEL), $message, ); self::assertSame( diff --git a/tests/HasMediaTest.php b/tests/HasMediaTest.php index 3eb6c10..2e95d1c 100644 --- a/tests/HasMediaTest.php +++ b/tests/HasMediaTest.php @@ -77,7 +77,7 @@ public function testSetMediaAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::MEDIA, ''), + $instance->getAttribute(Attribute::MEDIA), $message, ); self::assertSame( diff --git a/tests/HasNameTest.php b/tests/HasNameTest.php index 30289e4..d8365ac 100644 --- a/tests/HasNameTest.php +++ b/tests/HasNameTest.php @@ -9,7 +9,7 @@ use Stringable; use UIAwesome\Html\Attribute\HasName; use UIAwesome\Html\Attribute\Tests\Provider\NameProvider; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\{Attribute, ElementAttribute}; use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -77,7 +77,7 @@ public function testSetNameAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::NAME, ''), + $instance->getAttribute(ElementAttribute::NAME), $message, ); self::assertSame( diff --git a/tests/HasPingTest.php b/tests/HasPingTest.php index 9631220..96c92bb 100644 --- a/tests/HasPingTest.php +++ b/tests/HasPingTest.php @@ -9,7 +9,7 @@ use Stringable; use UIAwesome\Html\Attribute\HasPing; use UIAwesome\Html\Attribute\Tests\Provider\PingProvider; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\{Attribute, ElementAttribute}; use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -77,7 +77,7 @@ public function testSetPingAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::PING, ''), + $instance->getAttribute(ElementAttribute::PING), $message, ); self::assertSame( diff --git a/tests/HasReferrerpolicyTest.php b/tests/HasReferrerpolicyTest.php index 501993e..a2e308c 100644 --- a/tests/HasReferrerpolicyTest.php +++ b/tests/HasReferrerpolicyTest.php @@ -11,7 +11,7 @@ use UIAwesome\Html\Attribute\HasReferrerpolicy; use UIAwesome\Html\Attribute\Tests\Provider\ReferrerpolicyProvider; use UIAwesome\Html\Attribute\Values\{Attribute, Referrerpolicy}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -80,7 +80,7 @@ public function testSetReferrerpolicyAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::REFERRERPOLICY, ''), + $instance->getAttribute(Attribute::REFERRERPOLICY), $message, ); self::assertSame( @@ -102,7 +102,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingReferrerpolicy(): vo Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', Attribute::REFERRERPOLICY->value, - implode("', '", Enum::normalizeArray(Referrerpolicy::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Referrerpolicy::cases())), ), ); diff --git a/tests/HasRelTest.php b/tests/HasRelTest.php index 57e2f63..7f97dc4 100644 --- a/tests/HasRelTest.php +++ b/tests/HasRelTest.php @@ -11,7 +11,7 @@ use UIAwesome\Html\Attribute\HasRel; use UIAwesome\Html\Attribute\Tests\Provider\RelProvider; use UIAwesome\Html\Attribute\Values\{Attribute, Rel}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -80,7 +80,7 @@ public function testSetRelAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::REL, ''), + $instance->getAttribute(Attribute::REL), $message, ); self::assertSame( @@ -102,7 +102,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingRel(): void Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', Attribute::REL->value, - implode("', '", Enum::normalizeArray(Rel::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Rel::cases())), ), ); diff --git a/tests/HasSizesTest.php b/tests/HasSizesTest.php index c5d4da6..73ab0f1 100644 --- a/tests/HasSizesTest.php +++ b/tests/HasSizesTest.php @@ -9,7 +9,7 @@ use Stringable; use UIAwesome\Html\Attribute\HasSizes; use UIAwesome\Html\Attribute\Tests\Provider\SizesProvider; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\{Attribute, ElementAttribute}; use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -77,7 +77,7 @@ public function testSetSizesAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::SIZES, ''), + $instance->getAttribute(ElementAttribute::SIZES), $message, ); self::assertSame( diff --git a/tests/HasSrcTest.php b/tests/HasSrcTest.php index 80ff835..0818502 100644 --- a/tests/HasSrcTest.php +++ b/tests/HasSrcTest.php @@ -77,7 +77,7 @@ public function testSetSrcAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::SRC, ''), + $instance->getAttribute(Attribute::SRC), $message, ); self::assertSame( diff --git a/tests/HasTargetTest.php b/tests/HasTargetTest.php index f4b83d7..fcd3909 100644 --- a/tests/HasTargetTest.php +++ b/tests/HasTargetTest.php @@ -10,7 +10,7 @@ use UIAwesome\Html\Attribute\HasTarget; use UIAwesome\Html\Attribute\Tests\Provider\TargetProvider; use UIAwesome\Html\Attribute\Values\{Attribute, Target}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -79,7 +79,7 @@ public function testSetTargetAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::TARGET, ''), + $instance->getAttribute(Attribute::TARGET), $message, ); self::assertSame( @@ -101,7 +101,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingTarget(): void Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-target', Attribute::TARGET->value, - implode("', '", Enum::normalizeArray(Target::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Target::cases())), ), ); diff --git a/tests/HasTypeTest.php b/tests/HasTypeTest.php index ae23b07..b3543f9 100644 --- a/tests/HasTypeTest.php +++ b/tests/HasTypeTest.php @@ -11,7 +11,7 @@ use UIAwesome\Html\Attribute\HasType; use UIAwesome\Html\Attribute\Tests\Provider\TypeProvider; use UIAwesome\Html\Attribute\Values\{Attribute, Type}; -use UIAwesome\Html\Helper\{Attributes, Enum}; +use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Helper\Exception\Message; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -80,7 +80,7 @@ public function testSetTypeAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::TYPE, ''), + $instance->getAttribute(Attribute::TYPE), $message, ); self::assertSame( @@ -102,7 +102,7 @@ public function testThrowInvalidArgumentExceptionWhenSettingType(): void Message::VALUE_NOT_IN_LIST->getMessage( 'invalid-value', Attribute::TYPE->value, - implode("', '", Enum::normalizeArray(Type::cases())), + implode("', '", array_map(static fn(\BackedEnum $case): string => $case->value, Type::cases())), ), ); diff --git a/tests/HasValueTest.php b/tests/HasValueTest.php index ddd1b2b..347cabc 100644 --- a/tests/HasValueTest.php +++ b/tests/HasValueTest.php @@ -9,7 +9,7 @@ use Stringable; use UIAwesome\Html\Attribute\HasValue; use UIAwesome\Html\Attribute\Tests\Provider\ValueProvider; -use UIAwesome\Html\Attribute\Values\Attribute; +use UIAwesome\Html\Attribute\Values\{Attribute, ElementAttribute}; use UIAwesome\Html\Helper\Attributes; use UIAwesome\Html\Mixin\HasAttributes; use UnitEnum; @@ -77,7 +77,7 @@ public function testSetValueAttributeValue( self::assertSame( $expectedValue, - $instance->getAttribute(Attribute::VALUE, ''), + $instance->getAttribute(ElementAttribute::VALUE), $message, ); self::assertSame( diff --git a/tests/Provider/AsProvider.php b/tests/Provider/AsProvider.php index fed00f5..1231c55 100644 --- a/tests/Provider/AsProvider.php +++ b/tests/Provider/AsProvider.php @@ -6,7 +6,7 @@ use PHPForge\Support\EnumDataProvider; use Stringable; -use UIAwesome\Html\Attribute\Values\{AsValue, Attribute}; +use UIAwesome\Html\Attribute\Values\{AsValue, ElementAttribute}; use UnitEnum; /** @@ -27,7 +27,7 @@ final class AsProvider */ public static function values(): array { - $enumCases = EnumDataProvider::attributeCases(AsValue::class, Attribute::AS); + $enumCases = EnumDataProvider::attributeCases(AsValue::class, ElementAttribute::AS); $stringable = new class implements Stringable { public function __toString(): string diff --git a/tests/Provider/BlockingProvider.php b/tests/Provider/BlockingProvider.php index bd14f84..48e4273 100644 --- a/tests/Provider/BlockingProvider.php +++ b/tests/Provider/BlockingProvider.php @@ -5,7 +5,7 @@ namespace UIAwesome\Html\Attribute\Tests\Provider; use PHPForge\Support\EnumDataProvider; -use UIAwesome\Html\Attribute\Values\{Attribute, Blocking}; +use UIAwesome\Html\Attribute\Values\{Blocking, ElementAttribute}; use UnitEnum; /** @@ -23,7 +23,7 @@ final class BlockingProvider */ public static function values(): array { - $enumCases = EnumDataProvider::attributeCases(Blocking::class, Attribute::BLOCKING); + $enumCases = EnumDataProvider::attributeCases(Blocking::class, ElementAttribute::BLOCKING); $staticCase = [ 'empty string' => [ diff --git a/tests/Provider/CharsetProvider.php b/tests/Provider/CharsetProvider.php index 28c57ba..1a345cf 100644 --- a/tests/Provider/CharsetProvider.php +++ b/tests/Provider/CharsetProvider.php @@ -6,7 +6,7 @@ use PHPForge\Support\EnumDataProvider; use Stringable; -use UIAwesome\Html\Attribute\Values\{Attribute, Charset}; +use UIAwesome\Html\Attribute\Values\{Charset, ElementAttribute}; use UnitEnum; /** @@ -27,7 +27,7 @@ final class CharsetProvider */ public static function values(): array { - $enumCases = EnumDataProvider::attributeCases(Charset::class, Attribute::CHARSET); + $enumCases = EnumDataProvider::attributeCases(Charset::class, ElementAttribute::CHARSET); $stringable = new class implements Stringable { public function __toString(): string diff --git a/tests/Provider/Element/AltProvider.php b/tests/Provider/Element/AltProvider.php deleted file mode 100644 index c9f5d35..0000000 --- a/tests/Provider/Element/AltProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'A descriptive alt text.'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' alt="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' alt="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'A descriptive alt text.', - ['alt' => 'A different alt text.'], - 'A descriptive alt text.', - ' alt="A descriptive alt text."', - "Should return new 'alt' after replacing the existing 'alt' attribute.", - ], - 'string' => [ - 'A descriptive alt text.', - [], - 'A descriptive alt text.', - ' alt="A descriptive alt text."', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' alt="A descriptive alt text."', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['alt' => 'A descriptive alt text.'], - null, - '', - "Should unset the 'alt' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Element/DecodingProvider.php b/tests/Provider/Element/DecodingProvider.php deleted file mode 100644 index 11bead8..0000000 --- a/tests/Provider/Element/DecodingProvider.php +++ /dev/null @@ -1,86 +0,0 @@ - - */ - public static function values(): array - { - $enumCases = EnumDataProvider::attributeCases(Decoding::class, ElementAttribute::DECODING); - - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'async'; - } - }; - - $staticCases = [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'async', - ['decoding' => 'sync'], - 'async', - ' decoding="async"', - "Should return new 'decoding' after replacing the existing 'decoding' attribute.", - ], - 'string' => [ - 'async', - [], - 'async', - ' decoding="async"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' decoding="async"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['decoding' => 'async'], - null, - '', - "Should unset the 'decoding' attribute when 'null' is provided after a value.", - ], - ]; - - return [...$staticCases, ...$enumCases]; - } -} diff --git a/tests/Provider/Element/HeightProvider.php b/tests/Provider/Element/HeightProvider.php deleted file mode 100644 index f08dbd6..0000000 --- a/tests/Provider/Element/HeightProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return '100px'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' height="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' height="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - '100px', - ['height' => '200px'], - '100px', - ' height="100px"', - "Should return new 'height' after replacing the existing 'height' attribute.", - ], - 'string' => [ - '100px', - [], - '100px', - ' height="100px"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' height="100px"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['height' => '100px'], - null, - '', - "Should unset the 'height' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Element/HrefProvider.php b/tests/Provider/Element/HrefProvider.php deleted file mode 100644 index ce29d50..0000000 --- a/tests/Provider/Element/HrefProvider.php +++ /dev/null @@ -1,109 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'https://example.com/page'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' href="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' href="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'https://example.com/new', - ['href' => 'https://example.com/old'], - 'https://example.com/new', - ' href="https://example.com/new"', - "Should return new 'href' after replacing the existing 'href' attribute.", - ], - 'string' => [ - 'https://example.com/page', - [], - 'https://example.com/page', - ' href="https://example.com/page"', - 'Should return the attribute value after setting it.', - ], - 'string with fragment identifier' => [ - '#section', - [], - '#section', - ' href="#section"', - 'Should return the attribute value after setting it.', - ], - 'string with relative path' => [ - '/about', - [], - '/about', - ' href="/about"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' href="https://example.com/page"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['href' => 'https://example.com/old'], - null, - '', - "Should unset the 'href' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Element/LoadingProvider.php b/tests/Provider/Element/LoadingProvider.php deleted file mode 100644 index a7684df..0000000 --- a/tests/Provider/Element/LoadingProvider.php +++ /dev/null @@ -1,86 +0,0 @@ - - */ - public static function values(): array - { - $enumCases = EnumDataProvider::attributeCases(Loading::class, ElementAttribute::LOADING); - - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'lazy'; - } - }; - - $staticCases = [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'lazy', - ['loading' => 'eager'], - 'lazy', - ' loading="lazy"', - "Should return new 'loading' after replacing the existing 'loading' attribute.", - ], - 'string' => [ - 'eager', - [], - 'eager', - ' loading="eager"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' loading="lazy"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['loading' => 'lazy'], - null, - '', - "Should unset the 'loading' attribute when 'null' is provided after a value.", - ], - ]; - - return [...$staticCases, ...$enumCases]; - } -} diff --git a/tests/Provider/Element/PopoverTargetActionProvider.php b/tests/Provider/Element/PopoverTargetActionProvider.php deleted file mode 100644 index 8c295aa..0000000 --- a/tests/Provider/Element/PopoverTargetActionProvider.php +++ /dev/null @@ -1,89 +0,0 @@ - - */ - public static function values(): array - { - $enumCases = EnumDataProvider::attributeCases( - PopoverTargetAction::class, - ElementAttribute::POPOVERTARGETACTION, - ); - - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'show'; - } - }; - - $staticCases = [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'show', - ['popovertargetaction' => 'hide'], - 'show', - ' popovertargetaction="show"', - "Should return new 'popovertargetaction' after replacing the existing 'popovertargetaction' attribute.", - ], - 'string' => [ - 'toggle', - [], - 'toggle', - ' popovertargetaction="toggle"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' popovertargetaction="show"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['popovertargetaction' => 'toggle'], - null, - '', - "Should unset the 'popovertargetaction' attribute when 'null' is provided after a value.", - ], - ]; - - return [...$enumCases, ...$staticCases]; - } -} diff --git a/tests/Provider/Element/PopoverTargetProvider.php b/tests/Provider/Element/PopoverTargetProvider.php deleted file mode 100644 index 0cf91d8..0000000 --- a/tests/Provider/Element/PopoverTargetProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'popover-id'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' popovertarget="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' popovertarget="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'popover-id', - ['popovertarget' => 'old-popover-id'], - 'popover-id', - ' popovertarget="popover-id"', - "Should return new 'popovertarget' after replacing the existing 'popovertarget' attribute.", - ], - 'string' => [ - 'popover-id', - [], - 'popover-id', - ' popovertarget="popover-id"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' popovertarget="popover-id"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['popovertarget' => 'popover-id'], - null, - '', - "Should unset the 'popovertarget' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Element/ReferrerpolicyProvider.php b/tests/Provider/Element/ReferrerpolicyProvider.php deleted file mode 100644 index f69b4ac..0000000 --- a/tests/Provider/Element/ReferrerpolicyProvider.php +++ /dev/null @@ -1,86 +0,0 @@ - - */ - public static function values(): array - { - $enumCases = EnumDataProvider::attributeCases(Referrerpolicy::class, ElementAttribute::REFERRERPOLICY); - - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'no-referrer'; - } - }; - - $staticCases = [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'no-referrer', - ['referrerpolicy' => 'origin'], - 'no-referrer', - ' referrerpolicy="no-referrer"', - "Should return new 'referrerpolicy' after replacing the existing 'referrerpolicy' attribute.", - ], - 'string' => [ - 'no-referrer', - [], - 'no-referrer', - ' referrerpolicy="no-referrer"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' referrerpolicy="no-referrer"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['referrerpolicy' => 'no-referrer'], - null, - '', - "Should unset the 'referrerpolicy' attribute when 'null' is provided after a value.", - ], - ]; - - return [...$staticCases, ...$enumCases]; - } -} diff --git a/tests/Provider/Element/SrcProvider.php b/tests/Provider/Element/SrcProvider.php deleted file mode 100644 index f59ae68..0000000 --- a/tests/Provider/Element/SrcProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'http://example.com/image.png'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' src="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' src="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'http://example.com/image.png', - ['src' => 'http://example.com/old-image.png'], - 'http://example.com/image.png', - ' src="http://example.com/image.png"', - "Should return new 'src' after replacing the existing 'src' attribute.", - ], - 'string' => [ - 'http://example.com/image.png', - [], - 'http://example.com/image.png', - ' src="http://example.com/image.png"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' src="http://example.com/image.png"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['src' => 'http://example.com/image.png'], - null, - '', - "Should unset the 'src' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Element/SrcsetProvider.php b/tests/Provider/Element/SrcsetProvider.php deleted file mode 100644 index e47e18b..0000000 --- a/tests/Provider/Element/SrcsetProvider.php +++ /dev/null @@ -1,102 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'small.jpg 480w, medium.jpg 800w, large.jpg 1200w'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' srcset="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' srcset="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'small.jpg 480w, medium.jpg 800w', - ['srcset' => 'old-small.jpg 480w, old-medium.jpg 800w'], - 'small.jpg 480w, medium.jpg 800w', - ' srcset="small.jpg 480w, medium.jpg 800w"', - "Should return new 'srcset' after replacing the existing 'srcset' attribute.", - ], - 'string' => [ - 'small.jpg 480w, medium.jpg 800w, large.jpg 1200w', - [], - 'small.jpg 480w, medium.jpg 800w, large.jpg 1200w', - ' srcset="small.jpg 480w, medium.jpg 800w, large.jpg 1200w"', - 'Should return the attribute value after setting it.', - ], - 'string with pixel density descriptors' => [ - 'image-1x.jpg 1x, image-2x.jpg 2x', - [], - 'image-1x.jpg 1x, image-2x.jpg 2x', - ' srcset="image-1x.jpg 1x, image-2x.jpg 2x"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' srcset="small.jpg 480w, medium.jpg 800w, large.jpg 1200w"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['srcset' => 'small.jpg 480w, medium.jpg 800w'], - null, - '', - "Should unset the 'srcset' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Element/UsemapProvider.php b/tests/Provider/Element/UsemapProvider.php deleted file mode 100644 index 921be94..0000000 --- a/tests/Provider/Element/UsemapProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return '#imagemap'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' usemap="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' usemap="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - '#new-map', - ['usemap' => '#old-map'], - '#new-map', - ' usemap="#new-map"', - "Should return new 'usemap' after replacing the existing 'usemap' attribute.", - ], - 'string' => [ - '#imagemap', - [], - '#imagemap', - ' usemap="#imagemap"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' usemap="#imagemap"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['usemap' => '#imagemap'], - null, - '', - "Should unset the 'usemap' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Element/WidthProvider.php b/tests/Provider/Element/WidthProvider.php deleted file mode 100644 index a3dd773..0000000 --- a/tests/Provider/Element/WidthProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return '100px'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' width="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' width="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - '100px', - ['width' => '200px'], - '100px', - ' width="100px"', - "Should return new 'width' after replacing the existing 'width' attribute.", - ], - 'string' => [ - '100px', - [], - '100px', - ' width="100px"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' width="100px"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['width' => '100px'], - null, - '', - "Should unset the 'width' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/AcceptProvider.php b/tests/Provider/Form/AcceptProvider.php deleted file mode 100644 index 3bd49e6..0000000 --- a/tests/Provider/Form/AcceptProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'image/*'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' accept="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' accept="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'image/*', - ['accept' => '.pdf'], - 'image/*', - ' accept="image/*"', - "Should return new 'accept' after replacing the existing 'accept' attribute.", - ], - 'string' => [ - '.pdf', - [], - '.pdf', - ' accept=".pdf"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' accept="image/*"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['accept' => 'image/*'], - null, - '', - "Should unset the 'accept' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/AutocompleteProvider.php b/tests/Provider/Form/AutocompleteProvider.php deleted file mode 100644 index bf5c64d..0000000 --- a/tests/Provider/Form/AutocompleteProvider.php +++ /dev/null @@ -1,86 +0,0 @@ - - */ - public static function values(): array - { - $enumCases = EnumDataProvider::attributeCases(Autocomplete::class, Attribute::AUTOCOMPLETE); - - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'email'; - } - }; - - $staticCases = [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'on', - ['autocomplete' => 'email'], - 'on', - ' autocomplete="on"', - "Should return new 'autocomplete' after replacing the existing 'autocomplete' attribute.", - ], - 'string' => [ - 'on', - [], - 'on', - ' autocomplete="on"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' autocomplete="email"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['autocomplete' => 'on'], - null, - '', - "Should unset the 'autocomplete' attribute when 'null' is provided after a value.", - ], - ]; - - return [...$enumCases, ...$staticCases]; - } -} diff --git a/tests/Provider/Form/CheckedProvider.php b/tests/Provider/Form/CheckedProvider.php deleted file mode 100644 index 66d08b7..0000000 --- a/tests/Provider/Form/CheckedProvider.php +++ /dev/null @@ -1,60 +0,0 @@ - - */ - public static function values(): array - { - return [ - 'boolean false' => [ - false, - [], - false, - '', - 'Should return the attribute value after setting it.', - ], - 'boolean true' => [ - true, - [], - true, - ' checked', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - true, - ['checked' => false], - true, - ' checked', - "Should return new 'checked' after replacing the existing 'checked' attribute.", - ], - 'unset with null' => [ - null, - ['checked' => true], - null, - '', - "Should unset the 'checked' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/DirnameProvider.php b/tests/Provider/Form/DirnameProvider.php deleted file mode 100644 index a596871..0000000 --- a/tests/Provider/Form/DirnameProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'comment-dir'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' dirname="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' dirname="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'comment-dir', - ['dirname' => 'text-direction'], - 'comment-dir', - ' dirname="comment-dir"', - "Should return new 'dirname' after replacing the existing 'dirname' attribute.", - ], - 'string' => [ - 'text-direction', - [], - 'text-direction', - ' dirname="text-direction"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' dirname="comment-dir"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['dirname' => 'comment-dir'], - null, - '', - "Should unset the 'dirname' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/FormProvider.php b/tests/Provider/Form/FormProvider.php deleted file mode 100644 index 23c10d6..0000000 --- a/tests/Provider/Form/FormProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'form-id'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' form="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' form="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'string' => [ - 'myForm', - [], - 'myForm', - ' form="myForm"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' form="form-id"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'replace existing' => [ - 'myForm', - ['form' => 'oldForm'], - 'myForm', - ' form="myForm"', - "Should return new 'form' after replacing the existing 'form' attribute.", - ], - 'unset with null' => [ - null, - ['form' => 'myForm'], - null, - '', - "Should unset the 'form' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/ListProvider.php b/tests/Provider/Form/ListProvider.php deleted file mode 100644 index 33111b0..0000000 --- a/tests/Provider/Form/ListProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'suggestions'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' list="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' list="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'suggestions', - ['list' => 'oldList'], - 'suggestions', - ' list="suggestions"', - "Should return new 'list' after replacing the existing 'list' attribute.", - ], - 'string' => [ - 'suggestions', - [], - 'suggestions', - ' list="suggestions"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' list="suggestions"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['list' => 'suggestions'], - null, - '', - "Should unset the 'list' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/MaxProvider.php b/tests/Provider/Form/MaxProvider.php deleted file mode 100644 index 4646a4c..0000000 --- a/tests/Provider/Form/MaxProvider.php +++ /dev/null @@ -1,109 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return '2024-01-01'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' max="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' max="value"', - 'Should return the attribute value after setting it.', - ], - 'float' => [ - 3.14, - [], - 3.14, - ' max="3.14"', - 'Should return the attribute value after setting it.', - ], - 'integer' => [ - 10, - [], - 10, - ' max="10"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 10, - ['max' => 5], - 10, - ' max="10"', - "Should return new 'max' after replacing the existing 'max' attribute.", - ], - 'string' => [ - '2024-01-01', - [], - '2024-01-01', - ' max="2024-01-01"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' max="2024-01-01"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['max' => 10], - null, - '', - "Should unset the 'max' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/MaxlengthProvider.php b/tests/Provider/Form/MaxlengthProvider.php deleted file mode 100644 index 6c0dd6c..0000000 --- a/tests/Provider/Form/MaxlengthProvider.php +++ /dev/null @@ -1,134 +0,0 @@ - - */ - public static function invalidValues(): array - { - return [ - 'enum backed string' => [ - BackedString::VALUE, - ], - 'integer negative less than -1' => [ - -1, - ], - 'string float' => [ - '5.5', - ], - 'string negative less than -1' => [ - '-1', - ], - 'string non-numeric' => [ - 'invalid', - ], - 'stringable negative less than -1' => [ - new class implements Stringable { - public function __toString(): string - { - return '-10'; - } - }, - ], - ]; - } - - /** - * @phpstan-return array< - * string, - * array{int|string|Stringable|UnitEnum|null, mixed[], int|string|Stringable|UnitEnum|null, string, string}, - * > - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return '150'; - } - }; - - return [ - 'enum backed integer' => [ - BackedInteger::VALUE, - [], - 1, - ' maxlength="1"', - 'Should return the attribute value after setting it.', - ], - 'integer' => [ - 50, - [], - 50, - ' maxlength="50"', - 'Should return the attribute value after setting it.', - ], - 'integer zero' => [ - 0, - [], - 0, - ' maxlength="0"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 50, - ['maxlength' => 100], - 50, - ' maxlength="50"', - "Should return new 'maxlength' after replacing the existing 'maxlength' attribute.", - ], - 'string' => [ - '150', - [], - '150', - ' maxlength="150"', - 'Should return the attribute value after setting it.', - ], - 'string zero' => [ - '0', - [], - '0', - ' maxlength="0"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' maxlength="150"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['maxlength' => 50], - null, - '', - "Should unset the 'maxlength' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/MinProvider.php b/tests/Provider/Form/MinProvider.php deleted file mode 100644 index eb19aab..0000000 --- a/tests/Provider/Form/MinProvider.php +++ /dev/null @@ -1,109 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return '2024-01-01'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' min="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' min="value"', - 'Should return the attribute value after setting it.', - ], - 'float' => [ - 1.5, - [], - 1.5, - ' min="1.5"', - 'Should return the attribute value after setting it.', - ], - 'integer' => [ - 0, - [], - 0, - ' min="0"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 10, - ['min' => 5], - 10, - ' min="10"', - "Should return new 'min' after replacing the existing 'min' attribute.", - ], - 'string' => [ - '08:00', - [], - '08:00', - ' min="08:00"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' min="2024-01-01"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['min' => 10], - null, - '', - "Should unset the 'min' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/MinlengthProvider.php b/tests/Provider/Form/MinlengthProvider.php deleted file mode 100644 index 3ab6514..0000000 --- a/tests/Provider/Form/MinlengthProvider.php +++ /dev/null @@ -1,134 +0,0 @@ - - */ - public static function invalidValues(): array - { - return [ - 'enum backed string' => [ - BackedString::VALUE, - ], - 'integer negative less than -1' => [ - -1, - ], - 'string float' => [ - '5.5', - ], - 'string negative less than -1' => [ - '-1', - ], - 'string non-numeric' => [ - 'invalid', - ], - 'stringable negative less than -1' => [ - new class implements Stringable { - public function __toString(): string - { - return '-10'; - } - }, - ], - ]; - } - - /** - * @phpstan-return array< - * string, - * array{int|string|Stringable|UnitEnum|null, mixed[], int|string|Stringable|UnitEnum|null, string, string}, - * > - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return '150'; - } - }; - - return [ - 'enum backed integer' => [ - BackedInteger::VALUE, - [], - 1, - ' minlength="1"', - 'Should return the attribute value after setting it.', - ], - 'integer' => [ - 50, - [], - 50, - ' minlength="50"', - 'Should return the attribute value after setting it.', - ], - 'integer zero' => [ - 0, - [], - 0, - ' minlength="0"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 10, - ['minlength' => 5], - 10, - ' minlength="10"', - "Should return new 'minlength' after replacing the existing 'minlength' attribute.", - ], - 'string' => [ - '150', - [], - '150', - ' minlength="150"', - 'Should return the attribute value after setting it.', - ], - 'string zero' => [ - '0', - [], - '0', - ' minlength="0"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' minlength="150"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['minlength' => 8], - null, - '', - "Should unset the 'minlength' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/MultipleProvider.php b/tests/Provider/Form/MultipleProvider.php deleted file mode 100644 index 3415668..0000000 --- a/tests/Provider/Form/MultipleProvider.php +++ /dev/null @@ -1,60 +0,0 @@ - - */ - public static function values(): array - { - return [ - 'boolean false' => [ - false, - [], - false, - '', - 'Should return the attribute value after setting it.', - ], - 'boolean true' => [ - true, - [], - true, - ' multiple', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - true, - ['multiple' => false], - true, - ' multiple', - "Should return new 'multiple' after replacing the existing 'multiple' attribute.", - ], - 'unset with null' => [ - null, - ['multiple' => true], - null, - '', - "Should unset the 'multiple' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/PatternProvider.php b/tests/Provider/Form/PatternProvider.php deleted file mode 100644 index 2b77202..0000000 --- a/tests/Provider/Form/PatternProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return '[a-zA-Z]*'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return empty when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' pattern="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' pattern="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - '[0-9]{3}', - ['pattern' => '[a-z]+'], - '[0-9]{3}', - " pattern='[0-9]{3}'", - "Should return new 'pattern' after replacing the existing 'pattern' attribute.", - ], - 'string' => [ - '[0-9]+', - [], - '[0-9]+', - " pattern='[0-9]+'", - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - " pattern='[a-zA-Z]*'", - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['pattern' => '[0-9]+'], - null, - '', - "Should unset the 'pattern' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/PlaceholderProvider.php b/tests/Provider/Form/PlaceholderProvider.php deleted file mode 100644 index 3b02854..0000000 --- a/tests/Provider/Form/PlaceholderProvider.php +++ /dev/null @@ -1,95 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'Hint message'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return empty when setting an empty string.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' placeholder="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' placeholder="value"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 'Enter text', - ['placeholder' => 'Hint message'], - 'Enter text', - ' placeholder="Enter text"', - "Should return new 'placeholder' after replacing the existing 'placeholder' attribute.", - ], - 'string' => [ - 'Enter text', - [], - 'Enter text', - ' placeholder="Enter text"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' placeholder="Hint message"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['placeholder' => 'Enter text'], - null, - '', - "Should unset the 'placeholder' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/ReadonlyProvider.php b/tests/Provider/Form/ReadonlyProvider.php deleted file mode 100644 index 19745bb..0000000 --- a/tests/Provider/Form/ReadonlyProvider.php +++ /dev/null @@ -1,60 +0,0 @@ - - */ - public static function values(): array - { - return [ - 'boolean false' => [ - false, - [], - false, - '', - 'Should return the attribute value after setting it.', - ], - 'boolean true' => [ - true, - [], - true, - ' readonly', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - true, - ['readonly' => false], - true, - ' readonly', - "Should return new 'readonly' after replacing the existing 'readonly' attribute.", - ], - 'unset with null' => [ - null, - ['readonly' => true], - null, - '', - "Should unset the 'readonly' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/RequiredProvider.php b/tests/Provider/Form/RequiredProvider.php deleted file mode 100644 index 5c44dcb..0000000 --- a/tests/Provider/Form/RequiredProvider.php +++ /dev/null @@ -1,60 +0,0 @@ - - */ - public static function values(): array - { - return [ - 'boolean false' => [ - false, - [], - false, - '', - 'Should return the attribute value after setting it.', - ], - 'boolean true' => [ - true, - [], - true, - ' required', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - true, - ['required' => false], - true, - ' required', - "Should return new 'required' after replacing the existing 'required' attribute.", - ], - 'unset with null' => [ - null, - ['required' => true], - null, - '', - "Should unset the 'required' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/SizeProvider.php b/tests/Provider/Form/SizeProvider.php deleted file mode 100644 index 129834f..0000000 --- a/tests/Provider/Form/SizeProvider.php +++ /dev/null @@ -1,88 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return '12'; - } - }; - - return [ - 'enum backed integer' => [ - BackedInteger::VALUE, - [], - 1, - ' size="1"', - 'Should return the attribute value after setting it.', - ], - 'integer' => [ - 10, - [], - 10, - ' size="10"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 20, - ['size' => 10], - 20, - ' size="20"', - "Should return new 'size' after replacing the existing 'size' attribute.", - ], - 'string' => [ - '15', - [], - '15', - ' size="15"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' size="12"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['size' => 10], - null, - '', - "Should unset the 'size' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Form/StepProvider.php b/tests/Provider/Form/StepProvider.php deleted file mode 100644 index 123436b..0000000 --- a/tests/Provider/Form/StepProvider.php +++ /dev/null @@ -1,116 +0,0 @@ - - */ - public static function values(): array - { - $stringable = new class implements Stringable { - public function __toString(): string - { - return 'any'; - } - }; - - return [ - 'empty string' => [ - '', - [], - '', - '', - 'Should return an empty string when setting an empty string.', - ], - 'enum backed integer' => [ - BackedInteger::VALUE, - [], - BackedInteger::VALUE, - ' step="1"', - 'Should return the attribute value after setting it.', - ], - 'enum backed string' => [ - BackedString::VALUE, - [], - BackedString::VALUE, - ' step="value"', - 'Should return the attribute value after setting it.', - ], - 'enum unit' => [ - Unit::value, - [], - Unit::value, - ' step="value"', - 'Should return the attribute value after setting it.', - ], - 'float' => [ - 0.5, - [], - 0.5, - ' step="0.5"', - 'Should return the attribute value after setting it.', - ], - 'integer' => [ - 1, - [], - 1, - ' step="1"', - 'Should return the attribute value after setting it.', - ], - 'null' => [ - null, - [], - null, - '', - "Should return an empty string when the attribute is set to 'null'.", - ], - 'replace existing' => [ - 1, - ['step' => 0.5], - 1, - ' step="1"', - "Should return new 'step' after replacing the existing 'step' attribute.", - ], - 'string' => [ - 'any', - [], - 'any', - ' step="any"', - 'Should return the attribute value after setting it.', - ], - 'stringable' => [ - $stringable, - [], - $stringable, - ' step="any"', - 'Should return the attribute value after setting it with a Stringable instance.', - ], - 'unset with null' => [ - null, - ['step' => 1], - null, - '', - "Should unset the 'step' attribute when 'null' is provided after a value.", - ], - ]; - } -} diff --git a/tests/Provider/Global/AriaProvider.php b/tests/Provider/Global/AriaProvider.php index 58ebb15..0c65fc7 100644 --- a/tests/Provider/Global/AriaProvider.php +++ b/tests/Provider/Global/AriaProvider.php @@ -269,7 +269,7 @@ public function __toString(): string 'closure with null' => [ 'aria-label', static fn(): string|null => null, - ['aria-label' => null], + [], 'Should return the attribute value after setting it.', ], 'closure with string' => [ @@ -335,7 +335,7 @@ public function __toString(): string 'unset with null' => [ 'aria-label', null, - ['aria-label' => null], + [], "Should unset the 'aria-label' attribute when 'null' is provided after a value.", ], 'without prefix' => [ @@ -417,7 +417,7 @@ public function __toString(): string ], 'closure with null' => [ ['aria-label' => static fn(): string|null => null], - ['aria-label' => null], + [], 'Should return the attribute value after setting it.', ], 'closure with string' => [ @@ -473,7 +473,7 @@ public function __toString(): string ], 'unset with null' => [ ['aria-label' => null], - ['aria-label' => null], + [], "Should unset the 'aria-label' attribute when 'null' is provided after a value.", ], 'without prefix' => [ diff --git a/tests/Provider/Global/ClassProvider.php b/tests/Provider/Global/ClassProvider.php index c526901..cea0f26 100644 --- a/tests/Provider/Global/ClassProvider.php +++ b/tests/Provider/Global/ClassProvider.php @@ -21,7 +21,7 @@ final class ClassProvider /** * @phpstan-return array< * string, - * array{array, string, string, string} + * array{array, string|null, string, string} * > */ public static function values(): array @@ -38,7 +38,7 @@ public static function values(): array ], 'empty string' => [ [['value' => '']], - '', + null, '', 'Should return an empty string when setting an empty string.', ], @@ -63,7 +63,7 @@ public static function values(): array ], 'null' => [ [['value' => null]], - '', + null, '', "Should return an empty string when the attribute is set to 'null'.", ], @@ -105,7 +105,7 @@ public function __toString(): string ['value' => 'class-one'], ['value' => null], ], - '', + null, '', "Should unset the 'class' attribute when 'null' is provided after a value.", ], diff --git a/tests/Provider/Global/DataProvider.php b/tests/Provider/Global/DataProvider.php index abcf234..76f672d 100644 --- a/tests/Provider/Global/DataProvider.php +++ b/tests/Provider/Global/DataProvider.php @@ -269,7 +269,7 @@ public function __toString(): string 'closure with null' => [ 'data-value', static fn(): string|null => null, - ['data-value' => null], + [], 'Should return the attribute value after setting it.', ], 'closure with string' => [ @@ -329,7 +329,7 @@ public function __toString(): string 'unset with null' => [ 'data-value', null, - ['data-value' => null], + [], "Should unset the 'data-value' attribute when 'null' is provided after a value.", ], 'without prefix' => [ @@ -411,7 +411,7 @@ public function __toString(): string ], 'closure with null' => [ ['data-value' => static fn(): string|null => null], - ['data-value' => null], + [], 'Should return the attribute value after setting it.', ], 'closure with string' => [ @@ -467,7 +467,7 @@ public function __toString(): string ], 'unset with null' => [ ['data-value' => null], - ['data-value' => null], + [], "Should unset the 'data-value' attribute when 'null' is provided after a value.", ], 'without prefix' => [ diff --git a/tests/Provider/Global/EventProvider.php b/tests/Provider/Global/EventProvider.php index c189a88..49d18eb 100644 --- a/tests/Provider/Global/EventProvider.php +++ b/tests/Provider/Global/EventProvider.php @@ -227,7 +227,7 @@ public function __toString(): string 'closure with null' => [ 'onclick', static fn() => null, - ['onclick' => null], + [], 'Should unset the attribute when closure returns null.', ], 'closure with string' => [ @@ -269,7 +269,7 @@ public function __toString(): string 'unset with null' => [ 'onclick', null, - ['onclick' => null], + [], 'Should unset the attribute when null is provided.', ], 'without prefix' => [ @@ -312,7 +312,7 @@ public function __toString(): string ], 'closure with null' => [ ['onclick' => static fn() => null], - ['onclick' => null], + [], 'Should unset the attribute when closure returns null.', ], 'closure with string' => [ @@ -355,7 +355,7 @@ public function __toString(): string ], 'unset with null' => [ ['onclick' => null], - ['onclick' => null], + [], 'Should unset the attribute when null is provided.', ], 'without prefix' => [ diff --git a/tests/Provider/HttpEquivProvider.php b/tests/Provider/HttpEquivProvider.php index e274ad7..ce7442c 100644 --- a/tests/Provider/HttpEquivProvider.php +++ b/tests/Provider/HttpEquivProvider.php @@ -6,7 +6,7 @@ use PHPForge\Support\EnumDataProvider; use Stringable; -use UIAwesome\Html\Attribute\Values\{Attribute, HttpEquiv}; +use UIAwesome\Html\Attribute\Values\{ElementAttribute, HttpEquiv}; use UnitEnum; /** @@ -27,7 +27,7 @@ final class HttpEquivProvider */ public static function values(): array { - $enumCases = EnumDataProvider::attributeCases(HttpEquiv::class, Attribute::HTTP_EQUIV); + $enumCases = EnumDataProvider::attributeCases(HttpEquiv::class, ElementAttribute::HTTP_EQUIV); $stringable = new class implements Stringable { public function __toString(): string diff --git a/tests/Provider/ImagesizesProvider.php b/tests/Provider/ImageSizesProvider.php similarity index 98% rename from tests/Provider/ImagesizesProvider.php rename to tests/Provider/ImageSizesProvider.php index 0209f44..ca7a104 100644 --- a/tests/Provider/ImagesizesProvider.php +++ b/tests/Provider/ImageSizesProvider.php @@ -9,14 +9,14 @@ use UnitEnum; /** - * Data provider for {@see \UIAwesome\Html\Attribute\Tests\HasImagesizesTest} test cases. + * Data provider for {@see \UIAwesome\Html\Attribute\Tests\HasImageSizesTest} test cases. * * Provides representative input/output pairs for the `imagesizes` attribute. * * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -final class ImagesizesProvider +final class ImageSizesProvider { /** * @phpstan-return array< diff --git a/tests/Provider/ImagesrcsetProvider.php b/tests/Provider/ImageSrcSetProvider.php similarity index 98% rename from tests/Provider/ImagesrcsetProvider.php rename to tests/Provider/ImageSrcSetProvider.php index b3833d0..3bb3b6a 100644 --- a/tests/Provider/ImagesrcsetProvider.php +++ b/tests/Provider/ImageSrcSetProvider.php @@ -9,14 +9,14 @@ use UnitEnum; /** - * Data provider for {@see \UIAwesome\Html\Attribute\Tests\HasImagesrcsetTest} test cases. + * Data provider for {@see \UIAwesome\Html\Attribute\Tests\HasImageSrcSetTest} test cases. * * Provides representative input/output pairs for the `imagesrcset` attribute. * * @copyright Copyright (C) 2026 Terabytesoftw. * @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License. */ -final class ImagesrcsetProvider +final class ImageSrcSetProvider { /** * @phpstan-return array< diff --git a/tests/Provider/NameProvider.php b/tests/Provider/NameProvider.php index bde7d91..ea015c4 100644 --- a/tests/Provider/NameProvider.php +++ b/tests/Provider/NameProvider.php @@ -6,7 +6,7 @@ use PHPForge\Support\EnumDataProvider; use Stringable; -use UIAwesome\Html\Attribute\Values\{Attribute, MetaName}; +use UIAwesome\Html\Attribute\Values\{ElementAttribute, MetaName}; use UnitEnum; /** @@ -27,7 +27,7 @@ final class NameProvider */ public static function values(): array { - $enumCases = EnumDataProvider::attributeCases(MetaName::class, Attribute::NAME); + $enumCases = EnumDataProvider::attributeCases(MetaName::class, ElementAttribute::NAME); $stringable = new class implements Stringable { public function __toString(): string