Modern DOM library written in PHP for HTML documents
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.5 KiB

<?php
/**
* @license MIT
* Copyright 2017 Dustin Wilson, J. King, et al.
* See LICENSE and AUTHORS files for details
*/
declare(strict_types=1);
namespace MensBeam\HTML\DOM;
/** @property \DOMDocumentType $_innerNode */
class DocumentType extends Node {
use ChildNode;
// We need to work around a PHP DOM bug where doctype nodes aren't associated
// with a document until they're appended. _ownerDocument is set when the node
// is created but ignored once the doctype is appended to a document
protected ?\WeakReference $_ownerDocument = null;
protected function __get_name(): string {
// Return an empty string if a space is the name of the doctype. While the DOM
// itself cannot create a doctype with an empty string as the name, the HTML
// parser can. PHP's DOM cannot handle an empty string as the name, so a single
// space (an invalid value) is used instead and coerced to an empty string.
$name = $this->_innerNode->name;
return ($name !== ' ') ? $this->_innerNode->name : '';
}
protected function __get_ownerDocument(): ?Document {
return parent::__get_ownerDocument() ?? $this->_ownerDocument->get();
}
protected function __get_publicId(): string {
return $this->_innerNode->publicId;
}
protected function __get_systemId(): string {
return $this->_innerNode->systemId;
}
protected function __construct(\DOMDocumentType $doctype) {
parent::__construct($doctype);
}
}