Skip to content

Commit 244c3d8

Browse files
committed
Split $arg0 and $args as suggested by @luanalatte
1 parent 6b762dd commit 244c3d8

3 files changed

Lines changed: 1038 additions & 511 deletions

File tree

gen.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,16 @@ function generateNormalElement(string $funcName, string $tag): string
168168
{
169169
global $attrsType, $phpAttrsType, $childType;
170170
return <<<EOD
171-
/** @param $attrsType|$childType \$args - attribute array or children */
172-
function $funcName($phpAttrsType|$childType ...\$args): HTMLElement
171+
/**
172+
* @param $attrsType|$childType \$arg0 HTML attributes or first child
173+
* @param $childType \$args - any further children
174+
*/
175+
function $funcName(
176+
$phpAttrsType|$childType \$arg0 = [],
177+
$childType ...\$args,
178+
): HTMLElement
173179
{
174-
return new HTMLElement("$tag", \$args);
180+
return new HTMLElement("$tag", [\$arg0, ...\$args]);
175181
}
176182
EOD;
177183
}
@@ -181,7 +187,9 @@ function generateSelfClosingElement(string $funcName, string $tag): string
181187
global $attrsType, $phpAttrsType;
182188
return <<<EOD
183189
/** @param $attrsType \$attrs */
184-
function $funcName($phpAttrsType \$attrs = []): SelfClosingHTMLElement
190+
function $funcName(
191+
$phpAttrsType \$attrs = [],
192+
): SelfClosingHTMLElement
185193
{
186194
return new SelfClosingHTMLElement("$tag", \$attrs);
187195
}

0 commit comments

Comments
 (0)