diff --git a/.github/workflows/bc.yml b/.github/workflows/bc.yml index 42610fd8..a05ad83e 100644 --- a/.github/workflows/bc.yml +++ b/.github/workflows/bc.yml @@ -8,7 +8,7 @@ on: - '.gitattributes' - 'infection.json.dist' - 'phpunit.xml.dist' - - 'psalm.xml' + - 'phpstan.neon' push: branches: ['master'] paths-ignore: @@ -19,7 +19,7 @@ on: - '.gitattributes' - 'infection.json.dist' - 'phpunit.xml.dist' - - 'psalm.xml' + - 'phpstan.neon' name: backwards compatibility diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3ba58fe9..d70dead8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,7 +7,7 @@ on: - '.gitignore' - '.gitattributes' - 'infection.json.dist' - - 'psalm.xml' + - 'phpstan.neon' push: branches: ['master'] @@ -18,7 +18,7 @@ on: - '.gitignore' - '.gitattributes' - 'infection.json.dist' - - 'psalm.xml' + - 'phpstan.neon' name: build diff --git a/.github/workflows/mutation.yml b/.github/workflows/mutation.yml index a8e676ed..ef8f697a 100644 --- a/.github/workflows/mutation.yml +++ b/.github/workflows/mutation.yml @@ -6,7 +6,7 @@ on: - 'CHANGELOG.md' - '.gitignore' - '.gitattributes' - - 'psalm.xml' + - 'phpstan.neon' push: branches: [ 'master' ] @@ -16,7 +16,7 @@ on: - 'CHANGELOG.md' - '.gitignore' - '.gitattributes' - - 'psalm.xml' + - 'phpstan.neon' name: mutation test diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index b4b83b4d..883187fd 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -26,10 +26,10 @@ permissions: contents: read jobs: - psalm: - uses: yiisoft/actions/.github/workflows/psalm.yml@master + phpstan: + uses: yiisoft/actions/.github/workflows/phpstan.yml@master with: os: >- ['ubuntu-latest'] php: >- - ['8.1', '8.2', '8.3', '8.4'] + ['8.1', '8.2', '8.3', '8.4', '8.5'] diff --git a/CHANGELOG.md b/CHANGELOG.md index 242aaa89..980be35b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - New #278: Add dedicated classes for missing HTML tags (@Mister-42) - New #279: Add support for conditional CSS classes in `Html::addCssClass()` (@Mister-42) +- Chg #289: Replace Psalm with PHPStan (@vjik) ## 4.2.0 June 05, 2026 diff --git a/README.md b/README.md index 3e84b860..afceccc1 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,6 @@ [![Code Coverage](https://codecov.io/gh/yiisoft/html/branch/master/graph/badge.svg)](https://codecov.io/gh/yiisoft/html) [![Mutation testing badge](https://img.shields.io/endpoint?style=flat&url=https%3A%2F%2Fbadge-api.stryker-mutator.io%2Fgithub.com%2Fyiisoft%2Fhtml%2Fmaster)](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/html/master) [![static analysis](https://github.com/yiisoft/html/workflows/static%20analysis/badge.svg)](https://github.com/yiisoft/html/actions?query=workflow%3A%22static+analysis%22) -[![psalm-level](https://shepherd.dev/github/yiisoft/html/level.svg)](https://shepherd.dev/github/yiisoft/html) -[![type-coverage](https://shepherd.dev/github/yiisoft/html/coverage.svg)](https://shepherd.dev/github/yiisoft/html) The package provides various tools to help with dynamic server-side generation of HTML: diff --git a/composer.json b/composer.json index 543dc086..b8694a58 100644 --- a/composer.json +++ b/composer.json @@ -33,11 +33,11 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^3.90", "infection/infection": "^0.27.11 || ^0.32", + "phpstan/phpstan": "^2.3", "phpunit/phpunit": "^10.5.46", "rector/rector": "^2.0.17", "shipmonk/composer-dependency-analyser": "^1.8", - "spatie/phpunit-watcher": "^1.24", - "vimeo/psalm": "^5.26.1 || ^6.12" + "spatie/phpunit-watcher": "^1.24" }, "autoload": { "psr-4": { @@ -58,6 +58,7 @@ }, "scripts": { "dependency-analyser": "composer-dependency-analyser", + "phpstan": "phpstan", "test": "phpunit --testdox --no-interaction", "test-watch": "phpunit-watcher watch", "cs-fix": "php-cs-fixer fix", diff --git a/docs/internals.md b/docs/internals.md index f4864398..fc975a4d 100644 --- a/docs/internals.md +++ b/docs/internals.md @@ -18,10 +18,10 @@ The package tests are checked with [Infection](https://infection.github.io/) mut ## Static analysis -The code is statically analyzed with [Psalm](https://psalm.dev/). To run static analysis: +The code is statically analyzed with [PHPStan](https://phpstan.org/). To run static analysis: ```shell -./vendor/bin/psalm +./vendor/bin/phpstan ``` ## Code style diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 00000000..3e47faf9 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + level: max + treatPhpDocTypesAsCertain: false + paths: + - src diff --git a/psalm.xml b/psalm.xml deleted file mode 100644 index e051b468..00000000 --- a/psalm.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/Html.php b/src/Html.php index d833a986..7629734b 100644 --- a/src/Html.php +++ b/src/Html.php @@ -173,9 +173,7 @@ final class Html * * @param string $prefix Prefix to prepend to the generated ID. * - * @return string Autogenerated ID. - * - * @psalm-return non-empty-string + * @return non-empty-string Autogenerated ID. * * @see https://github.com/yiisoft/html/blob/master/docs/testing-id-generation.md for controlling ID generation in * tests. @@ -201,6 +199,7 @@ public static function generateId(string $prefix = 'i'): string public static function encode(mixed $content, bool $doubleEncode = true, string $encoding = 'UTF-8'): string { return htmlspecialchars( + // @phpstan-ignore-next-line cast.string (Any content is cast to string as is, that is the purpose of the method) (string) $content, ENT_NOQUOTES | ENT_SUBSTITUTE | ENT_HTML5, $encoding, @@ -229,6 +228,7 @@ public static function encodeUnquotedAttribute( string $encoding = 'UTF-8', ): string { $value = htmlspecialchars( + // @phpstan-ignore-next-line cast.string (Attribute values are cast to string as is) (string) $value, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5, $encoding, @@ -263,6 +263,7 @@ public static function encodeUnquotedAttribute( public static function encodeAttribute(mixed $value, bool $doubleEncode = true, string $encoding = 'UTF-8'): string { $value = htmlspecialchars( + // @phpstan-ignore-next-line cast.string (Attribute values are cast to string as is) (string) $value, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5, $encoding, @@ -289,6 +290,7 @@ public static function encodeAttribute(mixed $value, bool $doubleEncode = true, */ public static function escapeJavaScriptStringValue(mixed $value): string { + // @phpstan-ignore-next-line cast.string (JavaScript values are cast to string as is) return strtr((string) $value, [ '/' => '\/', '"' => '\"', @@ -302,11 +304,9 @@ public static function escapeJavaScriptStringValue(mixed $value): string * * @see CustomTag * - * @param string $name The tag name. + * @param non-empty-string $name The tag name. * @param string|Stringable|int|float|null $content The tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. - * - * @psalm-param non-empty-string $name + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function tag(string $name, string|Stringable|int|float|null $content = '', array $attributes = []): CustomTag { @@ -325,11 +325,9 @@ public static function tag(string $name, string|Stringable|int|float|null $conte * * @see CustomTag * - * @param string $name The tag name. + * @param non-empty-string $name The tag name. * @param string|Stringable|int|float|null $content The tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. - * - * @psalm-param non-empty-string $name + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function normalTag(string $name, string|Stringable|int|float|null $content = '', array $attributes = []): CustomTag { @@ -348,10 +346,8 @@ public static function normalTag(string $name, string|Stringable|int|float|null * * @see CustomTag * - * @param string $name The tag name. - * @param array $attributes The tag attributes in terms of name-value pairs. - * - * @psalm-param non-empty-string $name + * @param non-empty-string $name The tag name. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function voidTag(string $name, array $attributes = []): CustomTag { @@ -368,7 +364,7 @@ public static function voidTag(string $name, array $attributes = []): CustomTag * @see self::closeTag() * * @param string $name The tag name. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function openTag(string $name, array $attributes = []): string { @@ -391,7 +387,7 @@ public static function closeTag(string $name): string * Generates a {@see Style} tag. * * @param string|Stringable $content The style content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function style(string|Stringable $content = '', array $attributes = []): Style { @@ -409,7 +405,7 @@ public static function style(string|Stringable $content = '', array $attributes * Generates a {@see Script} tag. * * @param string|Stringable $content The script content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function script(string|Stringable $content = '', array $attributes = []): Script { @@ -438,7 +434,7 @@ public static function noscript(string|Stringable|int|float|null $content = ''): * Generates a {@see Title} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function title(string|Stringable|int|float|null $content = '', array $attributes = []): Title { @@ -452,7 +448,7 @@ public static function title(string|Stringable|int|float|null $content = '', arr /** * Generates a {@see Meta} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function meta(array $attributes = []): Meta { @@ -467,7 +463,7 @@ public static function meta(array $attributes = []): Meta * Generates a {@see Link} tag. * * @param string|null $url The destination of the link. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function link(?string $url = null, array $attributes = []): Link { @@ -485,7 +481,7 @@ public static function link(?string $url = null, array $attributes = []): Link * Generates a {@see Link} tag that refers to an CSS file. * * @param string $url The URL of the CSS file. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function cssFile(string $url, array $attributes = []): Link { @@ -500,7 +496,7 @@ public static function cssFile(string $url, array $attributes = []): Link * Generates a {@see Script} tag that refers to a JavaScript file. * * @param string $url The URL of the JavaScript file. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function javaScriptFile(string $url, array $attributes = []): Script { @@ -515,7 +511,7 @@ public static function javaScriptFile(string $url, array $attributes = []): Scri * Generates a hyperlink tag. * * @param string|Stringable|int|float|null $content The tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. * * @see A */ @@ -537,7 +533,7 @@ public static function a(string|Stringable|int|float|null $content = '', ?string /** * Generates a mailto hyperlink tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. * * @see A */ @@ -557,7 +553,7 @@ public static function mailto(string|Stringable|int|float|null $content, ?string * * @param string|null $url The image URL. * @param string|null $alt Alt text. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function img(?string $url = null, ?string $alt = '', array $attributes = []): Img { @@ -577,7 +573,7 @@ public static function img(?string $url = null, ?string $alt = '', array $attrib /** * Generates a {@see Fieldset} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function fieldset(array $attributes = []): Fieldset { @@ -593,7 +589,7 @@ public static function fieldset(array $attributes = []): Fieldset * * @param string|null $action The URL to use for form submission. * @param string|null $method The method attribute value. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function form(?string $action = null, ?string $method = null, array $attributes = []): Form { @@ -633,7 +629,7 @@ public static function label(string|Stringable|int|float|null $content = '', ?st * Generates a {@see Legend} tag. * * @param string|Stringable|int|float|null $content The tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function legend(string|Stringable|int|float|null $content = '', array $attributes = []): Legend { @@ -653,7 +649,7 @@ public static function legend(string|Stringable|int|float|null $content = '', ar * @see Button::button() * * @param string|Stringable|int|float|null $content The content enclosed within the button tag. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function button(string|Stringable|int|float|null $content = 'Button', array $attributes = []): Button { @@ -670,7 +666,7 @@ public static function button(string|Stringable|int|float|null $content = 'Butto * @see Button::submit() * * @param string|Stringable|int|float|null $content The content enclosed within the button tag. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function submitButton(string|Stringable|int|float|null $content = 'Submit', array $attributes = []): Button { @@ -687,7 +683,7 @@ public static function submitButton(string|Stringable|int|float|null $content = * @see Button::reset() * * @param string|Stringable|int|float|null $content The content enclosed within the button tag. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function resetButton(string|Stringable|int|float|null $content = 'Reset', array $attributes = []): Button { @@ -705,7 +701,7 @@ public static function resetButton(string|Stringable|int|float|null $content = ' * @param string|null $name The name attribute. If it is `null`, the name attribute will not be generated. * @param bool|float|int|string|Stringable|null $value The value attribute. If it is `null`, the value * attribute will not be generated. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function input( string $type, @@ -732,7 +728,7 @@ public static function input( * @see Input::button() * * @param string|null $label The value attribute. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function buttonInput(?string $label = 'Button', array $attributes = []): Input { @@ -749,7 +745,7 @@ public static function buttonInput(?string $label = 'Button', array $attributes * @see Input::submitButton() * * @param string|null $label The value attribute. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function submitInput(?string $label = 'Submit', array $attributes = []): Input { @@ -766,7 +762,7 @@ public static function submitInput(?string $label = 'Submit', array $attributes * @see Input::resetButton() * * @param string|null $label The value attribute. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function resetInput(?string $label = 'Reset', array $attributes = []): Input { @@ -782,7 +778,7 @@ public static function resetInput(?string $label = 'Reset', array $attributes = * * @param string|null $name The name attribute. * @param bool|float|int|string|Stringable|null $value The value attribute. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function textInput( ?string $name = null, @@ -800,7 +796,7 @@ public static function textInput( * * @param string|null $name The name attribute. * @param bool|float|int|string|Stringable|null $value The value attribute. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function hiddenInput( ?string $name = null, @@ -818,7 +814,7 @@ public static function hiddenInput( * * @param string|null $name The name attribute. * @param bool|float|int|string|Stringable|null $value The value attribute. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function passwordInput( ?string $name = null, @@ -840,7 +836,7 @@ public static function passwordInput( * * @param string|null $name The name attribute. * @param bool|float|int|string|Stringable|null $value The value attribute. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function file( ?string $name = null, @@ -858,7 +854,7 @@ public static function file( * * @param string|null $name The name attribute. * @param bool|float|int|string|Stringable|null $value The value attribute. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function radio( ?string $name = null, @@ -876,7 +872,7 @@ public static function radio( * * @param string|null $name The name attribute. * @param float|int|string|Stringable|null $value The value attribute. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function range( ?string $name = null, @@ -894,7 +890,7 @@ public static function range( * * @param string|null $name The name attribute. * @param string|Stringable|null $value The value attribute. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function color( ?string $name = null, @@ -912,7 +908,7 @@ public static function color( * * @param string|null $name The name attribute. * @param bool|float|int|string|Stringable|null $value The value attribute. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function checkbox( ?string $name = null, @@ -928,7 +924,7 @@ public static function checkbox( * * @param string|null $name The input name. * @param string|string[]|Stringable|null $value The input value. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function textarea(?string $name = null, string|Stringable|array|null $value = null, array $attributes = []): Textarea { @@ -1008,7 +1004,7 @@ public static function radioList(string $name): RadioList * Generates a {@see Div} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function div(string|Stringable|int|float|null $content = '', array $attributes = []): Div { @@ -1025,7 +1021,7 @@ public static function div(string|Stringable|int|float|null $content = '', array * @param string|Stringable|int|float|null $content Tag content. If content includes HTML tags or special characters like `<`, `>`, * or `&`, and you want them to be displayed as plain text, you need to enable encoding by calling `->encode(true)`. * This ensures they are not interpreted as actual HTML. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function code(string|Stringable|int|float|null $content = '', array $attributes = []): Code { @@ -1042,7 +1038,7 @@ public static function code(string|Stringable|int|float|null $content = '', arra * @param string|Stringable|int|float|null $content Tag content. If content includes HTML tags or special characters like `<`, `>`, * or `&`, and you want them to be displayed as plain text, you need to enable encoding by calling `->encode(true)`. * This ensures they are not interpreted as actual HTML. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function pre(string|Stringable|int|float|null $content = '', array $attributes = []): Pre { @@ -1057,7 +1053,7 @@ public static function pre(string|Stringable|int|float|null $content = '', array * Generates a {@see Span} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function span(string|Stringable|int|float|null $content = '', array $attributes = []): Span { @@ -1072,7 +1068,7 @@ public static function span(string|Stringable|int|float|null $content = '', arra * Generates a {@see Em} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function em(string|Stringable|int|float|null $content = '', array $attributes = []): Em { @@ -1087,7 +1083,7 @@ public static function em(string|Stringable|int|float|null $content = '', array * Generates a {@see Strong} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function strong(string|Stringable|int|float|null $content = '', array $attributes = []): Strong { @@ -1102,7 +1098,7 @@ public static function strong(string|Stringable|int|float|null $content = '', ar * Generates a {@see Small} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function small(string|Stringable|int|float|null $content = '', array $attributes = []): Small { @@ -1117,7 +1113,7 @@ public static function small(string|Stringable|int|float|null $content = '', arr * Generates a {@see B} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function b(string|Stringable|int|float|null $content = '', array $attributes = []): B { @@ -1132,7 +1128,7 @@ public static function b(string|Stringable|int|float|null $content = '', array $ * Generates a {@see I} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function i(string|Stringable|int|float|null $content = '', array $attributes = []): I { @@ -1147,7 +1143,7 @@ public static function i(string|Stringable|int|float|null $content = '', array $ * Generates a {@see H1} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function h1(string|Stringable|int|float|null $content = '', array $attributes = []): H1 { @@ -1162,7 +1158,7 @@ public static function h1(string|Stringable|int|float|null $content = '', array * Generates a {@see H2} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function h2(string|Stringable|int|float|null $content = '', array $attributes = []): H2 { @@ -1177,7 +1173,7 @@ public static function h2(string|Stringable|int|float|null $content = '', array * Generates a {@see H3} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function h3(string|Stringable|int|float|null $content = '', array $attributes = []): H3 { @@ -1192,7 +1188,7 @@ public static function h3(string|Stringable|int|float|null $content = '', array * Generates a {@see H4} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function h4(string|Stringable|int|float|null $content = '', array $attributes = []): H4 { @@ -1207,7 +1203,7 @@ public static function h4(string|Stringable|int|float|null $content = '', array * Generates a {@see H5} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function h5(string|Stringable|int|float|null $content = '', array $attributes = []): H5 { @@ -1222,7 +1218,7 @@ public static function h5(string|Stringable|int|float|null $content = '', array * Generates a {@see H6} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function h6(string|Stringable|int|float|null $content = '', array $attributes = []): H6 { @@ -1237,7 +1233,7 @@ public static function h6(string|Stringable|int|float|null $content = '', array * Generates a {@see P} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function p(string|Stringable|int|float|null $content = '', array $attributes = []): P { @@ -1251,7 +1247,7 @@ public static function p(string|Stringable|int|float|null $content = '', array $ /** * Generates a {@see Ul} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function ul(array $attributes = []): Ul { @@ -1265,7 +1261,7 @@ public static function ul(array $attributes = []): Ul /** * Generates a {@see Ol} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function ol(array $attributes = []): Ol { @@ -1280,7 +1276,7 @@ public static function ol(array $attributes = []): Ol * Generates a {@see Li} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function li(string|Stringable|int|float|null $content = '', array $attributes = []): Li { @@ -1296,7 +1292,7 @@ public static function li(string|Stringable|int|float|null $content = '', array /** * Generates a {@see Datalist} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function datalist(array $attributes = []): Datalist { @@ -1311,7 +1307,7 @@ public static function datalist(array $attributes = []): Datalist * Generates a {@see Caption} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function caption(string|Stringable|int|float|null $content = '', array $attributes = []): Caption { @@ -1328,7 +1324,7 @@ public static function caption(string|Stringable|int|float|null $content = '', a /** * Generates a {@see Col} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function col(array $attributes = []): Col { @@ -1339,7 +1335,7 @@ public static function col(array $attributes = []): Col /** * Generates a {@see Colgroup} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function colgroup(array $attributes = []): Colgroup { @@ -1350,7 +1346,7 @@ public static function colgroup(array $attributes = []): Colgroup /** * Generates a {@see Table} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function table(array $attributes = []): Table { @@ -1361,7 +1357,7 @@ public static function table(array $attributes = []): Table /** * Generates a {@see Thead} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function thead(array $attributes = []): Thead { @@ -1372,7 +1368,7 @@ public static function thead(array $attributes = []): Thead /** * Generates a {@see Tbody} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function tbody(array $attributes = []): Tbody { @@ -1383,7 +1379,7 @@ public static function tbody(array $attributes = []): Tbody /** * Generates a {@see Tfoot} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function tfoot(array $attributes = []): Tfoot { @@ -1394,7 +1390,7 @@ public static function tfoot(array $attributes = []): Tfoot /** * Generates a {@see Tr} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function tr(array $attributes = []): Tr { @@ -1406,7 +1402,7 @@ public static function tr(array $attributes = []): Tr * Generates a {@see Td} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function td(string|Stringable|int|float|null $content = '', array $attributes = []): Td { @@ -1424,7 +1420,7 @@ public static function td(string|Stringable|int|float|null $content = '', array * Generates a {@see Th} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function th(string|Stringable|int|float|null $content = '', array $attributes = []): Th { @@ -1492,7 +1488,7 @@ public static function source(): Source * * @param string|Stringable|int|float|null $content Tag content. * @param string|null $lang The document language. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function html(string|Stringable|int|float|null $content = '', ?string $lang = null, array $attributes = []): Tag\Html { @@ -1513,7 +1509,7 @@ public static function html(string|Stringable|int|float|null $content = '', ?str * Generates a {@see Body} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function body(string|Stringable|int|float|null $content = '', array $attributes = []): Body { @@ -1528,7 +1524,7 @@ public static function body(string|Stringable|int|float|null $content = '', arra * Generates a {@see Article} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function article(string|Stringable|int|float|null $content = '', array $attributes = []): Article { @@ -1543,7 +1539,7 @@ public static function article(string|Stringable|int|float|null $content = '', a * Generates a {@see Section} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function section(string|Stringable|int|float|null $content = '', array $attributes = []): Section { @@ -1558,7 +1554,7 @@ public static function section(string|Stringable|int|float|null $content = '', a * Generates a {@see Nav} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function nav(string|Stringable|int|float|null $content = '', array $attributes = []): Nav { @@ -1573,7 +1569,7 @@ public static function nav(string|Stringable|int|float|null $content = '', array * Generates a {@see Aside} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function aside(string|Stringable|int|float|null $content = '', array $attributes = []): Aside { @@ -1588,7 +1584,7 @@ public static function aside(string|Stringable|int|float|null $content = '', arr * Generates a {@see Hgroup} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function hgroup(string|Stringable|int|float|null $content = '', array $attributes = []): Hgroup { @@ -1603,7 +1599,7 @@ public static function hgroup(string|Stringable|int|float|null $content = '', ar * Generates a {@see Header} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function header(string|Stringable|int|float|null $content = '', array $attributes = []): Header { @@ -1616,6 +1612,8 @@ public static function header(string|Stringable|int|float|null $content = '', ar /** * Generates a {@see Hr} tag. + * + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function hr(array $attributes = []): Hr { @@ -1630,7 +1628,7 @@ public static function hr(array $attributes = []): Hr * Generates a {@see Footer} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function footer(string|Stringable|int|float|null $content = '', array $attributes = []): Footer { @@ -1645,7 +1643,7 @@ public static function footer(string|Stringable|int|float|null $content = '', ar * Generates a {@see Address} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function address(string|Stringable|int|float|null $content = '', array $attributes = []): Address { @@ -1660,7 +1658,7 @@ public static function address(string|Stringable|int|float|null $content = '', a * Generates a {@see Abbr} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function abbr(string|Stringable|int|float|null $content = '', array $attributes = []): Abbr { @@ -1675,7 +1673,7 @@ public static function abbr(string|Stringable|int|float|null $content = '', arra * Generates a {@see Area} tag. * * @param string|null $alt The alternate text for the area. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function area(?string $alt = null, array $attributes = []): Area { @@ -1693,7 +1691,7 @@ public static function area(?string $alt = null, array $attributes = []): Area * Generates a {@see Base} tag. * * @param string|null $url The base URL for the document. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function base(?string $url = null, array $attributes = []): Base { @@ -1711,7 +1709,7 @@ public static function base(?string $url = null, array $attributes = []): Base * Generates a {@see Bdi} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function bdi(string|Stringable|int|float|null $content = '', array $attributes = []): Bdi { @@ -1726,7 +1724,7 @@ public static function bdi(string|Stringable|int|float|null $content = '', array * Generates a {@see Bdo} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function bdo(string|Stringable|int|float|null $content = '', array $attributes = []): Bdo { @@ -1741,7 +1739,7 @@ public static function bdo(string|Stringable|int|float|null $content = '', array * Generates a {@see Blockquote} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function blockquote(string|Stringable|int|float|null $content = '', array $attributes = []): Blockquote { @@ -1756,7 +1754,7 @@ public static function blockquote(string|Stringable|int|float|null $content = '' * Generates a {@see Canvas} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function canvas(string|Stringable|int|float|null $content = '', array $attributes = []): Canvas { @@ -1771,7 +1769,7 @@ public static function canvas(string|Stringable|int|float|null $content = '', ar * Generates a {@see Cite} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function cite(string|Stringable|int|float|null $content = '', array $attributes = []): Cite { @@ -1786,7 +1784,7 @@ public static function cite(string|Stringable|int|float|null $content = '', arra * Generates a {@see Data} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function data(string|Stringable|int|float|null $content = '', array $attributes = []): Data { @@ -1801,7 +1799,7 @@ public static function data(string|Stringable|int|float|null $content = '', arra * Generates a {@see Dd} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function dd(string|Stringable|int|float|null $content = '', array $attributes = []): Dd { @@ -1816,7 +1814,7 @@ public static function dd(string|Stringable|int|float|null $content = '', array * Generates a {@see Del} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function del(string|Stringable|int|float|null $content = '', array $attributes = []): Del { @@ -1831,7 +1829,7 @@ public static function del(string|Stringable|int|float|null $content = '', array * Generates a {@see Details} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function details(string|Stringable|int|float|null $content = '', array $attributes = []): Details { @@ -1846,7 +1844,7 @@ public static function details(string|Stringable|int|float|null $content = '', a * Generates a {@see Dfn} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function dfn(string|Stringable|int|float|null $content = '', array $attributes = []): Dfn { @@ -1861,7 +1859,7 @@ public static function dfn(string|Stringable|int|float|null $content = '', array * Generates a {@see Dialog} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function dialog(string|Stringable|int|float|null $content = '', array $attributes = []): Dialog { @@ -1876,7 +1874,7 @@ public static function dialog(string|Stringable|int|float|null $content = '', ar * Generates a {@see Dl} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function dl(string|Stringable|int|float|null $content = '', array $attributes = []): Dl { @@ -1891,7 +1889,7 @@ public static function dl(string|Stringable|int|float|null $content = '', array * Generates a {@see Dt} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function dt(string|Stringable|int|float|null $content = '', array $attributes = []): Dt { @@ -1906,7 +1904,7 @@ public static function dt(string|Stringable|int|float|null $content = '', array * Generates a {@see Embed} tag. * * @param string|null $src The URL of the embedded resource. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function embed(?string $src = null, array $attributes = []): Embed { @@ -1924,7 +1922,7 @@ public static function embed(?string $src = null, array $attributes = []): Embed * Generates a {@see Figcaption} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function figcaption(string|Stringable|int|float|null $content = '', array $attributes = []): Figcaption { @@ -1939,7 +1937,7 @@ public static function figcaption(string|Stringable|int|float|null $content = '' * Generates a {@see Figure} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function figure(string|Stringable|int|float|null $content = '', array $attributes = []): Figure { @@ -1954,7 +1952,7 @@ public static function figure(string|Stringable|int|float|null $content = '', ar * Generates a {@see Head} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function head(string|Stringable|int|float|null $content = '', array $attributes = []): Head { @@ -1969,7 +1967,7 @@ public static function head(string|Stringable|int|float|null $content = '', arra * Generates a {@see Iframe} tag. * * @param string|null $src The src attribute value. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function iframe(?string $src = null, array $attributes = []): Iframe { @@ -1987,7 +1985,7 @@ public static function iframe(?string $src = null, array $attributes = []): Ifra * Generates a {@see Ins} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function ins(string|Stringable|int|float|null $content = '', array $attributes = []): Ins { @@ -2002,7 +2000,7 @@ public static function ins(string|Stringable|int|float|null $content = '', array * Generates a {@see Kbd} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function kbd(string|Stringable|int|float|null $content = '', array $attributes = []): Kbd { @@ -2017,7 +2015,7 @@ public static function kbd(string|Stringable|int|float|null $content = '', array * Generates a {@see Main} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function main(string|Stringable|int|float|null $content = '', array $attributes = []): Main { @@ -2032,7 +2030,7 @@ public static function main(string|Stringable|int|float|null $content = '', arra * Generates a {@see Map} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function map(string|Stringable|int|float|null $content = '', array $attributes = []): Map { @@ -2047,7 +2045,7 @@ public static function map(string|Stringable|int|float|null $content = '', array * Generates a {@see Mark} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function mark(string|Stringable|int|float|null $content = '', array $attributes = []): Mark { @@ -2061,7 +2059,7 @@ public static function mark(string|Stringable|int|float|null $content = '', arra /** * Generates a {@see Menu} tag. * - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function menu(array $attributes = []): Menu { @@ -2076,7 +2074,7 @@ public static function menu(array $attributes = []): Menu * Generates a {@see Meter} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function meter(string|Stringable|int|float|null $content = '', array $attributes = []): Meter { @@ -2091,7 +2089,7 @@ public static function meter(string|Stringable|int|float|null $content = '', arr * Generates a {@see ObjectTag} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function object(string|Stringable|int|float|null $content = '', array $attributes = []): ObjectTag { @@ -2106,7 +2104,7 @@ public static function object(string|Stringable|int|float|null $content = '', ar * Generates a {@see Output} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function output(string|Stringable|int|float|null $content = '', array $attributes = []): Output { @@ -2121,7 +2119,7 @@ public static function output(string|Stringable|int|float|null $content = '', ar * Generates a {@see Progress} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function progress(string|Stringable|int|float|null $content = '', array $attributes = []): Progress { @@ -2136,7 +2134,7 @@ public static function progress(string|Stringable|int|float|null $content = '', * Generates a {@see Q} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function q(string|Stringable|int|float|null $content = '', array $attributes = []): Q { @@ -2151,7 +2149,7 @@ public static function q(string|Stringable|int|float|null $content = '', array $ * Generates a {@see Rp} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function rp(string|Stringable|int|float|null $content = '', array $attributes = []): Rp { @@ -2166,7 +2164,7 @@ public static function rp(string|Stringable|int|float|null $content = '', array * Generates a {@see Rt} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function rt(string|Stringable|int|float|null $content = '', array $attributes = []): Rt { @@ -2181,7 +2179,7 @@ public static function rt(string|Stringable|int|float|null $content = '', array * Generates a {@see Ruby} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function ruby(string|Stringable|int|float|null $content = '', array $attributes = []): Ruby { @@ -2196,7 +2194,7 @@ public static function ruby(string|Stringable|int|float|null $content = '', arra * Generates a {@see S} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function s(string|Stringable|int|float|null $content = '', array $attributes = []): S { @@ -2211,7 +2209,7 @@ public static function s(string|Stringable|int|float|null $content = '', array $ * Generates a {@see Samp} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function samp(string|Stringable|int|float|null $content = '', array $attributes = []): Samp { @@ -2226,7 +2224,7 @@ public static function samp(string|Stringable|int|float|null $content = '', arra * Generates a {@see Search} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function search(string|Stringable|int|float|null $content = '', array $attributes = []): Search { @@ -2241,7 +2239,7 @@ public static function search(string|Stringable|int|float|null $content = '', ar * Generates a {@see Slot} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function slot(string|Stringable|int|float|null $content = '', array $attributes = []): Slot { @@ -2256,7 +2254,7 @@ public static function slot(string|Stringable|int|float|null $content = '', arra * Generates a {@see Sub} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function sub(string|Stringable|int|float|null $content = '', array $attributes = []): Sub { @@ -2271,7 +2269,7 @@ public static function sub(string|Stringable|int|float|null $content = '', array * Generates a {@see Summary} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function summary(string|Stringable|int|float|null $content = '', array $attributes = []): Summary { @@ -2286,7 +2284,7 @@ public static function summary(string|Stringable|int|float|null $content = '', a * Generates a {@see Sup} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function sup(string|Stringable|int|float|null $content = '', array $attributes = []): Sup { @@ -2301,7 +2299,7 @@ public static function sup(string|Stringable|int|float|null $content = '', array * Generates a {@see Template} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function template(string|Stringable|int|float|null $content = '', array $attributes = []): Template { @@ -2316,7 +2314,7 @@ public static function template(string|Stringable|int|float|null $content = '', * Generates a {@see Time} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function time(string|Stringable|int|float|null $content = '', array $attributes = []): Time { @@ -2331,7 +2329,7 @@ public static function time(string|Stringable|int|float|null $content = '', arra * Generates a {@see U} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function u(string|Stringable|int|float|null $content = '', array $attributes = []): U { @@ -2346,7 +2344,7 @@ public static function u(string|Stringable|int|float|null $content = '', array $ * Generates a {@see VarTag} tag. * * @param string|Stringable|int|float|null $content Tag content. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. */ public static function var(string|Stringable|int|float|null $content = '', array $attributes = []): VarTag { @@ -2381,7 +2379,7 @@ public static function wbr(): Wbr * Additionally, `'data' => ['params' => ['id' => 1, 'name' => 'yii'], 'status' => 'ok']` will be rendered as: * `data-params='{"id":1,"name":"yii"}' data-status="ok"`. * - * @param array $attributes Attributes to be rendered. The attribute values will be HTML-encoded using + * @param array $attributes Attributes to be rendered. The attribute values will be HTML-encoded using * {@see encodeAttribute()}. * * @throws JsonException @@ -2403,7 +2401,7 @@ public static function renderTagAttributes(array $attributes): string } } elseif (is_array($value)) { if (in_array($name, self::DATA_ATTRIBUTES, true)) { - /** @psalm-var array $value */ + /** @var (scalar[]|string|Stringable|null)[] $value */ foreach ($value as $n => $v) { if (!isset($v)) { continue; @@ -2429,7 +2427,7 @@ public static function renderTagAttributes(array $attributes): string } $html .= self::renderAttribute($name, self::encodeAttribute(implode(' ', $value))); } elseif ($name === 'style') { - /** @psalm-var array $value */ + /** @var array $value */ if (empty($value)) { continue; } @@ -2461,12 +2459,10 @@ public static function renderTagAttributes(array $attributes): string * * @see removeCssClass() * - * @param array $attributes The attributes to be modified. All string values in the array must be valid UTF-8 + * @param array $attributes The attributes to be modified. All string values in the array must be valid UTF-8 * strings. - * @param (BackedEnum|null|bool|string)[]|BackedEnum|string|null $class The CSS class(es) to be added. Null values will + * @param BackedEnum|string|(BackedEnum|bool|string|null)[]|null $class The CSS class(es) to be added. Null values will * be ignored. When passing an array, use a boolean value to conditionally include/exclude a class by its key. - * - * @psalm-param BackedEnum|string|array|null $class */ public static function addCssClass(array &$attributes, BackedEnum|array|string|null $class): void { @@ -2511,14 +2507,14 @@ public static function addCssClass(array &$attributes, BackedEnum|array|string|n if (isset($attributes['class'])) { if (is_array($attributes['class'])) { - /** @psalm-var string[] $attributes['class'] */ + // @phpstan-ignore-next-line argument.type (The class attribute is expected to be a list of CSS classes at this point) $attributes['class'] = self::mergeCssClasses($attributes['class'], (array) $class); } else { /** - * @psalm-var string $attributes['class'] - * @var string[] $classes We assume that `$attributes['class']` is valid UTF-8 string, so `preg_split()` + * @var list $classes We assume that `$attributes['class']` is valid UTF-8 string, so `preg_split()` * never returns `false`. */ + // @phpstan-ignore-next-line argument.type (The class attribute is assumed to be a valid UTF-8 string) $classes = preg_split('/\s+/', $attributes['class'], -1, PREG_SPLIT_NO_EMPTY); $classes = self::mergeCssClasses($classes, (array) $class); $attributes['class'] = is_array($class) ? $classes : implode(' ', $classes); @@ -2533,13 +2529,14 @@ public static function addCssClass(array &$attributes, BackedEnum|array|string|n * * @see addCssClass() * - * @param array $attributes The attributes to be modified. + * @param array $attributes The attributes to be modified. * @param string|string[] $class The CSS class(es) to be removed. */ public static function removeCssClass(array &$attributes, string|array $class): void { if (isset($attributes['class'])) { if (is_array($attributes['class'])) { + // @phpstan-ignore-next-line argument.type (The class attribute is expected to contain CSS classes at this point) $classes = array_diff($attributes['class'], (array) $class); if (empty($classes)) { unset($attributes['class']); @@ -2547,7 +2544,8 @@ public static function removeCssClass(array &$attributes, string|array $class): $attributes['class'] = $classes; } } else { - /** @var string[] */ + /** @var list */ + // @phpstan-ignore-next-line cast.string (The class attribute is assumed to be a valid UTF-8 string) $classes = preg_split('/\s+/', (string) $attributes['class'], -1, PREG_SPLIT_NO_EMPTY); $classes = array_diff($classes, (array) $class); if (empty($classes)) { @@ -2574,17 +2572,16 @@ public static function removeCssClass(array &$attributes, string|array $class): * * @see removeCssStyle() * - * @param array $attributes The HTML attributes to be modified. - * @param string|string[] $style The new style string (e.g. `'width: 100px; height: 200px'`) or array + * @param array $attributes The HTML attributes to be modified. + * @param array|string $style The new style string (e.g. `'width: 100px; height: 200px'`) or array * (e.g. `['width' => '100px', 'height' => '200px']`). * @param bool $overwrite Whether to overwrite existing CSS properties if the new style contains them too. - * - * @psalm-param array|string $style */ public static function addCssStyle(array &$attributes, array|string $style, bool $overwrite = true): void { if (!empty($attributes['style'])) { - /** @psalm-var array|string $attributes['style'] */ + /** @var array $oldStyle */ + // @phpstan-ignore-next-line argument.type (The style attribute is assumed to be a CSS string here) $oldStyle = is_array($attributes['style']) ? $attributes['style'] : self::cssStyleToArray($attributes['style']); $newStyle = is_array($style) ? $style : self::cssStyleToArray($style); if (!$overwrite) { @@ -2610,14 +2607,15 @@ public static function addCssStyle(array &$attributes, array|string $style, bool * * @see addCssStyle() * - * @param array $attributes The HTML attributes to be modified. + * @param array $attributes The HTML attributes to be modified. * @param string|string[] $properties The CSS properties to be removed. You may use a string if you are removing a * single property. */ public static function removeCssStyle(array &$attributes, string|array $properties): void { if (!empty($attributes['style'])) { - /** @psalm-var array|string $attributes['style'] */ + /** @var array $style */ + // @phpstan-ignore-next-line argument.type (The style attribute is assumed to be a CSS string here) $style = is_array($attributes['style']) ? $attributes['style'] : self::cssStyleToArray($attributes['style']); foreach ((array) $properties as $property) { unset($style[$property]); @@ -2670,8 +2668,7 @@ public static function cssStyleFromArray(array $style): ?string * * @param string|Stringable $style The CSS style string. * - * @return array The array representation of the CSS style. - * @psalm-return array + * @return array The array representation of the CSS style. */ public static function cssStyleToArray(string|Stringable $style): array { @@ -2748,11 +2745,9 @@ public static function getNonArrayableName(string $name): string * This method provides the priority for named existing classes over additional. * * @param string[] $existingClasses Already existing CSS classes. - * @param null[]|string[] $additionalClasses CSS classes to be added. + * @param string[] $additionalClasses CSS classes to be added. * * @return string[] The merge result. - * - * @psalm-param array $additionalClasses */ private static function mergeCssClasses(array $existingClasses, array $additionalClasses): array { diff --git a/src/IdGenerator.php b/src/IdGenerator.php index abf38705..3d4ec3cf 100644 --- a/src/IdGenerator.php +++ b/src/IdGenerator.php @@ -17,7 +17,7 @@ final class IdGenerator public static bool $useSeed = true; /** - * @psalm-return non-empty-string + * @return non-empty-string */ public static function generate(string $prefix): string { diff --git a/src/Tag/Base/BooleanInputTag.php b/src/Tag/Base/BooleanInputTag.php index f0bc987d..a33051ef 100644 --- a/src/Tag/Base/BooleanInputTag.php +++ b/src/Tag/Base/BooleanInputTag.php @@ -15,6 +15,9 @@ abstract class BooleanInputTag extends InputTag { private ?string $uncheckValue = null; private ?string $label = null; + /** + * @var array + */ private array $labelAttributes = []; private bool $labelWrap = true; private bool $labelEncode = true; @@ -37,7 +40,7 @@ final public function checked(bool $checked = true): static * Label that is wraps around attribute when rendered. * * @param string|null $label Input label. - * @param array $attributes Name-value set of label attributes. + * @param array $attributes Name-value set of label attributes. * @param bool $wrap Whether to wrap input with label tag. If set to `false`, label will be rendered aside with * input. */ @@ -57,7 +60,7 @@ final public function label( * Label that is rendered separately and is referring input by ID. * * @param string|null $label Input label. - * @param array $attributes Name-value set of label attributes. + * @param array $attributes Name-value set of label attributes. */ final public function sideLabel(?string $label, array $attributes = []): static { @@ -158,6 +161,7 @@ abstract protected function getType(): string; private function renderUncheckInput(): string { + // @phpstan-ignore-next-line cast.string (The name attribute is expected to be a scalar or null) $name = (string) ($this->attributes['name'] ?? ''); if (empty($name) || $this->uncheckValue === null) { return ''; @@ -180,6 +184,9 @@ private function renderUncheckInput(): string return $input->render(); } + /** + * @param array $attributes + */ private function renderLabelOpenTag(array $attributes): string { if ($this->label === null) { diff --git a/src/Tag/Base/ListTag.php b/src/Tag/Base/ListTag.php index 730fec12..a78fa098 100644 --- a/src/Tag/Base/ListTag.php +++ b/src/Tag/Base/ListTag.php @@ -29,7 +29,7 @@ public function items(Li ...$items): static /** * @param (string|Stringable|int|float|null)[] $strings Array of list item contents. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. * @param bool $encode Whether to encode the item contents when rendering. */ public function strings(array $strings, array $attributes = [], bool $encode = true): static diff --git a/src/Tag/Base/MediaTag.php b/src/Tag/Base/MediaTag.php index a56d5653..3c327cf2 100644 --- a/src/Tag/Base/MediaTag.php +++ b/src/Tag/Base/MediaTag.php @@ -11,29 +11,10 @@ abstract class MediaTag extends NormalTag { use TagSourcesTrait; - /** - * @psalm-suppress MissingClassConstType - */ final public const PRELOAD_NONE = 'none'; - - /** - * @psalm-suppress MissingClassConstType - */ final public const PRELOAD_METADATA = 'metadata'; - - /** - * @psalm-suppress MissingClassConstType - */ final public const PRELOAD_AUTO = 'auto'; - - /** - * @psalm-suppress MissingClassConstType - */ final public const CROSSORIGIN_ANONYMOUS = 'anonymous'; - - /** - * @psalm-suppress MissingClassConstType - */ final public const CROSSORIGIN_CREDENTIALS = 'use-credentials'; private ?string $fallback = null; diff --git a/src/Tag/Base/Tag.php b/src/Tag/Base/Tag.php index ee4d8f8b..33ad00ca 100644 --- a/src/Tag/Base/Tag.php +++ b/src/Tag/Base/Tag.php @@ -14,6 +14,9 @@ */ abstract class Tag implements NoEncodeStringableInterface { + /** + * @var array + */ protected array $attributes = []; final public function __toString(): string @@ -25,7 +28,7 @@ final public function __toString(): string * Add a set of attributes to existing tag attributes. * Same named attributes are replaced. * - * @param array $attributes Name-value set of attributes. + * @param array $attributes Name-value set of attributes. */ final public function addAttributes(array $attributes): static { @@ -37,7 +40,7 @@ final public function addAttributes(array $attributes): static /** * Replace attributes with a new set. * - * @param array $attributes Name-value set of attributes. + * @param array $attributes Name-value set of attributes. */ final public function attributes(array $attributes): static { @@ -49,7 +52,7 @@ final public function attributes(array $attributes): static /** * Union attributes with a new set. * - * @param array $attributes Name-value set of attributes. + * @param array $attributes Name-value set of attributes. */ final public function unionAttributes(array $attributes): static { @@ -74,13 +77,10 @@ final public function attribute(string $name, mixed $value): static /** * Set tag ID. * - * @param string|null $id Non-empty tag ID. - * - * @psalm-param non-empty-string|null $id + * @param non-empty-string|null $id Non-empty tag ID. */ final public function id(?string $id): static { - /** @psalm-suppress TypeDoesNotContainType */ if ($id === '') { throw new LogicException('The tag id cannot be an empty string.'); } @@ -120,11 +120,9 @@ final public function class(BackedEnum|string|null ...$class): static * * @see Html::addCssStyle() * - * @param string|string[] $style The new style string (e.g. `'width: 100px; height: 200px'`) or array + * @param array|string $style The new style string (e.g. `'width: 100px; height: 200px'`) or array * (e.g. `['width' => '100px', 'height' => '200px']`). * @param bool $overwrite Whether to overwrite existing CSS properties if the new style contain them too. - * - * @psalm-param array|string $style */ final public function addStyle(array|string $style, bool $overwrite = true): static { diff --git a/src/Tag/Base/TagContentTrait.php b/src/Tag/Base/TagContentTrait.php index 66846ebe..d2131556 100644 --- a/src/Tag/Base/TagContentTrait.php +++ b/src/Tag/Base/TagContentTrait.php @@ -17,7 +17,7 @@ trait TagContentTrait private bool $doubleEncode = true; /** - * @psalm-var list + * @var list */ private array $content = []; diff --git a/src/Tag/CustomTag.php b/src/Tag/CustomTag.php index a7d02036..80bbbe1a 100644 --- a/src/Tag/CustomTag.php +++ b/src/Tag/CustomTag.php @@ -51,9 +51,7 @@ public function __construct( /** * Create a tag instance with the name provided. * - * @param string $name Name of the tag. - * - * @psalm-param non-empty-string $name + * @param non-empty-string $name Name of the tag. * * @deprecated Use the constructor instead. */ diff --git a/src/Tag/Fieldset.php b/src/Tag/Fieldset.php index a731e0b2..78905937 100644 --- a/src/Tag/Fieldset.php +++ b/src/Tag/Fieldset.php @@ -15,6 +15,9 @@ final class Fieldset extends NormalTag private ?Legend $legend = null; + /** + * @param array $attributes + */ public function legend(string|Stringable|null $content, array $attributes = []): self { $new = clone $this; diff --git a/src/Tag/Input/File.php b/src/Tag/Input/File.php index 986a5c4c..ebacf067 100644 --- a/src/Tag/Input/File.php +++ b/src/Tag/Input/File.php @@ -14,6 +14,9 @@ final class File extends InputTag { private ?string $uncheckValue = null; + /** + * @var array + */ private array $uncheckInputAttributes = []; public function uncheckValue(bool|float|int|string|Stringable|null $value): self @@ -23,6 +26,9 @@ public function uncheckValue(bool|float|int|string|Stringable|null $value): self return $new; } + /** + * @param array $attributes + */ public function addUncheckInputAttributes(array $attributes): self { $new = clone $this; @@ -30,6 +36,9 @@ public function addUncheckInputAttributes(array $attributes): self return $new; } + /** + * @param array $attributes + */ public function uncheckInputAttributes(array $attributes): self { $new = clone $this; @@ -79,6 +88,7 @@ private function renderUncheckInput(): string return ''; } + // @phpstan-ignore-next-line cast.string (The name attribute is expected to be a scalar or null) $name = (string) ($this->attributes['name'] ?? ''); if (empty($name)) { return ''; diff --git a/src/Tag/Input/Range.php b/src/Tag/Input/Range.php index e3d63d20..6c2d9615 100644 --- a/src/Tag/Input/Range.php +++ b/src/Tag/Input/Range.php @@ -20,13 +20,16 @@ final class Range extends InputTag private bool $showOutput = false; /** - * @psalm-var non-empty-string + * @var non-empty-string */ private string $outputTag = 'span'; + /** + * @var array + */ private array $outputAttributes = []; /** - * @psalm-var non-empty-string|null + * @var non-empty-string|null */ private ?string $outputId = null; @@ -96,6 +99,9 @@ public function outputTag(string $tagName): self return $new; } + /** + * @param array $attributes + */ public function addOutputAttributes(array $attributes): self { $new = clone $this; @@ -103,6 +109,9 @@ public function addOutputAttributes(array $attributes): self return $new; } + /** + * @param array $attributes + */ public function outputAttributes(array $attributes): self { $new = clone $this; @@ -128,16 +137,18 @@ protected function after(): string return "\n" . (new CustomTag($this->outputTag)) ->attributes($this->outputAttributes) + // @phpstan-ignore-next-line cast.string (The value attribute is expected to be a scalar or null) ->content((string) ($this->attributes['value'] ?? '-')) ->id($this->outputId) ->render(); } /** - * @psalm-assert non-empty-string $this->outputId + * @phpstan-assert non-empty-string $this->outputId */ private function fillOutputId(): void { + // @phpstan-ignore-next-line cast.string (The id attribute is expected to be a scalar or null) $id = (string) ($this->outputAttributes['id'] ?? ''); $this->outputId = $id === '' ? Html::generateId('rangeOutput') : $id; } diff --git a/src/Tag/Optgroup.php b/src/Tag/Optgroup.php index 03260112..41605152 100644 --- a/src/Tag/Optgroup.php +++ b/src/Tag/Optgroup.php @@ -14,7 +14,13 @@ */ final class Optgroup extends NormalTag { + /** + * @var Option[] + */ private array $options = []; + /** + * @var string[] + */ private array $selection = []; public function options(Option ...$options): self @@ -29,7 +35,7 @@ public function options(Option ...$options): self * * @param (string|Stringable|int|float|null)[] $data Value-content set of options. * @param bool $encode Whether to encode option content. - * @param array[] $optionsAttributes Array of option attribute sets indexed by option values from {@see $data}. + * @param array[] $optionsAttributes Array of option attribute sets indexed by option values from {@see $data}. */ public function optionsData(array $data, bool $encode = true, array $optionsAttributes = []): self { diff --git a/src/Tag/Option.php b/src/Tag/Option.php index 78382dcf..f8457fd5 100644 --- a/src/Tag/Option.php +++ b/src/Tag/Option.php @@ -58,6 +58,7 @@ public function disabled(bool $disabled = true): self public function getValue(): ?string { $value = ArrayHelper::getValue($this->attributes, 'value'); + // @phpstan-ignore-next-line cast.string (The value attribute is expected to be a scalar, Stringable or null) return $value === null ? null : (string) $value; } diff --git a/src/Tag/Select.php b/src/Tag/Select.php index 5a13e88c..9c163d55 100644 --- a/src/Tag/Select.php +++ b/src/Tag/Select.php @@ -17,7 +17,7 @@ * * @link https://www.w3.org/TR/html52/sec-forms.html#the-select-element * - * @psalm-type OptionsData = array> + * @phpstan-type OptionsData = (string|Stringable|int|float|null|(string|Stringable|int|float|null)[])[] */ final class Select extends NormalTag { @@ -46,7 +46,7 @@ public function name(?string $name): self } /** - * @psalm-param Stringable|scalar|BackedEnum|null ...$value One or more string values. + * @param Stringable|scalar|BackedEnum|null ...$value One or more string values. */ public function value(Stringable|bool|float|int|string|BackedEnum|null ...$value): self { @@ -67,7 +67,7 @@ static function (Stringable|bool|float|int|string|BackedEnum $v): string { } /** - * @psalm-param iterable $values A set of values. + * @param iterable $values A set of values. */ public function values(iterable $values): self { @@ -104,7 +104,7 @@ public function options(Option ...$options): self } /** - * @param array $data Options data. The array keys are option values, and the array values are the corresponding + * @param OptionsData $data Options data. The array keys are option values, and the array values are the corresponding * option labels. The array can also be nested (i.e. some array values are arrays too). For each sub-array, * an option group will be generated whose label is the key associated with the sub-array. * @@ -138,10 +138,8 @@ public function options(Option ...$options): self * ]; * ``` * @param bool $encode Whether option content should be HTML-encoded. - * @param array[] $optionsAttributes Array of option attribute sets indexed by option values from {@see $data}. - * @param array[] $groupsAttributes Array of group attribute sets indexed by group labels from {@see $data}. - * - * @psalm-param OptionsData $data + * @param array[] $optionsAttributes Array of option attribute sets indexed by option values from {@see $data}. + * @param array[] $groupsAttributes Array of group attribute sets indexed by group labels from {@see $data}. */ public function optionsData( array $data, @@ -248,6 +246,7 @@ public function unselectValue(bool|float|int|string|Stringable|null $value): sel protected function prepareAttributes(): void { if (!empty($this->attributes['multiple']) && !empty($this->attributes['name'])) { + // @phpstan-ignore-next-line cast.string (The name attribute is checked to be non-empty in the condition above) $this->attributes['name'] = Html::getArrayableName((string) $this->attributes['name']); } } @@ -273,6 +272,7 @@ protected function generateContent(): string protected function before(): string { + // @phpstan-ignore-next-line cast.string (The name attribute is expected to be a scalar or null) $name = (string) ($this->attributes['name'] ?? ''); if ( empty($name) diff --git a/src/Tag/Tr.php b/src/Tag/Tr.php index 9c2c1f08..34cd60f7 100644 --- a/src/Tag/Tr.php +++ b/src/Tag/Tr.php @@ -40,7 +40,7 @@ public function addCells(TableCellTag ...$cells): self /** * @param string[] $strings Array of data cells ({@see Td}) as strings. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. * @param bool $encode Whether to encode strings passed. */ public function dataStrings(array $strings, array $attributes = [], bool $encode = true): self @@ -50,7 +50,7 @@ public function dataStrings(array $strings, array $attributes = [], bool $encode /** * @param string[] $strings Array of data cells ({@see Td}) as strings. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. * @param bool $encode Whether to encode strings passed. */ public function addDataStrings(array $strings, array $attributes = [], bool $encode = true): self @@ -60,7 +60,7 @@ public function addDataStrings(array $strings, array $attributes = [], bool $enc /** * @param (string|Stringable|int|float|null)[] $strings Array of header cells ({@see Th}) contents. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. * @param bool $encode Whether to encode strings passed. */ public function headerStrings(array $strings, array $attributes = [], bool $encode = true): self @@ -70,7 +70,7 @@ public function headerStrings(array $strings, array $attributes = [], bool $enco /** * @param (string|Stringable|int|float|null)[] $strings Array of header cells ({@see Th}) contents. - * @param array $attributes The tag attributes in terms of name-value pairs. + * @param array $attributes The tag attributes in terms of name-value pairs. * @param bool $encode Whether to encode strings passed. */ public function addHeaderStrings(array $strings, array $attributes = [], bool $encode = true): self @@ -92,6 +92,7 @@ protected function getName(): string /** * @param (string|Stringable|int|float|null)[] $strings + * @param array $attributes * * @return Td[] */ @@ -108,6 +109,7 @@ private function makeDataCells(array $strings, array $attributes, bool $encode): /** * @param (string|Stringable|int|float|null)[] $strings + * @param array $attributes * * @return Th[] */ diff --git a/src/Widget/ButtonGroup.php b/src/Widget/ButtonGroup.php index 76eb0b63..02c619b6 100644 --- a/src/Widget/ButtonGroup.php +++ b/src/Widget/ButtonGroup.php @@ -18,12 +18,18 @@ final class ButtonGroup implements NoEncodeStringableInterface { private ?string $containerTag = 'div'; + /** + * @var array + */ private array $containerAttributes = []; /** * @var Button[] */ private array $buttons = []; + /** + * @var array + */ private array $buttonAttributes = []; private string $separator = "\n"; @@ -54,6 +60,9 @@ public function containerTag(?string $name): self return $new; } + /** + * @param array $attributes + */ public function containerAttributes(array $attributes): self { $new = clone $this; @@ -69,7 +78,7 @@ public function buttons(Button ...$buttons): self } /** - * @param array $data Array of buttons. Each button is an array with label as first element and additional + * @param mixed[] $data Array of buttons. Each button is an array with label as first element and additional * name-value pairs as attributes of button. * * Example: @@ -93,11 +102,15 @@ public function buttonsData(array $data, bool $encode = true): self } $label = $row[0]; unset($row[0]); + // @phpstan-ignore-next-line argument.type (The row is validated above, so remaining keys are button attributes) $buttons[] = Html::button($label, $row)->encode($encode); } return $this->buttons(...$buttons); } + /** + * @param array $attributes + */ public function addButtonAttributes(array $attributes): self { $new = clone $this; @@ -105,6 +118,9 @@ public function addButtonAttributes(array $attributes): self return $new; } + /** + * @param array $attributes + */ public function buttonAttributes(array $attributes): self { $new = clone $this; diff --git a/src/Widget/CheckboxList/CheckboxItem.php b/src/Widget/CheckboxList/CheckboxItem.php index bef558be..06225c20 100644 --- a/src/Widget/CheckboxList/CheckboxItem.php +++ b/src/Widget/CheckboxList/CheckboxItem.php @@ -8,6 +8,10 @@ final class CheckboxItem { + /** + * @param array $checkboxAttributes + * @param array $labelAttributes + */ public function __construct( public int $index, public string $name, diff --git a/src/Widget/CheckboxList/CheckboxList.php b/src/Widget/CheckboxList/CheckboxList.php index 262dc6dc..5066c2ff 100644 --- a/src/Widget/CheckboxList/CheckboxList.php +++ b/src/Widget/CheckboxList/CheckboxList.php @@ -20,19 +20,31 @@ final class CheckboxList implements NoEncodeStringableInterface { private ?string $containerTag = 'div'; + /** + * @var array + */ private array $containerAttributes = []; private ?string $checkboxWrapTag = null; + /** + * @var array + */ private array $checkboxWrapAttributes = []; + /** + * @var array + */ private array $checkboxAttributes = []; + /** + * @var array + */ private array $checkboxLabelAttributes = []; private bool $checkboxLabelWrap = true; private string|Stringable $beforeCheckbox = ''; private string|Stringable $afterCheckbox = ''; /** - * @var array[] + * @var array[] */ private array $individualInputAttributes = []; @@ -46,12 +58,12 @@ final class CheckboxList implements NoEncodeStringableInterface private array $items = []; /** - * @psalm-var list + * @var list */ private array $values = []; /** - * @psalm-var Closure(CheckboxItem):string|null + * @var (Closure(CheckboxItem): string)|null */ private ?Closure $itemFormatter = null; @@ -93,6 +105,9 @@ public function containerTag(?string $name): self return $new; } + /** + * @param array $attributes + */ public function containerAttributes(array $attributes): self { $new = clone $this; @@ -107,6 +122,9 @@ public function checkboxWrapTag(?string $name): self return $new; } + /** + * @param array $attributes + */ public function checkboxWrapAttributes(array $attributes): self { $new = clone $this; @@ -131,6 +149,9 @@ public function addCheckboxWrapClass(?string ...$class): self return $new; } + /** + * @param array $attributes + */ public function addCheckboxAttributes(array $attributes): self { $new = clone $this; @@ -138,6 +159,9 @@ public function addCheckboxAttributes(array $attributes): self return $new; } + /** + * @param array $attributes + */ public function checkboxAttributes(array $attributes): self { $new = clone $this; @@ -145,6 +169,9 @@ public function checkboxAttributes(array $attributes): self return $new; } + /** + * @param array $attributes + */ public function addCheckboxLabelAttributes(array $attributes): self { $new = clone $this; @@ -152,6 +179,9 @@ public function addCheckboxLabelAttributes(array $attributes): self return $new; } + /** + * @param array $attributes + */ public function checkboxLabelAttributes(array $attributes): self { $new = clone $this; @@ -189,6 +219,9 @@ public function afterCheckbox(string|Stringable $content): self /** * @param array[] $attributes */ + /** + * @param array[] $attributes + */ public function addIndividualInputAttributes(array $attributes): self { $new = clone $this; @@ -199,6 +232,9 @@ public function addIndividualInputAttributes(array $attributes): self /** * @param array[] $attributes */ + /** + * @param array[] $attributes + */ public function individualInputAttributes(array $attributes): self { $new = clone $this; @@ -245,7 +281,7 @@ public function value(bool|string|int|float|Stringable|BackedEnum ...$value): se } /** - * @psalm-param iterable $values + * @param iterable $values */ public function values(iterable $values): self { @@ -298,7 +334,7 @@ public function separator(string $separator): self } /** - * @psalm-param Closure(CheckboxItem):string|null $formatter + * @param (Closure(CheckboxItem): string)|null $formatter */ public function itemFormatter(?Closure $formatter): self { diff --git a/src/Widget/RadioList/RadioItem.php b/src/Widget/RadioList/RadioItem.php index 2467d874..d7b0d655 100644 --- a/src/Widget/RadioList/RadioItem.php +++ b/src/Widget/RadioList/RadioItem.php @@ -8,6 +8,10 @@ final class RadioItem { + /** + * @param array $radioAttributes + * @param array $labelAttributes + */ public function __construct( public int $index, public string $name, diff --git a/src/Widget/RadioList/RadioList.php b/src/Widget/RadioList/RadioList.php index e091ab74..44fc37f9 100644 --- a/src/Widget/RadioList/RadioList.php +++ b/src/Widget/RadioList/RadioList.php @@ -17,19 +17,31 @@ final class RadioList implements NoEncodeStringableInterface { private ?string $containerTag = 'div'; + /** + * @var array + */ private array $containerAttributes = []; private ?string $radioWrapTag = null; + /** + * @var array + */ private array $radioWrapAttributes = []; + /** + * @var array + */ private array $radioAttributes = []; + /** + * @var array + */ private array $radioLabelAttributes = []; private bool $radioLabelWrap = true; private string|Stringable $beforeRadio = ''; private string|Stringable $afterRadio = ''; /** - * @var array[] + * @var array[] */ private array $individualInputAttributes = []; @@ -45,7 +57,7 @@ final class RadioList implements NoEncodeStringableInterface private ?string $value = null; /** - * @psalm-var Closure(RadioItem):string|null + * @var (Closure(RadioItem): string)|null */ private ?Closure $itemFormatter = null; @@ -87,6 +99,9 @@ public function containerTag(?string $name): self return $new; } + /** + * @param array $attributes + */ public function containerAttributes(array $attributes): self { $new = clone $this; @@ -101,6 +116,9 @@ public function radioWrapTag(?string $name): self return $new; } + /** + * @param array $attributes + */ public function radioWrapAttributes(array $attributes): self { $new = clone $this; @@ -122,6 +140,9 @@ public function addRadioWrapClass(?string ...$class): self return $new; } + /** + * @param array $attributes + */ public function addRadioAttributes(array $attributes): self { $new = clone $this; @@ -129,6 +150,9 @@ public function addRadioAttributes(array $attributes): self return $new; } + /** + * @param array $attributes + */ public function radioAttributes(array $attributes): self { $new = clone $this; @@ -136,6 +160,9 @@ public function radioAttributes(array $attributes): self return $new; } + /** + * @param array $attributes + */ public function addRadioLabelAttributes(array $attributes): self { $new = clone $this; @@ -143,6 +170,9 @@ public function addRadioLabelAttributes(array $attributes): self return $new; } + /** + * @param array $attributes + */ public function radioLabelAttributes(array $attributes): self { $new = clone $this; @@ -180,6 +210,9 @@ public function afterRadio(string|Stringable $content): self /** * @param array[] $attributes */ + /** + * @param array[] $attributes + */ public function addIndividualInputAttributes(array $attributes): self { $new = clone $this; @@ -190,6 +223,9 @@ public function addIndividualInputAttributes(array $attributes): self /** * @param array[] $attributes */ + /** + * @param array[] $attributes + */ public function individualInputAttributes(array $attributes): self { $new = clone $this; @@ -279,7 +315,7 @@ public function separator(string $separator): self } /** - * @psalm-param Closure(RadioItem):string|null $formatter + * @param (Closure(RadioItem): string)|null $formatter */ public function itemFormatter(?Closure $formatter): self {