diff --git a/src/Icons/CHANGELOG.md b/src/Icons/CHANGELOG.md index 71eb76d0f2..2868a9ae64 100644 --- a/src/Icons/CHANGELOG.md +++ b/src/Icons/CHANGELOG.md @@ -3,6 +3,7 @@ ## 2.20.0 - Add `aliases` configuration option to define icon alternative names. +- Fix `Icon` component to accept `integer` or `float` attributes. ## 2.19.0 diff --git a/src/Icons/src/Icon.php b/src/Icons/src/Icon.php index 41883a9825..225460c20b 100644 --- a/src/Icons/src/Icon.php +++ b/src/Icons/src/Icon.php @@ -189,8 +189,8 @@ public function withAttributes(array $attributes): self throw new \InvalidArgumentException(\sprintf('Invalid attribute name "%s".', $name)); } - if (!\is_string($value) && !\is_bool($value)) { - throw new \InvalidArgumentException(\sprintf('Invalid value type for attribute "%s". Boolean or string allowed, "%s" provided. ', $name, get_debug_type($value))); + if (!\is_string($value) && !\is_bool($value) && !\is_int($value) && !\is_float($value)) { + throw new \InvalidArgumentException(\sprintf('Invalid value type for attribute "%s". Boolean, string, int or float allowed, "%s" provided. ', $name, get_debug_type($value))); } } diff --git a/src/Icons/tests/Fixtures/templates/template1.html.twig b/src/Icons/tests/Fixtures/templates/template1.html.twig index 9824703029..096a3d5333 100644 --- a/src/Icons/tests/Fixtures/templates/template1.html.twig +++ b/src/Icons/tests/Fixtures/templates/template1.html.twig @@ -2,8 +2,10 @@