|
13 | 13 | */
|
14 | 14 | class Html extends Markup
|
15 | 15 | {
|
16 |
| - /** |
17 |
| - * Auto close these tags. |
18 |
| - * |
19 |
| - * @var array<int, string> |
20 |
| - */ |
21 |
| - protected $autocloseTagsList = [ |
22 |
| - 'img', 'br', 'hr', 'input', 'area', 'link', 'meta', 'param', |
23 |
| - ]; |
24 |
| - |
25 | 16 | /**
|
26 | 17 | * Current tag.
|
27 | 18 | *
|
28 | 19 | * @var string
|
29 | 20 | */
|
30 | 21 | protected $tag = 'tag';
|
31 | 22 |
|
| 23 | + /** |
| 24 | + * @param string $tag |
| 25 | + * @param array<mixed> $arguments |
| 26 | + */ |
| 27 | + public function __call($tag, $arguments): Html |
| 28 | + { |
| 29 | + // Reserved word: `call` ->class() |
| 30 | + if ($tag === 'class') { |
| 31 | + return $this->addClass(...$arguments); |
| 32 | + } |
| 33 | + |
| 34 | + // Reserved word: `for` ->for() |
| 35 | + if ($tag === 'for') { |
| 36 | + return $this->addFor(...$arguments); |
| 37 | + } |
| 38 | + |
| 39 | + array_unshift($arguments, $tag); |
| 40 | + |
| 41 | + return call_user_func_array([$this, 'addElement'], $arguments); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * @param string $tag |
| 46 | + * @param array<mixed> $arguments |
| 47 | + */ |
| 48 | + public static function __callStatic($tag, $arguments): Html |
| 49 | + { |
| 50 | + array_unshift($arguments, $tag); |
| 51 | + |
| 52 | + return call_user_func_array(['self', 'createElement'], $arguments); |
| 53 | + } |
| 54 | + |
32 | 55 | /**
|
33 | 56 | * Shortcut to set('action', $url).
|
34 | 57 | */
|
@@ -1013,7 +1036,7 @@ public function s(\Closure|string|bool|null $value = true): string
|
1013 | 1036 | /**
|
1014 | 1037 | * (Re)Define an attribute.
|
1015 | 1038 | *
|
1016 |
| - * @param ?string $name |
| 1039 | + * @param string|array<mixed>|null $name |
1017 | 1040 | * @param ?string $value
|
1018 | 1041 | */
|
1019 | 1042 | public function set($name, $value = null): Html
|
@@ -1360,36 +1383,4 @@ public static function tr(mixed ...$arguments): Html
|
1360 | 1383 |
|
1361 | 1384 | return self::createElement(...$arguments);
|
1362 | 1385 | }
|
1363 |
| - |
1364 |
| - /** |
1365 |
| - * @param string $tag |
1366 |
| - * @param array<mixed> $arguments |
1367 |
| - */ |
1368 |
| - public function __call($tag, $arguments): Html |
1369 |
| - { |
1370 |
| - // Reserved word: `call` ->class() |
1371 |
| - if ($tag === 'class') { |
1372 |
| - return $this->addClass(...$arguments); |
1373 |
| - } |
1374 |
| - |
1375 |
| - // Reserved word: `for` ->for() |
1376 |
| - if ($tag === 'for') { |
1377 |
| - return $this->addFor(...$arguments); |
1378 |
| - } |
1379 |
| - |
1380 |
| - array_unshift($arguments, $tag); |
1381 |
| - |
1382 |
| - return call_user_func_array([$this, 'addElement'], $arguments); |
1383 |
| - } |
1384 |
| - |
1385 |
| - /** |
1386 |
| - * @param string $tag |
1387 |
| - * @param array<mixed> $arguments |
1388 |
| - */ |
1389 |
| - public static function __callStatic($tag, $arguments): Html |
1390 |
| - { |
1391 |
| - array_unshift($arguments, $tag); |
1392 |
| - |
1393 |
| - return call_user_func_array(['self', 'createElement'], $arguments); |
1394 |
| - } |
1395 | 1386 | }
|
0 commit comments