@@ -1692,7 +1692,7 @@ public static function renderTagAttributes(array $attributes): string
16921692 *
16931693 * @see removeCssClass()
16941694 *
1695- * @param array $options The options to be modified.
1695+ * @param array $options The options to be modified. All string values in the array must be valid UTF-8 strings.
16961696 * @param BackedEnum|BackedEnum[]|null[]|string|string[]|null $class The CSS class(es) to be added. Null values will
16971697 * be ignored.
16981698 *
@@ -1733,7 +1733,11 @@ public static function addCssClass(array &$options, BackedEnum|array|string|null
17331733 /** @psalm-var string[] $options['class'] */
17341734 $ options ['class ' ] = self ::mergeCssClasses ($ options ['class ' ], (array ) $ class );
17351735 } else {
1736- /** @psalm-var string $options['class'] */
1736+ /**
1737+ * @psalm-var string $options['class']
1738+ * @var string[] $classes We assume that `$options['class']` is valid UTF-8 string, so `preg_split()`
1739+ * never returns `false`.
1740+ */
17371741 $ classes = preg_split ('/\s+/ ' , $ options ['class ' ], -1 , PREG_SPLIT_NO_EMPTY );
17381742 $ classes = self ::mergeCssClasses ($ classes , (array ) $ class );
17391743 $ options ['class ' ] = is_array ($ class ) ? $ classes : implode (' ' , $ classes );
@@ -1937,7 +1941,7 @@ public static function cssStyleToArray(string|Stringable $style): array
19371941 *
19381942 * @link https://html.spec.whatwg.org/multipage/input.html#the-pattern-attribute
19391943 *
1940- * @param string $regexp PCRE regular expression.
1944+ * @param string $regexp PCRE regular expression. It must be valid UTF-8 string.
19411945 * @param string|null $delimiter Regular expression delimiter.
19421946 *
19431947 * @throws InvalidArgumentException if incorrect regular expression or delimiter
@@ -1950,6 +1954,10 @@ public static function normalizeRegexpPattern(string $regexp, ?string $delimiter
19501954 throw new InvalidArgumentException ('Incorrect regular expression. ' );
19511955 }
19521956
1957+ /**
1958+ * @var string $pattern We assume that `$regexp` is valid UTF-8 string, so `preg_replace()` never returns
1959+ * `null`.
1960+ */
19531961 $ pattern = preg_replace ('/ \\\\x{?([0-9a-fA-F]+)}?/ ' , '\u$1 ' , $ regexp );
19541962
19551963 if ($ delimiter === null ) {
0 commit comments