Flatten some of the function implementations?
Consider function element
and function emptyElement
:
function element(string $name): Closure {
return function (Attribute ...$attributes) use ($name): Closure {
return function (Node ...$children) use ($name, $attributes): Element {
return new Element($name, $attributes, $children);
};
};
}
function emptyElement(string $name): Closure {
return function (Attribute ...$attributes) use ($name) : EmptyElement {
return new EmptyElement($name, $attributes);
};
}
They take a non-variadic parameter $name
and then return a closure which takes only a variadic. Why not flatten them like so?
function element(string $name, Attribute ...$attributes): Closure {
return function (Node ...$children) use ($name, $attributes): Element {
return new Element($name, $attributes, $children);
};
}
function emptyElement(string $name, Attribute ...$attributes): EmptyElement {
return new EmptyElement($name, $attributes);
}