@@ -40,18 +40,18 @@ class SelectTag extends PairTag implements Input
4040 /**
4141 * Html select box.
4242 *
43- * @param string $name name
44- * @param array $items items
45- * @param string $defaultValue default item id
46- * @param array $properties select tag properties
43+ * @param string $name name
44+ * @param array<string, string> $items items
45+ * @param string $defaultValue default item id
46+ * @param array<string, string> $properties select tag properties
4747 */
4848 public function __construct (string $ name , array $ items = [], string $ defaultValue = '' , array $ properties = [])
4949 {
5050 parent ::__construct ('select ' , $ properties );
5151 $ this ->defaultValue = $ defaultValue ;
5252 $ this ->setTagName ($ name );
5353
54- if (\is_array ( $ items) ) {
54+ if ($ items ) {
5555 $ this ->addItems ($ items );
5656 }
5757 }
@@ -68,7 +68,7 @@ public function addItems(array $items): array
6868 foreach ($ items as $ itemName => $ itemValue ) {
6969 $ added [$ itemName ] = $ this ->addItem (new OptionTag ((string ) $ itemValue , (string ) $ itemName ));
7070
71- if ($ this ->defaultValue === $ itemName ) {
71+ if ($ this ->defaultValue === ( string ) $ itemName ) {
7272 $ this ->lastItem ()->setDefault ();
7373 }
7474 }
@@ -160,14 +160,18 @@ public function disableItem($itemID): void
160160 * Get value of selected item.
161161 */
162162 #[\Override]
163- public function getValue (): string
163+ public function getValue (): ? string
164164 {
165+ $ value = null ;
166+
165167 foreach ($ this ->pageParts as $ option ) {
166168 $ pos = array_search ('selected ' , $ option ->tagProperties , true );
167169
168170 if (($ pos !== false ) && is_numeric ($ pos )) {
169- return $ option ->getValue ();
171+ $ value = $ option ->getValue ();
170172 }
171173 }
174+
175+ return $ value ;
172176 }
173177}
0 commit comments