diff --git a/CHANGELOG.md b/CHANGELOG.md index f914019c..770e8bde 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 3.12.1 under development - New #260: Add `$attributes` parameter to `Html::li()` method (@gauravkumar2525) +- Chg #234: Remove tag attributes sorting (@FrankiFixx) - Enh #261: Enhance `RadioList::addRadioWrapClass()` method for cleaner class addition (@vjik) ## 3.12.0 December 13, 2025 diff --git a/src/Html.php b/src/Html.php index 90866126..1d1c3238 100644 --- a/src/Html.php +++ b/src/Html.php @@ -99,45 +99,6 @@ */ final class Html { - /** - * The preferred order of attributes in a tag. This mainly affects the order of the attributes that are - * rendered by {@see renderTagAttributes()}. - */ - private const ATTRIBUTE_ORDER = [ - 'type', - 'id', - 'class', - 'name', - 'value', - - 'href', - 'loading', - 'src', - 'srcset', - 'form', - 'action', - 'method', - - 'selected', - 'checked', - 'readonly', - 'disabled', - 'multiple', - - 'size', - 'maxlength', - 'minlength', - 'width', - 'height', - 'rows', - 'cols', - - 'alt', - 'title', - 'rel', - 'media', - ]; - /** * List of tag attributes that should be specially handled when their values are of array type. * In particular, if the value of the `data` attribute is `['name' => 'xyz', 'age' => 13]`, two attributes will be @@ -1674,16 +1635,6 @@ public static function address(string|Stringable $content = '', array $attribute */ public static function renderTagAttributes(array $attributes): string { - if (count($attributes) > 1) { - $sorted = []; - foreach (self::ATTRIBUTE_ORDER as $name) { - if (isset($attributes[$name])) { - $sorted[$name] = $attributes[$name]; - } - } - $attributes = array_merge($sorted, $attributes); - } - $html = ''; /** * @var string $name diff --git a/tests/HtmlTest.php b/tests/HtmlTest.php index ad94d1d3..1da7e8f8 100644 --- a/tests/HtmlTest.php +++ b/tests/HtmlTest.php @@ -135,7 +135,7 @@ public function testMeta(): void { $this->assertSame('', Html::meta()->render()); $this->assertSame( - '', + '', Html::meta(['name' => 'keywords', 'content' => 'yii', 'id' => 'main'])->render(), ); } @@ -154,15 +154,15 @@ public function testLink(): void public function testCssFile(): void { $this->assertSame( - '', + '', Html::cssFile('http://example.com')->render(), ); $this->assertSame( - '', + '', Html::cssFile('')->render(), ); $this->assertSame( - '', + '', Html::cssFile('http://example.com', ['id' => 'main'])->render(), ); } @@ -178,7 +178,7 @@ public function testJavaScriptFile(): void Html::javaScriptFile('')->render(), ); $this->assertSame( - '', + '', Html::javaScriptFile('http://example.com', ['id' => 'main'])->render(), ); } @@ -206,7 +206,7 @@ public function testMailto(): void Html::mailto('contact me', 'info@example.com')->render(), ); $this->assertSame( - 'contact me', + 'contact me', Html::mailto('contact me', 'info@example.com', ['id' => 'contact'])->render(), ); } @@ -385,15 +385,15 @@ public function testTextInput(): void public function testColorInput(): void { $this->assertSame('', Html::color()->render()); - $this->assertSame('', Html::color('')->render()); - $this->assertSame('', Html::color(null, '')->render()); - $this->assertSame('', Html::color('test')->render()); + $this->assertSame('', Html::color('')->render()); + $this->assertSame('', Html::color(null, '')->render()); + $this->assertSame('', Html::color('test')->render()); $this->assertSame( - '', + '', Html::color('test', '#ff0000')->render(), ); $this->assertSame( - '', + '', Html::color('test', '#ff0000', ['required' => true])->render(), ); } @@ -409,7 +409,7 @@ public function testHiddenInput(): void Html::hiddenInput('test', '43')->render(), ); $this->assertSame( - '', + '', Html::hiddenInput('test', '43', ['id' => 'ABC'])->render(), ); } @@ -433,15 +433,15 @@ public function testPasswordInput(): void public function testFile(): void { $this->assertSame('', Html::file()->render()); - $this->assertSame('', Html::file('')->render()); - $this->assertSame('', Html::file(null, '')->render()); - $this->assertSame('', Html::file('test')->render()); + $this->assertSame('', Html::file('')->render()); + $this->assertSame('', Html::file(null, '')->render()); + $this->assertSame('', Html::file('test')->render()); $this->assertSame( - '', + '', Html::file('test', '43')->render(), ); $this->assertSame( - '', + '', Html::file('test', '43', ['class' => 'photo'])->render(), ); } @@ -449,15 +449,15 @@ public function testFile(): void public function testRadio(): void { $this->assertSame('', Html::radio()->render()); - $this->assertSame('', Html::radio('')->render()); - $this->assertSame('', Html::radio(null, '')->render()); - $this->assertSame('', Html::radio('test')->render()); + $this->assertSame('', Html::radio('')->render()); + $this->assertSame('', Html::radio(null, '')->render()); + $this->assertSame('', Html::radio('test')->render()); $this->assertSame( - '', + '', Html::radio('test', '43')->render(), ); $this->assertSame( - '', + '', Html::radio('test', '43', ['readonly' => true])->render(), ); } @@ -465,15 +465,15 @@ public function testRadio(): void public function testCheckbox(): void { $this->assertSame('', Html::checkbox()->render()); - $this->assertSame('', Html::checkbox('')->render()); - $this->assertSame('', Html::checkbox(null, '')->render()); - $this->assertSame('', Html::checkbox('test')->render()); + $this->assertSame('', Html::checkbox('')->render()); + $this->assertSame('', Html::checkbox(null, '')->render()); + $this->assertSame('', Html::checkbox('test')->render()); $this->assertSame( - '', + '', Html::checkbox('test', '43')->render(), ); $this->assertSame( - '', + '', Html::checkbox('test', '43', ['readonly' => true])->render(), ); } @@ -481,15 +481,15 @@ public function testCheckbox(): void public function testRange(): void { $this->assertSame('', Html::range()->render()); - $this->assertSame('', Html::range('')->render()); - $this->assertSame('', Html::range(null, '')->render()); - $this->assertSame('', Html::range('test')->render()); + $this->assertSame('', Html::range('')->render()); + $this->assertSame('', Html::range(null, '')->render()); + $this->assertSame('', Html::range('test')->render()); $this->assertSame( - '', + '', Html::range('test', '43')->render(), ); $this->assertSame( - '', + '', Html::range('test', '43', ['readonly' => true])->render(), ); } @@ -532,9 +532,9 @@ public function testCheckboxList(): void $this->assertSame( '' . "\n" . '
' . "\n" - . '' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" . '
', Html::checkboxList('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) @@ -550,9 +550,9 @@ public function testRadioList(): void $this->assertSame( '' . "\n" . '
' . "\n" - . '' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" . '
', Html::radioList('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) @@ -706,7 +706,7 @@ public function testLi(): void $this->assertSame('
  • Hello
  • ', Html::li(Html::span('Hello'))->render()); $this->assertSame( - '
  • Content
  • ', + '
  • Content
  • ', Html::li('Content', ['class' => 'item', 'id' => 'item-1'])->render(), ); $this->assertSame('
  • ', Html::li(attributes: ['class' => 'empty'])->render()); @@ -857,7 +857,7 @@ public static function dataRenderTagAttributes(): array [' class="first second"', ['class' => ['first', 'second']]], ['', ['class' => []]], [' style="width: 100px; height: 200px;"', ['style' => ['width' => '100px', 'height' => '200px']]], - [' name="position" value="42"', ['value' => 42, 'name' => 'position']], + [' value="42" name="position"', ['value' => 42, 'name' => 'position']], [ ' id="x" class="a b" data-a="1" data-b="2" style="width: 100px;" any=\'[1,2]\'', [ diff --git a/tests/Tag/Base/BooleanInputTagTest.php b/tests/Tag/Base/BooleanInputTagTest.php index aaa1780c..59bf58fa 100644 --- a/tests/Tag/Base/BooleanInputTagTest.php +++ b/tests/Tag/Base/BooleanInputTagTest.php @@ -12,7 +12,7 @@ final class BooleanInputTagTest extends TestCase { public function testChecked(): void { - $this->assertSame('', (string) TestBooleanInputTag::tag()->checked()); + $this->assertSame('', (string) TestBooleanInputTag::tag()->checked()); $this->assertSame('', (string) TestBooleanInputTag::tag()->checked(false)); $this->assertSame('', (string) TestBooleanInputTag::tag() ->checked(true) @@ -64,7 +64,7 @@ public function testLabel(string $expected, ?string $label, array $attributes): public function testLabelNoWrap(): void { $this->assertSame( - ' ', + ' ', (string) TestBooleanInputTag::tag() ->id('ID') ->label('Voronezh', wrap: false), @@ -74,7 +74,7 @@ public function testLabelNoWrap(): void public function testLabelWithId(): void { $this->assertSame( - '', + '', TestBooleanInputTag::tag() ->id('Test') ->label('One') @@ -85,7 +85,7 @@ public function testLabelWithId(): void public function testSideLabel(): void { $this->assertMatchesRegularExpression( - '~ ~', + '~ ~', TestBooleanInputTag::tag() ->sideLabel('One') ->render(), @@ -95,7 +95,7 @@ public function testSideLabel(): void public function testSideLabelEmpty(): void { $this->assertMatchesRegularExpression( - '~ ~', + '~ ~', TestBooleanInputTag::tag() ->sideLabel('') ->render(), @@ -115,7 +115,7 @@ public function testSideLabelNull(): void public function testSideLabelWithId(): void { $this->assertSame( - ' ', + ' ', TestBooleanInputTag::tag() ->id('Test') ->sideLabel('One') @@ -126,7 +126,7 @@ public function testSideLabelWithId(): void public function testSideLabelWithAttributes(): void { $this->assertMatchesRegularExpression( - '~ ~', + '~ ~', TestBooleanInputTag::tag() ->sideLabel('One', ['class' => 'red']) ->render(), @@ -136,7 +136,7 @@ public function testSideLabelWithAttributes(): void public function testSideLabelId(): void { $this->assertSame( - ' ', + ' ', TestBooleanInputTag::tag() ->sideLabel('One') ->id('count') @@ -160,15 +160,15 @@ public static function dataUncheckValue(): array return [ ['', null, null], ['', null, 7], - ['', 'color', null], - ['', 'color[]', null], + ['', 'color', null], + ['', 'color[]', null], [ - '', + '', 'color', 7, ], [ - '', + '', 'color[]', 7, ], @@ -191,7 +191,7 @@ public function testUncheckValueDisabled(): void { $this->assertSame( '' - . '', + . '', TestBooleanInputTag::tag() ->name('color') ->uncheckValue(7) @@ -204,7 +204,7 @@ public function testUncheckValueForm(): void { $this->assertSame( '' - . '', + . '', TestBooleanInputTag::tag() ->name('color') ->uncheckValue(7) @@ -217,7 +217,7 @@ public function testUncheckValueWithLabel(): void { $this->assertSame( '' - . '', + . '', TestBooleanInputTag::tag() ->name('color') ->uncheckValue(7) diff --git a/tests/Tag/Base/MediaTagTest.php b/tests/Tag/Base/MediaTagTest.php index 22e7f669..f78a2a0a 100644 --- a/tests/Tag/Base/MediaTagTest.php +++ b/tests/Tag/Base/MediaTagTest.php @@ -169,9 +169,9 @@ public function testWrongTrackDefault(): void $this->assertSame( '' . "\n" - . '' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" . '', $tag->render(), ); diff --git a/tests/Tag/Base/TagTest.php b/tests/Tag/Base/TagTest.php index cd7e33e2..752af442 100644 --- a/tests/Tag/Base/TagTest.php +++ b/tests/Tag/Base/TagTest.php @@ -28,7 +28,7 @@ public static function dataAttributes(): array ['', ['class' => ['first', 'second']]], ['', ['class' => []]], ['', ['style' => ['width' => '100px', 'height' => '200px']]], - ['', ['value' => 42, 'name' => 'position']], + ['', ['value' => 42, 'name' => 'position']], [ '', [ @@ -93,7 +93,7 @@ public function testReplaceAttributes(): void public function testUnionAttributes(): void { $this->assertSame( - '', + '', TestTag::tag() ->class('red') ->unionAttributes(['class' => 'green', 'id' => 'color']) diff --git a/tests/Tag/ColgroupTest.php b/tests/Tag/ColgroupTest.php index 00242d9a..b843fe6f 100644 --- a/tests/Tag/ColgroupTest.php +++ b/tests/Tag/ColgroupTest.php @@ -16,8 +16,8 @@ public function testBase(): void $this->assertSame( '' . "\n" . '' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '', Colgroup::tag() ->columns( diff --git a/tests/Tag/FormTest.php b/tests/Tag/FormTest.php index 2db79d06..d1e2adde 100644 --- a/tests/Tag/FormTest.php +++ b/tests/Tag/FormTest.php @@ -18,7 +18,7 @@ public function testBase(): void $tag = Form::tag(); $this->assertSame( - '
    ' + '' . '' . '' . '
    ', @@ -36,7 +36,7 @@ public function testBase(): void public function testGet(): void { $this->assertSame( - '
    ', + '
    ', Form::tag() ->get('https://example.com/send') ->render(), @@ -56,7 +56,7 @@ public function testGetWithoutUrl(): void public function testPost(): void { $this->assertSame( - '
    ', + '
    ', Form::tag() ->post('https://example.com/send') ->render(), diff --git a/tests/Tag/Input/CheckboxTest.php b/tests/Tag/Input/CheckboxTest.php index abedeebb..8951beae 100644 --- a/tests/Tag/Input/CheckboxTest.php +++ b/tests/Tag/Input/CheckboxTest.php @@ -12,7 +12,7 @@ final class CheckboxTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', Checkbox::tag() ->name('number') ->value(42) diff --git a/tests/Tag/Input/ColorTest.php b/tests/Tag/Input/ColorTest.php index 576299ff..b30d761d 100644 --- a/tests/Tag/Input/ColorTest.php +++ b/tests/Tag/Input/ColorTest.php @@ -12,7 +12,7 @@ final class ColorTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', Color::tag() ->name('color') ->value('#ff0000') diff --git a/tests/Tag/Input/FileTest.php b/tests/Tag/Input/FileTest.php index 8a861031..068205a6 100644 --- a/tests/Tag/Input/FileTest.php +++ b/tests/Tag/Input/FileTest.php @@ -13,7 +13,7 @@ final class FileTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', File::tag() ->name('avatar') ->render(), @@ -25,15 +25,15 @@ public static function dataUncheckValue(): array return [ ['', null, null], ['', null, 7], - ['', 'avatar', null], - ['', 'avatar[]', null], + ['', 'avatar', null], + ['', 'avatar[]', null], [ - '', + '', 'avatar', 7, ], [ - '', + '', 'avatar[]', 7, ], @@ -56,7 +56,7 @@ public function testUncheckValueDisabled(): void { $this->assertSame( '' - . '', + . '', File::tag() ->name('avatar') ->uncheckValue(7) @@ -69,7 +69,7 @@ public function testUncheckValueForm(): void { $this->assertSame( '' - . '', + . '', File::tag() ->name('avatar') ->uncheckValue(7) @@ -89,8 +89,8 @@ public function testUncheckInputAttributes(): void ->render(); $this->assertSame( - '' - . '', + '' + . '', $result, ); } @@ -106,8 +106,8 @@ public function testReplaceUncheckInputAttributes(): void ->render(); $this->assertSame( - '' - . '', + '' + . '', $result, ); } @@ -116,11 +116,11 @@ public static function dataAccept(): array { return [ [ - '', + '', null, ], [ - '', + '', '.doc,.docx', ], ]; @@ -142,11 +142,11 @@ public static function dataMultiple(): array { return [ [ - '', + '', true, ], [ - '', + '', false, ], ]; @@ -167,7 +167,7 @@ public function testMultiple(string $expected, ?bool $multiple): void public function testMultipleDefault(): void { $this->assertSame( - '', + '', File::tag() ->name('avatar') ->multiple() diff --git a/tests/Tag/Input/RadioTest.php b/tests/Tag/Input/RadioTest.php index 134660c8..0598ee2d 100644 --- a/tests/Tag/Input/RadioTest.php +++ b/tests/Tag/Input/RadioTest.php @@ -12,7 +12,7 @@ final class RadioTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', Radio::tag() ->name('number') ->value(42) diff --git a/tests/Tag/Input/RangeTest.php b/tests/Tag/Input/RangeTest.php index 1a05ec01..249fbcc6 100644 --- a/tests/Tag/Input/RangeTest.php +++ b/tests/Tag/Input/RangeTest.php @@ -21,7 +21,7 @@ public function testBase(): void ->step(10); $this->assertSame( - '', + '', $tag->render(), ); } @@ -30,11 +30,11 @@ public static function dataMin(): array { return [ ['', null], - ['', ''], - ['', '2.5'], - ['', 10], - ['', 42.7], - ['', new StringableObject('99')], + ['', ''], + ['', '2.5'], + ['', 10], + ['', 42.7], + ['', new StringableObject('99')], ]; } @@ -50,11 +50,11 @@ public static function dataMax(): array { return [ ['', null], - ['', ''], - ['', '2.5'], - ['', 10], - ['', 42.7], - ['', new StringableObject('99')], + ['', ''], + ['', '2.5'], + ['', 10], + ['', 42.7], + ['', new StringableObject('99')], ]; } @@ -70,11 +70,11 @@ public static function dataStep(): array { return [ ['', null], - ['', ''], - ['', '2.5'], - ['', 10], - ['', 42.7], - ['', new StringableObject('99')], + ['', ''], + ['', '2.5'], + ['', 10], + ['', 42.7], + ['', new StringableObject('99')], ]; } @@ -90,7 +90,7 @@ public static function dataList(): array { return [ ['', null], - ['', 'DataList'], + ['', 'DataList'], ]; } @@ -124,7 +124,7 @@ public function testAddOutputAttributes(): void $this->assertSame( '' - . "\n" . '-', + . "\n" . '-', $tag->render(), ); } @@ -181,7 +181,7 @@ public function testOutputWithCustomAttributes(): void $this->assertMatchesRegularExpression( '~' - . "\n" . '-~', + . "\n" . '-~', $tag->render(), ); } @@ -193,7 +193,7 @@ public function testOutputWithValue(): void ->value(10); $this->assertMatchesRegularExpression( - '~' . "\n" . '10~', $tag->render(), diff --git a/tests/Tag/InputTest.php b/tests/Tag/InputTest.php index a7056eaf..af283308 100644 --- a/tests/Tag/InputTest.php +++ b/tests/Tag/InputTest.php @@ -48,7 +48,7 @@ public function testPassword(): void public function testFile(): void { $this->assertSame( - '', + '', (string) Input::file('photo', 'c:\\path\\'), ); } @@ -56,7 +56,7 @@ public function testFile(): void public function testCheckbox(): void { $this->assertSame( - '', + '', (string) Input::checkbox('subscribe')->checked(), ); } @@ -64,7 +64,7 @@ public function testCheckbox(): void public function testRadio(): void { $this->assertSame( - '', + '', (string) Input::radio('count', 'one'), ); } @@ -72,7 +72,7 @@ public function testRadio(): void public function testRange(): void { $this->assertSame( - '', + '', (string) Input::range('count', 10), ); } @@ -80,7 +80,7 @@ public function testRange(): void public function testColor(): void { $this->assertSame( - '', + '', (string) Input::color('color', '#ff0000'), ); } diff --git a/tests/Tag/LinkTest.php b/tests/Tag/LinkTest.php index 627eae64..edd45638 100644 --- a/tests/Tag/LinkTest.php +++ b/tests/Tag/LinkTest.php @@ -13,7 +13,7 @@ final class LinkTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', (string) Link::tag() ->url('/rss') ->type('application/rss+xml') @@ -25,7 +25,7 @@ public function testBase(): void public function testToCssFile(): void { $this->assertSame( - '', + '', (string) Link::toCssFile('main.css'), ); } @@ -119,8 +119,8 @@ public function testAs(string $expected, ?string $as): void public static function dataPreload(): array { return [ - ['', '/main.css'], - ['', '/main.css', 'style'], + ['', '/main.css'], + ['', '/main.css', 'style'], ]; } diff --git a/tests/Tag/PictureTest.php b/tests/Tag/PictureTest.php index f052013c..f0019941 100644 --- a/tests/Tag/PictureTest.php +++ b/tests/Tag/PictureTest.php @@ -31,8 +31,8 @@ public function testBase(): void $this->assertSame( '' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . 'Flowers' . "\n" . '', $picture->render(), diff --git a/tests/Tag/SelectTest.php b/tests/Tag/SelectTest.php index 9b4d0a40..eb30355c 100644 --- a/tests/Tag/SelectTest.php +++ b/tests/Tag/SelectTest.php @@ -35,15 +35,15 @@ public static function dataNameForMultiple(): array { return [ ['', null], - ['', ''], + ['', ''], [ '' . "\n" - . '', + . '', 'age', ], [ '' . "\n" - . '', + . '', 'place[]', ], ]; @@ -362,7 +362,7 @@ public function testOptionsAndGroupsAttributes(): void $this->assertStringContainsStringIgnoringLineEndings( << - + diff --git a/tests/Tag/SourceTest.php b/tests/Tag/SourceTest.php index 0b02e337..6e61a96c 100644 --- a/tests/Tag/SourceTest.php +++ b/tests/Tag/SourceTest.php @@ -13,7 +13,7 @@ final class SourceTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', (string) Source::tag() ->src('audio.ogg') ->type('audio/ogg; codecs=vorbis'), diff --git a/tests/Tag/TrackTest.php b/tests/Tag/TrackTest.php index 69b94090..828a7a65 100644 --- a/tests/Tag/TrackTest.php +++ b/tests/Tag/TrackTest.php @@ -13,7 +13,7 @@ final class TrackTest extends TestCase public function testBase(): void { $this->assertSame( - '', + '', (string) Track::tag() ->kind(Track::SUBTITLES) ->src('brave.en.vtt') diff --git a/tests/Widget/ButtonGroupTest.php b/tests/Widget/ButtonGroupTest.php index 8ec51357..39557114 100644 --- a/tests/Widget/ButtonGroupTest.php +++ b/tests/Widget/ButtonGroupTest.php @@ -198,8 +198,8 @@ public function testMergeButtonAttributes(): void $this->assertStringContainsStringIgnoringLineEndings( << - - + + HTML, $widget->render(), diff --git a/tests/Widget/CheckboxListTest.php b/tests/Widget/CheckboxListTest.php index 52d3b9ed..edd2d2ff 100644 --- a/tests/Widget/CheckboxListTest.php +++ b/tests/Widget/CheckboxListTest.php @@ -21,9 +21,9 @@ public function testBase(): void $this->assertSame( '' . "\n" . '
    ' . "\n" - . '' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) @@ -42,7 +42,7 @@ public function testName(): void $this->assertSame( '
    ' . "\n" - . '' . "\n" + . '' . "\n" . '
    ', $widget->render(), ); @@ -51,7 +51,7 @@ public function testName(): void public function testWithoutContainer(): void { $this->assertSame( - '', + '', CheckboxList::create('test') ->items([1 => 'One']) ->withoutContainer() @@ -63,16 +63,16 @@ public static function dataContainerTag(): array { return [ [ - '', + '', null, ], [ - '', + '', '', ], [ '
    ' . "\n" - . '' . "\n" + . '' . "\n" . '
    ', 'section', ], @@ -95,7 +95,7 @@ public function testContainerAttributes(): void { $this->assertSame( '
    ' . "\n" - . '' . "\n" + . '' . "\n" . '
    ', CheckboxList::create('test') ->items([1 => 'One']) @@ -107,8 +107,8 @@ public function testContainerAttributes(): void public function testCheckboxAttributes(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -123,8 +123,8 @@ public function testCheckboxAttributes(): void public function testCheckboxAttributesMerge(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -140,8 +140,8 @@ public function testCheckboxAttributesMerge(): void public function testReplaceCheckboxAttributes(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -157,8 +157,8 @@ public function testReplaceCheckboxAttributes(): void public function testCheckboxLabelAttributes(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two']) ->checkboxLabelAttributes(['class' => 'red']) @@ -170,8 +170,8 @@ public function testCheckboxLabelAttributes(): void public function testCheckboxLabelAttributesMerge(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two']) ->checkboxLabelAttributes(['class' => 'red']) @@ -184,9 +184,9 @@ public function testCheckboxLabelAttributesMerge(): void public function testAddIndividualInputAttributes(): void { $this->assertSame( - '' . "\n" - . '' . "\n" - . '', + '' . "\n" + . '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -206,9 +206,9 @@ public function testAddIndividualInputAttributes(): void public function testIndividualUncheckInputAttributes(): void { $this->assertSame( - '' . "\n" - . '' . "\n" - . '', + '' . "\n" + . '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -227,9 +227,9 @@ public function testIndividualUncheckInputAttributes(): void public function testIndividualInputAttributesMerge(): void { $this->assertSame( - '' . "\n" - . '' . "\n" - . '', + '' . "\n" + . '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -253,9 +253,9 @@ public function testIndividualInputAttributesMerge(): void public function testIndividualInputAttributesReplace(): void { $this->assertSame( - '' . "\n" - . '' . "\n" - . '', + '' . "\n" + . '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -278,8 +278,8 @@ public function testIndividualInputAttributesReplace(): void public function testItems(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -293,8 +293,8 @@ public function testItems(): void public function testItemsWithoutEncodeLabel(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -309,18 +309,18 @@ public static function dataItemsFromValues(): array { return [ [ - '' . "\n" - . '', + '' . "\n" + . '', [1, 2], ], [ - '' . "\n" - . '', + '' . "\n" + . '', ['One', 'Two'], ], [ - '' . "\n" - . '', + '' . "\n" + . '', [true, false], ], ]; @@ -341,8 +341,8 @@ public function testItemsFromValues(string $expected, array $values): void public function testItemsFromValuesWithoutEncodeLabel(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', CheckboxList::create('test') ->itemsFromValues([ 'One', @@ -360,41 +360,41 @@ public static function dataValue(): array ["
    \n
    ", [], [42]], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [1 => 'One', 2 => 'Two'], [], ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [1 => 'One', 2 => 'Two'], [7], ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [1 => 'One', 2 => 'Two'], [1], ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [1 => 'One', 2 => 'Two'], [2], ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [1 => 'One', 2 => 'Two', 3 => 'Three'], [1, 3], @@ -402,25 +402,25 @@ public static function dataValue(): array ["
    \n
    ", [], [StringEnum::A]], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two'], [StringEnum::C], ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two'], [StringEnum::B], ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two', StringEnum::C->value => 'Three'], [StringEnum::B, StringEnum::C], @@ -428,25 +428,25 @@ public static function dataValue(): array ["
    \n
    ", [], [IntegerEnum::A]], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two'], [IntegerEnum::C], ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two'], [IntegerEnum::B], ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two', IntegerEnum::C->value => 'Three'], [IntegerEnum::B, IntegerEnum::C], @@ -492,22 +492,22 @@ public static function dataForm(): array return [ [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', null, ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', '', ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', 'post', ], @@ -539,8 +539,8 @@ public function testReadonly(): void $this->assertSame( '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', $checkbox ->readonly() @@ -549,8 +549,8 @@ public function testReadonly(): void $this->assertSame( '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', $checkbox ->readonly(false) @@ -558,8 +558,8 @@ public function testReadonly(): void ); $this->assertSame( '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', $checkbox ->readonly(true) @@ -578,8 +578,8 @@ public function testDisabled(): void $this->assertSame( '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', $checkbox ->disabled() @@ -588,8 +588,8 @@ public function testDisabled(): void $this->assertSame( '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', $checkbox ->disabled(false) @@ -597,8 +597,8 @@ public function testDisabled(): void ); $this->assertSame( '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', $checkbox ->disabled(true) @@ -612,16 +612,16 @@ public static function dataUncheckValue(): array return [ [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', 'test', null, ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', 'test[]', null, @@ -629,8 +629,8 @@ public static function dataUncheckValue(): array [ '' . "\n" . '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', 'test', 7, @@ -638,8 +638,8 @@ public static function dataUncheckValue(): array [ '' . "\n" . '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', 'test[]', 7, @@ -666,8 +666,8 @@ public function testUncheckValueDisabled(): void { $this->assertSame( '' . "\n" - . '' . "\n" - . '', + . '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -684,8 +684,8 @@ public function testUncheckValueForm(): void { $this->assertSame( '' . "\n" - . '' . "\n" - . '', + . '' . "\n" + . '', CheckboxList::create('test') ->items([ 1 => 'One', @@ -702,8 +702,8 @@ public function testSeparator(): void { $this->assertSame( '
    ' . "\n" - . '
    ' - . '' . "\n" + . '
    ' + . '' . "\n" . '
    ', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two']) @@ -716,8 +716,8 @@ public function testItemFormatter(): void { $this->assertSame( '
    ' . "\n" - . '
    0)
    ' - . '
    1)
    ' . "\n" + . '
    0)
    ' + . '
    1)
    ' . "\n" . '
    ', CheckboxList::create('test') ->items([1 => 'One', 2 => 'Two']) @@ -750,8 +750,8 @@ public function testDisableCheckboxLabelWrap(): void $this->assertSame( << - - + + HTML, $html, @@ -770,10 +770,10 @@ public function testCheckboxWrap(): void <<
    - +
    - +
    HTML, @@ -807,10 +807,10 @@ public function testCheckboxWrapClass(string $expected, array $class): void << - + - + HTML, @@ -843,10 +843,10 @@ public function testAddCheckboxWrapClass(string $expected, array $class): void << - + - + HTML, diff --git a/tests/Widget/RadioListTest.php b/tests/Widget/RadioListTest.php index 48139d3e..38d0a226 100644 --- a/tests/Widget/RadioListTest.php +++ b/tests/Widget/RadioListTest.php @@ -19,9 +19,9 @@ public function testBase(): void $this->assertSame( '' . "\n" . '
    ' . "\n" - . '' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', RadioList::create('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) @@ -40,7 +40,7 @@ public function testName(): void $this->assertSame( '
    ' . "\n" - . '' . "\n" + . '' . "\n" . '
    ', $widget->render(), ); @@ -49,7 +49,7 @@ public function testName(): void public function testWithoutContainer(): void { $this->assertSame( - '', + '', RadioList::create('test') ->items([1 => 'One']) ->withoutContainer() @@ -61,16 +61,16 @@ public static function dataContainerTag(): array { return [ [ - '', + '', null, ], [ - '', + '', '', ], [ '
    ' . "\n" - . '' . "\n" + . '' . "\n" . '
    ', 'section', ], @@ -93,7 +93,7 @@ public function testContainerAttributes(): void { $this->assertSame( '
    ' . "\n" - . '' . "\n" + . '' . "\n" . '
    ', RadioList::create('test') ->items([1 => 'One']) @@ -105,8 +105,8 @@ public function testContainerAttributes(): void public function testRadioAttributes(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -121,8 +121,8 @@ public function testRadioAttributes(): void public function testRadioAttributesMerge(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -138,8 +138,8 @@ public function testRadioAttributesMerge(): void public function testReplaceRadioAttributes(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -155,8 +155,8 @@ public function testReplaceRadioAttributes(): void public function testRadioLabelAttributes(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', RadioList::create('test') ->items([1 => 'One', 2 => 'Two']) ->radioLabelAttributes(['class' => 'red']) @@ -168,8 +168,8 @@ public function testRadioLabelAttributes(): void public function testRadioLabelAttributesMerge(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', RadioList::create('test') ->items([1 => 'One', 2 => 'Two']) ->radioLabelAttributes(['class' => 'red']) @@ -182,9 +182,9 @@ public function testRadioLabelAttributesMerge(): void public function testIndividualInputAttributes(): void { $this->assertSame( - '' . "\n" - . '' . "\n" - . '', + '' . "\n" + . '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -204,9 +204,9 @@ public function testIndividualInputAttributes(): void public function testIndividualUncheckInputAttributes(): void { $this->assertSame( - '' . "\n" - . '' . "\n" - . '', + '' . "\n" + . '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -225,9 +225,9 @@ public function testIndividualUncheckInputAttributes(): void public function testIndividualInputAttributesMerge(): void { $this->assertSame( - '' . "\n" - . '' . "\n" - . '', + '' . "\n" + . '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -251,9 +251,9 @@ public function testIndividualInputAttributesMerge(): void public function testIndividualInputAttributesReplace(): void { $this->assertSame( - '' . "\n" - . '' . "\n" - . '', + '' . "\n" + . '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -276,8 +276,8 @@ public function testIndividualInputAttributesReplace(): void public function testItems(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -291,8 +291,8 @@ public function testItems(): void public function testItemsWithoutEncodeLabel(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -307,18 +307,18 @@ public static function dataItemsFromValues(): array { return [ [ - '' . "\n" - . '', + '' . "\n" + . '', [1, 2], ], [ - '' . "\n" - . '', + '' . "\n" + . '', ['One', 'Two'], ], [ - '' . "\n" - . '', + '' . "\n" + . '', [true, false], ], ]; @@ -339,8 +339,8 @@ public function testItemsFromValues(string $expected, array $values): void public function testItemsFromValuesWithoutEncodeLabel(): void { $this->assertSame( - '' . "\n" - . '', + '' . "\n" + . '', RadioList::create('test') ->itemsFromValues([ 'One', @@ -358,32 +358,32 @@ public static function dataValue(): array ["
    \n
    ", [], 42], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [1 => 'One', 2 => 'Two'], null, ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [1 => 'One', 2 => 'Two'], 7, ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [1 => 'One', 2 => 'Two'], 1, ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [1 => 'One', 2 => 'Two'], 2, @@ -391,16 +391,16 @@ public static function dataValue(): array ["
    \n
    ", [], StringEnum::A], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two'], StringEnum::C, ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [StringEnum::A->value => 'One', StringEnum::B->value => 'Two'], StringEnum::A, @@ -408,16 +408,16 @@ public static function dataValue(): array ["
    \n
    ", [], IntegerEnum::A], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two'], IntegerEnum::C, ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', [IntegerEnum::A->value => 'One', IntegerEnum::B->value => 'Two'], IntegerEnum::A, @@ -442,22 +442,22 @@ public static function dataForm(): array return [ [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', null, ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', '', ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', 'post', ], @@ -489,8 +489,8 @@ public function testReadonly(): void $this->assertSame( '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', $checkbox ->readonly() @@ -499,8 +499,8 @@ public function testReadonly(): void $this->assertSame( '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', $checkbox ->readonly(false) @@ -508,8 +508,8 @@ public function testReadonly(): void ); $this->assertSame( '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', $checkbox ->readonly(true) @@ -528,8 +528,8 @@ public function testDisabled(): void $this->assertSame( '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', $checkbox ->disabled() @@ -538,8 +538,8 @@ public function testDisabled(): void $this->assertSame( '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', $checkbox ->disabled(false) @@ -547,8 +547,8 @@ public function testDisabled(): void ); $this->assertSame( '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', $checkbox ->disabled(true) @@ -562,16 +562,16 @@ public static function dataUncheckValue(): array return [ [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', 'test', null, ], [ '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', 'test', null, @@ -579,8 +579,8 @@ public static function dataUncheckValue(): array [ '' . "\n" . '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', 'test', 7, @@ -588,8 +588,8 @@ public static function dataUncheckValue(): array [ '' . "\n" . '
    ' . "\n" - . '' . "\n" - . '' . "\n" + . '' . "\n" + . '' . "\n" . '
    ', 'test', 7, @@ -616,8 +616,8 @@ public function testUncheckValueDisabled(): void { $this->assertSame( '' . "\n" - . '' . "\n" - . '', + . '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -634,8 +634,8 @@ public function testUncheckValueForm(): void { $this->assertSame( '' . "\n" - . '' . "\n" - . '', + . '' . "\n" + . '', RadioList::create('test') ->items([ 1 => 'One', @@ -652,8 +652,8 @@ public function testSeparator(): void { $this->assertSame( '
    ' . "\n" - . '
    ' - . '' . "\n" + . '
    ' + . '' . "\n" . '
    ', RadioList::create('test') ->items([1 => 'One', 2 => 'Two']) @@ -666,8 +666,8 @@ public function testItemFormatter(): void { $this->assertSame( '
    ' . "\n" - . '
    0)
    ' - . '
    1)
    ' . "\n" + . '
    0)
    ' + . '
    1)
    ' . "\n" . '
    ', RadioList::create('test') ->items([1 => 'One', 2 => 'Two']) @@ -700,8 +700,8 @@ public function testDisableRadioLabelWrap(): void $this->assertSame( << - - + + HTML, $html, @@ -720,10 +720,10 @@ public function testRadioWrap(): void <<
    - +
    - +
    HTML, @@ -758,10 +758,10 @@ public function testRadioWrapClass(string $expected, array $class): void << - + - + HTML, @@ -795,10 +795,10 @@ public function testAddRadioWrapClass(string $expected, array $class): void << - + - + HTML,