Browse Source

More documentation, disabled C14N

split-manual
Dustin Wilson 3 years ago
parent
commit
f5cca19355
  1. 13
      docs/en/030_Document_Object_Model/010_Document/020_Document-C14N.md
  2. 13
      docs/en/030_Document_Object_Model/010_Document/020_Document-C14NFile.md
  3. 69
      docs/en/030_Document_Object_Model/010_Document/index.md
  4. 46
      docs/en/030_Document_Object_Model/Walk/010_Walk-walk.md
  5. 11
      docs/en/030_Document_Object_Model/Walk/index.md
  6. 2
      lib/DOM/Comment.php
  7. 2
      lib/DOM/Document.php
  8. 2
      lib/DOM/DocumentFragment.php
  9. 2
      lib/DOM/Element.php
  10. 2
      lib/DOM/ProcessingInstruction.php
  11. 2
      lib/DOM/Text.php
  12. 18
      lib/DOM/traits/C14N.php

13
docs/en/030_Document_Object_Model/010_Document/020_Document-C14N.md

@ -0,0 +1,13 @@
---
title: Document::C14N
---
Document::C14N — **DISABLED**
## Description ##
```php
public Document::C14N ( bool $exclusive = false , bool $withComments = false , array|null $xpath = null , array|null $nsPrefixes = null ) : false
```
This function has been disabled and will always return `false`. `\DOMDocument::C14N` is an extremely slow and inefficient method to serialize DOM and never should be used. Documented to show difference from [`\DOMDocument`](https://www.php.net/manual/en/class.domdocument.php).

13
docs/en/030_Document_Object_Model/010_Document/020_Document-C14NFile.md

@ -0,0 +1,13 @@
---
title: Document::C14NFile
---
Document::C14NFile — **DISABLED**
## Description ##
```php
public Document::C14NFile ( string $uri , bool $exclusive = false , bool $withComments = false , array|null $xpath = null , array|null $nsPrefixes = null ) : false
```
This function has been disabled and will always return `false`. `\DOMDocument::C14NFile` is an extremely slow and inefficient method to serialize DOM and never should be used. Documented to show difference from [`\DOMDocument`](https://www.php.net/manual/en/class.domdocument.php).

69
docs/en/030_Document_Object_Model/010_Document/index.md

@ -11,6 +11,7 @@ Represents an entire HTML document; serves as the root of the document tree. Unl
<div class="info"><p><strong>Info</strong> Only new methods and methods which make outward-facing changes from <a href="https://www.php.net/manual/en/class.domdocument.php">\DOMDocument</a> will be documented here, otherwise they will be linked back to PHP's documentation.</p></div>
<pre><code class="php">MensBeam\HTML\Document extends <a href="https://www.php.net/manual/en/class.domdocument.php">\DOMDocument</a> {
use <a href="../Walk/index.html">Walk</a>;
/* Constants */
public const NO_QUIRKS_MODE = 0 ;
@ -18,26 +19,26 @@ Represents an entire HTML document; serves as the root of the document tree. Unl
public const LIMITED_QUIRKS_MODE = 2 ;
/* Properties */
public string|null $documentEncoding = null ;
public int $quirksMode = 0 ;
public string|null <a href="#document-props-documentencoding">$documentEncoding</a> = null ;
public int <a href="#document-props-quirksmode">$quirksMode</a> = 0 ;
/* Inherited properties from <a href="https://www.php.net/manual/en/class.domdocument.php">\DOMDocument</a> */
public readonly DocumentType <a href="https://www.php.net/manual/en/class.domdocument.php#domdocument.props.doctype">$doctype</a> ;
public readonly Element <a href="https://www.php.net/manual/en/class.domdocument.php#domdocument.props.documentelement">$documentElement</a> ;
public string|null <a href="https://www.php.net/manual/en/class.domdocument.php#domdocument.props.documenturi">$documentURI</a> ;
public readonly \<a href="https://www.php.net/manual/en/class.domimplementation.php">DOMImplementation</a> <a href="https://www.php.net/manual/en/class.domdocument.php#domdocument.props.implementation">$implementation</a> ;
public readonly <a href="https://www.php.net/manual/en/class.domimplementation.php">\DOMImplementation</a> <a href="https://www.php.net/manual/en/class.domdocument.php#domdocument.props.implementation">$implementation</a> ;
/* Inherited properties from <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a> */
public readonly string <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.nodename">$nodeName</a> ;
public string <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.nodevalue">$nodeValue</a> ;
public readonly int <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.nodetype">$nodeType</a> ;
public readonly \<a href="https://www.php.net/manual/en/class.domnode.php">DOMNode</a>|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.parentnode">$parentNode</a> ;
public readonly \<a href="https://www.php.net/manual/en/class.domnodelist.php">DOMNodeList</a> <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.childnodes">$childNodes</a> ;
public readonly \<a href="https://www.php.net/manual/en/class.domnode.php">DOMNode</a>|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.firstchild">$firstChild</a> ;
public readonly \<a href="https://www.php.net/manual/en/class.domnode.php">DOMNode</a>|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.lastchild">$lastChild</a> ;
public readonly \<a href="https://www.php.net/manual/en/class.domnode.php">DOMNode</a>|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.previoussibling">$previousSibling</a> ;
public readonly \<a href="https://www.php.net/manual/en/class.domnode.php">DOMNode</a>|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.nextsibling">$nextSibling</a> ;
public readonly \<a href="https://www.php.net/manual/en/class.domnamednodemap.php">DOMNamedNodeMap</a>|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.attributes">$attributes</a> ;
public readonly <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.parentnode">$parentNode</a> ;
public readonly <a href="https://www.php.net/manual/en/class.domnodelist.php">\DOMNodeList</a> <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.childnodes">$childNodes</a> ;
public readonly <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.firstchild">$firstChild</a> ;
public readonly <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.lastchild">$lastChild</a> ;
public readonly <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.previoussibling">$previousSibling</a> ;
public readonly <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.nextsibling">$nextSibling</a> ;
public readonly <a href="https://www.php.net/manual/en/class.domnamednodemap.php">\DOMNamedNodeMap</a>|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.attributes">$attributes</a> ;
public readonly Document|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.ownerdocument">$ownerDocument</a> ;
public readonly string|null <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.namespaceuri">$namespaceURI</a> ;
public string <a href="https://www.php.net/manual/en/class.domnode.php#domnode.props.prefix">$prefix</a> ;
@ -48,16 +49,60 @@ Represents an entire HTML document; serves as the root of the document tree. Unl
/* Methods */
public <a href="Document_construct.html">__construct</a> ( )
public <a href="Document_createEntityReference.html">createEntityReference</a> ( string $name ) : false
public <a href="Document_C14N.html">C14N</a> ( bool $exclusive = false , bool $withComments = false , array|null $xpath = null , array|null $nsPrefixes = null ) : false
public <a href="Document_C14NFile.html">C14NFile</a> ( string $uri , bool $exclusive = false , bool $withComments = false , array|null $xpath = null , array|null $nsPrefixes = null ) : false
public <a href="Document_load.html">load</a> ( string $filename , null $options = null , string|null $encodingOrContentType = null ) : bool
public <a href="Document_loadHTML.html">loadHTML</a> ( string $source , null $options = null , string|null $encodingOrContentType = null ) : bool
public <a href="Document_loadHTMLFile.html">loadHTMLFile</a> ( string $filename , null $options = null , string|null $encodingOrContentType = null ) : bool
public <a href="Document_loadHTML.html">loadXML</a> ( string $source , null $options = null ) : false
public <a href="Document_save.html">save</a> ( string $filename , null $options = null ) : int|false
public <a href="Document_saveHTMLFile.html">saveHTMLFile</a> ( string $filename , null $options = null ) : int|false
public <a href="Document_saveXML.html">saveXML</a> ( DOMNode|null $node = null , null $options = null ) : false
public <a href="Document_saveXML.html">saveXML</a> ( <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|null $node = null , null $options = null ) : false
public <a href="Document_validate.html">validate</a> ( ) : true
public <a href="Document_xinclude.html">xinclude</a> ( null $options = null ) : false
/* Methods from <a href="../Walk/index.html">Walk</a> */
public <a href="../Walk/Walk_walk.html">walk</a> ( <a href="https://www.php.net/manual/en/class.closure.php">\Closure</a> $filter ) : <a href="https://www.php.net/manual/en/class.generator.php">\Generator</a>
/* Methods inherited from <a href="https://www.php.net/manual/en/class.domdocument.php">\DOMDocument</a> */
public <a href="https://www.php.net/manual/en/domdocument.createattribute.php">createAttribute</a> ( string $localName ) : <a href="https://www.php.net/manual/en/class.domattr.php">\DOMAttr</a>|false
public <a href="https://www.php.net/manual/en/domdocument.createattributens.php">createAttributeNS</a> ( string|null $namespace , string $qualifiedName ) : <a href="https://www.php.net/manual/en/class.domattr.php">\DOMAttr</a>|false
public <a href="https://www.php.net/manual/en/domdocument.createcdatasection.php">createCDATASection</a> ( string $data ) : <a href="https://www.php.net/manual/en/class.domcdatasection.php">\DOMCdataSection</a>|false
public <a href="https://www.php.net/manual/en/domdocument.createcomment.php">createComment</a> ( string $data ) : Comment|false
public <a href="https://www.php.net/manual/en/domdocument.createdocumentfragment.php">createDocumentFragment</a> ( ) : DocumentFragment|false
public <a href="https://www.php.net/manual/en/domdocument.createelement.php">createElement</a> ( string $localName , string $value = "" ) : Element|false
public <a href="https://www.php.net/manual/en/domdocument.createelementns.php">createElementNS</a> ( string|null $namespace , string $qualifiedName , string $value = "" ) : Element|false
public <a href="https://www.php.net/manual/en/domdocument.createprocessinginstruction.php">createProcessingInstruction</a> ( string $target , string $data = "" ) : ProcessingInstruction|false
public <a href="https://www.php.net/manual/en/domdocument.createtextnode.php">createTextNode</a> ( string $data ) : Text|false
public <a href="https://www.php.net/manual/en/domdocument.getelementbyid.php">getElementById</a> ( string $elementId ) : Element|null
public <a href="https://www.php.net/manual/en/domdocument.getelementsbytagname.php">getElementsByTagName</a> ( string $qualifiedName ) : <a href="https://www.php.net/manual/en/class.domnodelist.php">\DOMNodeList</a>
public <a href="https://www.php.net/manual/en/domdocument.createelementsbytagnamens.php">getElementsByTagNameNS</a> ( string $namespace , string $localName ) : <a href="https://www.php.net/manual/en/class.domnodelist.php">\DOMNodeList</a>
public <a href="https://www.php.net/manual/en/domdocument.importnode.php">importNode</a> ( <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a> $node , bool $deep = false ) : <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|false
public <a href="https://www.php.net/manual/en/domdocument.normalizedocument.php">normalizeDocument</a> ( ) : void
public <a href="https://www.php.net/manual/en/domdocument.registernodeclass.php">registerNodeClass</a> ( string $baseClass , string|null $extendedClass ) : bool
public <a href="https://www.php.net/manual/en/domdocument.relaxngvalidate.php">relaxNGValidate</a> ( string $filename ) : bool
public <a href="https://www.php.net/manual/en/domdocument.relaxngvalidatesource.php">relaxNGValidateSource</a> ( string $source ) : bool
public <a href="https://www.php.net/manual/en/domdocument.savehtml.php">saveHTML</a> ( <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|null $node = null ) : string|false
public <a href="https://www.php.net/manual/en/domdocument.schemavalidate.php">schemaValidate</a> ( string $filename , int $flags = 0 ) : bool
public <a href="https://www.php.net/manual/en/domdocument.schemavalidatesource.php">schemaValidateSource</a> ( string $source , int $flags = 0 ) : bool
/* Methods inherited from <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a> */
public <a href="https://www.php.net/manual/en/domnode.appendchild.php">\DOMNode::appendChild</a> ( <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a> $node ) : <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|false
public <a href="https://www.php.net/manual/en/domnode.clonenode.php">\DOMNode::cloneNode</a> ( bool $deep = false ) : <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|false
public <a href="https://www.php.net/manual/en/domnode.getlineno.php">\DOMNode::getLineNo</a> ( ) : int
public <a href="https://www.php.net/manual/en/domnode.getnodepath.php">\DOMNode::getNodePath</a> ( ) : string|null
public <a href="https://www.php.net/manual/en/domnode.hasattributes.php">\DOMNode::hasAttributes</a> ( ) : bool
public <a href="https://www.php.net/manual/en/domnode.haschildnodes.php">\DOMNode::hasChildNodes</a> ( ) : bool
public <a href="https://www.php.net/manual/en/domnode.insertbefore.php">\DOMNode::insertBefore</a> ( <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a> $node , <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|null $child = null ) : <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|false
public <a href="https://www.php.net/manual/en/domnode.isdefaultnamespace.php">\DOMNode::isDefaultNamespace</a> ( string $namespace ) : bool
public <a href="https://www.php.net/manual/en/domnode.issamenode.php">\DOMNode::isSameNode</a> ( <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a> $otherNode ) : bool
public <a href="https://www.php.net/manual/en/domnode.issupported.php">\DOMNode::isSupported</a> ( string $feature , string $version ) : bool
public <a href="https://www.php.net/manual/en/domnode.lookupnamespaceuri.php">\DOMNode::lookupNamespaceUri</a> ( string $prefix ) : string
public <a href="https://www.php.net/manual/en/domnode.lookupprefix.php">\DOMNode::lookupPrefix</a> ( string $namespace ) : string|null
public <a href="https://www.php.net/manual/en/domnode.normalize.php">\DOMNode::normalize</a> ( ) : void
public <a href="https://www.php.net/manual/en/domnode.removechild.php">\DOMNode::removeChild</a> ( <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a> $child ) : <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|false
public <a href="https://www.php.net/manual/en/domnode.replacechild.php">\DOMNode::replaceChild</a> ( <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a> $node , <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a> $child ) : <a href="https://www.php.net/manual/en/class.domnode.php">\DOMNode</a>|false
}</code></pre>
## Constants ##
@ -78,7 +123,7 @@ Represents an entire HTML document; serves as the root of the document tree. Unl
<dd>Used when parsing. Specifies which mode the document was parsed in. One of the <a href="#page_Constants">predefined quirks mode constants</a>.</dd>
</dl>
The following properties inherited from `\DOMDocument` have no effect in `Mensbeam\HTML\Document`, so therefore are not listed in the schema above:
The following properties inherited from [`\DOMDocument`](https://www.php.net/manual/en/class.domdocument.php) have no effect in `Mensbeam\HTML\Document`, so therefore are not listed in the schema above:
* <a href="https://www.php.net/manual/en/class.domdocument.php#domdocument.props.actualencoding"><var>actualEncoding</var></a>
* <a href="https://www.php.net/manual/en/class.domdocument.php#domdocument.props.config"><var>config</var></a>

46
docs/en/030_Document_Object_Model/Walk/010_Walk-walk.md

@ -0,0 +1,46 @@
---
title: Walk::walk
---
Walk::walk — Output generator for walking down the DOM tree
## Description ##
```php
public Walk::walk ( <a href="https://www.php.net/manual/en/class.closure.php">\Closure</a> $filter ) : <a href="https://www.php.net/manual/en/class.generator.php">\Generator</a>
```
Creates a <a href="https://www.php.net/manual/en/class.generator.php">`\Generator`</a> object for walking down the DOM tree.
## Examples ##
**Example \#1 Print name of every Element**
```php
<?php
namespace MensBeam\HTML;
$dom = new Document();
$dom->loadHTML('<!DOCTYPE html><html><head><title>Ook!</title></head><body><h1>Eek</h1></body></html>');
$tree = $dom->walk(function($node) {
return ($node instanceof Element);
});
foreach ($tree as $t) {
echo "{$t->nodeName}\n";
}
?>
```
The above example will output something similar to:
```php
html
head
title
body
h1
```

11
docs/en/030_Document_Object_Model/Walk/index.md

@ -0,0 +1,11 @@
# The Walk trait #
## Introduction ##
Allows nodes to walk down the DOM via a [`\Generator`](https://www.php.net/manual/en/class.generator.php).
<pre><code class="php">trait MensBeam\HTML\Walk {
public <a href="Walk_walk.html">walk</a> ( <a href="https://www.php.net/manual/en/class.closure.php">\Closure</a> $filter ) : <a href="https://www.php.net/manual/en/class.generator.php">\Generator</a>
}</code></pre>

2
lib/DOM/Comment.php

@ -7,7 +7,7 @@ declare(strict_types=1);
namespace MensBeam\HTML;
class Comment extends \DOMComment {
use Moonwalk;
use C14N, Moonwalk;
public function __toString(): string {
# Append the literal string "<!--" (U+003C LESS-THAN SIGN, U+0021 EXCLAMATION

2
lib/DOM/Document.php

@ -7,7 +7,7 @@ declare(strict_types=1);
namespace MensBeam\HTML;
class Document extends \DOMDocument {
use EscapeString, Moonwalk, Serialize, Walk;
use C14N, EscapeString, Serialize, Walk;
// Quirks mode constants
public const NO_QUIRKS_MODE = 0;

2
lib/DOM/DocumentFragment.php

@ -7,7 +7,7 @@ declare(strict_types=1);
namespace MensBeam\HTML;
class DocumentFragment extends \DOMDocumentFragment {
use Moonwalk, Serialize;
use C14N, Moonwalk, Serialize;
public function __toString() {
return $this->serialize();

2
lib/DOM/Element.php

@ -7,7 +7,7 @@ declare(strict_types=1);
namespace MensBeam\HTML;
class Element extends \DOMElement {
use EscapeString, Moonwalk, Serialize, Walk;
use C14N, EscapeString, Moonwalk, Serialize, Walk;
protected $_classList;

2
lib/DOM/ProcessingInstruction.php

@ -7,7 +7,7 @@ declare(strict_types=1);
namespace MensBeam\HTML;
class ProcessingInstruction extends \DOMProcessingInstruction {
use Moonwalk;
use C14N, Moonwalk;
public function __toString(): string {
# Append the literal string "<?" (U+003C LESS-THAN SIGN, U+003F QUESTION MARK),

2
lib/DOM/Text.php

@ -7,7 +7,7 @@ declare(strict_types=1);
namespace MensBeam\HTML;
class Text extends \DOMText {
use EscapeString, Moonwalk;
use C14N, EscapeString, Moonwalk;
function __toString(): string {
# If the parent of current node is a style, script, xmp, iframe, noembed,

18
lib/DOM/traits/C14N.php

@ -0,0 +1,18 @@
<?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;
// Disables C14N in extended DOM classes
trait C14N {
public function C14N($exclusive = null, $with_comments = null, ?array $xpath = null, ?array $ns_prefixes = null): bool {
return false;
}
public function C14NFile($uri, $exclusive = null, $with_comments = null, ?array $xpath = null, ?array $ns_prefixes = null): bool {
return false;
}
}
Loading…
Cancel
Save