2626 */
2727trait ResolvesVariants
2828{
29- /** @param array<string, string|bool> $props */
29+ /** @param array<string, string|bool|array<string, string|bool> > $props */
3030 public function __invoke (array $ props = [], string $ slot = '' ): string
3131 {
3232 $ props = $ this ->applyDefaultVariants ($ props );
@@ -41,8 +41,8 @@ public function __invoke(array $props = [], string $slot = ''): string
4141 }
4242
4343 /**
44- * @param array<string, string|bool> $props
45- * @return array<string, string|bool>
44+ * @param array<string, string|bool|array<string, string|bool> > $props
45+ * @return array<string, string|bool|array<string, string|bool> >
4646 */
4747 private function applyDefaultVariants (array $ props ): array
4848 {
@@ -66,9 +66,7 @@ private function resolveSlot(string $slot): string
6666 if (is_array ($ this ->base ) && ! array_is_list ($ this ->base )) {
6767 if (count ($ this ->base ) === 1 ) {
6868 return (string ) array_key_first ($ this ->base );
69- }
70-
71- if (count ($ this ->base ) > 1 ) {
69+ } else {
7270 throw new InvalidArgumentException (
7371 'Multiple slots defined but no slot specified. Available slots: ' . implode (', ' , array_keys ($ this ->base )),
7472 );
@@ -106,7 +104,7 @@ private function resolvePassthrough(array $props, string $slot): ClassNames
106104 }
107105
108106 /**
109- * @param array<string, string|bool> $props
107+ * @param array<string, string|bool|array<string, string|bool> > $props
110108 */
111109 private function resolveVariants (array $ props , string $ slot ): ClassNames
112110 {
@@ -116,7 +114,15 @@ private function resolveVariants(array $props, string $slot): ClassNames
116114 $ variants = $ this ->variants ;
117115
118116 foreach ($ props as $ key => $ value ) {
119- $ lookupKey = is_bool ($ value ) ? ($ value ? 'true ' : 'false ' ) : $ value ;
117+ if (is_array ($ value )) {
118+ continue ;
119+ }
120+
121+ $ lookupKey = match (true ) {
122+ $ value === true => 'true ' ,
123+ $ value === false => 'false ' ,
124+ default => $ value ,
125+ };
120126 $ entry = $ variants [$ key ][$ lookupKey ] ?? null ;
121127
122128 if ($ entry === null ) {
@@ -130,7 +136,7 @@ private function resolveVariants(array $props, string $slot): ClassNames
130136 }
131137
132138 /**
133- * @param array<string, string|bool> $props
139+ * @param array<string, string|bool|array<string, string|bool> > $props
134140 */
135141 private function resolveCompoundVariants (array $ props , string $ slot ): ClassNames
136142 {
@@ -153,7 +159,7 @@ private function resolveCompoundVariants(array $props, string $slot): ClassNames
153159 }
154160
155161 /**
156- * @param array<string, string|bool> $props
162+ * @param array<string, string|bool|array<string, string|bool> > $props
157163 * @param array<string, mixed> $compound
158164 */
159165 private function compoundMatches (array $ props , array $ compound ): bool
0 commit comments