Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX] Prevent php warning when passing array as tag attribute #858

Merged
merged 1 commit into from
Mar 11, 2024

Conversation

s2b
Copy link
Contributor

@s2b s2b commented Mar 4, 2024

TagBuilder::addAttribute() allows both strings and array/traversables as attribute value. However, in the implementation only "data" and "aria" are properly handled as arrays. For other attribute names, this leads to a type conversion warning.

With this patch, that edge case is properly handled with an exception. Also, test coverage is added both for data/aria and the exception.

Resolves: #857

TagBuilder::addAttribute() allows both strings and array/traversables
as attribute value. However, in the implementation only "data" and
"aria" are properly handled as arrays. For other attribute names,
this leads to a type conversion warning.

With this patch, that edge case is properly handled with an
exception. Also, test coverage is added both for data/aria and the
exception.

Resolves: #857
@s2b s2b force-pushed the bugfix/tagBuilderArrayAttribute branch from f38c2ef to 5e6ffb7 Compare March 4, 2024 15:46
@s2b s2b merged commit 53cea02 into main Mar 11, 2024
6 checks passed
@s2b s2b deleted the bugfix/tagBuilderArrayAttribute branch March 11, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHP Warning: Array to string conversion in TagBuilder.php line 200
3 participants