From c30b7c820e35478d886ab5ec3f6b094acece9ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Tue, 3 Mar 2026 22:38:15 +0200 Subject: [PATCH 01/37] Use `new tagName()` without parentheses instead of static contructor --- CHANGELOG.md | 1 + README.md | 12 +- src/Html.php | 142 +++++++++---------- src/Tag/Base/ListTag.php | 2 +- src/Tag/Base/NormalTag.php | 3 +- src/Tag/Base/VoidTag.php | 3 +- src/Tag/Button.php | 6 +- src/Tag/CustomTag.php | 3 +- src/Tag/Input.php | 22 +-- src/Tag/Input/Range.php | 2 +- src/Tag/Link.php | 2 +- src/Tag/Meta.php | 8 +- src/Tag/Optgroup.php | 2 +- src/Tag/Script.php | 2 +- src/Tag/Select.php | 6 +- src/Tag/Table.php | 2 +- src/Tag/Tr.php | 4 +- src/Widget/ButtonGroup.php | 3 +- src/Widget/CheckboxList/CheckboxList.php | 3 +- src/Widget/RadioList/RadioList.php | 3 +- tests/HtmlTest.php | 2 +- tests/Tag/ATest.php | 16 +-- tests/Tag/AddressTest.php | 4 +- tests/Tag/ArticleTest.php | 8 +- tests/Tag/AsideTest.php | 6 +- tests/Tag/AudioTest.php | 6 +- tests/Tag/BTest.php | 2 +- tests/Tag/Base/BooleanInputTagTest.php | 36 ++--- tests/Tag/Base/InputTagTest.php | 26 ++-- tests/Tag/Base/ListTagTest.php | 16 +-- tests/Tag/Base/MediaTagTest.php | 64 ++++----- tests/Tag/Base/NormalTagTest.php | 6 +- tests/Tag/Base/TableCellTagTest.php | 6 +- tests/Tag/Base/TableRowsContainerTagTest.php | 16 +-- tests/Tag/Base/TagContentTraitTest.php | 26 ++-- tests/Tag/Base/TagSourcesTraitTest.php | 12 +- tests/Tag/Base/TagTest.php | 38 ++--- tests/Tag/Base/VoidTagTest.php | 2 +- tests/Tag/BodyTest.php | 4 +- tests/Tag/BrTest.php | 2 +- tests/Tag/ButtonTest.php | 12 +- tests/Tag/CaptionTest.php | 4 +- tests/Tag/CodeTest.php | 2 +- tests/Tag/ColTest.php | 6 +- tests/Tag/ColgroupTest.php | 28 ++-- tests/Tag/CustomTagTest.php | 32 ++--- tests/Tag/DatalistTest.php | 6 +- tests/Tag/DivTest.php | 2 +- tests/Tag/EmTest.php | 2 +- tests/Tag/FieldsetTest.php | 18 +-- tests/Tag/FooterTest.php | 6 +- tests/Tag/FormTest.php | 42 +++--- tests/Tag/H1Test.php | 2 +- tests/Tag/H2Test.php | 2 +- tests/Tag/H3Test.php | 2 +- tests/Tag/H4Test.php | 2 +- tests/Tag/H5Test.php | 2 +- tests/Tag/H6Test.php | 2 +- tests/Tag/HeaderTest.php | 6 +- tests/Tag/HgroupTest.php | 8 +- tests/Tag/HrTest.php | 2 +- tests/Tag/HtmlTest.php | 8 +- tests/Tag/ITest.php | 2 +- tests/Tag/ImgTest.php | 22 +-- tests/Tag/Input/CheckboxTest.php | 2 +- tests/Tag/Input/ColorTest.php | 2 +- tests/Tag/Input/FileTest.php | 20 +-- tests/Tag/Input/RadioTest.php | 2 +- tests/Tag/Input/RangeTest.php | 28 ++-- tests/Tag/InputTest.php | 6 +- tests/Tag/LabelTest.php | 6 +- tests/Tag/LegendTest.php | 2 +- tests/Tag/LiTest.php | 2 +- tests/Tag/LinkTest.php | 22 +-- tests/Tag/MetaTest.php | 12 +- tests/Tag/NavTest.php | 10 +- tests/Tag/NoscriptTest.php | 2 +- tests/Tag/OlTest.php | 6 +- tests/Tag/OptgroupTest.php | 40 +++--- tests/Tag/OptionTest.php | 26 ++-- tests/Tag/PTest.php | 2 +- tests/Tag/PictureTest.php | 14 +- tests/Tag/PreTest.php | 2 +- tests/Tag/ScriptTest.php | 44 +++--- tests/Tag/SectionTest.php | 6 +- tests/Tag/SelectTest.php | 120 ++++++++-------- tests/Tag/SmallTest.php | 2 +- tests/Tag/SourceTest.php | 16 +-- tests/Tag/SpanTest.php | 2 +- tests/Tag/StrongTest.php | 2 +- tests/Tag/StyleTest.php | 10 +- tests/Tag/TableTest.php | 108 +++++++------- tests/Tag/TbodyTest.php | 6 +- tests/Tag/TdTest.php | 2 +- tests/Tag/TextareaTest.php | 14 +- tests/Tag/TfootTest.php | 6 +- tests/Tag/ThTest.php | 2 +- tests/Tag/TheadTest.php | 6 +- tests/Tag/TitleTest.php | 2 +- tests/Tag/TrTest.php | 48 +++---- tests/Tag/TrackTest.php | 24 ++-- tests/Tag/UlTest.php | 6 +- tests/Tag/VideoTest.php | 14 +- tests/Widget/ButtonGroupTest.php | 34 ++--- tests/Widget/CheckboxListTest.php | 72 +++++----- tests/Widget/RadioListTest.php | 66 ++++----- 106 files changed, 787 insertions(+), 780 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 02acf384..06d34b54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - New #260: Add `$attributes` parameter to `Html::li()` method (@gauravkumar2525) - Enh #261: Enhance `RadioList::addRadioWrapClass()` method for cleaner class addition (@vjik) - Enh #263: Explicitly import classes and constants in "use" section (@mspirkov) +- Enh #243: Use `new tagName()` without parentheses instead of static constructor `tagName::tag()` (@razvbir) ## 3.12.0 December 13, 2025 diff --git a/README.md b/README.md index 1ff9daaf..bcf73c33 100644 --- a/README.md +++ b/README.md @@ -85,9 +85,9 @@ Tag classes allow working with a tag as an object and then get an HTML code by u to string. For example, the following code: ```php -echo \Yiisoft\Html\Tag\Div::tag() +echo new \Yiisoft\Html\Tag\Div() ->content( - \Yiisoft\Html\Tag\A::tag() + new \Yiisoft\Html\Tag\A() ->mailto('info@example.com') ->content('contact us') ->render() @@ -108,7 +108,7 @@ echo \Yiisoft\Html\Tag\Div::tag() To generate custom tags, use the `CustomTag` class. For example, the following code: ```php -echo \Yiisoft\Html\Tag\CustomTag::name('b') +echo new \Yiisoft\Html\Tag\CustomTag('b') ->content('text') ->attribute('title', 'Important'); ``` @@ -166,7 +166,7 @@ complex HTML in simple PHP. Represents a group of buttons. ```php -echo \Yiisoft\Html\Widget\ButtonGroup::create() +echo new \Yiisoft\Html\Widget\ButtonGroup() ->buttons( \Yiisoft\Html\Html::resetButton('Reset Data'), \Yiisoft\Html\Html::resetButton('Send'), @@ -189,7 +189,7 @@ Result will be: Represents a list of checkboxes. ```php -echo \Yiisoft\Html\Widget\CheckboxList\CheckboxList::create('count') +echo new \Yiisoft\Html\Widget\CheckboxList\CheckboxList('count') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) ->uncheckValue(0) ->value(2, 5) @@ -212,7 +212,7 @@ Result will be: Represents a list of radio buttons. ```php -echo \Yiisoft\Html\Widget\RadioList\RadioList::create('count') +echo new \Yiisoft\Html\Widget\RadioList\RadioList('count') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) ->uncheckValue(0) ->value(2) diff --git a/src/Html.php b/src/Html.php index c14daf29..6f79d841 100644 --- a/src/Html.php +++ b/src/Html.php @@ -307,7 +307,7 @@ public static function escapeJavaScriptStringValue(mixed $value): string */ public static function tag(string $name, string|Stringable $content = '', array $attributes = []): CustomTag { - $tag = CustomTag::name($name); + $tag = new CustomTag($name); if ($content !== '') { $tag = $tag->content($content); } @@ -330,7 +330,7 @@ public static function tag(string $name, string|Stringable $content = '', array */ public static function normalTag(string $name, string|Stringable $content = '', array $attributes = []): CustomTag { - $tag = CustomTag::name($name)->normal(); + $tag = new CustomTag($name)->normal(); if ($content !== '') { $tag = $tag->content($content); } @@ -352,7 +352,7 @@ public static function normalTag(string $name, string|Stringable $content = '', */ public static function voidTag(string $name, array $attributes = []): CustomTag { - $tag = CustomTag::name($name)->void(); + $tag = new CustomTag($name)->void(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -392,7 +392,7 @@ public static function closeTag(string $name): string */ public static function style(string $content = '', array $attributes = []): Style { - $tag = Style::tag(); + $tag = new Style(); if ($content !== '') { $tag = $tag->content($content); } @@ -410,7 +410,7 @@ public static function style(string $content = '', array $attributes = []): Styl */ public static function script(string $content = '', array $attributes = []): Script { - $tag = Script::tag(); + $tag = new Script(); if ($content !== '') { $tag = $tag->content($content); } @@ -427,7 +427,7 @@ public static function script(string $content = '', array $attributes = []): Scr */ public static function noscript(string|Stringable $content = ''): Noscript { - $tag = Noscript::tag(); + $tag = new Noscript(); return $content === '' ? $tag : $tag->content($content); } @@ -439,7 +439,7 @@ public static function noscript(string|Stringable $content = ''): Noscript */ public static function title(string|Stringable $content = '', array $attributes = []): Title { - $tag = Title::tag(); + $tag = new Title(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -453,7 +453,7 @@ public static function title(string|Stringable $content = '', array $attributes */ public static function meta(array $attributes = []): Meta { - $tag = Meta::tag(); + $tag = new Meta(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -468,7 +468,7 @@ public static function meta(array $attributes = []): Meta */ public static function link(?string $url = null, array $attributes = []): Link { - $tag = Link::tag(); + $tag = new Link(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -501,7 +501,7 @@ public static function cssFile(string $url, array $attributes = []): Link */ public static function javaScriptFile(string $url, array $attributes = []): Script { - $tag = Script::tag()->url($url); + $tag = new Script()->url($url); if (!empty($attributes)) { $tag = $tag->addAttributes($attributes); } @@ -518,7 +518,7 @@ public static function javaScriptFile(string $url, array $attributes = []): Scri */ public static function a(string|Stringable $content = '', ?string $url = null, array $attributes = []): A { - $tag = A::tag(); + $tag = new A(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -540,7 +540,7 @@ public static function a(string|Stringable $content = '', ?string $url = null, a */ public static function mailto(string $content, ?string $mail = null, array $attributes = []): A { - $tag = A::tag() + $tag = new A() ->content($content) ->mailto($mail ?? $content); if (!empty($attributes)) { @@ -558,7 +558,7 @@ public static function mailto(string $content, ?string $mail = null, array $attr */ public static function img(?string $url = null, ?string $alt = '', array $attributes = []): Img { - $tag = Img::tag(); + $tag = new Img(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -578,7 +578,7 @@ public static function img(?string $url = null, ?string $alt = '', array $attrib */ public static function fieldset(array $attributes = []): Fieldset { - $tag = Fieldset::tag(); + $tag = new Fieldset(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -594,7 +594,7 @@ public static function fieldset(array $attributes = []): Fieldset */ public static function form(?string $action = null, ?string $method = null, array $attributes = []): Form { - $tag = Form::tag(); + $tag = new Form(); if ($action !== null) { $attributes['action'] = $action; } @@ -616,7 +616,7 @@ public static function form(?string $action = null, ?string $method = null, arra */ public static function label(string|Stringable $content = '', ?string $for = null): Label { - $tag = Label::tag(); + $tag = new Label(); if ($for !== null) { $tag = $tag->forId($for); } @@ -634,7 +634,7 @@ public static function label(string|Stringable $content = '', ?string $for = nul */ public static function legend(string|Stringable $content = '', array $attributes = []): Legend { - $tag = Legend::tag(); + $tag = new Legend(); if ($content !== '') { $tag = $tag->content($content); } @@ -710,7 +710,7 @@ public static function input( bool|float|int|string|Stringable|null $value = null, array $attributes = [], ): Input { - $tag = Input::tag()->type($type); + $tag = new Input()->type($type); if ($name !== null) { $tag = $tag->name($name); } @@ -929,7 +929,7 @@ public static function checkbox( */ public static function textarea(?string $name = null, string|Stringable|array|null $value = null, array $attributes = []): Textarea { - $tag = Textarea::tag(); + $tag = new Textarea(); if ($name !== null) { $tag = $tag->name($name); } @@ -946,7 +946,7 @@ public static function textarea(?string $name = null, string|Stringable|array|nu */ public static function select(?string $name = null): Select { - $tag = Select::tag(); + $tag = new Select(); if ($name !== null) { $tag = $tag->name($name); } @@ -958,7 +958,7 @@ public static function select(?string $name = null): Select */ public static function optgroup(): Optgroup { - return Optgroup::tag(); + return new Optgroup(); } /** @@ -971,7 +971,7 @@ public static function option( string|Stringable $content = '', bool|float|int|string|Stringable|null $value = null, ): Option { - $tag = Option::tag(); + $tag = new Option(); if ($content !== '') { $tag = $tag->content($content); } @@ -988,7 +988,7 @@ public static function option( */ public static function checkboxList(string $name): CheckboxList { - return CheckboxList::create($name); + return new CheckboxList($name); } /** @@ -998,7 +998,7 @@ public static function checkboxList(string $name): CheckboxList */ public static function radioList(string $name): RadioList { - return RadioList::create($name); + return new RadioList($name); } /** @@ -1009,7 +1009,7 @@ public static function radioList(string $name): RadioList */ public static function div(string|Stringable $content = '', array $attributes = []): Div { - $tag = Div::tag(); + $tag = new Div(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1026,7 +1026,7 @@ public static function div(string|Stringable $content = '', array $attributes = */ public static function code(string|Stringable $content = '', array $attributes = []): Code { - $tag = Code::tag(); + $tag = new Code(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1043,7 +1043,7 @@ public static function code(string|Stringable $content = '', array $attributes = */ public static function pre(string|Stringable $content = '', array $attributes = []): Pre { - $tag = Pre::tag(); + $tag = new Pre(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1058,7 +1058,7 @@ public static function pre(string|Stringable $content = '', array $attributes = */ public static function span(string|Stringable $content = '', array $attributes = []): Span { - $tag = Span::tag(); + $tag = new Span(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1073,7 +1073,7 @@ public static function span(string|Stringable $content = '', array $attributes = */ public static function em(string|Stringable $content = '', array $attributes = []): Em { - $tag = Em::tag(); + $tag = new Em(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1088,7 +1088,7 @@ public static function em(string|Stringable $content = '', array $attributes = [ */ public static function strong(string|Stringable $content = '', array $attributes = []): Strong { - $tag = Strong::tag(); + $tag = new Strong(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1103,7 +1103,7 @@ public static function strong(string|Stringable $content = '', array $attributes */ public static function small(string|Stringable $content = '', array $attributes = []): Small { - $tag = Small::tag(); + $tag = new Small(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1118,7 +1118,7 @@ public static function small(string|Stringable $content = '', array $attributes */ public static function b(string|Stringable $content = '', array $attributes = []): B { - $tag = B::tag(); + $tag = new B(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1133,7 +1133,7 @@ public static function b(string|Stringable $content = '', array $attributes = [] */ public static function i(string|Stringable $content = '', array $attributes = []): I { - $tag = I::tag(); + $tag = new I(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1148,7 +1148,7 @@ public static function i(string|Stringable $content = '', array $attributes = [] */ public static function h1(string|Stringable $content = '', array $attributes = []): H1 { - $tag = H1::tag(); + $tag = new H1(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1163,7 +1163,7 @@ public static function h1(string|Stringable $content = '', array $attributes = [ */ public static function h2(string|Stringable $content = '', array $attributes = []): H2 { - $tag = H2::tag(); + $tag = new H2(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1178,7 +1178,7 @@ public static function h2(string|Stringable $content = '', array $attributes = [ */ public static function h3(string|Stringable $content = '', array $attributes = []): H3 { - $tag = H3::tag(); + $tag = new H3(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1193,7 +1193,7 @@ public static function h3(string|Stringable $content = '', array $attributes = [ */ public static function h4(string|Stringable $content = '', array $attributes = []): H4 { - $tag = H4::tag(); + $tag = new H4(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1208,7 +1208,7 @@ public static function h4(string|Stringable $content = '', array $attributes = [ */ public static function h5(string|Stringable $content = '', array $attributes = []): H5 { - $tag = H5::tag(); + $tag = new H5(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1223,7 +1223,7 @@ public static function h5(string|Stringable $content = '', array $attributes = [ */ public static function h6(string|Stringable $content = '', array $attributes = []): H6 { - $tag = H6::tag(); + $tag = new H6(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1238,7 +1238,7 @@ public static function h6(string|Stringable $content = '', array $attributes = [ */ public static function p(string|Stringable $content = '', array $attributes = []): P { - $tag = P::tag(); + $tag = new P(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1252,7 +1252,7 @@ public static function p(string|Stringable $content = '', array $attributes = [] */ public static function ul(array $attributes = []): Ul { - $tag = Ul::tag(); + $tag = new Ul(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1266,7 +1266,7 @@ public static function ul(array $attributes = []): Ul */ public static function ol(array $attributes = []): Ol { - $tag = Ol::tag(); + $tag = new Ol(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1281,7 +1281,7 @@ public static function ol(array $attributes = []): Ol */ public static function li(string|Stringable $content = '', array $attributes = []): Li { - $tag = Li::tag(); + $tag = new Li(); if ($attributes !== []) { $tag = $tag->attributes($attributes); @@ -1297,7 +1297,7 @@ public static function li(string|Stringable $content = '', array $attributes = [ */ public static function datalist(array $attributes = []): Datalist { - $tag = Datalist::tag(); + $tag = new Datalist(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1312,7 +1312,7 @@ public static function datalist(array $attributes = []): Datalist */ public static function caption(string|Stringable $content = '', array $attributes = []): Caption { - $tag = Caption::tag(); + $tag = new Caption(); if ($content !== '') { $tag = $tag->content($content); } @@ -1329,7 +1329,7 @@ public static function caption(string|Stringable $content = '', array $attribute */ public static function col(array $attributes = []): Col { - $tag = Col::tag(); + $tag = new Col(); return $attributes === [] ? $tag : $tag->attributes($attributes); } @@ -1340,7 +1340,7 @@ public static function col(array $attributes = []): Col */ public static function colgroup(array $attributes = []): Colgroup { - $tag = Colgroup::tag(); + $tag = new Colgroup(); return $attributes === [] ? $tag : $tag->attributes($attributes); } @@ -1351,7 +1351,7 @@ public static function colgroup(array $attributes = []): Colgroup */ public static function table(array $attributes = []): Table { - $tag = Table::tag(); + $tag = new Table(); return $attributes === [] ? $tag : $tag->attributes($attributes); } @@ -1362,7 +1362,7 @@ public static function table(array $attributes = []): Table */ public static function thead(array $attributes = []): Thead { - $tag = Thead::tag(); + $tag = new Thead(); return $attributes === [] ? $tag : $tag->attributes($attributes); } @@ -1373,7 +1373,7 @@ public static function thead(array $attributes = []): Thead */ public static function tbody(array $attributes = []): Tbody { - $tag = Tbody::tag(); + $tag = new Tbody(); return $attributes === [] ? $tag : $tag->attributes($attributes); } @@ -1384,7 +1384,7 @@ public static function tbody(array $attributes = []): Tbody */ public static function tfoot(array $attributes = []): Tfoot { - $tag = Tfoot::tag(); + $tag = new Tfoot(); return $attributes === [] ? $tag : $tag->attributes($attributes); } @@ -1395,7 +1395,7 @@ public static function tfoot(array $attributes = []): Tfoot */ public static function tr(array $attributes = []): Tr { - $tag = Tr::tag(); + $tag = new Tr(); return $attributes === [] ? $tag : $tag->attributes($attributes); } @@ -1407,7 +1407,7 @@ public static function tr(array $attributes = []): Tr */ public static function td(string|Stringable $content = '', array $attributes = []): Td { - $tag = Td::tag(); + $tag = new Td(); if ($content !== '') { $tag = $tag->content($content); } @@ -1425,7 +1425,7 @@ public static function td(string|Stringable $content = '', array $attributes = [ */ public static function th(string|Stringable $content = '', array $attributes = []): Th { - $tag = Th::tag(); + $tag = new Th(); if ($content !== '') { $tag = $tag->content($content); } @@ -1440,7 +1440,7 @@ public static function th(string|Stringable $content = '', array $attributes = [ */ public static function br(): Br { - return Br::tag(); + return new Br(); } /** @@ -1448,7 +1448,7 @@ public static function br(): Br */ public static function video(): Video { - return Video::tag(); + return new Video(); } /** @@ -1456,7 +1456,7 @@ public static function video(): Video */ public static function audio(): Audio { - return Audio::tag(); + return new Audio(); } /** @@ -1464,7 +1464,7 @@ public static function audio(): Audio */ public static function track(?string $src = null): Track { - $tag = Track::tag(); + $tag = new Track(); return $src === null ? $tag : $tag->src($src); } @@ -1473,7 +1473,7 @@ public static function track(?string $src = null): Track */ public static function picture(): Picture { - return Picture::tag(); + return new Picture(); } /** @@ -1481,7 +1481,7 @@ public static function picture(): Picture */ public static function source(): Source { - return Source::tag(); + return new Source(); } /** @@ -1493,7 +1493,7 @@ public static function source(): Source */ public static function html(string|Stringable $content = '', ?string $lang = null, array $attributes = []): Tag\Html { - $tag = Tag\Html::tag(); + $tag = new Tag\Html(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1514,7 +1514,7 @@ public static function html(string|Stringable $content = '', ?string $lang = nul */ public static function body(string|Stringable $content = '', array $attributes = []): Body { - $tag = Body::tag(); + $tag = new Body(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1529,7 +1529,7 @@ public static function body(string|Stringable $content = '', array $attributes = */ public static function article(string|Stringable $content = '', array $attributes = []): Article { - $tag = Article::tag(); + $tag = new Article(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1544,7 +1544,7 @@ public static function article(string|Stringable $content = '', array $attribute */ public static function section(string|Stringable $content = '', array $attributes = []): Section { - $tag = Section::tag(); + $tag = new Section(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1559,7 +1559,7 @@ public static function section(string|Stringable $content = '', array $attribute */ public static function nav(string|Stringable $content = '', array $attributes = []): Nav { - $tag = Nav::tag(); + $tag = new Nav(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1574,7 +1574,7 @@ public static function nav(string|Stringable $content = '', array $attributes = */ public static function aside(string|Stringable $content = '', array $attributes = []): Aside { - $tag = Aside::tag(); + $tag = new Aside(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1589,7 +1589,7 @@ public static function aside(string|Stringable $content = '', array $attributes */ public static function hgroup(string|Stringable $content = '', array $attributes = []): Hgroup { - $tag = Hgroup::tag(); + $tag = new Hgroup(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1604,7 +1604,7 @@ public static function hgroup(string|Stringable $content = '', array $attributes */ public static function header(string|Stringable $content = '', array $attributes = []): Header { - $tag = Header::tag(); + $tag = new Header(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1616,7 +1616,7 @@ public static function header(string|Stringable $content = '', array $attributes */ public static function hr(array $attributes = []): Hr { - $tag = Hr::tag(); + $tag = new Hr(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1631,7 +1631,7 @@ public static function hr(array $attributes = []): Hr */ public static function footer(string|Stringable $content = '', array $attributes = []): Footer { - $tag = Footer::tag(); + $tag = new Footer(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -1646,7 +1646,7 @@ public static function footer(string|Stringable $content = '', array $attributes */ public static function address(string|Stringable $content = '', array $attributes = []): Address { - $tag = Address::tag(); + $tag = new Address(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } diff --git a/src/Tag/Base/ListTag.php b/src/Tag/Base/ListTag.php index d6f34e82..a49c6c5c 100644 --- a/src/Tag/Base/ListTag.php +++ b/src/Tag/Base/ListTag.php @@ -34,7 +34,7 @@ public function items(Li ...$items): static public function strings(array $strings, array $attributes = [], bool $encode = true): static { $items = array_map( - static fn(string $string) => Li::tag() + static fn(string $string) => new Li() ->content($string) ->attributes($attributes) ->encode($encode), diff --git a/src/Tag/Base/NormalTag.php b/src/Tag/Base/NormalTag.php index ab8ac07c..c67232a4 100644 --- a/src/Tag/Base/NormalTag.php +++ b/src/Tag/Base/NormalTag.php @@ -9,8 +9,9 @@ */ abstract class NormalTag extends Tag { - final private function __construct() {} + final public function __construct() {} + #[\Deprecated] final public static function tag(): static { return new static(); diff --git a/src/Tag/Base/VoidTag.php b/src/Tag/Base/VoidTag.php index 34012b14..12d618d4 100644 --- a/src/Tag/Base/VoidTag.php +++ b/src/Tag/Base/VoidTag.php @@ -10,8 +10,9 @@ */ abstract class VoidTag extends Tag { - final private function __construct() {} + final public function __construct() {} + #[\Deprecated] final public static function tag(): static { return new static(); diff --git a/src/Tag/Button.php b/src/Tag/Button.php index ba59169a..def787bc 100644 --- a/src/Tag/Button.php +++ b/src/Tag/Button.php @@ -16,21 +16,21 @@ final class Button extends NormalTag public static function button(string $content = ''): self { - $button = self::tag()->content($content); + $button = new self()->content($content); $button->attributes['type'] = 'button'; return $button; } public static function submit(string $content = ''): self { - $button = self::tag()->content($content); + $button = new self()->content($content); $button->attributes['type'] = 'submit'; return $button; } public static function reset(string $content = ''): self { - $button = self::tag()->content($content); + $button = new self()->content($content); $button->attributes['type'] = 'reset'; return $button; } diff --git a/src/Tag/CustomTag.php b/src/Tag/CustomTag.php index 933d0d31..e6fe32f3 100644 --- a/src/Tag/CustomTag.php +++ b/src/Tag/CustomTag.php @@ -44,7 +44,7 @@ final class CustomTag extends Tag private int $type = self::TYPE_AUTO; - private function __construct( + public function __construct( private string $name, ) {} @@ -55,6 +55,7 @@ private function __construct( * * @psalm-param non-empty-string $name */ + #[\Deprecated] public static function name(string $name): self { return new self($name); diff --git a/src/Tag/Input.php b/src/Tag/Input.php index 9e50aeb5..412a9a19 100644 --- a/src/Tag/Input.php +++ b/src/Tag/Input.php @@ -29,7 +29,7 @@ final class Input extends InputTag */ public static function hidden(?string $name = null, bool|float|int|string|Stringable|null $value = null): self { - $input = self::tag(); + $input = new self(); $input->attributes['type'] = 'hidden'; $input->attributes['name'] = $name; $input->attributes['value'] = $value; @@ -46,7 +46,7 @@ public static function hidden(?string $name = null, bool|float|int|string|String */ public static function text(?string $name = null, bool|float|int|string|Stringable|null $value = null): self { - $input = self::tag(); + $input = new self(); $input->attributes['type'] = 'text'; $input->attributes['name'] = $name; $input->attributes['value'] = $value; @@ -63,7 +63,7 @@ public static function text(?string $name = null, bool|float|int|string|Stringab */ public static function password(?string $name = null, bool|float|int|string|Stringable|null $value = null): self { - $input = self::tag(); + $input = new self(); $input->attributes['type'] = 'password'; $input->attributes['name'] = $name; $input->attributes['value'] = $value; @@ -80,7 +80,7 @@ public static function password(?string $name = null, bool|float|int|string|Stri */ public static function file(?string $name = null, bool|float|int|string|Stringable|null $value = null): File { - $input = File::tag(); + $input = new File(); if ($name !== null) { $input = $input->name($name); } @@ -100,7 +100,7 @@ public static function file(?string $name = null, bool|float|int|string|Stringab */ public static function checkbox(?string $name = null, bool|float|int|string|Stringable|null $value = null): Checkbox { - $input = Checkbox::tag(); + $input = new Checkbox(); if ($name !== null) { $input = $input->name($name); } @@ -120,7 +120,7 @@ public static function checkbox(?string $name = null, bool|float|int|string|Stri */ public static function radio(?string $name = null, bool|float|int|string|Stringable|null $value = null): Radio { - $input = Radio::tag(); + $input = new Radio(); if ($name !== null) { $input = $input->name($name); } @@ -140,7 +140,7 @@ public static function radio(?string $name = null, bool|float|int|string|Stringa */ public static function range(?string $name = null, float|int|string|Stringable|null $value = null): Range { - $input = Range::tag(); + $input = new Range(); if ($name !== null) { $input = $input->name($name); } @@ -160,7 +160,7 @@ public static function range(?string $name = null, float|int|string|Stringable|n */ public static function color(?string $name = null, string|Stringable|null $value = null): Color { - $input = Color::tag(); + $input = new Color(); if ($name !== null) { $input = $input->name($name); } @@ -179,7 +179,7 @@ public static function color(?string $name = null, string|Stringable|null $value */ public static function button(?string $label = null): self { - $input = self::tag(); + $input = new self(); $input->attributes['type'] = 'button'; $input->attributes['value'] = $label; return $input; @@ -194,7 +194,7 @@ public static function button(?string $label = null): self */ public static function submitButton(?string $label = null): self { - $input = self::tag(); + $input = new self(); $input->attributes['type'] = 'submit'; $input->attributes['value'] = $label; return $input; @@ -209,7 +209,7 @@ public static function submitButton(?string $label = null): self */ public static function resetButton(?string $label = null): self { - $input = self::tag(); + $input = new self(); $input->attributes['type'] = 'reset'; $input->attributes['value'] = $label; return $input; diff --git a/src/Tag/Input/Range.php b/src/Tag/Input/Range.php index 48df6046..f1bca346 100644 --- a/src/Tag/Input/Range.php +++ b/src/Tag/Input/Range.php @@ -126,7 +126,7 @@ protected function after(): string return ''; } - return "\n" . CustomTag::name($this->outputTag) + return "\n" . new CustomTag($this->outputTag) ->attributes($this->outputAttributes) ->content((string) ($this->attributes['value'] ?? '-')) ->id($this->outputId) diff --git a/src/Tag/Link.php b/src/Tag/Link.php index 93d056ec..710af8f1 100644 --- a/src/Tag/Link.php +++ b/src/Tag/Link.php @@ -13,7 +13,7 @@ final class Link extends VoidTag { public static function toCssFile(string $url): self { - $link = self::tag(); + $link = new self(); $link->attributes['rel'] = 'stylesheet'; $link->attributes['href'] = $url; return $link; diff --git a/src/Tag/Meta.php b/src/Tag/Meta.php index c04f40a4..ef4303bf 100644 --- a/src/Tag/Meta.php +++ b/src/Tag/Meta.php @@ -16,7 +16,7 @@ final class Meta extends VoidTag */ public static function data(string $name, string $content): self { - $tag = self::tag(); + $tag = new self(); $tag->attributes['name'] = $name; $tag->attributes['content'] = $content; return $tag; @@ -27,7 +27,7 @@ public static function data(string $name, string $content): self */ public static function pragmaDirective(string $name, string $content): self { - $tag = self::tag(); + $tag = new self(); $tag->attributes['http-equiv'] = $name; $tag->attributes['content'] = $content; return $tag; @@ -38,7 +38,7 @@ public static function pragmaDirective(string $name, string $content): self */ public static function documentEncoding(string $encoding): self { - $tag = self::tag(); + $tag = new self(); $tag->attributes['charset'] = $encoding; return $tag; } @@ -48,7 +48,7 @@ public static function documentEncoding(string $encoding): self */ public static function description(string $content): self { - $tag = self::tag(); + $tag = new self(); $tag->attributes['name'] = 'description'; $tag->attributes['content'] = $content; return $tag; diff --git a/src/Tag/Optgroup.php b/src/Tag/Optgroup.php index 5fae1709..8e096efe 100644 --- a/src/Tag/Optgroup.php +++ b/src/Tag/Optgroup.php @@ -35,7 +35,7 @@ public function optionsData(array $data, bool $encode = true, array $optionsAttr { $options = []; foreach ($data as $value => $content) { - $options[] = Option::tag() + $options[] = new Option() ->attributes($optionsAttributes[$value] ?? []) ->value($value) ->content($content) diff --git a/src/Tag/Script.php b/src/Tag/Script.php index 220b6783..a59738a5 100644 --- a/src/Tag/Script.php +++ b/src/Tag/Script.php @@ -130,7 +130,7 @@ public function defer(bool $defer = true): self public function noscript(string|Stringable|null $content): self { $new = clone $this; - $new->noscript = $content === null ? null : Noscript::tag()->content($content); + $new->noscript = $content === null ? null : new Noscript()->content($content); return $new; } diff --git a/src/Tag/Select.php b/src/Tag/Select.php index d5e45bcb..c3e96d24 100644 --- a/src/Tag/Select.php +++ b/src/Tag/Select.php @@ -152,12 +152,12 @@ public function optionsData( $items = []; foreach ($data as $value => $content) { if (is_array($content)) { - $items[] = Optgroup::tag() + $items[] = new Optgroup() ->label((string) $value) ->addAttributes($groupsAttributes[$value] ?? []) ->optionsData($content, $encode, $optionsAttributes); } else { - $items[] = Option::tag() + $items[] = new Option() ->attributes($optionsAttributes[$value] ?? []) ->value($value) ->content($content) @@ -174,7 +174,7 @@ public function optionsData( public function prompt(?string $text): self { $new = clone $this; - $new->prompt = $text === null ? null : Option::tag() + $new->prompt = $text === null ? null : new Option() ->value('') ->content($text); return $new; diff --git a/src/Tag/Table.php b/src/Tag/Table.php index 94c07009..d0a22da9 100644 --- a/src/Tag/Table.php +++ b/src/Tag/Table.php @@ -46,7 +46,7 @@ public function caption(?Caption $caption): self public function captionString(string $content, bool $encode = true): self { - $caption = Caption::tag()->content($content); + $caption = new Caption()->content($content); if (!$encode) { $caption = $caption->encode(false); } diff --git a/src/Tag/Tr.php b/src/Tag/Tr.php index ce8ed00f..44b76a3d 100644 --- a/src/Tag/Tr.php +++ b/src/Tag/Tr.php @@ -97,7 +97,7 @@ protected function getName(): string private function makeDataCells(array $strings, array $attributes, bool $encode): array { return array_map( - static fn(string $string) => Td::tag() + static fn(string $string) => new Td() ->content($string) ->attributes($attributes) ->encode($encode), @@ -113,7 +113,7 @@ private function makeDataCells(array $strings, array $attributes, bool $encode): private function makeHeaderCells(array $strings, array $attributes, bool $encode): array { return array_map( - static fn(string $string) => Th::tag() + static fn(string $string) => new Th() ->content($string) ->attributes($attributes) ->encode($encode), diff --git a/src/Widget/ButtonGroup.php b/src/Widget/ButtonGroup.php index 2b1ae41c..3e5d5720 100644 --- a/src/Widget/ButtonGroup.php +++ b/src/Widget/ButtonGroup.php @@ -27,13 +27,14 @@ final class ButtonGroup implements NoEncodeStringableInterface private array $buttonAttributes = []; private string $separator = "\n"; - private function __construct() {} + public function __construct() {} public function __toString(): string { return $this->render(); } + #[\Deprecated] public static function create(): self { return new self(); diff --git a/src/Widget/CheckboxList/CheckboxList.php b/src/Widget/CheckboxList/CheckboxList.php index 79648351..43027569 100644 --- a/src/Widget/CheckboxList/CheckboxList.php +++ b/src/Widget/CheckboxList/CheckboxList.php @@ -53,7 +53,7 @@ final class CheckboxList implements NoEncodeStringableInterface */ private ?Closure $itemFormatter = null; - private function __construct( + public function __construct( private string $name, ) {} @@ -62,6 +62,7 @@ public function __toString(): string return $this->render(); } + #[\Deprecated] public static function create(string $name): self { return new self($name); diff --git a/src/Widget/RadioList/RadioList.php b/src/Widget/RadioList/RadioList.php index e9b22269..f08339de 100644 --- a/src/Widget/RadioList/RadioList.php +++ b/src/Widget/RadioList/RadioList.php @@ -47,7 +47,7 @@ final class RadioList implements NoEncodeStringableInterface */ private ?Closure $itemFormatter = null; - private function __construct( + public function __construct( private string $name, ) {} @@ -56,6 +56,7 @@ public function __toString(): string return $this->render(); } + #[\Deprecated] public static function create(string $name): self { return new self($name); diff --git a/tests/HtmlTest.php b/tests/HtmlTest.php index 6a604742..b1256397 100644 --- a/tests/HtmlTest.php +++ b/tests/HtmlTest.php @@ -122,7 +122,7 @@ public function testNoscript(): void { $this->assertSame('', Html::noscript()->render()); $this->assertSame('', Html::noscript('hello')->render()); - $this->assertSame('', Html::noscript(Div::tag())->render()); + $this->assertSame('', Html::noscript(new Div())->render()); } public function testTitle(): void diff --git a/tests/Tag/ATest.php b/tests/Tag/ATest.php index ea7eb326..c1d3f561 100644 --- a/tests/Tag/ATest.php +++ b/tests/Tag/ATest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( 'Link', - (string) A::tag() + (string) new A() ->url('https://example.com') ->content('Link'), ); @@ -31,7 +31,7 @@ public static function dataHref(): array #[DataProvider('dataHref')] public function testHref(string $expected, ?string $href): void { - $this->assertSame($expected, (string) A::tag()->href($href)); + $this->assertSame($expected, (string) new A()->href($href)); } public static function dataUrl(): array @@ -45,7 +45,7 @@ public static function dataUrl(): array #[DataProvider('dataUrl')] public function testUrl(string $expected, ?string $url): void { - $this->assertSame($expected, (string) A::tag()->url($url)); + $this->assertSame($expected, (string) new A()->url($url)); } public static function dataMailto(): array @@ -59,7 +59,7 @@ public static function dataMailto(): array #[DataProvider('dataMailto')] public function testMailto(string $expected, ?string $url): void { - $this->assertSame($expected, (string) A::tag()->mailto($url)); + $this->assertSame($expected, (string) new A()->mailto($url)); } public static function dataRel(): array @@ -76,12 +76,12 @@ public static function dataRel(): array #[DataProvider('dataRel')] public function testRel(string $expected, ?string $rel): void { - $this->assertSame($expected, (string) A::tag()->rel($rel)); + $this->assertSame($expected, (string) new A()->rel($rel)); } public function testNofollow(): void { - $this->assertSame('', (string) A::tag()->nofollow()); + $this->assertSame('', (string) new A()->nofollow()); } public static function dataTarget(): array @@ -95,12 +95,12 @@ public static function dataTarget(): array #[DataProvider('dataTarget')] public function testTarget(string $expected, ?string $contextName): void { - $this->assertSame($expected, (string) A::tag()->target($contextName)); + $this->assertSame($expected, (string) new A()->target($contextName)); } public function testImmutability(): void { - $tag = A::tag(); + $tag = new A(); $this->assertNotSame($tag, $tag->content('')); $this->assertNotSame($tag, $tag->href(null)); $this->assertNotSame($tag, $tag->url(null)); diff --git a/tests/Tag/AddressTest.php b/tests/Tag/AddressTest.php index 0ed2adef..e3dcd9f1 100644 --- a/tests/Tag/AddressTest.php +++ b/tests/Tag/AddressTest.php @@ -14,10 +14,10 @@ public function testBase(): void { $this->assertSame( '
Street 111, Mount View Town. Contact: xx-xx-xxxx
', - (string) Address::tag() + (string) new Address() ->content( 'Street 111, Mount View Town. Contact: ' - . A::tag() + . new A() ->href('tel:xx-xx-xxxx') ->content('xx-xx-xxxx'), ) diff --git a/tests/Tag/ArticleTest.php b/tests/Tag/ArticleTest.php index 6c07f2ca..16b6ec98 100644 --- a/tests/Tag/ArticleTest.php +++ b/tests/Tag/ArticleTest.php @@ -17,11 +17,11 @@ public function testBase(): void { $this->assertSame( '

Heading 1

Article content

Footer
', - (string) Article::tag() + (string) new Article() ->content( - Header::tag()->content(H1::tag()->content('Heading 1')) - . P::tag()->content('Article content') - . Footer::tag()->content('Footer'), + new Header()->content(new H1()->content('Heading 1')) + . new P()->content('Article content') + . new Footer()->content('Footer'), ) ->encode(false), ); diff --git a/tests/Tag/AsideTest.php b/tests/Tag/AsideTest.php index 4f3157d6..1106be6f 100644 --- a/tests/Tag/AsideTest.php +++ b/tests/Tag/AsideTest.php @@ -15,10 +15,10 @@ public function testBase(): void { $this->assertSame( '', - (string) Aside::tag() + (string) new Aside() ->content( - H2::tag()->content('Hello') - . P::tag()->content('Aside Tag Content'), + new H2()->content('Hello') + . new P()->content('Aside Tag Content'), ) ->encode(false), ); diff --git a/tests/Tag/AudioTest.php b/tests/Tag/AudioTest.php index ee49d906..98ba5a31 100644 --- a/tests/Tag/AudioTest.php +++ b/tests/Tag/AudioTest.php @@ -20,10 +20,10 @@ public function testBase(): void . '' . "\n" . 'Your browser does not support audio.' . "\n" . '', - (string) Audio::tag() + (string) new Audio() ->controls() - ->sources(Source::tag()->src('a.mp3'), Source::tag()->src('b.ogg')) - ->tracks(Track::tag()->src('c.mp3')) + ->sources(new Source()->src('a.mp3'), new Source()->src('b.ogg')) + ->tracks(new Track()->src('c.mp3')) ->fallback('Your browser does not support audio.'), ); } diff --git a/tests/Tag/BTest.php b/tests/Tag/BTest.php index 68e34b5c..cb987830 100644 --- a/tests/Tag/BTest.php +++ b/tests/Tag/BTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) B::tag() + (string) new B() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/Base/BooleanInputTagTest.php b/tests/Tag/Base/BooleanInputTagTest.php index aaa1780c..72d48f13 100644 --- a/tests/Tag/Base/BooleanInputTagTest.php +++ b/tests/Tag/Base/BooleanInputTagTest.php @@ -12,9 +12,9 @@ final class BooleanInputTagTest extends TestCase { public function testChecked(): void { - $this->assertSame('', (string) TestBooleanInputTag::tag()->checked()); - $this->assertSame('', (string) TestBooleanInputTag::tag()->checked(false)); - $this->assertSame('', (string) TestBooleanInputTag::tag() + $this->assertSame('', (string) new TestBooleanInputTag()->checked()); + $this->assertSame('', (string) new TestBooleanInputTag()->checked(false)); + $this->assertSame('', (string) new TestBooleanInputTag() ->checked(true) ->checked(false)); } @@ -55,7 +55,7 @@ public function testLabel(string $expected, ?string $label, array $attributes): { $this->assertSame( $expected, - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->label($label, $attributes) ->render(), ); @@ -65,7 +65,7 @@ public function testLabelNoWrap(): void { $this->assertSame( ' ', - (string) TestBooleanInputTag::tag() + (string) new TestBooleanInputTag() ->id('ID') ->label('Voronezh', wrap: false), ); @@ -75,7 +75,7 @@ public function testLabelWithId(): void { $this->assertSame( '', - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->id('Test') ->label('One') ->render(), @@ -86,7 +86,7 @@ public function testSideLabel(): void { $this->assertMatchesRegularExpression( '~ ~', - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->sideLabel('One') ->render(), ); @@ -96,7 +96,7 @@ public function testSideLabelEmpty(): void { $this->assertMatchesRegularExpression( '~ ~', - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->sideLabel('') ->render(), ); @@ -106,7 +106,7 @@ public function testSideLabelNull(): void { $this->assertSame( '', - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->sideLabel(null) ->render(), ); @@ -116,7 +116,7 @@ public function testSideLabelWithId(): void { $this->assertSame( ' ', - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->id('Test') ->sideLabel('One') ->render(), @@ -127,7 +127,7 @@ public function testSideLabelWithAttributes(): void { $this->assertMatchesRegularExpression( '~ ~', - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->sideLabel('One', ['class' => 'red']) ->render(), ); @@ -137,7 +137,7 @@ public function testSideLabelId(): void { $this->assertSame( ' ', - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->sideLabel('One') ->id('count') ->render(), @@ -148,7 +148,7 @@ public function testWithoutLabelEncode(): void { $this->assertSame( '', - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->label('One') ->labelEncode(false) ->render(), @@ -180,7 +180,7 @@ public function testUncheckValue(string $expected, ?string $name, $value): void { $this->assertSame( $expected, - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->name($name) ->uncheckValue($value) ->render(), @@ -192,7 +192,7 @@ public function testUncheckValueDisabled(): void $this->assertSame( '' . '', - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->name('color') ->uncheckValue(7) ->disabled() @@ -205,7 +205,7 @@ public function testUncheckValueForm(): void $this->assertSame( '' . '', - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->name('color') ->uncheckValue(7) ->form('post') @@ -218,7 +218,7 @@ public function testUncheckValueWithLabel(): void $this->assertSame( '' . '', - TestBooleanInputTag::tag() + new TestBooleanInputTag() ->name('color') ->uncheckValue(7) ->label('Seven') @@ -228,7 +228,7 @@ public function testUncheckValueWithLabel(): void public function testImmutability(): void { - $input = TestBooleanInputTag::tag(); + $input = new TestBooleanInputTag(); $this->assertNotSame($input, $input->checked()); $this->assertNotSame($input, $input->label('')); $this->assertNotSame($input, $input->sideLabel('')); diff --git a/tests/Tag/Base/InputTagTest.php b/tests/Tag/Base/InputTagTest.php index e4d9a958..e4637e84 100644 --- a/tests/Tag/Base/InputTagTest.php +++ b/tests/Tag/Base/InputTagTest.php @@ -22,7 +22,7 @@ public static function dataProviderName(): array #[DataProvider('dataProviderName')] public function testName(string $expected, ?string $name): void { - $this->assertSame($expected, (string) TestInputTag::tag()->name($name)); + $this->assertSame($expected, (string) new TestInputTag()->name($name)); } public static function dataValue(): array @@ -42,7 +42,7 @@ public static function dataValue(): array #[DataProvider('dataValue')] public function testValue(string $expected, $value): void { - $this->assertSame($expected, (string) TestInputTag::tag()->value($value)); + $this->assertSame($expected, (string) new TestInputTag()->value($value)); } public static function dataForm(): array @@ -57,41 +57,41 @@ public static function dataForm(): array #[DataProvider('dataForm')] public function testForm(string $expected, ?string $formId): void { - $this->assertSame($expected, TestInputTag::tag() + $this->assertSame($expected, new TestInputTag() ->form($formId) ->render()); } public function testReadonly(): void { - $this->assertSame('', (string) TestInputTag::tag()->readonly()); - $this->assertSame('', (string) TestInputTag::tag()->readonly(false)); - $this->assertSame('', (string) TestInputTag::tag() + $this->assertSame('', (string) new TestInputTag()->readonly()); + $this->assertSame('', (string) new TestInputTag()->readonly(false)); + $this->assertSame('', (string) new TestInputTag() ->readonly(true) ->readonly(false)); } public function testRequired(): void { - $this->assertSame('', (string) TestInputTag::tag()->required()); - $this->assertSame('', (string) TestInputTag::tag()->required(false)); - $this->assertSame('', (string) TestInputTag::tag() + $this->assertSame('', (string) new TestInputTag()->required()); + $this->assertSame('', (string) new TestInputTag()->required(false)); + $this->assertSame('', (string) new TestInputTag() ->required(true) ->required(false)); } public function testDisabled(): void { - $this->assertSame('', (string) TestInputTag::tag()->disabled()); - $this->assertSame('', (string) TestInputTag::tag()->disabled(false)); - $this->assertSame('', (string) TestInputTag::tag() + $this->assertSame('', (string) new TestInputTag()->disabled()); + $this->assertSame('', (string) new TestInputTag()->disabled(false)); + $this->assertSame('', (string) new TestInputTag() ->disabled(true) ->disabled(false)); } public function testImmutability(): void { - $input = TestInputTag::tag(); + $input = new TestInputTag(); $this->assertNotSame($input, $input->name(null)); $this->assertNotSame($input, $input->value(null)); $this->assertNotSame($input, $input->form(null)); diff --git a/tests/Tag/Base/ListTagTest.php b/tests/Tag/Base/ListTagTest.php index aca97f05..eac2e4e9 100644 --- a/tests/Tag/Base/ListTagTest.php +++ b/tests/Tag/Base/ListTagTest.php @@ -12,9 +12,9 @@ final class ListTagTest extends TestCase { public function testItems(): void { - $tag = TestListTag::tag()->items( - Li::tag()->content('A'), - Li::tag()->content('B'), + $tag = new TestListTag()->items( + new Li()->content('A'), + new Li()->content('B'), ); $this->assertSame("\n
  • A
  • \n
  • B
  • \n
    ", (string) $tag); @@ -22,14 +22,14 @@ public function testItems(): void public function testStrings(): void { - $tag = TestListTag::tag()->strings(['A', 'B']); + $tag = new TestListTag()->strings(['A', 'B']); $this->assertSame("\n
  • A
  • \n
  • B
  • \n
    ", (string) $tag); } public function testStringsAttributes(): void { - $tag = TestListTag::tag()->strings(['A', 'B'], ['class' => 'red']); + $tag = new TestListTag()->strings(['A', 'B'], ['class' => 'red']); $this->assertSame( "\n
  • A
  • \n
  • B
  • \n
    ", @@ -39,7 +39,7 @@ public function testStringsAttributes(): void public function testStringsEncode(): void { - $tag = TestListTag::tag()->strings(['A', 'B']); + $tag = new TestListTag()->strings(['A', 'B']); $this->assertSame( "\n
  • <b>A</b>
  • \n
  • <b>B</b>
  • \n
    ", @@ -49,14 +49,14 @@ public function testStringsEncode(): void public function testStringsWithoutEncode(): void { - $tag = TestListTag::tag()->strings(['A', 'B'], [], false); + $tag = new TestListTag()->strings(['A', 'B'], [], false); $this->assertSame("\n
  • A
  • \n
  • B
  • \n
    ", (string) $tag); } public function testImmutability(): void { - $tag = TestListTag::tag(); + $tag = new TestListTag(); $this->assertNotSame($tag, $tag->items()); $this->assertNotSame($tag, $tag->strings([])); } diff --git a/tests/Tag/Base/MediaTagTest.php b/tests/Tag/Base/MediaTagTest.php index 22e7f669..c84cf387 100644 --- a/tests/Tag/Base/MediaTagTest.php +++ b/tests/Tag/Base/MediaTagTest.php @@ -22,10 +22,10 @@ public function testBase(): void . '' . "\n" . 'Your browser does not support media.' . "\n" . '', - (string) TestMediaTag::tag() + (string) new TestMediaTag() ->controls() - ->sources(Source::tag()->src('a.mp3'), Source::tag()->src('b.ogg')) - ->tracks(Track::tag()->src('c.mp3')) + ->sources(new Source()->src('a.mp3'), new Source()->src('b.ogg')) + ->tracks(new Track()->src('c.mp3')) ->fallback('Your browser does not support media.'), ); } @@ -43,15 +43,15 @@ public static function dataFallback(): array #[DataProvider('dataFallback')] public function testFallback($fallback): void { - $tag = TestMediaTag::tag()->fallback($fallback); + $tag = new TestMediaTag()->fallback($fallback); $this->assertSame('' . "\n" . $fallback . "\n" . '', (string) $tag); } public function testTracks(): void { - $tag = TestMediaTag::tag()->tracks( - Track::tag()->src('a.mp4'), - Track::tag()->src('b.mp4'), + $tag = new TestMediaTag()->tracks( + new Track()->src('a.mp4'), + new Track()->src('b.mp4'), ); $this->assertSame("\n\n\n", (string) $tag); @@ -59,10 +59,10 @@ public function testTracks(): void public function testAddTrack(): void { - $tag = TestMediaTag::tag() - ->tracks(Track::tag()->src('a.mp4')) - ->addTrack(Track::tag()->src('b.mp4')) - ->addTrack(Track::tag()->src('c.mp4')); + $tag = new TestMediaTag() + ->tracks(new Track()->src('a.mp4')) + ->addTrack(new Track()->src('b.mp4')) + ->addTrack(new Track()->src('c.mp4')); $this->assertSame( "\n\n\n\n", @@ -81,7 +81,7 @@ public static function dataSrc(): array #[DataProvider('dataSrc')] public function testSrc(string $expected, ?string $url): void { - $this->assertSame($expected, (string) TestMediaTag::tag()->src($url)); + $this->assertSame($expected, (string) new TestMediaTag()->src($url)); } public static function dataCrossOrigin(): array @@ -95,7 +95,7 @@ public static function dataCrossOrigin(): array #[DataProvider('dataCrossOrigin')] public function testCrossOrigin(string $expected, ?string $crossOrigin): void { - $this->assertSame($expected, (string) TestMediaTag::tag()->crossOrigin($crossOrigin)); + $this->assertSame($expected, (string) new TestMediaTag()->crossOrigin($crossOrigin)); } public static function dataPreload(): array @@ -109,58 +109,58 @@ public static function dataPreload(): array #[DataProvider('dataPreload')] public function testPreload(string $expected, ?string $preload): void { - $this->assertSame($expected, (string) TestMediaTag::tag()->preload($preload)); + $this->assertSame($expected, (string) new TestMediaTag()->preload($preload)); } public function testMuted(): void { - $this->assertSame('', (string) TestMediaTag::tag()->muted()); - $this->assertSame('', (string) TestMediaTag::tag()->muted(false)); - $this->assertSame('', (string) TestMediaTag::tag() + $this->assertSame('', (string) new TestMediaTag()->muted()); + $this->assertSame('', (string) new TestMediaTag()->muted(false)); + $this->assertSame('', (string) new TestMediaTag() ->muted(true) ->muted(false)); } public function testLoop(): void { - $this->assertSame('', (string) TestMediaTag::tag()->loop()); - $this->assertSame('', (string) TestMediaTag::tag()->loop(false)); - $this->assertSame('', (string) TestMediaTag::tag() + $this->assertSame('', (string) new TestMediaTag()->loop()); + $this->assertSame('', (string) new TestMediaTag()->loop(false)); + $this->assertSame('', (string) new TestMediaTag() ->loop(true) ->loop(false)); } public function testAutoplay(): void { - $this->assertSame('', (string) TestMediaTag::tag()->autoplay()); - $this->assertSame('', (string) TestMediaTag::tag()->autoplay(false)); - $this->assertSame('', (string) TestMediaTag::tag() + $this->assertSame('', (string) new TestMediaTag()->autoplay()); + $this->assertSame('', (string) new TestMediaTag()->autoplay(false)); + $this->assertSame('', (string) new TestMediaTag() ->autoplay(true) ->autoplay(false)); } public function testControls(): void { - $this->assertSame('', (string) TestMediaTag::tag()->controls()); - $this->assertSame('', (string) TestMediaTag::tag()->controls(false)); - $this->assertSame('', (string) TestMediaTag::tag() + $this->assertSame('', (string) new TestMediaTag()->controls()); + $this->assertSame('', (string) new TestMediaTag()->controls(false)); + $this->assertSame('', (string) new TestMediaTag() ->controls(true) ->controls(false)); } public function testWrongTrackDefault(): void { - $tag = TestMediaTag::tag()->tracks( - Track::tag() + $tag = new TestMediaTag()->tracks( + new Track() ->kind('captions') ->src('sampleCaptions.vtt') ->srclang('en') ->default(), - Track::tag() + new Track() ->kind('descriptions') ->src('sampleDescriptions.vtt') ->srclang('de'), - Track::tag() + new Track() ->kind('chapters') ->src('sampleChapters.vtt') ->srclang('ja') @@ -179,10 +179,10 @@ public function testWrongTrackDefault(): void public function testImmutability(): void { - $tag = TestMediaTag::tag(); + $tag = new TestMediaTag(); $this->assertNotSame($tag, $tag->fallback(null)); $this->assertNotSame($tag, $tag->tracks()); - $this->assertNotSame($tag, $tag->addTrack(Track::tag())); + $this->assertNotSame($tag, $tag->addTrack(new Track())); $this->assertNotSame($tag, $tag->src(null)); $this->assertNotSame($tag, $tag->crossOrigin(null)); $this->assertNotSame($tag, $tag->preload(null)); diff --git a/tests/Tag/Base/NormalTagTest.php b/tests/Tag/Base/NormalTagTest.php index 1e75a9ca..8d7a2de5 100644 --- a/tests/Tag/Base/NormalTagTest.php +++ b/tests/Tag/Base/NormalTagTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'content', - TestNormalTag::tag() + new TestNormalTag() ->id('main') ->render(), ); @@ -23,7 +23,7 @@ public function testOpen(): void { $this->assertSame( '', - TestNormalTag::tag() + new TestNormalTag() ->id('main') ->open(), ); @@ -33,7 +33,7 @@ public function testClose(): void { $this->assertSame( '', - TestNormalTag::tag() + new TestNormalTag() ->id('main') ->close(), ); diff --git a/tests/Tag/Base/TableCellTagTest.php b/tests/Tag/Base/TableCellTagTest.php index 21754086..6d7f524b 100644 --- a/tests/Tag/Base/TableCellTagTest.php +++ b/tests/Tag/Base/TableCellTagTest.php @@ -21,7 +21,7 @@ public static function dataColSpan(): array #[DataProvider('dataColSpan')] public function testColSpan(string $expected, ?int $number): void { - $this->assertSame($expected, (string) TestTableCellTag::tag()->colSpan($number)); + $this->assertSame($expected, (string) new TestTableCellTag()->colSpan($number)); } public static function dataRowSpan(): array @@ -35,12 +35,12 @@ public static function dataRowSpan(): array #[DataProvider('dataRowSpan')] public function testRowSpan(string $expected, ?int $number): void { - $this->assertSame($expected, (string) TestTableCellTag::tag()->rowSpan($number)); + $this->assertSame($expected, (string) new TestTableCellTag()->rowSpan($number)); } public function testImmutability(): void { - $tag = TestTableCellTag::tag(); + $tag = new TestTableCellTag(); $this->assertNotSame($tag, $tag->colSpan(null)); $this->assertNotSame($tag, $tag->rowSpan(null)); } diff --git a/tests/Tag/Base/TableRowsContainerTagTest.php b/tests/Tag/Base/TableRowsContainerTagTest.php index ada7da6d..ab5e5ffe 100644 --- a/tests/Tag/Base/TableRowsContainerTagTest.php +++ b/tests/Tag/Base/TableRowsContainerTagTest.php @@ -12,9 +12,9 @@ final class TableRowsContainerTagTest extends TestCase { public function testRows(): void { - $tag = TestTableRowsContainerTag::tag()->rows( - Tr::tag()->dataStrings(['A', 'B']), - Tr::tag()->dataStrings(['C', 'D']), + $tag = new TestTableRowsContainerTag()->rows( + new Tr()->dataStrings(['A', 'B']), + new Tr()->dataStrings(['C', 'D']), ); $this->assertSame( @@ -34,13 +34,13 @@ public function testRows(): void public function testAddRows(): void { - $tag = TestTableRowsContainerTag::tag() + $tag = new TestTableRowsContainerTag() ->rows( - Tr::tag()->dataStrings(['A', 'B']), + new Tr()->dataStrings(['A', 'B']), ) ->addRows( - Tr::tag()->dataStrings(['C', 'D']), - Tr::tag()->dataStrings(['E', 'F']), + new Tr()->dataStrings(['C', 'D']), + new Tr()->dataStrings(['E', 'F']), ); $this->assertSame( @@ -64,7 +64,7 @@ public function testAddRows(): void public function testImmutability(): void { - $tag = TestTableRowsContainerTag::tag(); + $tag = new TestTableRowsContainerTag(); $this->assertNotSame($tag, $tag->rows()); $this->assertNotSame($tag, $tag->addRows()); } diff --git a/tests/Tag/Base/TagContentTraitTest.php b/tests/Tag/Base/TagContentTraitTest.php index e5f306a1..a47ca723 100644 --- a/tests/Tag/Base/TagContentTraitTest.php +++ b/tests/Tag/Base/TagContentTraitTest.php @@ -20,7 +20,7 @@ public function testBase(): void { $this->assertSame( '<b>hello &gt; world!</b>', - TestTagContentTrait::tag() + new TestTagContentTrait() ->id('main') ->content('hello > world!') ->render(), @@ -31,7 +31,7 @@ public function testWithoutEncode(): void { $this->assertSame( 'hello', - (string) TestTagContentTrait::tag() + (string) new TestTagContentTrait() ->content('hello') ->encode(false), ); @@ -41,7 +41,7 @@ public function testWithoutDoubleEncode(): void { $this->assertSame( '<b>A > B</b>', - (string) TestTagContentTrait::tag() + (string) new TestTagContentTrait() ->content('A > B') ->doubleEncode(false), ); @@ -52,10 +52,10 @@ public static function dataContent(): array return [ 'string' => ['hello', 'hello'], 'string-tag' => ['<p>Hi!</p>', '

    Hi!

    '], - 'object-tag' => ['

    Hi!

    ', P::tag()->content('Hi!')], + 'object-tag' => ['

    Hi!

    ', new P()->content('Hi!')], 'array' => [ 'Hello > World!', - ['Hello', ' > ', Span::tag()->content('World'), '!'], + ['Hello', ' > ', new Span()->content('World'), '!'], ], ]; } @@ -63,7 +63,7 @@ public static function dataContent(): array #[DataProvider('dataContent')] public function testContent(string $expected, string|array|Stringable $content): void { - $tag = TestTagContentTrait::tag(); + $tag = new TestTagContentTrait(); $tag = is_array($content) ? $tag->content(...$content) : $tag->content($content); $this->assertSame($expected, $tag->render()); @@ -73,9 +73,9 @@ public function testEncodeContent(): void { $this->assertSame( '<p>Hi!</p>', - TestTagContentTrait::tag() + new TestTagContentTrait() ->encode(true) - ->content(P::tag()->content('Hi!')) + ->content(new P()->content('Hi!')) ->render(), ); } @@ -84,7 +84,7 @@ public function testAddContent(): void { $this->assertSame( 'Hello World', - TestTagContentTrait::tag() + new TestTagContentTrait() ->content('Hello') ->addContent(' ') ->addContent(new StringableObject('World')) @@ -96,7 +96,7 @@ public function testAddContentVariadic(): void { $this->assertSame( '123', - TestTagContentTrait::tag() + new TestTagContentTrait() ->content('1') ->addContent(...['2', '3']) ->render(), @@ -107,7 +107,7 @@ public function testNamedParametersContent(): void { $this->assertSame( '123', - TestTagContentTrait::tag() + new TestTagContentTrait() ->content(content: '1') ->addContent(content: '2') ->addContent(content: '3') @@ -117,14 +117,14 @@ public function testNamedParametersContent(): void public function testContentArray(): void { - $tag = TestTagContentTrait::tag()->content(a: '1', b: '2'); + $tag = new TestTagContentTrait()->content(a: '1', b: '2'); $this->assertSame(['1', '2'], $tag->getContentArray()); } public function testImmutability(): void { - $tag = TestTagContentTrait::tag(); + $tag = new TestTagContentTrait(); $this->assertNotSame($tag, $tag->encode(true)); $this->assertNotSame($tag, $tag->doubleEncode(true)); $this->assertNotSame($tag, $tag->content('')); diff --git a/tests/Tag/Base/TagSourcesTraitTest.php b/tests/Tag/Base/TagSourcesTraitTest.php index 9c65ee1c..239d3525 100644 --- a/tests/Tag/Base/TagSourcesTraitTest.php +++ b/tests/Tag/Base/TagSourcesTraitTest.php @@ -14,18 +14,18 @@ public function testBase(): void { $this->assertSame( "\n\n\n\n", - TestTagSourcesTrait::tag() - ->sources(Source::tag()->src('video1.mp4')) - ->addSource(Source::tag()->src('video2.mp4')) - ->addSource(Source::tag()->src('video3.mp4')) + new TestTagSourcesTrait() + ->sources(new Source()->src('video1.mp4')) + ->addSource(new Source()->src('video2.mp4')) + ->addSource(new Source()->src('video3.mp4')) ->render(), ); } public function testImmutability(): void { - $tag = TestTagSourcesTrait::tag(); + $tag = new TestTagSourcesTrait(); $this->assertNotSame($tag, $tag->sources()); - $this->assertNotSame($tag, $tag->addSource(Source::tag())); + $this->assertNotSame($tag, $tag->addSource(new Source())); } } diff --git a/tests/Tag/Base/TagTest.php b/tests/Tag/Base/TagTest.php index cd7e33e2..35644d8b 100644 --- a/tests/Tag/Base/TagTest.php +++ b/tests/Tag/Base/TagTest.php @@ -62,15 +62,15 @@ public static function dataAttributes(): array #[DataProvider('dataAttributes')] public function testAttributes(string $expected, array $attributes): void { - $this->assertSame($expected, (string) TestTag::tag()->addAttributes($attributes)); - $this->assertSame($expected, (string) TestTag::tag()->attributes($attributes)); + $this->assertSame($expected, (string) new TestTag()->addAttributes($attributes)); + $this->assertSame($expected, (string) new TestTag()->attributes($attributes)); } public function testAttributesMerge(): void { $this->assertSame( '', - TestTag::tag() + new TestTag() ->id('color') ->class('red') ->addAttributes(['class' => 'green']) @@ -82,7 +82,7 @@ public function testReplaceAttributes(): void { $this->assertSame( '', - TestTag::tag() + new TestTag() ->id('color') ->class('red') ->attributes(['class' => 'green']) @@ -94,7 +94,7 @@ public function testUnionAttributes(): void { $this->assertSame( '', - TestTag::tag() + new TestTag() ->class('red') ->unionAttributes(['class' => 'green', 'id' => 'color']) ->render(), @@ -113,7 +113,7 @@ public static function dataAttribute(): array #[DataProvider('dataAttribute')] public function testAttribute(string $expected, $value): void { - $this->assertSame($expected, TestTag::tag() + $this->assertSame($expected, new TestTag() ->attribute('key', $value) ->render()); } @@ -129,7 +129,7 @@ public static function dataId(): array #[DataProvider('dataId')] public function testId(string $expected, ?string $id): void { - $this->assertSame($expected, (string) TestTag::tag()->id($id)); + $this->assertSame($expected, (string) new TestTag()->id($id)); } public static function dataAddClass(): array @@ -151,7 +151,7 @@ public static function dataAddClass(): array #[DataProvider('dataAddClass')] public function testAddClass(string $expected, array $class): void { - $this->assertSame($expected, (string) TestTag::tag() + $this->assertSame($expected, (string) new TestTag() ->addClass('main') ->addClass(...$class)); } @@ -168,7 +168,7 @@ public static function dataNewClass(): array #[DataProvider('dataNewClass')] public function testNewClass(string $expected, ?string $class): void { - $this->assertSame($expected, (string) TestTag::tag()->addClass($class)); + $this->assertSame($expected, (string) new TestTag()->addClass($class)); } public static function dataClass(): array @@ -191,7 +191,7 @@ public static function dataClass(): array #[DataProvider('dataClass')] public function testClass(string $expected, array $class): void { - $this->assertSame($expected, (string) TestTag::tag() + $this->assertSame($expected, (string) new TestTag() ->class('red') ->class(...$class)); } @@ -206,13 +206,13 @@ public static function dataAddStyle(): iterable #[DataProvider('dataAddStyle')] public function testAddStyle(string $expected, array|string $style): void { - $result = (string) TestTag::tag()->addStyle($style); + $result = (string) new TestTag()->addStyle($style); $this->assertSame($expected, $result); } public function testAddStyleMerging(): void { - $tag = TestTag::tag()->addStyle('width: 100px;'); + $tag = new TestTag()->addStyle('width: 100px;'); $result = (string) $tag->addStyle(['width' => '200px', 'height' => '300px']); @@ -224,7 +224,7 @@ public function testAddStyleMerging(): void public function testAddStyleMergingWithoutOverwrite(): void { - $tag = TestTag::tag()->addStyle('width: 100px;'); + $tag = new TestTag()->addStyle('width: 100px;'); $result = (string) $tag->addStyle(['width' => '200px', 'height' => '300px'], false); @@ -236,7 +236,7 @@ public function testAddStyleMergingWithoutOverwrite(): void public function testAddStyleWithExistingAttribute(): void { - $tag = TestTag::tag()->attribute('style', 'color: red;'); + $tag = new TestTag()->attribute('style', 'color: red;'); $result = (string) $tag->addStyle('width: 100px;'); @@ -250,22 +250,22 @@ public static function dataRemoveStyle(): iterable { yield [ '', - TestTag::tag(), + new TestTag(), 'width', ]; yield [ '', - TestTag::tag()->addStyle('width: 100px;'), + new TestTag()->addStyle('width: 100px;'), 'width', ]; yield [ '', - TestTag::tag()->addStyle('height: 100px; width: 100px;'), + new TestTag()->addStyle('height: 100px; width: 100px;'), 'width', ]; yield [ '', - TestTag::tag()->addStyle('height: 100px; width: 100px; color: red;'), + new TestTag()->addStyle('height: 100px; width: 100px; color: red;'), ['width', 'height'], ]; } @@ -280,7 +280,7 @@ public function testRemoveStyle(string $expected, TestTag $tag, string|array $pr public function testImmutability(): void { - $tag = TestTag::tag(); + $tag = new TestTag(); $this->assertNotSame($tag, $tag->addAttributes([])); $this->assertNotSame($tag, $tag->attributes([])); $this->assertNotSame($tag, $tag->unionAttributes([])); diff --git a/tests/Tag/Base/VoidTagTest.php b/tests/Tag/Base/VoidTagTest.php index 2ebc57dd..5dc31e00 100644 --- a/tests/Tag/Base/VoidTagTest.php +++ b/tests/Tag/Base/VoidTagTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '', - TestVoidTag::tag() + new TestVoidTag() ->id('main') ->render(), ); diff --git a/tests/Tag/BodyTest.php b/tests/Tag/BodyTest.php index 397d9080..a17b1f66 100644 --- a/tests/Tag/BodyTest.php +++ b/tests/Tag/BodyTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Welcome!', - (string) Body::tag()->content('Welcome!'), + (string) new Body()->content('Welcome!'), ); } @@ -21,7 +21,7 @@ public function testAttributes(): void { $this->assertSame( 'Welcome Back!', - (string) Body::tag() + (string) new Body() ->attributes([ 'onafterprint' => 'alert(123);', 'style' => 'font-size:20px;', diff --git a/tests/Tag/BrTest.php b/tests/Tag/BrTest.php index 466e01cb..e78e89e8 100644 --- a/tests/Tag/BrTest.php +++ b/tests/Tag/BrTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
    ', - (string) Br::tag(), + (string) new Br(), ); } } diff --git a/tests/Tag/ButtonTest.php b/tests/Tag/ButtonTest.php index 0f4c5c52..0c2735d8 100644 --- a/tests/Tag/ButtonTest.php +++ b/tests/Tag/ButtonTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) Button::tag() + (string) new Button() ->type('submit') ->content('Send'), ); @@ -79,21 +79,21 @@ public static function dataType(): array #[DataProvider('dataType')] public function testType(string $expected, ?string $type): void { - $this->assertSame($expected, (string) Button::tag()->type($type)); + $this->assertSame($expected, (string) new Button()->type($type)); } public function testDisabled(): void { - $this->assertSame('', (string) Button::tag()->disabled()); - $this->assertSame('', (string) Button::tag()->disabled(false)); - $this->assertSame('', (string) Button::tag() + $this->assertSame('', (string) new Button()->disabled()); + $this->assertSame('', (string) new Button()->disabled(false)); + $this->assertSame('', (string) new Button() ->disabled(true) ->disabled(false)); } public function testImmutability(): void { - $button = Button::tag(); + $button = new Button(); $this->assertNotSame($button, $button->type(null)); $this->assertNotSame($button, $button->disabled()); } diff --git a/tests/Tag/CaptionTest.php b/tests/Tag/CaptionTest.php index 2f19be71..26c8a1f4 100644 --- a/tests/Tag/CaptionTest.php +++ b/tests/Tag/CaptionTest.php @@ -14,10 +14,10 @@ public function testBase(): void { $this->assertSame( 'Table Caption', - Caption::tag() + new Caption() ->content( 'Table ', - CustomTag::name('b')->content('Caption'), + new CustomTag('b')->content('Caption'), ) ->render(), ); diff --git a/tests/Tag/CodeTest.php b/tests/Tag/CodeTest.php index da218840..a5edf48d 100644 --- a/tests/Tag/CodeTest.php +++ b/tests/Tag/CodeTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) Code::tag() + (string) new Code() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/ColTest.php b/tests/Tag/ColTest.php index 8af28cec..6a2f2ebd 100644 --- a/tests/Tag/ColTest.php +++ b/tests/Tag/ColTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - Col::tag() + new Col() ->span(2) ->attribute('style', 'background-color:#f00;') ->render(), @@ -34,13 +34,13 @@ public function testSpan(string $expected, ?int $span): void { $this->assertSame( $expected, - Col::tag()->span($span)->render(), + new Col()->span($span)->render(), ); } public function testImmutability(): void { - $tag = Col::tag(); + $tag = new Col(); $this->assertNotSame($tag, $tag->span(null)); } } diff --git a/tests/Tag/ColgroupTest.php b/tests/Tag/ColgroupTest.php index 00242d9a..e01b1be1 100644 --- a/tests/Tag/ColgroupTest.php +++ b/tests/Tag/ColgroupTest.php @@ -19,13 +19,13 @@ public function testBase(): void . '' . "\n" . '' . "\n" . '', - Colgroup::tag() + new Colgroup() ->columns( - Col::tag(), - Col::tag() + new Col(), + new Col() ->span(2) ->class('red'), - Col::tag() + new Col() ->span(2) ->class('blue'), ) @@ -35,9 +35,9 @@ public function testBase(): void public function testColumns(): void { - $tag = Colgroup::tag()->columns( - Col::tag(), - Col::tag()->span(2), + $tag = new Colgroup()->columns( + new Col(), + new Col()->span(2), ); $this->assertSame( @@ -51,14 +51,14 @@ public function testColumns(): void public function testAddColumns(): void { - $tag = Colgroup::tag() + $tag = new Colgroup() ->columns( - Col::tag(), - Col::tag()->span(2), + new Col(), + new Col()->span(2), ) ->addColumns( - Col::tag()->span(3), - Col::tag()->span(4), + new Col()->span(3), + new Col()->span(4), ); $this->assertSame( @@ -83,14 +83,14 @@ public static function dataSpan(): array #[DataProvider('dataSpan')] public function testSpan(string $expected, ?int $span): void { - $this->assertSame($expected, Colgroup::tag() + $this->assertSame($expected, new Colgroup() ->span($span) ->render()); } public function testImmutability(): void { - $tag = Colgroup::tag(); + $tag = new Colgroup(); $this->assertNotSame($tag, $tag->columns()); $this->assertNotSame($tag, $tag->addColumns()); $this->assertNotSame($tag, $tag->span(null)); diff --git a/tests/Tag/CustomTagTest.php b/tests/Tag/CustomTagTest.php index 003b5b05..0cf860cb 100644 --- a/tests/Tag/CustomTagTest.php +++ b/tests/Tag/CustomTagTest.php @@ -20,7 +20,7 @@ public function testBase(): void { $this->assertSame( 'body', - CustomTag::name('test') + new CustomTag('test') ->id('custom') ->attribute('count', 15) ->content('body') @@ -43,7 +43,7 @@ public function testVoidTags(string $name): void { $this->assertSame( "<$name>", - CustomTag::name($name)->render(), + new CustomTag($name)->render(), ); } @@ -58,7 +58,7 @@ public static function dataNormal(): array #[DataProvider('dataNormal')] public function testNormal(string $expected, string $name): void { - $this->assertSame($expected, CustomTag::name($name) + $this->assertSame($expected, new CustomTag($name) ->normal() ->render()); } @@ -74,7 +74,7 @@ public static function dataVoid(): array #[DataProvider('dataVoid')] public function testVoid(string $expected, string $name): void { - $this->assertSame($expected, CustomTag::name($name) + $this->assertSame($expected, new CustomTag($name) ->void() ->render()); } @@ -83,7 +83,7 @@ public function testWithoutEncode(): void { $this->assertSame( 'hello', - (string) CustomTag::name('test') + (string) new CustomTag('test') ->content('hello') ->encode(false), ); @@ -93,7 +93,7 @@ public function testWithoutDoubleEncode(): void { $this->assertSame( '<b>A > B</b>', - (string) CustomTag::name('test') + (string) new CustomTag('test') ->content('A > B') ->doubleEncode(false), ); @@ -104,10 +104,10 @@ public static function dataContent(): array return [ 'string' => ['hello', 'hello'], 'string-tag' => ['<p>Hi!</p>', '

    Hi!

    '], - 'object-tag' => ['

    Hi!

    ', P::tag()->content('Hi!')], + 'object-tag' => ['

    Hi!

    ', new P()->content('Hi!')], 'array' => [ 'Hello > World!', - ['Hello', ' > ', Span::tag()->content('World'), '!'], + ['Hello', ' > ', new Span()->content('World'), '!'], ], ]; } @@ -115,7 +115,7 @@ public static function dataContent(): array #[DataProvider('dataContent')] public function testContent(string $expected, string|array|Stringable $content): void { - $tag = CustomTag::name('test'); + $tag = new CustomTag('test'); $tag = is_array($content) ? $tag->content(...$content) : $tag->content($content); $this->assertSame($expected, $tag->render()); @@ -125,9 +125,9 @@ public function testEncodeContent(): void { $this->assertSame( '<p>Hi!</p>', - CustomTag::name('test') + new CustomTag('test') ->encode(true) - ->content(P::tag()->content('Hi!')) + ->content(new P()->content('Hi!')) ->render(), ); } @@ -136,7 +136,7 @@ public function testAddContent(): void { $this->assertSame( 'Hello World', - CustomTag::name('test') + new CustomTag('test') ->content('Hello') ->addContent(' ') ->addContent(new StringableObject('World')) @@ -148,7 +148,7 @@ public function testAddContentVariadic(): void { $this->assertSame( '123', - CustomTag::name('test') + new CustomTag('test') ->content('1') ->addContent(...['2', '3']) ->render(), @@ -159,7 +159,7 @@ public function testOpen(): void { $this->assertSame( '', - CustomTag::name('test') + new CustomTag('test') ->id('main') ->open(), ); @@ -169,7 +169,7 @@ public function testClose(): void { $this->assertSame( '', - CustomTag::name('test') + new CustomTag('test') ->id('main') ->close(), ); @@ -177,7 +177,7 @@ public function testClose(): void public function testImmutability(): void { - $tag = CustomTag::name('test'); + $tag = new CustomTag('test'); $this->assertNotSame($tag, $tag->normal()); $this->assertNotSame($tag, $tag->void()); $this->assertNotSame($tag, $tag->encode(true)); diff --git a/tests/Tag/DatalistTest.php b/tests/Tag/DatalistTest.php index 65f1ce2e..0e5399b9 100644 --- a/tests/Tag/DatalistTest.php +++ b/tests/Tag/DatalistTest.php @@ -12,11 +12,11 @@ final class DatalistTest extends TestCase { public function testBase(): void { - $tag = Datalist::tag() + $tag = new Datalist() ->id('numbers') ->content( - Option::tag()->value('One'), - Option::tag()->value('Two'), + new Option()->value('One'), + new Option()->value('Two'), ); $this->assertSame( diff --git a/tests/Tag/DivTest.php b/tests/Tag/DivTest.php index ea8c653b..2f6302f4 100644 --- a/tests/Tag/DivTest.php +++ b/tests/Tag/DivTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
    Hello
    ', - (string) Div::tag() + (string) new Div() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/EmTest.php b/tests/Tag/EmTest.php index a65de112..0aa242dd 100644 --- a/tests/Tag/EmTest.php +++ b/tests/Tag/EmTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) Em::tag() + (string) new Em() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/FieldsetTest.php b/tests/Tag/FieldsetTest.php index 619e90f0..66ca45d0 100644 --- a/tests/Tag/FieldsetTest.php +++ b/tests/Tag/FieldsetTest.php @@ -14,7 +14,7 @@ final class FieldsetTest extends TestCase { public function testBase(): void { - $tag = Fieldset::tag() + $tag = new Fieldset() ->legend('Personal data') ->content( Html::textInput('first_name'), @@ -65,7 +65,7 @@ public static function dataLegend(): array #[DataProvider('dataLegend')] public function testLegend(string $expected, $content, array $attributes = []): void { - $tag = Fieldset::tag()->legend($content, $attributes); + $tag = new Fieldset()->legend($content, $attributes); $this->assertSame($expected, $tag->render()); } @@ -83,7 +83,7 @@ public static function dataLegendTag(): array Hello HTML, - Legend::tag() + new Legend() ->content('Hello') ->attributes(['id' => 'MyLegend']), ], @@ -93,7 +93,7 @@ public static function dataLegendTag(): array #[DataProvider('dataLegendTag')] public function testLegendTag(string $expected, ?Legend $legend): void { - $tag = Fieldset::tag()->legendTag($legend); + $tag = new Fieldset()->legendTag($legend); $this->assertSame($expected, $tag->render()); } @@ -119,14 +119,14 @@ public static function dataDisabled(): array #[DataProvider('dataDisabled')] public function testDisabled(string $expected, ?bool $disabled): void { - $tag = Fieldset::tag()->disabled($disabled); + $tag = new Fieldset()->disabled($disabled); $this->assertSame($expected, $tag->render()); } public function testDisabledDefault(): void { - $tag = Fieldset::tag()->disabled(); + $tag = new Fieldset()->disabled(); $this->assertSame('
    ', $tag->render()); } @@ -142,7 +142,7 @@ public static function dataForm(): array #[DataProvider('dataForm')] public function testForm(string $expected, ?string $formId): void { - $tag = Fieldset::tag()->form($formId); + $tag = new Fieldset()->form($formId); $this->assertSame($expected, $tag->render()); } @@ -158,14 +158,14 @@ public static function dataProviderName(): array #[DataProvider('dataProviderName')] public function testName(string $expected, ?string $formId): void { - $tag = Fieldset::tag()->name($formId); + $tag = new Fieldset()->name($formId); $this->assertSame($expected, $tag->render()); } public function testImmutability(): void { - $tag = Fieldset::tag(); + $tag = new Fieldset(); $this->assertNotSame($tag, $tag->legend(null)); $this->assertNotSame($tag, $tag->legendTag(null)); diff --git a/tests/Tag/FooterTest.php b/tests/Tag/FooterTest.php index 4e76b38b..29192e31 100644 --- a/tests/Tag/FooterTest.php +++ b/tests/Tag/FooterTest.php @@ -15,10 +15,10 @@ public function testBase(): void { $this->assertSame( '

    Heading 1

    Hello Text

    ', - (string) Footer::tag() + (string) new Footer() ->content( - H3::tag()->content('Heading 1') - . P::tag()->content('Hello Text'), + new H3()->content('Heading 1') + . new P()->content('Hello Text'), ) ->encode(false), ); diff --git a/tests/Tag/FormTest.php b/tests/Tag/FormTest.php index 2db79d06..8b9290d9 100644 --- a/tests/Tag/FormTest.php +++ b/tests/Tag/FormTest.php @@ -15,7 +15,7 @@ final class FormTest extends TestCase { public function testBase(): void { - $tag = Form::tag(); + $tag = new Form(); $this->assertSame( '
    ' @@ -37,7 +37,7 @@ public function testGet(): void { $this->assertSame( '
    ', - Form::tag() + new Form() ->get('https://example.com/send') ->render(), ); @@ -47,7 +47,7 @@ public function testGetWithoutUrl(): void { $this->assertSame( '
    ', - Form::tag() + new Form() ->get() ->render(), ); @@ -57,7 +57,7 @@ public function testPost(): void { $this->assertSame( '
    ', - Form::tag() + new Form() ->post('https://example.com/send') ->render(), ); @@ -67,7 +67,7 @@ public function testPostWithoutUrl(): void { $this->assertSame( '
    ', - Form::tag() + new Form() ->post() ->render(), ); @@ -75,7 +75,7 @@ public function testPostWithoutUrl(): void public function testCsrf(): void { - $tag = Form::tag()->csrf('abc', 'csrf-token'); + $tag = new Form()->csrf('abc', 'csrf-token'); $this->assertSame( '
    ' . "\n" @@ -95,7 +95,7 @@ public function testCsrfDefaultName(): void $this->assertSame( '' . "\n" . '
    ', - Form::tag() + new Form() ->csrf('abc') ->render(), ); @@ -106,7 +106,7 @@ public function testStringableCsrfToken(): void $this->assertSame( '
    ' . "\n" . '
    ', - Form::tag() + new Form() ->csrf(new StringableObject('abc')) ->render(), ); @@ -125,7 +125,7 @@ public function testAcceptCharset(string $expected, ?string $charset): void { $this->assertSame( $expected, - Form::tag() + new Form() ->acceptCharset($charset) ->render(), ); @@ -144,7 +144,7 @@ public function testAction(string $expected, ?string $action): void { $this->assertSame( $expected, - Form::tag() + new Form() ->action($action) ->render(), ); @@ -163,7 +163,7 @@ public function testAutocomplete(string $expected, bool $value): void { $this->assertSame( $expected, - Form::tag() + new Form() ->autocomplete($value) ->render(), ); @@ -173,7 +173,7 @@ public function testDefaultAutocomplete(): void { $this->assertSame( '
    ', - Form::tag() + new Form() ->autocomplete() ->render(), ); @@ -192,7 +192,7 @@ public function testEnctype(string $expected, ?string $enctype): void { $this->assertSame( $expected, - Form::tag() + new Form() ->enctype($enctype) ->render(), ); @@ -202,7 +202,7 @@ public function testEnctypeApplicationXWwwFormUrlencoded(): void { $this->assertSame( '
    ', - Form::tag() + new Form() ->enctypeApplicationXWwwFormUrlencoded() ->render(), ); @@ -212,7 +212,7 @@ public function testEnctypeMultipartFormData(): void { $this->assertSame( '
    ', - Form::tag() + new Form() ->enctypeMultipartFormData() ->render(), ); @@ -222,7 +222,7 @@ public function testEnctypeTextPlain(): void { $this->assertSame( '
    ', - Form::tag() + new Form() ->enctypeTextPlain() ->render(), ); @@ -241,7 +241,7 @@ public function testMethod(string $expected, ?string $method): void { $this->assertSame( $expected, - Form::tag() + new Form() ->method($method) ->render(), ); @@ -260,7 +260,7 @@ public function testNoValidate(string $expected, bool $noValidate): void { $this->assertSame( $expected, - Form::tag() + new Form() ->noValidate($noValidate) ->render(), ); @@ -270,7 +270,7 @@ public function testDefaultNoValidate(): void { $this->assertSame( '
    ', - Form::tag() + new Form() ->noValidate() ->render(), ); @@ -289,7 +289,7 @@ public function testTarget(string $expected, ?string $target): void { $this->assertSame( $expected, - Form::tag() + new Form() ->target($target) ->render(), ); @@ -297,7 +297,7 @@ public function testTarget(string $expected, ?string $target): void public function testImmutability(): void { - $tag = Form::tag(); + $tag = new Form(); $this->assertNotSame($tag, $tag->get()); $this->assertNotSame($tag, $tag->post()); diff --git a/tests/Tag/H1Test.php b/tests/Tag/H1Test.php index 29043644..58bb3d8c 100644 --- a/tests/Tag/H1Test.php +++ b/tests/Tag/H1Test.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '

    Hello

    ', - (string) H1::tag() + (string) new H1() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/H2Test.php b/tests/Tag/H2Test.php index 6e723bb3..8d8a61a6 100644 --- a/tests/Tag/H2Test.php +++ b/tests/Tag/H2Test.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '

    Hello

    ', - (string) H2::tag() + (string) new H2() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/H3Test.php b/tests/Tag/H3Test.php index 000c3eb2..cea97f7a 100644 --- a/tests/Tag/H3Test.php +++ b/tests/Tag/H3Test.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '

    Hello

    ', - (string) H3::tag() + (string) new H3() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/H4Test.php b/tests/Tag/H4Test.php index 8e9232e0..19953bda 100644 --- a/tests/Tag/H4Test.php +++ b/tests/Tag/H4Test.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '

    Hello

    ', - (string) H4::tag() + (string) new H4() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/H5Test.php b/tests/Tag/H5Test.php index 9ed7580b..81b42086 100644 --- a/tests/Tag/H5Test.php +++ b/tests/Tag/H5Test.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
    Hello
    ', - (string) H5::tag() + (string) new H5() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/H6Test.php b/tests/Tag/H6Test.php index b9f15082..7b5bff9e 100644 --- a/tests/Tag/H6Test.php +++ b/tests/Tag/H6Test.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
    Hello
    ', - (string) H6::tag() + (string) new H6() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/HeaderTest.php b/tests/Tag/HeaderTest.php index 6bb18587..ae2d5f9a 100644 --- a/tests/Tag/HeaderTest.php +++ b/tests/Tag/HeaderTest.php @@ -15,10 +15,10 @@ public function testBase(): void { $this->assertSame( '

    Heading 1

    Hello Text
    ', - (string) Header::tag() + (string) new Header() ->content( - H1::tag()->content('Heading 1') - . I::tag()->content('Hello Text'), + new H1()->content('Heading 1') + . new I()->content('Hello Text'), ) ->encode(false), ); diff --git a/tests/Tag/HgroupTest.php b/tests/Tag/HgroupTest.php index 86f89a58..f9648f31 100644 --- a/tests/Tag/HgroupTest.php +++ b/tests/Tag/HgroupTest.php @@ -16,11 +16,11 @@ public function testBase(): void { $this->assertSame( '

    Heading 1

    Heading 2

    Heading 3

    ', - (string) Hgroup::tag() + (string) new Hgroup() ->content( - H1::tag()->content('Heading 1') - . H2::tag()->content('Heading 2') - . H3::tag()->content('Heading 3'), + new H1()->content('Heading 1') + . new H2()->content('Heading 2') + . new H3()->content('Heading 3'), ) ->encode(false), ); diff --git a/tests/Tag/HrTest.php b/tests/Tag/HrTest.php index dc5c56e2..9e28bb6e 100644 --- a/tests/Tag/HrTest.php +++ b/tests/Tag/HrTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
    ', - (string) Hr::tag(), + (string) new Hr(), ); } } diff --git a/tests/Tag/HtmlTest.php b/tests/Tag/HtmlTest.php index db47dc66..25aef7a6 100644 --- a/tests/Tag/HtmlTest.php +++ b/tests/Tag/HtmlTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( 'Welcome!', - (string) Html::tag()->content('Welcome!'), + (string) new Html()->content('Welcome!'), ); } @@ -22,7 +22,7 @@ public function testAttributes(): void { $this->assertSame( 'Welcome Back!', - (string) Html::tag() + (string) new Html() ->attributes([ 'onafterprint' => 'alert(123);', 'style' => 'font-size:20px;', @@ -42,12 +42,12 @@ public static function dataLang(): array #[DataProvider('dataLang')] public function testLang(string $expected, ?string $href): void { - $this->assertSame($expected, (string) Html::tag()->lang($href)); + $this->assertSame($expected, (string) new Html()->lang($href)); } public function testImmutability(): void { - $tag = Html::tag(); + $tag = new Html(); $this->assertNotSame($tag, $tag->lang(null)); } diff --git a/tests/Tag/ITest.php b/tests/Tag/ITest.php index 2c69b965..7a5ab34f 100644 --- a/tests/Tag/ITest.php +++ b/tests/Tag/ITest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) I::tag() + (string) new I() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/ImgTest.php b/tests/Tag/ImgTest.php index b072f3d8..c7ea824d 100644 --- a/tests/Tag/ImgTest.php +++ b/tests/Tag/ImgTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( 'Great Company', - (string) Img::tag() + (string) new Img() ->url('logo.png') ->alt('Great Company'), ); @@ -31,8 +31,8 @@ public static function dataUrl(): array #[DataProvider('dataUrl')] public function testUrl(string $expected, ?string $url): void { - $this->assertSame($expected, (string) Img::tag()->url($url)); - $this->assertSame($expected, (string) Img::tag()->src($url)); + $this->assertSame($expected, (string) new Img()->url($url)); + $this->assertSame($expected, (string) new Img()->src($url)); } public static function dataSrcset(): array @@ -48,7 +48,7 @@ public static function dataSrcset(): array #[DataProvider('dataSrcset')] public function testSrcset(string $expected, array $items): void { - $this->assertSame($expected, (string) Img::tag()->srcset(...$items)); + $this->assertSame($expected, (string) new Img()->srcset(...$items)); } public static function dataSrcsetData(): array @@ -70,7 +70,7 @@ public static function dataSrcsetData(): array #[DataProvider('dataSrcsetData')] public function testSrcsetData(string $expected, array $items): void { - $this->assertSame($expected, (string) Img::tag()->srcsetData($items)); + $this->assertSame($expected, (string) new Img()->srcsetData($items)); } public static function dataAlt(): array @@ -84,7 +84,7 @@ public static function dataAlt(): array #[DataProvider('dataAlt')] public function testAlt(string $expected, ?string $text): void { - $this->assertSame($expected, (string) Img::tag()->alt($text)); + $this->assertSame($expected, (string) new Img()->alt($text)); } public static function dataWidth(): array @@ -99,7 +99,7 @@ public static function dataWidth(): array #[DataProvider('dataWidth')] public function testWidth(string $expected, $width): void { - $this->assertSame($expected, (string) Img::tag()->width($width)); + $this->assertSame($expected, (string) new Img()->width($width)); } public static function dataHeight(): array @@ -114,7 +114,7 @@ public static function dataHeight(): array #[DataProvider('dataHeight')] public function testHeight(string $expected, $height): void { - $this->assertSame($expected, (string) Img::tag()->height($height)); + $this->assertSame($expected, (string) new Img()->height($height)); } public static function dataSize(): array @@ -129,7 +129,7 @@ public static function dataSize(): array #[DataProvider('dataSize')] public function testSize(string $expected, $width, $height): void { - $this->assertSame($expected, (string) Img::tag()->size($width, $height)); + $this->assertSame($expected, (string) new Img()->size($width, $height)); } public static function dataLoading(): array @@ -144,12 +144,12 @@ public static function dataLoading(): array #[DataProvider('dataLoading')] public function testLoading(string $expected, ?string $loading): void { - $this->assertSame($expected, (string) Img::tag()->loading($loading)); + $this->assertSame($expected, (string) new Img()->loading($loading)); } public function testImmutability(): void { - $img = Img::tag(); + $img = new Img(); $this->assertNotSame($img, $img->url(null)); $this->assertNotSame($img, $img->src(null)); $this->assertNotSame($img, $img->srcset()); diff --git a/tests/Tag/Input/CheckboxTest.php b/tests/Tag/Input/CheckboxTest.php index abedeebb..3564bf27 100644 --- a/tests/Tag/Input/CheckboxTest.php +++ b/tests/Tag/Input/CheckboxTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '', - Checkbox::tag() + new Checkbox() ->name('number') ->value(42) ->render(), diff --git a/tests/Tag/Input/ColorTest.php b/tests/Tag/Input/ColorTest.php index 576299ff..5af313f6 100644 --- a/tests/Tag/Input/ColorTest.php +++ b/tests/Tag/Input/ColorTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '', - Color::tag() + new Color() ->name('color') ->value('#ff0000') ->render(), diff --git a/tests/Tag/Input/FileTest.php b/tests/Tag/Input/FileTest.php index 8a861031..8ab7212e 100644 --- a/tests/Tag/Input/FileTest.php +++ b/tests/Tag/Input/FileTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - File::tag() + new File() ->name('avatar') ->render(), ); @@ -45,7 +45,7 @@ public function testUncheckValue(string $expected, ?string $name, $value): void { $this->assertSame( $expected, - File::tag() + new File() ->name($name) ->uncheckValue($value) ->render(), @@ -57,7 +57,7 @@ public function testUncheckValueDisabled(): void $this->assertSame( '' . '', - File::tag() + new File() ->name('avatar') ->uncheckValue(7) ->disabled() @@ -70,7 +70,7 @@ public function testUncheckValueForm(): void $this->assertSame( '' . '', - File::tag() + new File() ->name('avatar') ->uncheckValue(7) ->form('post') @@ -80,7 +80,7 @@ public function testUncheckValueForm(): void public function testUncheckInputAttributes(): void { - $result = File::tag() + $result = new File() ->name('avatar') ->uncheckValue(7) ->addUncheckInputAttributes(['id' => 'FileHidden']) @@ -97,7 +97,7 @@ public function testUncheckInputAttributes(): void public function testReplaceUncheckInputAttributes(): void { - $result = File::tag() + $result = new File() ->name('avatar') ->uncheckValue(7) ->addUncheckInputAttributes(['id' => 'FileHidden']) @@ -131,7 +131,7 @@ public function testAccept(string $expected, ?string $accept): void { $this->assertSame( $expected, - File::tag() + new File() ->name('avatar') ->accept($accept) ->render(), @@ -157,7 +157,7 @@ public function testMultiple(string $expected, ?bool $multiple): void { $this->assertSame( $expected, - File::tag() + new File() ->name('avatar') ->multiple($multiple) ->render(), @@ -168,7 +168,7 @@ public function testMultipleDefault(): void { $this->assertSame( '', - File::tag() + new File() ->name('avatar') ->multiple() ->render(), @@ -177,7 +177,7 @@ public function testMultipleDefault(): void public function testImmutability(): void { - $tag = File::tag(); + $tag = new File(); $this->assertNotSame($tag, $tag->uncheckValue(null)); $this->assertNotSame($tag, $tag->addUncheckInputAttributes([])); diff --git a/tests/Tag/Input/RadioTest.php b/tests/Tag/Input/RadioTest.php index 134660c8..2bf744f9 100644 --- a/tests/Tag/Input/RadioTest.php +++ b/tests/Tag/Input/RadioTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '', - Radio::tag() + new Radio() ->name('number') ->value(42) ->render(), diff --git a/tests/Tag/Input/RangeTest.php b/tests/Tag/Input/RangeTest.php index 1a05ec01..3cb58dfb 100644 --- a/tests/Tag/Input/RangeTest.php +++ b/tests/Tag/Input/RangeTest.php @@ -14,7 +14,7 @@ final class RangeTest extends TestCase { public function testBase(): void { - $tag = Range::tag() + $tag = new Range() ->name('opacity') ->min(0) ->max(100) @@ -41,7 +41,7 @@ public static function dataMin(): array #[DataProvider('dataMin')] public function testMin(string $expected, $value): void { - $tag = Range::tag()->min($value); + $tag = new Range()->min($value); $this->assertSame($expected, $tag->render()); } @@ -61,7 +61,7 @@ public static function dataMax(): array #[DataProvider('dataMax')] public function testMax(string $expected, $value): void { - $tag = Range::tag()->max($value); + $tag = new Range()->max($value); $this->assertSame($expected, $tag->render()); } @@ -81,7 +81,7 @@ public static function dataStep(): array #[DataProvider('dataStep')] public function testStep(string $expected, $value): void { - $tag = Range::tag()->step($value); + $tag = new Range()->step($value); $this->assertSame($expected, $tag->render()); } @@ -97,14 +97,14 @@ public static function dataList(): array #[DataProvider('dataList')] public function testList(string $expected, $value): void { - $tag = Range::tag()->list($value); + $tag = new Range()->list($value); $this->assertSame($expected, $tag->render()); } public function testShowOutput(): void { - $tag = Range::tag()->showOutput(); + $tag = new Range()->showOutput(); $this->assertMatchesRegularExpression( '~showOutput() ->addOutputAttributes(['class' => 'red']) ->addOutputAttributes(['id' => 'UID']); @@ -131,7 +131,7 @@ public function testAddOutputAttributes(): void public function testReplaceOutputAttributes(): void { - $tag = Range::tag() + $tag = new Range() ->showOutput() ->addOutputAttributes(['class' => 'red']) ->outputAttributes(['id' => 'UID']); @@ -146,7 +146,7 @@ public function testReplaceOutputAttributes(): void public function testOutputWithCustomId(): void { - $tag = Range::tag() + $tag = new Range() ->showOutput() ->outputAttributes(['id' => 'UID']); @@ -160,7 +160,7 @@ public function testOutputWithCustomId(): void public function testOutputWithCustomTag(): void { - $tag = Range::tag() + $tag = new Range() ->showOutput() ->outputTag('b'); @@ -174,7 +174,7 @@ public function testOutputWithCustomTag(): void public function testOutputWithCustomAttributes(): void { - $tag = Range::tag() + $tag = new Range() ->showOutput() ->outputAttributes(['class' => 'red']); @@ -188,7 +188,7 @@ public function testOutputWithCustomAttributes(): void public function testOutputWithValue(): void { - $tag = Range::tag() + $tag = new Range() ->showOutput() ->value(10); @@ -202,7 +202,7 @@ public function testOutputWithValue(): void public function testEmptyOutputTag(): void { - $tag = Range::tag(); + $tag = new Range(); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('The output tag name it cannot be empty value.'); @@ -211,7 +211,7 @@ public function testEmptyOutputTag(): void public function testImmutability(): void { - $tag = Range::tag(); + $tag = new Range(); $this->assertNotSame($tag, $tag->min(null)); $this->assertNotSame($tag, $tag->max(null)); diff --git a/tests/Tag/InputTest.php b/tests/Tag/InputTest.php index a7056eaf..0fce45df 100644 --- a/tests/Tag/InputTest.php +++ b/tests/Tag/InputTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) Input::tag() + (string) new Input() ->type('hidden') ->name('id') ->value('42'), @@ -120,12 +120,12 @@ public static function dataType(): array #[DataProvider('dataType')] public function testType(string $expected, ?string $type): void { - $this->assertSame($expected, (string) Input::tag()->type($type)); + $this->assertSame($expected, (string) new Input()->type($type)); } public function testImmutability(): void { - $input = Input::tag(); + $input = new Input(); $this->assertNotSame($input, $input->type(null)); } } diff --git a/tests/Tag/LabelTest.php b/tests/Tag/LabelTest.php index 23021510..a0271c94 100644 --- a/tests/Tag/LabelTest.php +++ b/tests/Tag/LabelTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) Label::tag() + (string) new Label() ->forId('name') ->content('Your name'), ); @@ -31,12 +31,12 @@ public static function dataForId(): array #[DataProvider('dataForId')] public function testForId(string $expected, ?string $id): void { - $this->assertSame($expected, (string) Label::tag()->forId($id)); + $this->assertSame($expected, (string) new Label()->forId($id)); } public function testImmutability(): void { - $label = Label::tag(); + $label = new Label(); $this->assertNotSame($label, $label->forId(null)); } } diff --git a/tests/Tag/LegendTest.php b/tests/Tag/LegendTest.php index f02d2c41..637dce52 100644 --- a/tests/Tag/LegendTest.php +++ b/tests/Tag/LegendTest.php @@ -11,7 +11,7 @@ final class LegendTest extends TestCase { public function testBase(): void { - $tag = Legend::tag()->content('Personal data'); + $tag = new Legend()->content('Personal data'); $this->assertSame('Personal data', $tag->render()); } } diff --git a/tests/Tag/LiTest.php b/tests/Tag/LiTest.php index 63b0c800..e2fa2a0c 100644 --- a/tests/Tag/LiTest.php +++ b/tests/Tag/LiTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
  • Hello
  • ', - (string) Li::tag() + (string) new Li() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/LinkTest.php b/tests/Tag/LinkTest.php index 627eae64..c0a1b112 100644 --- a/tests/Tag/LinkTest.php +++ b/tests/Tag/LinkTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) Link::tag() + (string) new Link() ->url('/rss') ->type('application/rss+xml') ->rel('alternate') @@ -41,8 +41,8 @@ public static function dataUrl(): array #[DataProvider('dataUrl')] public function testUrl(string $expected, ?string $url): void { - $this->assertSame($expected, (string) Link::tag()->url($url)); - $this->assertSame($expected, (string) Link::tag()->href($url)); + $this->assertSame($expected, (string) new Link()->url($url)); + $this->assertSame($expected, (string) new Link()->href($url)); } public static function dataRel(): array @@ -56,7 +56,7 @@ public static function dataRel(): array #[DataProvider('dataRel')] public function testRel(string $expected, ?string $rel): void { - $this->assertSame($expected, (string) Link::tag()->rel($rel)); + $this->assertSame($expected, (string) new Link()->rel($rel)); } public static function dataType(): array @@ -70,7 +70,7 @@ public static function dataType(): array #[DataProvider('dataType')] public function testType(string $expected, ?string $type): void { - $this->assertSame($expected, (string) Link::tag()->type($type)); + $this->assertSame($expected, (string) new Link()->type($type)); } public static function dataTitle(): array @@ -84,7 +84,7 @@ public static function dataTitle(): array #[DataProvider('dataTitle')] public function testTitle(string $expected, ?string $title): void { - $this->assertSame($expected, (string) Link::tag()->title($title)); + $this->assertSame($expected, (string) new Link()->title($title)); } public static function dataCrossOrigin(): array @@ -98,7 +98,7 @@ public static function dataCrossOrigin(): array #[DataProvider('dataCrossOrigin')] public function testCrossOrigin(string $expected, ?string $crossOrigin): void { - $this->assertSame($expected, (string) Link::tag()->crossOrigin($crossOrigin)); + $this->assertSame($expected, (string) new Link()->crossOrigin($crossOrigin)); } public static function dataTestAs(): array @@ -113,7 +113,7 @@ public static function dataTestAs(): array #[DataProvider('dataTestAs')] public function testAs(string $expected, ?string $as): void { - $this->assertSame($expected, (string) Link::tag()->as($as)); + $this->assertSame($expected, (string) new Link()->as($as)); } public static function dataPreload(): array @@ -128,15 +128,15 @@ public static function dataPreload(): array public function testPreload(string $expected, string $url, ?string $as = null): void { $tag = $as === null - ? Link::tag()->preload($url) - : Link::tag()->preload($url, $as); + ? new Link()->preload($url) + : new Link()->preload($url, $as); $this->assertSame($expected, $tag->render()); } public function testImmutability(): void { - $link = Link::tag(); + $link = new Link(); $this->assertNotSame($link, $link->url(null)); $this->assertNotSame($link, $link->href(null)); $this->assertNotSame($link, $link->rel(null)); diff --git a/tests/Tag/MetaTest.php b/tests/Tag/MetaTest.php index d426d229..91fb10b2 100644 --- a/tests/Tag/MetaTest.php +++ b/tests/Tag/MetaTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - Meta::tag() + new Meta() ->name('description') ->content('Yii Framework') ->render(), @@ -65,7 +65,7 @@ public static function dataProviderName(): array #[DataProvider('dataProviderName')] public function testName(string $expected, ?string $name): void { - $this->assertSame($expected, (string) Meta::tag()->name($name)); + $this->assertSame($expected, (string) new Meta()->name($name)); } public static function dataHttpEquiv(): array @@ -80,7 +80,7 @@ public static function dataHttpEquiv(): array #[DataProvider('dataHttpEquiv')] public function testHttpEquiv(string $expected, ?string $name): void { - $this->assertSame($expected, (string) Meta::tag()->httpEquiv($name)); + $this->assertSame($expected, (string) new Meta()->httpEquiv($name)); } public static function dataContent(): array @@ -95,7 +95,7 @@ public static function dataContent(): array #[DataProvider('dataContent')] public function testContent(string $expected, ?string $content): void { - $this->assertSame($expected, (string) Meta::tag()->content($content)); + $this->assertSame($expected, (string) new Meta()->content($content)); } public static function dataCharset(): array @@ -110,12 +110,12 @@ public static function dataCharset(): array #[DataProvider('dataCharset')] public function testCharset(string $expected, ?string $charset): void { - $this->assertSame($expected, (string) Meta::tag()->charset($charset)); + $this->assertSame($expected, (string) new Meta()->charset($charset)); } public function testImmutability(): void { - $tag = Meta::tag(); + $tag = new Meta(); $this->assertNotSame($tag, $tag->name(null)); $this->assertNotSame($tag, $tag->httpEquiv(null)); $this->assertNotSame($tag, $tag->content(null)); diff --git a/tests/Tag/NavTest.php b/tests/Tag/NavTest.php index f420596c..d0171567 100644 --- a/tests/Tag/NavTest.php +++ b/tests/Tag/NavTest.php @@ -15,11 +15,11 @@ public function testBase(): void { $this->assertSame( "", - (string) Nav::tag()->content( - Ul::tag()->items( - Li::tag()->content('Home'), - Li::tag()->content('About Us'), - Li::tag()->content('Contact Us'), + (string) new Nav()->content( + new Ul()->items( + new Li()->content('Home'), + new Li()->content('About Us'), + new Li()->content('Contact Us'), ), ), ); diff --git a/tests/Tag/NoscriptTest.php b/tests/Tag/NoscriptTest.php index 5163415b..4cc3aa47 100644 --- a/tests/Tag/NoscriptTest.php +++ b/tests/Tag/NoscriptTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) Noscript::tag()->content(Img::tag()->src('pixel.png')), + (string) new Noscript()->content(new Img()->src('pixel.png')), ); } } diff --git a/tests/Tag/OlTest.php b/tests/Tag/OlTest.php index 9f87ecf2..9fda046a 100644 --- a/tests/Tag/OlTest.php +++ b/tests/Tag/OlTest.php @@ -12,9 +12,9 @@ final class OlTest extends TestCase { public function testBase(): void { - $ol = Ol::tag()->items( - Li::tag()->content('A'), - Li::tag()->content('B'), + $ol = new Ol()->items( + new Li()->content('A'), + new Li()->content('B'), ); $this->assertSame("
      \n
    1. A
    2. \n
    3. B
    4. \n
    ", (string) $ol); diff --git a/tests/Tag/OptgroupTest.php b/tests/Tag/OptgroupTest.php index c180560c..667aefd9 100644 --- a/tests/Tag/OptgroupTest.php +++ b/tests/Tag/OptgroupTest.php @@ -18,12 +18,12 @@ public function testBase(): void . '' . "\n" . '' . "\n" . '', - (string) Optgroup::tag() + (string) new Optgroup() ->options( - Option::tag() + new Option() ->value('1') ->content('One'), - Option::tag() + new Option() ->value('2') ->content('Two'), ) @@ -35,12 +35,12 @@ public function testOptions(): void { $this->assertSame( "\n\n\n", - (string) Optgroup::tag() + (string) new Optgroup() ->options( - Option::tag() + new Option() ->value('1') ->content('One'), - Option::tag() + new Option() ->value('2') ->content('Two'), ), @@ -51,7 +51,7 @@ public function testOptionsData(): void { $this->assertSame( "\n\n\n", - (string) Optgroup::tag()->optionsData(['1' => 'One', '2' => 'Two']), + (string) new Optgroup()->optionsData(['1' => 'One', '2' => 'Two']), ); } @@ -59,7 +59,7 @@ public function testOptionsDataEncode(): void { $this->assertSame( "\n\n", - (string) Optgroup::tag()->optionsData(['1' => 'One']), + (string) new Optgroup()->optionsData(['1' => 'One']), ); } @@ -67,7 +67,7 @@ public function testOptionsDataWithoutEncode(): void { $this->assertSame( "\n\n", - (string) Optgroup::tag()->optionsData(['1' => 'One'], false), + (string) new Optgroup()->optionsData(['1' => 'One'], false), ); } @@ -82,14 +82,14 @@ public static function dataLabel(): array #[DataProvider('dataLabel')] public function testLabel(string $expected, ?string $label): void { - $this->assertSame($expected, (string) Optgroup::tag()->label($label)); + $this->assertSame($expected, (string) new Optgroup()->label($label)); } public function testDisabled(): void { - $this->assertSame('', (string) Optgroup::tag()->disabled()); - $this->assertSame('', (string) Optgroup::tag()->disabled(false)); - $this->assertSame('', (string) Optgroup::tag() + $this->assertSame('', (string) new Optgroup()->disabled()); + $this->assertSame('', (string) new Optgroup()->disabled(false)); + $this->assertSame('', (string) new Optgroup() ->disabled(true) ->disabled(false)); } @@ -104,7 +104,7 @@ public static function dataSelection(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag() + [new Option()->value('1'), new Option() ->value('2') ->selected(), ], [], @@ -114,7 +114,7 @@ public static function dataSelection(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag()->value('2')], + [new Option()->value('1'), new Option()->value('2')], [7], ], [ @@ -122,7 +122,7 @@ public static function dataSelection(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag()->value('2')], + [new Option()->value('1'), new Option()->value('2')], [1], ], [ @@ -130,7 +130,7 @@ public static function dataSelection(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag()->value('2')], + [new Option()->value('1'), new Option()->value('2')], ['2'], ], [ @@ -138,7 +138,7 @@ public static function dataSelection(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag()->value('2')], + [new Option()->value('1'), new Option()->value('2')], [1, 2], ], ]; @@ -149,7 +149,7 @@ public function testSelection(string $expected, array $options, array $selection { $this->assertSame( $expected, - (string) Optgroup::tag() + (string) new Optgroup() ->options(...$options) ->selection(...$selection), ); @@ -157,7 +157,7 @@ public function testSelection(string $expected, array $options, array $selection public function testImmutability(): void { - $optgroup = Optgroup::tag(); + $optgroup = new Optgroup(); $this->assertNotSame($optgroup, $optgroup->options()); $this->assertNotSame($optgroup, $optgroup->optionsData([])); $this->assertNotSame($optgroup, $optgroup->label(null)); diff --git a/tests/Tag/OptionTest.php b/tests/Tag/OptionTest.php index 069b63d6..c6d24b4e 100644 --- a/tests/Tag/OptionTest.php +++ b/tests/Tag/OptionTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) Option::tag() + (string) new Option() ->value('1') ->content('One'), ); @@ -31,21 +31,21 @@ public static function dataValue(): array #[DataProvider('dataValue')] public function testValue(string $expected, ?string $value): void { - $this->assertSame($expected, (string) Option::tag()->value($value)); + $this->assertSame($expected, (string) new Option()->value($value)); } public function testSelected(): void { - $this->assertSame('', (string) Option::tag()->selected()); - $this->assertSame('', (string) Option::tag()->selected(false)); - $this->assertSame('', (string) Option::tag()->selected(true)->selected(false)); + $this->assertSame('', (string) new Option()->selected()); + $this->assertSame('', (string) new Option()->selected(false)); + $this->assertSame('', (string) new Option()->selected(true)->selected(false)); } public function testDisabled(): void { - $this->assertSame('', (string) Option::tag()->disabled()); - $this->assertSame('', (string) Option::tag()->disabled(false)); - $this->assertSame('', (string) Option::tag() + $this->assertSame('', (string) new Option()->disabled()); + $this->assertSame('', (string) new Option()->disabled(false)); + $this->assertSame('', (string) new Option() ->disabled(true) ->disabled(false)); } @@ -53,10 +53,10 @@ public function testDisabled(): void public static function dataGetValue(): array { return [ - [null, Option::tag()], - [null, Option::tag()->value(null)], - ['', Option::tag()->value('')], - ['one', Option::tag()->value('one')], + [null, new Option()], + [null, new Option()->value(null)], + ['', new Option()->value('')], + ['one', new Option()->value('one')], ]; } @@ -68,7 +68,7 @@ public function testGetValue(?string $expected, Option $tag): void public function testImmutability(): void { - $option = Option::tag(); + $option = new Option(); $this->assertNotSame($option, $option->value(null)); $this->assertNotSame($option, $option->selected()); $this->assertNotSame($option, $option->disabled()); diff --git a/tests/Tag/PTest.php b/tests/Tag/PTest.php index f0dcd27f..7602883b 100644 --- a/tests/Tag/PTest.php +++ b/tests/Tag/PTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '

    Hello

    ', - (string) P::tag() + (string) new P() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/PictureTest.php b/tests/Tag/PictureTest.php index f052013c..66a17856 100644 --- a/tests/Tag/PictureTest.php +++ b/tests/Tag/PictureTest.php @@ -14,16 +14,16 @@ final class PictureTest extends TestCase { public function testBase(): void { - $picture = Picture::tag() - ->image(Img::tag() + $picture = new Picture() + ->image(new Img() ->src('img_orange_flowers.jpg') ->alt('Flowers')) ->sources( - Source::tag() + new Source() ->media('(min-width:650px)') ->srcset('img_pink_flowers.jpg') ->type('image/jpeg'), - Source::tag() + new Source() ->media('(min-width:465px)') ->srcset('img_white_flower.jpg') ->type('image/jpeg'), @@ -45,7 +45,7 @@ public static function dataImg(): array ['', null], [ '' . "\n" . '' . "\n" . '', - Img::tag() + new Img() ->src('image.jpg') ->width(100) ->height(100), @@ -56,14 +56,14 @@ public static function dataImg(): array #[DataProvider('dataImg')] public function testImg(string $expected, ?Img $img): void { - $this->assertSame($expected, Picture::tag() + $this->assertSame($expected, new Picture() ->image($img) ->render()); } public function testImmutability(): void { - $tag = Picture::tag(); + $tag = new Picture(); $this->assertNotSame($tag, $tag->image(null)); } } diff --git a/tests/Tag/PreTest.php b/tests/Tag/PreTest.php index 1de768e3..5b5209bf 100644 --- a/tests/Tag/PreTest.php +++ b/tests/Tag/PreTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
    Hello
    ', - (string) Pre::tag() + (string) new Pre() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/ScriptTest.php b/tests/Tag/ScriptTest.php index 6d9e1940..8404116e 100644 --- a/tests/Tag/ScriptTest.php +++ b/tests/Tag/ScriptTest.php @@ -17,14 +17,14 @@ public function testBase(): void { $this->assertSame( '', - (string) Script::tag()->url('main.js'), + (string) new Script()->url('main.js'), ); } public function testContent(): void { $content = 'alert("4 > 2");'; - $tag = Script::tag()->content($content); + $tag = new Script()->content($content); $this->assertSame($content, $tag->getContent()); $this->assertSame('', $tag->render()); @@ -41,8 +41,8 @@ public static function dataUrl(): array #[DataProvider('dataUrl')] public function testUrl(string $expected, ?string $url): void { - $this->assertSame($expected, (string) Script::tag()->url($url)); - $this->assertSame($expected, (string) Script::tag()->src($url)); + $this->assertSame($expected, (string) new Script()->url($url)); + $this->assertSame($expected, (string) new Script()->src($url)); } public static function dataType(): array @@ -56,7 +56,7 @@ public static function dataType(): array #[DataProvider('dataType')] public function testType(string $expected, ?string $type): void { - $this->assertSame($expected, (string) Script::tag()->type($type)); + $this->assertSame($expected, (string) new Script()->type($type)); } public static function dataCharset(): array @@ -70,23 +70,23 @@ public static function dataCharset(): array #[DataProvider('dataCharset')] public function testCharset(string $expected, ?string $charset): void { - $this->assertSame($expected, (string) Script::tag()->charset($charset)); + $this->assertSame($expected, (string) new Script()->charset($charset)); } public function testAsync(): void { - $this->assertSame('', (string) Script::tag()->async()); - $this->assertSame('', (string) Script::tag()->async(false)); - $this->assertSame('', (string) Script::tag() + $this->assertSame('', (string) new Script()->async()); + $this->assertSame('', (string) new Script()->async(false)); + $this->assertSame('', (string) new Script() ->async(true) ->async(false)); } public function testDefer(): void { - $this->assertSame('', (string) Script::tag()->defer()); - $this->assertSame('', (string) Script::tag()->defer(false)); - $this->assertSame('', (string) Script::tag() + $this->assertSame('', (string) new Script()->defer()); + $this->assertSame('', (string) new Script()->defer(false)); + $this->assertSame('', (string) new Script() ->defer(true) ->defer(false)); } @@ -95,34 +95,34 @@ public function testNoscript(): void { $this->assertSame( '', - (string) Script::tag()->noscript('hello'), + (string) new Script()->noscript('hello'), ); $this->assertSame( '', - (string) Script::tag()->noscript(Div::tag()), + (string) new Script()->noscript(new Div()), ); $this->assertSame( '', - (string) Script::tag()->noscript(null), + (string) new Script()->noscript(null), ); } public function testNoscriptTag(): void { - $noscriptTag = Noscript::tag()->content('hello'); + $noscriptTag = new Noscript()->content('hello'); $this->assertSame( '', - (string) Script::tag()->noscriptTag($noscriptTag), + (string) new Script()->noscriptTag($noscriptTag), ); $this->assertSame( '', - (string) Script::tag()->noscriptTag(null), + (string) new Script()->noscriptTag(null), ); } public function testImmutability(): void { - $script = Script::tag(); + $script = new Script(); $this->assertNotSame($script, $script->content('')); $this->assertNotSame($script, $script->url(null)); $this->assertNotSame($script, $script->src(null)); @@ -146,7 +146,7 @@ public static function dataNonce(): iterable #[DataProvider('dataNonce')] public function testNonce(string $expectedHtml, ?string $nonce): void { - $script = Script::tag()->nonce($nonce); + $script = new Script()->nonce($nonce); $this->assertSame($expectedHtml, (string) $script); $this->assertSame($nonce, $script->getNonce()); @@ -154,7 +154,7 @@ public function testNonce(string $expectedHtml, ?string $nonce): void public function testNonceWithoutValue(): void { - $script = Script::tag(); + $script = new Script(); $this->assertSame('', (string) $script); $this->assertNull($script->getNonce()); @@ -162,7 +162,7 @@ public function testNonceWithoutValue(): void public function testInvalidNonce(): void { - $script = Script::tag()->attribute('nonce', []); + $script = new Script()->attribute('nonce', []); $this->expectException(LogicException::class); $this->expectExceptionMessage('Nonce should be string or null. Got array.'); diff --git a/tests/Tag/SectionTest.php b/tests/Tag/SectionTest.php index 86ff2f27..4a39e5a9 100644 --- a/tests/Tag/SectionTest.php +++ b/tests/Tag/SectionTest.php @@ -15,10 +15,10 @@ public function testBase(): void { $this->assertSame( '

    Section Heading

    Section Content

    ', - (string) Section::tag() + (string) new Section() ->content( - H1::tag()->content('Section Heading') - . P::tag()->content('Section Content'), + new H1()->content('Section Heading') + . new P()->content('Section Content'), ) ->encode(false), ); diff --git a/tests/Tag/SelectTest.php b/tests/Tag/SelectTest.php index 9b4d0a40..3a88bf39 100644 --- a/tests/Tag/SelectTest.php +++ b/tests/Tag/SelectTest.php @@ -28,7 +28,7 @@ public static function dataProviderName(): array #[DataProvider('dataProviderName')] public function testName(string $expected, ?string $name): void { - $this->assertSame($expected, (string) Select::tag()->name($name)); + $this->assertSame($expected, (string) new Select()->name($name)); } public static function dataNameForMultiple(): array @@ -52,7 +52,7 @@ public static function dataNameForMultiple(): array #[DataProvider('dataNameForMultiple')] public function testNameForMultiple(string $expected, ?string $name): void { - $this->assertSame($expected, (string) Select::tag() + $this->assertSame($expected, (string) new Select() ->multiple() ->name($name)); } @@ -67,7 +67,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag() + [new Option()->value('1'), new Option() ->value('2') ->selected(), ], [], @@ -77,7 +77,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag()->value('2')], + [new Option()->value('1'), new Option()->value('2')], [7], ], [ @@ -85,7 +85,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag()->value('2')], + [new Option()->value('1'), new Option()->value('2')], [1], ], [ @@ -93,7 +93,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag()->value('2')], + [new Option()->value('1'), new Option()->value('2')], ['2'], ], [ @@ -101,7 +101,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag()->value('2')], + [new Option()->value('1'), new Option()->value('2')], [1, 2], ], [ @@ -113,14 +113,14 @@ public static function dataValue(): array . '' . "\n" . '', [ - Option::tag() + new Option() ->value('1') ->content('One'), - Optgroup::tag()->options( - Option::tag() + new Optgroup()->options( + new Option() ->value('1.1') ->content('One.One'), - Option::tag() + new Option() ->value('1.2') ->content('One.Two'), ), @@ -136,14 +136,14 @@ public static function dataValue(): array . '' . "\n" . '', [ - Option::tag() + new Option() ->value('1') ->content('One'), - Optgroup::tag()->options( - Option::tag() + new Optgroup()->options( + new Option() ->value('1.1') ->content('One.One'), - Option::tag() + new Option() ->value('1.2') ->content('One.Two'), ), @@ -157,7 +157,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag()->value('2')], + [new Option()->value('1'), new Option()->value('2')], [IntegerEnum::C], ], [ @@ -165,7 +165,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag()->value('2')], + [new Option()->value('1'), new Option()->value('2')], [IntegerEnum::A], ], [ @@ -173,7 +173,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('1'), Option::tag()->value('2')], + [new Option()->value('1'), new Option()->value('2')], [IntegerEnum::A, IntegerEnum::B], ], [ @@ -181,7 +181,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [Option::tag()->value('one'), Option::tag()->value('two')], + [new Option()->value('one'), new Option()->value('two')], [StringEnum::B], ], ]; @@ -192,11 +192,11 @@ public function testValue(string $expected, array $items, array $value): void { $this->assertSame( $expected, - (string) Select::tag()->items(...$items)->value(...$value), + (string) new Select()->items(...$items)->value(...$value), ); $this->assertSame( $expected, - (string) Select::tag()->items(...$items)->values($value), + (string) new Select()->items(...$items)->values($value), ); } @@ -212,7 +212,7 @@ public static function dataForm(): array #[DataProvider('dataForm')] public function testForm(string $expected, ?string $formId): void { - $this->assertSame($expected, Select::tag() + $this->assertSame($expected, new Select() ->form($formId) ->render()); } @@ -230,10 +230,10 @@ public static function dataItems(): array . '' . "\n" . '', [ - Option::tag() + new Option() ->value('1') ->content('One'), - Option::tag() + new Option() ->value('2') ->content('Two'), ], @@ -247,14 +247,14 @@ public static function dataItems(): array . '' . "\n" . '', [ - Option::tag() + new Option() ->value('1') ->content('One'), - Optgroup::tag()->options( - Option::tag() + new Optgroup()->options( + new Option() ->value('1.1') ->content('One.One'), - Option::tag() + new Option() ->value('1.2') ->content('One.Two'), ), @@ -266,19 +266,19 @@ public static function dataItems(): array #[DataProvider('dataItems')] public function testItems(string $expected, array $items): void { - $this->assertSame($expected, (string) Select::tag()->items(...$items)); + $this->assertSame($expected, (string) new Select()->items(...$items)); } public function testOptions(): void { $this->assertSame( "", - (string) Select::tag() + (string) new Select() ->options( - Option::tag() + new Option() ->value('1') ->content('One'), - Option::tag() + new Option() ->value('2') ->content('Two'), ), @@ -289,7 +289,7 @@ public function testOptionsData(): void { $this->assertSame( "", - (string) Select::tag()->optionsData(['1' => 'One', '2' => 'Two']), + (string) new Select()->optionsData(['1' => 'One', '2' => 'Two']), ); } @@ -297,7 +297,7 @@ public function testOptionsDataEncode(): void { $this->assertSame( "", - (string) Select::tag()->optionsData(['1' => 'One']), + (string) new Select()->optionsData(['1' => 'One']), ); } @@ -305,13 +305,13 @@ public function testOptionsDataWithoutEncode(): void { $this->assertSame( "", - (string) Select::tag()->optionsData(['1' => 'One'], false), + (string) new Select()->optionsData(['1' => 'One'], false), ); } public function testOptionsDataWithGroups(): void { - $tag = Select::tag() + $tag = new Select() ->optionsData([ 1 => 'One', 'Test Group' => [ @@ -336,7 +336,7 @@ public function testOptionsDataWithGroups(): void public function testOptionsAndGroupsAttributes(): void { - $tag = Select::tag() + $tag = new Select() ->optionsData( [ 1 => 'One', @@ -401,9 +401,9 @@ public function testPrompt(string $expected, ?string $text): void { $this->assertSame( $expected, - (string) Select::tag() + (string) new Select() ->prompt($text) - ->options(Option::tag() + ->options(new Option() ->value('1') ->content('One')), ); @@ -423,7 +423,7 @@ public static function dataPromptOption(): array . '' . "\n" . '' . "\n" . '', - Option::tag()->content('Please select...'), + new Option()->content('Please select...'), ], ]; } @@ -433,9 +433,9 @@ public function testPromptOption(string $expected, ?Option $option): void { $this->assertSame( $expected, - (string) Select::tag() + (string) new Select() ->promptOption($option) - ->options(Option::tag() + ->options(new Option() ->value('1') ->content('One')), ); @@ -443,27 +443,27 @@ public function testPromptOption(string $expected, ?Option $option): void public function testDisabled(): void { - $this->assertSame('', (string) Select::tag()->disabled()); - $this->assertSame('', (string) Select::tag()->disabled(false)); - $this->assertSame('', (string) Select::tag() + $this->assertSame('', (string) new Select()->disabled()); + $this->assertSame('', (string) new Select()->disabled(false)); + $this->assertSame('', (string) new Select() ->disabled(true) ->disabled(false)); } public function testMultiple(): void { - $this->assertSame('', (string) Select::tag()->multiple()); - $this->assertSame('', (string) Select::tag()->multiple(false)); - $this->assertSame('', (string) Select::tag() + $this->assertSame('', (string) new Select()->multiple()); + $this->assertSame('', (string) new Select()->multiple(false)); + $this->assertSame('', (string) new Select() ->multiple(true) ->multiple(false)); } public function testRequired(): void { - $this->assertSame('', (string) Select::tag()->required()); - $this->assertSame('', (string) Select::tag()->required(false)); - $this->assertSame('', (string) Select::tag() + $this->assertSame('', (string) new Select()->required()); + $this->assertSame('', (string) new Select()->required(false)); + $this->assertSame('', (string) new Select() ->required(true) ->required(false)); } @@ -479,7 +479,7 @@ public static function dataSize(): array #[DataProvider('dataSize')] public function testSize(string $expected, ?int $size): void { - $this->assertSame($expected, (string) Select::tag()->size($size)); + $this->assertSame($expected, (string) new Select()->size($size)); } public static function dataUnselectValue(): array @@ -509,7 +509,7 @@ public function testUnselectValue(string $expected, ?string $name, $value): void { $this->assertSame( $expected, - Select::tag() + new Select() ->name($name) ->unselectValue($value) ->render(), @@ -521,7 +521,7 @@ public function testUnselectValueDisabled(): void $this->assertSame( '' . "\n" . '', - Select::tag() + new Select() ->name('test') ->unselectValue(7) ->disabled() @@ -534,7 +534,7 @@ public function testUnselectValueForm(): void $this->assertSame( '' . "\n" . '', - Select::tag() + new Select() ->name('test') ->unselectValue(7) ->form('post') @@ -547,7 +547,7 @@ public function testUnselectValueMultiple(): void $this->assertSame( '' . "\n" . '', - Select::tag() + new Select() ->name('test') ->unselectValue(7) ->multiple() @@ -557,7 +557,7 @@ public function testUnselectValueMultiple(): void public function testImmutability(): void { - $select = Select::tag(); + $select = new Select(); $this->assertNotSame($select, $select->name('')); $this->assertNotSame($select, $select->value()); $this->assertNotSame($select, $select->values([])); @@ -566,7 +566,7 @@ public function testImmutability(): void $this->assertNotSame($select, $select->options()); $this->assertNotSame($select, $select->optionsData([])); $this->assertNotSame($select, $select->prompt('')); - $this->assertNotSame($select, $select->promptOption(Option::tag())); + $this->assertNotSame($select, $select->promptOption(new Option())); $this->assertNotSame($select, $select->disabled()); $this->assertNotSame($select, $select->multiple()); $this->assertNotSame($select, $select->required()); @@ -576,7 +576,7 @@ public function testImmutability(): void public function testNullValue(): void { - $select = Select::tag() + $select = new Select() ->optionsData(['red' => 'RED', 'green' => 'GREEN']) ->value(null); @@ -593,7 +593,7 @@ public function testNullValue(): void public function testNullValueOverride(): void { - $select = Select::tag() + $select = new Select() ->optionsData(['red' => 'RED', 'green' => 'GREEN']) ->value('red') ->value(null); diff --git a/tests/Tag/SmallTest.php b/tests/Tag/SmallTest.php index 18c331cf..fe845a7f 100644 --- a/tests/Tag/SmallTest.php +++ b/tests/Tag/SmallTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) Small::tag() + (string) new Small() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/SourceTest.php b/tests/Tag/SourceTest.php index 0b02e337..fea6528c 100644 --- a/tests/Tag/SourceTest.php +++ b/tests/Tag/SourceTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) Source::tag() + (string) new Source() ->src('audio.ogg') ->type('audio/ogg; codecs=vorbis'), ); @@ -31,7 +31,7 @@ public static function dataType(): array #[DataProvider('dataType')] public function testType(string $expected, ?string $url): void { - $this->assertSame($expected, (string) Source::tag()->type($url)); + $this->assertSame($expected, (string) new Source()->type($url)); } public static function dataSrc(): array @@ -45,7 +45,7 @@ public static function dataSrc(): array #[DataProvider('dataSrc')] public function testSrc(string $expected, ?string $url): void { - $this->assertSame($expected, (string) Source::tag()->src($url)); + $this->assertSame($expected, (string) new Source()->src($url)); } public static function dataSrcset(): array @@ -64,7 +64,7 @@ public static function dataSrcset(): array #[DataProvider('dataSrcset')] public function testSrcset(string $expected, array $items): void { - $this->assertSame($expected, (string) Source::tag()->srcset(...$items)); + $this->assertSame($expected, (string) new Source()->srcset(...$items)); } public static function dataSizes(): array @@ -83,7 +83,7 @@ public static function dataSizes(): array #[DataProvider('dataSizes')] public function testSizes(string $expected, array $items): void { - $this->assertSame($expected, (string) Source::tag()->sizes(...$items)); + $this->assertSame($expected, (string) new Source()->sizes(...$items)); } public static function dataWidth(): array @@ -98,7 +98,7 @@ public static function dataWidth(): array #[DataProvider('dataWidth')] public function testWidth(string $expected, $width): void { - $this->assertSame($expected, (string) Source::tag()->width($width)); + $this->assertSame($expected, (string) new Source()->width($width)); } public static function dataHeight(): array @@ -113,12 +113,12 @@ public static function dataHeight(): array #[DataProvider('dataHeight')] public function testHeight(string $expected, $height): void { - $this->assertSame($expected, (string) Source::tag()->height($height)); + $this->assertSame($expected, (string) new Source()->height($height)); } public function testImmutability(): void { - $source = Source::tag(); + $source = new Source(); $this->assertNotSame($source, $source->type(null)); $this->assertNotSame($source, $source->src(null)); $this->assertNotSame($source, $source->srcset(null)); diff --git a/tests/Tag/SpanTest.php b/tests/Tag/SpanTest.php index 6c9260f7..027ea325 100644 --- a/tests/Tag/SpanTest.php +++ b/tests/Tag/SpanTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) Span::tag() + (string) new Span() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/StrongTest.php b/tests/Tag/StrongTest.php index 6cfc575c..79332e82 100644 --- a/tests/Tag/StrongTest.php +++ b/tests/Tag/StrongTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) Strong::tag() + (string) new Strong() ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/StyleTest.php b/tests/Tag/StyleTest.php index 6a948f88..16bba3c7 100644 --- a/tests/Tag/StyleTest.php +++ b/tests/Tag/StyleTest.php @@ -14,14 +14,14 @@ public function testBase(): void { $this->assertSame( '', - (string) Style::tag()->content('.red { color: #f00; }'), + (string) new Style()->content('.red { color: #f00; }'), ); } public function testContent(): void { $content = 'body { display: block }'; - $tag = Style::tag()->content($content); + $tag = new Style()->content($content); $this->assertSame($content, $tag->getContent()); $this->assertSame('', $tag->render()); @@ -38,7 +38,7 @@ public static function dataMedia(): array #[DataProvider('dataMedia')] public function testMedia(string $expected, ?string $media): void { - $this->assertSame($expected, (string) Style::tag()->media($media)); + $this->assertSame($expected, (string) new Style()->media($media)); } public static function dataType(): array @@ -52,12 +52,12 @@ public static function dataType(): array #[DataProvider('dataType')] public function testType(string $expected, ?string $type): void { - $this->assertSame($expected, (string) Style::tag()->type($type)); + $this->assertSame($expected, (string) new Style()->type($type)); } public function testImmutability(): void { - $tag = Style::tag(); + $tag = new Style(); $this->assertNotSame($tag, $tag->content('')); $this->assertNotSame($tag, $tag->media(null)); $this->assertNotSame($tag, $tag->type(null)); diff --git a/tests/Tag/TableTest.php b/tests/Tag/TableTest.php index 2312da40..981e507b 100644 --- a/tests/Tag/TableTest.php +++ b/tests/Tag/TableTest.php @@ -19,21 +19,21 @@ class TableTest extends TestCase { public function testEmpty(): void { - $this->assertSame('
    ', Table::tag()->render()); + $this->assertSame('
    ', new Table()->render()); } public static function dataCaption(): array { return [ ['
    ', null], - ["\n\n
    Hello
    ", Caption::tag()->content('Hello')], + ["\n\n
    Hello
    ", new Caption()->content('Hello')], ]; } #[DataProvider('dataCaption')] public function testCaption(string $expected, ?Caption $caption): void { - $this->assertSame($expected, Table::tag() + $this->assertSame($expected, new Table() ->caption($caption) ->render()); } @@ -42,7 +42,7 @@ public function testCaptionString(): void { $this->assertSame( "\n\n
    Hello
    ", - Table::tag() + new Table() ->captionString('Hello') ->render(), ); @@ -52,7 +52,7 @@ public function testCaptionStringWithEncode(): void { $this->assertSame( "\n\n
    <b>Hello</b>
    ", - Table::tag() + new Table() ->captionString('Hello') ->render(), ); @@ -62,7 +62,7 @@ public function testCaptionStringWithoutEncode(): void { $this->assertSame( "\n\n
    Hello
    ", - Table::tag() + new Table() ->captionString('Hello', false) ->render(), ); @@ -70,12 +70,12 @@ public function testCaptionStringWithoutEncode(): void public function testColumnGroups(): void { - $tag = Table::tag()->columnGroups( - Colgroup::tag()->columns( - Col::tag(), - Col::tag()->span(2), + $tag = new Table()->columnGroups( + new Colgroup()->columns( + new Col(), + new Col()->span(2), ), - Colgroup::tag()->span(4), + new Colgroup()->span(4), ); $this->assertSame( @@ -92,16 +92,16 @@ public function testColumnGroups(): void public function testAddColumnGroups(): void { - $tag = Table::tag() + $tag = new Table() ->columnGroups( - Colgroup::tag()->columns( - Col::tag(), - Col::tag()->span(2), + new Colgroup()->columns( + new Col(), + new Col()->span(2), ), ) ->addColumnGroups( - Colgroup::tag()->span(4), - Colgroup::tag()->span(5), + new Colgroup()->span(4), + new Colgroup()->span(5), ); $this->assertSame( @@ -119,9 +119,9 @@ public function testAddColumnGroups(): void public function testColumns(): void { - $tag = Table::tag()->columns( - Col::tag(), - Col::tag()->span(2), + $tag = new Table()->columns( + new Col(), + new Col()->span(2), ); $this->assertSame( @@ -135,14 +135,14 @@ public function testColumns(): void public function testAddColumns(): void { - $tag = Table::tag() + $tag = new Table() ->columns( - Col::tag(), - Col::tag()->span(2), + new Col(), + new Col()->span(2), ) ->addColumns( - Col::tag()->span(3), - Col::tag()->span(4), + new Col()->span(3), + new Col()->span(4), ); $this->assertSame( @@ -160,23 +160,23 @@ public static function dataHeader(): array { return [ ['
    ', null], - ["\n\n
    ", Thead::tag()], + ["\n\n
    ", new Thead()], ]; } #[DataProvider('dataHeader')] public function testHeader(string $expected, ?Thead $header): void { - $this->assertSame($expected, Table::tag() + $this->assertSame($expected, new Table() ->header($header) ->render()); } public function testBody(): void { - $tag = Table::tag()->body( - Tbody::tag(), - Tbody::tag()->class('red'), + $tag = new Table()->body( + new Tbody(), + new Tbody()->class('red'), ); $this->assertSame( @@ -190,13 +190,13 @@ public function testBody(): void public function testAddBody(): void { - $tag = Table::tag() + $tag = new Table() ->body( - Tbody::tag(), + new Tbody(), ) ->addBody( - Tbody::tag()->class('red'), - Tbody::tag()->class('green'), + new Tbody()->class('red'), + new Tbody()->class('green'), ); $this->assertSame( @@ -211,9 +211,9 @@ public function testAddBody(): void public function testRows(): void { - $tag = Table::tag()->rows( - Tr::tag()->dataStrings(['A', 'B']), - Tr::tag()->dataStrings(['C', 'D']), + $tag = new Table()->rows( + new Tr()->dataStrings(['A', 'B']), + new Tr()->dataStrings(['C', 'D']), ); $this->assertSame( @@ -233,13 +233,13 @@ public function testRows(): void public function testAddRows(): void { - $tag = Table::tag() + $tag = new Table() ->rows( - Tr::tag()->dataStrings(['A', 'B']), + new Tr()->dataStrings(['A', 'B']), ) ->addRows( - Tr::tag()->dataStrings(['C', 'D']), - Tr::tag()->dataStrings(['E', 'F']), + new Tr()->dataStrings(['C', 'D']), + new Tr()->dataStrings(['E', 'F']), ); $this->assertSame( @@ -265,14 +265,14 @@ public static function dataFooter(): array { return [ ['
    ', null], - ["\n\n
    ", Tfoot::tag()], + ["\n\n
    ", new Tfoot()], ]; } #[DataProvider('dataFooter')] public function testFooter(string $expected, ?Tfoot $footer): void { - $this->assertSame($expected, Table::tag() + $this->assertSame($expected, new Table() ->footer($footer) ->render()); } @@ -288,12 +288,12 @@ public static function dataItemsOrder(): array . '' . "\n" . '' . "\n" . '', - Table::tag() + new Table() ->captionString('Caption of Table') - ->columnGroups(Colgroup::tag()) - ->header(Thead::tag()) - ->body(Tbody::tag()) - ->footer(Tfoot::tag()), + ->columnGroups(new Colgroup()) + ->header(new Thead()) + ->body(new Tbody()) + ->footer(new Tfoot()), ], [ '' . "\n" @@ -303,12 +303,12 @@ public static function dataItemsOrder(): array . '' . "\n" . '' . "\n" . '
    ', - Table::tag() + new Table() ->captionString('Caption of Table') - ->columns(Col::tag()) - ->header(Thead::tag()) - ->rows(Tr::tag()) - ->footer(Tfoot::tag()), + ->columns(new Col()) + ->header(new Thead()) + ->rows(new Tr()) + ->footer(new Tfoot()), ], ]; } @@ -321,7 +321,7 @@ public function testItemsOrder(string $expected, Table $tag): void public function testImmutability(): void { - $tag = Table::tag(); + $tag = new Table(); $this->assertNotSame($tag, $tag->caption(null)); $this->assertNotSame($tag, $tag->captionString('')); $this->assertNotSame($tag, $tag->columnGroups()); diff --git a/tests/Tag/TbodyTest.php b/tests/Tag/TbodyTest.php index c7d770fd..47be8219 100644 --- a/tests/Tag/TbodyTest.php +++ b/tests/Tag/TbodyTest.php @@ -23,11 +23,11 @@ public function testBase(): void . 'D' . "\n" . '' . "\n" . '', - Tbody::tag() + new Tbody() ->class('gray') ->rows( - Tr::tag()->dataStrings(['A', 'B']), - Tr::tag()->dataStrings(['C', 'D']), + new Tr()->dataStrings(['A', 'B']), + new Tr()->dataStrings(['C', 'D']), ) ->render(), ); diff --git a/tests/Tag/TdTest.php b/tests/Tag/TdTest.php index 88503564..8660f403 100644 --- a/tests/Tag/TdTest.php +++ b/tests/Tag/TdTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'hello', - Td::tag() + new Td() ->content('hello') ->render(), ); diff --git a/tests/Tag/TextareaTest.php b/tests/Tag/TextareaTest.php index 6eab4258..be9b9f0e 100644 --- a/tests/Tag/TextareaTest.php +++ b/tests/Tag/TextareaTest.php @@ -13,7 +13,7 @@ final class TextareaTest extends TestCase { public function testBase(): void { - $textarea = Textarea::tag() + $textarea = new Textarea() ->name('body') ->value('content') ->rows(6); @@ -32,7 +32,7 @@ public static function dataProviderName(): array #[DataProvider('dataProviderName')] public function testName(string $expected, ?string $name): void { - $this->assertSame($expected, (string) Textarea::tag()->name($name)); + $this->assertSame($expected, (string) new Textarea()->name($name)); } public static function dataRows(): array @@ -46,7 +46,7 @@ public static function dataRows(): array #[DataProvider('dataRows')] public function testRows(string $expected, ?int $rows): void { - $this->assertSame($expected, (string) Textarea::tag()->rows($rows)); + $this->assertSame($expected, (string) new Textarea()->rows($rows)); } public static function dataColumns(): array @@ -60,7 +60,7 @@ public static function dataColumns(): array #[DataProvider('dataColumns')] public function testColumns(string $expected, ?int $columns): void { - $this->assertSame($expected, (string) Textarea::tag()->columns($columns)); + $this->assertSame($expected, (string) new Textarea()->columns($columns)); } public static function dataValue(): array @@ -88,7 +88,7 @@ public static function dataValue(): array #[DataProvider('dataValue')] public function testValue(string $expected, mixed $value): void { - $this->assertSame($expected, (string) Textarea::tag()->value($value)); + $this->assertSame($expected, (string) new Textarea()->value($value)); } public static function dataForm(): array @@ -103,14 +103,14 @@ public static function dataForm(): array #[DataProvider('dataForm')] public function testForm(string $expected, ?string $formId): void { - $this->assertSame($expected, Textarea::tag() + $this->assertSame($expected, new Textarea() ->form($formId) ->render()); } public function testImmutability(): void { - $textarea = Textarea::tag(); + $textarea = new Textarea(); $this->assertNotSame($textarea, $textarea->name(null)); $this->assertNotSame($textarea, $textarea->rows(null)); $this->assertNotSame($textarea, $textarea->columns(null)); diff --git a/tests/Tag/TfootTest.php b/tests/Tag/TfootTest.php index fa9c0526..581167bb 100644 --- a/tests/Tag/TfootTest.php +++ b/tests/Tag/TfootTest.php @@ -23,11 +23,11 @@ public function testBase(): void . 'D' . "\n" . '' . "\n" . '', - Tfoot::tag() + new Tfoot() ->class('gray') ->rows( - Tr::tag()->dataStrings(['A', 'B']), - Tr::tag()->dataStrings(['C', 'D']), + new Tr()->dataStrings(['A', 'B']), + new Tr()->dataStrings(['C', 'D']), ) ->render(), ); diff --git a/tests/Tag/ThTest.php b/tests/Tag/ThTest.php index 1baf9c4c..9501005b 100644 --- a/tests/Tag/ThTest.php +++ b/tests/Tag/ThTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'hello', - Th::tag() + new Th() ->content('hello') ->render(), ); diff --git a/tests/Tag/TheadTest.php b/tests/Tag/TheadTest.php index e1115619..fc57e49a 100644 --- a/tests/Tag/TheadTest.php +++ b/tests/Tag/TheadTest.php @@ -23,11 +23,11 @@ public function testBase(): void . 'D' . "\n" . '' . "\n" . '', - Thead::tag() + new Thead() ->class('gray') ->rows( - Tr::tag()->dataStrings(['A', 'B']), - Tr::tag()->dataStrings(['C', 'D']), + new Tr()->dataStrings(['A', 'B']), + new Tr()->dataStrings(['C', 'D']), ) ->render(), ); diff --git a/tests/Tag/TitleTest.php b/tests/Tag/TitleTest.php index e4b5c052..0c13ea6f 100644 --- a/tests/Tag/TitleTest.php +++ b/tests/Tag/TitleTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello, World!', - (string) Title::tag()->content('Hello, World!'), + (string) new Title()->content('Hello, World!'), ); } } diff --git a/tests/Tag/TrTest.php b/tests/Tag/TrTest.php index 5027d225..43cbbb8a 100644 --- a/tests/Tag/TrTest.php +++ b/tests/Tag/TrTest.php @@ -19,7 +19,7 @@ public function testBase(): void . 'Two' . "\n" . 'Three' . "\n" . '', - Tr::tag() + new Tr() ->class('row') ->dataStrings(['One', 'Two', 'Three'], ['class' => 'cell']) ->render(), @@ -28,9 +28,9 @@ public function testBase(): void public function testCells(): void { - $tr = Tr::tag()->cells( - Th::tag()->content('A'), - Td::tag()->content('B'), + $tr = new Tr()->cells( + new Th()->content('A'), + new Td()->content('B'), ); $this->assertSame("\nA\nB\n", (string) $tr); @@ -38,16 +38,16 @@ public function testCells(): void public function testAddCells(): void { - $tr = Tr::tag() - ->cells(Td::tag()->content('A')) - ->addCells(Td::tag()->content('B')); + $tr = new Tr() + ->cells(new Td()->content('A')) + ->addCells(new Td()->content('B')); $this->assertSame("\nA\nB\n", (string) $tr); } public function testDataStrings(): void { - $tr = Tr::tag() + $tr = new Tr() ->dataStrings(['A', 'B']); $this->assertSame("\nA\nB\n", (string) $tr); @@ -55,7 +55,7 @@ public function testDataStrings(): void public function testDataStringsAttributes(): void { - $tr = Tr::tag() + $tr = new Tr() ->dataStrings(['A', 'B'], ['class' => 'red']); $this->assertSame("\nA\nB\n", (string) $tr); @@ -63,7 +63,7 @@ public function testDataStringsAttributes(): void public function testDataStringsEncode(): void { - $tr = Tr::tag() + $tr = new Tr() ->dataStrings(['A > B']); $this->assertSame("\nA > B\n", (string) $tr); @@ -71,7 +71,7 @@ public function testDataStringsEncode(): void public function testDataStringsWithoutEncode(): void { - $tr = Tr::tag() + $tr = new Tr() ->dataStrings(['A'], [], false); $this->assertSame("\nA\n", (string) $tr); @@ -79,7 +79,7 @@ public function testDataStringsWithoutEncode(): void public function testAddDataStrings(): void { - $tr = Tr::tag() + $tr = new Tr() ->dataStrings(['A']) ->addDataStrings(['B', 'C']); @@ -88,7 +88,7 @@ public function testAddDataStrings(): void public function testAddDataStringsAttributes(): void { - $tr = Tr::tag() + $tr = new Tr() ->dataStrings(['A']) ->addDataStrings(['B'], ['class' => 'red']); @@ -97,7 +97,7 @@ public function testAddDataStringsAttributes(): void public function testAddDataStringsEncode(): void { - $tr = Tr::tag() + $tr = new Tr() ->dataStrings(['A']) ->addDataStrings(['B > 1']); @@ -106,7 +106,7 @@ public function testAddDataStringsEncode(): void public function testAddDataStringsWithoutEncode(): void { - $tr = Tr::tag() + $tr = new Tr() ->dataStrings(['A']) ->addDataStrings(['B'], [], false); @@ -115,7 +115,7 @@ public function testAddDataStringsWithoutEncode(): void public function testHeaderStrings(): void { - $tr = Tr::tag() + $tr = new Tr() ->headerStrings(['A', 'B']); $this->assertSame("\nA\nB\n", (string) $tr); @@ -123,7 +123,7 @@ public function testHeaderStrings(): void public function testHeaderStringsAttributes(): void { - $tr = Tr::tag() + $tr = new Tr() ->headerStrings(['A', 'B'], ['class' => 'red']); $this->assertSame("\nA\nB\n", (string) $tr); @@ -131,7 +131,7 @@ public function testHeaderStringsAttributes(): void public function testHeaderStringsEncode(): void { - $tr = Tr::tag() + $tr = new Tr() ->headerStrings(['A > B']); $this->assertSame("\nA > B\n", (string) $tr); @@ -139,7 +139,7 @@ public function testHeaderStringsEncode(): void public function testHeaderStringsWithoutEncode(): void { - $tr = Tr::tag() + $tr = new Tr() ->headerStrings(['A'], [], false); $this->assertSame("\nA\n", (string) $tr); @@ -147,7 +147,7 @@ public function testHeaderStringsWithoutEncode(): void public function testAddHeaderStrings(): void { - $tr = Tr::tag() + $tr = new Tr() ->headerStrings(['A']) ->addHeaderStrings(['B', 'C']); @@ -156,7 +156,7 @@ public function testAddHeaderStrings(): void public function testAddHeaderStringsAttributes(): void { - $tr = Tr::tag() + $tr = new Tr() ->headerStrings(['A']) ->addHeaderStrings(['B'], ['class' => 'red']); @@ -165,7 +165,7 @@ public function testAddHeaderStringsAttributes(): void public function testAddHeaderStringsEncode(): void { - $tr = Tr::tag() + $tr = new Tr() ->headerStrings(['A']) ->addHeaderStrings(['B > 1']); @@ -174,7 +174,7 @@ public function testAddHeaderStringsEncode(): void public function testAddHeaderStringsWithoutEncode(): void { - $tr = Tr::tag() + $tr = new Tr() ->headerStrings(['A']) ->addHeaderStrings(['B'], [], false); @@ -183,7 +183,7 @@ public function testAddHeaderStringsWithoutEncode(): void public function testImmutability(): void { - $tr = Tr::tag(); + $tr = new Tr(); $this->assertNotSame($tr, $tr->cells()); $this->assertNotSame($tr, $tr->addCells()); $this->assertNotSame($tr, $tr->dataStrings([])); diff --git a/tests/Tag/TrackTest.php b/tests/Tag/TrackTest.php index 69b94090..d7ae88ff 100644 --- a/tests/Tag/TrackTest.php +++ b/tests/Tag/TrackTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) Track::tag() + (string) new Track() ->kind(Track::SUBTITLES) ->src('brave.en.vtt') ->srclang('en') @@ -24,20 +24,20 @@ public function testBase(): void public function testDefault(): void { - $this->assertSame('', (string) Track::tag()->default()); - $this->assertSame('', (string) Track::tag()->default(false)); - $this->assertSame('', (string) Track::tag() + $this->assertSame('', (string) new Track()->default()); + $this->assertSame('', (string) new Track()->default(false)); + $this->assertSame('', (string) new Track() ->default(true) ->default(false)); } public function testIsDefault(): void { - $this->assertFalse(Track::tag()->isDefault()); - $this->assertFalse(Track::tag() + $this->assertFalse(new Track()->isDefault()); + $this->assertFalse(new Track() ->default(false) ->isDefault()); - $this->assertTrue(Track::tag() + $this->assertTrue(new Track() ->default() ->isDefault()); } @@ -53,7 +53,7 @@ public static function dataKind(): array #[DataProvider('dataKind')] public function testKind(string $expected, ?string $kind): void { - $this->assertSame($expected, (string) Track::tag()->kind($kind)); + $this->assertSame($expected, (string) new Track()->kind($kind)); } public static function dataLabel(): array @@ -67,14 +67,14 @@ public static function dataLabel(): array #[DataProvider('dataLabel')] public function testLabel(string $expected, ?string $label): void { - $this->assertSame($expected, (string) Track::tag()->label($label)); + $this->assertSame($expected, (string) new Track()->label($label)); } public function testSrc(): void { $this->assertSame( '', - (string) Track::tag()->src('brave.en.vtt'), + (string) new Track()->src('brave.en.vtt'), ); } @@ -89,12 +89,12 @@ public static function dataSrclang(): array #[DataProvider('dataSrclang')] public function testSrclang(string $expected, ?string $lang): void { - $this->assertSame($expected, (string) Track::tag()->srclang($lang)); + $this->assertSame($expected, (string) new Track()->srclang($lang)); } public function testImmutability(): void { - $track = Track::tag(); + $track = new Track(); $this->assertNotSame($track, $track->default()); $this->assertNotSame($track, $track->kind(null)); $this->assertNotSame($track, $track->label(null)); diff --git a/tests/Tag/UlTest.php b/tests/Tag/UlTest.php index a2eef02b..795c37d2 100644 --- a/tests/Tag/UlTest.php +++ b/tests/Tag/UlTest.php @@ -12,9 +12,9 @@ final class UlTest extends TestCase { public function testBase(): void { - $ul = Ul::tag()->items( - Li::tag()->content('A'), - Li::tag()->content('B'), + $ul = new Ul()->items( + new Li()->content('A'), + new Li()->content('B'), ); $this->assertSame("
      \n
    • A
    • \n
    • B
    • \n
    ", (string) $ul); diff --git a/tests/Tag/VideoTest.php b/tests/Tag/VideoTest.php index b0a8b586..3ad7ab92 100644 --- a/tests/Tag/VideoTest.php +++ b/tests/Tag/VideoTest.php @@ -21,10 +21,10 @@ public function testBase(): void . '' . "\n" . 'Your browser does not support video.' . "\n" . '', - (string) Video::tag() + (string) new Video() ->controls() - ->sources(Source::tag()->src('a.mp4'), Source::tag()->src('b.avi')) - ->tracks(Track::tag()->src('c.mp4')) + ->sources(new Source()->src('a.mp4'), new Source()->src('b.avi')) + ->tracks(new Track()->src('c.mp4')) ->fallback('Your browser does not support video.'), ); } @@ -40,7 +40,7 @@ public static function dataPoster(): array #[DataProvider('dataPoster')] public function testPoster(string $expected, ?string $poster): void { - $this->assertSame($expected, (string) Video::tag()->poster($poster)); + $this->assertSame($expected, (string) new Video()->poster($poster)); } public static function dataWidth(): array @@ -55,7 +55,7 @@ public static function dataWidth(): array #[DataProvider('dataWidth')] public function testWidth(string $expected, $width): void { - $this->assertSame($expected, (string) Video::tag()->width($width)); + $this->assertSame($expected, (string) new Video()->width($width)); } public static function dataHeight(): array @@ -70,12 +70,12 @@ public static function dataHeight(): array #[DataProvider('dataHeight')] public function testHeight(string $expected, $height): void { - $this->assertSame($expected, (string) Video::tag()->height($height)); + $this->assertSame($expected, (string) new Video()->height($height)); } public function testImmutability(): void { - $tag = Video::tag(); + $tag = new Video(); $this->assertNotSame($tag, $tag->poster(null)); $this->assertNotSame($tag, $tag->width(null)); $this->assertNotSame($tag, $tag->height(null)); diff --git a/tests/Widget/ButtonGroupTest.php b/tests/Widget/ButtonGroupTest.php index 8ec51357..a79480ef 100644 --- a/tests/Widget/ButtonGroupTest.php +++ b/tests/Widget/ButtonGroupTest.php @@ -14,7 +14,7 @@ final class ButtonGroupTest extends TestCase { public function testBase(): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttons( Html::resetButton('Reset Data'), Html::submitButton('Send'), @@ -33,12 +33,12 @@ public function testBase(): void public function testWithoutButtons(): void { - $this->assertSame('', ButtonGroup::create()->render()); + $this->assertSame('', new ButtonGroup()->render()); } public function testButtonsData(): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttonsData([ ['Reset Data', 'type' => 'reset'], ['Send >', 'type' => 'submit', 'class' => 'primary'], @@ -74,7 +74,7 @@ public static function dataButtonsDataEncode(): array #[DataProvider('dataButtonsDataEncode')] public function testButtonsDataEncode(string $expected, string $label, ?bool $encode): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttonsData( [ [$label], @@ -88,7 +88,7 @@ public function testButtonsDataEncode(string $expected, string $label, ?bool $en public function testInvalidButtonsData(): void { - $widget = ButtonGroup::create(); + $widget = new ButtonGroup(); $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage( @@ -100,7 +100,7 @@ public function testInvalidButtonsData(): void public function testWithoutContainer(): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttons( Html::resetButton('Reset Data'), Html::submitButton('Send'), @@ -141,7 +141,7 @@ public static function dataContainerTag(): array #[DataProvider('dataContainerTag')] public function testContainerTag(string $expected, ?string $tagName): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttons(Html::button('Show')) ->containerTag($tagName); @@ -150,7 +150,7 @@ public function testContainerTag(string $expected, ?string $tagName): void public function testBaseContainerAttributes(): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttons(Html::button('Show')) ->containerAttributes(['id' => 'actions']); @@ -166,7 +166,7 @@ public function testBaseContainerAttributes(): void public function testAddNewButtonAttributes(): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttons( Html::button('Show'), Html::button('Hide'), @@ -186,7 +186,7 @@ public function testAddNewButtonAttributes(): void public function testMergeButtonAttributes(): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttons( Html::button('Show'), Html::button('Hide'), @@ -208,7 +208,7 @@ public function testMergeButtonAttributes(): void public function testUnionButtonAttributes(): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttons( Html::button('Show')->class('red'), Html::button('Hide'), @@ -228,7 +228,7 @@ public function testUnionButtonAttributes(): void public function testReplaceButtonAttributes(): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttons( Html::button('Show'), Html::button('Hide'), @@ -277,7 +277,7 @@ public static function dataDisabled(): array #[DataProvider('dataDisabled')] public function testDisabled(string $expected, ?bool $disabled): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttons( Html::button('Show'), Html::button('Hide'), @@ -311,7 +311,7 @@ public static function dataForm(): array #[DataProvider('dataForm')] public function testForm($expected, ?string $id): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttons( Html::button('Show'), Html::button('Hide'), @@ -324,7 +324,7 @@ public function testForm($expected, ?string $id): void public function testSeparator(): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttons( Html::button('Show'), Html::button('Hide'), @@ -343,7 +343,7 @@ public function testSeparator(): void public function testStringable(): void { - $widget = ButtonGroup::create() + $widget = new ButtonGroup() ->buttons( Html::resetButton('Reset Data'), Html::submitButton('Send'), @@ -354,7 +354,7 @@ public function testStringable(): void public function testImmutability(): void { - $widget = ButtonGroup::create(); + $widget = new ButtonGroup(); $this->assertNotSame($widget, $widget->withoutContainer()); $this->assertNotSame($widget, $widget->containerTag(null)); diff --git a/tests/Widget/CheckboxListTest.php b/tests/Widget/CheckboxListTest.php index 52d3b9ed..47bb626a 100644 --- a/tests/Widget/CheckboxListTest.php +++ b/tests/Widget/CheckboxListTest.php @@ -25,7 +25,7 @@ public function testBase(): void . '' . "\n" . '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) ->uncheckValue(0) ->value(2, 5) @@ -36,7 +36,7 @@ public function testBase(): void public function testName(): void { - $widget = CheckboxList::create('a') + $widget = new CheckboxList('a') ->items([1 => 'One']) ->name('b'); @@ -52,7 +52,7 @@ public function testWithoutContainer(): void { $this->assertSame( '', - CheckboxList::create('test') + new CheckboxList('test') ->items([1 => 'One']) ->withoutContainer() ->render(), @@ -84,7 +84,7 @@ public function testContainerTag(string $expected, ?string $name): void { $this->assertSame( $expected, - CheckboxList::create('test') + new CheckboxList('test') ->items([1 => 'One']) ->containerTag($name) ->render(), @@ -97,7 +97,7 @@ public function testContainerAttributes(): void '
    ' . "\n" . '' . "\n" . '
    ', - CheckboxList::create('test') + new CheckboxList('test') ->items([1 => 'One']) ->containerAttributes(['id' => 'main']) ->render(), @@ -109,7 +109,7 @@ public function testCheckboxAttributes(): void $this->assertSame( '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -125,7 +125,7 @@ public function testCheckboxAttributesMerge(): void $this->assertSame( '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -142,7 +142,7 @@ public function testReplaceCheckboxAttributes(): void $this->assertSame( '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -159,7 +159,7 @@ public function testCheckboxLabelAttributes(): void $this->assertSame( '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([1 => 'One', 2 => 'Two']) ->checkboxLabelAttributes(['class' => 'red']) ->withoutContainer() @@ -172,7 +172,7 @@ public function testCheckboxLabelAttributesMerge(): void $this->assertSame( '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([1 => 'One', 2 => 'Two']) ->checkboxLabelAttributes(['class' => 'red']) ->addCheckboxLabelAttributes(['data-type' => 'label']) @@ -187,7 +187,7 @@ public function testAddIndividualInputAttributes(): void '' . "\n" . '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -209,7 +209,7 @@ public function testIndividualUncheckInputAttributes(): void '' . "\n" . '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -230,7 +230,7 @@ public function testIndividualInputAttributesMerge(): void '' . "\n" . '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -256,7 +256,7 @@ public function testIndividualInputAttributesReplace(): void '' . "\n" . '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -280,7 +280,7 @@ public function testItems(): void $this->assertSame( '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -295,7 +295,7 @@ public function testItemsWithoutEncodeLabel(): void $this->assertSame( '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -331,7 +331,7 @@ public function testItemsFromValues(string $expected, array $values): void { $this->assertSame( $expected, - CheckboxList::create('test') + new CheckboxList('test') ->itemsFromValues($values) ->withoutContainer() ->render(), @@ -343,7 +343,7 @@ public function testItemsFromValuesWithoutEncodeLabel(): void $this->assertSame( '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->itemsFromValues([ 'One', 'Two', @@ -459,28 +459,28 @@ public function testValue(string $expected, array $items, array $value): void { $this->assertSame( $expected, - CheckboxList::create('test') + new CheckboxList('test') ->items($items) ->value(...$value) ->render(), ); $this->assertSame( $expected, - CheckboxList::create('test') + new CheckboxList('test') ->items($items) ->values($value) ->render(), ); $this->assertSame( $expected, - CheckboxList::create('test') + new CheckboxList('test') ->items($items) ->values(new ArrayObject($value)) ->render(), ); $this->assertSame( $expected, - CheckboxList::create('test') + new CheckboxList('test') ->items($items) ->values(new IterableObject($value)) ->render(), @@ -519,7 +519,7 @@ public function testForm(string $expected, ?string $formId): void { $this->assertSame( $expected, - CheckboxList::create('test') + new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -531,7 +531,7 @@ public function testForm(string $expected, ?string $formId): void public function testReadonly(): void { - $checkbox = CheckboxList::create('test') + $checkbox = new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -570,7 +570,7 @@ public function testReadonly(): void public function testDisabled(): void { - $checkbox = CheckboxList::create('test') + $checkbox = new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -652,7 +652,7 @@ public function testUncheckValue(string $expected, string $name, $value): void { $this->assertSame( $expected, - CheckboxList::create($name) + new CheckboxList($name) ->items([ 1 => 'One', 2 => 'Two', @@ -668,7 +668,7 @@ public function testUncheckValueDisabled(): void '' . "\n" . '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -686,7 +686,7 @@ public function testUncheckValueForm(): void '' . "\n" . '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -705,7 +705,7 @@ public function testSeparator(): void . '
    ' . '' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([1 => 'One', 2 => 'Two']) ->separator('
    ') ->render(), @@ -719,7 +719,7 @@ public function testItemFormatter(): void . '
    0)
    ' . '
    1)
    ' . "\n" . '', - CheckboxList::create('test') + new CheckboxList('test') ->items([1 => 'One', 2 => 'Two']) ->itemFormatter(fn(CheckboxItem $item): string => '
    ' . $item->index . ') ' @@ -738,7 +738,7 @@ public function testItemFormatter(): void public function testDisableCheckboxLabelWrap(): void { - $html = CheckboxList::create('test') + $html = new CheckboxList('test') ->items([1 => 'One', 2 => 'Two']) ->addIndividualInputAttributes([ 1 => ['id' => 'id1'], @@ -760,7 +760,7 @@ public function testDisableCheckboxLabelWrap(): void public function testCheckboxWrap(): void { - $html = CheckboxList::create('test') + $html = new CheckboxList('test') ->items([1 => 'One', 2 => 'Two']) ->checkboxWrapTag('div') ->checkboxWrapAttributes(['class' => 'form-check']) @@ -796,7 +796,7 @@ public static function dataCheckboxWrapClass(): array #[DataProvider('dataCheckboxWrapClass')] public function testCheckboxWrapClass(string $expected, array $class): void { - $html = CheckboxList::create('test') + $html = new CheckboxList('test') ->items([1 => 'One', 2 => 'Two']) ->checkboxWrapTag('div') ->checkboxWrapAttributes(['class' => 'form-check']) @@ -832,7 +832,7 @@ public static function dataAddCheckboxWrapClass(): array #[DataProvider('dataAddCheckboxWrapClass')] public function testAddCheckboxWrapClass(string $expected, array $class): void { - $html = CheckboxList::create('test') + $html = new CheckboxList('test') ->items([1 => 'One', 2 => 'Two']) ->checkboxWrapTag('div') ->checkboxWrapAttributes(['class' => 'form-check']) @@ -858,13 +858,13 @@ public function testStringable(): void { $this->assertSame( "
    \n
    ", - (string) CheckboxList::create('test'), + (string) new CheckboxList('test'), ); } public function testImmutability(): void { - $widget = CheckboxList::create('test'); + $widget = new CheckboxList('test'); $this->assertNotSame($widget, $widget->name('test')); $this->assertNotSame($widget, $widget->withoutContainer()); $this->assertNotSame($widget, $widget->containerTag('')); diff --git a/tests/Widget/RadioListTest.php b/tests/Widget/RadioListTest.php index 48139d3e..2cc2d805 100644 --- a/tests/Widget/RadioListTest.php +++ b/tests/Widget/RadioListTest.php @@ -23,7 +23,7 @@ public function testBase(): void . '' . "\n" . '' . "\n" . '
    ', - RadioList::create('test') + new RadioList('test') ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) ->uncheckValue(0) ->value(2) @@ -34,7 +34,7 @@ public function testBase(): void public function testName(): void { - $widget = RadioList::create('a') + $widget = new RadioList('a') ->items([1 => 'One']) ->name('b'); @@ -50,7 +50,7 @@ public function testWithoutContainer(): void { $this->assertSame( '', - RadioList::create('test') + new RadioList('test') ->items([1 => 'One']) ->withoutContainer() ->render(), @@ -82,7 +82,7 @@ public function testContainerTag(string $expected, ?string $name): void { $this->assertSame( $expected, - RadioList::create('test') + new RadioList('test') ->items([1 => 'One']) ->containerTag($name) ->render(), @@ -95,7 +95,7 @@ public function testContainerAttributes(): void '
    ' . "\n" . '' . "\n" . '
    ', - RadioList::create('test') + new RadioList('test') ->items([1 => 'One']) ->containerAttributes(['id' => 'main']) ->render(), @@ -107,7 +107,7 @@ public function testRadioAttributes(): void $this->assertSame( '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -123,7 +123,7 @@ public function testRadioAttributesMerge(): void $this->assertSame( '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -140,7 +140,7 @@ public function testReplaceRadioAttributes(): void $this->assertSame( '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -157,7 +157,7 @@ public function testRadioLabelAttributes(): void $this->assertSame( '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([1 => 'One', 2 => 'Two']) ->radioLabelAttributes(['class' => 'red']) ->withoutContainer() @@ -170,7 +170,7 @@ public function testRadioLabelAttributesMerge(): void $this->assertSame( '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([1 => 'One', 2 => 'Two']) ->radioLabelAttributes(['class' => 'red']) ->addRadioLabelAttributes(['data-type' => 'label']) @@ -185,7 +185,7 @@ public function testIndividualInputAttributes(): void '' . "\n" . '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -207,7 +207,7 @@ public function testIndividualUncheckInputAttributes(): void '' . "\n" . '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -228,7 +228,7 @@ public function testIndividualInputAttributesMerge(): void '' . "\n" . '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -254,7 +254,7 @@ public function testIndividualInputAttributesReplace(): void '' . "\n" . '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -278,7 +278,7 @@ public function testItems(): void $this->assertSame( '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -293,7 +293,7 @@ public function testItemsWithoutEncodeLabel(): void $this->assertSame( '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -329,7 +329,7 @@ public function testItemsFromValues(string $expected, array $values): void { $this->assertSame( $expected, - RadioList::create('test') + new RadioList('test') ->itemsFromValues($values) ->withoutContainer() ->render(), @@ -341,7 +341,7 @@ public function testItemsFromValuesWithoutEncodeLabel(): void $this->assertSame( '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->itemsFromValues([ 'One', 'Two', @@ -430,7 +430,7 @@ public function testValue(string $expected, array $items, $value): void { $this->assertSame( $expected, - RadioList::create('test') + new RadioList('test') ->items($items) ->value($value) ->render(), @@ -469,7 +469,7 @@ public function testForm(string $expected, ?string $formId): void { $this->assertSame( $expected, - RadioList::create('test') + new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -481,7 +481,7 @@ public function testForm(string $expected, ?string $formId): void public function testReadonly(): void { - $checkbox = RadioList::create('test') + $checkbox = new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -520,7 +520,7 @@ public function testReadonly(): void public function testDisabled(): void { - $checkbox = RadioList::create('test') + $checkbox = new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -602,7 +602,7 @@ public function testUncheckValue(string $expected, string $name, $value): void { $this->assertSame( $expected, - RadioList::create($name) + new RadioList($name) ->items([ 1 => 'One', 2 => 'Two', @@ -618,7 +618,7 @@ public function testUncheckValueDisabled(): void '' . "\n" . '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -636,7 +636,7 @@ public function testUncheckValueForm(): void '' . "\n" . '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([ 1 => 'One', 2 => 'Two', @@ -655,7 +655,7 @@ public function testSeparator(): void . '
    ' . '' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([1 => 'One', 2 => 'Two']) ->separator('
    ') ->render(), @@ -669,7 +669,7 @@ public function testItemFormatter(): void . '
    0)
    ' . '
    1)
    ' . "\n" . '', - RadioList::create('test') + new RadioList('test') ->items([1 => 'One', 2 => 'Two']) ->itemFormatter(fn(RadioItem $item): string => '
    ' . $item->index . ') ' @@ -688,7 +688,7 @@ public function testItemFormatter(): void public function testDisableRadioLabelWrap(): void { - $html = RadioList::create('test') + $html = new RadioList('test') ->items([1 => 'One', 2 => 'Two']) ->addIndividualInputAttributes([ 1 => ['id' => 'id1'], @@ -710,7 +710,7 @@ public function testDisableRadioLabelWrap(): void public function testRadioWrap(): void { - $html = RadioList::create('test') + $html = new RadioList('test') ->items([1 => 'One', 2 => 'Two']) ->radioWrapTag('div') ->radioWrapAttributes(['class' => 'form-check']) @@ -747,7 +747,7 @@ public static function dataRadioWrapClass(): array #[DataProvider('dataRadioWrapClass')] public function testRadioWrapClass(string $expected, array $class): void { - $html = RadioList::create('test') + $html = new RadioList('test') ->items([1 => 'One', 2 => 'Two']) ->radioWrapTag('div') ->radioWrapAttributes(['class' => 'form-check']) @@ -784,7 +784,7 @@ public static function dataAddRadioWrapClass(): array #[DataProvider('dataAddRadioWrapClass')] public function testAddRadioWrapClass(string $expected, array $class): void { - $html = RadioList::create('test') + $html = new RadioList('test') ->items([1 => 'One', 2 => 'Two']) ->radioWrapTag('div') ->radioWrapAttributes(['class' => 'form-check']) @@ -810,13 +810,13 @@ public function testStringable(): void { $this->assertSame( "
    \n
    ", - (string) RadioList::create('test'), + (string) new RadioList('test'), ); } public function testImmutability(): void { - $widget = RadioList::create('test'); + $widget = new RadioList('test'); $this->assertNotSame($widget, $widget->name('test')); $this->assertNotSame($widget, $widget->withoutContainer()); $this->assertNotSame($widget, $widget->containerTag('')); From 8149d9343ce0d2123cae83cde5ed869504dc2736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Wed, 4 Mar 2026 22:29:01 +0200 Subject: [PATCH 02/37] Use annotations instead of attributes for deprecation --- src/Tag/Base/NormalTag.php | 5 ++++- src/Tag/Base/VoidTag.php | 5 ++++- src/Tag/CustomTag.php | 4 +++- src/Widget/ButtonGroup.php | 5 ++++- src/Widget/CheckboxList/CheckboxList.php | 5 ++++- src/Widget/RadioList/RadioList.php | 5 ++++- 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/Tag/Base/NormalTag.php b/src/Tag/Base/NormalTag.php index c67232a4..d7f0ec99 100644 --- a/src/Tag/Base/NormalTag.php +++ b/src/Tag/Base/NormalTag.php @@ -11,9 +11,12 @@ abstract class NormalTag extends Tag { final public function __construct() {} - #[\Deprecated] + /** + * @deprecated use the constructor instead + */ final public static function tag(): static { + trigger_error('use the constructor instead', E_USER_DEPRECATED); return new static(); } diff --git a/src/Tag/Base/VoidTag.php b/src/Tag/Base/VoidTag.php index 12d618d4..e9437a24 100644 --- a/src/Tag/Base/VoidTag.php +++ b/src/Tag/Base/VoidTag.php @@ -12,9 +12,12 @@ abstract class VoidTag extends Tag { final public function __construct() {} - #[\Deprecated] + /** + * @deprecated use the constructor instead + */ final public static function tag(): static { + trigger_error('use the constructor instead', E_USER_DEPRECATED); return new static(); } diff --git a/src/Tag/CustomTag.php b/src/Tag/CustomTag.php index e6fe32f3..28cc7f3b 100644 --- a/src/Tag/CustomTag.php +++ b/src/Tag/CustomTag.php @@ -54,10 +54,12 @@ public function __construct( * @param string $name Name of the tag. * * @psalm-param non-empty-string $name + * + * @deprecated use the constructor instead */ - #[\Deprecated] public static function name(string $name): self { + trigger_error('use the constructor instead', E_USER_DEPRECATED); return new self($name); } diff --git a/src/Widget/ButtonGroup.php b/src/Widget/ButtonGroup.php index 3e5d5720..07e58288 100644 --- a/src/Widget/ButtonGroup.php +++ b/src/Widget/ButtonGroup.php @@ -34,9 +34,12 @@ public function __toString(): string return $this->render(); } - #[\Deprecated] + /** + * @deprecated use the constructor instead + */ public static function create(): self { + trigger_error('use the constructor instead', E_USER_DEPRECATED); return new self(); } diff --git a/src/Widget/CheckboxList/CheckboxList.php b/src/Widget/CheckboxList/CheckboxList.php index 43027569..c1b4cc2c 100644 --- a/src/Widget/CheckboxList/CheckboxList.php +++ b/src/Widget/CheckboxList/CheckboxList.php @@ -62,9 +62,12 @@ public function __toString(): string return $this->render(); } - #[\Deprecated] + /** + * @deprecated use the constructor instead + */ public static function create(string $name): self { + trigger_error('use the constructor instead', E_USER_DEPRECATED); return new self($name); } diff --git a/src/Widget/RadioList/RadioList.php b/src/Widget/RadioList/RadioList.php index f08339de..84df050c 100644 --- a/src/Widget/RadioList/RadioList.php +++ b/src/Widget/RadioList/RadioList.php @@ -56,9 +56,12 @@ public function __toString(): string return $this->render(); } - #[\Deprecated] + /** + * @deprecated use the constructor instead + */ public static function create(string $name): self { + trigger_error('use the constructor instead', E_USER_DEPRECATED); return new self($name); } From 5c26f95f6b6ca4dd7ec07816eb5ff24958fe5319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Wed, 4 Mar 2026 22:31:11 +0200 Subject: [PATCH 03/37] Revert "Use annotations instead of attributes for deprecation" This reverts commit 8149d9343ce0d2123cae83cde5ed869504dc2736. --- src/Tag/Base/NormalTag.php | 5 +---- src/Tag/Base/VoidTag.php | 5 +---- src/Tag/CustomTag.php | 4 +--- src/Widget/ButtonGroup.php | 5 +---- src/Widget/CheckboxList/CheckboxList.php | 5 +---- src/Widget/RadioList/RadioList.php | 5 +---- 6 files changed, 6 insertions(+), 23 deletions(-) diff --git a/src/Tag/Base/NormalTag.php b/src/Tag/Base/NormalTag.php index d7f0ec99..c67232a4 100644 --- a/src/Tag/Base/NormalTag.php +++ b/src/Tag/Base/NormalTag.php @@ -11,12 +11,9 @@ abstract class NormalTag extends Tag { final public function __construct() {} - /** - * @deprecated use the constructor instead - */ + #[\Deprecated] final public static function tag(): static { - trigger_error('use the constructor instead', E_USER_DEPRECATED); return new static(); } diff --git a/src/Tag/Base/VoidTag.php b/src/Tag/Base/VoidTag.php index e9437a24..12d618d4 100644 --- a/src/Tag/Base/VoidTag.php +++ b/src/Tag/Base/VoidTag.php @@ -12,12 +12,9 @@ abstract class VoidTag extends Tag { final public function __construct() {} - /** - * @deprecated use the constructor instead - */ + #[\Deprecated] final public static function tag(): static { - trigger_error('use the constructor instead', E_USER_DEPRECATED); return new static(); } diff --git a/src/Tag/CustomTag.php b/src/Tag/CustomTag.php index 28cc7f3b..e6fe32f3 100644 --- a/src/Tag/CustomTag.php +++ b/src/Tag/CustomTag.php @@ -54,12 +54,10 @@ public function __construct( * @param string $name Name of the tag. * * @psalm-param non-empty-string $name - * - * @deprecated use the constructor instead */ + #[\Deprecated] public static function name(string $name): self { - trigger_error('use the constructor instead', E_USER_DEPRECATED); return new self($name); } diff --git a/src/Widget/ButtonGroup.php b/src/Widget/ButtonGroup.php index 07e58288..3e5d5720 100644 --- a/src/Widget/ButtonGroup.php +++ b/src/Widget/ButtonGroup.php @@ -34,12 +34,9 @@ public function __toString(): string return $this->render(); } - /** - * @deprecated use the constructor instead - */ + #[\Deprecated] public static function create(): self { - trigger_error('use the constructor instead', E_USER_DEPRECATED); return new self(); } diff --git a/src/Widget/CheckboxList/CheckboxList.php b/src/Widget/CheckboxList/CheckboxList.php index c1b4cc2c..43027569 100644 --- a/src/Widget/CheckboxList/CheckboxList.php +++ b/src/Widget/CheckboxList/CheckboxList.php @@ -62,12 +62,9 @@ public function __toString(): string return $this->render(); } - /** - * @deprecated use the constructor instead - */ + #[\Deprecated] public static function create(string $name): self { - trigger_error('use the constructor instead', E_USER_DEPRECATED); return new self($name); } diff --git a/src/Widget/RadioList/RadioList.php b/src/Widget/RadioList/RadioList.php index 84df050c..f08339de 100644 --- a/src/Widget/RadioList/RadioList.php +++ b/src/Widget/RadioList/RadioList.php @@ -56,12 +56,9 @@ public function __toString(): string return $this->render(); } - /** - * @deprecated use the constructor instead - */ + #[\Deprecated] public static function create(string $name): self { - trigger_error('use the constructor instead', E_USER_DEPRECATED); return new self($name); } From 1044c7171b9e788adb4bc59c7547a34e53f870ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Wed, 4 Mar 2026 22:36:28 +0200 Subject: [PATCH 04/37] Add message to deprications --- src/Tag/Base/NormalTag.php | 2 +- src/Tag/Base/VoidTag.php | 2 +- src/Tag/CustomTag.php | 2 +- src/Widget/ButtonGroup.php | 2 +- src/Widget/CheckboxList/CheckboxList.php | 2 +- src/Widget/RadioList/RadioList.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Tag/Base/NormalTag.php b/src/Tag/Base/NormalTag.php index c67232a4..8516c60d 100644 --- a/src/Tag/Base/NormalTag.php +++ b/src/Tag/Base/NormalTag.php @@ -11,7 +11,7 @@ abstract class NormalTag extends Tag { final public function __construct() {} - #[\Deprecated] + #[\Deprecated('use the constructor instead')] final public static function tag(): static { return new static(); diff --git a/src/Tag/Base/VoidTag.php b/src/Tag/Base/VoidTag.php index 12d618d4..fadca73f 100644 --- a/src/Tag/Base/VoidTag.php +++ b/src/Tag/Base/VoidTag.php @@ -12,7 +12,7 @@ abstract class VoidTag extends Tag { final public function __construct() {} - #[\Deprecated] + #[\Deprecated('use the constructor instead')] final public static function tag(): static { return new static(); diff --git a/src/Tag/CustomTag.php b/src/Tag/CustomTag.php index e6fe32f3..368aab2a 100644 --- a/src/Tag/CustomTag.php +++ b/src/Tag/CustomTag.php @@ -55,7 +55,7 @@ public function __construct( * * @psalm-param non-empty-string $name */ - #[\Deprecated] + #[\Deprecated('use the constructor instead')] public static function name(string $name): self { return new self($name); diff --git a/src/Widget/ButtonGroup.php b/src/Widget/ButtonGroup.php index 3e5d5720..ebcda5f8 100644 --- a/src/Widget/ButtonGroup.php +++ b/src/Widget/ButtonGroup.php @@ -34,7 +34,7 @@ public function __toString(): string return $this->render(); } - #[\Deprecated] + #[\Deprecated('use the constructor instead')] public static function create(): self { return new self(); diff --git a/src/Widget/CheckboxList/CheckboxList.php b/src/Widget/CheckboxList/CheckboxList.php index 43027569..f93ef24f 100644 --- a/src/Widget/CheckboxList/CheckboxList.php +++ b/src/Widget/CheckboxList/CheckboxList.php @@ -62,7 +62,7 @@ public function __toString(): string return $this->render(); } - #[\Deprecated] + #[\Deprecated('use the constructor instead')] public static function create(string $name): self { return new self($name); diff --git a/src/Widget/RadioList/RadioList.php b/src/Widget/RadioList/RadioList.php index f08339de..d7895221 100644 --- a/src/Widget/RadioList/RadioList.php +++ b/src/Widget/RadioList/RadioList.php @@ -56,7 +56,7 @@ public function __toString(): string return $this->render(); } - #[\Deprecated] + #[\Deprecated('use the constructor instead')] public static function create(string $name): self { return new self($name); From d58950a8a7ef3a86cd16b7f73ddc87244c59c1f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Wed, 4 Mar 2026 22:37:57 +0200 Subject: [PATCH 05/37] Modify build and change log This is drops support for php 8.1, 8.2, 8.3 --- .github/workflows/build.yml | 2 +- .github/workflows/composer-require-checker.yml | 2 +- .github/workflows/static.yml | 2 +- CHANGELOG.md | 5 ++++- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1b1e2d89..54c85fb2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,4 +31,4 @@ jobs: os: >- ['ubuntu-latest', 'windows-latest'] php: >- - ['8.1', '8.2', '8.3', '8.4', '8.5'] + ['8.4', '8.5'] diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index e06b70e4..ae7184a7 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -31,4 +31,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.1', '8.2', '8.3', '8.4', '8.5'] + ['8.4', '8.5'] diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index b56464d6..4d97d3e8 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -29,4 +29,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.1', '8.2', '8.3', '8.4'] + ['8.4'] diff --git a/CHANGELOG.md b/CHANGELOG.md index 06d34b54..0cb473dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,11 +1,14 @@ # Yii HTML Change Log +## ?.?.0 + +- Enh #243: Use `new tagName()` without parentheses instead of static constructor `tagName::tag()` (@razvbir) + ## 3.12.1 under development - New #260: Add `$attributes` parameter to `Html::li()` method (@gauravkumar2525) - Enh #261: Enhance `RadioList::addRadioWrapClass()` method for cleaner class addition (@vjik) - Enh #263: Explicitly import classes and constants in "use" section (@mspirkov) -- Enh #243: Use `new tagName()` without parentheses instead of static constructor `tagName::tag()` (@razvbir) ## 3.12.0 December 13, 2025 From 0388219bc1781e90bbfe7290e6f4d3baa45c4917 Mon Sep 17 00:00:00 2001 From: razvbir <6582802+razvbir@users.noreply.github.com> Date: Wed, 4 Mar 2026 20:50:15 +0000 Subject: [PATCH 06/37] Apply PHP CS Fixer and Rector changes (CI) --- src/Tag/Base/NormalTag.php | 4 +++- src/Tag/Base/VoidTag.php | 4 +++- src/Tag/CustomTag.php | 3 ++- src/Widget/ButtonGroup.php | 3 ++- src/Widget/CheckboxList/CheckboxList.php | 3 ++- src/Widget/RadioList/RadioList.php | 3 ++- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Tag/Base/NormalTag.php b/src/Tag/Base/NormalTag.php index 8516c60d..31a0fcdb 100644 --- a/src/Tag/Base/NormalTag.php +++ b/src/Tag/Base/NormalTag.php @@ -4,6 +4,8 @@ namespace Yiisoft\Html\Tag\Base; +use Deprecated; + /** * Base for all normal tags. Normal tags are the ones that have both opening tag and closing tag. */ @@ -11,7 +13,7 @@ abstract class NormalTag extends Tag { final public function __construct() {} - #[\Deprecated('use the constructor instead')] + #[Deprecated('use the constructor instead')] final public static function tag(): static { return new static(); diff --git a/src/Tag/Base/VoidTag.php b/src/Tag/Base/VoidTag.php index fadca73f..7b72611f 100644 --- a/src/Tag/Base/VoidTag.php +++ b/src/Tag/Base/VoidTag.php @@ -4,6 +4,8 @@ namespace Yiisoft\Html\Tag\Base; +use Deprecated; + /** * Base for all void tags. * Void tags are immediately self-closed and have no content. @@ -12,7 +14,7 @@ abstract class VoidTag extends Tag { final public function __construct() {} - #[\Deprecated('use the constructor instead')] + #[Deprecated('use the constructor instead')] final public static function tag(): static { return new static(); diff --git a/src/Tag/CustomTag.php b/src/Tag/CustomTag.php index 368aab2a..9dd87d5b 100644 --- a/src/Tag/CustomTag.php +++ b/src/Tag/CustomTag.php @@ -6,6 +6,7 @@ use Yiisoft\Html\Tag\Base\Tag; use Yiisoft\Html\Tag\Base\TagContentTrait; +use Deprecated; /** * Custom HTML tag. @@ -55,7 +56,7 @@ public function __construct( * * @psalm-param non-empty-string $name */ - #[\Deprecated('use the constructor instead')] + #[Deprecated('use the constructor instead')] public static function name(string $name): self { return new self($name); diff --git a/src/Widget/ButtonGroup.php b/src/Widget/ButtonGroup.php index ebcda5f8..9feb0575 100644 --- a/src/Widget/ButtonGroup.php +++ b/src/Widget/ButtonGroup.php @@ -8,6 +8,7 @@ use Yiisoft\Html\Html; use Yiisoft\Html\NoEncodeStringableInterface; use Yiisoft\Html\Tag\Button; +use Deprecated; use function is_array; use function is_string; @@ -34,7 +35,7 @@ public function __toString(): string return $this->render(); } - #[\Deprecated('use the constructor instead')] + #[Deprecated('use the constructor instead')] public static function create(): self { return new self(); diff --git a/src/Widget/CheckboxList/CheckboxList.php b/src/Widget/CheckboxList/CheckboxList.php index f93ef24f..9f5dea18 100644 --- a/src/Widget/CheckboxList/CheckboxList.php +++ b/src/Widget/CheckboxList/CheckboxList.php @@ -11,6 +11,7 @@ use Yiisoft\Html\Html; use Yiisoft\Html\NoEncodeStringableInterface; use Yiisoft\Html\Tag\Input; +use Deprecated; use function is_array; @@ -62,7 +63,7 @@ public function __toString(): string return $this->render(); } - #[\Deprecated('use the constructor instead')] + #[Deprecated('use the constructor instead')] public static function create(string $name): self { return new self($name); diff --git a/src/Widget/RadioList/RadioList.php b/src/Widget/RadioList/RadioList.php index d7895221..7bc72f3d 100644 --- a/src/Widget/RadioList/RadioList.php +++ b/src/Widget/RadioList/RadioList.php @@ -10,6 +10,7 @@ use Yiisoft\Html\Html; use Yiisoft\Html\NoEncodeStringableInterface; use Yiisoft\Html\Tag\Input; +use Deprecated; /** * `RadioList` represents a list of radios and their corresponding labels. @@ -56,7 +57,7 @@ public function __toString(): string return $this->render(); } - #[\Deprecated('use the constructor instead')] + #[Deprecated('use the constructor instead')] public static function create(string $name): self { return new self($name); From 487547adc222da7ff1fba52830b941b9ee3f1921 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Wed, 4 Mar 2026 23:19:33 +0200 Subject: [PATCH 07/37] Add tests This add tests that check that the static constructor has the Deprecated attribute --- tests/Tag/Base/NormalTagTest.php | 8 ++++++++ tests/Tag/Base/VoidTagTest.php | 8 ++++++++ tests/Tag/CustomTagTest.php | 7 +++++++ tests/Widget/ButtonGroupTest.php | 7 +++++++ tests/Widget/CheckboxListTest.php | 7 +++++++ tests/Widget/RadioListTest.php | 7 +++++++ 6 files changed, 44 insertions(+) diff --git a/tests/Tag/Base/NormalTagTest.php b/tests/Tag/Base/NormalTagTest.php index 8d7a2de5..050665a1 100644 --- a/tests/Tag/Base/NormalTagTest.php +++ b/tests/Tag/Base/NormalTagTest.php @@ -5,6 +5,8 @@ namespace Yiisoft\Html\Tests\Tag\Base; use PHPUnit\Framework\TestCase; +use ReflectionFunction; +use Yiisoft\Html\Tag\Base\NormalTag; use Yiisoft\Html\Tests\Objects\TestNormalTag; final class NormalTagTest extends TestCase @@ -38,4 +40,10 @@ public function testClose(): void ->close(), ); } + + public function testDeprecation(): void + { + $func = new ReflectionFunction(NormalTag::tag(...)); + $this->assertTrue($func->isDeprecated()); + } } diff --git a/tests/Tag/Base/VoidTagTest.php b/tests/Tag/Base/VoidTagTest.php index 5dc31e00..69eeddb0 100644 --- a/tests/Tag/Base/VoidTagTest.php +++ b/tests/Tag/Base/VoidTagTest.php @@ -5,6 +5,8 @@ namespace Yiisoft\Html\Tests\Tag\Base; use PHPUnit\Framework\TestCase; +use ReflectionFunction; +use Yiisoft\Html\Tag\Base\VoidTag; use Yiisoft\Html\Tests\Objects\TestVoidTag; final class VoidTagTest extends TestCase @@ -18,4 +20,10 @@ public function testBase(): void ->render(), ); } + + public function testDeprecation(): void + { + $func = new ReflectionFunction(VoidTag::tag(...)); + $this->assertTrue($func->isDeprecated()); + } } diff --git a/tests/Tag/CustomTagTest.php b/tests/Tag/CustomTagTest.php index 0cf860cb..66367230 100644 --- a/tests/Tag/CustomTagTest.php +++ b/tests/Tag/CustomTagTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +use ReflectionFunction; use Stringable; use Yiisoft\Html\Tag\CustomTag; use Yiisoft\Html\Tag\P; @@ -185,4 +186,10 @@ public function testImmutability(): void $this->assertNotSame($tag, $tag->content('')); $this->assertNotSame($tag, $tag->addContent('')); } + + public function testDeprecation(): void + { + $func = new ReflectionFunction(CustomTag::name(...)); + $this->assertTrue($func->isDeprecated()); + } } diff --git a/tests/Widget/ButtonGroupTest.php b/tests/Widget/ButtonGroupTest.php index a79480ef..db52c0fc 100644 --- a/tests/Widget/ButtonGroupTest.php +++ b/tests/Widget/ButtonGroupTest.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +use ReflectionFunction; use Yiisoft\Html\Html; use Yiisoft\Html\Widget\ButtonGroup; @@ -367,4 +368,10 @@ public function testImmutability(): void $this->assertNotSame($widget, $widget->form(null)); $this->assertNotSame($widget, $widget->separator('')); } + + public function testDeprecation(): void + { + $func = new ReflectionFunction(ButtonGroup::create(...)); + $this->assertTrue($func->isDeprecated()); + } } diff --git a/tests/Widget/CheckboxListTest.php b/tests/Widget/CheckboxListTest.php index 47bb626a..75538b3c 100644 --- a/tests/Widget/CheckboxListTest.php +++ b/tests/Widget/CheckboxListTest.php @@ -7,6 +7,7 @@ use ArrayObject; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +use ReflectionFunction; use Yiisoft\Html\Html; use Yiisoft\Html\Tests\Objects\IterableObject; use Yiisoft\Html\Tests\Support\IntegerEnum; @@ -891,4 +892,10 @@ public function testImmutability(): void $this->assertNotSame($widget, $widget->separator('')); $this->assertNotSame($widget, $widget->itemFormatter(null)); } + + public function testDeprecation(): void + { + $func = new ReflectionFunction(CheckboxList::create(...)); + $this->assertTrue($func->isDeprecated()); + } } diff --git a/tests/Widget/RadioListTest.php b/tests/Widget/RadioListTest.php index 2cc2d805..6b4ef2f6 100644 --- a/tests/Widget/RadioListTest.php +++ b/tests/Widget/RadioListTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +use ReflectionFunction; use Yiisoft\Html\Html; use Yiisoft\Html\Tests\Support\IntegerEnum; use Yiisoft\Html\Tests\Support\StringEnum; @@ -842,4 +843,10 @@ public function testImmutability(): void $this->assertNotSame($widget, $widget->separator('')); $this->assertNotSame($widget, $widget->itemFormatter(null)); } + + public function testDeprecation(): void + { + $func = new ReflectionFunction(RadioList::create(...)); + $this->assertTrue($func->isDeprecated()); + } } From 155c84067e04e1b567b6e492f5eaa14789c51674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= <6582802+razvbir@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:10:58 +0200 Subject: [PATCH 08/37] Update src/Widget/CheckboxList/CheckboxList.php Co-authored-by: Alexander Makarov --- src/Widget/CheckboxList/CheckboxList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widget/CheckboxList/CheckboxList.php b/src/Widget/CheckboxList/CheckboxList.php index 9f5dea18..2af04b14 100644 --- a/src/Widget/CheckboxList/CheckboxList.php +++ b/src/Widget/CheckboxList/CheckboxList.php @@ -63,7 +63,7 @@ public function __toString(): string return $this->render(); } - #[Deprecated('use the constructor instead')] + #[Deprecated('Use the constructor instead.')] public static function create(string $name): self { return new self($name); From 52e7923de4f9cec7522af9807e8c6237e74ada80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= <6582802+razvbir@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:12:07 +0200 Subject: [PATCH 09/37] Update CHANGELOG.md Co-authored-by: Alexander Makarov --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cb473dd..e3c06b01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## ?.?.0 -- Enh #243: Use `new tagName()` without parentheses instead of static constructor `tagName::tag()` (@razvbir) +- Enh #243: Use `new tagName()` instead of static constructor `tagName::tag()` (@razvbir) ## 3.12.1 under development From a1e5aaa190a9ee1f72946f1a7c6386d065b148c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= <6582802+razvbir@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:14:00 +0200 Subject: [PATCH 10/37] Update src/Tag/Base/NormalTag.php Co-authored-by: Alexander Makarov --- src/Tag/Base/NormalTag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tag/Base/NormalTag.php b/src/Tag/Base/NormalTag.php index 31a0fcdb..3b07308d 100644 --- a/src/Tag/Base/NormalTag.php +++ b/src/Tag/Base/NormalTag.php @@ -13,7 +13,7 @@ abstract class NormalTag extends Tag { final public function __construct() {} - #[Deprecated('use the constructor instead')] + #[Deprecated('Use the constructor instead.')] final public static function tag(): static { return new static(); From ca0163ddc9224de2fc9dc7b2e11647c21f7e88f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= <6582802+razvbir@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:14:16 +0200 Subject: [PATCH 11/37] Update src/Tag/Base/VoidTag.php Co-authored-by: Alexander Makarov --- src/Tag/Base/VoidTag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tag/Base/VoidTag.php b/src/Tag/Base/VoidTag.php index 7b72611f..bc00e337 100644 --- a/src/Tag/Base/VoidTag.php +++ b/src/Tag/Base/VoidTag.php @@ -14,7 +14,7 @@ abstract class VoidTag extends Tag { final public function __construct() {} - #[Deprecated('use the constructor instead')] + #[Deprecated('Use the constructor instead.')] final public static function tag(): static { return new static(); From c13f890527f7a46d59ad9ba404674f4191e4aedb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= <6582802+razvbir@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:14:32 +0200 Subject: [PATCH 12/37] Update src/Tag/CustomTag.php Co-authored-by: Alexander Makarov --- src/Tag/CustomTag.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tag/CustomTag.php b/src/Tag/CustomTag.php index 9dd87d5b..7c439a49 100644 --- a/src/Tag/CustomTag.php +++ b/src/Tag/CustomTag.php @@ -56,7 +56,7 @@ public function __construct( * * @psalm-param non-empty-string $name */ - #[Deprecated('use the constructor instead')] + #[Deprecated('Use the constructor instead.')] public static function name(string $name): self { return new self($name); From 8d07325003594137d816c7a1b06c442c6ac39e0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= <6582802+razvbir@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:14:45 +0200 Subject: [PATCH 13/37] Update src/Widget/RadioList/RadioList.php Co-authored-by: Alexander Makarov --- src/Widget/RadioList/RadioList.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widget/RadioList/RadioList.php b/src/Widget/RadioList/RadioList.php index 7bc72f3d..913119d7 100644 --- a/src/Widget/RadioList/RadioList.php +++ b/src/Widget/RadioList/RadioList.php @@ -57,7 +57,7 @@ public function __toString(): string return $this->render(); } - #[Deprecated('use the constructor instead')] + #[Deprecated('Use the constructor instead.')] public static function create(string $name): self { return new self($name); From 9fab09b11b308d4c74a1954b46406d61ce3bbfbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= <6582802+razvbir@users.noreply.github.com> Date: Fri, 6 Mar 2026 23:15:08 +0200 Subject: [PATCH 14/37] Update src/Widget/ButtonGroup.php Co-authored-by: Alexander Makarov --- src/Widget/ButtonGroup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Widget/ButtonGroup.php b/src/Widget/ButtonGroup.php index 9feb0575..ef24e5e4 100644 --- a/src/Widget/ButtonGroup.php +++ b/src/Widget/ButtonGroup.php @@ -35,7 +35,7 @@ public function __toString(): string return $this->render(); } - #[Deprecated('use the constructor instead')] + #[Deprecated('Use the constructor instead.')] public static function create(): self { return new self(); From 58191cb5331b5469bedb42057da4012b7426e144 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Fri, 6 Mar 2026 23:30:49 +0200 Subject: [PATCH 15/37] Revert "Modify build and change log" This reverts commit d58950a8a7ef3a86cd16b7f73ddc87244c59c1f3. --- .github/workflows/build.yml | 2 +- .github/workflows/composer-require-checker.yml | 2 +- .github/workflows/static.yml | 2 +- CHANGELOG.md | 1 + 4 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 54c85fb2..1b1e2d89 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,4 +31,4 @@ jobs: os: >- ['ubuntu-latest', 'windows-latest'] php: >- - ['8.4', '8.5'] + ['8.1', '8.2', '8.3', '8.4', '8.5'] diff --git a/.github/workflows/composer-require-checker.yml b/.github/workflows/composer-require-checker.yml index ae7184a7..e06b70e4 100644 --- a/.github/workflows/composer-require-checker.yml +++ b/.github/workflows/composer-require-checker.yml @@ -31,4 +31,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.4', '8.5'] + ['8.1', '8.2', '8.3', '8.4', '8.5'] diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml index 4d97d3e8..b56464d6 100644 --- a/.github/workflows/static.yml +++ b/.github/workflows/static.yml @@ -29,4 +29,4 @@ jobs: os: >- ['ubuntu-latest'] php: >- - ['8.4'] + ['8.1', '8.2', '8.3', '8.4'] diff --git a/CHANGELOG.md b/CHANGELOG.md index e3c06b01..b6f34e3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - New #260: Add `$attributes` parameter to `Html::li()` method (@gauravkumar2525) - Enh #261: Enhance `RadioList::addRadioWrapClass()` method for cleaner class addition (@vjik) - Enh #263: Explicitly import classes and constants in "use" section (@mspirkov) +- Enh #243: Use `new tagName()` without parentheses instead of static constructor `tagName::tag()` (@razvbir) ## 3.12.0 December 13, 2025 From 65ac00ed9723254a9170526b568044286f7ce2fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Fri, 6 Mar 2026 23:42:11 +0200 Subject: [PATCH 16/37] CR Changes --- CHANGELOG.md | 2 +- src/Attribute/Deprecated.php | 19 +++++++ src/Html.php | 8 +-- src/Tag/Button.php | 6 +-- src/Tag/Script.php | 2 +- src/Tag/Table.php | 2 +- tests/Tag/ATest.php | 12 ++--- tests/Tag/ArticleTest.php | 6 +-- tests/Tag/AsideTest.php | 4 +- tests/Tag/AudioTest.php | 2 +- tests/Tag/Base/BooleanInputTagTest.php | 4 +- tests/Tag/Base/InputTagTest.php | 16 +++--- tests/Tag/Base/ListTagTest.php | 14 ++--- tests/Tag/Base/MediaTagTest.php | 34 ++++++------ tests/Tag/Base/TableCellTagTest.php | 4 +- tests/Tag/Base/TableRowsContainerTagTest.php | 12 ++--- tests/Tag/Base/TagContentTraitTest.php | 6 +-- tests/Tag/Base/TagTest.php | 22 ++++---- tests/Tag/BodyTest.php | 2 +- tests/Tag/ButtonTest.php | 6 +-- tests/Tag/CaptionTest.php | 2 +- tests/Tag/ColTest.php | 2 +- tests/Tag/ColgroupTest.php | 10 ++-- tests/Tag/CustomTagTest.php | 6 +-- tests/Tag/DatalistTest.php | 4 +- tests/Tag/FieldsetTest.php | 12 ++--- tests/Tag/FooterTest.php | 4 +- tests/Tag/FormTest.php | 2 +- tests/Tag/HeaderTest.php | 4 +- tests/Tag/HgroupTest.php | 6 +-- tests/Tag/HtmlTest.php | 4 +- tests/Tag/ImgTest.php | 18 +++---- tests/Tag/Input/RangeTest.php | 10 ++-- tests/Tag/InputTest.php | 2 +- tests/Tag/LabelTest.php | 2 +- tests/Tag/LegendTest.php | 2 +- tests/Tag/LinkTest.php | 18 +++---- tests/Tag/MetaTest.php | 8 +-- tests/Tag/NavTest.php | 10 ++-- tests/Tag/NoscriptTest.php | 2 +- tests/Tag/OlTest.php | 6 +-- tests/Tag/OptgroupTest.php | 22 ++++---- tests/Tag/OptionTest.php | 18 +++---- tests/Tag/ScriptTest.php | 36 ++++++------- tests/Tag/SectionTest.php | 4 +- tests/Tag/SelectTest.php | 54 ++++++++++---------- tests/Tag/SourceTest.php | 12 ++--- tests/Tag/StyleTest.php | 8 +-- tests/Tag/TableTest.php | 50 +++++++++--------- tests/Tag/TbodyTest.php | 4 +- tests/Tag/TextareaTest.php | 8 +-- tests/Tag/TfootTest.php | 4 +- tests/Tag/TheadTest.php | 4 +- tests/Tag/TitleTest.php | 2 +- tests/Tag/TrTest.php | 6 +-- tests/Tag/TrackTest.php | 12 ++--- tests/Tag/UlTest.php | 6 +-- tests/Tag/VideoTest.php | 8 +-- tests/Widget/ButtonGroupTest.php | 2 +- 59 files changed, 298 insertions(+), 279 deletions(-) create mode 100644 src/Attribute/Deprecated.php diff --git a/CHANGELOG.md b/CHANGELOG.md index b6f34e3b..3cad911e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Yii HTML Change Log -## ?.?.0 +## 3.13.0 - Enh #243: Use `new tagName()` instead of static constructor `tagName::tag()` (@razvbir) diff --git a/src/Attribute/Deprecated.php b/src/Attribute/Deprecated.php new file mode 100644 index 00000000..012f607e --- /dev/null +++ b/src/Attribute/Deprecated.php @@ -0,0 +1,19 @@ +normal(); + $tag = (new CustomTag($name))->normal(); if ($content !== '') { $tag = $tag->content($content); } @@ -352,7 +352,7 @@ public static function normalTag(string $name, string|Stringable $content = '', */ public static function voidTag(string $name, array $attributes = []): CustomTag { - $tag = new CustomTag($name)->void(); + $tag = (new CustomTag($name))->void(); if (!empty($attributes)) { $tag = $tag->attributes($attributes); } @@ -501,7 +501,7 @@ public static function cssFile(string $url, array $attributes = []): Link */ public static function javaScriptFile(string $url, array $attributes = []): Script { - $tag = new Script()->url($url); + $tag = (new Script())->url($url); if (!empty($attributes)) { $tag = $tag->addAttributes($attributes); } @@ -710,7 +710,7 @@ public static function input( bool|float|int|string|Stringable|null $value = null, array $attributes = [], ): Input { - $tag = new Input()->type($type); + $tag = (new Input())->type($type); if ($name !== null) { $tag = $tag->name($name); } diff --git a/src/Tag/Button.php b/src/Tag/Button.php index def787bc..c370eb5a 100644 --- a/src/Tag/Button.php +++ b/src/Tag/Button.php @@ -16,21 +16,21 @@ final class Button extends NormalTag public static function button(string $content = ''): self { - $button = new self()->content($content); + $button = (new self())->content($content); $button->attributes['type'] = 'button'; return $button; } public static function submit(string $content = ''): self { - $button = new self()->content($content); + $button = (new self())->content($content); $button->attributes['type'] = 'submit'; return $button; } public static function reset(string $content = ''): self { - $button = new self()->content($content); + $button = (new self())->content($content); $button->attributes['type'] = 'reset'; return $button; } diff --git a/src/Tag/Script.php b/src/Tag/Script.php index a59738a5..4716c01c 100644 --- a/src/Tag/Script.php +++ b/src/Tag/Script.php @@ -130,7 +130,7 @@ public function defer(bool $defer = true): self public function noscript(string|Stringable|null $content): self { $new = clone $this; - $new->noscript = $content === null ? null : new Noscript()->content($content); + $new->noscript = $content === null ? null : (new Noscript())->content($content); return $new; } diff --git a/src/Tag/Table.php b/src/Tag/Table.php index d0a22da9..28a11d2e 100644 --- a/src/Tag/Table.php +++ b/src/Tag/Table.php @@ -46,7 +46,7 @@ public function caption(?Caption $caption): self public function captionString(string $content, bool $encode = true): self { - $caption = new Caption()->content($content); + $caption = (new Caption())->content($content); if (!$encode) { $caption = $caption->encode(false); } diff --git a/tests/Tag/ATest.php b/tests/Tag/ATest.php index c1d3f561..a98b6534 100644 --- a/tests/Tag/ATest.php +++ b/tests/Tag/ATest.php @@ -31,7 +31,7 @@ public static function dataHref(): array #[DataProvider('dataHref')] public function testHref(string $expected, ?string $href): void { - $this->assertSame($expected, (string) new A()->href($href)); + $this->assertSame($expected, (string) (new A())->href($href)); } public static function dataUrl(): array @@ -45,7 +45,7 @@ public static function dataUrl(): array #[DataProvider('dataUrl')] public function testUrl(string $expected, ?string $url): void { - $this->assertSame($expected, (string) new A()->url($url)); + $this->assertSame($expected, (string) (new A())->url($url)); } public static function dataMailto(): array @@ -59,7 +59,7 @@ public static function dataMailto(): array #[DataProvider('dataMailto')] public function testMailto(string $expected, ?string $url): void { - $this->assertSame($expected, (string) new A()->mailto($url)); + $this->assertSame($expected, (string) (new A())->mailto($url)); } public static function dataRel(): array @@ -76,12 +76,12 @@ public static function dataRel(): array #[DataProvider('dataRel')] public function testRel(string $expected, ?string $rel): void { - $this->assertSame($expected, (string) new A()->rel($rel)); + $this->assertSame($expected, (string) (new A())->rel($rel)); } public function testNofollow(): void { - $this->assertSame('', (string) new A()->nofollow()); + $this->assertSame('', (string) (new A())->nofollow()); } public static function dataTarget(): array @@ -95,7 +95,7 @@ public static function dataTarget(): array #[DataProvider('dataTarget')] public function testTarget(string $expected, ?string $contextName): void { - $this->assertSame($expected, (string) new A()->target($contextName)); + $this->assertSame($expected, (string) (new A())->target($contextName)); } public function testImmutability(): void diff --git a/tests/Tag/ArticleTest.php b/tests/Tag/ArticleTest.php index 16b6ec98..f192fd5d 100644 --- a/tests/Tag/ArticleTest.php +++ b/tests/Tag/ArticleTest.php @@ -19,9 +19,9 @@ public function testBase(): void '

    Heading 1

    Article content

    Footer
    ', (string) new Article() ->content( - new Header()->content(new H1()->content('Heading 1')) - . new P()->content('Article content') - . new Footer()->content('Footer'), + (new Header())->content(new H1()->content('Heading 1')) + . (new P())->content('Article content') + . (new Footer())->content('Footer'), ) ->encode(false), ); diff --git a/tests/Tag/AsideTest.php b/tests/Tag/AsideTest.php index 1106be6f..f78f4475 100644 --- a/tests/Tag/AsideTest.php +++ b/tests/Tag/AsideTest.php @@ -17,8 +17,8 @@ public function testBase(): void '', (string) new Aside() ->content( - new H2()->content('Hello') - . new P()->content('Aside Tag Content'), + (new H2())->content('Hello') + . (new P())->content('Aside Tag Content'), ) ->encode(false), ); diff --git a/tests/Tag/AudioTest.php b/tests/Tag/AudioTest.php index 98ba5a31..4b68c387 100644 --- a/tests/Tag/AudioTest.php +++ b/tests/Tag/AudioTest.php @@ -22,7 +22,7 @@ public function testBase(): void . '', (string) new Audio() ->controls() - ->sources(new Source()->src('a.mp3'), new Source()->src('b.ogg')) + ->sources(new Source()->src('a.mp3'), (new Source())->src('b.ogg')) ->tracks(new Track()->src('c.mp3')) ->fallback('Your browser does not support audio.'), ); diff --git a/tests/Tag/Base/BooleanInputTagTest.php b/tests/Tag/Base/BooleanInputTagTest.php index 72d48f13..2d8f27df 100644 --- a/tests/Tag/Base/BooleanInputTagTest.php +++ b/tests/Tag/Base/BooleanInputTagTest.php @@ -12,8 +12,8 @@ final class BooleanInputTagTest extends TestCase { public function testChecked(): void { - $this->assertSame('', (string) new TestBooleanInputTag()->checked()); - $this->assertSame('', (string) new TestBooleanInputTag()->checked(false)); + $this->assertSame('', (string) (new TestBooleanInputTag())->checked()); + $this->assertSame('', (string) (new TestBooleanInputTag())->checked(false)); $this->assertSame('', (string) new TestBooleanInputTag() ->checked(true) ->checked(false)); diff --git a/tests/Tag/Base/InputTagTest.php b/tests/Tag/Base/InputTagTest.php index e4637e84..67907586 100644 --- a/tests/Tag/Base/InputTagTest.php +++ b/tests/Tag/Base/InputTagTest.php @@ -22,7 +22,7 @@ public static function dataProviderName(): array #[DataProvider('dataProviderName')] public function testName(string $expected, ?string $name): void { - $this->assertSame($expected, (string) new TestInputTag()->name($name)); + $this->assertSame($expected, (string) (new TestInputTag())->name($name)); } public static function dataValue(): array @@ -42,7 +42,7 @@ public static function dataValue(): array #[DataProvider('dataValue')] public function testValue(string $expected, $value): void { - $this->assertSame($expected, (string) new TestInputTag()->value($value)); + $this->assertSame($expected, (string) (new TestInputTag())->value($value)); } public static function dataForm(): array @@ -64,8 +64,8 @@ public function testForm(string $expected, ?string $formId): void public function testReadonly(): void { - $this->assertSame('', (string) new TestInputTag()->readonly()); - $this->assertSame('', (string) new TestInputTag()->readonly(false)); + $this->assertSame('', (string) (new TestInputTag())->readonly()); + $this->assertSame('', (string) (new TestInputTag())->readonly(false)); $this->assertSame('', (string) new TestInputTag() ->readonly(true) ->readonly(false)); @@ -73,8 +73,8 @@ public function testReadonly(): void public function testRequired(): void { - $this->assertSame('', (string) new TestInputTag()->required()); - $this->assertSame('', (string) new TestInputTag()->required(false)); + $this->assertSame('', (string) (new TestInputTag())->required()); + $this->assertSame('', (string) (new TestInputTag())->required(false)); $this->assertSame('', (string) new TestInputTag() ->required(true) ->required(false)); @@ -82,8 +82,8 @@ public function testRequired(): void public function testDisabled(): void { - $this->assertSame('', (string) new TestInputTag()->disabled()); - $this->assertSame('', (string) new TestInputTag()->disabled(false)); + $this->assertSame('', (string) (new TestInputTag())->disabled()); + $this->assertSame('', (string) (new TestInputTag())->disabled(false)); $this->assertSame('', (string) new TestInputTag() ->disabled(true) ->disabled(false)); diff --git a/tests/Tag/Base/ListTagTest.php b/tests/Tag/Base/ListTagTest.php index eac2e4e9..22ab0cff 100644 --- a/tests/Tag/Base/ListTagTest.php +++ b/tests/Tag/Base/ListTagTest.php @@ -12,9 +12,9 @@ final class ListTagTest extends TestCase { public function testItems(): void { - $tag = new TestListTag()->items( - new Li()->content('A'), - new Li()->content('B'), + $tag = (new TestListTag())->items( + (new Li())->content('A'), + (new Li())->content('B'), ); $this->assertSame("\n
  • A
  • \n
  • B
  • \n
    ", (string) $tag); @@ -22,14 +22,14 @@ public function testItems(): void public function testStrings(): void { - $tag = new TestListTag()->strings(['A', 'B']); + $tag = (new TestListTag())->strings(['A', 'B']); $this->assertSame("\n
  • A
  • \n
  • B
  • \n
    ", (string) $tag); } public function testStringsAttributes(): void { - $tag = new TestListTag()->strings(['A', 'B'], ['class' => 'red']); + $tag = (new TestListTag())->strings(['A', 'B'], ['class' => 'red']); $this->assertSame( "\n
  • A
  • \n
  • B
  • \n
    ", @@ -39,7 +39,7 @@ public function testStringsAttributes(): void public function testStringsEncode(): void { - $tag = new TestListTag()->strings(['A', 'B']); + $tag = (new TestListTag())->strings(['A', 'B']); $this->assertSame( "\n
  • <b>A</b>
  • \n
  • <b>B</b>
  • \n
    ", @@ -49,7 +49,7 @@ public function testStringsEncode(): void public function testStringsWithoutEncode(): void { - $tag = new TestListTag()->strings(['A', 'B'], [], false); + $tag = (new TestListTag())->strings(['A', 'B'], [], false); $this->assertSame("\n
  • A
  • \n
  • B
  • \n
    ", (string) $tag); } diff --git a/tests/Tag/Base/MediaTagTest.php b/tests/Tag/Base/MediaTagTest.php index c84cf387..5aa5a693 100644 --- a/tests/Tag/Base/MediaTagTest.php +++ b/tests/Tag/Base/MediaTagTest.php @@ -24,7 +24,7 @@ public function testBase(): void . '', (string) new TestMediaTag() ->controls() - ->sources(new Source()->src('a.mp3'), new Source()->src('b.ogg')) + ->sources(new Source()->src('a.mp3'), (new Source())->src('b.ogg')) ->tracks(new Track()->src('c.mp3')) ->fallback('Your browser does not support media.'), ); @@ -43,15 +43,15 @@ public static function dataFallback(): array #[DataProvider('dataFallback')] public function testFallback($fallback): void { - $tag = new TestMediaTag()->fallback($fallback); + $tag = (new TestMediaTag())->fallback($fallback); $this->assertSame('' . "\n" . $fallback . "\n" . '', (string) $tag); } public function testTracks(): void { - $tag = new TestMediaTag()->tracks( - new Track()->src('a.mp4'), - new Track()->src('b.mp4'), + $tag = (new TestMediaTag())->tracks( + (new Track())->src('a.mp4'), + (new Track())->src('b.mp4'), ); $this->assertSame("\n\n\n", (string) $tag); @@ -81,7 +81,7 @@ public static function dataSrc(): array #[DataProvider('dataSrc')] public function testSrc(string $expected, ?string $url): void { - $this->assertSame($expected, (string) new TestMediaTag()->src($url)); + $this->assertSame($expected, (string) (new TestMediaTag())->src($url)); } public static function dataCrossOrigin(): array @@ -95,7 +95,7 @@ public static function dataCrossOrigin(): array #[DataProvider('dataCrossOrigin')] public function testCrossOrigin(string $expected, ?string $crossOrigin): void { - $this->assertSame($expected, (string) new TestMediaTag()->crossOrigin($crossOrigin)); + $this->assertSame($expected, (string) (new TestMediaTag())->crossOrigin($crossOrigin)); } public static function dataPreload(): array @@ -109,13 +109,13 @@ public static function dataPreload(): array #[DataProvider('dataPreload')] public function testPreload(string $expected, ?string $preload): void { - $this->assertSame($expected, (string) new TestMediaTag()->preload($preload)); + $this->assertSame($expected, (string) (new TestMediaTag())->preload($preload)); } public function testMuted(): void { - $this->assertSame('', (string) new TestMediaTag()->muted()); - $this->assertSame('', (string) new TestMediaTag()->muted(false)); + $this->assertSame('', (string) (new TestMediaTag())->muted()); + $this->assertSame('', (string) (new TestMediaTag())->muted(false)); $this->assertSame('', (string) new TestMediaTag() ->muted(true) ->muted(false)); @@ -123,8 +123,8 @@ public function testMuted(): void public function testLoop(): void { - $this->assertSame('', (string) new TestMediaTag()->loop()); - $this->assertSame('', (string) new TestMediaTag()->loop(false)); + $this->assertSame('', (string) (new TestMediaTag())->loop()); + $this->assertSame('', (string) (new TestMediaTag())->loop(false)); $this->assertSame('', (string) new TestMediaTag() ->loop(true) ->loop(false)); @@ -132,8 +132,8 @@ public function testLoop(): void public function testAutoplay(): void { - $this->assertSame('', (string) new TestMediaTag()->autoplay()); - $this->assertSame('', (string) new TestMediaTag()->autoplay(false)); + $this->assertSame('', (string) (new TestMediaTag())->autoplay()); + $this->assertSame('', (string) (new TestMediaTag())->autoplay(false)); $this->assertSame('', (string) new TestMediaTag() ->autoplay(true) ->autoplay(false)); @@ -141,8 +141,8 @@ public function testAutoplay(): void public function testControls(): void { - $this->assertSame('', (string) new TestMediaTag()->controls()); - $this->assertSame('', (string) new TestMediaTag()->controls(false)); + $this->assertSame('', (string) (new TestMediaTag())->controls()); + $this->assertSame('', (string) (new TestMediaTag())->controls(false)); $this->assertSame('', (string) new TestMediaTag() ->controls(true) ->controls(false)); @@ -150,7 +150,7 @@ public function testControls(): void public function testWrongTrackDefault(): void { - $tag = new TestMediaTag()->tracks( + $tag = (new TestMediaTag())->tracks( new Track() ->kind('captions') ->src('sampleCaptions.vtt') diff --git a/tests/Tag/Base/TableCellTagTest.php b/tests/Tag/Base/TableCellTagTest.php index 6d7f524b..b50cd77e 100644 --- a/tests/Tag/Base/TableCellTagTest.php +++ b/tests/Tag/Base/TableCellTagTest.php @@ -21,7 +21,7 @@ public static function dataColSpan(): array #[DataProvider('dataColSpan')] public function testColSpan(string $expected, ?int $number): void { - $this->assertSame($expected, (string) new TestTableCellTag()->colSpan($number)); + $this->assertSame($expected, (string) (new TestTableCellTag())->colSpan($number)); } public static function dataRowSpan(): array @@ -35,7 +35,7 @@ public static function dataRowSpan(): array #[DataProvider('dataRowSpan')] public function testRowSpan(string $expected, ?int $number): void { - $this->assertSame($expected, (string) new TestTableCellTag()->rowSpan($number)); + $this->assertSame($expected, (string) (new TestTableCellTag())->rowSpan($number)); } public function testImmutability(): void diff --git a/tests/Tag/Base/TableRowsContainerTagTest.php b/tests/Tag/Base/TableRowsContainerTagTest.php index ab5e5ffe..5e09d9d8 100644 --- a/tests/Tag/Base/TableRowsContainerTagTest.php +++ b/tests/Tag/Base/TableRowsContainerTagTest.php @@ -12,9 +12,9 @@ final class TableRowsContainerTagTest extends TestCase { public function testRows(): void { - $tag = new TestTableRowsContainerTag()->rows( - new Tr()->dataStrings(['A', 'B']), - new Tr()->dataStrings(['C', 'D']), + $tag = (new TestTableRowsContainerTag())->rows( + (new Tr())->dataStrings(['A', 'B']), + (new Tr())->dataStrings(['C', 'D']), ); $this->assertSame( @@ -36,11 +36,11 @@ public function testAddRows(): void { $tag = new TestTableRowsContainerTag() ->rows( - new Tr()->dataStrings(['A', 'B']), + (new Tr())->dataStrings(['A', 'B']), ) ->addRows( - new Tr()->dataStrings(['C', 'D']), - new Tr()->dataStrings(['E', 'F']), + (new Tr())->dataStrings(['C', 'D']), + (new Tr())->dataStrings(['E', 'F']), ); $this->assertSame( diff --git a/tests/Tag/Base/TagContentTraitTest.php b/tests/Tag/Base/TagContentTraitTest.php index a47ca723..00197d24 100644 --- a/tests/Tag/Base/TagContentTraitTest.php +++ b/tests/Tag/Base/TagContentTraitTest.php @@ -52,10 +52,10 @@ public static function dataContent(): array return [ 'string' => ['hello', 'hello'], 'string-tag' => ['<p>Hi!</p>', '

    Hi!

    '], - 'object-tag' => ['

    Hi!

    ', new P()->content('Hi!')], + 'object-tag' => ['

    Hi!

    ', (new P())->content('Hi!')], 'array' => [ 'Hello > World!', - ['Hello', ' > ', new Span()->content('World'), '!'], + ['Hello', ' > ', (new Span())->content('World'), '!'], ], ]; } @@ -117,7 +117,7 @@ public function testNamedParametersContent(): void public function testContentArray(): void { - $tag = new TestTagContentTrait()->content(a: '1', b: '2'); + $tag = (new TestTagContentTrait())->content(a: '1', b: '2'); $this->assertSame(['1', '2'], $tag->getContentArray()); } diff --git a/tests/Tag/Base/TagTest.php b/tests/Tag/Base/TagTest.php index 35644d8b..7a7d9e23 100644 --- a/tests/Tag/Base/TagTest.php +++ b/tests/Tag/Base/TagTest.php @@ -62,8 +62,8 @@ public static function dataAttributes(): array #[DataProvider('dataAttributes')] public function testAttributes(string $expected, array $attributes): void { - $this->assertSame($expected, (string) new TestTag()->addAttributes($attributes)); - $this->assertSame($expected, (string) new TestTag()->attributes($attributes)); + $this->assertSame($expected, (string) (new TestTag())->addAttributes($attributes)); + $this->assertSame($expected, (string) (new TestTag())->attributes($attributes)); } public function testAttributesMerge(): void @@ -129,7 +129,7 @@ public static function dataId(): array #[DataProvider('dataId')] public function testId(string $expected, ?string $id): void { - $this->assertSame($expected, (string) new TestTag()->id($id)); + $this->assertSame($expected, (string) (new TestTag())->id($id)); } public static function dataAddClass(): array @@ -168,7 +168,7 @@ public static function dataNewClass(): array #[DataProvider('dataNewClass')] public function testNewClass(string $expected, ?string $class): void { - $this->assertSame($expected, (string) new TestTag()->addClass($class)); + $this->assertSame($expected, (string) (new TestTag())->addClass($class)); } public static function dataClass(): array @@ -206,13 +206,13 @@ public static function dataAddStyle(): iterable #[DataProvider('dataAddStyle')] public function testAddStyle(string $expected, array|string $style): void { - $result = (string) new TestTag()->addStyle($style); + $result = (string) (new TestTag())->addStyle($style); $this->assertSame($expected, $result); } public function testAddStyleMerging(): void { - $tag = new TestTag()->addStyle('width: 100px;'); + $tag = (new TestTag())->addStyle('width: 100px;'); $result = (string) $tag->addStyle(['width' => '200px', 'height' => '300px']); @@ -224,7 +224,7 @@ public function testAddStyleMerging(): void public function testAddStyleMergingWithoutOverwrite(): void { - $tag = new TestTag()->addStyle('width: 100px;'); + $tag = (new TestTag())->addStyle('width: 100px;'); $result = (string) $tag->addStyle(['width' => '200px', 'height' => '300px'], false); @@ -236,7 +236,7 @@ public function testAddStyleMergingWithoutOverwrite(): void public function testAddStyleWithExistingAttribute(): void { - $tag = new TestTag()->attribute('style', 'color: red;'); + $tag = (new TestTag())->attribute('style', 'color: red;'); $result = (string) $tag->addStyle('width: 100px;'); @@ -255,17 +255,17 @@ public static function dataRemoveStyle(): iterable ]; yield [ '', - new TestTag()->addStyle('width: 100px;'), + (new TestTag())->addStyle('width: 100px;'), 'width', ]; yield [ '', - new TestTag()->addStyle('height: 100px; width: 100px;'), + (new TestTag())->addStyle('height: 100px; width: 100px;'), 'width', ]; yield [ '', - new TestTag()->addStyle('height: 100px; width: 100px; color: red;'), + (new TestTag())->addStyle('height: 100px; width: 100px; color: red;'), ['width', 'height'], ]; } diff --git a/tests/Tag/BodyTest.php b/tests/Tag/BodyTest.php index a17b1f66..06d810ff 100644 --- a/tests/Tag/BodyTest.php +++ b/tests/Tag/BodyTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Welcome!', - (string) new Body()->content('Welcome!'), + (string) (new Body())->content('Welcome!'), ); } diff --git a/tests/Tag/ButtonTest.php b/tests/Tag/ButtonTest.php index 0c2735d8..e1b58627 100644 --- a/tests/Tag/ButtonTest.php +++ b/tests/Tag/ButtonTest.php @@ -79,13 +79,13 @@ public static function dataType(): array #[DataProvider('dataType')] public function testType(string $expected, ?string $type): void { - $this->assertSame($expected, (string) new Button()->type($type)); + $this->assertSame($expected, (string) (new Button())->type($type)); } public function testDisabled(): void { - $this->assertSame('', (string) new Button()->disabled()); - $this->assertSame('', (string) new Button()->disabled(false)); + $this->assertSame('', (string) (new Button())->disabled()); + $this->assertSame('', (string) (new Button())->disabled(false)); $this->assertSame('', (string) new Button() ->disabled(true) ->disabled(false)); diff --git a/tests/Tag/CaptionTest.php b/tests/Tag/CaptionTest.php index 26c8a1f4..85398bb5 100644 --- a/tests/Tag/CaptionTest.php +++ b/tests/Tag/CaptionTest.php @@ -17,7 +17,7 @@ public function testBase(): void new Caption() ->content( 'Table ', - new CustomTag('b')->content('Caption'), + (new CustomTag('b'))->content('Caption'), ) ->render(), ); diff --git a/tests/Tag/ColTest.php b/tests/Tag/ColTest.php index 6a2f2ebd..7b3f8056 100644 --- a/tests/Tag/ColTest.php +++ b/tests/Tag/ColTest.php @@ -34,7 +34,7 @@ public function testSpan(string $expected, ?int $span): void { $this->assertSame( $expected, - new Col()->span($span)->render(), + (new Col())->span($span)->render(), ); } diff --git a/tests/Tag/ColgroupTest.php b/tests/Tag/ColgroupTest.php index e01b1be1..30a77f99 100644 --- a/tests/Tag/ColgroupTest.php +++ b/tests/Tag/ColgroupTest.php @@ -35,9 +35,9 @@ public function testBase(): void public function testColumns(): void { - $tag = new Colgroup()->columns( + $tag = (new Colgroup())->columns( new Col(), - new Col()->span(2), + (new Col())->span(2), ); $this->assertSame( @@ -54,11 +54,11 @@ public function testAddColumns(): void $tag = new Colgroup() ->columns( new Col(), - new Col()->span(2), + (new Col())->span(2), ) ->addColumns( - new Col()->span(3), - new Col()->span(4), + (new Col())->span(3), + (new Col())->span(4), ); $this->assertSame( diff --git a/tests/Tag/CustomTagTest.php b/tests/Tag/CustomTagTest.php index 66367230..7888e4d9 100644 --- a/tests/Tag/CustomTagTest.php +++ b/tests/Tag/CustomTagTest.php @@ -44,7 +44,7 @@ public function testVoidTags(string $name): void { $this->assertSame( "<$name>", - new CustomTag($name)->render(), + (new CustomTag($name))->render(), ); } @@ -105,10 +105,10 @@ public static function dataContent(): array return [ 'string' => ['hello', 'hello'], 'string-tag' => ['<p>Hi!</p>', '

    Hi!

    '], - 'object-tag' => ['

    Hi!

    ', new P()->content('Hi!')], + 'object-tag' => ['

    Hi!

    ', (new P())->content('Hi!')], 'array' => [ 'Hello > World!', - ['Hello', ' > ', new Span()->content('World'), '!'], + ['Hello', ' > ', (new Span())->content('World'), '!'], ], ]; } diff --git a/tests/Tag/DatalistTest.php b/tests/Tag/DatalistTest.php index 0e5399b9..6c4272a5 100644 --- a/tests/Tag/DatalistTest.php +++ b/tests/Tag/DatalistTest.php @@ -15,8 +15,8 @@ public function testBase(): void $tag = new Datalist() ->id('numbers') ->content( - new Option()->value('One'), - new Option()->value('Two'), + (new Option())->value('One'), + (new Option())->value('Two'), ); $this->assertSame( diff --git a/tests/Tag/FieldsetTest.php b/tests/Tag/FieldsetTest.php index 66ca45d0..d57928e0 100644 --- a/tests/Tag/FieldsetTest.php +++ b/tests/Tag/FieldsetTest.php @@ -65,7 +65,7 @@ public static function dataLegend(): array #[DataProvider('dataLegend')] public function testLegend(string $expected, $content, array $attributes = []): void { - $tag = new Fieldset()->legend($content, $attributes); + $tag = (new Fieldset())->legend($content, $attributes); $this->assertSame($expected, $tag->render()); } @@ -93,7 +93,7 @@ public static function dataLegendTag(): array #[DataProvider('dataLegendTag')] public function testLegendTag(string $expected, ?Legend $legend): void { - $tag = new Fieldset()->legendTag($legend); + $tag = (new Fieldset())->legendTag($legend); $this->assertSame($expected, $tag->render()); } @@ -119,14 +119,14 @@ public static function dataDisabled(): array #[DataProvider('dataDisabled')] public function testDisabled(string $expected, ?bool $disabled): void { - $tag = new Fieldset()->disabled($disabled); + $tag = (new Fieldset())->disabled($disabled); $this->assertSame($expected, $tag->render()); } public function testDisabledDefault(): void { - $tag = new Fieldset()->disabled(); + $tag = (new Fieldset())->disabled(); $this->assertSame('
    ', $tag->render()); } @@ -142,7 +142,7 @@ public static function dataForm(): array #[DataProvider('dataForm')] public function testForm(string $expected, ?string $formId): void { - $tag = new Fieldset()->form($formId); + $tag = (new Fieldset())->form($formId); $this->assertSame($expected, $tag->render()); } @@ -158,7 +158,7 @@ public static function dataProviderName(): array #[DataProvider('dataProviderName')] public function testName(string $expected, ?string $formId): void { - $tag = new Fieldset()->name($formId); + $tag = (new Fieldset())->name($formId); $this->assertSame($expected, $tag->render()); } diff --git a/tests/Tag/FooterTest.php b/tests/Tag/FooterTest.php index 29192e31..5405d084 100644 --- a/tests/Tag/FooterTest.php +++ b/tests/Tag/FooterTest.php @@ -17,8 +17,8 @@ public function testBase(): void '

    Heading 1

    Hello Text

    ', (string) new Footer() ->content( - new H3()->content('Heading 1') - . new P()->content('Hello Text'), + (new H3())->content('Heading 1') + . (new P())->content('Hello Text'), ) ->encode(false), ); diff --git a/tests/Tag/FormTest.php b/tests/Tag/FormTest.php index 8b9290d9..9728ee9a 100644 --- a/tests/Tag/FormTest.php +++ b/tests/Tag/FormTest.php @@ -75,7 +75,7 @@ public function testPostWithoutUrl(): void public function testCsrf(): void { - $tag = new Form()->csrf('abc', 'csrf-token'); + $tag = (new Form())->csrf('abc', 'csrf-token'); $this->assertSame( '
    ' . "\n" diff --git a/tests/Tag/HeaderTest.php b/tests/Tag/HeaderTest.php index ae2d5f9a..4530ca4b 100644 --- a/tests/Tag/HeaderTest.php +++ b/tests/Tag/HeaderTest.php @@ -17,8 +17,8 @@ public function testBase(): void '

    Heading 1

    Hello Text
    ', (string) new Header() ->content( - new H1()->content('Heading 1') - . new I()->content('Hello Text'), + (new H1())->content('Heading 1') + . (new I())->content('Hello Text'), ) ->encode(false), ); diff --git a/tests/Tag/HgroupTest.php b/tests/Tag/HgroupTest.php index f9648f31..a643165a 100644 --- a/tests/Tag/HgroupTest.php +++ b/tests/Tag/HgroupTest.php @@ -18,9 +18,9 @@ public function testBase(): void '

    Heading 1

    Heading 2

    Heading 3

    ', (string) new Hgroup() ->content( - new H1()->content('Heading 1') - . new H2()->content('Heading 2') - . new H3()->content('Heading 3'), + (new H1())->content('Heading 1') + . (new H2())->content('Heading 2') + . (new H3())->content('Heading 3'), ) ->encode(false), ); diff --git a/tests/Tag/HtmlTest.php b/tests/Tag/HtmlTest.php index 25aef7a6..5f3eb08d 100644 --- a/tests/Tag/HtmlTest.php +++ b/tests/Tag/HtmlTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( 'Welcome!', - (string) new Html()->content('Welcome!'), + (string) (new Html())->content('Welcome!'), ); } @@ -42,7 +42,7 @@ public static function dataLang(): array #[DataProvider('dataLang')] public function testLang(string $expected, ?string $href): void { - $this->assertSame($expected, (string) new Html()->lang($href)); + $this->assertSame($expected, (string) (new Html())->lang($href)); } public function testImmutability(): void diff --git a/tests/Tag/ImgTest.php b/tests/Tag/ImgTest.php index c7ea824d..417fb1fa 100644 --- a/tests/Tag/ImgTest.php +++ b/tests/Tag/ImgTest.php @@ -31,8 +31,8 @@ public static function dataUrl(): array #[DataProvider('dataUrl')] public function testUrl(string $expected, ?string $url): void { - $this->assertSame($expected, (string) new Img()->url($url)); - $this->assertSame($expected, (string) new Img()->src($url)); + $this->assertSame($expected, (string) (new Img())->url($url)); + $this->assertSame($expected, (string) (new Img())->src($url)); } public static function dataSrcset(): array @@ -48,7 +48,7 @@ public static function dataSrcset(): array #[DataProvider('dataSrcset')] public function testSrcset(string $expected, array $items): void { - $this->assertSame($expected, (string) new Img()->srcset(...$items)); + $this->assertSame($expected, (string) (new Img())->srcset(...$items)); } public static function dataSrcsetData(): array @@ -70,7 +70,7 @@ public static function dataSrcsetData(): array #[DataProvider('dataSrcsetData')] public function testSrcsetData(string $expected, array $items): void { - $this->assertSame($expected, (string) new Img()->srcsetData($items)); + $this->assertSame($expected, (string) (new Img())->srcsetData($items)); } public static function dataAlt(): array @@ -84,7 +84,7 @@ public static function dataAlt(): array #[DataProvider('dataAlt')] public function testAlt(string $expected, ?string $text): void { - $this->assertSame($expected, (string) new Img()->alt($text)); + $this->assertSame($expected, (string) (new Img())->alt($text)); } public static function dataWidth(): array @@ -99,7 +99,7 @@ public static function dataWidth(): array #[DataProvider('dataWidth')] public function testWidth(string $expected, $width): void { - $this->assertSame($expected, (string) new Img()->width($width)); + $this->assertSame($expected, (string) (new Img())->width($width)); } public static function dataHeight(): array @@ -114,7 +114,7 @@ public static function dataHeight(): array #[DataProvider('dataHeight')] public function testHeight(string $expected, $height): void { - $this->assertSame($expected, (string) new Img()->height($height)); + $this->assertSame($expected, (string) (new Img())->height($height)); } public static function dataSize(): array @@ -129,7 +129,7 @@ public static function dataSize(): array #[DataProvider('dataSize')] public function testSize(string $expected, $width, $height): void { - $this->assertSame($expected, (string) new Img()->size($width, $height)); + $this->assertSame($expected, (string) (new Img())->size($width, $height)); } public static function dataLoading(): array @@ -144,7 +144,7 @@ public static function dataLoading(): array #[DataProvider('dataLoading')] public function testLoading(string $expected, ?string $loading): void { - $this->assertSame($expected, (string) new Img()->loading($loading)); + $this->assertSame($expected, (string) (new Img())->loading($loading)); } public function testImmutability(): void diff --git a/tests/Tag/Input/RangeTest.php b/tests/Tag/Input/RangeTest.php index 3cb58dfb..94f92e74 100644 --- a/tests/Tag/Input/RangeTest.php +++ b/tests/Tag/Input/RangeTest.php @@ -41,7 +41,7 @@ public static function dataMin(): array #[DataProvider('dataMin')] public function testMin(string $expected, $value): void { - $tag = new Range()->min($value); + $tag = (new Range())->min($value); $this->assertSame($expected, $tag->render()); } @@ -61,7 +61,7 @@ public static function dataMax(): array #[DataProvider('dataMax')] public function testMax(string $expected, $value): void { - $tag = new Range()->max($value); + $tag = (new Range())->max($value); $this->assertSame($expected, $tag->render()); } @@ -81,7 +81,7 @@ public static function dataStep(): array #[DataProvider('dataStep')] public function testStep(string $expected, $value): void { - $tag = new Range()->step($value); + $tag = (new Range())->step($value); $this->assertSame($expected, $tag->render()); } @@ -97,14 +97,14 @@ public static function dataList(): array #[DataProvider('dataList')] public function testList(string $expected, $value): void { - $tag = new Range()->list($value); + $tag = (new Range())->list($value); $this->assertSame($expected, $tag->render()); } public function testShowOutput(): void { - $tag = new Range()->showOutput(); + $tag = (new Range())->showOutput(); $this->assertMatchesRegularExpression( '~assertSame($expected, (string) new Input()->type($type)); + $this->assertSame($expected, (string) (new Input())->type($type)); } public function testImmutability(): void diff --git a/tests/Tag/LabelTest.php b/tests/Tag/LabelTest.php index a0271c94..f30738c7 100644 --- a/tests/Tag/LabelTest.php +++ b/tests/Tag/LabelTest.php @@ -31,7 +31,7 @@ public static function dataForId(): array #[DataProvider('dataForId')] public function testForId(string $expected, ?string $id): void { - $this->assertSame($expected, (string) new Label()->forId($id)); + $this->assertSame($expected, (string) (new Label())->forId($id)); } public function testImmutability(): void diff --git a/tests/Tag/LegendTest.php b/tests/Tag/LegendTest.php index 637dce52..13b8ffef 100644 --- a/tests/Tag/LegendTest.php +++ b/tests/Tag/LegendTest.php @@ -11,7 +11,7 @@ final class LegendTest extends TestCase { public function testBase(): void { - $tag = new Legend()->content('Personal data'); + $tag = (new Legend())->content('Personal data'); $this->assertSame('Personal data', $tag->render()); } } diff --git a/tests/Tag/LinkTest.php b/tests/Tag/LinkTest.php index c0a1b112..7314870d 100644 --- a/tests/Tag/LinkTest.php +++ b/tests/Tag/LinkTest.php @@ -41,8 +41,8 @@ public static function dataUrl(): array #[DataProvider('dataUrl')] public function testUrl(string $expected, ?string $url): void { - $this->assertSame($expected, (string) new Link()->url($url)); - $this->assertSame($expected, (string) new Link()->href($url)); + $this->assertSame($expected, (string) (new Link())->url($url)); + $this->assertSame($expected, (string) (new Link())->href($url)); } public static function dataRel(): array @@ -56,7 +56,7 @@ public static function dataRel(): array #[DataProvider('dataRel')] public function testRel(string $expected, ?string $rel): void { - $this->assertSame($expected, (string) new Link()->rel($rel)); + $this->assertSame($expected, (string) (new Link())->rel($rel)); } public static function dataType(): array @@ -70,7 +70,7 @@ public static function dataType(): array #[DataProvider('dataType')] public function testType(string $expected, ?string $type): void { - $this->assertSame($expected, (string) new Link()->type($type)); + $this->assertSame($expected, (string) (new Link())->type($type)); } public static function dataTitle(): array @@ -84,7 +84,7 @@ public static function dataTitle(): array #[DataProvider('dataTitle')] public function testTitle(string $expected, ?string $title): void { - $this->assertSame($expected, (string) new Link()->title($title)); + $this->assertSame($expected, (string) (new Link())->title($title)); } public static function dataCrossOrigin(): array @@ -98,7 +98,7 @@ public static function dataCrossOrigin(): array #[DataProvider('dataCrossOrigin')] public function testCrossOrigin(string $expected, ?string $crossOrigin): void { - $this->assertSame($expected, (string) new Link()->crossOrigin($crossOrigin)); + $this->assertSame($expected, (string) (new Link())->crossOrigin($crossOrigin)); } public static function dataTestAs(): array @@ -113,7 +113,7 @@ public static function dataTestAs(): array #[DataProvider('dataTestAs')] public function testAs(string $expected, ?string $as): void { - $this->assertSame($expected, (string) new Link()->as($as)); + $this->assertSame($expected, (string) (new Link())->as($as)); } public static function dataPreload(): array @@ -128,8 +128,8 @@ public static function dataPreload(): array public function testPreload(string $expected, string $url, ?string $as = null): void { $tag = $as === null - ? new Link()->preload($url) - : new Link()->preload($url, $as); + ? (new Link())->preload($url) + : (new Link())->preload($url, $as); $this->assertSame($expected, $tag->render()); } diff --git a/tests/Tag/MetaTest.php b/tests/Tag/MetaTest.php index 91fb10b2..4feef8b2 100644 --- a/tests/Tag/MetaTest.php +++ b/tests/Tag/MetaTest.php @@ -65,7 +65,7 @@ public static function dataProviderName(): array #[DataProvider('dataProviderName')] public function testName(string $expected, ?string $name): void { - $this->assertSame($expected, (string) new Meta()->name($name)); + $this->assertSame($expected, (string) (new Meta())->name($name)); } public static function dataHttpEquiv(): array @@ -80,7 +80,7 @@ public static function dataHttpEquiv(): array #[DataProvider('dataHttpEquiv')] public function testHttpEquiv(string $expected, ?string $name): void { - $this->assertSame($expected, (string) new Meta()->httpEquiv($name)); + $this->assertSame($expected, (string) (new Meta())->httpEquiv($name)); } public static function dataContent(): array @@ -95,7 +95,7 @@ public static function dataContent(): array #[DataProvider('dataContent')] public function testContent(string $expected, ?string $content): void { - $this->assertSame($expected, (string) new Meta()->content($content)); + $this->assertSame($expected, (string) (new Meta())->content($content)); } public static function dataCharset(): array @@ -110,7 +110,7 @@ public static function dataCharset(): array #[DataProvider('dataCharset')] public function testCharset(string $expected, ?string $charset): void { - $this->assertSame($expected, (string) new Meta()->charset($charset)); + $this->assertSame($expected, (string) (new Meta())->charset($charset)); } public function testImmutability(): void diff --git a/tests/Tag/NavTest.php b/tests/Tag/NavTest.php index d0171567..bfd8f6ba 100644 --- a/tests/Tag/NavTest.php +++ b/tests/Tag/NavTest.php @@ -15,11 +15,11 @@ public function testBase(): void { $this->assertSame( "", - (string) new Nav()->content( - new Ul()->items( - new Li()->content('Home'), - new Li()->content('About Us'), - new Li()->content('Contact Us'), + (string) (new Nav())->content( + (new Ul())->items( + (new Li())->content('Home'), + (new Li())->content('About Us'), + (new Li())->content('Contact Us'), ), ), ); diff --git a/tests/Tag/NoscriptTest.php b/tests/Tag/NoscriptTest.php index 4cc3aa47..a3695ceb 100644 --- a/tests/Tag/NoscriptTest.php +++ b/tests/Tag/NoscriptTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) new Noscript()->content(new Img()->src('pixel.png')), + (string) (new Noscript())->content(new Img()->src('pixel.png')), ); } } diff --git a/tests/Tag/OlTest.php b/tests/Tag/OlTest.php index 9fda046a..cb01748a 100644 --- a/tests/Tag/OlTest.php +++ b/tests/Tag/OlTest.php @@ -12,9 +12,9 @@ final class OlTest extends TestCase { public function testBase(): void { - $ol = new Ol()->items( - new Li()->content('A'), - new Li()->content('B'), + $ol = (new Ol())->items( + (new Li())->content('A'), + (new Li())->content('B'), ); $this->assertSame("
      \n
    1. A
    2. \n
    3. B
    4. \n
    ", (string) $ol); diff --git a/tests/Tag/OptgroupTest.php b/tests/Tag/OptgroupTest.php index 667aefd9..32d46e1f 100644 --- a/tests/Tag/OptgroupTest.php +++ b/tests/Tag/OptgroupTest.php @@ -51,7 +51,7 @@ public function testOptionsData(): void { $this->assertSame( "\n\n\n", - (string) new Optgroup()->optionsData(['1' => 'One', '2' => 'Two']), + (string) (new Optgroup())->optionsData(['1' => 'One', '2' => 'Two']), ); } @@ -59,7 +59,7 @@ public function testOptionsDataEncode(): void { $this->assertSame( "\n\n", - (string) new Optgroup()->optionsData(['1' => 'One']), + (string) (new Optgroup())->optionsData(['1' => 'One']), ); } @@ -67,7 +67,7 @@ public function testOptionsDataWithoutEncode(): void { $this->assertSame( "\n\n", - (string) new Optgroup()->optionsData(['1' => 'One'], false), + (string) (new Optgroup())->optionsData(['1' => 'One'], false), ); } @@ -82,13 +82,13 @@ public static function dataLabel(): array #[DataProvider('dataLabel')] public function testLabel(string $expected, ?string $label): void { - $this->assertSame($expected, (string) new Optgroup()->label($label)); + $this->assertSame($expected, (string) (new Optgroup())->label($label)); } public function testDisabled(): void { - $this->assertSame('', (string) new Optgroup()->disabled()); - $this->assertSame('', (string) new Optgroup()->disabled(false)); + $this->assertSame('', (string) (new Optgroup())->disabled()); + $this->assertSame('', (string) (new Optgroup())->disabled(false)); $this->assertSame('', (string) new Optgroup() ->disabled(true) ->disabled(false)); @@ -104,7 +104,7 @@ public static function dataSelection(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option() + [(new Option())->value('1'), new Option() ->value('2') ->selected(), ], [], @@ -114,7 +114,7 @@ public static function dataSelection(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option()->value('2')], + [(new Option())->value('1'), (new Option())->value('2')], [7], ], [ @@ -122,7 +122,7 @@ public static function dataSelection(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option()->value('2')], + [(new Option())->value('1'), (new Option())->value('2')], [1], ], [ @@ -130,7 +130,7 @@ public static function dataSelection(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option()->value('2')], + [(new Option())->value('1'), (new Option())->value('2')], ['2'], ], [ @@ -138,7 +138,7 @@ public static function dataSelection(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option()->value('2')], + [(new Option())->value('1'), (new Option())->value('2')], [1, 2], ], ]; diff --git a/tests/Tag/OptionTest.php b/tests/Tag/OptionTest.php index c6d24b4e..0ce65529 100644 --- a/tests/Tag/OptionTest.php +++ b/tests/Tag/OptionTest.php @@ -31,20 +31,20 @@ public static function dataValue(): array #[DataProvider('dataValue')] public function testValue(string $expected, ?string $value): void { - $this->assertSame($expected, (string) new Option()->value($value)); + $this->assertSame($expected, (string) (new Option())->value($value)); } public function testSelected(): void { - $this->assertSame('', (string) new Option()->selected()); - $this->assertSame('', (string) new Option()->selected(false)); - $this->assertSame('', (string) new Option()->selected(true)->selected(false)); + $this->assertSame('', (string) (new Option())->selected()); + $this->assertSame('', (string) (new Option())->selected(false)); + $this->assertSame('', (string) (new Option())->selected(true)->selected(false)); } public function testDisabled(): void { - $this->assertSame('', (string) new Option()->disabled()); - $this->assertSame('', (string) new Option()->disabled(false)); + $this->assertSame('', (string) (new Option())->disabled()); + $this->assertSame('', (string) (new Option())->disabled(false)); $this->assertSame('', (string) new Option() ->disabled(true) ->disabled(false)); @@ -54,9 +54,9 @@ public static function dataGetValue(): array { return [ [null, new Option()], - [null, new Option()->value(null)], - ['', new Option()->value('')], - ['one', new Option()->value('one')], + [null, (new Option())->value(null)], + ['', (new Option())->value('')], + ['one', (new Option())->value('one')], ]; } diff --git a/tests/Tag/ScriptTest.php b/tests/Tag/ScriptTest.php index 8404116e..51720df8 100644 --- a/tests/Tag/ScriptTest.php +++ b/tests/Tag/ScriptTest.php @@ -17,14 +17,14 @@ public function testBase(): void { $this->assertSame( '', - (string) new Script()->url('main.js'), + (string) (new Script())->url('main.js'), ); } public function testContent(): void { $content = 'alert("4 > 2");'; - $tag = new Script()->content($content); + $tag = (new Script())->content($content); $this->assertSame($content, $tag->getContent()); $this->assertSame('', $tag->render()); @@ -41,8 +41,8 @@ public static function dataUrl(): array #[DataProvider('dataUrl')] public function testUrl(string $expected, ?string $url): void { - $this->assertSame($expected, (string) new Script()->url($url)); - $this->assertSame($expected, (string) new Script()->src($url)); + $this->assertSame($expected, (string) (new Script())->url($url)); + $this->assertSame($expected, (string) (new Script())->src($url)); } public static function dataType(): array @@ -56,7 +56,7 @@ public static function dataType(): array #[DataProvider('dataType')] public function testType(string $expected, ?string $type): void { - $this->assertSame($expected, (string) new Script()->type($type)); + $this->assertSame($expected, (string) (new Script())->type($type)); } public static function dataCharset(): array @@ -70,13 +70,13 @@ public static function dataCharset(): array #[DataProvider('dataCharset')] public function testCharset(string $expected, ?string $charset): void { - $this->assertSame($expected, (string) new Script()->charset($charset)); + $this->assertSame($expected, (string) (new Script())->charset($charset)); } public function testAsync(): void { - $this->assertSame('', (string) new Script()->async()); - $this->assertSame('', (string) new Script()->async(false)); + $this->assertSame('', (string) (new Script())->async()); + $this->assertSame('', (string) (new Script())->async(false)); $this->assertSame('', (string) new Script() ->async(true) ->async(false)); @@ -84,8 +84,8 @@ public function testAsync(): void public function testDefer(): void { - $this->assertSame('', (string) new Script()->defer()); - $this->assertSame('', (string) new Script()->defer(false)); + $this->assertSame('', (string) (new Script())->defer()); + $this->assertSame('', (string) (new Script())->defer(false)); $this->assertSame('', (string) new Script() ->defer(true) ->defer(false)); @@ -95,28 +95,28 @@ public function testNoscript(): void { $this->assertSame( '', - (string) new Script()->noscript('hello'), + (string) (new Script())->noscript('hello'), ); $this->assertSame( '', - (string) new Script()->noscript(new Div()), + (string) (new Script())->noscript(new Div()), ); $this->assertSame( '', - (string) new Script()->noscript(null), + (string) (new Script())->noscript(null), ); } public function testNoscriptTag(): void { - $noscriptTag = new Noscript()->content('hello'); + $noscriptTag = (new Noscript())->content('hello'); $this->assertSame( '', - (string) new Script()->noscriptTag($noscriptTag), + (string) (new Script())->noscriptTag($noscriptTag), ); $this->assertSame( '', - (string) new Script()->noscriptTag(null), + (string) (new Script())->noscriptTag(null), ); } @@ -146,7 +146,7 @@ public static function dataNonce(): iterable #[DataProvider('dataNonce')] public function testNonce(string $expectedHtml, ?string $nonce): void { - $script = new Script()->nonce($nonce); + $script = (new Script())->nonce($nonce); $this->assertSame($expectedHtml, (string) $script); $this->assertSame($nonce, $script->getNonce()); @@ -162,7 +162,7 @@ public function testNonceWithoutValue(): void public function testInvalidNonce(): void { - $script = new Script()->attribute('nonce', []); + $script = (new Script())->attribute('nonce', []); $this->expectException(LogicException::class); $this->expectExceptionMessage('Nonce should be string or null. Got array.'); diff --git a/tests/Tag/SectionTest.php b/tests/Tag/SectionTest.php index 4a39e5a9..61226e34 100644 --- a/tests/Tag/SectionTest.php +++ b/tests/Tag/SectionTest.php @@ -17,8 +17,8 @@ public function testBase(): void '

    Section Heading

    Section Content

    ', (string) new Section() ->content( - new H1()->content('Section Heading') - . new P()->content('Section Content'), + (new H1())->content('Section Heading') + . (new P())->content('Section Content'), ) ->encode(false), ); diff --git a/tests/Tag/SelectTest.php b/tests/Tag/SelectTest.php index 3a88bf39..90d5e87b 100644 --- a/tests/Tag/SelectTest.php +++ b/tests/Tag/SelectTest.php @@ -28,7 +28,7 @@ public static function dataProviderName(): array #[DataProvider('dataProviderName')] public function testName(string $expected, ?string $name): void { - $this->assertSame($expected, (string) new Select()->name($name)); + $this->assertSame($expected, (string) (new Select())->name($name)); } public static function dataNameForMultiple(): array @@ -67,7 +67,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option() + [(new Option())->value('1'), new Option() ->value('2') ->selected(), ], [], @@ -77,7 +77,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option()->value('2')], + [(new Option())->value('1'), (new Option())->value('2')], [7], ], [ @@ -85,7 +85,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option()->value('2')], + [(new Option())->value('1'), (new Option())->value('2')], [1], ], [ @@ -93,7 +93,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option()->value('2')], + [(new Option())->value('1'), (new Option())->value('2')], ['2'], ], [ @@ -101,7 +101,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option()->value('2')], + [(new Option())->value('1'), (new Option())->value('2')], [1, 2], ], [ @@ -116,7 +116,7 @@ public static function dataValue(): array new Option() ->value('1') ->content('One'), - new Optgroup()->options( + (new Optgroup())->options( new Option() ->value('1.1') ->content('One.One'), @@ -139,7 +139,7 @@ public static function dataValue(): array new Option() ->value('1') ->content('One'), - new Optgroup()->options( + (new Optgroup())->options( new Option() ->value('1.1') ->content('One.One'), @@ -157,7 +157,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option()->value('2')], + [(new Option())->value('1'), (new Option())->value('2')], [IntegerEnum::C], ], [ @@ -165,7 +165,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option()->value('2')], + [(new Option())->value('1'), (new Option())->value('2')], [IntegerEnum::A], ], [ @@ -173,7 +173,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('1'), new Option()->value('2')], + [(new Option())->value('1'), (new Option())->value('2')], [IntegerEnum::A, IntegerEnum::B], ], [ @@ -181,7 +181,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [new Option()->value('one'), new Option()->value('two')], + [(new Option())->value('one'), (new Option())->value('two')], [StringEnum::B], ], ]; @@ -192,11 +192,11 @@ public function testValue(string $expected, array $items, array $value): void { $this->assertSame( $expected, - (string) new Select()->items(...$items)->value(...$value), + (string) (new Select())->items(...$items)->value(...$value), ); $this->assertSame( $expected, - (string) new Select()->items(...$items)->values($value), + (string) (new Select())->items(...$items)->values($value), ); } @@ -250,7 +250,7 @@ public static function dataItems(): array new Option() ->value('1') ->content('One'), - new Optgroup()->options( + (new Optgroup())->options( new Option() ->value('1.1') ->content('One.One'), @@ -266,7 +266,7 @@ public static function dataItems(): array #[DataProvider('dataItems')] public function testItems(string $expected, array $items): void { - $this->assertSame($expected, (string) new Select()->items(...$items)); + $this->assertSame($expected, (string) (new Select())->items(...$items)); } public function testOptions(): void @@ -289,7 +289,7 @@ public function testOptionsData(): void { $this->assertSame( "", - (string) new Select()->optionsData(['1' => 'One', '2' => 'Two']), + (string) (new Select())->optionsData(['1' => 'One', '2' => 'Two']), ); } @@ -297,7 +297,7 @@ public function testOptionsDataEncode(): void { $this->assertSame( "", - (string) new Select()->optionsData(['1' => 'One']), + (string) (new Select())->optionsData(['1' => 'One']), ); } @@ -305,7 +305,7 @@ public function testOptionsDataWithoutEncode(): void { $this->assertSame( "", - (string) new Select()->optionsData(['1' => 'One'], false), + (string) (new Select())->optionsData(['1' => 'One'], false), ); } @@ -423,7 +423,7 @@ public static function dataPromptOption(): array . '' . "\n" . '' . "\n" . '', - new Option()->content('Please select...'), + (new Option())->content('Please select...'), ], ]; } @@ -443,8 +443,8 @@ public function testPromptOption(string $expected, ?Option $option): void public function testDisabled(): void { - $this->assertSame('', (string) new Select()->disabled()); - $this->assertSame('', (string) new Select()->disabled(false)); + $this->assertSame('', (string) (new Select())->disabled()); + $this->assertSame('', (string) (new Select())->disabled(false)); $this->assertSame('', (string) new Select() ->disabled(true) ->disabled(false)); @@ -452,8 +452,8 @@ public function testDisabled(): void public function testMultiple(): void { - $this->assertSame('', (string) new Select()->multiple()); - $this->assertSame('', (string) new Select()->multiple(false)); + $this->assertSame('', (string) (new Select())->multiple()); + $this->assertSame('', (string) (new Select())->multiple(false)); $this->assertSame('', (string) new Select() ->multiple(true) ->multiple(false)); @@ -461,8 +461,8 @@ public function testMultiple(): void public function testRequired(): void { - $this->assertSame('', (string) new Select()->required()); - $this->assertSame('', (string) new Select()->required(false)); + $this->assertSame('', (string) (new Select())->required()); + $this->assertSame('', (string) (new Select())->required(false)); $this->assertSame('', (string) new Select() ->required(true) ->required(false)); @@ -479,7 +479,7 @@ public static function dataSize(): array #[DataProvider('dataSize')] public function testSize(string $expected, ?int $size): void { - $this->assertSame($expected, (string) new Select()->size($size)); + $this->assertSame($expected, (string) (new Select())->size($size)); } public static function dataUnselectValue(): array diff --git a/tests/Tag/SourceTest.php b/tests/Tag/SourceTest.php index fea6528c..5b62be1e 100644 --- a/tests/Tag/SourceTest.php +++ b/tests/Tag/SourceTest.php @@ -31,7 +31,7 @@ public static function dataType(): array #[DataProvider('dataType')] public function testType(string $expected, ?string $url): void { - $this->assertSame($expected, (string) new Source()->type($url)); + $this->assertSame($expected, (string) (new Source())->type($url)); } public static function dataSrc(): array @@ -45,7 +45,7 @@ public static function dataSrc(): array #[DataProvider('dataSrc')] public function testSrc(string $expected, ?string $url): void { - $this->assertSame($expected, (string) new Source()->src($url)); + $this->assertSame($expected, (string) (new Source())->src($url)); } public static function dataSrcset(): array @@ -64,7 +64,7 @@ public static function dataSrcset(): array #[DataProvider('dataSrcset')] public function testSrcset(string $expected, array $items): void { - $this->assertSame($expected, (string) new Source()->srcset(...$items)); + $this->assertSame($expected, (string) (new Source())->srcset(...$items)); } public static function dataSizes(): array @@ -83,7 +83,7 @@ public static function dataSizes(): array #[DataProvider('dataSizes')] public function testSizes(string $expected, array $items): void { - $this->assertSame($expected, (string) new Source()->sizes(...$items)); + $this->assertSame($expected, (string) (new Source())->sizes(...$items)); } public static function dataWidth(): array @@ -98,7 +98,7 @@ public static function dataWidth(): array #[DataProvider('dataWidth')] public function testWidth(string $expected, $width): void { - $this->assertSame($expected, (string) new Source()->width($width)); + $this->assertSame($expected, (string) (new Source())->width($width)); } public static function dataHeight(): array @@ -113,7 +113,7 @@ public static function dataHeight(): array #[DataProvider('dataHeight')] public function testHeight(string $expected, $height): void { - $this->assertSame($expected, (string) new Source()->height($height)); + $this->assertSame($expected, (string) (new Source())->height($height)); } public function testImmutability(): void diff --git a/tests/Tag/StyleTest.php b/tests/Tag/StyleTest.php index 16bba3c7..9dc8310d 100644 --- a/tests/Tag/StyleTest.php +++ b/tests/Tag/StyleTest.php @@ -14,14 +14,14 @@ public function testBase(): void { $this->assertSame( '', - (string) new Style()->content('.red { color: #f00; }'), + (string) (new Style())->content('.red { color: #f00; }'), ); } public function testContent(): void { $content = 'body { display: block }'; - $tag = new Style()->content($content); + $tag = (new Style())->content($content); $this->assertSame($content, $tag->getContent()); $this->assertSame('', $tag->render()); @@ -38,7 +38,7 @@ public static function dataMedia(): array #[DataProvider('dataMedia')] public function testMedia(string $expected, ?string $media): void { - $this->assertSame($expected, (string) new Style()->media($media)); + $this->assertSame($expected, (string) (new Style())->media($media)); } public static function dataType(): array @@ -52,7 +52,7 @@ public static function dataType(): array #[DataProvider('dataType')] public function testType(string $expected, ?string $type): void { - $this->assertSame($expected, (string) new Style()->type($type)); + $this->assertSame($expected, (string) (new Style())->type($type)); } public function testImmutability(): void diff --git a/tests/Tag/TableTest.php b/tests/Tag/TableTest.php index 981e507b..2d9c8210 100644 --- a/tests/Tag/TableTest.php +++ b/tests/Tag/TableTest.php @@ -19,14 +19,14 @@ class TableTest extends TestCase { public function testEmpty(): void { - $this->assertSame('
    ', new Table()->render()); + $this->assertSame('
    ', (new Table())->render()); } public static function dataCaption(): array { return [ ['
    ', null], - ["\n\n
    Hello
    ", new Caption()->content('Hello')], + ["\n\n
    Hello
    ", (new Caption())->content('Hello')], ]; } @@ -70,12 +70,12 @@ public function testCaptionStringWithoutEncode(): void public function testColumnGroups(): void { - $tag = new Table()->columnGroups( - new Colgroup()->columns( + $tag = (new Table())->columnGroups( + (new Colgroup())->columns( new Col(), - new Col()->span(2), + (new Col())->span(2), ), - new Colgroup()->span(4), + (new Colgroup())->span(4), ); $this->assertSame( @@ -94,14 +94,14 @@ public function testAddColumnGroups(): void { $tag = new Table() ->columnGroups( - new Colgroup()->columns( + (new Colgroup())->columns( new Col(), - new Col()->span(2), + (new Col())->span(2), ), ) ->addColumnGroups( - new Colgroup()->span(4), - new Colgroup()->span(5), + (new Colgroup())->span(4), + (new Colgroup())->span(5), ); $this->assertSame( @@ -119,9 +119,9 @@ public function testAddColumnGroups(): void public function testColumns(): void { - $tag = new Table()->columns( + $tag = (new Table())->columns( new Col(), - new Col()->span(2), + (new Col())->span(2), ); $this->assertSame( @@ -138,11 +138,11 @@ public function testAddColumns(): void $tag = new Table() ->columns( new Col(), - new Col()->span(2), + (new Col())->span(2), ) ->addColumns( - new Col()->span(3), - new Col()->span(4), + (new Col())->span(3), + (new Col())->span(4), ); $this->assertSame( @@ -174,9 +174,9 @@ public function testHeader(string $expected, ?Thead $header): void public function testBody(): void { - $tag = new Table()->body( + $tag = (new Table())->body( new Tbody(), - new Tbody()->class('red'), + (new Tbody())->class('red'), ); $this->assertSame( @@ -195,8 +195,8 @@ public function testAddBody(): void new Tbody(), ) ->addBody( - new Tbody()->class('red'), - new Tbody()->class('green'), + (new Tbody())->class('red'), + (new Tbody())->class('green'), ); $this->assertSame( @@ -211,9 +211,9 @@ public function testAddBody(): void public function testRows(): void { - $tag = new Table()->rows( - new Tr()->dataStrings(['A', 'B']), - new Tr()->dataStrings(['C', 'D']), + $tag = (new Table())->rows( + (new Tr())->dataStrings(['A', 'B']), + (new Tr())->dataStrings(['C', 'D']), ); $this->assertSame( @@ -235,11 +235,11 @@ public function testAddRows(): void { $tag = new Table() ->rows( - new Tr()->dataStrings(['A', 'B']), + (new Tr())->dataStrings(['A', 'B']), ) ->addRows( - new Tr()->dataStrings(['C', 'D']), - new Tr()->dataStrings(['E', 'F']), + (new Tr())->dataStrings(['C', 'D']), + (new Tr())->dataStrings(['E', 'F']), ); $this->assertSame( diff --git a/tests/Tag/TbodyTest.php b/tests/Tag/TbodyTest.php index 47be8219..f6282a13 100644 --- a/tests/Tag/TbodyTest.php +++ b/tests/Tag/TbodyTest.php @@ -26,8 +26,8 @@ public function testBase(): void new Tbody() ->class('gray') ->rows( - new Tr()->dataStrings(['A', 'B']), - new Tr()->dataStrings(['C', 'D']), + (new Tr())->dataStrings(['A', 'B']), + (new Tr())->dataStrings(['C', 'D']), ) ->render(), ); diff --git a/tests/Tag/TextareaTest.php b/tests/Tag/TextareaTest.php index be9b9f0e..016fd2e2 100644 --- a/tests/Tag/TextareaTest.php +++ b/tests/Tag/TextareaTest.php @@ -32,7 +32,7 @@ public static function dataProviderName(): array #[DataProvider('dataProviderName')] public function testName(string $expected, ?string $name): void { - $this->assertSame($expected, (string) new Textarea()->name($name)); + $this->assertSame($expected, (string) (new Textarea())->name($name)); } public static function dataRows(): array @@ -46,7 +46,7 @@ public static function dataRows(): array #[DataProvider('dataRows')] public function testRows(string $expected, ?int $rows): void { - $this->assertSame($expected, (string) new Textarea()->rows($rows)); + $this->assertSame($expected, (string) (new Textarea())->rows($rows)); } public static function dataColumns(): array @@ -60,7 +60,7 @@ public static function dataColumns(): array #[DataProvider('dataColumns')] public function testColumns(string $expected, ?int $columns): void { - $this->assertSame($expected, (string) new Textarea()->columns($columns)); + $this->assertSame($expected, (string) (new Textarea())->columns($columns)); } public static function dataValue(): array @@ -88,7 +88,7 @@ public static function dataValue(): array #[DataProvider('dataValue')] public function testValue(string $expected, mixed $value): void { - $this->assertSame($expected, (string) new Textarea()->value($value)); + $this->assertSame($expected, (string) (new Textarea())->value($value)); } public static function dataForm(): array diff --git a/tests/Tag/TfootTest.php b/tests/Tag/TfootTest.php index 581167bb..5f7a26b4 100644 --- a/tests/Tag/TfootTest.php +++ b/tests/Tag/TfootTest.php @@ -26,8 +26,8 @@ public function testBase(): void new Tfoot() ->class('gray') ->rows( - new Tr()->dataStrings(['A', 'B']), - new Tr()->dataStrings(['C', 'D']), + (new Tr())->dataStrings(['A', 'B']), + (new Tr())->dataStrings(['C', 'D']), ) ->render(), ); diff --git a/tests/Tag/TheadTest.php b/tests/Tag/TheadTest.php index fc57e49a..635ffbf7 100644 --- a/tests/Tag/TheadTest.php +++ b/tests/Tag/TheadTest.php @@ -26,8 +26,8 @@ public function testBase(): void new Thead() ->class('gray') ->rows( - new Tr()->dataStrings(['A', 'B']), - new Tr()->dataStrings(['C', 'D']), + (new Tr())->dataStrings(['A', 'B']), + (new Tr())->dataStrings(['C', 'D']), ) ->render(), ); diff --git a/tests/Tag/TitleTest.php b/tests/Tag/TitleTest.php index 0c13ea6f..1e7a8086 100644 --- a/tests/Tag/TitleTest.php +++ b/tests/Tag/TitleTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello, World!', - (string) new Title()->content('Hello, World!'), + (string) (new Title())->content('Hello, World!'), ); } } diff --git a/tests/Tag/TrTest.php b/tests/Tag/TrTest.php index 43cbbb8a..4a35164f 100644 --- a/tests/Tag/TrTest.php +++ b/tests/Tag/TrTest.php @@ -28,9 +28,9 @@ public function testBase(): void public function testCells(): void { - $tr = new Tr()->cells( - new Th()->content('A'), - new Td()->content('B'), + $tr = (new Tr())->cells( + (new Th())->content('A'), + (new Td())->content('B'), ); $this->assertSame("\nA\nB\n", (string) $tr); diff --git a/tests/Tag/TrackTest.php b/tests/Tag/TrackTest.php index d7ae88ff..0316382c 100644 --- a/tests/Tag/TrackTest.php +++ b/tests/Tag/TrackTest.php @@ -24,8 +24,8 @@ public function testBase(): void public function testDefault(): void { - $this->assertSame('', (string) new Track()->default()); - $this->assertSame('', (string) new Track()->default(false)); + $this->assertSame('', (string) (new Track())->default()); + $this->assertSame('', (string) (new Track())->default(false)); $this->assertSame('', (string) new Track() ->default(true) ->default(false)); @@ -53,7 +53,7 @@ public static function dataKind(): array #[DataProvider('dataKind')] public function testKind(string $expected, ?string $kind): void { - $this->assertSame($expected, (string) new Track()->kind($kind)); + $this->assertSame($expected, (string) (new Track())->kind($kind)); } public static function dataLabel(): array @@ -67,14 +67,14 @@ public static function dataLabel(): array #[DataProvider('dataLabel')] public function testLabel(string $expected, ?string $label): void { - $this->assertSame($expected, (string) new Track()->label($label)); + $this->assertSame($expected, (string) (new Track())->label($label)); } public function testSrc(): void { $this->assertSame( '', - (string) new Track()->src('brave.en.vtt'), + (string) (new Track())->src('brave.en.vtt'), ); } @@ -89,7 +89,7 @@ public static function dataSrclang(): array #[DataProvider('dataSrclang')] public function testSrclang(string $expected, ?string $lang): void { - $this->assertSame($expected, (string) new Track()->srclang($lang)); + $this->assertSame($expected, (string) (new Track())->srclang($lang)); } public function testImmutability(): void diff --git a/tests/Tag/UlTest.php b/tests/Tag/UlTest.php index 795c37d2..ef2bc697 100644 --- a/tests/Tag/UlTest.php +++ b/tests/Tag/UlTest.php @@ -12,9 +12,9 @@ final class UlTest extends TestCase { public function testBase(): void { - $ul = new Ul()->items( - new Li()->content('A'), - new Li()->content('B'), + $ul = (new Ul())->items( + (new Li())->content('A'), + (new Li())->content('B'), ); $this->assertSame("
      \n
    • A
    • \n
    • B
    • \n
    ", (string) $ul); diff --git a/tests/Tag/VideoTest.php b/tests/Tag/VideoTest.php index 3ad7ab92..d8858bff 100644 --- a/tests/Tag/VideoTest.php +++ b/tests/Tag/VideoTest.php @@ -23,7 +23,7 @@ public function testBase(): void . '', (string) new Video() ->controls() - ->sources(new Source()->src('a.mp4'), new Source()->src('b.avi')) + ->sources(new Source()->src('a.mp4'), (new Source())->src('b.avi')) ->tracks(new Track()->src('c.mp4')) ->fallback('Your browser does not support video.'), ); @@ -40,7 +40,7 @@ public static function dataPoster(): array #[DataProvider('dataPoster')] public function testPoster(string $expected, ?string $poster): void { - $this->assertSame($expected, (string) new Video()->poster($poster)); + $this->assertSame($expected, (string) (new Video())->poster($poster)); } public static function dataWidth(): array @@ -55,7 +55,7 @@ public static function dataWidth(): array #[DataProvider('dataWidth')] public function testWidth(string $expected, $width): void { - $this->assertSame($expected, (string) new Video()->width($width)); + $this->assertSame($expected, (string) (new Video())->width($width)); } public static function dataHeight(): array @@ -70,7 +70,7 @@ public static function dataHeight(): array #[DataProvider('dataHeight')] public function testHeight(string $expected, $height): void { - $this->assertSame($expected, (string) new Video()->height($height)); + $this->assertSame($expected, (string) (new Video())->height($height)); } public function testImmutability(): void diff --git a/tests/Widget/ButtonGroupTest.php b/tests/Widget/ButtonGroupTest.php index db52c0fc..ed62a1c6 100644 --- a/tests/Widget/ButtonGroupTest.php +++ b/tests/Widget/ButtonGroupTest.php @@ -34,7 +34,7 @@ public function testBase(): void public function testWithoutButtons(): void { - $this->assertSame('', new ButtonGroup()->render()); + $this->assertSame('', (new ButtonGroup())->render()); } public function testButtonsData(): void From 09d9c8225d68332b256eeddacb89e597669e56a6 Mon Sep 17 00:00:00 2001 From: razvbir <6582802+razvbir@users.noreply.github.com> Date: Fri, 6 Mar 2026 21:43:30 +0000 Subject: [PATCH 17/37] Apply PHP CS Fixer and Rector changes (CI) --- src/Attribute/Deprecated.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Attribute/Deprecated.php b/src/Attribute/Deprecated.php index 012f607e..a33b971a 100644 --- a/src/Attribute/Deprecated.php +++ b/src/Attribute/Deprecated.php @@ -7,7 +7,8 @@ use Attribute; #[Attribute] -final class Deprecated { +final class Deprecated +{ public function __construct( public readonly ?string $message, public readonly ?string $since, @@ -15,5 +16,5 @@ public function __construct( } if (!class_exists('\Deprecated')) { - class_alias('\Deprecated', '\Yiisoft\Html\Attribute\Deprecated'); + class_alias('\Deprecated', \Yiisoft\Html\Attribute\Deprecated::class); } From cc41b17edc56ef128cd6bdb75ca3def18d40123d Mon Sep 17 00:00:00 2001 From: samdark <47294+samdark@users.noreply.github.com> Date: Fri, 6 Mar 2026 21:43:59 +0000 Subject: [PATCH 18/37] Apply PHP CS Fixer and Rector changes (CI) --- src/Attribute/Deprecated.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Attribute/Deprecated.php b/src/Attribute/Deprecated.php index a33b971a..0cf205fb 100644 --- a/src/Attribute/Deprecated.php +++ b/src/Attribute/Deprecated.php @@ -16,5 +16,5 @@ public function __construct( } if (!class_exists('\Deprecated')) { - class_alias('\Deprecated', \Yiisoft\Html\Attribute\Deprecated::class); + class_alias('\Deprecated', Deprecated::class); } From fe76b16c434bc28a6153ca42cc77fb2350116071 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Fri, 6 Mar 2026 23:52:47 +0200 Subject: [PATCH 19/37] Add parenthesis to missed cases --- src/Html.php | 2 +- src/Tag/Base/ListTag.php | 2 +- tests/Tag/ATest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Html.php b/src/Html.php index 8f157779..a1393ae7 100644 --- a/src/Html.php +++ b/src/Html.php @@ -540,7 +540,7 @@ public static function a(string|Stringable $content = '', ?string $url = null, a */ public static function mailto(string $content, ?string $mail = null, array $attributes = []): A { - $tag = new A() + $tag = (new A()) ->content($content) ->mailto($mail ?? $content); if (!empty($attributes)) { diff --git a/src/Tag/Base/ListTag.php b/src/Tag/Base/ListTag.php index a49c6c5c..f4cc2052 100644 --- a/src/Tag/Base/ListTag.php +++ b/src/Tag/Base/ListTag.php @@ -34,7 +34,7 @@ public function items(Li ...$items): static public function strings(array $strings, array $attributes = [], bool $encode = true): static { $items = array_map( - static fn(string $string) => new Li() + static fn(string $string) => (new Li()) ->content($string) ->attributes($attributes) ->encode($encode), diff --git a/tests/Tag/ATest.php b/tests/Tag/ATest.php index a98b6534..63c10e18 100644 --- a/tests/Tag/ATest.php +++ b/tests/Tag/ATest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( 'Link', - (string) new A() + (string) (new A()) ->url('https://example.com') ->content('Link'), ); From d796ca71bbd85a5c5bac1180553518bd5bbaadfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Sat, 7 Mar 2026 00:27:29 +0200 Subject: [PATCH 20/37] Add parenthesis to missed cases --- src/Tag/Input/Range.php | 2 +- src/Tag/Optgroup.php | 2 +- src/Tag/Select.php | 4 +- tests/Tag/AddressTest.php | 4 +- tests/Tag/ArticleTest.php | 2 +- tests/Tag/AsideTest.php | 2 +- tests/Tag/AudioTest.php | 2 +- tests/Tag/BTest.php | 2 +- tests/Tag/Base/BooleanInputTagTest.php | 30 ++++----- tests/Tag/Base/InputTagTest.php | 8 +-- tests/Tag/Base/MediaTagTest.php | 18 +++--- tests/Tag/Base/NormalTagTest.php | 6 +- tests/Tag/Base/TableRowsContainerTagTest.php | 2 +- tests/Tag/Base/TagContentTraitTest.php | 14 ++-- tests/Tag/Base/TagSourcesTraitTest.php | 2 +- tests/Tag/Base/TagTest.php | 12 ++-- tests/Tag/Base/VoidTagTest.php | 2 +- tests/Tag/BodyTest.php | 2 +- tests/Tag/ButtonTest.php | 4 +- tests/Tag/CaptionTest.php | 2 +- tests/Tag/CodeTest.php | 2 +- tests/Tag/ColTest.php | 2 +- tests/Tag/ColgroupTest.php | 6 +- tests/Tag/CustomTagTest.php | 10 +-- tests/Tag/DatalistTest.php | 2 +- tests/Tag/DivTest.php | 2 +- tests/Tag/EmTest.php | 2 +- tests/Tag/FieldsetTest.php | 4 +- tests/Tag/FooterTest.php | 2 +- tests/Tag/FormTest.php | 36 +++++------ tests/Tag/H1Test.php | 2 +- tests/Tag/H2Test.php | 2 +- tests/Tag/H3Test.php | 2 +- tests/Tag/H4Test.php | 2 +- tests/Tag/H5Test.php | 2 +- tests/Tag/H6Test.php | 2 +- tests/Tag/HeaderTest.php | 2 +- tests/Tag/HgroupTest.php | 2 +- tests/Tag/HrTest.php | 2 +- tests/Tag/HtmlTest.php | 2 +- tests/Tag/ITest.php | 2 +- tests/Tag/ImgTest.php | 2 +- tests/Tag/Input/CheckboxTest.php | 2 +- tests/Tag/Input/ColorTest.php | 2 +- tests/Tag/Input/FileTest.php | 18 +++--- tests/Tag/Input/RadioTest.php | 2 +- tests/Tag/Input/RangeTest.php | 14 ++-- tests/Tag/InputTest.php | 2 +- tests/Tag/LabelTest.php | 2 +- tests/Tag/LiTest.php | 2 +- tests/Tag/LinkTest.php | 2 +- tests/Tag/MetaTest.php | 2 +- tests/Tag/OptgroupTest.php | 18 +++--- tests/Tag/OptionTest.php | 4 +- tests/Tag/PTest.php | 2 +- tests/Tag/PictureTest.php | 10 +-- tests/Tag/PreTest.php | 2 +- tests/Tag/ScriptTest.php | 4 +- tests/Tag/SectionTest.php | 2 +- tests/Tag/SelectTest.php | 60 ++++++++--------- tests/Tag/SmallTest.php | 2 +- tests/Tag/SourceTest.php | 2 +- tests/Tag/SpanTest.php | 2 +- tests/Tag/StrongTest.php | 2 +- tests/Tag/TableTest.php | 24 +++---- tests/Tag/TbodyTest.php | 2 +- tests/Tag/TdTest.php | 2 +- tests/Tag/TextareaTest.php | 4 +- tests/Tag/TfootTest.php | 2 +- tests/Tag/ThTest.php | 2 +- tests/Tag/TheadTest.php | 2 +- tests/Tag/TrTest.php | 36 +++++------ tests/Tag/TrackTest.php | 4 +- tests/Tag/VideoTest.php | 2 +- tests/Widget/ButtonGroupTest.php | 28 ++++---- tests/Widget/CheckboxListTest.php | 68 ++++++++++---------- tests/Widget/RadioListTest.php | 62 +++++++++--------- 77 files changed, 305 insertions(+), 305 deletions(-) diff --git a/src/Tag/Input/Range.php b/src/Tag/Input/Range.php index f1bca346..e3d63d20 100644 --- a/src/Tag/Input/Range.php +++ b/src/Tag/Input/Range.php @@ -126,7 +126,7 @@ protected function after(): string return ''; } - return "\n" . new CustomTag($this->outputTag) + return "\n" . (new CustomTag($this->outputTag)) ->attributes($this->outputAttributes) ->content((string) ($this->attributes['value'] ?? '-')) ->id($this->outputId) diff --git a/src/Tag/Optgroup.php b/src/Tag/Optgroup.php index 8e096efe..83f9cbe5 100644 --- a/src/Tag/Optgroup.php +++ b/src/Tag/Optgroup.php @@ -35,7 +35,7 @@ public function optionsData(array $data, bool $encode = true, array $optionsAttr { $options = []; foreach ($data as $value => $content) { - $options[] = new Option() + $options[] = (new Option()) ->attributes($optionsAttributes[$value] ?? []) ->value($value) ->content($content) diff --git a/src/Tag/Select.php b/src/Tag/Select.php index c3e96d24..66724f49 100644 --- a/src/Tag/Select.php +++ b/src/Tag/Select.php @@ -152,12 +152,12 @@ public function optionsData( $items = []; foreach ($data as $value => $content) { if (is_array($content)) { - $items[] = new Optgroup() + $items[] = (new Optgroup()) ->label((string) $value) ->addAttributes($groupsAttributes[$value] ?? []) ->optionsData($content, $encode, $optionsAttributes); } else { - $items[] = new Option() + $items[] = (new Option()) ->attributes($optionsAttributes[$value] ?? []) ->value($value) ->content($content) diff --git a/tests/Tag/AddressTest.php b/tests/Tag/AddressTest.php index e3dcd9f1..a1ccf7de 100644 --- a/tests/Tag/AddressTest.php +++ b/tests/Tag/AddressTest.php @@ -14,10 +14,10 @@ public function testBase(): void { $this->assertSame( '
    Street 111, Mount View Town. Contact: xx-xx-xxxx
    ', - (string) new Address() + (string) (new Address()) ->content( 'Street 111, Mount View Town. Contact: ' - . new A() + . (new A()) ->href('tel:xx-xx-xxxx') ->content('xx-xx-xxxx'), ) diff --git a/tests/Tag/ArticleTest.php b/tests/Tag/ArticleTest.php index f192fd5d..ec7eef27 100644 --- a/tests/Tag/ArticleTest.php +++ b/tests/Tag/ArticleTest.php @@ -17,7 +17,7 @@ public function testBase(): void { $this->assertSame( '

    Heading 1

    Article content

    Footer
    ', - (string) new Article() + (string) (new Article()) ->content( (new Header())->content(new H1()->content('Heading 1')) . (new P())->content('Article content') diff --git a/tests/Tag/AsideTest.php b/tests/Tag/AsideTest.php index f78f4475..698dc809 100644 --- a/tests/Tag/AsideTest.php +++ b/tests/Tag/AsideTest.php @@ -15,7 +15,7 @@ public function testBase(): void { $this->assertSame( '', - (string) new Aside() + (string) (new Aside()) ->content( (new H2())->content('Hello') . (new P())->content('Aside Tag Content'), diff --git a/tests/Tag/AudioTest.php b/tests/Tag/AudioTest.php index 4b68c387..ff079290 100644 --- a/tests/Tag/AudioTest.php +++ b/tests/Tag/AudioTest.php @@ -20,7 +20,7 @@ public function testBase(): void . '' . "\n" . 'Your browser does not support audio.' . "\n" . '', - (string) new Audio() + (string) (new Audio()) ->controls() ->sources(new Source()->src('a.mp3'), (new Source())->src('b.ogg')) ->tracks(new Track()->src('c.mp3')) diff --git a/tests/Tag/BTest.php b/tests/Tag/BTest.php index cb987830..200bb383 100644 --- a/tests/Tag/BTest.php +++ b/tests/Tag/BTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) new B() + (string) (new B()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/Base/BooleanInputTagTest.php b/tests/Tag/Base/BooleanInputTagTest.php index 2d8f27df..a1d8f27f 100644 --- a/tests/Tag/Base/BooleanInputTagTest.php +++ b/tests/Tag/Base/BooleanInputTagTest.php @@ -14,7 +14,7 @@ public function testChecked(): void { $this->assertSame('', (string) (new TestBooleanInputTag())->checked()); $this->assertSame('', (string) (new TestBooleanInputTag())->checked(false)); - $this->assertSame('', (string) new TestBooleanInputTag() + $this->assertSame('', (string) (new TestBooleanInputTag()) ->checked(true) ->checked(false)); } @@ -55,7 +55,7 @@ public function testLabel(string $expected, ?string $label, array $attributes): { $this->assertSame( $expected, - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->label($label, $attributes) ->render(), ); @@ -65,7 +65,7 @@ public function testLabelNoWrap(): void { $this->assertSame( ' ', - (string) new TestBooleanInputTag() + (string) (new TestBooleanInputTag()) ->id('ID') ->label('Voronezh', wrap: false), ); @@ -75,7 +75,7 @@ public function testLabelWithId(): void { $this->assertSame( '', - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->id('Test') ->label('One') ->render(), @@ -86,7 +86,7 @@ public function testSideLabel(): void { $this->assertMatchesRegularExpression( '~ ~', - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->sideLabel('One') ->render(), ); @@ -96,7 +96,7 @@ public function testSideLabelEmpty(): void { $this->assertMatchesRegularExpression( '~ ~', - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->sideLabel('') ->render(), ); @@ -106,7 +106,7 @@ public function testSideLabelNull(): void { $this->assertSame( '', - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->sideLabel(null) ->render(), ); @@ -116,7 +116,7 @@ public function testSideLabelWithId(): void { $this->assertSame( ' ', - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->id('Test') ->sideLabel('One') ->render(), @@ -127,7 +127,7 @@ public function testSideLabelWithAttributes(): void { $this->assertMatchesRegularExpression( '~ ~', - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->sideLabel('One', ['class' => 'red']) ->render(), ); @@ -137,7 +137,7 @@ public function testSideLabelId(): void { $this->assertSame( ' ', - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->sideLabel('One') ->id('count') ->render(), @@ -148,7 +148,7 @@ public function testWithoutLabelEncode(): void { $this->assertSame( '', - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->label('One') ->labelEncode(false) ->render(), @@ -180,7 +180,7 @@ public function testUncheckValue(string $expected, ?string $name, $value): void { $this->assertSame( $expected, - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->name($name) ->uncheckValue($value) ->render(), @@ -192,7 +192,7 @@ public function testUncheckValueDisabled(): void $this->assertSame( '' . '', - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->name('color') ->uncheckValue(7) ->disabled() @@ -205,7 +205,7 @@ public function testUncheckValueForm(): void $this->assertSame( '' . '', - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->name('color') ->uncheckValue(7) ->form('post') @@ -218,7 +218,7 @@ public function testUncheckValueWithLabel(): void $this->assertSame( '' . '', - new TestBooleanInputTag() + (new TestBooleanInputTag()) ->name('color') ->uncheckValue(7) ->label('Seven') diff --git a/tests/Tag/Base/InputTagTest.php b/tests/Tag/Base/InputTagTest.php index 67907586..6ebfb142 100644 --- a/tests/Tag/Base/InputTagTest.php +++ b/tests/Tag/Base/InputTagTest.php @@ -57,7 +57,7 @@ public static function dataForm(): array #[DataProvider('dataForm')] public function testForm(string $expected, ?string $formId): void { - $this->assertSame($expected, new TestInputTag() + $this->assertSame($expected, (new TestInputTag()) ->form($formId) ->render()); } @@ -66,7 +66,7 @@ public function testReadonly(): void { $this->assertSame('', (string) (new TestInputTag())->readonly()); $this->assertSame('', (string) (new TestInputTag())->readonly(false)); - $this->assertSame('', (string) new TestInputTag() + $this->assertSame('', (string) (new TestInputTag()) ->readonly(true) ->readonly(false)); } @@ -75,7 +75,7 @@ public function testRequired(): void { $this->assertSame('', (string) (new TestInputTag())->required()); $this->assertSame('', (string) (new TestInputTag())->required(false)); - $this->assertSame('', (string) new TestInputTag() + $this->assertSame('', (string) (new TestInputTag()) ->required(true) ->required(false)); } @@ -84,7 +84,7 @@ public function testDisabled(): void { $this->assertSame('', (string) (new TestInputTag())->disabled()); $this->assertSame('', (string) (new TestInputTag())->disabled(false)); - $this->assertSame('', (string) new TestInputTag() + $this->assertSame('', (string) (new TestInputTag()) ->disabled(true) ->disabled(false)); } diff --git a/tests/Tag/Base/MediaTagTest.php b/tests/Tag/Base/MediaTagTest.php index 5aa5a693..d71cef14 100644 --- a/tests/Tag/Base/MediaTagTest.php +++ b/tests/Tag/Base/MediaTagTest.php @@ -22,7 +22,7 @@ public function testBase(): void . '' . "\n" . 'Your browser does not support media.' . "\n" . '', - (string) new TestMediaTag() + (string) (new TestMediaTag()) ->controls() ->sources(new Source()->src('a.mp3'), (new Source())->src('b.ogg')) ->tracks(new Track()->src('c.mp3')) @@ -59,7 +59,7 @@ public function testTracks(): void public function testAddTrack(): void { - $tag = new TestMediaTag() + $tag = (new TestMediaTag()) ->tracks(new Track()->src('a.mp4')) ->addTrack(new Track()->src('b.mp4')) ->addTrack(new Track()->src('c.mp4')); @@ -116,7 +116,7 @@ public function testMuted(): void { $this->assertSame('', (string) (new TestMediaTag())->muted()); $this->assertSame('', (string) (new TestMediaTag())->muted(false)); - $this->assertSame('', (string) new TestMediaTag() + $this->assertSame('', (string) (new TestMediaTag()) ->muted(true) ->muted(false)); } @@ -125,7 +125,7 @@ public function testLoop(): void { $this->assertSame('', (string) (new TestMediaTag())->loop()); $this->assertSame('', (string) (new TestMediaTag())->loop(false)); - $this->assertSame('', (string) new TestMediaTag() + $this->assertSame('', (string) (new TestMediaTag()) ->loop(true) ->loop(false)); } @@ -134,7 +134,7 @@ public function testAutoplay(): void { $this->assertSame('', (string) (new TestMediaTag())->autoplay()); $this->assertSame('', (string) (new TestMediaTag())->autoplay(false)); - $this->assertSame('', (string) new TestMediaTag() + $this->assertSame('', (string) (new TestMediaTag()) ->autoplay(true) ->autoplay(false)); } @@ -143,7 +143,7 @@ public function testControls(): void { $this->assertSame('', (string) (new TestMediaTag())->controls()); $this->assertSame('', (string) (new TestMediaTag())->controls(false)); - $this->assertSame('', (string) new TestMediaTag() + $this->assertSame('', (string) (new TestMediaTag()) ->controls(true) ->controls(false)); } @@ -151,16 +151,16 @@ public function testControls(): void public function testWrongTrackDefault(): void { $tag = (new TestMediaTag())->tracks( - new Track() + (new Track()) ->kind('captions') ->src('sampleCaptions.vtt') ->srclang('en') ->default(), - new Track() + (new Track()) ->kind('descriptions') ->src('sampleDescriptions.vtt') ->srclang('de'), - new Track() + (new Track()) ->kind('chapters') ->src('sampleChapters.vtt') ->srclang('ja') diff --git a/tests/Tag/Base/NormalTagTest.php b/tests/Tag/Base/NormalTagTest.php index 050665a1..e441675c 100644 --- a/tests/Tag/Base/NormalTagTest.php +++ b/tests/Tag/Base/NormalTagTest.php @@ -15,7 +15,7 @@ public function testBase(): void { $this->assertSame( 'content', - new TestNormalTag() + (new TestNormalTag()) ->id('main') ->render(), ); @@ -25,7 +25,7 @@ public function testOpen(): void { $this->assertSame( '', - new TestNormalTag() + (new TestNormalTag()) ->id('main') ->open(), ); @@ -35,7 +35,7 @@ public function testClose(): void { $this->assertSame( '', - new TestNormalTag() + (new TestNormalTag()) ->id('main') ->close(), ); diff --git a/tests/Tag/Base/TableRowsContainerTagTest.php b/tests/Tag/Base/TableRowsContainerTagTest.php index 5e09d9d8..ebd93304 100644 --- a/tests/Tag/Base/TableRowsContainerTagTest.php +++ b/tests/Tag/Base/TableRowsContainerTagTest.php @@ -34,7 +34,7 @@ public function testRows(): void public function testAddRows(): void { - $tag = new TestTableRowsContainerTag() + $tag = (new TestTableRowsContainerTag()) ->rows( (new Tr())->dataStrings(['A', 'B']), ) diff --git a/tests/Tag/Base/TagContentTraitTest.php b/tests/Tag/Base/TagContentTraitTest.php index 00197d24..d449c2b2 100644 --- a/tests/Tag/Base/TagContentTraitTest.php +++ b/tests/Tag/Base/TagContentTraitTest.php @@ -20,7 +20,7 @@ public function testBase(): void { $this->assertSame( '<b>hello &gt; world!</b>', - new TestTagContentTrait() + (new TestTagContentTrait()) ->id('main') ->content('hello > world!') ->render(), @@ -31,7 +31,7 @@ public function testWithoutEncode(): void { $this->assertSame( 'hello', - (string) new TestTagContentTrait() + (string) (new TestTagContentTrait()) ->content('hello') ->encode(false), ); @@ -41,7 +41,7 @@ public function testWithoutDoubleEncode(): void { $this->assertSame( '<b>A > B</b>', - (string) new TestTagContentTrait() + (string) (new TestTagContentTrait()) ->content('A > B') ->doubleEncode(false), ); @@ -73,7 +73,7 @@ public function testEncodeContent(): void { $this->assertSame( '<p>Hi!</p>', - new TestTagContentTrait() + (new TestTagContentTrait()) ->encode(true) ->content(new P()->content('Hi!')) ->render(), @@ -84,7 +84,7 @@ public function testAddContent(): void { $this->assertSame( 'Hello World', - new TestTagContentTrait() + (new TestTagContentTrait()) ->content('Hello') ->addContent(' ') ->addContent(new StringableObject('World')) @@ -96,7 +96,7 @@ public function testAddContentVariadic(): void { $this->assertSame( '123', - new TestTagContentTrait() + (new TestTagContentTrait()) ->content('1') ->addContent(...['2', '3']) ->render(), @@ -107,7 +107,7 @@ public function testNamedParametersContent(): void { $this->assertSame( '123', - new TestTagContentTrait() + (new TestTagContentTrait()) ->content(content: '1') ->addContent(content: '2') ->addContent(content: '3') diff --git a/tests/Tag/Base/TagSourcesTraitTest.php b/tests/Tag/Base/TagSourcesTraitTest.php index 239d3525..2036b2f6 100644 --- a/tests/Tag/Base/TagSourcesTraitTest.php +++ b/tests/Tag/Base/TagSourcesTraitTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( "\n\n\n\n", - new TestTagSourcesTrait() + (new TestTagSourcesTrait()) ->sources(new Source()->src('video1.mp4')) ->addSource(new Source()->src('video2.mp4')) ->addSource(new Source()->src('video3.mp4')) diff --git a/tests/Tag/Base/TagTest.php b/tests/Tag/Base/TagTest.php index 7a7d9e23..e0a3416f 100644 --- a/tests/Tag/Base/TagTest.php +++ b/tests/Tag/Base/TagTest.php @@ -70,7 +70,7 @@ public function testAttributesMerge(): void { $this->assertSame( '', - new TestTag() + (new TestTag()) ->id('color') ->class('red') ->addAttributes(['class' => 'green']) @@ -82,7 +82,7 @@ public function testReplaceAttributes(): void { $this->assertSame( '', - new TestTag() + (new TestTag()) ->id('color') ->class('red') ->attributes(['class' => 'green']) @@ -94,7 +94,7 @@ public function testUnionAttributes(): void { $this->assertSame( '', - new TestTag() + (new TestTag()) ->class('red') ->unionAttributes(['class' => 'green', 'id' => 'color']) ->render(), @@ -113,7 +113,7 @@ public static function dataAttribute(): array #[DataProvider('dataAttribute')] public function testAttribute(string $expected, $value): void { - $this->assertSame($expected, new TestTag() + $this->assertSame($expected, (new TestTag()) ->attribute('key', $value) ->render()); } @@ -151,7 +151,7 @@ public static function dataAddClass(): array #[DataProvider('dataAddClass')] public function testAddClass(string $expected, array $class): void { - $this->assertSame($expected, (string) new TestTag() + $this->assertSame($expected, (string) (new TestTag()) ->addClass('main') ->addClass(...$class)); } @@ -191,7 +191,7 @@ public static function dataClass(): array #[DataProvider('dataClass')] public function testClass(string $expected, array $class): void { - $this->assertSame($expected, (string) new TestTag() + $this->assertSame($expected, (string) (new TestTag()) ->class('red') ->class(...$class)); } diff --git a/tests/Tag/Base/VoidTagTest.php b/tests/Tag/Base/VoidTagTest.php index 69eeddb0..2cff7a92 100644 --- a/tests/Tag/Base/VoidTagTest.php +++ b/tests/Tag/Base/VoidTagTest.php @@ -15,7 +15,7 @@ public function testBase(): void { $this->assertSame( '', - new TestVoidTag() + (new TestVoidTag()) ->id('main') ->render(), ); diff --git a/tests/Tag/BodyTest.php b/tests/Tag/BodyTest.php index 06d810ff..1a89b982 100644 --- a/tests/Tag/BodyTest.php +++ b/tests/Tag/BodyTest.php @@ -21,7 +21,7 @@ public function testAttributes(): void { $this->assertSame( 'Welcome Back!', - (string) new Body() + (string) (new Body()) ->attributes([ 'onafterprint' => 'alert(123);', 'style' => 'font-size:20px;', diff --git a/tests/Tag/ButtonTest.php b/tests/Tag/ButtonTest.php index e1b58627..fd09ac46 100644 --- a/tests/Tag/ButtonTest.php +++ b/tests/Tag/ButtonTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) new Button() + (string) (new Button()) ->type('submit') ->content('Send'), ); @@ -86,7 +86,7 @@ public function testDisabled(): void { $this->assertSame('', (string) (new Button())->disabled()); $this->assertSame('', (string) (new Button())->disabled(false)); - $this->assertSame('', (string) new Button() + $this->assertSame('', (string) (new Button()) ->disabled(true) ->disabled(false)); } diff --git a/tests/Tag/CaptionTest.php b/tests/Tag/CaptionTest.php index 85398bb5..37ed1a11 100644 --- a/tests/Tag/CaptionTest.php +++ b/tests/Tag/CaptionTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( 'Table Caption', - new Caption() + (new Caption()) ->content( 'Table ', (new CustomTag('b'))->content('Caption'), diff --git a/tests/Tag/CodeTest.php b/tests/Tag/CodeTest.php index a5edf48d..96323015 100644 --- a/tests/Tag/CodeTest.php +++ b/tests/Tag/CodeTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) new Code() + (string) (new Code()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/ColTest.php b/tests/Tag/ColTest.php index 7b3f8056..8bd8a5b1 100644 --- a/tests/Tag/ColTest.php +++ b/tests/Tag/ColTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - new Col() + (new Col()) ->span(2) ->attribute('style', 'background-color:#f00;') ->render(), diff --git a/tests/Tag/ColgroupTest.php b/tests/Tag/ColgroupTest.php index 30a77f99..d7709fb8 100644 --- a/tests/Tag/ColgroupTest.php +++ b/tests/Tag/ColgroupTest.php @@ -19,7 +19,7 @@ public function testBase(): void . '' . "\n" . '' . "\n" . '', - new Colgroup() + (new Colgroup()) ->columns( new Col(), new Col() @@ -51,7 +51,7 @@ public function testColumns(): void public function testAddColumns(): void { - $tag = new Colgroup() + $tag = (new Colgroup()) ->columns( new Col(), (new Col())->span(2), @@ -83,7 +83,7 @@ public static function dataSpan(): array #[DataProvider('dataSpan')] public function testSpan(string $expected, ?int $span): void { - $this->assertSame($expected, new Colgroup() + $this->assertSame($expected, (new Colgroup()) ->span($span) ->render()); } diff --git a/tests/Tag/CustomTagTest.php b/tests/Tag/CustomTagTest.php index 7888e4d9..4bb64d5d 100644 --- a/tests/Tag/CustomTagTest.php +++ b/tests/Tag/CustomTagTest.php @@ -21,7 +21,7 @@ public function testBase(): void { $this->assertSame( 'body', - new CustomTag('test') + (new CustomTag('test')) ->id('custom') ->attribute('count', 15) ->content('body') @@ -59,7 +59,7 @@ public static function dataNormal(): array #[DataProvider('dataNormal')] public function testNormal(string $expected, string $name): void { - $this->assertSame($expected, new CustomTag($name) + $this->assertSame($expected, (new CustomTag($name)) ->normal() ->render()); } @@ -75,7 +75,7 @@ public static function dataVoid(): array #[DataProvider('dataVoid')] public function testVoid(string $expected, string $name): void { - $this->assertSame($expected, new CustomTag($name) + $this->assertSame($expected, (new CustomTag($name)) ->void() ->render()); } @@ -84,7 +84,7 @@ public function testWithoutEncode(): void { $this->assertSame( 'hello', - (string) new CustomTag('test') + (string) (new CustomTag('test')) ->content('hello') ->encode(false), ); @@ -94,7 +94,7 @@ public function testWithoutDoubleEncode(): void { $this->assertSame( '<b>A > B</b>', - (string) new CustomTag('test') + (string) (new CustomTag('test')) ->content('A > B') ->doubleEncode(false), ); diff --git a/tests/Tag/DatalistTest.php b/tests/Tag/DatalistTest.php index 6c4272a5..9e10f8c4 100644 --- a/tests/Tag/DatalistTest.php +++ b/tests/Tag/DatalistTest.php @@ -12,7 +12,7 @@ final class DatalistTest extends TestCase { public function testBase(): void { - $tag = new Datalist() + $tag = (new Datalist()) ->id('numbers') ->content( (new Option())->value('One'), diff --git a/tests/Tag/DivTest.php b/tests/Tag/DivTest.php index 2f6302f4..3dac791e 100644 --- a/tests/Tag/DivTest.php +++ b/tests/Tag/DivTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
    Hello
    ', - (string) new Div() + (string) (new Div()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/EmTest.php b/tests/Tag/EmTest.php index 0aa242dd..3f711d50 100644 --- a/tests/Tag/EmTest.php +++ b/tests/Tag/EmTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) new Em() + (string) (new Em()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/FieldsetTest.php b/tests/Tag/FieldsetTest.php index d57928e0..31aeedb3 100644 --- a/tests/Tag/FieldsetTest.php +++ b/tests/Tag/FieldsetTest.php @@ -14,7 +14,7 @@ final class FieldsetTest extends TestCase { public function testBase(): void { - $tag = new Fieldset() + $tag = (new Fieldset()) ->legend('Personal data') ->content( Html::textInput('first_name'), @@ -83,7 +83,7 @@ public static function dataLegendTag(): array Hello HTML, - new Legend() + (new Legend()) ->content('Hello') ->attributes(['id' => 'MyLegend']), ], diff --git a/tests/Tag/FooterTest.php b/tests/Tag/FooterTest.php index 5405d084..94402c27 100644 --- a/tests/Tag/FooterTest.php +++ b/tests/Tag/FooterTest.php @@ -15,7 +15,7 @@ public function testBase(): void { $this->assertSame( '

    Heading 1

    Hello Text

    ', - (string) new Footer() + (string) (new Footer()) ->content( (new H3())->content('Heading 1') . (new P())->content('Hello Text'), diff --git a/tests/Tag/FormTest.php b/tests/Tag/FormTest.php index 9728ee9a..f06cabd5 100644 --- a/tests/Tag/FormTest.php +++ b/tests/Tag/FormTest.php @@ -37,7 +37,7 @@ public function testGet(): void { $this->assertSame( '', - new Form() + (new Form()) ->get('https://example.com/send') ->render(), ); @@ -47,7 +47,7 @@ public function testGetWithoutUrl(): void { $this->assertSame( '
    ', - new Form() + (new Form()) ->get() ->render(), ); @@ -57,7 +57,7 @@ public function testPost(): void { $this->assertSame( '
    ', - new Form() + (new Form()) ->post('https://example.com/send') ->render(), ); @@ -67,7 +67,7 @@ public function testPostWithoutUrl(): void { $this->assertSame( '
    ', - new Form() + (new Form()) ->post() ->render(), ); @@ -95,7 +95,7 @@ public function testCsrfDefaultName(): void $this->assertSame( '
    ' . "\n" . '
    ', - new Form() + (new Form()) ->csrf('abc') ->render(), ); @@ -106,7 +106,7 @@ public function testStringableCsrfToken(): void $this->assertSame( '
    ' . "\n" . '
    ', - new Form() + (new Form()) ->csrf(new StringableObject('abc')) ->render(), ); @@ -125,7 +125,7 @@ public function testAcceptCharset(string $expected, ?string $charset): void { $this->assertSame( $expected, - new Form() + (new Form()) ->acceptCharset($charset) ->render(), ); @@ -144,7 +144,7 @@ public function testAction(string $expected, ?string $action): void { $this->assertSame( $expected, - new Form() + (new Form()) ->action($action) ->render(), ); @@ -163,7 +163,7 @@ public function testAutocomplete(string $expected, bool $value): void { $this->assertSame( $expected, - new Form() + (new Form()) ->autocomplete($value) ->render(), ); @@ -173,7 +173,7 @@ public function testDefaultAutocomplete(): void { $this->assertSame( '
    ', - new Form() + (new Form()) ->autocomplete() ->render(), ); @@ -192,7 +192,7 @@ public function testEnctype(string $expected, ?string $enctype): void { $this->assertSame( $expected, - new Form() + (new Form()) ->enctype($enctype) ->render(), ); @@ -202,7 +202,7 @@ public function testEnctypeApplicationXWwwFormUrlencoded(): void { $this->assertSame( '
    ', - new Form() + (new Form()) ->enctypeApplicationXWwwFormUrlencoded() ->render(), ); @@ -212,7 +212,7 @@ public function testEnctypeMultipartFormData(): void { $this->assertSame( '
    ', - new Form() + (new Form()) ->enctypeMultipartFormData() ->render(), ); @@ -222,7 +222,7 @@ public function testEnctypeTextPlain(): void { $this->assertSame( '
    ', - new Form() + (new Form()) ->enctypeTextPlain() ->render(), ); @@ -241,7 +241,7 @@ public function testMethod(string $expected, ?string $method): void { $this->assertSame( $expected, - new Form() + (new Form()) ->method($method) ->render(), ); @@ -260,7 +260,7 @@ public function testNoValidate(string $expected, bool $noValidate): void { $this->assertSame( $expected, - new Form() + (new Form()) ->noValidate($noValidate) ->render(), ); @@ -270,7 +270,7 @@ public function testDefaultNoValidate(): void { $this->assertSame( '
    ', - new Form() + (new Form()) ->noValidate() ->render(), ); @@ -289,7 +289,7 @@ public function testTarget(string $expected, ?string $target): void { $this->assertSame( $expected, - new Form() + (new Form()) ->target($target) ->render(), ); diff --git a/tests/Tag/H1Test.php b/tests/Tag/H1Test.php index 58bb3d8c..24d21d39 100644 --- a/tests/Tag/H1Test.php +++ b/tests/Tag/H1Test.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '

    Hello

    ', - (string) new H1() + (string) (new H1()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/H2Test.php b/tests/Tag/H2Test.php index 8d8a61a6..e63cc6b4 100644 --- a/tests/Tag/H2Test.php +++ b/tests/Tag/H2Test.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '

    Hello

    ', - (string) new H2() + (string) (new H2()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/H3Test.php b/tests/Tag/H3Test.php index cea97f7a..47e5dd10 100644 --- a/tests/Tag/H3Test.php +++ b/tests/Tag/H3Test.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '

    Hello

    ', - (string) new H3() + (string) (new H3()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/H4Test.php b/tests/Tag/H4Test.php index 19953bda..f250545a 100644 --- a/tests/Tag/H4Test.php +++ b/tests/Tag/H4Test.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '

    Hello

    ', - (string) new H4() + (string) (new H4()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/H5Test.php b/tests/Tag/H5Test.php index 81b42086..db325230 100644 --- a/tests/Tag/H5Test.php +++ b/tests/Tag/H5Test.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
    Hello
    ', - (string) new H5() + (string) (new H5()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/H6Test.php b/tests/Tag/H6Test.php index 7b5bff9e..cd427f79 100644 --- a/tests/Tag/H6Test.php +++ b/tests/Tag/H6Test.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
    Hello
    ', - (string) new H6() + (string) (new H6()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/HeaderTest.php b/tests/Tag/HeaderTest.php index 4530ca4b..1fce9ddf 100644 --- a/tests/Tag/HeaderTest.php +++ b/tests/Tag/HeaderTest.php @@ -15,7 +15,7 @@ public function testBase(): void { $this->assertSame( '

    Heading 1

    Hello Text
    ', - (string) new Header() + (string) (new Header()) ->content( (new H1())->content('Heading 1') . (new I())->content('Hello Text'), diff --git a/tests/Tag/HgroupTest.php b/tests/Tag/HgroupTest.php index a643165a..579900bd 100644 --- a/tests/Tag/HgroupTest.php +++ b/tests/Tag/HgroupTest.php @@ -16,7 +16,7 @@ public function testBase(): void { $this->assertSame( '

    Heading 1

    Heading 2

    Heading 3

    ', - (string) new Hgroup() + (string) (new Hgroup()) ->content( (new H1())->content('Heading 1') . (new H2())->content('Heading 2') diff --git a/tests/Tag/HrTest.php b/tests/Tag/HrTest.php index 9e28bb6e..e60c65c5 100644 --- a/tests/Tag/HrTest.php +++ b/tests/Tag/HrTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
    ', - (string) new Hr(), + (string) (new Hr()), ); } } diff --git a/tests/Tag/HtmlTest.php b/tests/Tag/HtmlTest.php index 5f3eb08d..1f6b1e48 100644 --- a/tests/Tag/HtmlTest.php +++ b/tests/Tag/HtmlTest.php @@ -22,7 +22,7 @@ public function testAttributes(): void { $this->assertSame( 'Welcome Back!', - (string) new Html() + (string) (new Html()) ->attributes([ 'onafterprint' => 'alert(123);', 'style' => 'font-size:20px;', diff --git a/tests/Tag/ITest.php b/tests/Tag/ITest.php index 7a5ab34f..befadd5b 100644 --- a/tests/Tag/ITest.php +++ b/tests/Tag/ITest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) new I() + (string) (new I()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/ImgTest.php b/tests/Tag/ImgTest.php index 417fb1fa..94f925fe 100644 --- a/tests/Tag/ImgTest.php +++ b/tests/Tag/ImgTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( 'Great Company', - (string) new Img() + (string) (new Img()) ->url('logo.png') ->alt('Great Company'), ); diff --git a/tests/Tag/Input/CheckboxTest.php b/tests/Tag/Input/CheckboxTest.php index 3564bf27..1608e0b6 100644 --- a/tests/Tag/Input/CheckboxTest.php +++ b/tests/Tag/Input/CheckboxTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '', - new Checkbox() + (new Checkbox()) ->name('number') ->value(42) ->render(), diff --git a/tests/Tag/Input/ColorTest.php b/tests/Tag/Input/ColorTest.php index 5af313f6..d543d5ba 100644 --- a/tests/Tag/Input/ColorTest.php +++ b/tests/Tag/Input/ColorTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '', - new Color() + (new Color()) ->name('color') ->value('#ff0000') ->render(), diff --git a/tests/Tag/Input/FileTest.php b/tests/Tag/Input/FileTest.php index 8ab7212e..820f82ce 100644 --- a/tests/Tag/Input/FileTest.php +++ b/tests/Tag/Input/FileTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - new File() + (new File()) ->name('avatar') ->render(), ); @@ -45,7 +45,7 @@ public function testUncheckValue(string $expected, ?string $name, $value): void { $this->assertSame( $expected, - new File() + (new File()) ->name($name) ->uncheckValue($value) ->render(), @@ -57,7 +57,7 @@ public function testUncheckValueDisabled(): void $this->assertSame( '' . '', - new File() + (new File()) ->name('avatar') ->uncheckValue(7) ->disabled() @@ -70,7 +70,7 @@ public function testUncheckValueForm(): void $this->assertSame( '' . '', - new File() + (new File()) ->name('avatar') ->uncheckValue(7) ->form('post') @@ -80,7 +80,7 @@ public function testUncheckValueForm(): void public function testUncheckInputAttributes(): void { - $result = new File() + $result = (new File()) ->name('avatar') ->uncheckValue(7) ->addUncheckInputAttributes(['id' => 'FileHidden']) @@ -97,7 +97,7 @@ public function testUncheckInputAttributes(): void public function testReplaceUncheckInputAttributes(): void { - $result = new File() + $result = (new File()) ->name('avatar') ->uncheckValue(7) ->addUncheckInputAttributes(['id' => 'FileHidden']) @@ -131,7 +131,7 @@ public function testAccept(string $expected, ?string $accept): void { $this->assertSame( $expected, - new File() + (new File()) ->name('avatar') ->accept($accept) ->render(), @@ -157,7 +157,7 @@ public function testMultiple(string $expected, ?bool $multiple): void { $this->assertSame( $expected, - new File() + (new File()) ->name('avatar') ->multiple($multiple) ->render(), @@ -168,7 +168,7 @@ public function testMultipleDefault(): void { $this->assertSame( '', - new File() + (new File()) ->name('avatar') ->multiple() ->render(), diff --git a/tests/Tag/Input/RadioTest.php b/tests/Tag/Input/RadioTest.php index 2bf744f9..2ce8214a 100644 --- a/tests/Tag/Input/RadioTest.php +++ b/tests/Tag/Input/RadioTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '', - new Radio() + (new Radio()) ->name('number') ->value(42) ->render(), diff --git a/tests/Tag/Input/RangeTest.php b/tests/Tag/Input/RangeTest.php index 94f92e74..689f0e08 100644 --- a/tests/Tag/Input/RangeTest.php +++ b/tests/Tag/Input/RangeTest.php @@ -14,7 +14,7 @@ final class RangeTest extends TestCase { public function testBase(): void { - $tag = new Range() + $tag = (new Range()) ->name('opacity') ->min(0) ->max(100) @@ -116,7 +116,7 @@ public function testShowOutput(): void public function testAddOutputAttributes(): void { - $tag = new Range() + $tag = (new Range()) ->showOutput() ->addOutputAttributes(['class' => 'red']) ->addOutputAttributes(['id' => 'UID']); @@ -131,7 +131,7 @@ public function testAddOutputAttributes(): void public function testReplaceOutputAttributes(): void { - $tag = new Range() + $tag = (new Range()) ->showOutput() ->addOutputAttributes(['class' => 'red']) ->outputAttributes(['id' => 'UID']); @@ -146,7 +146,7 @@ public function testReplaceOutputAttributes(): void public function testOutputWithCustomId(): void { - $tag = new Range() + $tag = (new Range()) ->showOutput() ->outputAttributes(['id' => 'UID']); @@ -160,7 +160,7 @@ public function testOutputWithCustomId(): void public function testOutputWithCustomTag(): void { - $tag = new Range() + $tag = (new Range()) ->showOutput() ->outputTag('b'); @@ -174,7 +174,7 @@ public function testOutputWithCustomTag(): void public function testOutputWithCustomAttributes(): void { - $tag = new Range() + $tag = (new Range()) ->showOutput() ->outputAttributes(['class' => 'red']); @@ -188,7 +188,7 @@ public function testOutputWithCustomAttributes(): void public function testOutputWithValue(): void { - $tag = new Range() + $tag = (new Range()) ->showOutput() ->value(10); diff --git a/tests/Tag/InputTest.php b/tests/Tag/InputTest.php index 2c2aad03..e00f6043 100644 --- a/tests/Tag/InputTest.php +++ b/tests/Tag/InputTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) new Input() + (string) (new Input()) ->type('hidden') ->name('id') ->value('42'), diff --git a/tests/Tag/LabelTest.php b/tests/Tag/LabelTest.php index f30738c7..7457c787 100644 --- a/tests/Tag/LabelTest.php +++ b/tests/Tag/LabelTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) new Label() + (string) (new Label()) ->forId('name') ->content('Your name'), ); diff --git a/tests/Tag/LiTest.php b/tests/Tag/LiTest.php index e2fa2a0c..2d9f6d40 100644 --- a/tests/Tag/LiTest.php +++ b/tests/Tag/LiTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
  • Hello
  • ', - (string) new Li() + (string) (new Li()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/LinkTest.php b/tests/Tag/LinkTest.php index 7314870d..1b93c46a 100644 --- a/tests/Tag/LinkTest.php +++ b/tests/Tag/LinkTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) new Link() + (string) (new Link()) ->url('/rss') ->type('application/rss+xml') ->rel('alternate') diff --git a/tests/Tag/MetaTest.php b/tests/Tag/MetaTest.php index 4feef8b2..a0faafe8 100644 --- a/tests/Tag/MetaTest.php +++ b/tests/Tag/MetaTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - new Meta() + (new Meta()) ->name('description') ->content('Yii Framework') ->render(), diff --git a/tests/Tag/OptgroupTest.php b/tests/Tag/OptgroupTest.php index 32d46e1f..1d272419 100644 --- a/tests/Tag/OptgroupTest.php +++ b/tests/Tag/OptgroupTest.php @@ -18,12 +18,12 @@ public function testBase(): void . '' . "\n" . '' . "\n" . '', - (string) new Optgroup() + (string) (new Optgroup()) ->options( - new Option() + (new Option()) ->value('1') ->content('One'), - new Option() + (new Option()) ->value('2') ->content('Two'), ) @@ -35,12 +35,12 @@ public function testOptions(): void { $this->assertSame( "\n\n\n", - (string) new Optgroup() + (string) (new Optgroup()) ->options( - new Option() + (new Option()) ->value('1') ->content('One'), - new Option() + (new Option()) ->value('2') ->content('Two'), ), @@ -89,7 +89,7 @@ public function testDisabled(): void { $this->assertSame('', (string) (new Optgroup())->disabled()); $this->assertSame('', (string) (new Optgroup())->disabled(false)); - $this->assertSame('', (string) new Optgroup() + $this->assertSame('', (string) (new Optgroup()) ->disabled(true) ->disabled(false)); } @@ -104,7 +104,7 @@ public static function dataSelection(): array . '' . "\n" . '' . "\n" . '', - [(new Option())->value('1'), new Option() + [(new Option())->value('1'), (new Option()) ->value('2') ->selected(), ], [], @@ -149,7 +149,7 @@ public function testSelection(string $expected, array $options, array $selection { $this->assertSame( $expected, - (string) new Optgroup() + (string) (new Optgroup()) ->options(...$options) ->selection(...$selection), ); diff --git a/tests/Tag/OptionTest.php b/tests/Tag/OptionTest.php index 0ce65529..32d6762c 100644 --- a/tests/Tag/OptionTest.php +++ b/tests/Tag/OptionTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) new Option() + (string) (new Option()) ->value('1') ->content('One'), ); @@ -45,7 +45,7 @@ public function testDisabled(): void { $this->assertSame('', (string) (new Option())->disabled()); $this->assertSame('', (string) (new Option())->disabled(false)); - $this->assertSame('', (string) new Option() + $this->assertSame('', (string) (new Option()) ->disabled(true) ->disabled(false)); } diff --git a/tests/Tag/PTest.php b/tests/Tag/PTest.php index 7602883b..d7afd489 100644 --- a/tests/Tag/PTest.php +++ b/tests/Tag/PTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '

    Hello

    ', - (string) new P() + (string) (new P()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/PictureTest.php b/tests/Tag/PictureTest.php index 66a17856..2f20b381 100644 --- a/tests/Tag/PictureTest.php +++ b/tests/Tag/PictureTest.php @@ -14,16 +14,16 @@ final class PictureTest extends TestCase { public function testBase(): void { - $picture = new Picture() + $picture = (new Picture()) ->image(new Img() ->src('img_orange_flowers.jpg') ->alt('Flowers')) ->sources( - new Source() + (new Source()) ->media('(min-width:650px)') ->srcset('img_pink_flowers.jpg') ->type('image/jpeg'), - new Source() + (new Source()) ->media('(min-width:465px)') ->srcset('img_white_flower.jpg') ->type('image/jpeg'), @@ -45,7 +45,7 @@ public static function dataImg(): array ['', null], [ '' . "\n" . '' . "\n" . '', - new Img() + (new Img()) ->src('image.jpg') ->width(100) ->height(100), @@ -56,7 +56,7 @@ public static function dataImg(): array #[DataProvider('dataImg')] public function testImg(string $expected, ?Img $img): void { - $this->assertSame($expected, new Picture() + $this->assertSame($expected, (new Picture()) ->image($img) ->render()); } diff --git a/tests/Tag/PreTest.php b/tests/Tag/PreTest.php index 5b5209bf..c62e29c0 100644 --- a/tests/Tag/PreTest.php +++ b/tests/Tag/PreTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( '
    Hello
    ', - (string) new Pre() + (string) (new Pre()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/ScriptTest.php b/tests/Tag/ScriptTest.php index 51720df8..65adb8a7 100644 --- a/tests/Tag/ScriptTest.php +++ b/tests/Tag/ScriptTest.php @@ -77,7 +77,7 @@ public function testAsync(): void { $this->assertSame('', (string) (new Script())->async()); $this->assertSame('', (string) (new Script())->async(false)); - $this->assertSame('', (string) new Script() + $this->assertSame('', (string) (new Script()) ->async(true) ->async(false)); } @@ -86,7 +86,7 @@ public function testDefer(): void { $this->assertSame('', (string) (new Script())->defer()); $this->assertSame('', (string) (new Script())->defer(false)); - $this->assertSame('', (string) new Script() + $this->assertSame('', (string) (new Script()) ->defer(true) ->defer(false)); } diff --git a/tests/Tag/SectionTest.php b/tests/Tag/SectionTest.php index 61226e34..7237f793 100644 --- a/tests/Tag/SectionTest.php +++ b/tests/Tag/SectionTest.php @@ -15,7 +15,7 @@ public function testBase(): void { $this->assertSame( '

    Section Heading

    Section Content

    ', - (string) new Section() + (string) (new Section()) ->content( (new H1())->content('Section Heading') . (new P())->content('Section Content'), diff --git a/tests/Tag/SelectTest.php b/tests/Tag/SelectTest.php index 90d5e87b..ae0782a5 100644 --- a/tests/Tag/SelectTest.php +++ b/tests/Tag/SelectTest.php @@ -52,7 +52,7 @@ public static function dataNameForMultiple(): array #[DataProvider('dataNameForMultiple')] public function testNameForMultiple(string $expected, ?string $name): void { - $this->assertSame($expected, (string) new Select() + $this->assertSame($expected, (string) (new Select()) ->multiple() ->name($name)); } @@ -67,7 +67,7 @@ public static function dataValue(): array . '' . "\n" . '' . "\n" . '', - [(new Option())->value('1'), new Option() + [(new Option())->value('1'), (new Option()) ->value('2') ->selected(), ], [], @@ -113,14 +113,14 @@ public static function dataValue(): array . '' . "\n" . '', [ - new Option() + (new Option()) ->value('1') ->content('One'), (new Optgroup())->options( - new Option() + (new Option()) ->value('1.1') ->content('One.One'), - new Option() + (new Option()) ->value('1.2') ->content('One.Two'), ), @@ -136,14 +136,14 @@ public static function dataValue(): array . '' . "\n" . '', [ - new Option() + (new Option()) ->value('1') ->content('One'), (new Optgroup())->options( - new Option() + (new Option()) ->value('1.1') ->content('One.One'), - new Option() + (new Option()) ->value('1.2') ->content('One.Two'), ), @@ -212,7 +212,7 @@ public static function dataForm(): array #[DataProvider('dataForm')] public function testForm(string $expected, ?string $formId): void { - $this->assertSame($expected, new Select() + $this->assertSame($expected, (new Select()) ->form($formId) ->render()); } @@ -230,10 +230,10 @@ public static function dataItems(): array . '' . "\n" . '', [ - new Option() + (new Option()) ->value('1') ->content('One'), - new Option() + (new Option()) ->value('2') ->content('Two'), ], @@ -247,14 +247,14 @@ public static function dataItems(): array . '' . "\n" . '', [ - new Option() + (new Option()) ->value('1') ->content('One'), (new Optgroup())->options( - new Option() + (new Option()) ->value('1.1') ->content('One.One'), - new Option() + (new Option()) ->value('1.2') ->content('One.Two'), ), @@ -273,12 +273,12 @@ public function testOptions(): void { $this->assertSame( "", - (string) new Select() + (string) (new Select()) ->options( - new Option() + (new Option()) ->value('1') ->content('One'), - new Option() + (new Option()) ->value('2') ->content('Two'), ), @@ -311,7 +311,7 @@ public function testOptionsDataWithoutEncode(): void public function testOptionsDataWithGroups(): void { - $tag = new Select() + $tag = (new Select()) ->optionsData([ 1 => 'One', 'Test Group' => [ @@ -336,7 +336,7 @@ public function testOptionsDataWithGroups(): void public function testOptionsAndGroupsAttributes(): void { - $tag = new Select() + $tag = (new Select()) ->optionsData( [ 1 => 'One', @@ -401,7 +401,7 @@ public function testPrompt(string $expected, ?string $text): void { $this->assertSame( $expected, - (string) new Select() + (string) (new Select()) ->prompt($text) ->options(new Option() ->value('1') @@ -433,7 +433,7 @@ public function testPromptOption(string $expected, ?Option $option): void { $this->assertSame( $expected, - (string) new Select() + (string) (new Select()) ->promptOption($option) ->options(new Option() ->value('1') @@ -445,7 +445,7 @@ public function testDisabled(): void { $this->assertSame('', (string) (new Select())->disabled()); $this->assertSame('', (string) (new Select())->disabled(false)); - $this->assertSame('', (string) new Select() + $this->assertSame('', (string) (new Select()) ->disabled(true) ->disabled(false)); } @@ -454,7 +454,7 @@ public function testMultiple(): void { $this->assertSame('', (string) (new Select())->multiple()); $this->assertSame('', (string) (new Select())->multiple(false)); - $this->assertSame('', (string) new Select() + $this->assertSame('', (string) (new Select()) ->multiple(true) ->multiple(false)); } @@ -463,7 +463,7 @@ public function testRequired(): void { $this->assertSame('', (string) (new Select())->required()); $this->assertSame('', (string) (new Select())->required(false)); - $this->assertSame('', (string) new Select() + $this->assertSame('', (string) (new Select()) ->required(true) ->required(false)); } @@ -509,7 +509,7 @@ public function testUnselectValue(string $expected, ?string $name, $value): void { $this->assertSame( $expected, - new Select() + (new Select()) ->name($name) ->unselectValue($value) ->render(), @@ -521,7 +521,7 @@ public function testUnselectValueDisabled(): void $this->assertSame( '' . "\n" . '', - new Select() + (new Select()) ->name('test') ->unselectValue(7) ->disabled() @@ -534,7 +534,7 @@ public function testUnselectValueForm(): void $this->assertSame( '' . "\n" . '', - new Select() + (new Select()) ->name('test') ->unselectValue(7) ->form('post') @@ -547,7 +547,7 @@ public function testUnselectValueMultiple(): void $this->assertSame( '' . "\n" . '', - new Select() + (new Select()) ->name('test') ->unselectValue(7) ->multiple() @@ -576,7 +576,7 @@ public function testImmutability(): void public function testNullValue(): void { - $select = new Select() + $select = (new Select()) ->optionsData(['red' => 'RED', 'green' => 'GREEN']) ->value(null); @@ -593,7 +593,7 @@ public function testNullValue(): void public function testNullValueOverride(): void { - $select = new Select() + $select = (new Select()) ->optionsData(['red' => 'RED', 'green' => 'GREEN']) ->value('red') ->value(null); diff --git a/tests/Tag/SmallTest.php b/tests/Tag/SmallTest.php index fe845a7f..d14d4f80 100644 --- a/tests/Tag/SmallTest.php +++ b/tests/Tag/SmallTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) new Small() + (string) (new Small()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/SourceTest.php b/tests/Tag/SourceTest.php index 5b62be1e..c21d28b7 100644 --- a/tests/Tag/SourceTest.php +++ b/tests/Tag/SourceTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) new Source() + (string) (new Source()) ->src('audio.ogg') ->type('audio/ogg; codecs=vorbis'), ); diff --git a/tests/Tag/SpanTest.php b/tests/Tag/SpanTest.php index 027ea325..c595864f 100644 --- a/tests/Tag/SpanTest.php +++ b/tests/Tag/SpanTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) new Span() + (string) (new Span()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/StrongTest.php b/tests/Tag/StrongTest.php index 79332e82..08c43d1e 100644 --- a/tests/Tag/StrongTest.php +++ b/tests/Tag/StrongTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'Hello', - (string) new Strong() + (string) (new Strong()) ->class('red') ->content('Hello'), ); diff --git a/tests/Tag/TableTest.php b/tests/Tag/TableTest.php index 2d9c8210..d3339990 100644 --- a/tests/Tag/TableTest.php +++ b/tests/Tag/TableTest.php @@ -33,7 +33,7 @@ public static function dataCaption(): array #[DataProvider('dataCaption')] public function testCaption(string $expected, ?Caption $caption): void { - $this->assertSame($expected, new Table() + $this->assertSame($expected, (new Table()) ->caption($caption) ->render()); } @@ -42,7 +42,7 @@ public function testCaptionString(): void { $this->assertSame( "\n\n
    Hello
    ", - new Table() + (new Table()) ->captionString('Hello') ->render(), ); @@ -52,7 +52,7 @@ public function testCaptionStringWithEncode(): void { $this->assertSame( "\n\n
    <b>Hello</b>
    ", - new Table() + (new Table()) ->captionString('Hello') ->render(), ); @@ -62,7 +62,7 @@ public function testCaptionStringWithoutEncode(): void { $this->assertSame( "\n\n
    Hello
    ", - new Table() + (new Table()) ->captionString('Hello', false) ->render(), ); @@ -92,7 +92,7 @@ public function testColumnGroups(): void public function testAddColumnGroups(): void { - $tag = new Table() + $tag = (new Table()) ->columnGroups( (new Colgroup())->columns( new Col(), @@ -135,7 +135,7 @@ public function testColumns(): void public function testAddColumns(): void { - $tag = new Table() + $tag = (new Table()) ->columns( new Col(), (new Col())->span(2), @@ -167,7 +167,7 @@ public static function dataHeader(): array #[DataProvider('dataHeader')] public function testHeader(string $expected, ?Thead $header): void { - $this->assertSame($expected, new Table() + $this->assertSame($expected, (new Table()) ->header($header) ->render()); } @@ -190,7 +190,7 @@ public function testBody(): void public function testAddBody(): void { - $tag = new Table() + $tag = (new Table()) ->body( new Tbody(), ) @@ -233,7 +233,7 @@ public function testRows(): void public function testAddRows(): void { - $tag = new Table() + $tag = (new Table()) ->rows( (new Tr())->dataStrings(['A', 'B']), ) @@ -272,7 +272,7 @@ public static function dataFooter(): array #[DataProvider('dataFooter')] public function testFooter(string $expected, ?Tfoot $footer): void { - $this->assertSame($expected, new Table() + $this->assertSame($expected, (new Table()) ->footer($footer) ->render()); } @@ -288,7 +288,7 @@ public static function dataItemsOrder(): array . '' . "\n" . '' . "\n" . '', - new Table() + (new Table()) ->captionString('Caption of Table') ->columnGroups(new Colgroup()) ->header(new Thead()) @@ -303,7 +303,7 @@ public static function dataItemsOrder(): array . '' . "\n" . '' . "\n" . '', - new Table() + (new Table()) ->captionString('Caption of Table') ->columns(new Col()) ->header(new Thead()) diff --git a/tests/Tag/TbodyTest.php b/tests/Tag/TbodyTest.php index f6282a13..29005466 100644 --- a/tests/Tag/TbodyTest.php +++ b/tests/Tag/TbodyTest.php @@ -23,7 +23,7 @@ public function testBase(): void . 'D' . "\n" . '' . "\n" . '', - new Tbody() + (new Tbody()) ->class('gray') ->rows( (new Tr())->dataStrings(['A', 'B']), diff --git a/tests/Tag/TdTest.php b/tests/Tag/TdTest.php index 8660f403..47407d7e 100644 --- a/tests/Tag/TdTest.php +++ b/tests/Tag/TdTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'hello', - new Td() + (new Td()) ->content('hello') ->render(), ); diff --git a/tests/Tag/TextareaTest.php b/tests/Tag/TextareaTest.php index 016fd2e2..e77ebd37 100644 --- a/tests/Tag/TextareaTest.php +++ b/tests/Tag/TextareaTest.php @@ -13,7 +13,7 @@ final class TextareaTest extends TestCase { public function testBase(): void { - $textarea = new Textarea() + $textarea = (new Textarea()) ->name('body') ->value('content') ->rows(6); @@ -103,7 +103,7 @@ public static function dataForm(): array #[DataProvider('dataForm')] public function testForm(string $expected, ?string $formId): void { - $this->assertSame($expected, new Textarea() + $this->assertSame($expected, (new Textarea()) ->form($formId) ->render()); } diff --git a/tests/Tag/TfootTest.php b/tests/Tag/TfootTest.php index 5f7a26b4..276bc764 100644 --- a/tests/Tag/TfootTest.php +++ b/tests/Tag/TfootTest.php @@ -23,7 +23,7 @@ public function testBase(): void . 'D' . "\n" . '' . "\n" . '', - new Tfoot() + (new Tfoot()) ->class('gray') ->rows( (new Tr())->dataStrings(['A', 'B']), diff --git a/tests/Tag/ThTest.php b/tests/Tag/ThTest.php index 9501005b..b1846b26 100644 --- a/tests/Tag/ThTest.php +++ b/tests/Tag/ThTest.php @@ -13,7 +13,7 @@ public function testBase(): void { $this->assertSame( 'hello', - new Th() + (new Th()) ->content('hello') ->render(), ); diff --git a/tests/Tag/TheadTest.php b/tests/Tag/TheadTest.php index 635ffbf7..09530128 100644 --- a/tests/Tag/TheadTest.php +++ b/tests/Tag/TheadTest.php @@ -23,7 +23,7 @@ public function testBase(): void . 'D' . "\n" . '' . "\n" . '', - new Thead() + (new Thead()) ->class('gray') ->rows( (new Tr())->dataStrings(['A', 'B']), diff --git a/tests/Tag/TrTest.php b/tests/Tag/TrTest.php index 4a35164f..b2738e43 100644 --- a/tests/Tag/TrTest.php +++ b/tests/Tag/TrTest.php @@ -19,7 +19,7 @@ public function testBase(): void . 'Two' . "\n" . 'Three' . "\n" . '', - new Tr() + (new Tr()) ->class('row') ->dataStrings(['One', 'Two', 'Three'], ['class' => 'cell']) ->render(), @@ -38,7 +38,7 @@ public function testCells(): void public function testAddCells(): void { - $tr = new Tr() + $tr = (new Tr()) ->cells(new Td()->content('A')) ->addCells(new Td()->content('B')); @@ -47,7 +47,7 @@ public function testAddCells(): void public function testDataStrings(): void { - $tr = new Tr() + $tr = (new Tr()) ->dataStrings(['A', 'B']); $this->assertSame("\nA\nB\n", (string) $tr); @@ -55,7 +55,7 @@ public function testDataStrings(): void public function testDataStringsAttributes(): void { - $tr = new Tr() + $tr = (new Tr()) ->dataStrings(['A', 'B'], ['class' => 'red']); $this->assertSame("\nA\nB\n", (string) $tr); @@ -63,7 +63,7 @@ public function testDataStringsAttributes(): void public function testDataStringsEncode(): void { - $tr = new Tr() + $tr = (new Tr()) ->dataStrings(['A > B']); $this->assertSame("\nA > B\n", (string) $tr); @@ -71,7 +71,7 @@ public function testDataStringsEncode(): void public function testDataStringsWithoutEncode(): void { - $tr = new Tr() + $tr = (new Tr()) ->dataStrings(['A'], [], false); $this->assertSame("\nA\n", (string) $tr); @@ -79,7 +79,7 @@ public function testDataStringsWithoutEncode(): void public function testAddDataStrings(): void { - $tr = new Tr() + $tr = (new Tr()) ->dataStrings(['A']) ->addDataStrings(['B', 'C']); @@ -88,7 +88,7 @@ public function testAddDataStrings(): void public function testAddDataStringsAttributes(): void { - $tr = new Tr() + $tr = (new Tr()) ->dataStrings(['A']) ->addDataStrings(['B'], ['class' => 'red']); @@ -97,7 +97,7 @@ public function testAddDataStringsAttributes(): void public function testAddDataStringsEncode(): void { - $tr = new Tr() + $tr = (new Tr()) ->dataStrings(['A']) ->addDataStrings(['B > 1']); @@ -106,7 +106,7 @@ public function testAddDataStringsEncode(): void public function testAddDataStringsWithoutEncode(): void { - $tr = new Tr() + $tr = (new Tr()) ->dataStrings(['A']) ->addDataStrings(['B'], [], false); @@ -115,7 +115,7 @@ public function testAddDataStringsWithoutEncode(): void public function testHeaderStrings(): void { - $tr = new Tr() + $tr = (new Tr()) ->headerStrings(['A', 'B']); $this->assertSame("\nA\nB\n", (string) $tr); @@ -123,7 +123,7 @@ public function testHeaderStrings(): void public function testHeaderStringsAttributes(): void { - $tr = new Tr() + $tr = (new Tr()) ->headerStrings(['A', 'B'], ['class' => 'red']); $this->assertSame("\nA\nB\n", (string) $tr); @@ -131,7 +131,7 @@ public function testHeaderStringsAttributes(): void public function testHeaderStringsEncode(): void { - $tr = new Tr() + $tr = (new Tr()) ->headerStrings(['A > B']); $this->assertSame("\nA > B\n", (string) $tr); @@ -139,7 +139,7 @@ public function testHeaderStringsEncode(): void public function testHeaderStringsWithoutEncode(): void { - $tr = new Tr() + $tr = (new Tr()) ->headerStrings(['A'], [], false); $this->assertSame("\nA\n", (string) $tr); @@ -147,7 +147,7 @@ public function testHeaderStringsWithoutEncode(): void public function testAddHeaderStrings(): void { - $tr = new Tr() + $tr = (new Tr()) ->headerStrings(['A']) ->addHeaderStrings(['B', 'C']); @@ -156,7 +156,7 @@ public function testAddHeaderStrings(): void public function testAddHeaderStringsAttributes(): void { - $tr = new Tr() + $tr = (new Tr()) ->headerStrings(['A']) ->addHeaderStrings(['B'], ['class' => 'red']); @@ -165,7 +165,7 @@ public function testAddHeaderStringsAttributes(): void public function testAddHeaderStringsEncode(): void { - $tr = new Tr() + $tr = (new Tr()) ->headerStrings(['A']) ->addHeaderStrings(['B > 1']); @@ -174,7 +174,7 @@ public function testAddHeaderStringsEncode(): void public function testAddHeaderStringsWithoutEncode(): void { - $tr = new Tr() + $tr = (new Tr()) ->headerStrings(['A']) ->addHeaderStrings(['B'], [], false); diff --git a/tests/Tag/TrackTest.php b/tests/Tag/TrackTest.php index 0316382c..5f9e4364 100644 --- a/tests/Tag/TrackTest.php +++ b/tests/Tag/TrackTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) new Track() + (string) (new Track()) ->kind(Track::SUBTITLES) ->src('brave.en.vtt') ->srclang('en') @@ -26,7 +26,7 @@ public function testDefault(): void { $this->assertSame('', (string) (new Track())->default()); $this->assertSame('', (string) (new Track())->default(false)); - $this->assertSame('', (string) new Track() + $this->assertSame('', (string) (new Track()) ->default(true) ->default(false)); } diff --git a/tests/Tag/VideoTest.php b/tests/Tag/VideoTest.php index d8858bff..750e6b61 100644 --- a/tests/Tag/VideoTest.php +++ b/tests/Tag/VideoTest.php @@ -21,7 +21,7 @@ public function testBase(): void . '' . "\n" . 'Your browser does not support video.' . "\n" . '', - (string) new Video() + (string) (new Video()) ->controls() ->sources(new Source()->src('a.mp4'), (new Source())->src('b.avi')) ->tracks(new Track()->src('c.mp4')) diff --git a/tests/Widget/ButtonGroupTest.php b/tests/Widget/ButtonGroupTest.php index ed62a1c6..aa4f5a65 100644 --- a/tests/Widget/ButtonGroupTest.php +++ b/tests/Widget/ButtonGroupTest.php @@ -15,7 +15,7 @@ final class ButtonGroupTest extends TestCase { public function testBase(): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttons( Html::resetButton('Reset Data'), Html::submitButton('Send'), @@ -39,7 +39,7 @@ public function testWithoutButtons(): void public function testButtonsData(): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttonsData([ ['Reset Data', 'type' => 'reset'], ['Send >', 'type' => 'submit', 'class' => 'primary'], @@ -75,7 +75,7 @@ public static function dataButtonsDataEncode(): array #[DataProvider('dataButtonsDataEncode')] public function testButtonsDataEncode(string $expected, string $label, ?bool $encode): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttonsData( [ [$label], @@ -101,7 +101,7 @@ public function testInvalidButtonsData(): void public function testWithoutContainer(): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttons( Html::resetButton('Reset Data'), Html::submitButton('Send'), @@ -142,7 +142,7 @@ public static function dataContainerTag(): array #[DataProvider('dataContainerTag')] public function testContainerTag(string $expected, ?string $tagName): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttons(Html::button('Show')) ->containerTag($tagName); @@ -151,7 +151,7 @@ public function testContainerTag(string $expected, ?string $tagName): void public function testBaseContainerAttributes(): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttons(Html::button('Show')) ->containerAttributes(['id' => 'actions']); @@ -167,7 +167,7 @@ public function testBaseContainerAttributes(): void public function testAddNewButtonAttributes(): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttons( Html::button('Show'), Html::button('Hide'), @@ -187,7 +187,7 @@ public function testAddNewButtonAttributes(): void public function testMergeButtonAttributes(): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttons( Html::button('Show'), Html::button('Hide'), @@ -209,7 +209,7 @@ public function testMergeButtonAttributes(): void public function testUnionButtonAttributes(): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttons( Html::button('Show')->class('red'), Html::button('Hide'), @@ -229,7 +229,7 @@ public function testUnionButtonAttributes(): void public function testReplaceButtonAttributes(): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttons( Html::button('Show'), Html::button('Hide'), @@ -278,7 +278,7 @@ public static function dataDisabled(): array #[DataProvider('dataDisabled')] public function testDisabled(string $expected, ?bool $disabled): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttons( Html::button('Show'), Html::button('Hide'), @@ -312,7 +312,7 @@ public static function dataForm(): array #[DataProvider('dataForm')] public function testForm($expected, ?string $id): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttons( Html::button('Show'), Html::button('Hide'), @@ -325,7 +325,7 @@ public function testForm($expected, ?string $id): void public function testSeparator(): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttons( Html::button('Show'), Html::button('Hide'), @@ -344,7 +344,7 @@ public function testSeparator(): void public function testStringable(): void { - $widget = new ButtonGroup() + $widget = (new ButtonGroup()) ->buttons( Html::resetButton('Reset Data'), Html::submitButton('Send'), diff --git a/tests/Widget/CheckboxListTest.php b/tests/Widget/CheckboxListTest.php index 75538b3c..d40ab40b 100644 --- a/tests/Widget/CheckboxListTest.php +++ b/tests/Widget/CheckboxListTest.php @@ -26,7 +26,7 @@ public function testBase(): void . '' . "\n" . '' . "\n" . '
    ', - new CheckboxList('test') + (new CheckboxList('test')) ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) ->uncheckValue(0) ->value(2, 5) @@ -37,7 +37,7 @@ public function testBase(): void public function testName(): void { - $widget = new CheckboxList('a') + $widget = (new CheckboxList('a')) ->items([1 => 'One']) ->name('b'); @@ -53,7 +53,7 @@ public function testWithoutContainer(): void { $this->assertSame( '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([1 => 'One']) ->withoutContainer() ->render(), @@ -85,7 +85,7 @@ public function testContainerTag(string $expected, ?string $name): void { $this->assertSame( $expected, - new CheckboxList('test') + (new CheckboxList('test')) ->items([1 => 'One']) ->containerTag($name) ->render(), @@ -98,7 +98,7 @@ public function testContainerAttributes(): void '
    ' . "\n" . '' . "\n" . '
    ', - new CheckboxList('test') + (new CheckboxList('test')) ->items([1 => 'One']) ->containerAttributes(['id' => 'main']) ->render(), @@ -110,7 +110,7 @@ public function testCheckboxAttributes(): void $this->assertSame( '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -126,7 +126,7 @@ public function testCheckboxAttributesMerge(): void $this->assertSame( '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -143,7 +143,7 @@ public function testReplaceCheckboxAttributes(): void $this->assertSame( '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -160,7 +160,7 @@ public function testCheckboxLabelAttributes(): void $this->assertSame( '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([1 => 'One', 2 => 'Two']) ->checkboxLabelAttributes(['class' => 'red']) ->withoutContainer() @@ -173,7 +173,7 @@ public function testCheckboxLabelAttributesMerge(): void $this->assertSame( '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([1 => 'One', 2 => 'Two']) ->checkboxLabelAttributes(['class' => 'red']) ->addCheckboxLabelAttributes(['data-type' => 'label']) @@ -188,7 +188,7 @@ public function testAddIndividualInputAttributes(): void '' . "\n" . '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -210,7 +210,7 @@ public function testIndividualUncheckInputAttributes(): void '' . "\n" . '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -231,7 +231,7 @@ public function testIndividualInputAttributesMerge(): void '' . "\n" . '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -257,7 +257,7 @@ public function testIndividualInputAttributesReplace(): void '' . "\n" . '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -281,7 +281,7 @@ public function testItems(): void $this->assertSame( '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -296,7 +296,7 @@ public function testItemsWithoutEncodeLabel(): void $this->assertSame( '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -332,7 +332,7 @@ public function testItemsFromValues(string $expected, array $values): void { $this->assertSame( $expected, - new CheckboxList('test') + (new CheckboxList('test')) ->itemsFromValues($values) ->withoutContainer() ->render(), @@ -344,7 +344,7 @@ public function testItemsFromValuesWithoutEncodeLabel(): void $this->assertSame( '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->itemsFromValues([ 'One', 'Two', @@ -460,28 +460,28 @@ public function testValue(string $expected, array $items, array $value): void { $this->assertSame( $expected, - new CheckboxList('test') + (new CheckboxList('test')) ->items($items) ->value(...$value) ->render(), ); $this->assertSame( $expected, - new CheckboxList('test') + (new CheckboxList('test')) ->items($items) ->values($value) ->render(), ); $this->assertSame( $expected, - new CheckboxList('test') + (new CheckboxList('test')) ->items($items) ->values(new ArrayObject($value)) ->render(), ); $this->assertSame( $expected, - new CheckboxList('test') + (new CheckboxList('test')) ->items($items) ->values(new IterableObject($value)) ->render(), @@ -520,7 +520,7 @@ public function testForm(string $expected, ?string $formId): void { $this->assertSame( $expected, - new CheckboxList('test') + (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -532,7 +532,7 @@ public function testForm(string $expected, ?string $formId): void public function testReadonly(): void { - $checkbox = new CheckboxList('test') + $checkbox = (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -571,7 +571,7 @@ public function testReadonly(): void public function testDisabled(): void { - $checkbox = new CheckboxList('test') + $checkbox = (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -653,7 +653,7 @@ public function testUncheckValue(string $expected, string $name, $value): void { $this->assertSame( $expected, - new CheckboxList($name) + (new CheckboxList($name)) ->items([ 1 => 'One', 2 => 'Two', @@ -669,7 +669,7 @@ public function testUncheckValueDisabled(): void '' . "\n" . '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -687,7 +687,7 @@ public function testUncheckValueForm(): void '' . "\n" . '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -706,7 +706,7 @@ public function testSeparator(): void . '
    ' . '' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([1 => 'One', 2 => 'Two']) ->separator('
    ') ->render(), @@ -720,7 +720,7 @@ public function testItemFormatter(): void . '
    0)
    ' . '
    1)
    ' . "\n" . '', - new CheckboxList('test') + (new CheckboxList('test')) ->items([1 => 'One', 2 => 'Two']) ->itemFormatter(fn(CheckboxItem $item): string => '
    ' . $item->index . ') ' @@ -739,7 +739,7 @@ public function testItemFormatter(): void public function testDisableCheckboxLabelWrap(): void { - $html = new CheckboxList('test') + $html = (new CheckboxList('test')) ->items([1 => 'One', 2 => 'Two']) ->addIndividualInputAttributes([ 1 => ['id' => 'id1'], @@ -761,7 +761,7 @@ public function testDisableCheckboxLabelWrap(): void public function testCheckboxWrap(): void { - $html = new CheckboxList('test') + $html = (new CheckboxList('test')) ->items([1 => 'One', 2 => 'Two']) ->checkboxWrapTag('div') ->checkboxWrapAttributes(['class' => 'form-check']) @@ -797,7 +797,7 @@ public static function dataCheckboxWrapClass(): array #[DataProvider('dataCheckboxWrapClass')] public function testCheckboxWrapClass(string $expected, array $class): void { - $html = new CheckboxList('test') + $html = (new CheckboxList('test')) ->items([1 => 'One', 2 => 'Two']) ->checkboxWrapTag('div') ->checkboxWrapAttributes(['class' => 'form-check']) @@ -833,7 +833,7 @@ public static function dataAddCheckboxWrapClass(): array #[DataProvider('dataAddCheckboxWrapClass')] public function testAddCheckboxWrapClass(string $expected, array $class): void { - $html = new CheckboxList('test') + $html = (new CheckboxList('test')) ->items([1 => 'One', 2 => 'Two']) ->checkboxWrapTag('div') ->checkboxWrapAttributes(['class' => 'form-check']) diff --git a/tests/Widget/RadioListTest.php b/tests/Widget/RadioListTest.php index 6b4ef2f6..9bd24880 100644 --- a/tests/Widget/RadioListTest.php +++ b/tests/Widget/RadioListTest.php @@ -24,7 +24,7 @@ public function testBase(): void . '' . "\n" . '' . "\n" . '
    ', - new RadioList('test') + (new RadioList('test')) ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) ->uncheckValue(0) ->value(2) @@ -35,7 +35,7 @@ public function testBase(): void public function testName(): void { - $widget = new RadioList('a') + $widget = (new RadioList('a')) ->items([1 => 'One']) ->name('b'); @@ -51,7 +51,7 @@ public function testWithoutContainer(): void { $this->assertSame( '', - new RadioList('test') + (new RadioList('test')) ->items([1 => 'One']) ->withoutContainer() ->render(), @@ -83,7 +83,7 @@ public function testContainerTag(string $expected, ?string $name): void { $this->assertSame( $expected, - new RadioList('test') + (new RadioList('test')) ->items([1 => 'One']) ->containerTag($name) ->render(), @@ -96,7 +96,7 @@ public function testContainerAttributes(): void '
    ' . "\n" . '' . "\n" . '
    ', - new RadioList('test') + (new RadioList('test')) ->items([1 => 'One']) ->containerAttributes(['id' => 'main']) ->render(), @@ -108,7 +108,7 @@ public function testRadioAttributes(): void $this->assertSame( '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -124,7 +124,7 @@ public function testRadioAttributesMerge(): void $this->assertSame( '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -141,7 +141,7 @@ public function testReplaceRadioAttributes(): void $this->assertSame( '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -158,7 +158,7 @@ public function testRadioLabelAttributes(): void $this->assertSame( '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([1 => 'One', 2 => 'Two']) ->radioLabelAttributes(['class' => 'red']) ->withoutContainer() @@ -171,7 +171,7 @@ public function testRadioLabelAttributesMerge(): void $this->assertSame( '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([1 => 'One', 2 => 'Two']) ->radioLabelAttributes(['class' => 'red']) ->addRadioLabelAttributes(['data-type' => 'label']) @@ -186,7 +186,7 @@ public function testIndividualInputAttributes(): void '' . "\n" . '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -208,7 +208,7 @@ public function testIndividualUncheckInputAttributes(): void '' . "\n" . '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -229,7 +229,7 @@ public function testIndividualInputAttributesMerge(): void '' . "\n" . '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -255,7 +255,7 @@ public function testIndividualInputAttributesReplace(): void '' . "\n" . '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -279,7 +279,7 @@ public function testItems(): void $this->assertSame( '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -294,7 +294,7 @@ public function testItemsWithoutEncodeLabel(): void $this->assertSame( '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -330,7 +330,7 @@ public function testItemsFromValues(string $expected, array $values): void { $this->assertSame( $expected, - new RadioList('test') + (new RadioList('test')) ->itemsFromValues($values) ->withoutContainer() ->render(), @@ -342,7 +342,7 @@ public function testItemsFromValuesWithoutEncodeLabel(): void $this->assertSame( '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->itemsFromValues([ 'One', 'Two', @@ -431,7 +431,7 @@ public function testValue(string $expected, array $items, $value): void { $this->assertSame( $expected, - new RadioList('test') + (new RadioList('test')) ->items($items) ->value($value) ->render(), @@ -470,7 +470,7 @@ public function testForm(string $expected, ?string $formId): void { $this->assertSame( $expected, - new RadioList('test') + (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -482,7 +482,7 @@ public function testForm(string $expected, ?string $formId): void public function testReadonly(): void { - $checkbox = new RadioList('test') + $checkbox = (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -521,7 +521,7 @@ public function testReadonly(): void public function testDisabled(): void { - $checkbox = new RadioList('test') + $checkbox = (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -603,7 +603,7 @@ public function testUncheckValue(string $expected, string $name, $value): void { $this->assertSame( $expected, - new RadioList($name) + (new RadioList($name)) ->items([ 1 => 'One', 2 => 'Two', @@ -619,7 +619,7 @@ public function testUncheckValueDisabled(): void '' . "\n" . '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -637,7 +637,7 @@ public function testUncheckValueForm(): void '' . "\n" . '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([ 1 => 'One', 2 => 'Two', @@ -656,7 +656,7 @@ public function testSeparator(): void . '
    ' . '' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([1 => 'One', 2 => 'Two']) ->separator('
    ') ->render(), @@ -670,7 +670,7 @@ public function testItemFormatter(): void . '
    0)
    ' . '
    1)
    ' . "\n" . '', - new RadioList('test') + (new RadioList('test')) ->items([1 => 'One', 2 => 'Two']) ->itemFormatter(fn(RadioItem $item): string => '
    ' . $item->index . ') ' @@ -689,7 +689,7 @@ public function testItemFormatter(): void public function testDisableRadioLabelWrap(): void { - $html = new RadioList('test') + $html = (new RadioList('test')) ->items([1 => 'One', 2 => 'Two']) ->addIndividualInputAttributes([ 1 => ['id' => 'id1'], @@ -711,7 +711,7 @@ public function testDisableRadioLabelWrap(): void public function testRadioWrap(): void { - $html = new RadioList('test') + $html = (new RadioList('test')) ->items([1 => 'One', 2 => 'Two']) ->radioWrapTag('div') ->radioWrapAttributes(['class' => 'form-check']) @@ -748,7 +748,7 @@ public static function dataRadioWrapClass(): array #[DataProvider('dataRadioWrapClass')] public function testRadioWrapClass(string $expected, array $class): void { - $html = new RadioList('test') + $html = (new RadioList('test')) ->items([1 => 'One', 2 => 'Two']) ->radioWrapTag('div') ->radioWrapAttributes(['class' => 'form-check']) @@ -785,7 +785,7 @@ public static function dataAddRadioWrapClass(): array #[DataProvider('dataAddRadioWrapClass')] public function testAddRadioWrapClass(string $expected, array $class): void { - $html = new RadioList('test') + $html = (new RadioList('test')) ->items([1 => 'One', 2 => 'Two']) ->radioWrapTag('div') ->radioWrapAttributes(['class' => 'form-check']) From c953ad22907b7c1e287ee5790b201127cb6e0296 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Sat, 7 Mar 2026 19:48:11 +0200 Subject: [PATCH 21/37] Add parenthesis to missed cases --- src/Tag/Tr.php | 4 ++-- tests/Tag/ArticleTest.php | 2 +- tests/Tag/ColgroupTest.php | 4 ++-- tests/Tag/CustomTagTest.php | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Tag/Tr.php b/src/Tag/Tr.php index 44b76a3d..7179dcd6 100644 --- a/src/Tag/Tr.php +++ b/src/Tag/Tr.php @@ -97,7 +97,7 @@ protected function getName(): string private function makeDataCells(array $strings, array $attributes, bool $encode): array { return array_map( - static fn(string $string) => new Td() + static fn(string $string) => (new Td()) ->content($string) ->attributes($attributes) ->encode($encode), @@ -113,7 +113,7 @@ private function makeDataCells(array $strings, array $attributes, bool $encode): private function makeHeaderCells(array $strings, array $attributes, bool $encode): array { return array_map( - static fn(string $string) => new Th() + static fn(string $string) => (new Th()) ->content($string) ->attributes($attributes) ->encode($encode), diff --git a/tests/Tag/ArticleTest.php b/tests/Tag/ArticleTest.php index ec7eef27..dc4e3fd3 100644 --- a/tests/Tag/ArticleTest.php +++ b/tests/Tag/ArticleTest.php @@ -19,7 +19,7 @@ public function testBase(): void '

    Heading 1

    Article content

    Footer
    ', (string) (new Article()) ->content( - (new Header())->content(new H1()->content('Heading 1')) + (new Header())->content((new H1())->content('Heading 1')) . (new P())->content('Article content') . (new Footer())->content('Footer'), ) diff --git a/tests/Tag/ColgroupTest.php b/tests/Tag/ColgroupTest.php index d7709fb8..c87b15f8 100644 --- a/tests/Tag/ColgroupTest.php +++ b/tests/Tag/ColgroupTest.php @@ -22,10 +22,10 @@ public function testBase(): void (new Colgroup()) ->columns( new Col(), - new Col() + (new Col()) ->span(2) ->class('red'), - new Col() + (new Col()) ->span(2) ->class('blue'), ) diff --git a/tests/Tag/CustomTagTest.php b/tests/Tag/CustomTagTest.php index 4bb64d5d..2e153977 100644 --- a/tests/Tag/CustomTagTest.php +++ b/tests/Tag/CustomTagTest.php @@ -126,7 +126,7 @@ public function testEncodeContent(): void { $this->assertSame( '<p>Hi!</p>', - new CustomTag('test') + (new CustomTag('test')) ->encode(true) ->content(new P()->content('Hi!')) ->render(), @@ -137,7 +137,7 @@ public function testAddContent(): void { $this->assertSame( 'Hello World', - new CustomTag('test') + (new CustomTag('test')) ->content('Hello') ->addContent(' ') ->addContent(new StringableObject('World')) @@ -149,7 +149,7 @@ public function testAddContentVariadic(): void { $this->assertSame( '123', - new CustomTag('test') + (new CustomTag('test')) ->content('1') ->addContent(...['2', '3']) ->render(), @@ -160,7 +160,7 @@ public function testOpen(): void { $this->assertSame( '', - new CustomTag('test') + (new CustomTag('test')) ->id('main') ->open(), ); @@ -170,7 +170,7 @@ public function testClose(): void { $this->assertSame( '', - new CustomTag('test') + (new CustomTag('test')) ->id('main') ->close(), ); From 881e97cf5b20e66f44bef29e4edd8d954f43e74e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Sat, 7 Mar 2026 19:54:39 +0200 Subject: [PATCH 22/37] Add parenthesis to missed cases --- src/Tag/Select.php | 2 +- tests/Tag/AudioTest.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tag/Select.php b/src/Tag/Select.php index 66724f49..1d81dc0d 100644 --- a/src/Tag/Select.php +++ b/src/Tag/Select.php @@ -174,7 +174,7 @@ public function optionsData( public function prompt(?string $text): self { $new = clone $this; - $new->prompt = $text === null ? null : new Option() + $new->prompt = $text === null ? null : (new Option()) ->value('') ->content($text); return $new; diff --git a/tests/Tag/AudioTest.php b/tests/Tag/AudioTest.php index ff079290..8ebd0d91 100644 --- a/tests/Tag/AudioTest.php +++ b/tests/Tag/AudioTest.php @@ -22,8 +22,8 @@ public function testBase(): void . '', (string) (new Audio()) ->controls() - ->sources(new Source()->src('a.mp3'), (new Source())->src('b.ogg')) - ->tracks(new Track()->src('c.mp3')) + ->sources((new Source())->src('a.mp3'), (new Source())->src('b.ogg')) + ->tracks((new Track())->src('c.mp3')) ->fallback('Your browser does not support audio.'), ); } From 69f123a0f418c188c521798096d35f80ec9b9be4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Sat, 7 Mar 2026 20:00:28 +0200 Subject: [PATCH 23/37] Whitelist Deprecated symbol and fix class_alias --- composer-require-checker.json | 3 ++- src/Attribute/Deprecated.php | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/composer-require-checker.json b/composer-require-checker.json index c23d1d83..c8849726 100644 --- a/composer-require-checker.json +++ b/composer-require-checker.json @@ -1,6 +1,7 @@ { "symbol-whitelist": [ - "BackedEnum" + "BackedEnum", + "Deprecated" ], "php-core-extensions": [ "Core", diff --git a/src/Attribute/Deprecated.php b/src/Attribute/Deprecated.php index 0cf205fb..0a67aa89 100644 --- a/src/Attribute/Deprecated.php +++ b/src/Attribute/Deprecated.php @@ -15,6 +15,6 @@ public function __construct( ) {} } -if (!class_exists('\Deprecated')) { - class_alias('\Deprecated', Deprecated::class); +if (!class_exists('Deprecated')) { + class_alias(Deprecated::class, 'Deprecated'); } From bbe68d350f6f222e48724423580386503b37a1c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Sat, 7 Mar 2026 20:02:50 +0200 Subject: [PATCH 24/37] Add parenthesis to missed cases --- tests/Tag/Base/MediaTagTest.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Tag/Base/MediaTagTest.php b/tests/Tag/Base/MediaTagTest.php index d71cef14..bd8ff6c6 100644 --- a/tests/Tag/Base/MediaTagTest.php +++ b/tests/Tag/Base/MediaTagTest.php @@ -24,8 +24,8 @@ public function testBase(): void . '', (string) (new TestMediaTag()) ->controls() - ->sources(new Source()->src('a.mp3'), (new Source())->src('b.ogg')) - ->tracks(new Track()->src('c.mp3')) + ->sources((new Source())->src('a.mp3'), (new Source())->src('b.ogg')) + ->tracks((new Track())->src('c.mp3')) ->fallback('Your browser does not support media.'), ); } @@ -60,9 +60,9 @@ public function testTracks(): void public function testAddTrack(): void { $tag = (new TestMediaTag()) - ->tracks(new Track()->src('a.mp4')) - ->addTrack(new Track()->src('b.mp4')) - ->addTrack(new Track()->src('c.mp4')); + ->tracks((new Track())->src('a.mp4')) + ->addTrack((new Track())->src('b.mp4')) + ->addTrack((new Track())->src('c.mp4')); $this->assertSame( "\n\n\n\n", From dad58c932461bf76ec07e4b4b9cc5c35cacc7d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Sat, 7 Mar 2026 20:30:23 +0200 Subject: [PATCH 25/37] Add parenthesis to missed cases --- src/Attribute/Deprecated.php | 4 +++- tests/Tag/Base/NormalTagTest.php | 6 ++++-- tests/Tag/Base/TagContentTraitTest.php | 2 +- tests/Tag/Base/TagSourcesTraitTest.php | 6 +++--- tests/Tag/Base/VoidTagTest.php | 6 ++++-- tests/Tag/CustomTagTest.php | 8 +++++--- tests/Tag/NoscriptTest.php | 2 +- tests/Tag/PictureTest.php | 2 +- tests/Tag/SelectTest.php | 4 ++-- tests/Tag/TrTest.php | 4 ++-- tests/Tag/TrackTest.php | 6 +++--- tests/Tag/VideoTest.php | 4 ++-- tests/Widget/ButtonGroupTest.php | 6 ++++-- tests/Widget/CheckboxListTest.php | 6 ++++-- tests/Widget/RadioListTest.php | 6 ++++-- 15 files changed, 43 insertions(+), 29 deletions(-) diff --git a/src/Attribute/Deprecated.php b/src/Attribute/Deprecated.php index 0a67aa89..acdfe4a1 100644 --- a/src/Attribute/Deprecated.php +++ b/src/Attribute/Deprecated.php @@ -12,7 +12,9 @@ final class Deprecated public function __construct( public readonly ?string $message, public readonly ?string $since, - ) {} + ) { + trigger_error($message ?? '', E_USER_DEPRECATED); + } } if (!class_exists('Deprecated')) { diff --git a/tests/Tag/Base/NormalTagTest.php b/tests/Tag/Base/NormalTagTest.php index e441675c..f1df3b1d 100644 --- a/tests/Tag/Base/NormalTagTest.php +++ b/tests/Tag/Base/NormalTagTest.php @@ -5,6 +5,7 @@ namespace Yiisoft\Html\Tests\Tag\Base; use PHPUnit\Framework\TestCase; +use Deprecated; use ReflectionFunction; use Yiisoft\Html\Tag\Base\NormalTag; use Yiisoft\Html\Tests\Objects\TestNormalTag; @@ -43,7 +44,8 @@ public function testClose(): void public function testDeprecation(): void { - $func = new ReflectionFunction(NormalTag::tag(...)); - $this->assertTrue($func->isDeprecated()); + $attributes = (new ReflectionFunction(NormalTag::tag(...)))->getAttributes(Deprecated::class); + $this->assertNotEmpty($attributes); + $this->assertSame('Use the constructor instead.', $attributes[0]->newInstance()->message); } } diff --git a/tests/Tag/Base/TagContentTraitTest.php b/tests/Tag/Base/TagContentTraitTest.php index d449c2b2..db201736 100644 --- a/tests/Tag/Base/TagContentTraitTest.php +++ b/tests/Tag/Base/TagContentTraitTest.php @@ -75,7 +75,7 @@ public function testEncodeContent(): void '<p>Hi!</p>', (new TestTagContentTrait()) ->encode(true) - ->content(new P()->content('Hi!')) + ->content((new P())->content('Hi!')) ->render(), ); } diff --git a/tests/Tag/Base/TagSourcesTraitTest.php b/tests/Tag/Base/TagSourcesTraitTest.php index 2036b2f6..a138b318 100644 --- a/tests/Tag/Base/TagSourcesTraitTest.php +++ b/tests/Tag/Base/TagSourcesTraitTest.php @@ -15,9 +15,9 @@ public function testBase(): void $this->assertSame( "\n\n\n\n", (new TestTagSourcesTrait()) - ->sources(new Source()->src('video1.mp4')) - ->addSource(new Source()->src('video2.mp4')) - ->addSource(new Source()->src('video3.mp4')) + ->sources((new Source())->src('video1.mp4')) + ->addSource((new Source())->src('video2.mp4')) + ->addSource((new Source())->src('video3.mp4')) ->render(), ); } diff --git a/tests/Tag/Base/VoidTagTest.php b/tests/Tag/Base/VoidTagTest.php index 2cff7a92..17d7840f 100644 --- a/tests/Tag/Base/VoidTagTest.php +++ b/tests/Tag/Base/VoidTagTest.php @@ -5,6 +5,7 @@ namespace Yiisoft\Html\Tests\Tag\Base; use PHPUnit\Framework\TestCase; +use Deprecated; use ReflectionFunction; use Yiisoft\Html\Tag\Base\VoidTag; use Yiisoft\Html\Tests\Objects\TestVoidTag; @@ -23,7 +24,8 @@ public function testBase(): void public function testDeprecation(): void { - $func = new ReflectionFunction(VoidTag::tag(...)); - $this->assertTrue($func->isDeprecated()); + $attributes = (new ReflectionFunction(VoidTag::tag(...)))->getAttributes(Deprecated::class); + $this->assertNotEmpty($attributes); + $this->assertSame('Use the constructor instead.', $attributes[0]->newInstance()->message); } } diff --git a/tests/Tag/CustomTagTest.php b/tests/Tag/CustomTagTest.php index 2e153977..40de8066 100644 --- a/tests/Tag/CustomTagTest.php +++ b/tests/Tag/CustomTagTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +use Deprecated; use ReflectionFunction; use Stringable; use Yiisoft\Html\Tag\CustomTag; @@ -128,7 +129,7 @@ public function testEncodeContent(): void '<p>Hi!</p>', (new CustomTag('test')) ->encode(true) - ->content(new P()->content('Hi!')) + ->content((new P())->content('Hi!')) ->render(), ); } @@ -189,7 +190,8 @@ public function testImmutability(): void public function testDeprecation(): void { - $func = new ReflectionFunction(CustomTag::name(...)); - $this->assertTrue($func->isDeprecated()); + $attributes = (new ReflectionFunction(CustomTag::name(...)))->getAttributes(Deprecated::class); + $this->assertNotEmpty($attributes); + $this->assertSame('Use the constructor instead.', $attributes[0]->newInstance()->message); } } diff --git a/tests/Tag/NoscriptTest.php b/tests/Tag/NoscriptTest.php index a3695ceb..45be12d5 100644 --- a/tests/Tag/NoscriptTest.php +++ b/tests/Tag/NoscriptTest.php @@ -14,7 +14,7 @@ public function testBase(): void { $this->assertSame( '', - (string) (new Noscript())->content(new Img()->src('pixel.png')), + (string) (new Noscript())->content((new Img())->src('pixel.png')), ); } } diff --git a/tests/Tag/PictureTest.php b/tests/Tag/PictureTest.php index 2f20b381..a051d13b 100644 --- a/tests/Tag/PictureTest.php +++ b/tests/Tag/PictureTest.php @@ -15,7 +15,7 @@ final class PictureTest extends TestCase public function testBase(): void { $picture = (new Picture()) - ->image(new Img() + ->image((new Img()) ->src('img_orange_flowers.jpg') ->alt('Flowers')) ->sources( diff --git a/tests/Tag/SelectTest.php b/tests/Tag/SelectTest.php index ae0782a5..9883f1cd 100644 --- a/tests/Tag/SelectTest.php +++ b/tests/Tag/SelectTest.php @@ -403,7 +403,7 @@ public function testPrompt(string $expected, ?string $text): void $expected, (string) (new Select()) ->prompt($text) - ->options(new Option() + ->options((new Option()) ->value('1') ->content('One')), ); @@ -435,7 +435,7 @@ public function testPromptOption(string $expected, ?Option $option): void $expected, (string) (new Select()) ->promptOption($option) - ->options(new Option() + ->options((new Option()) ->value('1') ->content('One')), ); diff --git a/tests/Tag/TrTest.php b/tests/Tag/TrTest.php index b2738e43..6fd75942 100644 --- a/tests/Tag/TrTest.php +++ b/tests/Tag/TrTest.php @@ -39,8 +39,8 @@ public function testCells(): void public function testAddCells(): void { $tr = (new Tr()) - ->cells(new Td()->content('A')) - ->addCells(new Td()->content('B')); + ->cells((new Td())->content('A')) + ->addCells((new Td())->content('B')); $this->assertSame("\nA\nB\n", (string) $tr); } diff --git a/tests/Tag/TrackTest.php b/tests/Tag/TrackTest.php index 5f9e4364..eb55f2f4 100644 --- a/tests/Tag/TrackTest.php +++ b/tests/Tag/TrackTest.php @@ -33,11 +33,11 @@ public function testDefault(): void public function testIsDefault(): void { - $this->assertFalse(new Track()->isDefault()); - $this->assertFalse(new Track() + $this->assertFalse((new Track())->isDefault()); + $this->assertFalse((new Track()) ->default(false) ->isDefault()); - $this->assertTrue(new Track() + $this->assertTrue((new Track()) ->default() ->isDefault()); } diff --git a/tests/Tag/VideoTest.php b/tests/Tag/VideoTest.php index 750e6b61..5a3e9c63 100644 --- a/tests/Tag/VideoTest.php +++ b/tests/Tag/VideoTest.php @@ -23,8 +23,8 @@ public function testBase(): void . '', (string) (new Video()) ->controls() - ->sources(new Source()->src('a.mp4'), (new Source())->src('b.avi')) - ->tracks(new Track()->src('c.mp4')) + ->sources((new Source())->src('a.mp4'), (new Source())->src('b.avi')) + ->tracks((new Track())->src('c.mp4')) ->fallback('Your browser does not support video.'), ); } diff --git a/tests/Widget/ButtonGroupTest.php b/tests/Widget/ButtonGroupTest.php index aa4f5a65..e4d5fed2 100644 --- a/tests/Widget/ButtonGroupTest.php +++ b/tests/Widget/ButtonGroupTest.php @@ -7,6 +7,7 @@ use InvalidArgumentException; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +use Deprecated; use ReflectionFunction; use Yiisoft\Html\Html; use Yiisoft\Html\Widget\ButtonGroup; @@ -371,7 +372,8 @@ public function testImmutability(): void public function testDeprecation(): void { - $func = new ReflectionFunction(ButtonGroup::create(...)); - $this->assertTrue($func->isDeprecated()); + $attributes = (new ReflectionFunction(ButtonGroup::create(...)))->getAttributes(Deprecated::class); + $this->assertNotEmpty($attributes); + $this->assertSame('Use the constructor instead.', $attributes[0]->newInstance()->message); } } diff --git a/tests/Widget/CheckboxListTest.php b/tests/Widget/CheckboxListTest.php index d40ab40b..b61c1e49 100644 --- a/tests/Widget/CheckboxListTest.php +++ b/tests/Widget/CheckboxListTest.php @@ -7,6 +7,7 @@ use ArrayObject; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +use Deprecated; use ReflectionFunction; use Yiisoft\Html\Html; use Yiisoft\Html\Tests\Objects\IterableObject; @@ -895,7 +896,8 @@ public function testImmutability(): void public function testDeprecation(): void { - $func = new ReflectionFunction(CheckboxList::create(...)); - $this->assertTrue($func->isDeprecated()); + $attributes = (new ReflectionFunction(CheckboxList::create(...)))->getAttributes(Deprecated::class); + $this->assertNotEmpty($attributes); + $this->assertSame('Use the constructor instead.', $attributes[0]->newInstance()->message); } } diff --git a/tests/Widget/RadioListTest.php b/tests/Widget/RadioListTest.php index 9bd24880..f094045e 100644 --- a/tests/Widget/RadioListTest.php +++ b/tests/Widget/RadioListTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; +use Deprecated; use ReflectionFunction; use Yiisoft\Html\Html; use Yiisoft\Html\Tests\Support\IntegerEnum; @@ -846,7 +847,8 @@ public function testImmutability(): void public function testDeprecation(): void { - $func = new ReflectionFunction(RadioList::create(...)); - $this->assertTrue($func->isDeprecated()); + $attributes = (new ReflectionFunction(RadioList::create(...)))->getAttributes(Deprecated::class); + $this->assertNotEmpty($attributes); + $this->assertSame('Use the constructor instead.', $attributes[0]->newInstance()->message); } } From 2be0cf05b5000c87776fb79fcc36df8577dee684 Mon Sep 17 00:00:00 2001 From: razvbir <6582802+razvbir@users.noreply.github.com> Date: Sat, 7 Mar 2026 18:32:52 +0000 Subject: [PATCH 26/37] Apply PHP CS Fixer and Rector changes (CI) --- src/Attribute/Deprecated.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Attribute/Deprecated.php b/src/Attribute/Deprecated.php index acdfe4a1..42f5939f 100644 --- a/src/Attribute/Deprecated.php +++ b/src/Attribute/Deprecated.php @@ -6,6 +6,8 @@ use Attribute; +use const E_USER_DEPRECATED; + #[Attribute] final class Deprecated { From c9377b66c8eb7da1687d1acb8dd0b968cb7dcc27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Sat, 7 Mar 2026 20:42:50 +0200 Subject: [PATCH 27/37] Add @codeCoverageIgnore --- src/Tag/Base/NormalTag.php | 2 +- src/Tag/Base/VoidTag.php | 2 +- src/Tag/CustomTag.php | 2 +- src/Widget/ButtonGroup.php | 2 +- src/Widget/CheckboxList/CheckboxList.php | 2 +- src/Widget/RadioList/RadioList.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Tag/Base/NormalTag.php b/src/Tag/Base/NormalTag.php index 3b07308d..8958ebf3 100644 --- a/src/Tag/Base/NormalTag.php +++ b/src/Tag/Base/NormalTag.php @@ -13,7 +13,7 @@ abstract class NormalTag extends Tag { final public function __construct() {} - #[Deprecated('Use the constructor instead.')] + #[Deprecated('Use the constructor instead.')] // @codeCoverageIgnore final public static function tag(): static { return new static(); diff --git a/src/Tag/Base/VoidTag.php b/src/Tag/Base/VoidTag.php index bc00e337..018e9981 100644 --- a/src/Tag/Base/VoidTag.php +++ b/src/Tag/Base/VoidTag.php @@ -14,7 +14,7 @@ abstract class VoidTag extends Tag { final public function __construct() {} - #[Deprecated('Use the constructor instead.')] + #[Deprecated('Use the constructor instead.')] // @codeCoverageIgnore final public static function tag(): static { return new static(); diff --git a/src/Tag/CustomTag.php b/src/Tag/CustomTag.php index 7c439a49..f718a50c 100644 --- a/src/Tag/CustomTag.php +++ b/src/Tag/CustomTag.php @@ -56,7 +56,7 @@ public function __construct( * * @psalm-param non-empty-string $name */ - #[Deprecated('Use the constructor instead.')] + #[Deprecated('Use the constructor instead.')] // @codeCoverageIgnore public static function name(string $name): self { return new self($name); diff --git a/src/Widget/ButtonGroup.php b/src/Widget/ButtonGroup.php index ef24e5e4..9df82ce6 100644 --- a/src/Widget/ButtonGroup.php +++ b/src/Widget/ButtonGroup.php @@ -35,7 +35,7 @@ public function __toString(): string return $this->render(); } - #[Deprecated('Use the constructor instead.')] + #[Deprecated('Use the constructor instead.')] // @codeCoverageIgnore public static function create(): self { return new self(); diff --git a/src/Widget/CheckboxList/CheckboxList.php b/src/Widget/CheckboxList/CheckboxList.php index 2af04b14..c8b235f2 100644 --- a/src/Widget/CheckboxList/CheckboxList.php +++ b/src/Widget/CheckboxList/CheckboxList.php @@ -63,7 +63,7 @@ public function __toString(): string return $this->render(); } - #[Deprecated('Use the constructor instead.')] + #[Deprecated('Use the constructor instead.')] // @codeCoverageIgnore public static function create(string $name): self { return new self($name); diff --git a/src/Widget/RadioList/RadioList.php b/src/Widget/RadioList/RadioList.php index 913119d7..feab0b61 100644 --- a/src/Widget/RadioList/RadioList.php +++ b/src/Widget/RadioList/RadioList.php @@ -57,7 +57,7 @@ public function __toString(): string return $this->render(); } - #[Deprecated('Use the constructor instead.')] + #[Deprecated('Use the constructor instead.')] // @codeCoverageIgnore public static function create(string $name): self { return new self($name); From 98dd286d97eb9113f3e7563903e62cd104061f80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Sat, 7 Mar 2026 20:57:03 +0200 Subject: [PATCH 28/37] Revert "Add @codeCoverageIgnore" This reverts commit c9377b66c8eb7da1687d1acb8dd0b968cb7dcc27. --- src/Tag/Base/NormalTag.php | 2 +- src/Tag/Base/VoidTag.php | 2 +- src/Tag/CustomTag.php | 2 +- src/Widget/ButtonGroup.php | 2 +- src/Widget/CheckboxList/CheckboxList.php | 2 +- src/Widget/RadioList/RadioList.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Tag/Base/NormalTag.php b/src/Tag/Base/NormalTag.php index 8958ebf3..3b07308d 100644 --- a/src/Tag/Base/NormalTag.php +++ b/src/Tag/Base/NormalTag.php @@ -13,7 +13,7 @@ abstract class NormalTag extends Tag { final public function __construct() {} - #[Deprecated('Use the constructor instead.')] // @codeCoverageIgnore + #[Deprecated('Use the constructor instead.')] final public static function tag(): static { return new static(); diff --git a/src/Tag/Base/VoidTag.php b/src/Tag/Base/VoidTag.php index 018e9981..bc00e337 100644 --- a/src/Tag/Base/VoidTag.php +++ b/src/Tag/Base/VoidTag.php @@ -14,7 +14,7 @@ abstract class VoidTag extends Tag { final public function __construct() {} - #[Deprecated('Use the constructor instead.')] // @codeCoverageIgnore + #[Deprecated('Use the constructor instead.')] final public static function tag(): static { return new static(); diff --git a/src/Tag/CustomTag.php b/src/Tag/CustomTag.php index f718a50c..7c439a49 100644 --- a/src/Tag/CustomTag.php +++ b/src/Tag/CustomTag.php @@ -56,7 +56,7 @@ public function __construct( * * @psalm-param non-empty-string $name */ - #[Deprecated('Use the constructor instead.')] // @codeCoverageIgnore + #[Deprecated('Use the constructor instead.')] public static function name(string $name): self { return new self($name); diff --git a/src/Widget/ButtonGroup.php b/src/Widget/ButtonGroup.php index 9df82ce6..ef24e5e4 100644 --- a/src/Widget/ButtonGroup.php +++ b/src/Widget/ButtonGroup.php @@ -35,7 +35,7 @@ public function __toString(): string return $this->render(); } - #[Deprecated('Use the constructor instead.')] // @codeCoverageIgnore + #[Deprecated('Use the constructor instead.')] public static function create(): self { return new self(); diff --git a/src/Widget/CheckboxList/CheckboxList.php b/src/Widget/CheckboxList/CheckboxList.php index c8b235f2..2af04b14 100644 --- a/src/Widget/CheckboxList/CheckboxList.php +++ b/src/Widget/CheckboxList/CheckboxList.php @@ -63,7 +63,7 @@ public function __toString(): string return $this->render(); } - #[Deprecated('Use the constructor instead.')] // @codeCoverageIgnore + #[Deprecated('Use the constructor instead.')] public static function create(string $name): self { return new self($name); diff --git a/src/Widget/RadioList/RadioList.php b/src/Widget/RadioList/RadioList.php index feab0b61..913119d7 100644 --- a/src/Widget/RadioList/RadioList.php +++ b/src/Widget/RadioList/RadioList.php @@ -57,7 +57,7 @@ public function __toString(): string return $this->render(); } - #[Deprecated('Use the constructor instead.')] // @codeCoverageIgnore + #[Deprecated('Use the constructor instead.')] public static function create(string $name): self { return new self($name); From 2eefab998d85fe6a76801330dee979bf61b427b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Sat, 7 Mar 2026 21:03:12 +0200 Subject: [PATCH 29/37] Add tests for Deprecated attribute --- tests/Attribute/DeprecatedTest.php | 98 ++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 tests/Attribute/DeprecatedTest.php diff --git a/tests/Attribute/DeprecatedTest.php b/tests/Attribute/DeprecatedTest.php new file mode 100644 index 00000000..239783d5 --- /dev/null +++ b/tests/Attribute/DeprecatedTest.php @@ -0,0 +1,98 @@ +make('Test message', null); + + $this->assertSame('Test message', $attribute->message); + } + + public function testSinceProperty(): void + { + $attribute = $this->make('Test message', '1.0.0'); + + $this->assertSame('1.0.0', $attribute->since); + } + + public function testNullMessageProperty(): void + { + $attribute = $this->make(null, null); + + $this->assertNull($attribute->message); + } + + public function testNullSinceProperty(): void + { + $attribute = $this->make('Test message', null); + + $this->assertNull($attribute->since); + } + + public function testTriggersDeprecationError(): void + { + $triggered = false; + $triggeredMessage = null; + + set_error_handler(static function (int $errno, string $errstr) use (&$triggered, &$triggeredMessage): bool { + $triggered = true; + $triggeredMessage = $errstr; + return true; + }, E_USER_DEPRECATED); + + new Deprecated('Use something else.', null); + + restore_error_handler(); + + $this->assertTrue($triggered); + $this->assertSame('Use something else.', $triggeredMessage); + } + + public function testNullMessageTriggersEmptyError(): void + { + $triggeredMessage = null; + + set_error_handler(static function (int $errno, string $errstr) use (&$triggeredMessage): bool { + $triggeredMessage = $errstr; + return true; + }, E_USER_DEPRECATED); + + new Deprecated(null, null); + + restore_error_handler(); + + $this->assertSame('', $triggeredMessage); + } + + public function testClassAlias(): void + { + $this->assertTrue(class_exists('Deprecated')); + + $attribute = $this->make('Test message', null); + + $this->assertInstanceOf(Deprecated::class, $attribute); + } +} \ No newline at end of file From 8b8280f7c9aa23220ece363fd6b0bffe18839bf3 Mon Sep 17 00:00:00 2001 From: razvbir <6582802+razvbir@users.noreply.github.com> Date: Sat, 7 Mar 2026 19:03:48 +0000 Subject: [PATCH 30/37] Apply PHP CS Fixer and Rector changes (CI) --- tests/Attribute/DeprecatedTest.php | 34 ++++++++++++++++-------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/tests/Attribute/DeprecatedTest.php b/tests/Attribute/DeprecatedTest.php index 239783d5..fa11a018 100644 --- a/tests/Attribute/DeprecatedTest.php +++ b/tests/Attribute/DeprecatedTest.php @@ -7,23 +7,10 @@ use PHPUnit\Framework\TestCase; use Yiisoft\Html\Attribute\Deprecated; +use const E_USER_DEPRECATED; + final class DeprecatedTest extends TestCase { - private function make(?string $message, ?string $since): Deprecated - { - $errors = []; - set_error_handler(static function (int $errno, string $errstr) use (&$errors): bool { - $errors[] = $errstr; - return true; - }, E_USER_DEPRECATED); - - $attribute = new Deprecated($message, $since); - - restore_error_handler(); - - return $attribute; - } - public function testMessageProperty(): void { $attribute = $this->make('Test message', null); @@ -95,4 +82,19 @@ public function testClassAlias(): void $this->assertInstanceOf(Deprecated::class, $attribute); } -} \ No newline at end of file + + private function make(?string $message, ?string $since): Deprecated + { + $errors = []; + set_error_handler(static function (int $errno, string $errstr) use (&$errors): bool { + $errors[] = $errstr; + return true; + }, E_USER_DEPRECATED); + + $attribute = new Deprecated($message, $since); + + restore_error_handler(); + + return $attribute; + } +} From c660bc5cdf8cd4ca07545e93fa064ae7004e6197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Tue, 10 Mar 2026 21:21:02 +0200 Subject: [PATCH 31/37] Remove Deprecated polyfill --- src/Attribute/Deprecated.php | 24 ------ src/Tag/Base/NormalTag.php | 5 +- src/Tag/Base/VoidTag.php | 6 +- src/Tag/CustomTag.php | 4 +- src/Widget/ButtonGroup.php | 5 +- src/Widget/CheckboxList/CheckboxList.php | 5 +- src/Widget/RadioList/RadioList.php | 5 +- tests/Attribute/DeprecatedTest.php | 98 ------------------------ tests/Tag/Base/NormalTagTest.php | 10 --- tests/Tag/Base/VoidTagTest.php | 10 --- tests/Tag/CustomTagTest.php | 9 --- tests/Widget/ButtonGroupTest.php | 9 --- tests/Widget/CheckboxListTest.php | 9 --- tests/Widget/RadioListTest.php | 9 --- 14 files changed, 17 insertions(+), 191 deletions(-) delete mode 100644 src/Attribute/Deprecated.php delete mode 100644 tests/Attribute/DeprecatedTest.php diff --git a/src/Attribute/Deprecated.php b/src/Attribute/Deprecated.php deleted file mode 100644 index 42f5939f..00000000 --- a/src/Attribute/Deprecated.php +++ /dev/null @@ -1,24 +0,0 @@ -render(); } - #[Deprecated('Use the constructor instead.')] + /** + * @deprecated Use the constructor instead. + */ public static function create(): self { return new self(); diff --git a/src/Widget/CheckboxList/CheckboxList.php b/src/Widget/CheckboxList/CheckboxList.php index 2af04b14..87a198f8 100644 --- a/src/Widget/CheckboxList/CheckboxList.php +++ b/src/Widget/CheckboxList/CheckboxList.php @@ -11,7 +11,6 @@ use Yiisoft\Html\Html; use Yiisoft\Html\NoEncodeStringableInterface; use Yiisoft\Html\Tag\Input; -use Deprecated; use function is_array; @@ -63,7 +62,9 @@ public function __toString(): string return $this->render(); } - #[Deprecated('Use the constructor instead.')] + /** + * @deprecated Use the constructor instead. + */ public static function create(string $name): self { return new self($name); diff --git a/src/Widget/RadioList/RadioList.php b/src/Widget/RadioList/RadioList.php index 913119d7..6d5c6103 100644 --- a/src/Widget/RadioList/RadioList.php +++ b/src/Widget/RadioList/RadioList.php @@ -10,7 +10,6 @@ use Yiisoft\Html\Html; use Yiisoft\Html\NoEncodeStringableInterface; use Yiisoft\Html\Tag\Input; -use Deprecated; /** * `RadioList` represents a list of radios and their corresponding labels. @@ -57,7 +56,9 @@ public function __toString(): string return $this->render(); } - #[Deprecated('Use the constructor instead.')] + /** + * @deprecated Use the constructor instead. + */ public static function create(string $name): self { return new self($name); diff --git a/tests/Attribute/DeprecatedTest.php b/tests/Attribute/DeprecatedTest.php deleted file mode 100644 index 239783d5..00000000 --- a/tests/Attribute/DeprecatedTest.php +++ /dev/null @@ -1,98 +0,0 @@ -make('Test message', null); - - $this->assertSame('Test message', $attribute->message); - } - - public function testSinceProperty(): void - { - $attribute = $this->make('Test message', '1.0.0'); - - $this->assertSame('1.0.0', $attribute->since); - } - - public function testNullMessageProperty(): void - { - $attribute = $this->make(null, null); - - $this->assertNull($attribute->message); - } - - public function testNullSinceProperty(): void - { - $attribute = $this->make('Test message', null); - - $this->assertNull($attribute->since); - } - - public function testTriggersDeprecationError(): void - { - $triggered = false; - $triggeredMessage = null; - - set_error_handler(static function (int $errno, string $errstr) use (&$triggered, &$triggeredMessage): bool { - $triggered = true; - $triggeredMessage = $errstr; - return true; - }, E_USER_DEPRECATED); - - new Deprecated('Use something else.', null); - - restore_error_handler(); - - $this->assertTrue($triggered); - $this->assertSame('Use something else.', $triggeredMessage); - } - - public function testNullMessageTriggersEmptyError(): void - { - $triggeredMessage = null; - - set_error_handler(static function (int $errno, string $errstr) use (&$triggeredMessage): bool { - $triggeredMessage = $errstr; - return true; - }, E_USER_DEPRECATED); - - new Deprecated(null, null); - - restore_error_handler(); - - $this->assertSame('', $triggeredMessage); - } - - public function testClassAlias(): void - { - $this->assertTrue(class_exists('Deprecated')); - - $attribute = $this->make('Test message', null); - - $this->assertInstanceOf(Deprecated::class, $attribute); - } -} \ No newline at end of file diff --git a/tests/Tag/Base/NormalTagTest.php b/tests/Tag/Base/NormalTagTest.php index f1df3b1d..83ae8772 100644 --- a/tests/Tag/Base/NormalTagTest.php +++ b/tests/Tag/Base/NormalTagTest.php @@ -5,9 +5,6 @@ namespace Yiisoft\Html\Tests\Tag\Base; use PHPUnit\Framework\TestCase; -use Deprecated; -use ReflectionFunction; -use Yiisoft\Html\Tag\Base\NormalTag; use Yiisoft\Html\Tests\Objects\TestNormalTag; final class NormalTagTest extends TestCase @@ -41,11 +38,4 @@ public function testClose(): void ->close(), ); } - - public function testDeprecation(): void - { - $attributes = (new ReflectionFunction(NormalTag::tag(...)))->getAttributes(Deprecated::class); - $this->assertNotEmpty($attributes); - $this->assertSame('Use the constructor instead.', $attributes[0]->newInstance()->message); - } } diff --git a/tests/Tag/Base/VoidTagTest.php b/tests/Tag/Base/VoidTagTest.php index 17d7840f..2e222f7b 100644 --- a/tests/Tag/Base/VoidTagTest.php +++ b/tests/Tag/Base/VoidTagTest.php @@ -5,9 +5,6 @@ namespace Yiisoft\Html\Tests\Tag\Base; use PHPUnit\Framework\TestCase; -use Deprecated; -use ReflectionFunction; -use Yiisoft\Html\Tag\Base\VoidTag; use Yiisoft\Html\Tests\Objects\TestVoidTag; final class VoidTagTest extends TestCase @@ -21,11 +18,4 @@ public function testBase(): void ->render(), ); } - - public function testDeprecation(): void - { - $attributes = (new ReflectionFunction(VoidTag::tag(...)))->getAttributes(Deprecated::class); - $this->assertNotEmpty($attributes); - $this->assertSame('Use the constructor instead.', $attributes[0]->newInstance()->message); - } } diff --git a/tests/Tag/CustomTagTest.php b/tests/Tag/CustomTagTest.php index 40de8066..6936fc16 100644 --- a/tests/Tag/CustomTagTest.php +++ b/tests/Tag/CustomTagTest.php @@ -6,8 +6,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; -use Deprecated; -use ReflectionFunction; use Stringable; use Yiisoft\Html\Tag\CustomTag; use Yiisoft\Html\Tag\P; @@ -187,11 +185,4 @@ public function testImmutability(): void $this->assertNotSame($tag, $tag->content('')); $this->assertNotSame($tag, $tag->addContent('')); } - - public function testDeprecation(): void - { - $attributes = (new ReflectionFunction(CustomTag::name(...)))->getAttributes(Deprecated::class); - $this->assertNotEmpty($attributes); - $this->assertSame('Use the constructor instead.', $attributes[0]->newInstance()->message); - } } diff --git a/tests/Widget/ButtonGroupTest.php b/tests/Widget/ButtonGroupTest.php index e4d5fed2..0ebadc9f 100644 --- a/tests/Widget/ButtonGroupTest.php +++ b/tests/Widget/ButtonGroupTest.php @@ -7,8 +7,6 @@ use InvalidArgumentException; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; -use Deprecated; -use ReflectionFunction; use Yiisoft\Html\Html; use Yiisoft\Html\Widget\ButtonGroup; @@ -369,11 +367,4 @@ public function testImmutability(): void $this->assertNotSame($widget, $widget->form(null)); $this->assertNotSame($widget, $widget->separator('')); } - - public function testDeprecation(): void - { - $attributes = (new ReflectionFunction(ButtonGroup::create(...)))->getAttributes(Deprecated::class); - $this->assertNotEmpty($attributes); - $this->assertSame('Use the constructor instead.', $attributes[0]->newInstance()->message); - } } diff --git a/tests/Widget/CheckboxListTest.php b/tests/Widget/CheckboxListTest.php index b61c1e49..336c406f 100644 --- a/tests/Widget/CheckboxListTest.php +++ b/tests/Widget/CheckboxListTest.php @@ -7,8 +7,6 @@ use ArrayObject; use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; -use Deprecated; -use ReflectionFunction; use Yiisoft\Html\Html; use Yiisoft\Html\Tests\Objects\IterableObject; use Yiisoft\Html\Tests\Support\IntegerEnum; @@ -893,11 +891,4 @@ public function testImmutability(): void $this->assertNotSame($widget, $widget->separator('')); $this->assertNotSame($widget, $widget->itemFormatter(null)); } - - public function testDeprecation(): void - { - $attributes = (new ReflectionFunction(CheckboxList::create(...)))->getAttributes(Deprecated::class); - $this->assertNotEmpty($attributes); - $this->assertSame('Use the constructor instead.', $attributes[0]->newInstance()->message); - } } diff --git a/tests/Widget/RadioListTest.php b/tests/Widget/RadioListTest.php index f094045e..ae22662e 100644 --- a/tests/Widget/RadioListTest.php +++ b/tests/Widget/RadioListTest.php @@ -6,8 +6,6 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; -use Deprecated; -use ReflectionFunction; use Yiisoft\Html\Html; use Yiisoft\Html\Tests\Support\IntegerEnum; use Yiisoft\Html\Tests\Support\StringEnum; @@ -844,11 +842,4 @@ public function testImmutability(): void $this->assertNotSame($widget, $widget->separator('')); $this->assertNotSame($widget, $widget->itemFormatter(null)); } - - public function testDeprecation(): void - { - $attributes = (new ReflectionFunction(RadioList::create(...)))->getAttributes(Deprecated::class); - $this->assertNotEmpty($attributes); - $this->assertSame('Use the constructor instead.', $attributes[0]->newInstance()->message); - } } From 09e670c1cc35f4d387537bc75b51c797e6b1e92e Mon Sep 17 00:00:00 2001 From: razvbir <6582802+razvbir@users.noreply.github.com> Date: Tue, 10 Mar 2026 19:33:07 +0000 Subject: [PATCH 32/37] Apply PHP CS Fixer and Rector changes (CI) --- src/Tag/Base/NormalTag.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Tag/Base/NormalTag.php b/src/Tag/Base/NormalTag.php index 3801ea87..cf05ce0e 100644 --- a/src/Tag/Base/NormalTag.php +++ b/src/Tag/Base/NormalTag.php @@ -4,7 +4,6 @@ namespace Yiisoft\Html\Tag\Base; - /** * Base for all normal tags. Normal tags are the ones that have both opening tag and closing tag. */ From 37b523b6caa5b96d1aa27efb80ff2db73132eb05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Tue, 10 Mar 2026 21:41:09 +0200 Subject: [PATCH 33/37] Improve CHANGELOG message and remove duplication --- CHANGELOG.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3cad911e..e16e765c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,15 +1,11 @@ # Yii HTML Change Log -## 3.13.0 - -- Enh #243: Use `new tagName()` instead of static constructor `tagName::tag()` (@razvbir) - ## 3.12.1 under development - New #260: Add `$attributes` parameter to `Html::li()` method (@gauravkumar2525) - Enh #261: Enhance `RadioList::addRadioWrapClass()` method for cleaner class addition (@vjik) - Enh #263: Explicitly import classes and constants in "use" section (@mspirkov) -- Enh #243: Use `new tagName()` without parentheses instead of static constructor `tagName::tag()` (@razvbir) +- Enh #243: Deprecate static constructors such as `tagName::tag()` in favor of `new tagName()` (@razvbir) ## 3.12.0 December 13, 2025 From d765cac237f42881330de986829f3ace245be7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Tue, 10 Mar 2026 21:44:10 +0200 Subject: [PATCH 34/37] Update composer-require-checker.json --- composer-require-checker.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer-require-checker.json b/composer-require-checker.json index c8849726..c23d1d83 100644 --- a/composer-require-checker.json +++ b/composer-require-checker.json @@ -1,7 +1,6 @@ { "symbol-whitelist": [ - "BackedEnum", - "Deprecated" + "BackedEnum" ], "php-core-extensions": [ "Core", From 40a775d2b63679b2dfd5932f221306b77f206c8f Mon Sep 17 00:00:00 2001 From: Alexander Makarov Date: Tue, 10 Mar 2026 23:48:11 +0300 Subject: [PATCH 35/37] Apply suggestions from code review --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e16e765c..1c33166c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - New #260: Add `$attributes` parameter to `Html::li()` method (@gauravkumar2525) - Enh #261: Enhance `RadioList::addRadioWrapClass()` method for cleaner class addition (@vjik) - Enh #263: Explicitly import classes and constants in "use" section (@mspirkov) -- Enh #243: Deprecate static constructors such as `tagName::tag()` in favor of `new tagName()` (@razvbir) +- Chg #243: Deprecate static constructors such as `tagName::tag()` in favor of `new tagName()` (@razvbir) ## 3.12.0 December 13, 2025 From 78ca70704339eae3924da32e9bcf5b39c36bdfb7 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Wed, 11 Mar 2026 10:50:43 +0300 Subject: [PATCH 36/37] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c33166c..7e291fb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - New #260: Add `$attributes` parameter to `Html::li()` method (@gauravkumar2525) - Enh #261: Enhance `RadioList::addRadioWrapClass()` method for cleaner class addition (@vjik) - Enh #263: Explicitly import classes and constants in "use" section (@mspirkov) -- Chg #243: Deprecate static constructors such as `tagName::tag()` in favor of `new tagName()` (@razvbir) +- Chg #243: Deprecate static constructors such as `TagName::tag()` in favor of `new TagName()` (@razvbir) ## 3.12.0 December 13, 2025 From 702ed5226f6430a7f7785e4d9fdf6c3025c74df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C4=83zvan=20Biri=C8=99an?= Date: Wed, 11 Mar 2026 14:34:43 +0200 Subject: [PATCH 37/37] Add tests for static constructors --- tests/Tag/Base/NormalTagTest.php | 10 ++++++++++ tests/Tag/Base/VoidTagTest.php | 10 ++++++++++ tests/Tag/CustomTagTest.php | 12 ++++++++++++ tests/Widget/ButtonGroupTest.php | 19 +++++++++++++++++++ tests/Widget/CheckboxListTest.php | 13 +++++++++++++ tests/Widget/RadioListTest.php | 18 ++++++++++++++++++ 6 files changed, 82 insertions(+) diff --git a/tests/Tag/Base/NormalTagTest.php b/tests/Tag/Base/NormalTagTest.php index 83ae8772..be966862 100644 --- a/tests/Tag/Base/NormalTagTest.php +++ b/tests/Tag/Base/NormalTagTest.php @@ -19,6 +19,16 @@ public function testBase(): void ); } + public function testTag(): void + { + $this->assertSame( + 'content', + TestNormalTag::tag() + ->id('main') + ->render(), + ); + } + public function testOpen(): void { $this->assertSame( diff --git a/tests/Tag/Base/VoidTagTest.php b/tests/Tag/Base/VoidTagTest.php index 2e222f7b..114a6c1d 100644 --- a/tests/Tag/Base/VoidTagTest.php +++ b/tests/Tag/Base/VoidTagTest.php @@ -18,4 +18,14 @@ public function testBase(): void ->render(), ); } + + public function testTag(): void + { + $this->assertSame( + '', + TestVoidTag::tag() + ->id('main') + ->render(), + ); + } } diff --git a/tests/Tag/CustomTagTest.php b/tests/Tag/CustomTagTest.php index 6936fc16..38e4ab26 100644 --- a/tests/Tag/CustomTagTest.php +++ b/tests/Tag/CustomTagTest.php @@ -28,6 +28,18 @@ public function testBase(): void ); } + public function testName(): void + { + $this->assertSame( + 'body', + CustomTag::name('test') + ->id('custom') + ->attribute('count', 15) + ->content('body') + ->render(), + ); + } + public static function dataVoidTags(): array { return [ diff --git a/tests/Widget/ButtonGroupTest.php b/tests/Widget/ButtonGroupTest.php index 0ebadc9f..57d84157 100644 --- a/tests/Widget/ButtonGroupTest.php +++ b/tests/Widget/ButtonGroupTest.php @@ -31,6 +31,25 @@ public function testBase(): void ); } + public function testCreate(): void + { + $widget = ButtonGroup::create() + ->buttons( + Html::resetButton('Reset Data'), + Html::submitButton('Send'), + ); + + $this->assertStringContainsStringIgnoringLineEndings( + << + + +
    + HTML, + $widget->render(), + ); + } + public function testWithoutButtons(): void { $this->assertSame('', (new ButtonGroup())->render()); diff --git a/tests/Widget/CheckboxListTest.php b/tests/Widget/CheckboxListTest.php index 336c406f..6c5b1be4 100644 --- a/tests/Widget/CheckboxListTest.php +++ b/tests/Widget/CheckboxListTest.php @@ -48,6 +48,19 @@ public function testName(): void ); } + public function testCreate(): void + { + $widget = CheckboxList::create('b') + ->items([1 => 'One']); + + $this->assertSame( + '
    ' . "\n" + . '' . "\n" + . '
    ', + $widget->render(), + ); + } + public function testWithoutContainer(): void { $this->assertSame( diff --git a/tests/Widget/RadioListTest.php b/tests/Widget/RadioListTest.php index ae22662e..35d70adb 100644 --- a/tests/Widget/RadioListTest.php +++ b/tests/Widget/RadioListTest.php @@ -32,6 +32,24 @@ public function testBase(): void ); } + public function testCreate(): void + { + $this->assertSame( + '' . "\n" + . '
    ' . "\n" + . '' . "\n" + . '' . "\n" + . '' . "\n" + . '
    ', + RadioList::create('test') + ->items([1 => 'One', 2 => 'Two', 5 => 'Five']) + ->uncheckValue(0) + ->value(2) + ->containerAttributes(['id' => 'main']) + ->render(), + ); + } + public function testName(): void { $widget = (new RadioList('a'))