public function open() : string
{
if (TRUE === $this->contentOnly) {
return '';
}
$this->isEmptyElement = isset($this->emptyElements[$this->tag]);
$buff = '';
foreach ($this->attributes as $name => $value) {
if (isset(self::$attrs[$name])) {
if (($name === 'selected' || $name === 'checked' || $name === 'readonly' || $name === 'disabled') && $value) {
$value = $name;
}
$notEmpty = $value !== null && $value !== '' && $value !== false;
if ($this->isRequiredAttr($this->tag, $name) || $notEmpty) {
// For not empty attributes and the value attribute by the <option> tag
if (!isset($this->noEncode[$name])) {
$value = String::escape($value);
}
$attrString = sprintf(' %s="%s"', $name, $value);
if ($name === 'value') {
if ($this->tag === 'textarea') {
$buff .= '';
} else {
$buff .= $attrString;
}
} else {
$buff .= $attrString;
}
}
}
}
$buff = '<' . $this->tag . $buff . ($this->xhtml ? $this->isEmptyElement ? ' />' : '>' : '>');
return $buff;
}