Conversation
vjik
commented
Mar 17, 2026
| Q | A |
|---|---|
| Is bugfix? | ❌ |
| New feature? | ✔️ |
| Breaks BC? | ❌ |
| Fix #151 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #270 +/- ##
===========================================
Coverage 100.00% 100.00%
- Complexity 827 828 +1
===========================================
Files 89 89
Lines 2225 2225
===========================================
Hits 2225 2225 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR implements issue #151 by widening supported tag content types across the tag API, allowing int, float, and null to be used as content (rendering numeric scalars as strings and null as empty content), and extends coverage across multiple tags and helpers.
Changes:
- Expand
TagContentTraitto acceptint|float|nulland ensure consistent string rendering. - Widen multiple tag/helper method signatures (e.g.,
Html::*,Button::*,Table::captionString(),Textarea::value(), table/list cell builders) to accept the new content types. - Add/extend PHPUnit coverage for numeric/null content across tags and helper factories.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Tag/TrTest.php | Adds coverage for `null |
| tests/Tag/TextareaTest.php | Adds coverage for numeric Textarea::value(). |
| tests/Tag/TableTest.php | Refactors captionString test into a data provider including numeric/null inputs. |
| tests/Tag/StyleTest.php | Adds coverage for Stringable style content. |
| tests/Tag/SelectTest.php | Adds coverage for numeric option labels and Stringable prompt text. |
| tests/Tag/ScriptTest.php | Adds coverage for Stringable script content. |
| tests/Tag/OptgroupTest.php | Adds coverage for numeric option labels in optgroups. |
| tests/Tag/CustomTagTest.php | Adds coverage for numeric/null content on custom tags. |
| tests/Tag/ButtonTest.php | Refactors button/submit/reset tests into data providers covering numeric/null content. |
| tests/Tag/Base/TagContentTraitTest.php | Extends trait tests for numeric/null content and addContent/content-array behavior. |
| tests/Tag/Base/ListTagTest.php | Adds coverage for numeric/null list item content. |
| tests/HtmlTest.php | Extends Html::* helper tests to assert numeric/null content rendering across many tags. |
| src/Tag/Tr.php | Updates internal cell builders to accept `Stringable |
| src/Tag/Textarea.php | Widens value() to accept numeric values and casts to string. |
| src/Tag/Table.php | Widens captionString() to accept `Stringable |
| src/Tag/Style.php | Allows Stringable content and casts to string. |
| src/Tag/Select.php | Widens OptionsData Psalm type and prompt() to accept Stringable. |
| src/Tag/Script.php | Allows Stringable content and casts to string. |
| src/Tag/Optgroup.php | Updates options-data PHPDoc to allow numeric/null option labels. |
| src/Tag/Button.php | Widens named constructors to accept `Stringable |
| src/Tag/Base/TagContentTrait.php | Core change: allow `int |
| src/Tag/Base/ListTag.php | Updates list strings() to accept numeric/null item content. |
| src/Html.php | Widens many helper signatures to accept `int |
| CHANGELOG.md | Adds entry describing the new feature. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
This PR extends the HTML tag API to accept int, float, and null as tag content across core tag building helpers, aligning behavior with issue #151 and updating tests accordingly.
Changes:
- Broaden
TagContentTraitcontent handling to supportstring|Stringable|int|float|nulland stringify content during rendering. - Update multiple tag/helper APIs (
Html::*,Button,Table::captionString(),Select::prompt(), list/table row helpers) and add test coverage for the new accepted content types. - Add/extend tests across tags to validate rendering of numeric and null content.
Reviewed changes
Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Tag/TrTest.php | Extends Tr::dataStrings() / headerStrings() test cases to include null, int, float. |
| tests/Tag/TextareaTest.php | Adds int/float value cases for <textarea>. |
| tests/Tag/TableTest.php | Converts caption string test to a data provider covering `string |
| tests/Tag/StyleTest.php | Adds coverage for Style::content() accepting Stringable. |
| tests/Tag/SelectTest.php | Adds coverage for numeric/null option labels and prompt text types. |
| tests/Tag/ScriptTest.php | Adds coverage for Script::content() accepting Stringable. |
| tests/Tag/OptgroupTest.php | Adds coverage for numeric option labels in optgroups. |
| tests/Tag/CustomTagTest.php | Adds content cases for `int |
| tests/Tag/ButtonTest.php | Adds data providers covering `string |
| tests/Tag/Base/TagContentTraitTest.php | Extends trait tests for numeric/null content and array/named-argument usage. |
| tests/Tag/Base/ListTagTest.php | Adds coverage for list item contents including numeric/null. |
| tests/HtmlTest.php | Adds coverage for Html::* helpers with numeric/null content + stringable style/script. |
| src/Tag/Tr.php | Updates internal cell creation to accept broader content types; updates header docs. |
| src/Tag/Textarea.php | Widens value() accepted types to include `int |
| src/Tag/Table.php | Widens captionString() to accept `Stringable |
| src/Tag/Style.php | Allows Stringable content and casts to string. |
| src/Tag/Select.php | Broadens OptionsData psalm type and widens prompt() to numeric/null/stringable. |
| src/Tag/Script.php | Allows Stringable content and casts to string. |
| src/Tag/Optgroup.php | Updates option data phpdoc to allow numeric/null/stringable contents. |
| src/Tag/Button.php | Widens static factory methods to accept numeric/null/stringable content. |
| src/Tag/Base/TagContentTrait.php | Core change: allow `int |
| src/Tag/Base/ListTag.php | Widens list item “strings” helpers to accept numeric/null/stringable contents. |
| src/Html.php | Widens many helper method content parameter types to include `int |
| CHANGELOG.md | Adds changelog entry for allowing int, float, null tag content. |
Comments suppressed due to low confidence (2)
src/Tag/Tr.php:106
makeDataCells()now acceptsstring|Stringable|int|float|null, but the publicdataStrings()/addDataStrings()docblocks above still say@param string[] $stringsand describe encoding “strings passed”. Please update those docblocks to match the actual supported content types (as done forheaderStrings()), so static analysis and IDE hints stay accurate.
/**
* @param (string|Stringable|int|float|null)[] $strings
*
* @return Td[]
*/
private function makeDataCells(array $strings, array $attributes, bool $encode): array
{
return array_map(
static fn(string|Stringable|int|float|null $string) => (new Td())
->content($string)
->attributes($attributes)
->encode($encode),
$strings,
);
src/Tag/Textarea.php:50
Textarea::value()currently casts any non-array$valueto string before passing it toTagContentTrait::content(). This loses object identity forNoEncodeStringableInterfaceimplementations (they will now be encoded because they become plain strings). SinceTagContentTrait::content()now supportsStringable|int|float|null, consider passing$valuethrough unchanged (and onlyimplode()arrays) to preserve encoding semantics for stringable inputs.
public function value(string|Stringable|int|float|array|null $value): self
{
$content = is_array($value)
? implode("\n", $value)
: (string) $value;
return $this->content($content);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.