From 3c8cc210645c8ac15d21d494a18c46aa6f0a403e Mon Sep 17 00:00:00 2001 From: "J. King" Date: Sun, 26 Sep 2021 15:49:13 -0400 Subject: [PATCH] Remove DOM features and related --- RoboFile.php | 4 +- composer.json | 13 +- composer.lock | 2183 +---------------- docs/config.json | 15 - docs/en/010_About.md | 1 - docs/en/020_Installation.md | 8 - .../030_Document_Object_Model/010_Comment.md | 63 - .../010_Document/010_construct.md | 28 - .../010_Document/020_createEntityReference.md | 13 - .../010_Document/020_load.md | 46 - .../010_Document/020_loadHTML.md | 46 - .../010_Document/020_loadHTMLFile.md | 9 - .../010_Document/020_loadXML.md | 13 - .../010_Document/020_save.md | 43 - .../010_Document/020_saveHTMLFile.md | 9 - .../010_Document/020_saveXML.md | 13 - .../010_Document/020_validate.md | 13 - .../010_Document/020_xinclude.md | 13 - .../010_Document/index.md | 147 -- .../010_Element/010_getAttribute.md | 24 - .../010_Element/010_getAttributeNS.md | 26 - .../010_Element/index.md | 100 - .../ContainerNode/010_appendChild.md | 55 - .../ContainerNode/010_insertBefore.md | 40 - .../ContainerNode/index.md | 14 - .../LeafNode/010_appendChild.md | 13 - .../LeafNode/010_insertBefore.md | 13 - .../LeafNode/010_removeChild.md | 13 - .../LeafNode/010_replaceChild.md | 13 - .../LeafNode/index.md | 16 - .../Moonwalk/010_moonwalk.md | 43 - .../Moonwalk/index.md | 11 - .../Node/010_C14N.md | 13 - .../Node/010_C14NFile.md | 13 - .../030_Document_Object_Model/Node/index.md | 12 - .../Walk/010_walk.md | 45 - .../030_Document_Object_Model/Walk/index.md | 11 - docs/en/030_Document_Object_Model/index.md | 1 - docs/index.md | 1 - docs/theme/php/config.json | 9 - docs/theme/php/daux.min.js | 2 - docs/theme/php/php.css | 2 - docs/theme/src/php.scss | 324 --- lib/DOM/AbstractDocument.php | 12 - lib/DOM/Comment.php | 11 - lib/DOM/DOMException.php | 65 - lib/DOM/Document.php | 755 ------ lib/DOM/DocumentFragment.php | 11 - lib/DOM/Element.php | 313 --- lib/DOM/ElementMap.php | 70 - lib/DOM/ProcessingInstruction.php | 11 - lib/DOM/TemplateElement.php | 29 - lib/DOM/TokenList.php | 317 --- lib/DOM/traits/ContainerNode.php | 104 - lib/DOM/traits/DocumentOrElement.php | 57 - lib/DOM/traits/EscapeString.php | 56 - lib/DOM/traits/LeafNode.php | 31 - lib/DOM/traits/MagicProperties.php | 64 - lib/DOM/traits/Moonwalk.php | 40 - lib/DOM/traits/MoonwalkShallow.php | 27 - lib/DOM/traits/Node.php | 21 - lib/DOM/traits/ParentNode.php | 243 -- lib/DOM/traits/ToString.php | 15 - lib/DOM/traits/Walk.php | 31 - lib/DOM/traits/WalkShallow.php | 24 - lib/Parser.php | 31 +- lib/Parser/ActiveFormattingElementsList.php | 4 +- lib/Parser/CharacterReference.php | 2 +- lib/Parser/Charset.php | 2 +- lib/Parser/Data.php | 4 +- lib/Parser/Exception.php | 2 +- lib/Parser/LoopException.php | 2 +- lib/Parser/NameCoercion.php | 2 +- lib/Parser/NotImplementedException.php | 2 +- lib/Parser/OpenElementsStack.php | 4 +- lib/{DOM/Text.php => Parser/Output.php} | 10 +- lib/Parser/ParseError.php | 2 +- lib/Parser/ParseErrorDummy.php | 2 +- lib/Parser/ParseErrorEmitter.php | 2 +- lib/Parser/Stack.php | 2 +- lib/Parser/TemplateInsertionModesStack.php | 2 +- lib/Parser/Token.php | 2 +- lib/Parser/Tokenizer.php | 3 +- lib/Parser/TreeBuilder.php | 8 +- lib/Parser/ctype.php | 2 +- package.json | 17 - postcss.config.js | 17 - tests/bootstrap.php | 2 +- tests/cases/TestCharset.php | 8 +- tests/cases/TestDOM.php | 318 --- tests/cases/TestSerializer.php | 138 -- tests/cases/TestTokenizer.php | 49 +- tests/cases/TestTreeConstructor.php | 38 +- tests/cases/serializer/menbeam01.dat | 32 - tests/cases/serializer/menbeam02.dat | 34 - tests/cases/serializer/wpt01.dat | 913 ------- tests/phpunit.dist.xml | 6 - yarn.lock | 1158 --------- 98 files changed, 112 insertions(+), 8509 deletions(-) delete mode 100644 docs/config.json delete mode 100644 docs/en/010_About.md delete mode 100644 docs/en/020_Installation.md delete mode 100644 docs/en/030_Document_Object_Model/010_Comment.md delete mode 100644 docs/en/030_Document_Object_Model/010_Document/010_construct.md delete mode 100644 docs/en/030_Document_Object_Model/010_Document/020_createEntityReference.md delete mode 100644 docs/en/030_Document_Object_Model/010_Document/020_load.md delete mode 100644 docs/en/030_Document_Object_Model/010_Document/020_loadHTML.md delete mode 100644 docs/en/030_Document_Object_Model/010_Document/020_loadHTMLFile.md delete mode 100644 docs/en/030_Document_Object_Model/010_Document/020_loadXML.md delete mode 100644 docs/en/030_Document_Object_Model/010_Document/020_save.md delete mode 100644 docs/en/030_Document_Object_Model/010_Document/020_saveHTMLFile.md delete mode 100644 docs/en/030_Document_Object_Model/010_Document/020_saveXML.md delete mode 100644 docs/en/030_Document_Object_Model/010_Document/020_validate.md delete mode 100644 docs/en/030_Document_Object_Model/010_Document/020_xinclude.md delete mode 100644 docs/en/030_Document_Object_Model/010_Document/index.md delete mode 100644 docs/en/030_Document_Object_Model/010_Element/010_getAttribute.md delete mode 100644 docs/en/030_Document_Object_Model/010_Element/010_getAttributeNS.md delete mode 100644 docs/en/030_Document_Object_Model/010_Element/index.md delete mode 100644 docs/en/030_Document_Object_Model/ContainerNode/010_appendChild.md delete mode 100644 docs/en/030_Document_Object_Model/ContainerNode/010_insertBefore.md delete mode 100644 docs/en/030_Document_Object_Model/ContainerNode/index.md delete mode 100644 docs/en/030_Document_Object_Model/LeafNode/010_appendChild.md delete mode 100644 docs/en/030_Document_Object_Model/LeafNode/010_insertBefore.md delete mode 100644 docs/en/030_Document_Object_Model/LeafNode/010_removeChild.md delete mode 100644 docs/en/030_Document_Object_Model/LeafNode/010_replaceChild.md delete mode 100644 docs/en/030_Document_Object_Model/LeafNode/index.md delete mode 100644 docs/en/030_Document_Object_Model/Moonwalk/010_moonwalk.md delete mode 100644 docs/en/030_Document_Object_Model/Moonwalk/index.md delete mode 100644 docs/en/030_Document_Object_Model/Node/010_C14N.md delete mode 100644 docs/en/030_Document_Object_Model/Node/010_C14NFile.md delete mode 100644 docs/en/030_Document_Object_Model/Node/index.md delete mode 100644 docs/en/030_Document_Object_Model/Walk/010_walk.md delete mode 100644 docs/en/030_Document_Object_Model/Walk/index.md delete mode 100644 docs/en/030_Document_Object_Model/index.md delete mode 100644 docs/index.md delete mode 100644 docs/theme/php/config.json delete mode 100644 docs/theme/php/daux.min.js delete mode 100644 docs/theme/php/php.css delete mode 100644 docs/theme/src/php.scss delete mode 100644 lib/DOM/AbstractDocument.php delete mode 100644 lib/DOM/Comment.php delete mode 100644 lib/DOM/DOMException.php delete mode 100644 lib/DOM/Document.php delete mode 100644 lib/DOM/DocumentFragment.php delete mode 100644 lib/DOM/Element.php delete mode 100644 lib/DOM/ElementMap.php delete mode 100644 lib/DOM/ProcessingInstruction.php delete mode 100644 lib/DOM/TemplateElement.php delete mode 100644 lib/DOM/TokenList.php delete mode 100644 lib/DOM/traits/ContainerNode.php delete mode 100644 lib/DOM/traits/DocumentOrElement.php delete mode 100644 lib/DOM/traits/EscapeString.php delete mode 100644 lib/DOM/traits/LeafNode.php delete mode 100644 lib/DOM/traits/MagicProperties.php delete mode 100644 lib/DOM/traits/Moonwalk.php delete mode 100644 lib/DOM/traits/MoonwalkShallow.php delete mode 100644 lib/DOM/traits/Node.php delete mode 100644 lib/DOM/traits/ParentNode.php delete mode 100644 lib/DOM/traits/ToString.php delete mode 100644 lib/DOM/traits/Walk.php delete mode 100644 lib/DOM/traits/WalkShallow.php rename lib/{DOM/Text.php => Parser/Output.php} (56%) delete mode 100644 package.json delete mode 100644 postcss.config.js delete mode 100644 tests/cases/TestDOM.php delete mode 100644 tests/cases/TestSerializer.php delete mode 100644 tests/cases/serializer/menbeam01.dat delete mode 100644 tests/cases/serializer/menbeam02.dat delete mode 100644 tests/cases/serializer/wpt01.dat delete mode 100644 yarn.lock diff --git a/RoboFile.php b/RoboFile.php index 5b3b612..eaf3100 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -204,7 +204,7 @@ class RoboFile extends \Robo\Tasks { $template = <<<'FILE' =7.3", - "scrivo/highlight.php": "^9.15", - "symfony/console": "^4.4|^5.0", - "symfony/http-foundation": "^4.4|^5.0", - "symfony/mime": "^4.4|^5.0", - "symfony/polyfill-intl-icu": "^1.10", - "symfony/process": "^4.4|^5.0", - "webuni/front-matter": "^1.0.0" - }, - "replace": { - "justinwalsh/daux.io": "*" - }, - "require-dev": { - "mikey179/vfsstream": "^1.6" - }, - "suggest": { - "ext-intl": "Allows to translate the modified at date" - }, - "bin": [ - "bin/daux" - ], - "type": "project", - "autoload": { - "psr-4": { - "Todaymade\\Daux\\": "libs/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Stéphane Goetz", - "homepage": "http://onigoetz.ch/" - }, - { - "name": "Justin Walsh", - "homepage": "http://todaymade.com/" - } - ], - "description": "Documentation generator that uses a simple folder structure and Markdown files to create custom documentation on the fly", - "homepage": "https://dauxio.github.io/", - "keywords": [ - "docs", - "documentation", - "markdown", - "md" - ], - "support": { - "issues": "https://github.com/dauxio/daux.io/issues", - "source": "https://github.com/dauxio/daux.io/tree/0.16.2" - }, - "time": "2021-04-06T09:13:54+00:00" - }, - { - "name": "guzzlehttp/guzzle", - "version": "7.3.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "7008573787b430c1c1f650e3722d9bba59967628" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/7008573787b430c1c1f650e3722d9bba59967628", - "reference": "7008573787b430c1c1f650e3722d9bba59967628", - "shasum": "" - }, - "require": { - "ext-json": "*", - "guzzlehttp/promises": "^1.4", - "guzzlehttp/psr7": "^1.7 || ^2.0", - "php": "^7.2.5 || ^8.0", - "psr/http-client": "^1.0" - }, - "provide": { - "psr/http-client-implementation": "1.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "ext-curl": "*", - "php-http/client-integration-tests": "^3.0", - "phpunit/phpunit": "^8.5.5 || ^9.3.5", - "psr/log": "^1.1" - }, - "suggest": { - "ext-curl": "Required for CURL handler support", - "ext-intl": "Required for Internationalized Domain Name (IDN) support", - "psr/log": "Required for using the Log middleware" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "7.3-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "psr-18", - "psr-7", - "rest", - "web service" - ], - "support": { - "issues": "https://github.com/guzzle/guzzle/issues", - "source": "https://github.com/guzzle/guzzle/tree/7.3.0" - }, - "funding": [ - { - "url": "https://github.com/GrahamCampbell", - "type": "github" - }, - { - "url": "https://github.com/Nyholm", - "type": "github" - }, - { - "url": "https://github.com/alexeyshockov", - "type": "github" - }, - { - "url": "https://github.com/gmponos", - "type": "github" - } - ], - "time": "2021-03-23T11:33:13+00:00" - }, - { - "name": "guzzlehttp/promises", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/8e7d04f1f6450fef59366c399cfad4b9383aa30d", - "reference": "8e7d04f1f6450fef59366c399cfad4b9383aa30d", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "symfony/phpunit-bridge": "^4.4 || ^5.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ], - "support": { - "issues": "https://github.com/guzzle/promises/issues", - "source": "https://github.com/guzzle/promises/tree/1.4.1" - }, - "time": "2021-03-07T09:25:29+00:00" - }, - { - "name": "guzzlehttp/psr7", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "1dc8d9cba3897165e16d12bb13d813afb1eb3fe7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/1dc8d9cba3897165e16d12bb13d813afb1eb3fe7", - "reference": "1dc8d9cba3897165e16d12bb13d813afb1eb3fe7", - "shasum": "" - }, - "require": { - "php": "^7.2.5 || ^8.0", - "psr/http-factory": "^1.0", - "psr/http-message": "^1.0", - "ralouphie/getallheaders": "^3.0" - }, - "provide": { - "psr/http-factory-implementation": "1.0", - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "bamarni/composer-bin-plugin": "^1.4.1", - "http-interop/http-factory-tests": "^0.9", - "phpunit/phpunit": "^8.5.8 || ^9.3.10" - }, - "suggest": { - "laminas/laminas-httphandlerrunner": "Emit PSR-7 responses" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0-dev" - } - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - }, - { - "name": "Tobias Schultze", - "homepage": "https://github.com/Tobion" - }, - { - "name": "Márk Sági-Kazár", - "email": "mark.sagikazar@gmail.com", - "homepage": "https://sagikazarmark.hu" - } - ], - "description": "PSR-7 message implementation that also provides common utility methods", - "keywords": [ - "http", - "message", - "psr-7", - "request", - "response", - "stream", - "uri", - "url" - ], - "support": { - "issues": "https://github.com/guzzle/psr7/issues", - "source": "https://github.com/guzzle/psr7/tree/2.0.0" - }, - "time": "2021-06-30T20:03:07+00:00" - }, - { - "name": "league/commonmark", - "version": "1.6.6", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/commonmark.git", - "reference": "c4228d11e30d7493c6836d20872f9582d8ba6dcf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/commonmark/zipball/c4228d11e30d7493c6836d20872f9582d8ba6dcf", - "reference": "c4228d11e30d7493c6836d20872f9582d8ba6dcf", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "php": "^7.1 || ^8.0" - }, - "conflict": { - "scrutinizer/ocular": "1.7.*" - }, - "require-dev": { - "cebe/markdown": "~1.0", - "commonmark/commonmark.js": "0.29.2", - "erusev/parsedown": "~1.0", - "ext-json": "*", - "github/gfm": "0.29.0", - "michelf/php-markdown": "~1.4", - "mikehaertl/php-shellcommand": "^1.4", - "phpstan/phpstan": "^0.12.90", - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.2", - "scrutinizer/ocular": "^1.5", - "symfony/finder": "^4.2" - }, - "bin": [ - "bin/commonmark" - ], - "type": "library", - "autoload": { - "psr-4": { - "League\\CommonMark\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Colin O'Dell", - "email": "colinodell@gmail.com", - "homepage": "https://www.colinodell.com", - "role": "Lead Developer" - } - ], - "description": "Highly-extensible PHP Markdown parser which fully supports the CommonMark spec and Github-Flavored Markdown (GFM)", - "homepage": "https://commonmark.thephpleague.com", - "keywords": [ - "commonmark", - "flavored", - "gfm", - "github", - "github-flavored", - "markdown", - "md", - "parser" - ], - "support": { - "docs": "https://commonmark.thephpleague.com/", - "issues": "https://github.com/thephpleague/commonmark/issues", - "rss": "https://github.com/thephpleague/commonmark/releases.atom", - "source": "https://github.com/thephpleague/commonmark" - }, - "funding": [ - { - "url": "https://enjoy.gitstore.app/repositories/thephpleague/commonmark", - "type": "custom" - }, - { - "url": "https://www.colinodell.com/sponsor", - "type": "custom" - }, - { - "url": "https://www.paypal.me/colinpodell/10.00", - "type": "custom" - }, - { - "url": "https://github.com/colinodell", - "type": "github" - }, - { - "url": "https://www.patreon.com/colinodell", - "type": "patreon" - }, - { - "url": "https://tidelift.com/funding/github/packagist/league/commonmark", - "type": "tidelift" - } - ], - "time": "2021-07-17T17:13:23+00:00" - }, - { - "name": "league/plates", - "version": "v3.4.0", - "source": { - "type": "git", - "url": "https://github.com/thephpleague/plates.git", - "reference": "6d3ee31199b536a4e003b34a356ca20f6f75496a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/thephpleague/plates/zipball/6d3ee31199b536a4e003b34a356ca20f6f75496a", - "reference": "6d3ee31199b536a4e003b34a356ca20f6f75496a", - "shasum": "" - }, - "require": { - "php": "^7.0|^8.0" - }, - "require-dev": { - "mikey179/vfsstream": "^1.6", - "phpunit/phpunit": "^9.5", - "squizlabs/php_codesniffer": "^3.5" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.0-dev" - } - }, - "autoload": { - "psr-4": { - "League\\Plates\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jonathan Reinink", - "email": "jonathan@reinink.ca", - "role": "Developer" - }, - { - "name": "RJ Garcia", - "email": "ragboyjr@icloud.com", - "role": "Developer" - } - ], - "description": "Plates, the native PHP template system that's fast, easy to use and easy to extend.", - "homepage": "https://platesphp.com", - "keywords": [ - "league", - "package", - "templates", - "templating", - "views" - ], - "support": { - "issues": "https://github.com/thephpleague/plates/issues", - "source": "https://github.com/thephpleague/plates/tree/v3.4.0" - }, - "time": "2020-12-25T05:00:37+00:00" - }, { "name": "masterminds/html5", "version": "2.7.5", @@ -762,1710 +285,6 @@ "source": "https://github.com/Masterminds/html5-php/tree/2.7.5" }, "time": "2021-07-01T14:25:37+00:00" - }, - { - "name": "psr/container", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/8622567409010282b7aeebe4bb841fe98b58dcaf", - "reference": "8622567409010282b7aeebe4bb841fe98b58dcaf", - "shasum": "" - }, - "require": { - "php": ">=7.2.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "support": { - "issues": "https://github.com/php-fig/container/issues", - "source": "https://github.com/php-fig/container/tree/1.1.1" - }, - "time": "2021-03-05T17:36:06+00:00" - }, - { - "name": "psr/http-client", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-client.git", - "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", - "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", - "shasum": "" - }, - "require": { - "php": "^7.0 || ^8.0", - "psr/http-message": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Client\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP clients", - "homepage": "https://github.com/php-fig/http-client", - "keywords": [ - "http", - "http-client", - "psr", - "psr-18" - ], - "support": { - "source": "https://github.com/php-fig/http-client/tree/master" - }, - "time": "2020-06-29T06:28:15+00:00" - }, - { - "name": "psr/http-factory", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-factory.git", - "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", - "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", - "shasum": "" - }, - "require": { - "php": ">=7.0.0", - "psr/http-message": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interfaces for PSR-7 HTTP message factories", - "keywords": [ - "factory", - "http", - "message", - "psr", - "psr-17", - "psr-7", - "request", - "response" - ], - "support": { - "source": "https://github.com/php-fig/http-factory/tree/master" - }, - "time": "2019-04-30T12:38:16+00:00" - }, - { - "name": "ralouphie/getallheaders", - "version": "3.0.3", - "source": { - "type": "git", - "url": "https://github.com/ralouphie/getallheaders.git", - "reference": "120b605dfeb996808c31b6477290a714d356e822" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822", - "reference": "120b605dfeb996808c31b6477290a714d356e822", - "shasum": "" - }, - "require": { - "php": ">=5.6" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.1", - "phpunit/phpunit": "^5 || ^6.5" - }, - "type": "library", - "autoload": { - "files": [ - "src/getallheaders.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" - } - ], - "description": "A polyfill for getallheaders.", - "support": { - "issues": "https://github.com/ralouphie/getallheaders/issues", - "source": "https://github.com/ralouphie/getallheaders/tree/develop" - }, - "time": "2019-03-08T08:55:37+00:00" - }, - { - "name": "scrivo/highlight.php", - "version": "v9.18.1.7", - "source": { - "type": "git", - "url": "https://github.com/scrivo/highlight.php.git", - "reference": "05996fcc61e97978d76ca7d1ac14b65e7cd26f91" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/scrivo/highlight.php/zipball/05996fcc61e97978d76ca7d1ac14b65e7cd26f91", - "reference": "05996fcc61e97978d76ca7d1ac14b65e7cd26f91", - "shasum": "" - }, - "require": { - "ext-json": "*", - "ext-mbstring": "*", - "php": ">=5.4" - }, - "require-dev": { - "phpunit/phpunit": "^4.8|^5.7", - "sabberworm/php-css-parser": "^8.3", - "symfony/finder": "^2.8|^3.4", - "symfony/var-dumper": "^2.8|^3.4" - }, - "type": "library", - "autoload": { - "psr-0": { - "Highlight\\": "", - "HighlightUtilities\\": "" - }, - "files": [ - "HighlightUtilities/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Geert Bergman", - "homepage": "http://www.scrivo.org/", - "role": "Project Author" - }, - { - "name": "Vladimir Jimenez", - "homepage": "https://allejo.io", - "role": "Maintainer" - }, - { - "name": "Martin Folkers", - "homepage": "https://twobrain.io", - "role": "Contributor" - } - ], - "description": "Server side syntax highlighter that supports 185 languages. It's a PHP port of highlight.js", - "keywords": [ - "code", - "highlight", - "highlight.js", - "highlight.php", - "syntax" - ], - "support": { - "issues": "https://github.com/scrivo/highlight.php/issues", - "source": "https://github.com/scrivo/highlight.php" - }, - "funding": [ - { - "url": "https://github.com/allejo", - "type": "github" - } - ], - "time": "2021-07-09T00:30:39+00:00" - }, - { - "name": "symfony/console", - "version": "v5.3.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "8b1008344647462ae6ec57559da166c2bfa5e16a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/8b1008344647462ae6ec57559da166c2bfa5e16a", - "reference": "8b1008344647462ae6ec57559da166c2bfa5e16a", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php73": "^1.8", - "symfony/polyfill-php80": "^1.16", - "symfony/service-contracts": "^1.1|^2", - "symfony/string": "^5.1" - }, - "conflict": { - "psr/log": ">=3", - "symfony/dependency-injection": "<4.4", - "symfony/dotenv": "<5.1", - "symfony/event-dispatcher": "<4.4", - "symfony/lock": "<4.4", - "symfony/process": "<4.4" - }, - "provide": { - "psr/log-implementation": "1.0|2.0" - }, - "require-dev": { - "psr/log": "^1|^2", - "symfony/config": "^4.4|^5.0", - "symfony/dependency-injection": "^4.4|^5.0", - "symfony/event-dispatcher": "^4.4|^5.0", - "symfony/lock": "^4.4|^5.0", - "symfony/process": "^4.4|^5.0", - "symfony/var-dumper": "^4.4|^5.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/lock": "", - "symfony/process": "" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Eases the creation of beautiful and testable command line interfaces", - "homepage": "https://symfony.com", - "keywords": [ - "cli", - "command line", - "console", - "terminal" - ], - "support": { - "source": "https://github.com/symfony/console/tree/v5.3.7" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-08-25T20:02:16+00:00" - }, - { - "name": "symfony/deprecation-contracts", - "version": "v2.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/deprecation-contracts.git", - "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/5f38c8804a9e97d23e0c8d63341088cd8a22d627", - "reference": "5f38c8804a9e97d23e0c8d63341088cd8a22d627", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.4-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "files": [ - "function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A generic function and convention to trigger deprecation notices", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/deprecation-contracts/tree/v2.4.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-03-23T23:28:01+00:00" - }, - { - "name": "symfony/http-foundation", - "version": "v5.3.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-foundation.git", - "reference": "e36c8e5502b4f3f0190c675f1c1f1248a64f04e5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/e36c8e5502b4f3f0190c675f1c1f1248a64f04e5", - "reference": "e36c8e5502b4f3f0190c675f1c1f1248a64f04e5", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", - "symfony/polyfill-mbstring": "~1.1", - "symfony/polyfill-php80": "^1.16" - }, - "require-dev": { - "predis/predis": "~1.0", - "symfony/cache": "^4.4|^5.0", - "symfony/expression-language": "^4.4|^5.0", - "symfony/mime": "^4.4|^5.0" - }, - "suggest": { - "symfony/mime": "To use the file extension guesser" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpFoundation\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Defines an object-oriented layer for the HTTP specification", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/http-foundation/tree/v5.3.7" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-08-27T11:20:35+00:00" - }, - { - "name": "symfony/mime", - "version": "v5.3.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/mime.git", - "reference": "ae887cb3b044658676129f5e97aeb7e9eb69c2d8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/mime/zipball/ae887cb3b044658676129f5e97aeb7e9eb69c2d8", - "reference": "ae887cb3b044658676129f5e97aeb7e9eb69c2d8", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", - "symfony/polyfill-intl-idn": "^1.10", - "symfony/polyfill-mbstring": "^1.0", - "symfony/polyfill-php80": "^1.16" - }, - "conflict": { - "egulias/email-validator": "~3.0.0", - "phpdocumentor/reflection-docblock": "<3.2.2", - "phpdocumentor/type-resolver": "<1.4.0", - "symfony/mailer": "<4.4" - }, - "require-dev": { - "egulias/email-validator": "^2.1.10|^3.1", - "phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0", - "symfony/dependency-injection": "^4.4|^5.0", - "symfony/property-access": "^4.4|^5.1", - "symfony/property-info": "^4.4|^5.1", - "symfony/serializer": "^5.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Mime\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Allows manipulating MIME messages", - "homepage": "https://symfony.com", - "keywords": [ - "mime", - "mime-type" - ], - "support": { - "source": "https://github.com/symfony/mime/tree/v5.3.7" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-08-20T11:40:01+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.23.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/46cd95797e9df938fdd2b03693b5fca5e64b01ce", - "reference": "46cd95797e9df938fdd2b03693b5fca5e64b01ce", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.23.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-02-19T12:13:01+00:00" - }, - { - "name": "symfony/polyfill-intl-grapheme", - "version": "v1.23.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "16880ba9c5ebe3642d1995ab866db29270b36535" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/16880ba9c5ebe3642d1995ab866db29270b36535", - "reference": "16880ba9c5ebe3642d1995ab866db29270b36535", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Grapheme\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's grapheme_* functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "grapheme", - "intl", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.23.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-05-27T12:26:48+00:00" - }, - { - "name": "symfony/polyfill-intl-icu", - "version": "v1.23.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-icu.git", - "reference": "4a80a521d6176870b6445cfb469c130f9cae1dda" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/4a80a521d6176870b6445cfb469c130f9cae1dda", - "reference": "4a80a521d6176870b6445cfb469c130f9cae1dda", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance and support of other locales than \"en\"" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Intl\\Icu\\": "" - }, - "classmap": [ - "Resources/stubs" - ], - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's ICU-related data and classes", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "icu", - "intl", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-icu/tree/v1.23.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-05-24T10:04:56+00:00" - }, - { - "name": "symfony/polyfill-intl-idn", - "version": "v1.23.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "65bd267525e82759e7d8c4e8ceea44f398838e65" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/65bd267525e82759e7d8c4e8ceea44f398838e65", - "reference": "65bd267525e82759e7d8c4e8ceea44f398838e65", - "shasum": "" - }, - "require": { - "php": ">=7.1", - "symfony/polyfill-intl-normalizer": "^1.10", - "symfony/polyfill-php72": "^1.10" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Idn\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Laurent Bassin", - "email": "laurent@bassin.info" - }, - { - "name": "Trevor Rowbotham", - "email": "trevor.rowbotham@pm.me" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "idn", - "intl", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.23.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-05-27T09:27:20+00:00" - }, - { - "name": "symfony/polyfill-intl-normalizer", - "version": "v1.23.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/8590a5f561694770bdcd3f9b5c69dde6945028e8", - "reference": "8590a5f561694770bdcd3f9b5c69dde6945028e8", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's Normalizer class and related functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "intl", - "normalizer", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.23.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-02-19T12:13:01+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.23.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9174a3d80210dca8daa7f31fec659150bbeabfc6", - "reference": "9174a3d80210dca8daa7f31fec659150bbeabfc6", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.23.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-05-27T12:26:48+00:00" - }, - { - "name": "symfony/polyfill-php72", - "version": "v1.23.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "9a142215a36a3888e30d0a9eeea9766764e96976" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/9a142215a36a3888e30d0a9eeea9766764e96976", - "reference": "9a142215a36a3888e30d0a9eeea9766764e96976", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php72\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.23.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-05-27T09:17:38+00:00" - }, - { - "name": "symfony/polyfill-php73", - "version": "v1.23.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php73.git", - "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/fba8933c384d6476ab14fb7b8526e5287ca7e010", - "reference": "fba8933c384d6476ab14fb7b8526e5287ca7e010", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php73\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php73/tree/v1.23.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-02-19T12:13:01+00:00" - }, - { - "name": "symfony/polyfill-php80", - "version": "v1.23.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/1100343ed1a92e3a38f9ae122fc0eb21602547be", - "reference": "1100343ed1a92e3a38f9ae122fc0eb21602547be", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "1.23-dev" - }, - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Php80\\": "" - }, - "files": [ - "bootstrap.php" - ], - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Ion Bazan", - "email": "ion.bazan@gmail.com" - }, - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.23.1" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-07-28T13:41:28+00:00" - }, - { - "name": "symfony/process", - "version": "v5.3.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "38f26c7d6ed535217ea393e05634cb0b244a1967" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/38f26c7d6ed535217ea393e05634cb0b244a1967", - "reference": "38f26c7d6ed535217ea393e05634cb0b244a1967", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-php80": "^1.16" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Executes commands in sub-processes", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/process/tree/v5.3.7" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-08-04T21:20:46+00:00" - }, - { - "name": "symfony/service-contracts", - "version": "v2.4.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/service-contracts.git", - "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/service-contracts/zipball/f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", - "reference": "f040a30e04b57fbcc9c6cbcf4dbaa96bd318b9bb", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "psr/container": "^1.1" - }, - "suggest": { - "symfony/service-implementation": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-main": "2.4-dev" - }, - "thanks": { - "name": "symfony/contracts", - "url": "https://github.com/symfony/contracts" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\Service\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Generic abstractions related to writing services", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "support": { - "source": "https://github.com/symfony/service-contracts/tree/v2.4.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-04-01T10:43:52+00:00" - }, - { - "name": "symfony/string", - "version": "v5.3.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/string.git", - "reference": "8d224396e28d30f81969f083a58763b8b9ceb0a5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/8d224396e28d30f81969f083a58763b8b9ceb0a5", - "reference": "8d224396e28d30f81969f083a58763b8b9ceb0a5", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-intl-grapheme": "~1.0", - "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0", - "symfony/polyfill-php80": "~1.15" - }, - "require-dev": { - "symfony/error-handler": "^4.4|^5.0", - "symfony/http-client": "^4.4|^5.0", - "symfony/translation-contracts": "^1.1|^2", - "symfony/var-exporter": "^4.4|^5.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\String\\": "" - }, - "files": [ - "Resources/functions.php" - ], - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", - "homepage": "https://symfony.com", - "keywords": [ - "grapheme", - "i18n", - "string", - "unicode", - "utf-8", - "utf8" - ], - "support": { - "source": "https://github.com/symfony/string/tree/v5.3.7" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-08-26T08:00:08+00:00" - }, - { - "name": "symfony/yaml", - "version": "v5.3.6", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "4500fe63dc9c6ffc32d3b1cb0448c329f9c814b7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/4500fe63dc9c6ffc32d3b1cb0448c329f9c814b7", - "reference": "4500fe63dc9c6ffc32d3b1cb0448c329f9c814b7", - "shasum": "" - }, - "require": { - "php": ">=7.2.5", - "symfony/deprecation-contracts": "^2.1", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/console": "<4.4" - }, - "require-dev": { - "symfony/console": "^4.4|^5.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "bin": [ - "Resources/bin/yaml-lint" - ], - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Loads and dumps YAML files", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/yaml/tree/v5.3.6" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2021-07-29T06:20:01+00:00" - }, - { - "name": "webuni/front-matter", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/webuni/front-matter.git", - "reference": "334e3532546d62d28164580208edef1c5c853024" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webuni/front-matter/zipball/334e3532546d62d28164580208edef1c5c853024", - "reference": "334e3532546d62d28164580208edef1c5c853024", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "symfony/yaml": "^3.4.31 || ^4.3.4 || ^5.0" - }, - "require-dev": { - "ext-json": "*", - "league/commonmark": "^1.4", - "mthaml/mthaml": "^1.3", - "nette/neon": "^2.2 || ^3.0", - "twig/twig": "^3.0", - "yosymfony/toml": "^1.0" - }, - "suggest": { - "nette/neon": "If you want to use NEON as front matter", - "yosymfony/toml": "If you want to use TOML as front matter" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "psr-4": { - "Webuni\\FrontMatter\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Martin Hasoň", - "email": "martin.hason@gmail.com", - "homepage": "https://www.martinhason.cz" - }, - { - "name": "Webuni s.r.o.", - "homepage": "https://www.webuni.cz" - } - ], - "description": "Front matter parser and dumper for PHP", - "homepage": "https://github.com/webuni/front-matter", - "keywords": [ - "commonmark", - "front-matter", - "json", - "neon", - "toml", - "yaml" - ], - "support": { - "issues": "https://github.com/webuni/front-matter/issues", - "source": "https://github.com/webuni/front-matter/tree/1.3.0" - }, - "time": "2021-06-14T20:44:30+00:00" } ], "aliases": [], diff --git a/docs/config.json b/docs/config.json deleted file mode 100644 index 567368b..0000000 --- a/docs/config.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "title": "HTML", - "tagline": "Tools for parsing and printing HTML5 documents and fragments.", - "author": "Dustin Wilson", - "languages": { - "en": "English" - }, - "themes_directory": "docs/theme", - "html": { - "theme":"php", - "float": false, - "toggle_code": false, - "search": false - } -} diff --git a/docs/en/010_About.md b/docs/en/010_About.md deleted file mode 100644 index 57792e0..0000000 --- a/docs/en/010_About.md +++ /dev/null @@ -1 +0,0 @@ -HTML is a library which provides tools for parsing and printing of HTML5 documents and fragments. Unlike PHP's DOM and other similar libraries the goal of the project is to parse HTML as accurate to the specification as possible given the limitations of PHP's DOM and of the uses of the library. Therefore, there is no scripting in this implementation, and there likely never will be. \ No newline at end of file diff --git a/docs/en/020_Installation.md b/docs/en/020_Installation.md deleted file mode 100644 index a566886..0000000 --- a/docs/en/020_Installation.md +++ /dev/null @@ -1,8 +0,0 @@ -We try to make the installation of the MensBeam HTML library as easy and straightforward as possible. - -## Requirements ## - -HTML intentionally has few requirements. It only requires PHP 7.1.0 or later with the [dom](http://php.net/manual/en/book.dom.php) extension installed. It is recommended to install the [ctype](https://www.php.net/manual/en/book.ctype.php) extension for performance improvements, but it is not required. - -TODO: Add Installation instructions once there are releases and a package is available on Packagist. - diff --git a/docs/en/030_Document_Object_Model/010_Comment.md b/docs/en/030_Document_Object_Model/010_Comment.md deleted file mode 100644 index 489c3ef..0000000 --- a/docs/en/030_Document_Object_Model/010_Comment.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -title: Comment ---- - -# The Comment Class # - -## Introduction ## - -

Info Only new methods and methods which make outward-facing changes from \DOMComment will be documented here, otherwise they will be linked back to PHP's documentation.

- -## Class Synopsis ## - -
MensBeam\HTML\Comment extends \DOMComment {
-
-    use LeafNode, Moonwalk;
-
-    /* Inherited properties */
-    public string $data ;
-    public readonly int $length ;
-    public readonly string $nodeName ;
-    public string $nodeValue ;
-    public readonly int $nodeType ;
-    public readonly \DOMNode|null $parentNode ;
-    public readonly \DOMNodeList $childNodes ;
-    public readonly \DOMNode|null $firstChild ;
-    public readonly \DOMNode|null $lastChild ;
-    public readonly \DOMNode|null $previousSibling ;
-    public readonly \DOMNode|null $nextSibling ;
-    public readonly \DOMNamedNodeMap|null $attributes ;
-    public readonly Document|null $ownerDocument ;
-    public readonly string|null $namespaceURI ;
-    public string $prefix ;
-    public readonly string $localName ;
-    public readonly string|null $baseURI ;
-    public string $textContent ;
-
-    /* Trait Methods */
-    public LeafNode::appendChild ( \DOMNode $node ) : DOMException;
-    public Node::C14N ( bool $exclusive = false , bool $withComments = false , null $xpath = null , null $nsPrefixes = null ) : false
-    public Node::C14NFile ( string $uri , bool $exclusive = false , bool $withComments = false , null $xpath = null , null $nsPrefixes = null ) : false
-    public LeafNode::insertBefore ( \DOMNode $node , \DOMNode|null $child = null ) : DOMException
-    public Moonwalk::moonwalk ( \Closure|null $filter = null ) : \Generator
-    public LeafNode::removeChild ( \DOMNode $child ) : DOMException
-    public LeafNode::replaceChild ( \DOMNode $node , \DOMNode $child ) : DOMException
-
-    /* Magic Methods */
-    public __toString() : string
-
-    /* Inherited Methods */
-    public __construct ( string $data = "" )
-    public \DOMNode::cloneNode ( bool $deep = false ) : \DOMNode|false
-    public \DOMNode::getLineNo ( ) : int
-    public \DOMNode::getNodePath ( ) : string|null
-    public \DOMNode::hasAttributes ( ) : bool
-    public \DOMNode::hasChildNodes ( ) : bool
-    public \DOMNode::isDefaultNamespace ( string $namespace ) : bool
-    public \DOMNode::isSameNode ( \DOMNode $otherNode ) : bool
-    public \DOMNode::isSupported ( string $feature , string $version ) : bool
-    public \DOMNode::lookupNamespaceUri ( string $prefix ) : string
-    public \DOMNode::lookupPrefix ( string $namespace ) : string|null
-    public \DOMNode::normalize ( ) : void
-
-}
\ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Document/010_construct.md b/docs/en/030_Document_Object_Model/010_Document/010_construct.md deleted file mode 100644 index 4791f2e..0000000 --- a/docs/en/030_Document_Object_Model/010_Document/010_construct.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -title: Document::__construct ---- - -Document::__construct — Creates a new Document object - -## Description ## - -```php -public Document::__construct ( ) -``` - -Creates a new Document object. - -## Examples ## - -**Example \#1 Creating a new Document** - -```php - -``` \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Document/020_createEntityReference.md b/docs/en/030_Document_Object_Model/010_Document/020_createEntityReference.md deleted file mode 100644 index ecb8b16..0000000 --- a/docs/en/030_Document_Object_Model/010_Document/020_createEntityReference.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Document::createEntityReference ---- - -Document::createEntityReference — **DISABLED** - -## Description ## - -```php -public Document::createEntityReference ( string $name ) : false -``` - -This function has been disabled and will always return `false`. Documented to show difference from [`\DOMDocument`](https://www.php.net/manual/en/class.domdocument.php). DOM4 does not have entity references or entity nodes. \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Document/020_load.md b/docs/en/030_Document_Object_Model/010_Document/020_load.md deleted file mode 100644 index 619f745..0000000 --- a/docs/en/030_Document_Object_Model/010_Document/020_load.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: Document::load ---- - -Document::load — Load HTML from a file - -## Description ## - -```php -public Document::load ( string $filename , null $options = null , string|null $encodingOrContentType = null ) : bool -``` - -Loads an HTML document from a file. - -## Parameters ## - -
-
filename
-
The path to the HTML document.
- -
options
-
Always null. Was used for option constants in \DOMDocument.
- -
encodingOrContentType
-
The encoding of the document that is being loaded. If not specified it will be determined automatically.
-
- -## Return Values ## - -Returns true on success or false on failure. - -## Examples ## - -**Example \#1 Creating a Document** - -```php -load('ook.html'); -echo $dom; - -?> -``` \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Document/020_loadHTML.md b/docs/en/030_Document_Object_Model/010_Document/020_loadHTML.md deleted file mode 100644 index 03bb904..0000000 --- a/docs/en/030_Document_Object_Model/010_Document/020_loadHTML.md +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: Document::loadHTML ---- - -Document::loadHTML — Load HTML from a string - -## Description ## - -```php -public Document::loadHTML ( string $source , null $options = null , string|null $encodingOrContentType = null ) : bool -``` - -The function parses the HTML contained in the string source. - -## Parameters ## - -
-
source
-
The HTML string.
- -
options
-
Always null. Was used for option constants in \DOMDocument.
- -
encodingOrContentType
-
The encoding of the document that is being loaded. If not specified it will be determined automatically.
-
- -## Return Values ## - -Returns true on success or false on failure. - -## Examples ## - -**Example \#1 Creating a Document** - -```php -loadHTML('Ook!

Eek

'); -echo $dom; - -?> -``` \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Document/020_loadHTMLFile.md b/docs/en/030_Document_Object_Model/010_Document/020_loadHTMLFile.md deleted file mode 100644 index 28f9a3f..0000000 --- a/docs/en/030_Document_Object_Model/010_Document/020_loadHTMLFile.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: Document::loadHTMLFile ---- - -Document::loadHTMLFile — Alias of Document::load() - -## Description ## - -This function is an alias of Document::load(). \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Document/020_loadXML.md b/docs/en/030_Document_Object_Model/010_Document/020_loadXML.md deleted file mode 100644 index ec63b89..0000000 --- a/docs/en/030_Document_Object_Model/010_Document/020_loadXML.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Document::loadXML ---- - -Document::loadXML — **DISABLED** - -## Description ## - -```php -public Document::loadXML ( string $source , null $options = null ) : false -``` - -This function has been disabled and will always return `false`. Documented to show difference from [`\DOMDocument`](https://www.php.net/manual/en/class.domdocument.php). \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Document/020_save.md b/docs/en/030_Document_Object_Model/010_Document/020_save.md deleted file mode 100644 index f72bd03..0000000 --- a/docs/en/030_Document_Object_Model/010_Document/020_save.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: Document::save ---- - -Document::save — Serializes the DOM tree into a file - -## Description ## - -```php -public Document::save ( string $filename , null $options = null ) : int|false -``` - -Creates an HTML document from the DOM representation. - -## Parameters ## - -
-
filename
-
The path to the saved HTML document
- -
options
-
Always null. Was used for option constants in \DOMDocument.
-
- -## Return Values ## - -Returns the number of bytes written or false on failure. - -## Examples ## - -**Example \#1 Saving a DOM tree into a file** - -```php -loadHTML('Ook!

Eek

'); -echo 'Wrote: ' . $dom->save('/tmp/test.html') . ' bytes'; // Wrote: 85 bytes - -?> -``` \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Document/020_saveHTMLFile.md b/docs/en/030_Document_Object_Model/010_Document/020_saveHTMLFile.md deleted file mode 100644 index 9aa0a5e..0000000 --- a/docs/en/030_Document_Object_Model/010_Document/020_saveHTMLFile.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -title: Document::saveHTMLFile ---- - -Document::saveHTMLFile — Alias of Document::save() - -## Description ## - -This function is an alias of Document::save(). \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Document/020_saveXML.md b/docs/en/030_Document_Object_Model/010_Document/020_saveXML.md deleted file mode 100644 index 1267302..0000000 --- a/docs/en/030_Document_Object_Model/010_Document/020_saveXML.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Document::saveXML ---- - -Document::saveXML — **DISABLED** - -## Description ## - -```php -public Document::saveXML ( DOMNode|null $node = null , null $options = null ) : false -``` - -This function has been disabled and will always return `false`. Documented to show difference from [`\DOMDocument`](https://www.php.net/manual/en/class.domdocument.php). \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Document/020_validate.md b/docs/en/030_Document_Object_Model/010_Document/020_validate.md deleted file mode 100644 index da7b908..0000000 --- a/docs/en/030_Document_Object_Model/010_Document/020_validate.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Document::validate ---- - -Document::validate — **DISABLED** - -## Description ## - -```php -public Document::validate ( ) : true -``` - -This function has been disabled and will always return `true`. Documented to show difference from [`\DOMDocument`](https://www.php.net/manual/en/class.domdocument.php). \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Document/020_xinclude.md b/docs/en/030_Document_Object_Model/010_Document/020_xinclude.md deleted file mode 100644 index 523bf74..0000000 --- a/docs/en/030_Document_Object_Model/010_Document/020_xinclude.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Document::xinclude ---- - -Document::xinclude — **DISABLED** - -## Description ## - -```php -public Document::xinclude ( null $options = null ) : false -``` - -This function has been disabled and will always return `false`. Documented to show difference from [`\DOMDocument`](https://www.php.net/manual/en/class.domdocument.php). \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Document/index.md b/docs/en/030_Document_Object_Model/010_Document/index.md deleted file mode 100644 index e5f0c69..0000000 --- a/docs/en/030_Document_Object_Model/010_Document/index.md +++ /dev/null @@ -1,147 +0,0 @@ ---- -title: Document ---- - -# The Document Class # - -## Introduction ## - -Represents an entire HTML document; serves as the root of the document tree. Unlike the PHP [`\DOMDocument`](https://www.php.net/manual/en/class.domdocument.php) class in which it inherits from it cannot be used to represent an XML document. It is strictly used to represent HTML. - -

Note: Only new methods and methods which make outward-facing changes from \DOMDocument will be documented here, otherwise they will be linked back to PHP's documentation.

- -## Class Synopsis ## - -
MensBeam\HTML\Document extends \DOMDocument {
-
-    use ContainerNode, Walk;
-
-    /* Constants */
-    public const NO_QUIRKS_MODE = 0 ;
-    public const QUIRKS_MODE = 1 ;
-    public const LIMITED_QUIRKS_MODE = 2 ;
-
-    /* Properties */
-    public Element|null $body = null ;
-    public string|null $documentEncoding = null ;
-    public int $quirksMode = 0 ;
-
-    /* Inherited properties */
-    public readonly \DOMNamedNodeMap|null $attributes ;
-    public readonly string|null $baseURI ;
-    public readonly \DOMNodeList $childNodes ;
-    public readonly DocumentType $doctype ;
-    public readonly Element $documentElement ;
-    public string|null $documentURI ;
-    public readonly \DOMNode|null $firstChild ;
-    public readonly \DOMImplementation $implementation ;
-    public readonly \DOMNode|null $lastChild ;
-    public readonly string $localName ;
-    public readonly string|null $namespaceURI ;
-    public readonly \DOMNode|null $nextSibling ;
-    public readonly string $nodeName ;
-    public string $nodeValue ;
-    public readonly int $nodeType ;
-    public readonly Document|null $ownerDocument ;
-    public readonly \DOMNode|null $parentNode ;
-    public string $prefix ;
-    public readonly \DOMNode|null $previousSibling ;
-    public string $textContent ;
-
-    /* Methods */
-    public __construct ( )
-    public createEntityReference ( string $name ) : false
-    public load ( string $filename , null $options = null , string|null $encodingOrContentType = null ) : bool
-    public loadHTML ( string $source , null $options = null , string|null $encodingOrContentType = null ) : bool
-    public loadHTMLFile ( string $filename , null $options = null , string|null $encodingOrContentType = null ) : bool
-    public loadXML ( string $source , null $options = null ) : false
-    public save ( string $filename , null $options = null ) : int|false
-    public saveHTMLFile ( string $filename , null $options = null ) : int|false
-    public saveXML ( \DOMNode|null $node = null , null $options = null ) : false
-    public validate ( ) : true
-    public xinclude ( null $options = null ) : false
-
-    /* Trait Methods */
-    public ContainerNode::appendChild ( \DOMNode $node ) : \DOMNode|false
-    public Node::C14N ( bool $exclusive = false , bool $withComments = false , null $xpath = null , null $nsPrefixes = null ) : false
-    public Node::C14NFile ( string $uri , bool $exclusive = false , bool $withComments = false , null $xpath = null , null $nsPrefixes = null ) : false
-    public ContainerNode::insertBefore ( \DOMNode $node , \DOMNode|null $child = null ) : \DOMNode|false
-    public Walk::walk ( \Closure|null $filter = null ) : \Generator
-
-    /* Magic Methods */
-    public __toString() : string
-
-    /* Inherited methods */
-    public \DOMNode::cloneNode ( bool $deep = false ) : \DOMNode|false
-    public \DOMDocument::createAttribute ( string $localName ) : \DOMAttr|false
-    public \DOMDocument::createAttributeNS ( string|null $namespace , string $qualifiedName ) : \DOMAttr|false
-    public \DOMDocument::createCDATASection ( string $data ) : \DOMCdataSection|false
-    public \DOMDocument::createComment ( string $data ) : Comment|false
-    public \DOMDocument::createDocumentFragment ( ) : DocumentFragment|false
-    public \DOMDocument::createElement ( string $localName , string $value = "" ) : Element|false
-    public \DOMDocument::createElementNS ( string|null $namespace , string $qualifiedName , string $value = "" ) : Element|false
-    public \DOMDocument::createProcessingInstruction ( string $target , string $data = "" ) : ProcessingInstruction|false
-    public \DOMDocument::createTextNode ( string $data ) : Text|false
-    public \DOMDocument::getElementById ( string $elementId ) : Element|null
-    public \DOMDocument:getElementsByTagName ( string $qualifiedName ) : \DOMNodeList
-    public getElementsByTagNameNS ( string $namespace , string $localName ) : \DOMNodeList
-    public \DOMNode::getLineNo ( ) : int
-    public \DOMNode::getNodePath ( ) : string|null
-    public \DOMNode::hasAttributes ( ) : bool
-    public \DOMNode::hasChildNodes ( ) : bool
-    public \DOMDocument::importNode ( \DOMNode $node , bool $deep = false ) : \DOMNode|false
-    public \DOMNode::isDefaultNamespace ( string $namespace ) : bool
-    public \DOMNode::isSameNode ( \DOMNode $otherNode ) : bool
-    public \DOMNode::isSupported ( string $feature , string $version ) : bool
-    public \DOMNode::lookupNamespaceUri ( string $prefix ) : string
-    public \DOMNode::lookupPrefix ( string $namespace ) : string|null
-    public \DOMNode::normalize ( ) : void
-    public \DOMDocument::normalizeDocument ( ) : void
-    public \DOMDocument::registerNodeClass ( string $baseClass , string|null $extendedClass ) : bool
-    public \DOMDocument::relaxNGValidate ( string $filename ) : bool
-    public \DOMDocument::relaxNGValidateSource ( string $source ) : bool
-    public \DOMNode::removeChild ( \DOMNode $child ) : \DOMNode|false
-    public \DOMNode::replaceChild ( \DOMNode $node , \DOMNode $child ) : \DOMNode|false
-    public \DOMDocument::saveHTML ( \DOMNode|null $node = null ) : string|false
-    public \DOMDocument::schemaValidate ( string $filename , int $flags = 0 ) : bool
-    public \DOMDocument::schemaValidateSource ( string $source , int $flags = 0 ) : bool
-}
- -## Constants ## - -| Constant | Value | Description | -| ----------------------------------------------------- | ----- | ------------------------------------- | -| MensBeam\HTML\Document::NO_QUIRKS_MODE | 0 | Document not in quirks mode | -| MensBeam\HTML\Document::QUIRKS_MODE | 1 | Document is in quirks mode | -| MensBeam\HTML\Document::LIMITEDQUIRKS_MODE | 2 | Document is in limited quirks mode | - -## Properties ## - -
-
body
-
Represents the body or frameset node of the current document, or null if no such element exists.
- -
documentEncoding
-
Encoding of the document, as specified when parsing or when determining encoding type. Use this instead of \DOMDocument::encoding.
- -
quirksMode
-
Used when parsing. Specifies which mode the document was parsed in. One of the predefined quirks mode constants.
-
- -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: - -* actualEncoding -* config -* encoding -* formatOutput -* preserveWhiteSpace -* recover -* resolveExternals -* standalone -* strictErrorChecking -* substituteEntities -* validateOnParse -* version -* xmlEncoding -* xmlStandalone -* xmlVersion \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Element/010_getAttribute.md b/docs/en/030_Document_Object_Model/010_Element/010_getAttribute.md deleted file mode 100644 index 2d2fb64..0000000 --- a/docs/en/030_Document_Object_Model/010_Element/010_getAttribute.md +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: Element::getAttribute ---- - -Element::getAttribute — Returns value of attribute - -## Description ## - -```php -public Element::getAttribute ( string $qualifiedName ) : string|null -``` - -Gets the value of the attribute with name `qualifiedName` for the current node. - -## Parameters ## - -
-
qualifiedName
-
The name of the attribute.
-
- -## Return Values ## - -Returns a string on success or null if no attribute with the given `qualifiedName` is found. `\DOMElement::getAttribute` returns an empty string on failure which is incorrect in newer versions of the DOM. \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Element/010_getAttributeNS.md b/docs/en/030_Document_Object_Model/010_Element/010_getAttributeNS.md deleted file mode 100644 index 4bba473..0000000 --- a/docs/en/030_Document_Object_Model/010_Element/010_getAttributeNS.md +++ /dev/null @@ -1,26 +0,0 @@ ---- -title: Element::getAttributeNS ---- - -Element::getAttributeNS — Returns value of attribute - -## Description ## - -```php -public Element::getAttribute ( string|null $namespace , string $localName ) : string|null -``` - -Gets the value of the attribute in namespace `namespace` with local name `localName` for the current node. - -## Parameters ## - -
-
namespace
-
The namespace URI.
-
localName
-
The local name of the attribute.
-
- -## Return Values ## - -Returns a string on success or null if no attribute with the given `localName` and `namespace` is found. `\DOMElement::getAttribute` returns an empty string on failure which is incorrect in newer versions of the DOM. \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/010_Element/index.md b/docs/en/030_Document_Object_Model/010_Element/index.md deleted file mode 100644 index 8111dcc..0000000 --- a/docs/en/030_Document_Object_Model/010_Element/index.md +++ /dev/null @@ -1,100 +0,0 @@ ---- -title: Element ---- - -# The Element Class # - -## Introduction ## - -

Note: Only new methods and methods which make outward-facing changes from \DOMElement will be documented here, otherwise they will be linked back to PHP's documentation.

- -## Class Synopsis ## - -
MensBeam\HTML\Element extends \DOMElement {
-
-    use ContainerNode, Moonwalk, Walk;
-
-    /* Properties */
-    public readonly NodeList|null $classList ;
-    public string $innerHTML ;
-    public string $outerHTML ;
-
-    /* Inherited properties */
-    public readonly string $nodeName ;
-    public string $nodeValue ;
-    public readonly int $nodeType ;
-    public readonly \DOMNode|null $parentNode ;
-    public readonly \DOMNodeList $childNodes ;
-    public readonly \DOMNode|null $firstChild ;
-    public readonly \DOMNode|null $lastChild ;
-    public readonly \DOMNode|null $previousSibling ;
-    public readonly \DOMNode|null $nextSibling ;
-    public readonly \DOMNamedNodeMap|null $attributes ;
-    public readonly Document|null $ownerDocument ;
-    public readonly string|null $namespaceURI ;
-    public string $prefix ;
-    public readonly string $localName ;
-    public readonly string|null $baseURI ;
-    public string $textContent ;
-
-    /* Methods */
-    public getAttribute ( string $qualifiedName ) : string|null
-    public getAttributeNS ( string|null $namespace , string $localName ) : string|null
-
-    /* Trait Methods */
-    public ContainerNode::appendChild ( \DOMNode $node ) : \DOMNode|false
-    public Node::C14N ( bool $exclusive = false , bool $withComments = false , null $xpath = null , null $nsPrefixes = null ) : false
-    public Node::C14NFile ( string $uri , bool $exclusive = false , bool $withComments = false , null $xpath = null , null $nsPrefixes = null ) : false
-    public ContainerNode::insertBefore ( \DOMNode $node , \DOMNode|null $child = null ) : \DOMNode|false
-    public Moonwalk::moonwalk ( \Closure|null $filter = null ) : \Generator
-    public Walk::walk ( \Closure|null $filter = null ) : \Generator
-
-    /* Magic Methods */
-    public __toString() : string
-
-    /* Inherited Methods */
-    public __construct ( string $qualifiedName , string|null $value = null , string $namespace = "" )
-    public \DOMNode::cloneNode ( bool $deep = false ) : \DOMNode|false
-    public \DOMElement::getAttributeNode ( string $qualifiedName ) :  \DOMAttr|false
-    public \DOMElement::getAttributeNodeNS ( string|null $namespace , string $localName ) :  \DOMAttr|null
-    public \DOMElement::getElementsByTagName ( string $qualifiedName ) :  \DOMNodeList
-    public \DOMElement::getElementsByTagNameNS ( string $namespace , string $localName ) : \DOMNodeList
-    public \DOMNode::getLineNo ( ) : int
-    public \DOMNode::getNodePath ( ) : string|null
-    public \DOMElement::hasAttribute ( string $qualifiedName ) : bool
-    public \DOMElement::hasAttributeNS ( string|null $namespace , string $localName ) : bool
-    public \DOMNode::hasAttributes ( ) : bool
-    public \DOMNode::hasChildNodes ( ) : bool
-    public \DOMNode::isDefaultNamespace ( string $namespace ) : bool
-    public \DOMNode::isSameNode ( \DOMNode $otherNode ) : bool
-    public \DOMNode::isSupported ( string $feature , string $version ) : bool
-    public \DOMNode::lookupNamespaceUri ( string $prefix ) : string
-    public \DOMNode::lookupPrefix ( string $namespace ) : string|null
-    public \DOMNode::normalize ( ) : void
-    public \DOMElement::removeAttribute ( string $qualifiedName ) : bool
-    public \DOMElement::removeAttributeNode (  \DOMAttr $attr ) :  \DOMAttr|false
-    public \DOMElement::removeAttributeNS ( string|null $namespace , string $localName ) : void
-    public \DOMElement::setAttribute ( string $qualifiedName , string $value ) :  \DOMAttr|bool
-    public \DOMNode::removeChild ( \DOMNode $child ) : \DOMNode|false
-    public \DOMNode::replaceChild ( \DOMNode $node , \DOMNode $child ) : \DOMNode|false
-    public \DOMElement::setAttributeNode (  \DOMAttr $attr ) :  \DOMAttr|null|false
-    public \DOMElement::setAttributeNodeNS (  \DOMAttr $attr ) :  \DOMAttr|null|false
-    public \DOMElement::setAttributeNS ( string|null $namespace , string $qualifiedName , string $value ) : void
-    public \DOMElement::setIdAttribute ( string $qualifiedName , bool $isId ) : void
-    public \DOMElement::setIdAttributeNode (  \DOMAttr $attr , bool $isId ) : void
-    public \DOMElement::setIdAttributeNS ( string $namespace , string $qualifiedName , bool $isId ) : void
-
-}
- -## Properties ## - -
-
classList
-
A live TokenList collection of the class attributes of the element. This can then be used to manipulate the class list.
- -
innerHTML
-
Gets or sets the HTML or XML markup contained within the element
- -
outerHTML
-
Gets the serialized HTML fragment describing the element including its descendants. It can also be set to replace the element with nodes parsed from the given string.
-
\ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/ContainerNode/010_appendChild.md b/docs/en/030_Document_Object_Model/ContainerNode/010_appendChild.md deleted file mode 100644 index c4cdf2f..0000000 --- a/docs/en/030_Document_Object_Model/ContainerNode/010_appendChild.md +++ /dev/null @@ -1,55 +0,0 @@ ---- -title: ContainerNode::appendChild ---- - -ContainerNode::appendChild — Adds new child at the end of the children - -## Description ## - -```php -public ContainerNode::appendChild ( \DOMNode $node ) : \DOMNode|false -``` - -This function appends a child to an existing list of children or creates a new list of children. The child can be created with e.g. [`Document::createElement()`](https://www.php.net/manual/en/domdocument.createelement.php), [`Document::createTextNode()`](https://www.php.net/manual/en/domdocument.createtextnode.php) etc. or simply by using any other node. - -When using an existing node it will be moved. - -
-

Warning Only the following element types may be appended to any node using Node and subject to hierarchy restrictions depending on the type of node being appended to:

- - - -

Note that \DOMAttr is missing from this list.

-
- -## Parameters ## - -
-
node
-
The new node.
-
- -## Examples ## - -**Example \#1 Adding a child to the body** - -```php -loadHTML('Ook!'); - -$node = $dom->createElement('br'); -$dom->body->appendChild($node); - -?> -``` \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/ContainerNode/010_insertBefore.md b/docs/en/030_Document_Object_Model/ContainerNode/010_insertBefore.md deleted file mode 100644 index be5445d..0000000 --- a/docs/en/030_Document_Object_Model/ContainerNode/010_insertBefore.md +++ /dev/null @@ -1,40 +0,0 @@ ---- -title: ContainerNode::insertBefore ---- - -ContainerNode::insertBefore — Adds a new child before a reference node - -## Description ## - -```php -public ContainerNode::insertBefore ( \DOMNode $node , \DOMNode|null $child = null ) : \DOMNode|false -``` - -This function inserts a new node right before the reference node. If you plan to do further modifications on the appended child you must use the returned node. - -When using an existing node it will be moved. - -
-

Warning Only the following element types may be appended to any node using Node and subject to hierarchy restrictions depending on the type of node being appended to:

- - - -

Note that \DOMAttr is missing from this list.

-
- -## Parameters ## - -
-
node
-
The new node.
- -
child
-
The reference node. If not supplied, node is appended to the children.
-
\ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/ContainerNode/index.md b/docs/en/030_Document_Object_Model/ContainerNode/index.md deleted file mode 100644 index ac288c9..0000000 --- a/docs/en/030_Document_Object_Model/ContainerNode/index.md +++ /dev/null @@ -1,14 +0,0 @@ -# The ContainerNode trait # - -## Introduction ## - -Allows the extended PHP DOM classes to simulate inheriting from a theoretical extended [\DOMNode](https://www.php.net/manual/en/class.domnode.php). This one implements improved DOM child insertion methods. - -
trait MensBeam\HTML\ContainerNode {
-
-    use Node;
-
-    public appendChild ( \DOMNode $node ) : \DOMNode|false
-    public insertBefore ( \DOMNode $node , \DOMNode|null $child = null ) : \DOMNode|false
-
-}
\ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/LeafNode/010_appendChild.md b/docs/en/030_Document_Object_Model/LeafNode/010_appendChild.md deleted file mode 100644 index 67b4625..0000000 --- a/docs/en/030_Document_Object_Model/LeafNode/010_appendChild.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: LeafNode::appendChild ---- - -LeafNode::appendChild — **DISABLED** - -## Description ## - -```php -public LeafNode::appendChild ( \DOMNode $node ) : DOMException -``` - -Throws a `DOMException` upon use. \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/LeafNode/010_insertBefore.md b/docs/en/030_Document_Object_Model/LeafNode/010_insertBefore.md deleted file mode 100644 index 8d0f802..0000000 --- a/docs/en/030_Document_Object_Model/LeafNode/010_insertBefore.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: LeafNode::insertBefore ---- - -LeafNode::insertBefore — **DISABLED** - -## Description ## - -```php -public LeafNode::insertBefore ( \DOMNode $node , \DOMNode|null $child = null ) : DOMException -``` - -Throws a `DOMException` upon use. \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/LeafNode/010_removeChild.md b/docs/en/030_Document_Object_Model/LeafNode/010_removeChild.md deleted file mode 100644 index 86fe255..0000000 --- a/docs/en/030_Document_Object_Model/LeafNode/010_removeChild.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: LeafNode::removeChild ---- - -LeafNode::removeChild — **DISABLED** - -## Description ## - -```php -public LeafNode::removeChild ( \DOMNode $node ) : DOMException -``` - -Throws a `DOMException` upon use. \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/LeafNode/010_replaceChild.md b/docs/en/030_Document_Object_Model/LeafNode/010_replaceChild.md deleted file mode 100644 index 968b58e..0000000 --- a/docs/en/030_Document_Object_Model/LeafNode/010_replaceChild.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: LeafNode::replaceChild ---- - -LeafNode::replaceChild — **DISABLED** - -## Description ## - -```php -public LeafNode::replaceChild ( \DOMNode $node , \DOMNode $child ) : DOMException -``` - -Throws a `DOMException` upon use. \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/LeafNode/index.md b/docs/en/030_Document_Object_Model/LeafNode/index.md deleted file mode 100644 index 1c84993..0000000 --- a/docs/en/030_Document_Object_Model/LeafNode/index.md +++ /dev/null @@ -1,16 +0,0 @@ -# The LeafNode trait # - -## Introduction ## - -Allows the extended PHP DOM classes to simulate inheriting from a theoretical extended [\DOMNode](https://www.php.net/manual/en/class.domnode.php). This one disables all DOM child insertion methods. - -
trait MensBeam\HTML\LeafNode {
-
-    use Node;
-    
-    public appendChild ( \DOMNode $node ) : DOMException
-    public insertBefore ( \DOMNode $node , \DOMNode|null $child = null ) : DOMException
-    public removeChild ( \DOMNode $child ) : DOMException
-    public replaceChild ( \DOMNode $node, \DOMNode $child ) : DOMException
-
-}
\ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/Moonwalk/010_moonwalk.md b/docs/en/030_Document_Object_Model/Moonwalk/010_moonwalk.md deleted file mode 100644 index 3896311..0000000 --- a/docs/en/030_Document_Object_Model/Moonwalk/010_moonwalk.md +++ /dev/null @@ -1,43 +0,0 @@ ---- -title: Moonwalk::moonwalk ---- - -Moonwalk::moonwalk — Output generator for walking up the DOM tree - -## Description ## - -
public Moonwalk::moonwalk ( \Closure|null $filter = null ) : \Generator
-
- -Non-standard. Creates a [`\Generator`](https://www.php.net/manual/en/class.generator.php) object for walking up the DOM tree. This is in lieu of recreating the awful [DOM TreeWalker API](https://developer.mozilla.org/en-US/docs/Web/API/Treewalker). - -## Examples ## - -**Example \#1 Print name of all ancestors of the H1 element** - -```php -loadHTML('Ook!

Eek

'); -$h1 = $dom->getElementsByTagName('h1')->item(0); - -// All ancestors will be elements so there's no reason to have a filter. -$tree = $h1->moonwalk(); - -foreach ($tree as $t) { - echo "{$t->nodeName}\n"; -} - -?> -``` - -The above example will output something similar to: - -```php -body -html - -``` \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/Moonwalk/index.md b/docs/en/030_Document_Object_Model/Moonwalk/index.md deleted file mode 100644 index 43fd695..0000000 --- a/docs/en/030_Document_Object_Model/Moonwalk/index.md +++ /dev/null @@ -1,11 +0,0 @@ -# The Moonwalk trait # - -## Introduction ## - -Allows the extended PHP DOM classes to Moonwalk up the DOM via a [`\Generator`](https://www.php.net/manual/en/class.generator.php). This is in lieu of recreating the awful [DOM TreeMoonwalker API](https://developer.mozilla.org/en-US/docs/Web/API/TreeMoonwalker). - -
trait MensBeam\HTML\Moonwalk {
-
-    public Moonwalk ( \Closure $filter ) : \Generator
-
-}
\ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/Node/010_C14N.md b/docs/en/030_Document_Object_Model/Node/010_C14N.md deleted file mode 100644 index 1228dda..0000000 --- a/docs/en/030_Document_Object_Model/Node/010_C14N.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Node::C14N ---- - -Node::C14N — **DISABLED** - -## Description ## - -```php -public Node::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`. `\DOMNode::C14N` is an extremely slow and inefficient method to serialize DOM and never should be used. \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/Node/010_C14NFile.md b/docs/en/030_Document_Object_Model/Node/010_C14NFile.md deleted file mode 100644 index 0ab0f91..0000000 --- a/docs/en/030_Document_Object_Model/Node/010_C14NFile.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Node::C14NFile ---- - -Document::C14NFile — **DISABLED** - -## Description ## - -```php -public Node::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`. `\DOMNode::C14NFile` is an extremely slow and inefficient method to serialize DOM and never should be used. \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/Node/index.md b/docs/en/030_Document_Object_Model/Node/index.md deleted file mode 100644 index 0489d67..0000000 --- a/docs/en/030_Document_Object_Model/Node/index.md +++ /dev/null @@ -1,12 +0,0 @@ -# The Node trait # - -## Introduction ## - -Allows the extended PHP DOM classes to simulate inheriting from a theoretical extended [\DOMNode](https://www.php.net/manual/en/class.domnode.php). It is used to disable [C14N](C14N.html) and [C14NFile](C14NFile.html). - -
trait MensBeam\HTML\Node {
-
-    public C14N ( bool $exclusive = false , bool $withComments = false , null $xpath = null , null $nsPrefixes = null ) : false
-    public C14NFile ( string $uri , bool $exclusive = false , bool $withComments = false , null $xpath = null , null $nsPrefixes = null ) : false
-
-}
\ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/Walk/010_walk.md b/docs/en/030_Document_Object_Model/Walk/010_walk.md deleted file mode 100644 index ddcf37e..0000000 --- a/docs/en/030_Document_Object_Model/Walk/010_walk.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -title: Walk::walk ---- - -Walk::walk — Output generator for walking down the DOM tree - -## Description ## - -
public Walk::walk ( \Closure|null $filter = null ) : \Generator
-
- -Non-standard. Creates a [`\Generator`](https://www.php.net/manual/en/class.generator.php) object for walking down the DOM tree. This is in lieu of recreating the awful [DOM TreeWalker API](https://developer.mozilla.org/en-US/docs/Web/API/Treewalker). - -## Examples ## - -**Example \#1 Print name of every Element** - -```php -loadHTML('Ook!

Eek

'); -$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 - -``` \ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/Walk/index.md b/docs/en/030_Document_Object_Model/Walk/index.md deleted file mode 100644 index e9b7ec8..0000000 --- a/docs/en/030_Document_Object_Model/Walk/index.md +++ /dev/null @@ -1,11 +0,0 @@ -# The Walk trait # - -## Introduction ## - -Allows the extended PHP DOM classes to walk down the DOM via a [`\Generator`](https://www.php.net/manual/en/class.generator.php). This is in lieu of recreating the awful [DOM TreeWalker API](https://developer.mozilla.org/en-US/docs/Web/API/Treewalker). - -
trait MensBeam\HTML\Walk {
-
-    public walk ( \Closure $filter ) : \Generator
-
-}
\ No newline at end of file diff --git a/docs/en/030_Document_Object_Model/index.md b/docs/en/030_Document_Object_Model/index.md deleted file mode 100644 index 12cac6f..0000000 --- a/docs/en/030_Document_Object_Model/index.md +++ /dev/null @@ -1 +0,0 @@ -The MensBeam HTML library works by parsing HTML strings into PHP's existing XML DOM. It, however, has to force the antiquated PHP DOM extension into working properly with modern HTML DOM by extending many of the node types. The documentation below follows PHP's doc style guide as closely as possible. Each class should be listed separately in the menu under this section. diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index 509b64c..0000000 --- a/docs/index.md +++ /dev/null @@ -1 +0,0 @@ -Welcome to the user manual for HTML. It is included with each copy of the software, and is also [available online](https://mensbeam.com/html/en/). Please select a language above. diff --git a/docs/theme/php/config.json b/docs/theme/php/config.json deleted file mode 100644 index 15dd40d..0000000 --- a/docs/theme/php/config.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "favicon": "favicon.png", - "js": [ - "daux.min.js" - ], - "css": [ - "php.css" - ] -} diff --git a/docs/theme/php/daux.min.js b/docs/theme/php/daux.min.js deleted file mode 100644 index fd87588..0000000 --- a/docs/theme/php/daux.min.js +++ /dev/null @@ -1,2 +0,0 @@ -var e=document.querySelectorAll(".s-content pre"),t=document.querySelector(".CodeToggler"),n="daux_code_blocks_hidden";function a(t){for(var a=0;a code:not(.hljs)");if(l.length){var i=document.getElementsByTagName("head")[0],c=document.createElement("script");c.type="text/javascript",c.async=!0,c.src="".concat(window.base_url,"daux_libraries/highlight.pack.js"),c.onload=function(e){[].forEach.call(l,window.hljs.highlightBlock)},i.appendChild(c)}function s(e){var t=void 0!==e.preventDefault;t&&e.preventDefault();var n=function(e){for(var t=e;(t=t.parentNode)&&9!==t.nodeType;)if(1===t.nodeType&&t.classList.contains("Nav__item"))return t;throw new Error("Could not find a NavItem...")}(e.target),a=n.querySelector("ul.Nav");t&&n.classList.contains("Nav__item--open")?(a.style.height="".concat(a.scrollHeight,"px"),a.style.transitionDuration="150ms",a.style.height="0px",n.classList.remove("Nav__item--open")):t?(a.style.transitionDuration="150ms",a.addEventListener("transitionend",(function e(t){"0px"!==t.target.style.height&&(t.target.style.height="auto"),t.target.removeEventListener("transitionend",e)})),a.style.height="".concat(a.scrollHeight,"px"),n.classList.add("Nav__item--open")):a.style.height="auto"}for(var d,u=document.querySelectorAll(".Nav__item.has-children i.Nav__arrow"),h=u.length-1;h>=0;h--)(d=u[h]).addEventListener("click",s),d.parentNode.parentNode.classList.contains("Nav__item--open")&&s({target:d});var g=document.querySelectorAll(".Nav__item__link--nopage"),v=!0,p=!1,_=void 0;try{for(var y,m=g[Symbol.iterator]();!(v=(y=m.next()).done);v=!0){y.value.addEventListener("click",s)}}catch(e){p=!0,_=e}finally{try{v||null==m.return||m.return()}finally{if(p)throw _}} -//# sourceMappingURL=daux.min.js.map diff --git a/docs/theme/php/php.css b/docs/theme/php/php.css deleted file mode 100644 index cffc18c..0000000 --- a/docs/theme/php/php.css +++ /dev/null @@ -1,2 +0,0 @@ -/*! normalize.css v4.1.1 | MIT License | github.com/necolas/normalize.css */ -html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%;font-size:14px}body{margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block}audio:not([controls]){display:none;height:0}progress,sub,sup{vertical-align:baseline}.s-content pre code:after,.s-content pre code:before,[hidden],template{display:none}a{background-color:transparent;-webkit-text-decoration-skip:objects;text-decoration:none;color:#369}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}.s-content blockquote cite,dfn{font-style:italic}h1{font-size:2em;margin:.67em 0}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}svg:not(:root){overflow:hidden}code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;clear:both;margin:1em 0;border:0;border-top:1px solid #ddd}button,input,select,textarea{font:inherit;margin:0}optgroup{font-weight:700}button,hr,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{color:inherit;display:table;max-width:100%;white-space:normal}textarea{overflow:auto}[type=checkbox],[type=radio],legend{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-input-placeholder{color:inherit;opacity:.54}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}*,:after,:before{box-sizing:border-box}@media (min-width:850px){html{font-size:16px}}html{background-color:#fff;color:#333}body,html{height:100%}.Collapsible__trigger:hover .Collapsible__trigger__bar,.Columns__left{background-color:#333}.Columns__right__content{padding:10px}@media (max-width:768px){html:not(.no-js) .Collapsible__content{height:0;overflow:hidden;transition:height 400ms ease-in-out}}.Collapsible__trigger{margin:12px;padding:7px 10px;background-color:transparent;border:0;float:right;background-image:none;filter:none;box-shadow:none}.Collapsible__trigger__bar{display:block;width:18px;height:2px;margin-top:2px;margin-bottom:3px;background-color:#e8d5d3}.Collapsible__trigger:hover{background-color:#8892bf;box-shadow:none}@media screen and (min-width:769px){body{background-color:#15284b}.Navbar{position:fixed;z-index:1030;width:100%}.Collapsible__trigger{display:none!important}.Collapsible__content{display:block!important}.Columns{height:100%}.Columns:after,.Columns:before{content:" ";display:table}.Columns:after{clear:both}.Columns__left,.Columns__right{position:relative;min-height:1px;float:left;overflow:auto;height:100%}.Columns__left{width:25%;border-right:1px solid #e7e7e9;overflow-x:hidden}.Columns__right{width:75%}.Columns__right__content{padding:0 20px 20px;min-height:100%}}.Page{max-width:860px}.u-visuallyHidden{position:absolute!important;height:1px;width:1px;overflow:hidden;clip:rect(1px 1px 1px 1px);clip:rect(1px,1px,1px,1px);white-space:nowrap}body{font-feature-settings:"kern" 1;-webkit-font-kerning:normal;font-kerning:normal;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;line-height:1.618;font-size:16px;color:#333!important}body,h1,h2,h3,h4,h5,h6{font-family:sans-serif}.s-content h1,.s-content h2,.s-content h3,.s-content h4,.s-content h5,.s-content h6{cursor:text;line-height:1.4em;margin:2em 0 .5em}.s-content h1 code,.s-content h1 tt,.s-content h2 code,.s-content h2 tt,.s-content h3 code,.s-content h3 tt,.s-content h4 code,.s-content h4 tt,.s-content h5 code,.s-content h5 tt,.s-content h6 code,.s-content h6 tt{font-size:inherit}.s-content h1 i,.s-content h2 i,.s-content h3 i,.s-content h4 i,.s-content h5 i,.s-content h6 i{font-size:.7em}.s-content h1,.s-content h1 p,.s-content h2 p,.s-content h3 p,.s-content h4 p,.s-content h5 p,.s-content h6 p{margin-top:0}.s-content small{font-size:1rem}.s-content a{text-decoration:underline}.s-content p{margin-bottom:1.3em}.s-content ol,.s-content ul{padding-left:2em}.s-content ul p,.s-content ul ul{margin:0}.s-content dl{padding:0}.s-content dl dt{font-weight:700;font-style:italic;padding:0;margin:15px 0 5px}.s-content dl dt:first-child{padding:0}.s-content dl dd{margin:0 0 15px;padding:0 15px}.s-content blockquote{margin:.75em 2em;padding:.5em 1em;font-style:italic;border-left:.25em solid #333}.s-content blockquote cite:before{content:"\2014";padding-right:.5em}.s-content table{width:100%;padding:0;margin-bottom:1em;border-collapse:separate;border-spacing:2px;border:2px solid #939393}.s-content table+table{margin-top:1em}.s-content table tr{background-color:#fff;margin:0;padding:0;border-top:0}.s-content table tr:nth-child(2n){background-color:transparent}.s-content table th{font-weight:700;background:#dbdbdb}.s-content table td,.s-content table th{margin:0;padding:.5em}.s-content blockquote>:first-child,.s-content dl dd>:first-child,.s-content dl dt>:first-child,.s-content ol>:first-child,.s-content table td>:first-child,.s-content table th>:first-child,.s-content ul>:first-child{margin-top:0}.admonition p:last-child,.s-content blockquote>:last-child,.s-content dl dd>:last-child,.s-content dl dt>:last-child,.s-content ol>:last-child,.s-content table td>:last-child,.s-content table th>:last-child,.s-content ul>:last-child{margin-bottom:0}.s-content img{max-width:100%;display:inline-block}.s-content code{font-family:"Operator Mono SSm","Operator Mono",monospace;padding-top:.1rem;padding-bottom:.1rem;background:0 0;border-radius:0;box-shadow:none;padding:0;border:0;margin:0}.s-content code:after,.s-content code:before{letter-spacing:-.2em;content:"\00a0"}.s-content pre{background:#f5f2f0;line-height:1.5em;overflow:auto;border:0;border-radius:0;padding:.75em 20px;margin:0 -20px 20px}.s-content pre code{margin:0;padding:0;white-space:pre;box-shadow:none}.s-content pre code,.s-content pre tt{background-color:transparent;border:0}.s-content ins,.s-content u{text-decoration:none;border-bottom:1px solid #333}.s-content del a,.s-content ins a,.s-content u a{color:inherit}a.Link--external:after{content:" " url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAVklEQVR4Xn3PgQkAMQhDUXfqTu7kTtkpd5RA8AInfArtQ2iRXFWT2QedAfttj2FsPIOE1eCOlEuoWWjgzYaB/IkeGOrxXhqB+uA9Bfcm0lAZuh+YIeAD+cAqSz4kCMUAAAAASUVORK5CYII=)}a.Link--broken{color:red}p{margin:0 0 1em}.Button{display:inline-block;text-align:center;vertical-align:middle;touch-action:manipulation;cursor:pointer;background-image:none;border:1px solid transparent;white-space:nowrap;margin-bottom:0}.Button--small{font-size:12px;line-height:1.5;border-radius:3px}.Button--default{color:#333;background-color:#fff;border-color:#ccc}.Button--default.Button--active{color:#333;background-color:#e6e6e6;border-color:#adadad}.Brand{display:block;background-color:#4f5b93;padding:.75em .6em;font-size:1.125rem;text-shadow:none;font-family:sans-serif;color:#fff}.Navbar{box-shadow:0 1px 5px rgba(0,0,0,.25);background-color:#e63c2f;margin-bottom:0}.CodeToggler{padding:0 20px}.CodeToggler__text{font-size:12px;line-height:1.5;padding:6px 10px 6px 0;display:inline-block;vertical-align:middle}.CodeToggler--hidden,.no-js .CodeToggler,.s-content code::after,.s-content code::before{display:none}.Nav{margin:0;padding:0}.Nav__arrow{display:inline-block;position:relative;width:16px;margin-left:-16px}.Nav__arrow:before{position:absolute;display:block;content:"";left:50%;border-right:.15em solid #333;border-top:.15em solid #333;transform:rotate(45deg);transition-duration:.3s}.Nav__item,.Nav__item a{display:block}.Nav__item a{margin:0;padding:6px 15px 6px 20px;font-family:sans-serif;font-weight:400;color:#f2f2f2;text-shadow:none}.Nav__item a:hover{color:#f2f2f2;text-shadow:none;background-color:#793862}.Nav .Nav{margin-left:15px}html:not(.no-js) .Nav .Nav{height:0;transition:height 400ms ease-in-out;overflow:hidden}.Nav .Nav .Nav__item a{margin:0 0 0 -15px;padding:3px 30px;font-family:sans-serif;color:#f2f2f2;opacity:.7}.HomepageButtons .Button--hero:hover,.Nav .Nav .Nav__item a:hover{opacity:1}.Nav .Nav .Nav__item--active a{color:#f2f2f2}.Nav__item--active>a,.Nav__item--open>a{background-color:#793862}.Nav__item--open>a>.Nav__arrow:before{margin-left:-.25em;transform:rotate(135deg)}.Page__header{margin:0 0 10px;padding:0}.Page__header:after,.Page__header:before{content:" ";display:table}.Page__header:after{clear:both}.Page__header h1{padding:0;line-height:57px;font-size:1rem;border-bottom:0;margin:0}.Page__header--separator{height:.6em}.Page__header a{text-decoration:none}.Page__header .EditOn,.Page__header .ModifiedDate{float:left;font-size:10px;color:gray}.Page__header .EditOn{float:right}.Links,.Twitter{padding:0 20px}.Links a{font-family:sans-serif;font-weight:400;color:#f2f2f2;line-height:2em}.Twitter{font:11px/18px "Helvetica Neue",Arial,sans-serif}.Twitter__button{text-decoration:none;display:inline-block;vertical-align:top;position:relative;height:20px;box-sizing:border-box;padding:1px 8px 1px 6px;background-color:#1b95e0;color:#fff;border-radius:3px;font-weight:500;cursor:pointer}.Twitter__button .Twitter__button__label{display:inline-block;vertical-align:top;margin-left:3px;white-space:nowrap}.Twitter__button svg{position:relative;top:2px;display:inline-block;width:14px;height:14px}.PoweredBy{padding:0 20px 1rem;font-size:1rem}.Search{position:relative}.Search__field{display:block;width:100%;height:34px;padding:6px 30px 6px 20px;color:#555;border-width:0 0 1px;border-bottom:1px solid #ccc;background:#fff;transition:border-color ease-in-out .15s}.Search__field:focus{border-color:#8892bf;outline:0}.Search__icon{position:absolute;right:9px;top:9px;width:16px;height:16px;cursor:pointer}.Navbar .Search{float:right;margin:8px 20px}.Navbar .Search__field{box-shadow:inset 0 1px 1px rgba(0,0,0,.075);border-width:0;border-radius:4px;padding-left:10px}.TableOfContentsContainer{float:right;min-width:300px;max-width:25%;padding-left:1em}.TableOfContentsContainer__title{margin-bottom:0!important}.TableOfContentsContainer__content{border:1px solid #efefef;border-width:4px 2px 2px 6px}.TableOfContentsContainer__content>.TableOfContents>li+li{border-top:1px solid #ddd}ul.TableOfContents{font-size:1rem;padding-left:0;margin:0;list-style-type:none}ul.TableOfContents p{margin-bottom:0}ul.TableOfContents a{text-decoration:none;display:block;padding:.2em 0 .2em .75em}ul.TableOfContents .TableOfContents{padding-left:.75em}.Pager{padding-left:0;margin:1em 0;list-style:none;text-align:center}.Pager:after,.Pager:before{content:" ";display:table}.Pager,.Pager:after{clear:both}.Pager li,pre .s-content code{display:inline}.Pager li>a{display:inline-block;padding:5px 14px;background-color:#fff}.Pager li>a:focus,.Pager li>a:hover{text-decoration:none}.Pager--next>a{float:right}.Pager--prev>a{float:left}.Checkbox{position:relative;display:block;padding-left:30px;cursor:pointer}.Checkbox input{position:absolute;z-index:-1;opacity:0}.Checkbox__indicator{position:absolute;top:50%;left:0;width:20px;height:20px;margin-top:-10px;background:#e6e6e6}.Checkbox__indicator:after{position:absolute;display:none;content:""}.Checkbox input:focus~.Checkbox__indicator,.Checkbox:hover input~.Checkbox__indicator{background:#ccc}.Checkbox input:checked~.Checkbox__indicator{background:#333}.Checkbox input:checked~.Checkbox__indicator:after{display:block}.Checkbox input:checked:focus~.Checkbox__indicator,.Checkbox:hover input:not([disabled]):checked~.Checkbox__indicator{background:#8892bf}.Checkbox input:disabled~.Checkbox__indicator{pointer-events:none;opacity:.6;background:#e6e6e6}.Checkbox .Checkbox__indicator:after{top:4px;left:8px;width:5px;height:10px;transform:rotate(45deg);border:solid #fff;border-width:0 2px 2px 0}.Checkbox input:disabled~.Checkbox__indicator:after{border-color:#7b7b7b}.Container{margin-right:auto;margin-left:auto}.Container--inner{width:80%;margin:0 auto}@media (min-width:1200px){.Container{width:1170px}}@media (min-width:992px){.Container{width:970px}}@media (min-width:769px){.Container{width:750px}}.Homepage{background-color:#fff;border-radius:0;border:0;color:#333;overflow:hidden;padding-bottom:0;margin-bottom:0;box-shadow:none}.HomepageTitle h2{width:80%;font-size:30px;margin:20px auto;text-align:center}.HomepageImage img{display:block;max-width:80%;margin:0 auto;height:auto}.HomepageButtons{padding:20px 0;background-color:#e8d5d3;text-align:center}.HomepageButtons:after,.HomepageButtons:before{content:" ";display:table}.HomepageButtons:after{clear:both}.HomepageButtons .Button--hero{padding:20px 30px;border-radius:0;text-shadow:none;opacity:.8;margin:0 10px;text-transform:uppercase;border:5px solid #333;font-family:sans-serif;background-image:none;filter:none;box-shadow:none}@media (max-width:768px){.HomepageButtons .Button--hero{display:block;margin-bottom:10px}}.HomepageButtons .Button--hero.Button--secondary{background-color:#793862;color:#333}.HomepageButtons .Button--hero.Button--primary{background-color:#333;color:#333}.HomepageContent{background-color:#fff;padding:40px 0}.HomepageContent ol li,.HomepageContent ul li{list-style:none;margin-bottom:.5em;position:relative}.HomepageContent ol li:before,.HomepageContent ul li:before{position:absolute;top:50%;left:-1.5em;content:"";width:0;height:0;border:.5em solid transparent;border-left:.5em solid #8892bf;float:left;display:block;margin-top:-.5em}.HomepageContent .HeroText{font-family:sans-serif;font-weight:300;font-size:16px;margin-bottom:20px;line-height:1.4}@media (min-width:769px){.HomepageContent{padding:40px 20px}.HomepageContent .HeroText{font-size:21px}.HomepageContent .Row{margin:0 -15px}.HomepageContent .Row__half,.HomepageContent .Row__quarter,.HomepageContent .Row__third{float:left;position:relative;min-height:1px;padding-left:15px;padding-right:15px}.HomepageContent .Row__third{width:33.333333%}.HomepageContent .Row__half{width:50%}.HomepageContent .Row__quarter{width:25%}}.HomepageFooter{background-color:#333;color:#8892bf;border:0;box-shadow:none}.HomepageFooter:after,.HomepageFooter:before{content:" ";display:table}.HomepageFooter:after{clear:both}@media (max-width:768px){.HomepageFooter{padding:0 20px;text-align:center}.HomepageFooter .HomepageFooter__links{padding-left:0;list-style-type:none}}@media (min-width:769px){.HomepageFooter .HomepageFooter__links{float:left}.HomepageFooter .HomepageFooter__twitter{float:right}}.HomepageFooter__links,.HomepageFooter__twitter{margin:40px 0}.HomepageFooter__links li a{line-height:32px;font-size:16px;font-family:sans-serif;font-weight:700}.HomepageFooter__links li a:hover{text-decoration:underline}.HomepageFooter .Twitter__button{margin-bottom:20px}@media print{*{text-shadow:none!important;color:#000!important;background:0 0!important;box-shadow:none!important}h1,h2,h3,h4,h5,h6{-moz-column-break-after:avoid;break-after:avoid;-moz-column-break-before:auto;break-before:auto}blockquote,img,pre{-moz-column-break-inside:avoid;break-inside:avoid}blockquote,pre{border:1px solid #999;font-style:italic}img{border:0}a,a:visited{text-decoration:underline}abbr[title]:after{content:" (" attr(title) ")"}q{quotes:none}.s-content a[href^="#"]:after,q:before{content:""}q:after{content:" (" attr(cite) ")"}.PageBreak{display:block;-moz-column-break-before:always;break-before:always}.NoPrint,.Pager,aside{display:none}.Columns__right{width:100%!important}.s-content a:after{content:" (" attr(href) ")";font-size:80%;word-wrap:break-word}h1 a[href]:after{font-size:50%}}.Columns__right__content,body{background-color:#f2f2f2}a.Link--external::after{content:''}.s-content h1,.s-content h2,.s-content h3,.s-content h4,.s-content h5,.s-content h6{margin-bottom:1.5rem}.s-content h1{font-size:1.75rem}.s-content h2{font-size:1.5rem}.s-content h3{font-size:1.25rem}.s-content h4{font-size:1.125rem}.Nav__item .Nav__item,.s-content h5,.s-content h6,.s-content table{font-size:1rem}.s-content table tbody,.s-content table thead{background-color:#fff}.s-content table tr:nth-child(2n) td{background-color:#fff}.s-content table td,.s-content table th{border:0}.s-content table th{background-color:#c4c9df}.Brand,h1,h2,h3,h4,h5,h6{font-weight:600;font-stretch:condensed}h1,h2,h3,h4,h5,h6{color:#793862;border-bottom:1px dotted #333;padding-bottom:5px}.Button,.Pager li>a{border-radius:0}.HomepageButtons .Button--hero{font-weight:400;font-size:1rem}.Page__header{border-bottom:0}.Pager li>a{border:2px solid #dbdbdb}.Pager li>a:focus,.Pager li>a:hover{background-color:#dbdbdb}.Pager--prev a::before{content:"\2190\00a0"}.Pager--next a::after{content:"\00a0\2192"}.Navbar{height:auto;box-shadow:none}.Navbar .Brand{float:none;line-height:inherit;height:auto}.Homepage{padding-top:10px!important}.Nav__item{font-size:1rem}.Nav .Nav .Nav__item a{padding-left:35px}.Nav__arrow:before{margin:0 0 0 -.25em;top:auto;bottom:calc(50% - .0625em);width:.375em;height:.375em;transform-origin:center}.Nav .Nav .Nav__item a .Nav__arrow:before,.Nav__arrow:before{border-right-color:#f2f2f2;border-top-color:#f2f2f2}.admonition{padding:.75rem;margin:1.5rem 0;border:1px solid #c2c2c2;background-color:#fff}.admonition .danger{background-color:#f4dfdf;border-color:#c4b4b4}.hljs,.s-content pre{background:#15284b;color:#e8d5d3}.hljs{display:block;overflow-x:auto;padding:.5em}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}.hljs-comment,.hljs-quote{color:#978e9c}.hljs-addition,.hljs-keyword,.hljs-selector-tag{color:#acb39a}.hljs-doctag,.hljs-literal,.hljs-meta .hljs-meta-string,.hljs-number,.hljs-regexp,.hljs-string{color:#93b7bb}.hljs-name,.hljs-section,.hljs-selector-class,.hljs-selector-id,.hljs-title{color:#82b7e5}.hljs-attr,.hljs-attribute,.hljs-class .hljs-title,.hljs-template-variable,.hljs-type,.hljs-variable{color:#c5b031}.hljs-bullet,.hljs-link,.hljs-meta,.hljs-meta .hljs-keyword,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-subst,.hljs-symbol{color:#ea8031}.hljs-built_in,.hljs-deletion{color:#e63c2f}.hljs-formula{background:#686986}@media (min-width:850px){.Columns__left{border:0}} \ No newline at end of file diff --git a/docs/theme/src/php.scss b/docs/theme/src/php.scss deleted file mode 100644 index 3041d69..0000000 --- a/docs/theme/src/php.scss +++ /dev/null @@ -1,324 +0,0 @@ -/* Daux imports; fonts are omitted */ -@import "../../../vendor/daux/daux.io/src/css/theme_daux/vendor/normalize.scss"; -@import "../../../vendor/daux/daux.io/src/css/theme_daux/_variables.scss"; -@import "../../../vendor/daux/daux.io/src/css/theme_daux/_mixins.scss"; -@import "../../../vendor/daux/daux.io/src/css/theme_daux/_structure.scss"; -@import "../../../vendor/daux/daux.io/src/css/theme_daux/_typography.scss"; -@import "../../../vendor/daux/daux.io/src/css/theme_daux/_components.scss"; -@import "../../../vendor/daux/daux.io/src/css/theme_daux/_homepage.scss"; -@import "../../../vendor/daux/daux.io/src/css/theme_daux/_print.scss" print; - -/* Overrides */ - -:root { - --font-family-text: sans-serif; - --font-family-monospace: "Operator Mono SSm", "Operator Mono", monospace; - --font-family-heading: sans-serif; - - --type-size-1: 1.75rem; - --type-size-2: 1.5rem; - --type-size-3: 1.25rem; - --type-size-4: 1.125rem; - --type-size-5: 1rem; - --type-size-6: 1rem; - - --purple: #4f5b93; - --tyrian: #793862; - --light-purple: #8892bf; - --lighter-purple: #c4c9df; - --danger: #f4dfdf; - - --page: #f2f2f2; - --text: #333; - - --red: #e63c2f; - --blue: #15284b; - --light-blue: #93b7bb; - --beige: #e8d5d3; - --green: #2c9a42; - - --dark-gray: color(var(--page) blend(var(--text) 75%)); - --gray: color(var(--page) blend(var(--text) 50%)); - --light-gray: color(var(--page) blend(var(--text) 25%)); - --lighter-gray: color(var(--page) blend(var(--text) 12.5%)); - --lightest-gray: color(#fff blend(var(--page) 75%)); - - --dark: var(--text); - --light: var(--light-purple); - - --sidebar-background: var(--text); - --sidebar-link-active-background: var(--tyrian); - --sidebar-link-color: var(--page); - --sidebar-link-secondary-color: var(--page); - --sidebar-collapsible--hamburger-color: var(--beige); - - --link-color: #369; - --brand-color: #fff; - --brand-background: var(--purple); - - --code-tag-background-color: transparent; - --code-tag-border-radius: 0; - --code-tag-box-shadow: none; - - --homepage-navbar-background: var(--red); - --hero-button-block-background: var(--beige); - --homepage-hero-background: #fff; - --content-floating-blocks-background: var(--blue); -} - -body { - line-height: 1.618; - font-size: 16px; - color: var(--text) !important; -} - -body, .Columns__right__content { - background-color: var(--page); -} - -a.Link--external::after { - content: ''; -} - -.Page__header h1 { - font-size: var(--type-size-6); - border-bottom: 0; - margin-bottom: 0; -} - -.s-content { - h1, h2, h3, h4, h5, h6 { - margin-bottom: 1.5rem; - } - - h1 { - font-size: var(--type-size-1); - } - - h2 { - font-size: var(--type-size-2); - } - - h3 { - font-size: var(--type-size-3); - } - - h4 { - font-size: var(--type-size-4); - } - - h5 { - font-size: var(--type-size-5); - } - - h6 { - font-size: var(--type-size-6); - } - - - code { - padding-top: 0; - padding-bottom: 0; - padding: 0; - border: 0; - margin: 0; - - &::before, &::after { - display: none; - } - - pre & { - display: inline; - } - } - - table { - border-collapse: separate; - border-spacing: 2px; - border: 2px solid var(--gray); - - thead, tbody { - background-color: #fff; - } - - tr { - border-top: 0; - - &:nth-child(2n) { - background-color: transparent; - - td { - background-color: #fff; - } - } - } - - th, td { - border: 0; - } - - th { - background-color: var(--lighter-purple); - } - } -} - -.s-content table, .Nav__item .Nav__item { - font-size: 1rem; -} - -.Brand, h1, h2, h3, h4, h5, h6 { - font-weight: 600; - font-stretch: condensed; -} - -h1, h2, h3, h4, h5, h6 { - color: var(--tyrian); - border-bottom: 1px dotted var(--text); - padding-bottom: 5px; -} - -.Button { - border-radius: 0; -} - -.HomepageButtons .Button--hero { - font-weight: normal; - font-size: var(--type-size-6); -} - -.Page__header { - border-bottom: 0; -} - -.Pager li > a { - border: 2px solid var(--lighter-gray); - border-radius: 0; - - &:hover, &:focus { - background-color: var(--lighter-gray); - } -} - -.Pager--prev a::before { - content: "\2190\00a0"; -} -.Pager--next a::after { - content: "\00a0\2192"; -} - -.Navbar { - height: auto; - box-shadow: none; - - .Brand { - float: none; - line-height: inherit; - height: auto; - } -} - -.Homepage { - padding-top: 10px !important; -} - -.Nav__item { - font-size: var(--type-size-6); -} - -.Nav .Nav .Nav__item a { - padding-left: 35px; -} - -.Nav__arrow:before { - margin: 0 0 0 -.25em; - top: auto; - bottom: calc(50% - 0.0625em); - width: 0.375em; - height: 0.375em; - transform-origin: center; -} - -.Nav__arrow:before, .Nav .Nav .Nav__item a .Nav__arrow:before { - border-right-color: var(--page); - border-top-color: var(--page); -} - -.admonition { - padding: 0.75rem; - margin: 1.5rem 0; - border: 1px solid var(--light-gray); - background-color: #fff; - - p:last-child { - margin-bottom: 0; - } - - .danger { - background-color: var(--danger); - border-color: color(var(--danger) blend(var(--text) 25%)); - } -} - -.hljs, .s-content pre { - background: var(--blue); - color: var(--beige); -} - -.hljs { - display: block; - overflow-x: auto; - padding: 0.5em; -} - -.hljs-emphasis { - font-style: italic; -} - -.hljs-strong { - font-weight: bold; -} - -.hljs-comment, .hljs-quote { - color: #978e9c; -} - -/* Green */ -.hljs-keyword, .hljs-selector-tag, .hljs-addition { - color: #acb39a; -} - -/* Cyan */ -.hljs-number, .hljs-string, .hljs-meta .hljs-meta-string, .hljs-literal, .hljs-doctag, .hljs-regexp { - color: var(--light-blue); -} - -/* Blue */ -.hljs-title, .hljs-section, .hljs-name, .hljs-selector-id, .hljs-selector-class { - color: #82b7e5; -} - -/* Yellow */ -.hljs-attribute, .hljs-attr, .hljs-variable, .hljs-template-variable, .hljs-class .hljs-title, .hljs-type { - color: #c5b031; -} - -/* Orange */ -.hljs-symbol, .hljs-bullet, .hljs-subst, .hljs-meta, .hljs-meta .hljs-keyword, .hljs-selector-attr, .hljs-selector-pseudo, .hljs-link { - color: #ea8031; -} - -/* Red */ -.hljs-built_in, .hljs-deletion { - color: var(--red); -} - -.hljs-formula { - background: #686986; -} - -@media (--viewport-large) { - .Columns__left { - border: 0; - } -} diff --git a/lib/DOM/AbstractDocument.php b/lib/DOM/AbstractDocument.php deleted file mode 100644 index 1e162fe..0000000 --- a/lib/DOM/AbstractDocument.php +++ /dev/null @@ -1,12 +0,0 @@ - 'Hierarchy request error; supplied node is not allowed here', - 4 => 'Supplied node does not belong to this document', - 5 => 'Invalid character', - 7 => 'Modification not allowed here', - 8 => 'Not found error', - 12 => 'Syntax error', - 100 => 'Argument #%s (\$%s) must be of type %s, %s given', - 101 => 'Failed to set the "outerHTML" property; the element does not have a parent node' - ]; - - public function __construct(int $code, ...$args) { - if (!isset(self::$messages[$code])) { - throw new Exception(Exception::INVALID_CODE); - } - - $message = self::$messages[$code]; - $previous = null; - - if ($args) { - // Grab a previous exception if there is one. - if ($args[0] instanceof \Throwable) { - $previous = array_shift($args); - } elseif (end($args) instanceof \Throwable) { - $previous = array_pop($args); - } - } - - // Count the number of replacements needed in the message. - preg_match_all('/(\%(?:\d+\$)?s)/', $message, $matches); - $count = count($matches[1]); - - // If the number of replacements don't match the arguments then oops. - if (count($args) !== $count) { - throw new Exception(Exception::INCORRECT_PARAMETERS_FOR_MESSAGE, $count); - } - - if ($count > 0) { - // Go through each of the arguments and run sprintf on the strings. - $message = call_user_func_array('sprintf', array_merge([$message], $args)); - } - - parent::__construct($message, $code, $previous); - } -} diff --git a/lib/DOM/Document.php b/lib/DOM/Document.php deleted file mode 100644 index 54daffc..0000000 --- a/lib/DOM/Document.php +++ /dev/null @@ -1,755 +0,0 @@ -documentElement === null || $this->documentElement->childNodes->length === 0) { - return null; - } - - $body = null; - - # The body element of a document is the first of the html element's children - # that is either a body element or a frameset element, or null if there is no - # such element. - $n = $this->documentElement->firstChild; - do { - if ($n instanceof Element && $n->namespaceURI === null && ($n->nodeName === 'body' || $n->nodeName === 'frameset')) { - $body = $n; - break; - } - } while ($n = $n->nextSibling); - - if ($body !== null) { - // References are handled weirdly by PHP's DOM. Return a stored body element - // unless it is changed so operations (like classList) can be done without - // losing the reference. - if ($body !== $this->_body) { - $this->_body = $body; - } - - return $this->_body; - } - - $this->_body = null; - return null; - } - - public function __set_body($value) { - # On setting, the following algorithm must be run: - # - # 1. If the new value is not a body or frameset element, then throw a - # "HierarchyRequestError" DOMException. - if (!$value instanceof Element || $value->namespaceURI !== null) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - if ($value->nodeName !== 'body' && $value->nodeName !== 'frameset') { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - - if ($this->_body !== null) { - # 2. Otherwise, if the new value is the same as the body element, return. - if ($value->isSameNode($this->_body)) { - return; - } - - # 3. Otherwise, if the body element is not null, then replace the body element - # with the new value within the body element's parent and return. - $this->documentElement->replaceChild($value, $this->_body); - $this->_body = $value; - return; - } - - # 4. Otherwise, if there is no document element, throw a "HierarchyRequestError" - # DOMException. - if ($this->documentElement === null) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - - # 5. Otherwise, the body element is null, but there's a document element. Append - # the new value to the document element. - $this->documentElement->appendChild($value); - $this->_body = $value; - } - - public function __get_xpath(): \DOMXPath { - if ($this->_xpath === null) { - $this->_xpath = new \DOMXPath($this); - } - return $this->_xpath; - } - - - public function __construct($source = null, ?string $encodingOrContentType = null) { - // Because we cannot have union types until php 8... :) - if ($source !== null && !$source instanceof \DOMDocument && !is_string($source)) { - throw new DOMException(DOMException::ARGUMENT_TYPE_ERROR, 1, 'source', 'string|\DOMDocument', gettype($source)); - } elseif ($source instanceof self) { - return $source; - } - - parent::__construct(); - - $this->registerNodeClass('DOMDocument', '\MensBeam\HTML\Document'); - $this->registerNodeClass('DOMComment', '\MensBeam\HTML\Comment'); - $this->registerNodeClass('DOMDocumentFragment', '\MensBeam\HTML\DocumentFragment'); - $this->registerNodeClass('DOMElement', '\MensBeam\HTML\Element'); - $this->registerNodeClass('DOMProcessingInstruction', '\MensBeam\HTML\ProcessingInstruction'); - $this->registerNodeClass('DOMText', '\MensBeam\HTML\Text'); - - if ($source !== null) { - if (is_string($source)) { - $source = Parser::parse($source, null, $encodingOrContentType); - } - - foreach ($source->childNodes as $child) { - if (!$child instanceof \DOMDocumentType) { - $this->appendChild($this->importNode($child, true)); - } else { - $this->appendChild($this->implementation->createDocumentType($child->name ?? ' ', $child->public ?? '', $child->system ?? '')); - } - } - } - } - - - public function createAttribute($name) { - return $this->createAttributeNS(null, $name); - } - - public function createAttributeNS($namespaceURI, $qualifiedName) { - // Normalize the attribute name and namespace URI per modern DOM specifications. - if ($namespaceURI !== null) { - $namespaceURI = trim($namespaceURI); - } - $qualifiedName = trim($qualifiedName); - - try { - return parent::createAttributeNS($namespaceURI, $qualifiedName); - } catch (\DOMException $e) { - // The element name is invalid for XML - // Replace any offending characters with "UHHHHHH" where H are the - // uppercase hexadecimal digits of the character's code point - $this->mangledAttributes = true; - if ($namespaceURI !== null) { - $qualifiedName = implode(":", array_map([$this, "coerceName"], explode(":", $qualifiedName, 2))); - } else { - $qualifiedName = $this->coerceName($qualifiedName); - } - return parent::createAttributeNS($namespaceURI, $qualifiedName); - } - } - - public function createElement($name, $value = "") { - return $this->createElementNS(null, $name, $value); - } - - public function createElementNS($namespaceURI, $qualifiedName, $value = "") { - // Normalize the element name and namespace URI per modern DOM specifications. - if ($namespaceURI !== null) { - $namespaceURI = trim($namespaceURI); - $namespaceURI = ($namespaceURI === Parser::HTML_NAMESPACE) ? null : $namespaceURI; - } - $qualifiedName = ($namespaceURI === null) ? strtolower(trim($qualifiedName)) : trim($qualifiedName); - - try { - if ($qualifiedName !== 'template' || $namespaceURI !== null) { - $e = parent::createElementNS($namespaceURI, $qualifiedName, $value); - } else { - $e = new TemplateElement($this, $qualifiedName, $value); - // Template elements need to have a reference kept in userland - ElementMap::set($e); - $e->content = $this->createDocumentFragment(); - } - - return $e; - } catch (\DOMException $e) { - // The element name is invalid for XML - // Replace any offending characters with "UHHHHHH" where H are the - // uppercase hexadecimal digits of the character's code point - $this->mangledElements = true; - if ($namespaceURI !== null) { - $qualifiedName = implode(":", array_map([$this, "coerceName"], explode(":", $qualifiedName, 2))); - } else { - $qualifiedName = $this->coerceName($qualifiedName); - } - return parent::createElementNS($namespaceURI, $qualifiedName, $value); - } - } - - public function createEntityReference($name): bool { - return false; - } - - public function load($filename, $options = null, ?string $encodingOrContentType = null): bool { - $data = Parser::fetchFile($filename, $encodingOrContentType); - if (!$data) { - return false; - } - [$data, $encodingOrContentType] = $data; - Parser::parse($data, $this, $encodingOrContentType, null, (string)$filename); - return true; - } - - public function loadHTML($source, $options = null, ?string $encodingOrContentType = null): bool { - if (!is_string($source)) { - throw new DOMException(DOMException::ARGUMENT_TYPE_ERROR, 1, 'source', 'string', gettype($source)); - } - - if (is_string($source)) { - $source = Parser::parse($source, null, $encodingOrContentType); - } - - foreach ($source->childNodes as $child) { - if (!$child instanceof \DOMDocumentType) { - $this->appendChild($this->importNode($child, true)); - } else { - $this->appendChild($this->implementation->createDocumentType($child->name ?? ' ', $child->public ?? '', $child->system ?? '')); - } - } - - assert(is_string($source), new DOMException(DOMException::STRING_EXPECTED, 'source', gettype($source))); - Parser::parse($source, $this, $encodingOrContentType); - return true; - } - - public function loadHTMLFile($filename, $options = null, ?string $encodingOrContentType = null): bool { - return $this->load($filename, $options, $encodingOrContentType); - } - - public function loadXML($source, $options = null): bool { - return false; - } - - public function save($filename, $options = null) { - return file_put_contents($filename, $this->serialize()); - } - - public function saveHTML(\DOMNode $node = null): string { - return $node->serialize($node); - } - - public function saveHTMLFile($filename): int { - return $this->save($filename); - } - - public function saveXML(?\DOMNode $node = null, $options = null): bool { - return false; - } - - public function serialize(\DOMNode $node = null): string { - $node = $node ?? $this; - $formatOutput = $this->formatOutput; - - if ($node !== $this) { - if (!$node->ownerDocument->isSameNode($this)) { - throw new DOMException(DOMException::WRONG_DOCUMENT); - } - - // This method is used to serialize any node. If not a Document or a - // DocumentFragment or a DocumentType clone the node in a fragment and serialize - // that. Otherwise, if a DocumentFragment create a new Document with a clone of - // the DocumentFragment as its doctype and then serialize the new document. - if (!$node instanceof Document && !$node instanceof DocumentFragment) { - // If the node isn't an element disable output formatting - if ($formatOutput && !$node instanceof Element) { - $formatOutput = false; - } - - if (!$node instanceof \DOMDocumentType) { - $frag = $this->createDocumentFragment(); - $frag->appendChild($node->cloneNode(true)); - $node = $frag; - } else { - $newDoc = new self(); - $newDoc->appendChild($newDoc->implementation->createDocumentType($node->name, $node->publicId, $node->systemId)); - $node = $newDoc; - } - } - } elseif ($formatOutput && $node instanceof DocumentFragment) { - // If node is a document fragment disable output formatting if the - // DocumentFragment doesn't have any Element children. - $formatOutput = ($node->childElementCount > 0); - } - - return $this->serializeFragment($node, $formatOutput); - } - - public function validate(): bool { - return true; - } - - public function xinclude($options = null): bool { - return false; - } - - - protected function preInsertionValidity(\DOMNode $node, ?\DOMNode $child = null) { - parent::preInsertionValidity($node, $child); - - # 6. If parent is a document, and any of the statements below, switched on node, - # are true, then throw a "HierarchyRequestError" DOMException. - # - # DocumentFragment node - # If node has more than one element child or has a Text node child. - # Otherwise, if node has one element child and either parent has an element - # child, child is a doctype, or child is non-null and a doctype is following - # child. - if ($node instanceof \DOMDocumentType) { - if ($node->childNodes->length > 1 || $node->firstChild instanceof Text) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } else { - if ($node->firstChild instanceof \DOMDocumentType) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - - foreach ($this->childNodes as $c) { - if ($c instanceof Element) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - } - - if ($child !== null) { - $n = $child; - while ($n = $n->nextSibling) { - if ($n instanceof \DOMDocumentType) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - } - } - } - } - # element - # parent has an element child, child is a doctype, or child is non-null and a - # doctype is following child. - elseif ($node instanceof Element) { - if ($child instanceof \DOMDocumentType) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - - if ($child !== null) { - $n = $child; - while ($n = $n->nextSibling) { - if ($n instanceof \DOMDocumentType) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - } - } - - foreach ($this->childNodes as $c) { - if ($c instanceof Element) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - } - } - - # doctype - # parent has a doctype child, child is non-null and an element is preceding - # child, or child is null and parent has an element child. - elseif ($node instanceof \DOMDocumentType) { - foreach ($this->childNodes as $c) { - if ($c instanceof \DOMDocumentType) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - } - - if ($child !== null) { - $n = $child; - while ($n = $n->prevSibling) { - if ($n instanceof Element) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - } - } else { - foreach ($this->childNodes as $c) { - if ($c instanceof Element) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - } - } - } - } - - protected function serializeBlockElementFilter(\DOMNode $ignoredNode): \Closure { - $blockElementFilter = function($n) use ($ignoredNode) { - if (!$n->isSameNode($ignoredNode) && $n instanceof Element && $n->namespaceURI === null && (in_array($n->nodeName, self::BLOCK_ELEMENTS) || $n->walk(function($nn) { - if ($nn instanceof Element && $nn->namespaceURI === null && in_array($nn->nodeName, self::BLOCK_ELEMENTS)) { - return true; - } - })->current() !== null)) { - return true; - } - }; - - return $blockElementFilter; - } - - protected function serializeFragment(\DOMNode $node, bool $formatOutput = false): string { - if ($formatOutput) { - // Stores the root foreign element when parsing its descendants - static $foreignElement = null; - // Flag used if the root foreign element above has block element siblings - static $foreignElementWithBlockElementSiblings = false; - // Stores the indention level - static $indent = 0; - // Stores the root preformatted element when parsing its descendants - static $preformattedElement = null; - // Stores the previous non text node name so it can be used to check for adding - // additional space. - static $previousNonTextNodeSiblingName = null; - } - - # 13.3. Serializing HTML fragments - # - # 1. If the node serializes as void, then return the empty string. - if (in_array($node->nodeName, self::VOID_ELEMENTS)) { - return ''; - } - - # 2. Let s be a string, and initialize it to the empty string. - $s = ''; - - # 3. If the node is a template element, then let the node instead be the - # template element’s template contents (a DocumentFragment node). - if ($node instanceof TemplateElement) { - $node = $node->content; - } - - $nodesLength = $node->childNodes->length; - # 4. For each child node of the node, in tree order, run the following steps: - ## 1. Let current node be the child node being processed. - foreach ($node->childNodes as $currentNode) { - $foreign = ($currentNode->namespaceURI !== null); - - if ($this->formatOutput) { - // Filter meant to be used with DOM walker generator methods which checks if - // elements are block or if elements are inline with block descendants - $blockElementFilter = self::serializeBlockElementFilter($currentNode->parentNode); - } - - # 2. Append the appropriate string from the following list to s: - # If current node is an Element - if ($currentNode instanceof Element) { - # If current node is an element in the HTML namespace, the MathML namespace, or - # the SVG namespace, then let tagname be current node's local name. Otherwise, - # let tagname be current node's qualified name. - $tagName = (!$foreign || $currentNode->namespaceURI === Parser::MATHML_NAMESPACE || $currentNode->namespaceURI === Parser::SVG_NAMESPACE) ? $currentNode->localName : $currentNode->nodeName; - - // Since tag names can contain characters that are invalid in PHP's XML DOM - // uncoerce the name when printing if necessary. - if (strpos($tagName, 'U') !== false) { - $tagName = $this->uncoerceName($tagName); - } - - if ($formatOutput) { - $blockElementFilter = self::serializeBlockElementFilter($currentNode); - $hasChildNodes = ($currentNode->hasChildNodes()); - $modify = false; - - if (!$foreign) { - if ($hasChildNodes && $preformattedElement === null && in_array($tagName, self::PREFORMATTED_ELEMENTS)) { - $preformattedElement = $currentNode; - } - - // If a block element, an inline element with block element siblings, or an - // inline element with block element descendants... - if (in_array($tagName, self::BLOCK_ELEMENTS) || $currentNode->parentNode->walkShallow($blockElementFilter)->current() !== null || ($hasChildNodes && $currentNode->walk($blockElementFilter)->current() !== null)) { - $modify = true; - } - } else { - // If a foreign element with block element siblings - if ($hasChildNodes && $foreignElement === null) { - $foreignElement = $currentNode; - if ($currentNode->parentNode->walkShallow($blockElementFilter)->current() !== null) { - $foreignElementWithBlockElementSiblings = true; - $modify = true; - } - } - // If a foreign element with a foreign element ancestor with block element - // siblings - elseif ($foreignElement !== null && $foreignElementWithBlockElementSiblings) { - $modify = true; - } - } - - if ($modify) { - // If the previous non text node sibling doesn't have the same name as the - // current node and neither are h1-h6 elements then add an additional newline. - if ($previousNonTextNodeSiblingName !== null && $previousNonTextNodeSiblingName !== $tagName && !(in_array($previousNonTextNodeSiblingName, self::H_ELEMENTS) && in_array($tagName, self::H_ELEMENTS))) { - $s .= "\n"; - } - - $s .= "\n" . str_repeat(' ', $indent); - } - } - - - # Append a U+003C LESS-THAN SIGN character (<), followed by tagname. - $s .= "<$tagName"; - - # If current node's is value is not null, and the element does not have an is - # attribute in its attribute list, then append the string " is="", followed by - # current node's is value escaped as described below in attribute mode, followed - # by a U+0022 QUOTATION MARK character ("). - // DEVIATION: There is no scripting support in this implementation. - - # For each attribute that the element has, append a U+0020 SPACE character, - # the attribute’s serialized name as described below, a U+003D EQUALS SIGN - # character (=), a U+0022 QUOTATION MARK character ("), the attribute’s value, - # escaped as described below in attribute mode, and a second U+0022 QUOTATION - # MARK character ("). - foreach ($currentNode->attributes as $attr) { - # An attribute’s serialized name for the purposes of the previous paragraph - # must be determined as follows: - switch ($attr->namespaceURI) { - # If the attribute has no namespace - case null: - # The attribute’s serialized name is the attribute’s local name. - $name = $attr->localName; - break; - # If the attribute is in the XML namespace - case Parser::XML_NAMESPACE: - # The attribute’s serialized name is the string "xml:" followed by the - # attribute’s local name. - $name = 'xml:' . $attr->localName; - break; - # If the attribute is in the XMLNS namespace... - case Parser::XMLNS_NAMESPACE: - # ...and the attribute’s local name is xmlns - if ($attr->localName === 'xmlns') { - # The attribute’s serialized name is the string "xmlns". - $name = 'xmlns'; - } - # ... and the attribute’s local name is not xmlns - else { - # The attribute’s serialized name is the string "xmlns:" followed by the - # attribute’s local name. - $name = 'xmlns:' . $attr->localName; - } - break; - # If the attribute is in the XLink namespace - case Parser::XLINK_NAMESPACE: - # The attribute’s serialized name is the string "xlink:" followed by the - # attribute’s local name. - $name = 'xlink:' . $attr->localName; - break; - # If the attribute is in some other namespace - default: - # The attribute’s serialized name is the attribute’s qualified name. - $name = $attr->nodeName; - } - // undo any name mangling - if (strpos($name, 'U') !== false) { - $name = $this->uncoerceName($name); - } - $value = $this->escapeString($attr->value, true); - $s .= " $name=\"$value\""; - } - - # While the exact order of attributes is UA-defined, and may depend on factors - # such as the order that the attributes were given in the original markup, the - # sort order must be stable, such that consecutive invocations of this - # algorithm serialize an element’s attributes in the same order. - // Okay. - - // When formatting output set the previous non text node sibling name to the - // current node name so void elements and empty foreign elements will be - // recognized by their next sibling. - if ($formatOutput) { - $previousNonTextNodeSiblingName = $tagName; - } - - # Append a U+003E GREATER-THAN SIGN character (>). - // DEVIATION: Printing XML-based content such as SVG as if it's HTML might be - // practical when a browser is serializing, but it's not in this library's - // usage. So, if the element is foreign and doesn't contain any children close - // the element instead and continue on to the next child node. - $hasChildNodes = $currentNode->hasChildNodes(); - if (!$foreign || $hasChildNodes) { - $s .= '>'; - } elseif (!$hasChildNodes) { - $s .= '/>'; - continue; - } - - # If current node serializes as void, then continue on to the next child node at - # this point. - if (in_array($currentNode->nodeName, self::VOID_ELEMENTS)) { - continue; - } - - if ($formatOutput) { - // If formatting output set the previous non text node sibling to null before - // serializing children. - $previousNonTextNodeSiblingName = null; - - // If formatting output and the element has already been modified increment the - // indention level - if ($modify) { - $indent++; - } - } - - # Append the value of running the HTML fragment serialization algorithm on the - # current node element (thus recursing into this algorithm for that element), - # followed by a U+003C LESS-THAN SIGN character (<), a U+002F SOLIDUS character (/), - # tagname again, and finally a U+003E GREATER-THAN SIGN character (>). - $s .= $this->serializeFragment($currentNode, $formatOutput); - - if ($formatOutput) { - if ($modify) { - // Decrement the indention level. - $indent--; - - if ($preformattedElement === null) { - // If a foreign element with a foreign element ancestor with block element - // siblings and has at least one element child or any element with a block - // element descendant... - if (($foreign && $foreignElementWithBlockElementSiblings && $currentNode->firstElementChild !== null) || ($currentNode->walk($blockElementFilter)->current() !== null)) { - $s .= "\n" . str_repeat(' ', $indent); - } - } - } - - if ($foreignElement !== null && $currentNode->isSameNode($foreignElement)) { - $foreignElement = null; - $foreignElementWithBlockElementSiblings = false; - } elseif ($preformattedElement !== null && $currentNode->isSameNode($preformattedElement)) { - $preformattedElement = null; - } - - // Set the previous text node sibling name to the current node's name so it may - // be recognized by the following sibling. - $previousNonTextNodeSiblingName = $tagName; - } - - $s .= ""; - } - # If current node is a Text node - elseif ($currentNode instanceof Text) { - $text = $currentNode->data; - - # If the parent of current node is a style, script, xmp, iframe, noembed, - # noframes, or plaintext element, or if the parent of current node is a noscript - # element and scripting is enabled for the node, then append the value of - # current node’s data IDL attribute literally. - if ($currentNode->parentNode->namespaceURI === null && in_array($currentNode->parentNode->nodeName, [ 'style', 'script', 'xmp', 'iframe', 'noembed', 'noframes', 'plaintext' ])) { - $s .= $text; - } - # Otherwise, append the value of current node’s data IDL attribute, escaped as - # described below. - else { - if ($formatOutput) { - if ($preformattedElement === null) { - // Condense spaces and tabs into a single space. - $text = preg_replace('/ +/', ' ', str_replace("\t", ' ', $text)); - if ($foreignElementWithBlockElementSiblings || $currentNode->parentNode->walk($blockElementFilter)->current() !== null) { - // If the text node's data is made up of only whitespace characters continue - // onto the next node - if (strspn($text, Data::WHITESPACE) === strlen($text)) { - continue; - } - - // Otherwise, remove newlines from the text node's data; if that causes the data - // to be empty then continue onto the next node. - $text = preg_replace('/[\n\x0C\x0D]+/', '', $text); - if ($text === '') { - continue; - } - } - } - } - - $s .= $this->escapeString($text); - } - } - # If current node is a Comment - elseif ($currentNode instanceof Comment) { - if ($formatOutput) { - if ($preformattedElement === null && $foreignElementWithBlockElementSiblings || $currentNode->parentNode->walk($blockElementFilter)->current() !== null) { - // Add an additional newline if the previous sibling wasn't a comment. - if ($previousNonTextNodeSiblingName !== null && $previousNonTextNodeSiblingName !== $this->nodeName) { - $s .= "\n"; - } - - $s .= "\n" . str_repeat(' ', $indent); - } - - $previousNonTextNodeSiblingName = $this->nodeName; - } - - # Append the literal string "" - # (U+002D HYPHEN-MINUS, U+002D HYPHEN-MINUS, U+003E GREATER-THAN SIGN). - $s .= ""; - } - # If current node is a ProcessingInstruction - elseif ($currentNode instanceof ProcessingInstruction) { - if ($formatOutput) { - if ($preformattedElement === null && $foreignElementWithBlockElementSiblings || $currentNode->parentNode->walk($blockElementFilter)->current() !== null) { - // Add an additional newline if the previous sibling wasn't a processing - // instruction. - if ($previousNonTextNodeSiblingName !== null && $previousNonTextNodeSiblingName !== $this->nodeName) { - $s .= "\n"; - } - - $s .= "\n" . str_repeat(' ', $indent); - } - - $previousNonTextNodeSiblingName = $this->nodeName; - } - - # Append the literal string "). - $s .= "target} {$currentNode->data}>"; - } - # If current node is a DocumentFragment - elseif ($currentNode instanceof \DOMDocumentType) { - # Append the literal string "" (U+003E - # GREATER-THAN SIGN). - // DEVIATION: The name is trimmed because PHP's DOM does not - // accept the empty string as a DOCTYPE name - $name = trim($node->childNodes->item(0)->name, ' '); - $s .= ""; - } - } - - # 5. Return s. - return $s; - } - - - public function __toString() { - return $this->serialize(); - } -} diff --git a/lib/DOM/DocumentFragment.php b/lib/DOM/DocumentFragment.php deleted file mode 100644 index 5a667e8..0000000 --- a/lib/DOM/DocumentFragment.php +++ /dev/null @@ -1,11 +0,0 @@ -=')) { - // Only create the class list if it is actually used. - if ($this->_classList === null) { - $this->_classList = new TokenList($this, 'class'); - } - return $this->_classList; - } - return null; // @codeCoverageIgnore - } - - public function __get_innerHTML(): string { - ### DOM Parsing Specification ### - # 2.3 The InnerHTML mixin - # - # On getting, return the result of invoking the fragment serializing algorithm - # on the context object providing true for the require well-formed flag (this - # might throw an exception instead of returning a string). - // DEVIATION: Parsing of XML documents will not be handled by this - // implementation, so there's no need for the well-formed flag. - return $this->ownerDocument->serialize($this); - } - - public function __set_innerHTML(string $value) { - ### DOM Parsing Specification ### - # 2.3 The InnerHTML mixin - # - # On setting, these steps must be run: - # 1. Let context element be the context object's host if the context object is a - # ShadowRoot object, or the context object otherwise. - // DEVIATION: There is no scripting in this implementation. - - # 2. Let fragment be the result of invoking the fragment parsing algorithm with - # the new value as markup, and with context element. - $fragment = Parser::parseFragment($value, $this->ownerDocument, 'UTF-8', $this); - - # 3. If the context object is a template element, then let context object be the - # template's template contents (a DocumentFragment). - if ($this->nodeName === 'template') { - $this->content = $fragment; - } - # 4. Replace all with fragment within the context object. - else { - # To replace all with a node within a parent, run these steps: - # - # 1. Let removedNodes be parent’s children. - // DEVIATION: removedNodes is used below for scripting. There is no scripting in - // this implementation. - - # 2. Let addedNodes be parent’s children. - // DEVIATION: addedNodes is used below for scripting. There is no scripting in - // this implementation. - - # 3. If node is a DocumentFragment node, then set addedNodes to node’s - # children. - - // DEVIATION: Again, there is no scripting in this implementation. - # 4. Otherwise, if node is non-null, set addedNodes to « node ». - // DEVIATION: Yet again, there is no scripting in this implementation. - - # 5. Remove all parent’s children, in tree order, with the suppress observers - # flag set. - // DEVIATION: There are no observers to suppress as there is no scripting in - // this implementation. - while ($this->hasChildNodes()) { - $this->removeChild($this->firstChild); - } - - # 6. Otherwise, if node is non-null, set addedNodes to « node ». - # If node is non-null, then insert node into parent before null with the - # suppress observers flag set. - // DEVIATION: Yet again, there is no scripting in this implementation. - - # 7. If either addedNodes or removedNodes is not empty, then queue a tree - # mutation record for parent with addedNodes, removedNodes, null, and null. - // DEVIATION: Normally the tree mutation record would do the actual replacement, - // but there is no scripting in this implementation. Going to simply append the - // fragment instead. - $this->appendChild($fragment); - } - } - - public function __get_nextElementSibling(): Element { - # The nextElementSibling getter steps are to return the first following sibling - # that is an element; otherwise null. - if ($this->parentNode !== null) { - $start = false; - foreach ($this->parentNode->childNodes as $child) { - if (!$start) { - if ($child->isSameNode($this)) { - $start = true; - } - - continue; - } - - if (!$child instanceof Element) { - continue; - } - - return $child; - } - } - - return null; - } - - public function __get_outerHTML(): string { - ### DOM Parsing Specification ### - # 2.4 Extensions to the Element interface - # outerHTML - # - # On getting, return the result of invoking the fragment serializing algorithm - # on a fictional node whose only child is the context object providing true for - # the require well-formed flag (this might throw an exception instead of - # returning a string). - // DEVIATION: Parsing of XML documents will not be handled by this - // implementation, so there's no need for the well-formed flag. - return $this->__toString(); - } - - public function __set_outerHTML(string $value) { - ### DOM Parsing Specification ### - # 2.4 Extensions to the Element interface - # outerHTML - # - # On setting, the following steps must be run: - # 1. Let parent be the context object's parent. - $parent = $this->parentNode; - - # 2. If parent is null, terminate these steps. There would be no way to obtain a - # reference to the nodes created even if the remaining steps were run. - // The spec is unclear here as to what to do. What do you return? Most browsers - // throw an exception here, so that's what we're going to do. - if ($parent === null) { - throw new DOMException(DOMException::OUTER_HTML_FAILED_NOPARENT); - } - # 3. If parent is a Document, throw a "NoModificationAllowedError" DOMException. - elseif ($parent instanceof Document) { - throw new DOMException(DOMException::NO_MODIFICATION_ALLOWED); - } - # 4. parent is a DocumentFragment, let parent be a new Element with: - # • body as its local name, - # • The HTML namespace as its namespace, and - # • The context object's node document as its node document. - elseif ($parent instanceof DocumentFragment) { - $parent = $this->ownerDocument->createElement('body'); - } - - # 5. Let fragment be the result of invoking the fragment parsing algorithm with - # the new value as markup, and parent as the context element. - $fragment = Parser::parseFragment($value, $this->ownerDocument, 'UTF-8', $parent); - - # 6. Replace the context object with fragment within the context object's - # parent. - $this->parentNode->replaceChild($fragment, $this); - } - - public function __get_previousElementSibling(): Element { - # The previousElementSibling getter steps are to return the first preceding - # sibling that is an element; otherwise null. - if ($this->parentNode !== null) { - foreach ($this->parentNode->childNodes as $child) { - if ($child->isSameNode($this)) { - return null; - } - - if (!$child instanceof Element) { - continue; - } - - return $child; - } - } - - return null; - } - - - public function getAttribute($name) { - // Newer versions of the DOM spec have getAttribute return an empty string only - // when the attribute exists and is empty, otherwise null. This fixes that. - $value = parent::getAttribute($name); - if ($value === '' && !parent::hasAttribute($name)) { - // the PHP DOM does not acknowledge the presence of XMLNS-namespace attributes - foreach ($this->attributes as $a) { - if ($a->nodeName === $name) { - return $a->value; - } - } - return null; - } - return $value; - } - - public function getAttributeNS($namespaceURI, $localName) { - // Newer versions of the DOM spec have getAttributeNS return an empty string - // only when the attribute exists and is empty, otherwise null. This fixes that. - $value = parent::getAttributeNS($namespaceURI, $localName); - if ($value === '' && !$this->hasAttributeNS($namespaceURI, $localName)) { - return null; - } - return $value; - } - - public function hasAttribute($name) { - if (!parent::hasAttribute($name)) { - foreach ($this->attributes as $a) { - if ($a->nodeName === $name) { - return true; - } - } - return false; - } - return true; - } - - public function setAttribute($name, $value) { - $this->setAttributeNS(null, $name, $value); - } - - public function setAttributeNS($namespaceURI, $qualifiedName, $value) { - // Normalize the attribute name and namespace URI per modern DOM specifications. - if ($namespaceURI !== null) { - $namespaceURI = trim($namespaceURI); - } - $qualifiedName = trim($qualifiedName); - if ($namespaceURI === null && ($this->namespaceURI ?? Parser::HTML_NAMESPACE) === Parser::HTML_NAMESPACE && !$this->hasAttributeNS($namespaceURI, $qualifiedName)) { - $qualifiedName = trim(strtolower($qualifiedName)); - } - // If setting a class attribute and classList has been invoked use classList to - // set it. - if ($qualifiedName === 'class' && $namespaceURI === null && $this->_classList !== null) { - $this->_classList->value = $value; - } elseif ($namespaceURI === Parser::XMLNS_NAMESPACE) { - // NOTE: We create attribute nodes so that xmlns attributes - // don't get lost; otherwise they cannot be serialized - $a = @$this->ownerDocument->createAttributeNS($namespaceURI, $qualifiedName); - if ($a === false) { - // The document element does not exist yet, so we need - // to insert this element into the document - $this->ownerDocument->appendChild($this); - $a = $this->ownerDocument->createAttributeNS($namespaceURI, $qualifiedName); - $this->ownerDocument->removeChild($this); - } - $a->value = $this->escapeString($value, true); - $this->setAttributeNodeNS($a); - } else { - try { - parent::setAttributeNS($namespaceURI, $qualifiedName, $value); - } catch (\DOMException $e) { - // The attribute name is invalid for XML - // Replace any offending characters with "UHHHHHH" where H are the - // uppercase hexadecimal digits of the character's code point - $this->ownerDocument->mangledAttributes = true; - if ($namespaceURI !== null) { - $qualifiedName = implode(":", array_map([$this, "coerceName"], explode(":", $qualifiedName, 2))); - } else { - $qualifiedName = $this->coerceName($qualifiedName); - } - parent::setAttributeNS($namespaceURI, $qualifiedName, $value); - } - if ($qualifiedName === "id" && $namespaceURI === null) { - $this->setIdAttribute($qualifiedName, true); - } - } - } - - public function setAttributeNode(\DOMAttr $attribute) { - return $this->setAttributeNodeNS($attribute, null); - } - - public function setAttributeNodeNS(\DOMAttr $attribute) { - $fixId = false; - if ($attribute->namespaceURI === null) { - if ($attribute->name === 'id') { - $fixId = true; - } - // If appending a class attribute node, and classList has been invoked set - // the class using classList instead of appending the attribute node. Will - // return the created node instead. TokenList appends an attribute node - // internally to set the class attribute, so to prevent an infinite call loop - // from occurring, a check between the normalized value and classList's - // serialized value is performed. The spec is vague on how this is supposed to - // be handled. - elseif ($this->_classList !== null && $attribute->name === 'class' && preg_replace(Data::WHITESPACE_REGEX, ' ', $attribute->value) !== $this->_classList->value) { - $this->_classList->value = $attribute->value; - return $this->getAttributeNode('class'); - } - } - $result = parent::setAttributeNodeNS($attribute); - if ($fixId) { - $this->setIdAttribute($attribute->name, true); - } - return $result; - } -} diff --git a/lib/DOM/ElementMap.php b/lib/DOM/ElementMap.php deleted file mode 100644 index 17b3a21..0000000 --- a/lib/DOM/ElementMap.php +++ /dev/null @@ -1,70 +0,0 @@ - $v) { - if ($v->isSameNode($element)) { - unset(self::$_storage[$k]); - self::$_storage = array_values(self::$_storage); - return true; - } - } - - return false; - } - - public static function destroy(Document $document) { - $changed = false; - foreach (self::$_storage as $k => $v) { - if ($v->ownerDocument->isSameNode($document)) { - unset(self::$_storage[$k]); - $changed = true; - } - } - - if ($changed) { - self::$_storage = array_values(self::$_storage); - return true; - } - - return false; - } - - public static function getIterator(): \Traversable { - foreach (self::$_storage as $v) { - yield $v; - } - } - - public static function has(Element $element) { - foreach (self::$_storage as $v) { - if ($v->isSameNode($element)) { - return true; - } - } - - return false; - } - - public static function set(Element $element) { - if (!self::has($element)) { - self::$_storage[] = $element; - return true; - } - - return false; - } -} diff --git a/lib/DOM/ProcessingInstruction.php b/lib/DOM/ProcessingInstruction.php deleted file mode 100644 index 878dafc..0000000 --- a/lib/DOM/ProcessingInstruction.php +++ /dev/null @@ -1,11 +0,0 @@ -createDocumentFragment(); - $frag->appendChild($this); - $frag->removeChild($this); - unset($frag); - } - - public function __destruct() { - ElementMap::delete($this); - } -} diff --git a/lib/DOM/TokenList.php b/lib/DOM/TokenList.php deleted file mode 100644 index aa8de20..0000000 --- a/lib/DOM/TokenList.php +++ /dev/null @@ -1,317 +0,0 @@ -_length; - } - - public function __get_value(): string { - return $this->__toString(); - } - - public function __set_value(string $value) { - $this->tokenSet = $this->parseOrderedSet($value); - $this->_length = count($this->tokenSet); - } - - - public function __construct(\DOMElement $element, string $attributeLocalName) { - # A DOMTokenList object also has an associated element and an attribute’s local - # name. - - # When a DOMTokenList object is created, then: - # - # 1. Let element be associated element. - // Using a weak reference here to prevent a circular reference. - $this->element = \WeakReference::create($element); - # 2. Let localName be associated attribute’s local name. - $this->localName = $attributeLocalName; - # 3. Let value be the result of getting an attribute value given element and - # localName. - $value = $element->getAttribute($attributeLocalName); - # 4. Run the attribute change steps for element, localName, value, value, and - # null. - $this->attributeChange($attributeLocalName, $value, $value); - } - - public function add(...$tokens) { - # 1. For each token in tokens: - foreach ($tokens as $token) { - # 1. If token is the empty string, then throw a "SyntaxError" DOMException. - if ($token === '') { - throw new DOMException(DOMException::SYNTAX_ERROR); - } - - # 2. If token contains any ASCII whitespace, then throw an - # "InvalidCharacterError" DOMException. - if (preg_match(Data::WHITESPACE_REGEX, $token)) { - throw new DOMException(DOMException::INVALID_CHARACTER); - } - } - - # 2. For each token in tokens, append token to this’s token set. - foreach ($tokens as $token) { - if (!in_array($token, $this->tokenSet)) { - // The spec does not say to trim, but browsers do. - $this->tokenSet[] = trim($token); - $this->_length++; - } - } - - # 3. Run the update steps. - $this->update(); - } - - public function contains(string $token): bool { - return (in_array($token, $this->tokenSet)); - } - - public function count(): int { - return $this->_length; - } - - public function current() { - return $this->item($this->position); - } - - public function item(int $index): string { - return $this->tokenSet[$index]; - } - - public function key() { - return $this->position; - } - - public function next() { - ++$this->position; - } - - public function rewind() { - $this->position = 0; - } - - public function offsetExists($offset) { - return $this->contains($offset); - } - - public function offsetGet($offset): string { - return $this->item($offset); - } - - public function offsetSet($offset, $value) { - $this->add($offset); - } - - public function offsetUnset($offset) { - $this->remove($offset); - } - - public function remove(...$tokens) { - # 1. For each token in tokens: - foreach ($tokens as $token) { - # 1. If token is the empty string, then throw a "SyntaxError" DOMException. - if ($token === '') { - throw new DOMException(DOMException::SYNTAX_ERROR); - } - - # 2. If token contains any ASCII whitespace, then throw an - # "InvalidCharacterError" DOMException. - if (preg_match(Data::WHITESPACE_REGEX, $token)) { - throw new DOMException(DOMException::INVALID_CHARACTER); - } - } - - # For each token in tokens, remove token from this’s token set. - $changed = false; - foreach ($tokens as $token) { - if (in_array($token, $this->tokenSet)) { - unset($this->tokenSet[$token]); - $this->_length--; - $changed = true; - } - } - - if ($changed) { - $this->tokenSet = array_values($this->tokenSet); - } - - # 3. Run the update steps. - $this->update(); - } - - public function replace(string $token, string $newToken): bool { - # 1. If either token or newToken is the empty string, then throw a "SyntaxError" - # DOMException. - if ($token === '' || $newToken === '') { - throw new DOMException(DOMException::SYNTAX_ERROR); - } - - # 2. If either token or newToken contains any ASCII whitespace, then throw an - # "InvalidCharacterError" DOMException. - if (preg_match(Data::WHITESPACE_REGEX, $token) || preg_match(Data::WHITESPACE_REGEX, $newToken)) { - throw new DOMException(DOMException::INVALID_CHARACTER); - } - - // The spec does not say to trim, but browsers do. - $token = trim($token); - $newToken = trim($token); - - # 3. If this’s token set does not contain token, then return false. - if (!isset($this->tokenSet[$token])) { - return false; - } - - # 4. Replace token in this’s token set with newToken. - $index = array_search($token, $this->tokenSet); - $this->tokenSet[$index] = $newToken; - - # 5. Run the update steps. - $this->update(); - - # 6. Return true. - return true; - } - - public function supports(string $token): bool { - # 1. Let result be the return value of validation steps called with token. - # 2. Return result. - # - # A DOMTokenList object’s validation steps for a given token are: - # - # 1. If the associated attribute’s local name does not define supported tokens, - # throw a TypeError. - # 2. Let lowercase token be a copy of token, in ASCII lowercase. - # 3. If lowercase token is present in supported tokens, return true. - # 4. Return false. - - // This class is presently only used for Element::classList, and it supports any - // valid class name as a token. So, there's nothing to do here at the moment. - // Just return true. - return true; - } - - public function toggle(string $token, ?bool $force = false): bool { - # 1. If token is the empty string, then throw a "SyntaxError" DOMException. - if ($token === '') { - throw new DOMException(DOMException::SYNTAX_ERROR); - } - - # 2. If token contains any ASCII whitespace, then throw an - # "InvalidCharacterError" DOMException. - if (preg_match(Data::WHITESPACE_REGEX, $token)) { - throw new DOMException(DOMException::INVALID_CHARACTER); - } - - # 3. If this’s token set[token] exists, then: - if (isset($this->tokenSet[$token])) { - # 1. If force is either not given or is false, then remove token from this’s - # token set, run the update steps and return false. - if (!$force) { - $this->remove($token); - return false; - } - - # 2. Return true. - return true; - } - # 4. Otherwise, if force not given or is true, append token to this’s token set, - # run the update steps, and return true. - else { - $this->add($token); - return true; - } - - # 5. Return false. - return false; - } - - public function valid() { - return array_key_exists($this->position, $this->tokenSet); - } - - - protected function attributeChange(string $localName, ?string $oldValue = null, ?string $value = null, ?string $namespace = null) { - # A DOMTokenList object has these attribute change steps for its associated - # element: - # - # 1. If localName is associated attribute’s local name, namespace is null, and - # value is null, then empty token set. - if ($localName !== $this->localName || $namespace !== null) { - return; - } - - if ($value === null) { - $this->tokenSet = []; - $this->tokenKeys = []; - $this->_length = 0; - } - # 2. Otherwise, if localName is associated attribute’s local name, namespace is - # null, then set token set to value, parsed. - else { - $this->tokenSet = $this->parseOrderedSet($value); - $this->_length = count($this->tokenSet); - } - } - - protected function parseOrderedSet(string $input) { - if ($input === '') { - return []; - } - - # The ordered set parser takes a string input and then runs these steps: - # - # 1. Let inputTokens be the result of splitting input on ASCII whitespace. - // There isn't a Set object in php, so make sure all the tokens are unique. - $inputTokens = array_unique(preg_split(Data::WHITESPACE_REGEX, $input)); - - # 2. Let tokens be a new ordered set. - # 3. For each token in inputTokens, append token to tokens. - # 4. Return tokens. - // There isn't a Set object in php, so just return the uniqued input tokens. - return $inputTokens; - } - - protected function update() { - # A DOMTokenList object’s update steps are: - # - # 1. If the associated element does not have an associated attribute and token - # set is empty, then return. - // Not sure what this is about. This class is constructed with a provided - // associated element and attribute; there is no need to do this. - - # 2. Set an attribute value for the associated element using associated - # attribute’s local name and the result of running the ordered set serializer - # for token set. - $element = $this->element->get(); - $class = $element->ownerDocument->createAttribute($this->localName); - $class->value = $this->__toString(); - $element->setAttributeNode($class); - } - - - public function __toString(): string { - # The ordered set serializer takes a set and returns the concatenation of set - # using U+0020 SPACE. - return implode(' ', $this->tokenSet); - } -} diff --git a/lib/DOM/traits/ContainerNode.php b/lib/DOM/traits/ContainerNode.php deleted file mode 100644 index 7656400..0000000 --- a/lib/DOM/traits/ContainerNode.php +++ /dev/null @@ -1,104 +0,0 @@ -preInsertionValidity($node); - - $result = parent::appendChild($node); - if ($result !== false && $result instanceof TemplateElement) { - if ($result instanceof TemplateElement) { - ElementMap::set($result); - } - } - return $result; - } - - public function insertBefore($node, $child = null) { - $this->preInsertionValidity($node, $child); - - $result = parent::insertBefore($node, $child); - if ($result !== false) { - if ($result instanceof TemplateElement) { - ElementMap::set($result); - } - if ($child instanceof TemplateElement) { - ElementMap::delete($child); - } - } - return $result; - } - - public function removeChild($child) { - $result = parent::removeChild($child); - if ($result !== false && $result instanceof TemplateElement) { - ElementMap::delete($child); - } - return $result; - } - - public function replaceChild($node, $child) { - $result = parent::replaceChild($node, $child); - if ($result !== false) { - if ($result instanceof TemplateElement) { - ElementMap::set($child); - } - if ($child instanceof TemplateElement) { - ElementMap::delete($child); - } - } - return $result; - } - - - protected function preInsertionValidity(\DOMNode $node, ?\DOMNode $child = null) { - // "parent" in the spec comments below is $this - - # 1. If parent is not a Document, DocumentFragment, or Element node, then throw - # a "HierarchyRequestError" DOMException. - // Not necessary because they've been disabled and return hierarchy request - // errors in "leaf nodes". - - # 2. If node is a host-including inclusive ancestor of parent, then throw a - # "HierarchyRequestError" DOMException. - # - # An object A is a host-including inclusive ancestor of an object B, if either - # A is an inclusive ancestor of B, or if B’s root has a non-null host and A is a - # host-including inclusive ancestor of B’s root’s host. - // DEVIATION: The baseline for this library is PHP 7.1, and without - // WeakReferences we cannot add a host property to DocumentFragment to check - // against. - // This is handled just fine by PHP's DOM. - - # 3. If child is non-null and its parent is not parent, then throw a - # "NotFoundError" DOMException. - // This is handled just fine by PHP's DOM. - - # 4. If node is not a DocumentFragment, DocumentType, Element, Text, - # ProcessingInstruction, or Comment node, then throw a "HierarchyRequestError" - # DOMException. - if (!$node instanceof DocumentFragment && !$node instanceof \DOMDocumentType && !$node instanceof Element && !$node instanceof Text && !$node instanceof ProcessingInstruction && !$node instanceof Comment) { - throw new DOMException(DOMException::HIERARCHY_REQUEST_ERROR); - } - - # 5. If either node is a Text node and parent is a document, or node is a - # doctype and parent is not a document, then throw a "HierarchyRequestError" - # DOMException. - // Not necessary because they've been disabled and return hierarchy request - // errors in "leaf nodes". - - # 6. If parent is a document, and any of the statements below, switched on node, - # are true, then throw a "HierarchyRequestError" DOMException. - // Handled by the Document class. - } -} diff --git a/lib/DOM/traits/DocumentOrElement.php b/lib/DOM/traits/DocumentOrElement.php deleted file mode 100644 index 44739d8..0000000 --- a/lib/DOM/traits/DocumentOrElement.php +++ /dev/null @@ -1,57 +0,0 @@ -ownerDocument; - - ## 2. Let tokens be a new ordered set. - ## 3. For each token in inputTokens, append token to tokens. - ## 4. Return tokens. - // There isn't a Set object in php, so just use the uniqued input tokens. - - # 2. If classes is the empty set, return an empty HTMLCollection. - // DEVIATION: We can't do that, so let's create a bogus Xpath query instead. - if ($inputTokens === []) { - $ook = $document->createElement('ook'); - $query = $document->xpath->query('//eek', $ook); - unset($ook); - return $query; - } - - # 3. Return a HTMLCollection rooted at root, whose filter matches descendant - # elements that have all their classes in classes. - # - # The comparisons for the classes must be done in an ASCII case-insensitive manner - # if root’s node document’s mode is "quirks"; otherwise in an identical to manner. - // DEVIATION: Since we can't just create a \DOMNodeList we must instead query the document with XPath with the root element to get a list. - - $query = '//*'; - foreach ($inputTokens as $token) { - $query .= "[@class=\"$token\"]"; - } - - return ($isDocument) ? $document->xpath->query($query) : $document->xpath->query($query, $this); - } -} \ No newline at end of file diff --git a/lib/DOM/traits/EscapeString.php b/lib/DOM/traits/EscapeString.php deleted file mode 100644 index 0dfff10..0000000 --- a/lib/DOM/traits/EscapeString.php +++ /dev/null @@ -1,56 +0,0 @@ -" character by the string ">". - return ($attribute) ? str_replace('"', '"', $string) : str_replace(['<', '>'], ['<', '>'], $string); - } - - protected function coerceName(string $name): string { - // This matches the inverse of the production of NameChar in XML 1.0, - // with the added exclusion of ":" from allowed characters - // See https://www.w3.org/TR/REC-xml/#NT-NameStartChar - preg_match_all('/[^\-\.0-9\x{B7}\x{300}-\x{36F}\x{203F}-\x{2040}A-Za-z_\x{C0}-\x{D6}\x{D8}-\x{F6}\x{F8}-\x{2FF}\x{370}-\x{37D}\x{37F}-\x{1FFF}\x{200C}-\x{200D}\x{2070}-\x{218F}\x{2C00}-\x{2FEF}\x{3001}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFFD}\x{10000}-\x{EFFFF}]/u', $name, $m); - foreach (array_unique($m[0], \SORT_STRING) as $c) { - $o = (new UTF8($c))->nextCode(); - $esc = "U".str_pad(strtoupper(dechex($o)), 6, "0", \STR_PAD_LEFT); - $name = str_replace($c, $esc, $name); - } - // Apply stricter rules to the first character - if (preg_match('/^[^A-Za-z_\x{C0}-\x{D6}\x{D8}-\x{F6}\x{F8}-\x{2FF}\x{370}-\x{37D}\x{37F}-\x{1FFF}\x{200C}-\x{200D}\x{2070}-\x{218F}\x{2C00}-\x{2FEF}\x{3001}-\x{D7FF}\x{F900}-\x{FDCF}\x{FDF0}-\x{FFFD}\x{10000}-\x{EFFFF}]/u', $name, $m)) { - $c = $m[0]; - $o = (new UTF8($c))->nextCode(); - $esc = "U".str_pad(strtoupper(dechex($o)), 6, "0", \STR_PAD_LEFT); - $name = $esc.substr($name, strlen($c)); - } - return $name; - } - - protected function uncoerceName(string $name): string { - preg_match_all('/U[0-9A-F]{6}/', $name, $m); - foreach (array_unique($m[0], \SORT_STRING) as $o) { - $c = UTF8::encode(hexdec(substr($o, 1))); - $name = str_replace($o, $c, $name); - } - return $name; - } -} diff --git a/lib/DOM/traits/LeafNode.php b/lib/DOM/traits/LeafNode.php deleted file mode 100644 index 5367a93..0000000 --- a/lib/DOM/traits/LeafNode.php +++ /dev/null @@ -1,31 +0,0 @@ -getMagicPropertyMethodName($name); - if (!method_exists($this, $methodName)) { - trigger_error("Property \"$name\" does not exist", \E_USER_ERROR); - } - return call_user_func([ $this, $methodName ]); - } - - public function __isset(string $name): bool { - return (method_exists($this, $this->getMagicPropertyMethodName($name))); - } - - public function __set(string $name, $value) { - // If a setter method exists return that. - $methodName = $this->getMagicPropertyMethodName($name, false); - if (method_exists($this, $methodName)) { - call_user_func([ $this, $methodName ], $value); - return; - } - - // Otherwise, if a getter exists then trigger a readonly property fatal error. - // Finally, if a getter doesn't exist trigger a property does not exist fatal - // error. - if (method_exists($this, $this->getMagicPropertyMethodName($name))) { - trigger_error("Cannot write readonly property \"$name\"", \E_USER_ERROR); - } else { - trigger_error("Property \"$name\" does not exist", \E_USER_ERROR); - } - } - - public function __unset(string $name) { - $methodName = $this->getMagicPropertyMethodName($name, false); - if (!method_exists($this, $methodName)) { - trigger_error("Cannot write readonly property \"$name\"", \E_USER_ERROR); - } - - call_user_func([ $this, $methodName ], null); - } - - - private function getMagicPropertyMethodName(string $name, bool $get = true): string { - return "__" . (($get) ? 'get' : 'set') . "_{$name}"; - } -} \ No newline at end of file diff --git a/lib/DOM/traits/Moonwalk.php b/lib/DOM/traits/Moonwalk.php deleted file mode 100644 index 39d1eca..0000000 --- a/lib/DOM/traits/Moonwalk.php +++ /dev/null @@ -1,40 +0,0 @@ -moonwalkGenerator($this, $filter); - } - - private function moonwalkGenerator(\DOMNode $node, ?\Closure $filter = null) { - do { - while (true) { - if ($filter === null || $filter($node)) { - yield $node; - } - - // If node is an instance of DocumentFragment then it might be the content - // fragment of a template element, so iterate through all template elements - // stored in the element map and see if node is the fragment of one of the - // templates; if it is change node to the template element and reprocess. Magic! - // Can walk backwards THROUGH templates! - if ($node instanceof DocumentFragment) { - foreach (ElementMap::getIterator() as $element) { - if ($element->ownerDocument->isSameNode($node->ownerDocument) && $element instanceof TemplateElement && $element->content->isSameNode($node)) { - $node = $element; - continue; - } - } - } - - break; - } - } while ($node = $node->parentNode); - } -} diff --git a/lib/DOM/traits/MoonwalkShallow.php b/lib/DOM/traits/MoonwalkShallow.php deleted file mode 100644 index db97f02..0000000 --- a/lib/DOM/traits/MoonwalkShallow.php +++ /dev/null @@ -1,27 +0,0 @@ -content; - - $childNodesLength = $node->childNodes->length; - for ($childNodesLength = $node->childNodes->length, $i = $childNodesLength - 1; $i >= 0; $i--) { - $child = $node->childNodes[$i]; - if ($filter === null || $filter($child)) { - yield $child; - } - } - } -} diff --git a/lib/DOM/traits/Node.php b/lib/DOM/traits/Node.php deleted file mode 100644 index 9df990f..0000000 --- a/lib/DOM/traits/Node.php +++ /dev/null @@ -1,21 +0,0 @@ -=')) { - # 4.2.6. Mixin ParentNode - trait ParentNode { - public function __get_children(): \DOMNodeList { - # The children getter steps are to return an HTMLCollection collection rooted at - # this matching only element children. - // DEVIATION: HTMLCollection doesn't exist in PHP's DOM, and \DOMNodeList is - // almost identical; so, using that. PHP's DOM doesn't provide the end user any - // way to create a \DOMNodeList from scratch, so going to cheat and use XPath to - // make one for us. - - $isDocument = ($this instanceof Document); - $document = ($isDocument) ? $this : $this->ownerDocument; - return $document->xpath->query('//*', (!$isDocument) ? $this : null); - } - - public function replaceChildren(...$nodes) { - # The replaceChildren(nodes) method steps are: - # 1. Let node be the result of converting nodes into a node given nodes and - # this’s node document. - $node = $this->convertNodesToNode($nodes); - # 2. Ensure pre-insertion validity of node into this before null. - $this->preInsertionValidity($node); - # 3. Replace all with node within this. - # - # To replace all with a node within a parent, run these steps: - # 1. Let removedNodes be parent’s children. - $removedNodes = $this->childNodes; - # 2. Let addedNodes be the empty set. - $addedNodes = []; - # 3. If node is a DocumentFragment node, then set addedNodes to node’s children. - if ($node instanceof DocumentFragment) { - $addedNodes = $node->childNodes; - } - # 4. Otherwise, if node is non-null, set addedNodes to « node ». - elseif ($node !== null) { - $addedNodes = node; - } - # 5. Remove all parent’s children, in tree order, with the suppress observers - # flag set. - // DEVIATION: There is no scripting in this implementation, so cannnot set - // suppress observers flag. - while ($this->hasChildNodes()) { - $this->removeChild($this->firstChild); - } - # 6. If node is non-null, then insert node into parent before null with the - # suppress observers flag set. - // DEVIATION: There is no scripting in this implementation, so cannnot set - // suppress observers flag. - if ($node !== null) { - $this->appendChild($node); - } - # 7. If either addedNodes or removedNodes is not empty, then queue a tree - # mutation record for parent with addedNodes, removedNodes, null, and null. - // DEVIATION: There is no scripting in this implementation - } - - private function convertNodesToNode(array $nodes): \DOMNode { - # To convert nodes into a node, given nodes and document, run these steps: - # 1. Let node be null. - # 2. Replace each string in nodes with a new Text node whose data is the string - # and node document is document. - # 3. If nodes contains one node, then set node to nodes[0]. - # 4. Otherwise, set node to a new DocumentFragment node whose node document is - # document, and then append each node in nodes, if any, to it. - // The spec would have us iterate through the provided nodes and then iterate - // through them again to append. Let's optimize this a wee bit, shall we? - $document = ($this instanceof Document) ? $this : $this->ownerDocument; - $node = ($node->length > 1) ? $document->createDocumentFragment() : null; - foreach ($nodes as &$n) { - // Can't do union types until PHP 8... OTL - if (!$n instanceof \DOMNode && !is_string($n)) { - trigger_error(sprintf("Uncaught TypeError: %s::%s(): Argument #1 (\$%s) must be of type \DOMNode|string, %s given", __CLASS__, __METHOD__, 'nodes', gettype($n))); - } - - if (is_string($n)) { - $n = $this->ownerDocument->createTextNode($n); - } - - if ($node !== null) { - $node->appendChild($n); - } else { - $node = $n; - } - } - - return $node; - } - } -} else { - trait ParentNode { - public function __get_childElementCount(): int { - # The childElementCount getter steps are to return the number of children of - # this that are elements. - $count = 0; - foreach ($this->childNodes as $child) { - if ($child instanceof Element) { - $count++; - } - } - - return $count; - } - - public function __get_children(): \DOMNodeList { - # The children getter steps are to return an HTMLCollection collection rooted at - # this matching only element children. - // DEVIATION: HTMLCollection doesn't exist in PHP's DOM, and \DOMNodeList is - // almost identical; so, using that. PHP's DOM doesn't provide the end user any - // way to create a \DOMNodeList from scratch, so going to cheat and use XPath to - // make one for us. - - $isDocument = ($this instanceof Document); - $document = ($isDocument) ? $this : $this->ownerDocument; - return $document->xpath->query('//*', (!$isDocument) ? $this : null); - } - - public function __get_firstElementChild(): Element { - # The firstElementChild getter steps are to return the first child that is an - # element; otherwise null. - foreach ($this->childNodes as $child) { - if ($child instanceof Element) { - return $child; - } - } - return null; - } - - public function __get_lastElementChild(): Element { - # The lastElementChild getter steps are to return the last child that is an - # element; otherwise null. - for ($i = $this->childNodes->length - 1; $i >= 0; $i--) { - $child = $this->childNodes->item($i); - if ($child instanceof Element) { - return $child; - } - } - - return null; - } - - - public function append(...$nodes): void { - # The append(nodes) method steps are: - # 1. Let node be the result of converting nodes into a node given nodes and - # this’s node document. - $node = $this->convertNodesToNode($nodes); - # 2. Append node to this. - $this->appendChild($node); - } - - public function prepend(...$nodes): void { - # The prepend(nodes) method steps are: - # - # 1. Let node be the result of converting nodes into a node given nodes and - # this’s node document. - $node = $this->convertNodesToNode($nodes); - # 2. Pre-insert node into this before this’s first child. - $this->insertBefore($node, $this->firstChild); - } - - public function replaceChildren(...$nodes) { - # The replaceChildren(nodes) method steps are: - # 1. Let node be the result of converting nodes into a node given nodes and - # this’s node document. - $node = $this->convertNodesToNode($nodes); - # 2. Ensure pre-insertion validity of node into this before null. - $this->preInsertionValidity($node); - # 3. Replace all with node within this. - # - # To replace all with a node within a parent, run these steps: - # 1. Let removedNodes be parent’s children. - $removedNodes = $this->childNodes; - # 2. Let addedNodes be the empty set. - $addedNodes = []; - # 3. If node is a DocumentFragment node, then set addedNodes to node’s children. - if ($node instanceof DocumentFragment) { - $addedNodes = $node->childNodes; - } - # 4. Otherwise, if node is non-null, set addedNodes to « node ». - elseif ($node !== null) { - $addedNodes = node; - } - # 5. Remove all parent’s children, in tree order, with the suppress observers - # flag set. - // DEVIATION: There is no scripting in this implementation, so cannnot set - // suppress observers flag. - while ($this->hasChildNodes()) { - $this->removeChild($this->firstChild); - } - # 6. If node is non-null, then insert node into parent before null with the - # suppress observers flag set. - // DEVIATION: There is no scripting in this implementation, so cannnot set - // suppress observers flag. - if ($node !== null) { - $this->appendChild($node); - } - # 7. If either addedNodes or removedNodes is not empty, then queue a tree - # mutation record for parent with addedNodes, removedNodes, null, and null. - // DEVIATION: There is no scripting in this implementation - } - - private function convertNodesToNode(array $nodes): \DOMNode { - # To convert nodes into a node, given nodes and document, run these steps: - # 1. Let node be null. - # 2. Replace each string in nodes with a new Text node whose data is the string - # and node document is document. - # 3. If nodes contains one node, then set node to nodes[0]. - # 4. Otherwise, set node to a new DocumentFragment node whose node document is - # document, and then append each node in nodes, if any, to it. - // The spec would have us iterate through the provided nodes and then iterate - // through them again to append. Let's optimize this a wee bit, shall we? - $document = ($this instanceof Document) ? $this : $this->ownerDocument; - $node = ($node->length > 1) ? $document->createDocumentFragment() : null; - foreach ($nodes as &$n) { - // Can't do union types until PHP 8... OTL - if (!$n instanceof \DOMNode && !is_string($n)) { - trigger_error(sprintf("Uncaught TypeError: %s::%s(): Argument #1 (\$%s) must be of type \DOMNode|string, %s given", __CLASS__, __METHOD__, 'nodes', gettype($n))); - } - - if (is_string($n)) { - $n = $this->ownerDocument->createTextNode($n); - } - - if ($node !== null) { - $node->appendChild($n); - } else { - $node = $n; - } - } - - return $node; - } - } -} diff --git a/lib/DOM/traits/ToString.php b/lib/DOM/traits/ToString.php deleted file mode 100644 index 07e4edc..0000000 --- a/lib/DOM/traits/ToString.php +++ /dev/null @@ -1,15 +0,0 @@ -ownerDocument->createDocumentFragment(); - $frag->appendChild($this->cloneNode(true)); - return $this->ownerDocument->serialize($frag); - } -} diff --git a/lib/DOM/traits/Walk.php b/lib/DOM/traits/Walk.php deleted file mode 100644 index a198665..0000000 --- a/lib/DOM/traits/Walk.php +++ /dev/null @@ -1,31 +0,0 @@ -walkGenerator($this, $filter); - } - - private function walkGenerator(\DOMNode $node, ?\Closure $filter = null) { - if ($filter === null || $filter($node)) { - yield $node; - } - - if ($node instanceof TemplateElement) { - $node = $node->content; - } - - if ($node->hasChildNodes()) { - $children = $node->childNodes; - foreach ($children as $c) { - yield from $this->walkGenerator($c, $filter); - } - } - } -} diff --git a/lib/DOM/traits/WalkShallow.php b/lib/DOM/traits/WalkShallow.php deleted file mode 100644 index 33d2e09..0000000 --- a/lib/DOM/traits/WalkShallow.php +++ /dev/null @@ -1,24 +0,0 @@ -content; - - foreach ($node->childNodes as $child) { - if ($filter === null || $filter($child)) { - yield $child; - } - } - } -} diff --git a/lib/Parser.php b/lib/Parser.php index 1501b39..a692dc2 100644 --- a/lib/Parser.php +++ b/lib/Parser.php @@ -6,6 +6,16 @@ declare(strict_types=1); namespace MensBeam\HTML; +use MensBeam\HTML\Parser\Charset; +use MensBeam\HTML\Parser\Data; +use MensBeam\HTML\Parser\ParseError; +use MensBeam\HTML\Parser\ParseErrorDummy; +use MensBeam\HTML\Parser\OpenElementsStack; +use MensBeam\HTML\Parser\TemplateInsertionModesStack; +use MensBeam\HTML\Parser\Tokenizer; +use MensBeam\HTML\Parser\TreeBuilder; +use MensBeam\HTML\Parser\Output; + class Parser { public static $fallbackEncoding = "windows-1252"; @@ -30,7 +40,7 @@ class Parser { self::XMLNS_NAMESPACE => "xmlns", ]; - public static function parse(string $data, ?\DOMDocument $document = null, ?string $encodingOrContentType = null, ?\DOMElement $fragmentContext = null, ?String $file = null): \DOMDocument { + public static function parse(string $data, ?string $encodingOrContentType = null, ?\DOMDocument $document = null, ?\DOMElement $fragmentContext = null, ?int $fragmentQuirks = null, ?String $file = null): Output { // Initialize the various classes needed for parsing $document = $document ?? new \DOMDocument; if ((error_reporting() & \E_USER_WARNING)) { @@ -43,7 +53,7 @@ class Parser { $stack = new OpenElementsStack($fragmentContext); $tokenizer = new Tokenizer($decoder, $stack, $errorHandler); $tokenList = $tokenizer->tokenize(); - $treeBuilder = new TreeBuilder($document, $decoder, $tokenizer, $tokenList, $errorHandler, $stack, new TemplateInsertionModesStack, $fragmentContext); + $treeBuilder = new TreeBuilder($document, $decoder, $tokenizer, $tokenList, $errorHandler, $stack, new TemplateInsertionModesStack, $fragmentContext, $fragmentQuirks); // Override error handling $errorHandler->setHandler(); try { @@ -53,19 +63,22 @@ class Parser { // Restore error handling $errorHandler->clearHandler(); } - return $document; + // prepare the output + $out = new Output; + $out->document = $document; + $out->encoding = $decoder->encoding; + $out->quirksMode = $treeBuilder->quirksMode; + return $out; } - public static function parseFragment(string $data, ?\DOMDocument $document = null, ?string $encodingOrContentType = null, ?\DOMElement $fragmentContext = null, ?String $file = null): DocumentFragment { + public static function parseFragment(\DOMElement $fragmentContext, ?int $fragmentQuirks, string $data, ?string $encodingOrContentType = null, ?\DOMDocument $document = null, ?String $file = null): \DOMDocumentFragment { // Create the requisite parsing context if none was supplied $document = $document ?? new \DOMDocument; - $tempDocument = new \DOMDocument; - $fragmentContext = $fragmentContext ?? $document->createElement("div"); // parse the fragment into the temporary document - self::parse($data, $tempDocument, $encodingOrContentType, $fragmentContext, $file); + self::parse($data, $encodingOrContentType, $document, $fragmentContext, $fragmentQuirks, $file); // extract the nodes from the temp document into a fragment - $fragment = $document->createDocumentFragment(); - foreach ($tempDocument->documentElement->childNodes as $node) { + $fragment = $fragmentContext->ownerDocument->createDocumentFragment(); + foreach ($document->documentElement->childNodes as $node) { $node = $document->importNode($node, true); $fragment->appendChild($node); } diff --git a/lib/Parser/ActiveFormattingElementsList.php b/lib/Parser/ActiveFormattingElementsList.php index 0bd06e2..51a9b4a 100644 --- a/lib/Parser/ActiveFormattingElementsList.php +++ b/lib/Parser/ActiveFormattingElementsList.php @@ -4,7 +4,9 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace MensBeam\HTML; +namespace MensBeam\HTML\Parser; + +use MensBeam\HTML\Parser; # 8.2.3.3. The list of active formatting elements # Initially, the list of active formatting elements is empty. It is used to diff --git a/lib/Parser/CharacterReference.php b/lib/Parser/CharacterReference.php index d107a16..cdce32b 100644 --- a/lib/Parser/CharacterReference.php +++ b/lib/Parser/CharacterReference.php @@ -1,6 +1,6 @@ ({ - //map: ctx.options.map, - parser: 'postcss-scss', - //syntax: 'postcss-scss', - plugins: { - 'postcss-import': { root: ctx.file.dirname }, - 'postcss-discard-comments': {}, - 'postcss-sassy-mixins': {}, - 'postcss-custom-media': {preserve: false}, - 'postcss-media-minmax': {}, - 'postcss-custom-properties': {preserve: false}, - 'postcss-color-function': {}, - 'postcss-nested': {}, - 'autoprefixer': {}, - 'postcss-csso': {}, - } -}) diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d074e3c..1a16001 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -4,7 +4,7 @@ * See LICENSE and AUTHORS files for details */ declare(strict_types=1); -namespace MensBeam\HTML; +namespace MensBeam\HTML\Parser; const NS_BASE = __NAMESPACE__."\\"; define(NS_BASE."BASE", dirname(__DIR__).DIRECTORY_SEPARATOR); diff --git a/tests/cases/TestCharset.php b/tests/cases/TestCharset.php index 27e0ef4..a0082f9 100644 --- a/tests/cases/TestCharset.php +++ b/tests/cases/TestCharset.php @@ -6,10 +6,10 @@ declare(strict_types=1); namespace MensBeam\HTML\TestCase; -use MensBeam\HTML\Charset; +use MensBeam\HTML\Parser\Charset; /** - * @covers \MensBeam\HTML\Charset + * @covers \MensBeam\HTML\Parser\Charset */ class TestCharset extends \PHPUnit\Framework\TestCase { /** @dataProvider provideCharsets */ @@ -73,8 +73,8 @@ class TestCharset extends \PHPUnit\Framework\TestCase { $tests = []; $blacklist = []; $files = new \AppendIterator(); - $files->append(new \GlobIterator(\MensBeam\HTML\BASE."tests/html5lib-tests/encoding/*.dat", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); - $files->append(new \GlobIterator(\MensBeam\HTML\BASE."tests/cases/encoding/*.dat", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); + $files->append(new \GlobIterator(\MensBeam\HTML\Parser\BASE."tests/html5lib-tests/encoding/*.dat", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); + $files->append(new \GlobIterator(\MensBeam\HTML\Parser\BASE."tests/cases/encoding/*.dat", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); foreach ($files as $file) { if (!in_array(basename($file), $blacklist)) { $tests[] = $file; diff --git a/tests/cases/TestDOM.php b/tests/cases/TestDOM.php deleted file mode 100644 index c09c0ae..0000000 --- a/tests/cases/TestDOM.php +++ /dev/null @@ -1,318 +0,0 @@ -createElementNS($nsIn, $nameIn); - $this->assertSame($nsOut, $e->namespaceURI); - $this->assertSame($local, $e->localName); - $this->assertSame($prefix, $e->prefix); - } - - public function provideNamespacedElements(): iterable { - return [ - [null, "test", null, "test", ""], - [null, "test:test", null, "testU00003Atest", ""], - ["http://www.w3.org/2000/svg", "svg", "http://www.w3.org/2000/svg", "svg", ""], - ["http://www.w3.org/2000/svg", "svg:svg", "http://www.w3.org/2000/svg", "svg", "svg"], - ["fake_ns", "test:test", "fake_ns", "test", "test"], - ["fake_ns", "test:test:test", "fake_ns", "testU00003Atest", "test"], - ["fake_ns", "te st:test", "fake_ns", "test", "teU000020st"], - [null, "9", null, "U000039", ""], - ["http://www.w3.org/1999/xhtml", "test", null, "test", ""], - ["http://www.w3.org/1999/xhtml", "TEST", null, "test", ""], - [null, "TEST", null, "test", ""], - ["fake_ns", "TEST", "fake_ns", "TEST", ""], - ["http://www.w3.org/2000/svg", "TEST", "http://www.w3.org/2000/svg", "TEST", ""], - ["http://www.w3.org/1998/Math/MathML", "TEST", "http://www.w3.org/1998/Math/MathML", "TEST", ""], - ]; - } - /** - * @dataProvider provideBareElements - * @covers \MensBeam\HTML\Document::createElement - */ - public function testCreateBareElements(string $nameIn, $nameOut): void { - $d = new Document; - $e = $d->createElement($nameIn); - $this->assertNull($e->namespaceURI); - $this->assertSame("", $e->prefix); - $this->assertSame($nameOut, $e->localName); - } - - public function provideBareElements(): iterable { - return [ - ["test", "test"], - ["test:test", "testU00003Atest"], - ["9", "U000039"], - ["TEST", "test"], - ]; - } - - /** @covers \MensBeam\HTML\Document::createElementNS */ - public function testCreateTemplateElements(): void { - $d = new Document; - $t = $d->createElement("template"); - $this->assertInstanceOf(TemplateElement::class, $t); - $this->assertNotNull($t->ownerDocument); - $t = $d->createElement("TEMPLATE"); - $this->assertInstanceOf(TemplateElement::class, $t); - $this->assertNotNull($t->ownerDocument); - $t = $d->createElementNS(null, "template"); - $this->assertInstanceOf(TemplateElement::class, $t); - $this->assertNotNull($t->ownerDocument); - $t = $d->createElementNS(null, "TEMPLATE"); - $this->assertInstanceOf(TemplateElement::class, $t); - $this->assertNotNull($t->ownerDocument); - $t = $d->createElementNS("http://www.w3.org/1999/xhtml", "template"); - $this->assertInstanceOf(TemplateElement::class, $t); - $this->assertNotNull($t->ownerDocument); - $t = $d->createElementNS("http://www.w3.org/1999/xhtml", "TEMPLATE"); - $this->assertInstanceOf(TemplateElement::class, $t); - $this->assertNotNull($t->ownerDocument); - } - - /** - * @dataProvider provideNamespacedAttributeCreations - * @covers \MensBeam\HTML\Document::createAttributeNS - */ - public function testCreateNamespacedAttributes(?string $nsIn, string $nameIn, string $local, string $prefix): void { - $d = new Document; - $d->appendChild($d->createElement("html")); - $a = $d->createAttributeNS($nsIn, $nameIn); - $this->assertSame($local, $a->localName); - $this->assertSame($nsIn, $a->namespaceURI); - $this->assertSame($prefix, $a->prefix); - } - - public function provideNamespacedAttributeCreations(): iterable { - return [ - [null, "test", "test", ""], - [null, "test:test", "testU00003Atest", ""], - [null, "test", "test", ""], - [null, "TEST:TEST", "TESTU00003ATEST", ""], - ["fake_ns", "test", "test", ""], - ["fake_ns", "test:test", "test", "test"], - ["fake_ns", "TEST:TEST", "TEST", "TEST"], - ["fake_ns", "test:test:test", "testU00003Atest", "test"], - ["fake_ns", "TEST:TEST:TEST", "TESTU00003ATEST", "TEST"], - ]; - } - - /** - * @dataProvider provideBareAttributeCreations - * @covers \MensBeam\HTML\Document::createAttribute - */ - public function testCreateBareAttributes(string $nameIn, string $nameOut): void { - $d = new Document; - $d->appendChild($d->createElement("html")); - $a = $d->createAttribute($nameIn); - $this->assertSame($nameOut, $a->name); - $this->assertNull($a->namespaceURI); - } - - public function provideBareAttributeCreations(): iterable { - return [ - ["test", "test"], - ["test:test", "testU00003Atest"], - ["TEST", "TEST"], - ["TEST:TEST", "TESTU00003ATEST"], - ]; - } - - /** - * @dataProvider provideNamespacedAttributeSettings - * @covers \MensBeam\HTML\Element::setAttributeNS - */ - public function testSetNamespoacedAttributes(?string $elementNS, ?string $attrNS, string $nameIn, string $nameOut): void { - $d = new Document; - $e = $d->createElementNS($elementNS, "test"); - $this->assertSame(0, $e->attributes->length); - $e->setAttributeNS($attrNS, $nameIn, "test"); - $this->assertSame(1, $e->attributes->length); - $a = $e->attributes[0]; - $this->assertSame($nameOut, $a->nodeName); - $this->assertSame($attrNS, $a->namespaceURI); - } - - public function provideNamespacedAttributeSettings(): iterable { - return [ - [null, null, "test", "test"], - [null, null, "TEST", "test"], - ["http://www.w3.org/1999/xhtml", null, "test", "test"], - ["http://www.w3.org/1999/xhtml", null, "TEST", "test"], - [null, null, "test:test", "testU00003Atest"], - [null, null, "TEST:TEST", "testU00003Atest"], - ["http://www.w3.org/1999/xhtml", null, "test:test", "testU00003Atest"], - ["http://www.w3.org/1999/xhtml", null, "TEST:TEST", "testU00003Atest"], - [null, "http://www.w3.org/1999/xhtml", "test:test", "test:test"], - [null, "http://www.w3.org/1999/xhtml", "TEST:TEST", "TEST:TEST"], - ["http://www.w3.org/1998/Math/MathML", null, "test", "test"], - ["http://www.w3.org/1998/Math/MathML", null, "TEST", "TEST"], - [null, "http://www.w3.org/2000/xmlns/", "xmlns:xlink", "xmlns:xlink"], - [null, "http://www.w3.org/2000/xmlns/", "xmlns:XLINK", "xmlns:XLINK"], - [null, "fake_ns", "test:test:test", "test:testU00003Atest"], - [null, "fake_ns", "TEST:TEST:TEST", "TEST:TESTU00003ATEST"], - ]; - } - - /** - * @dataProvider provideBareAttributeSettings - * @covers \MensBeam\HTML\Element::setAttribute - */ - public function testSetBareAttributes(?string $elementNS, string $nameIn, string $nameOut): void { - $d = new Document; - $e = $d->createElementNS($elementNS, "test"); - $this->assertSame(0, $e->attributes->length); - $e->setAttribute($nameIn, "test"); - $this->assertSame(1, $e->attributes->length); - $a = $e->attributes[0]; - $this->assertSame($nameOut, $a->nodeName); - $this->assertNull($a->namespaceURI); - } - - public function provideBareAttributeSettings(): iterable { - return [ - [null, "test", "test"], - [null, "TEST", "test"], - ["http://www.w3.org/1999/xhtml", "test", "test"], - ["http://www.w3.org/1999/xhtml", "TEST", "test"], - [null, "test:test", "testU00003Atest"], - [null, "TEST:TEST", "testU00003Atest"], - ["http://www.w3.org/1999/xhtml", "test:test", "testU00003Atest"], - ["http://www.w3.org/1999/xhtml", "TEST:TEST", "testU00003Atest"], - ["http://www.w3.org/1998/Math/MathML", "test", "test"], - ["http://www.w3.org/1998/Math/MathML", "TEST", "TEST"], - ]; - } - - /** - * @dataProvider provideAttributeNodeSettings - * @covers \MensBeam\HTML\Element::setAttributeNode - * @covers \MensBeam\HTML\Element::setAttributeNodeNS - */ - public function testSetAttributeNodes(bool $ns, ?string $elementNS, ?string $attrNS, string $name): void { - $d = new Document; - $e = $d->createElementNS($elementNS, "test"); - $d->appendChild($e); - $this->assertSame(0, $e->attributes->length); - $a = $d->createAttributeNS($attrNS, $name); - if ($ns) { - $e->setAttributeNodeNS($a); - } else { - $e->setAttributeNode($a); - } - $this->assertSame(1, $e->attributes->length); - $a = $e->attributes[0]; - $this->assertSame($name, $a->nodeName); - $this->assertSame($attrNS, $a->namespaceURI); - } - - public function provideAttributeNodeSettings(): iterable { - return [ - [true, null, null, "test"], - [true, null, null, "TEST"], - [true, "http://www.w3.org/1999/xhtml", null, "test"], - [true, "http://www.w3.org/1999/xhtml", null, "TEST"], - [true, null, null, "testU00003Atest"], - [true, null, null, "TESTU00003ATEST"], - [true, "http://www.w3.org/1999/xhtml", null, "testU00003Atest"], - [true, "http://www.w3.org/1999/xhtml", null, "TESTU00003ATEST"], - [true, null, "http://www.w3.org/1999/xhtml", "test:test"], - [true, null, "http://www.w3.org/1999/xhtml", "TEST:TEST"], - [true, "http://www.w3.org/1998/Math/MathML", null, "test"], - [true, "http://www.w3.org/1998/Math/MathML", null, "TEST"], - [true, null, "http://www.w3.org/2000/xmlns/", "xmlns:xlink"], - [true, null, "http://www.w3.org/2000/xmlns/", "xmlns:XLINK"], - [true, null, "fake_ns", "test:testU00003Atest"], - [true, null, "fake_ns", "TEST:TESTU00003ATEST"], - [false, null, null, "test"], - [false, null, null, "TEST"], - [false, "http://www.w3.org/1999/xhtml", null, "test"], - [false, "http://www.w3.org/1999/xhtml", null, "TEST"], - [false, null, null, "testU00003Atest"], - [false, null, null, "TESTU00003ATEST"], - [false, "http://www.w3.org/1999/xhtml", null, "testU00003Atest"], - [false, "http://www.w3.org/1999/xhtml", null, "TESTU00003ATEST"], - [false, null, "http://www.w3.org/1999/xhtml", "test:test"], - [false, null, "http://www.w3.org/1999/xhtml", "TEST:TEST"], - [false, "http://www.w3.org/1998/Math/MathML", null, "test"], - [false, "http://www.w3.org/1998/Math/MathML", null, "TEST"], - [false, null, "http://www.w3.org/2000/xmlns/", "xmlns:xlink"], - [false, null, "http://www.w3.org/2000/xmlns/", "xmlns:XLINK"], - [false, null, "fake_ns", "test:testU00003Atest"], - [false, null, "fake_ns", "TEST:TESTU00003ATEST"], - ]; - } - - /** - * @covers \MensBeam\HTML\Element::hasAttribute - * @covers \MensBeam\HTML\Element::getAttribute - * @covers \MensBeam\HTML\Element::getAttributeNS - */ - public function testCheckForAttribute(): void { - $d = new Document; - $d->appendChild($d->createElement("html")); - $e = $d->documentElement; - $e->setAttribute("ook", "eek"); - $e->setAttributeNS(Parser::XML_NAMESPACE, "xml:base", "http://example.com/"); - $e->setAttributeNS(Parser::XMLNS_NAMESPACE, "xmlns:xlink", Parser::XLINK_NAMESPACE); - $e->setAttributeNS("fake_ns", "ook:eek", "ack"); - // perform boolean tests - $this->assertFalse($e->hasAttribute("blah")); - $this->assertFalse($e->hasAttribute("OOK"));; - $this->assertFalse($e->hasAttribute("eek")); - $this->assertFalse($e->hasAttribute("ack")); - $this->assertTrue($e->hasAttribute("ook")); - $this->assertTrue($e->hasAttribute("xml:base")); - $this->assertTrue($e->hasAttribute("xmlns:xlink")); - $this->assertTrue($e->hasAttribute("ook:eek")); - $this->assertFalse($e->hasAttributeNS(null, "blah")); - $this->assertFalse($e->hasAttributeNS(null, "OOK")); - $this->assertFalse($e->hasAttributeNS(null, "eek")); - $this->assertTrue($e->hasAttributeNS(null, "ook")); - $this->assertTrue($e->hasAttributeNS(Parser::XML_NAMESPACE, "base")); - $this->assertTrue($e->hasAttributeNS(Parser::XMLNS_NAMESPACE, "xlink")); - $this->assertTrue($e->hasAttributeNS("fake_ns", "eek")); - // perform retrival tests - $this->assertNull($e->getAttribute("blah")); - $this->assertNull($e->getAttribute("OOK")); - $this->assertNull($e->getAttribute("eek")); - $this->assertNull($e->getAttribute("ack")); - $this->assertSame("eek", $e->getAttribute("ook")); - $this->assertSame("http://example.com/", $e->getAttribute("xml:base")); - $this->assertSame(Parser::XLINK_NAMESPACE, $e->getAttribute("xmlns:xlink")); - $this->assertSame("ack", $e->getAttribute("ook:eek")); - $this->assertNull($e->getAttributeNS(null, "blah")); - $this->assertNull($e->getAttributeNS(null, "OOK")); - $this->assertNull($e->getAttributeNS(null, "ack")); - $this->assertSame("eek", $e->getAttributeNS(null, "ook")); - $this->assertSame("http://example.com/", $e->getAttributeNS(Parser::XML_NAMESPACE, "base")); - $this->assertSame(Parser::XLINK_NAMESPACE, $e->getAttributeNS(Parser::XMLNS_NAMESPACE, "xlink")); - $this->assertSame("ack", $e->getAttributeNS("fake_ns", "eek")); - } - - /** @covers \MensBeam\HTML\Element::__get */ - public function testGetInnerAndOuterHtml(): void { - $d = new Document; - $d->appendChild($d->createElement("html")); - $d->documentElement->appendChild($d->createTextNode("OOK")); - $this->assertSame("OOK", $d->documentElement->innerHTML); - $this->assertSame("OOK", $d->documentElement->outerHTML); - $this->assertNull($d->documentElement->innerHtml); - $this->assertNull($d->documentElement->outerHtml); - } -} diff --git a/tests/cases/TestSerializer.php b/tests/cases/TestSerializer.php deleted file mode 100644 index 9845b3f..0000000 --- a/tests/cases/TestSerializer.php +++ /dev/null @@ -1,138 +0,0 @@ -buildTree($data, $fragment); - $this->assertSame($exp, (string) $node); - } - - public function provideStandardSerializerTests(): iterable { - $blacklist = []; - $files = new \AppendIterator(); - $files->append(new \GlobIterator(\MensBeam\HTML\BASE."tests/cases/serializer/*.dat", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); - foreach ($files as $file) { - $index = 0; - $l = 0; - if (!in_array(basename($file), $blacklist)) { - $lines = array_map(function($v) { - return rtrim($v, "\n"); - }, file($file)); - while ($l < sizeof($lines)) { - $pos = $l + 1; - assert(in_array($lines[$l], ["#document", "#fragment"]), new \Exception("Test $file #$index does not start with #doocument or #fragment tag at line ".($l + 1))); - $fragment = $lines[$l] === "#fragment"; - // collect the test input - $data = []; - for (++$l; $l < sizeof($lines); $l++) { - if (preg_match('/^#(script-(on|off)|output)$/', $lines[$l])) { - break; - } - $data[] = $lines[$l]; - } - // set the script mode, if present - assert(preg_match('/^#(script-(on|off)|output)$/', $lines[$l]) === 1, new \Exception("Test $file #$index follows data with something other than script flag or output at line ".($l + 1))); - $script = null; - if ($lines[$l] === "#script-off") { - $script = false; - $l++; - } elseif ($lines[$l] === "#script-on") { - $script = true; - $l++; - } - // collect the output string - $exp = []; - assert($lines[$l] === "#output", new \Exception("Test $file #$index follows input with something other than output at line ".($l + 1))); - for (++$l; $l < sizeof($lines); $l++) { - if ($lines[$l] === "" && in_array(($lines[$l + 1] ?? ""), ["#document", "#fragment"])) { - break; - } - assert(preg_match('/^[^#]/', $lines[$l]) === 1, new \Exception("Test $file #$index contains unrecognized data after output at line ".($l + 1))); - $exp[] = $lines[$l]; - } - $exp = implode("\n", $exp); - if (!$script) { - yield basename($file)." #$index (line $pos)" => [$data, $fragment, $exp]; - } - $l++; - $index++; - } - } - } - } - - protected function buildTree(array $data, bool $fragment): \DOMNode { - $document = new Document; - if ($fragment) { - $document->appendChild($document->createElement("html")); - $out = $document->createDocumentFragment(); - } else { - $out = $document; - } - $cur = $out; - $pad = 2; - // process each line in turn - for ($l = 0; $l < sizeof($data); $l++) { - preg_match('/^(\|\s+)(.+)/', $data[$l], $m); - // pop any parents as long as the padding of the line is less than the expected padding - $p = strlen((string) $m[1]); - assert($p >= 2 && $p <= $pad && !($p % 2), new \Exception("Input data is invalid on line ".($l + 1))); - while ($p < $pad) { - $pad -= 2; - $cur = $cur->parentNode; - } - // act based upon what the rest of the line looks like - $d = $m[2]; - if (preg_match('/^$/', $d, $m)) { - // comment - $cur->appendChild($document->createComment($m[1])); - } elseif (preg_match('/^]*)(?: "([^"]*)" "([^"]*)")?)?>$/', $d, $m)) { - // doctype - $name = strlen((string) ($m[1] ?? "")) ? $m[1] : " "; - $public = strlen((string) ($m[2] ?? "")) ? $m[2] : ""; - $system = strlen((string) ($m[3] ?? "")) ? $m[3] : ""; - $cur->appendChild($document->implementation->createDocumentType($name, $public, $system)); - } elseif (preg_match('/^<\?([^ ]+) ([^>]*)>$/', $d, $m)) { - $cur->appendChild($document->createProcessingInstruction($m[1], $m[2])); - } elseif (preg_match('/^<(?:([^ ]+) )?([^>]+)>$/', $d, $m)) { - // element - $ns = strlen((string) $m[1]) ? (array_flip(Parser::NAMESPACE_MAP)[$m[1]] ?? $m[1]) : null; - $cur = $cur->appendChild($document->createElementNS($ns, $m[2])); - $pad += 2; - } elseif (preg_match('/^(?:([^" ]+) )?([^"=]+)="((?:[^"]|"(?!$))*)"$/', $d, $m)) { - // attribute - $ns = strlen((string) $m[1]) ? (array_flip(Parser::NAMESPACE_MAP)[$m[1]] ?? $m[1]) : ""; - $cur->setAttributeNS($ns, $m[2], $m[3]); - } elseif (preg_match('/^"((?:[^"]|"(?!$))*)("?)$/', $d, $m)) { - // text - $t = $m[1]; - while (!strlen((string) $m[2])) { - preg_match('/^((?:[^"]|"(?!$))*)("?)$/', $data[++$l], $m); - $t .= "\n".$m[1]; - } - $cur->appendChild($document->createTextNode($t)); - } else { - throw new \Exception("Input data is invalid on line ".($l + 1)); - } - } - return $out; - } -} diff --git a/tests/cases/TestTokenizer.php b/tests/cases/TestTokenizer.php index d120b7d..35045cf 100644 --- a/tests/cases/TestTokenizer.php +++ b/tests/cases/TestTokenizer.php @@ -6,29 +6,30 @@ declare(strict_types=1); namespace MensBeam\HTML\TestCase; -use MensBeam\HTML\Data; -use MensBeam\HTML\EOFToken; -use MensBeam\HTML\OpenElementsStack; -use MensBeam\HTML\ParseError; -use MensBeam\HTML\Tokenizer; -use MensBeam\HTML\CharacterToken; -use MensBeam\HTML\CommentToken; -use MensBeam\HTML\DOCTYPEToken; -use MensBeam\HTML\EndTagToken; -use MensBeam\HTML\NullCharacterToken; -use MensBeam\HTML\StartTagToken; -use MensBeam\HTML\TokenAttr; -use MensBeam\HTML\WhitespaceToken; +use MensBeam\HTML\Parser\Data; +use MensBeam\HTML\Parser\EOFToken; +use MensBeam\HTML\Parser\OpenElementsStack; +use MensBeam\HTML\Parser\ParseError; +use MensBeam\HTML\Parser\Tokenizer; +use MensBeam\HTML\Parser\CharacterToken; +use MensBeam\HTML\Parser\CommentToken; +use MensBeam\HTML\Parser\DOCTYPEToken; +use MensBeam\HTML\Parser\EndTagToken; +use MensBeam\HTML\Parser\NullCharacterToken; +use MensBeam\HTML\Parser\StartTagToken; +use MensBeam\HTML\Parser\TokenAttr; +use MensBeam\HTML\Parser\WhitespaceToken; +use MensBeam\Intl\Encoding\UTF8; /** - * @covers \MensBeam\HTML\Data - * @covers \MensBeam\HTML\Tokenizer - * @covers \MensBeam\HTML\CharacterToken - * @covers \MensBeam\HTML\CommentToken - * @covers \MensBeam\HTML\DataToken - * @covers \MensBeam\HTML\TagToken - * @covers \MensBeam\HTML\DOCTYPEToken - * @covers \MensBeam\HTML\TokenAttr + * @covers \MensBeam\HTML\Parser\Data + * @covers \MensBeam\HTML\Parser\Tokenizer + * @covers \MensBeam\HTML\Parser\CharacterToken + * @covers \MensBeam\HTML\Parser\CommentToken + * @covers \MensBeam\HTML\Parser\DataToken + * @covers \MensBeam\HTML\Parser\TagToken + * @covers \MensBeam\HTML\Parser\DOCTYPEToken + * @covers \MensBeam\HTML\Parser\TokenAttr */ class TestTokenizer extends \PHPUnit\Framework\TestCase { const STATE_MAP = [ @@ -87,8 +88,8 @@ class TestTokenizer extends \PHPUnit\Framework\TestCase { $tests = []; $blacklist = ["xmlViolation.test"]; $files = new \AppendIterator(); - $files->append(new \GlobIterator(\MensBeam\HTML\BASE."tests/html5lib-tests/tokenizer/*.test", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); - $files->append(new \GlobIterator(\MensBeam\HTML\BASE."tests/cases/tokenizer/*.test", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); + $files->append(new \GlobIterator(\MensBeam\HTML\Parser\BASE."tests/html5lib-tests/tokenizer/*.test", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); + $files->append(new \GlobIterator(\MensBeam\HTML\Parser\BASE."tests/cases/tokenizer/*.test", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); foreach ($files as $file) { if (!in_array(basename($file), $blacklist)) { $tests[] = $file; @@ -101,7 +102,7 @@ class TestTokenizer extends \PHPUnit\Framework\TestCase { if (preg_match_all("/\\\\u([0-9a-f]{4})/i", $str, $matches)) { for ($a = 0; $a < sizeof($matches[0]); $a++) { $esc = $matches[0][$a]; - $chr = \MensBeam\Intl\Encoding\UTF8::encode(hexdec($matches[1][$a])); + $chr = UTF8::encode(hexdec($matches[1][$a])); $str = str_replace($esc, $chr, $str); } } diff --git a/tests/cases/TestTreeConstructor.php b/tests/cases/TestTreeConstructor.php index 55c112b..2e64f5e 100644 --- a/tests/cases/TestTreeConstructor.php +++ b/tests/cases/TestTreeConstructor.php @@ -6,29 +6,27 @@ declare(strict_types=1); namespace MensBeam\HTML\TestCase; -use MensBeam\HTML\Data; -use MensBeam\HTML\LoopException; -use MensBeam\HTML\NotImplementedException; -use MensBeam\HTML\OpenElementsStack; -use MensBeam\HTML\ParseError; use MensBeam\HTML\Parser; -use MensBeam\HTML\TemplateInsertionModesStack; -use MensBeam\HTML\Tokenizer; -use MensBeam\HTML\TreeBuilder; +use MensBeam\HTML\Parser\Data; +use MensBeam\HTML\Parser\LoopException; +use MensBeam\HTML\Parser\NotImplementedException; +use MensBeam\HTML\Parser\OpenElementsStack; +use MensBeam\HTML\Parser\ParseError; +use MensBeam\HTML\Parser\TemplateInsertionModesStack; +use MensBeam\HTML\Parser\Tokenizer; +use MensBeam\HTML\Parser\TreeBuilder; /** - * @covers \MensBeam\HTML\Document - * @covers \MensBeam\HTML\Element - * @covers \MensBeam\HTML\Tokenizer - * @covers \MensBeam\HTML\TreeBuilder - * @covers \MensBeam\HTML\ActiveFormattingElementsList - * @covers \MensBeam\HTML\TemplateInsertionModesStack - * @covers \MensBeam\HTML\OpenElementsStack - * @covers \MensBeam\HTML\Stack - * @covers \MensBeam\HTML\TagToken + * @covers \MensBeam\HTML\Parser\Tokenizer + * @covers \MensBeam\HTML\Parser\TreeBuilder + * @covers \MensBeam\HTML\Parser\ActiveFormattingElementsList + * @covers \MensBeam\HTML\Parser\TemplateInsertionModesStack + * @covers \MensBeam\HTML\Parser\OpenElementsStack + * @covers \MensBeam\HTML\Parser\Stack + * @covers \MensBeam\HTML\Parser\TagToken */ class TestTreeConstructor extends \PHPUnit\Framework\TestCase { - use \MensBeam\HTML\EscapeString; + use \MensBeam\HTML\Parser\NameCoercion; protected $out; protected $depth; @@ -379,8 +377,8 @@ class TestTreeConstructor extends \PHPUnit\Framework\TestCase { public function provideStandardTreeTests(): iterable { $blacklist = []; $files = new \AppendIterator(); - $files->append(new \GlobIterator(\MensBeam\HTML\BASE."tests/html5lib-tests/tree-construction/*.dat", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); - $files->append(new \GlobIterator(\MensBeam\HTML\BASE."tests/cases/tree-construction/*.dat", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); + $files->append(new \GlobIterator(\MensBeam\HTML\Parser\BASE."tests/html5lib-tests/tree-construction/*.dat", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); + $files->append(new \GlobIterator(\MensBeam\HTML\Parser\BASE."tests/cases/tree-construction/*.dat", \FilesystemIterator::SKIP_DOTS | \FilesystemIterator::CURRENT_AS_PATHNAME)); foreach ($files as $file) { $index = 0; $l = 0; diff --git a/tests/cases/serializer/menbeam01.dat b/tests/cases/serializer/menbeam01.dat deleted file mode 100644 index 8b06b8e..0000000 --- a/tests/cases/serializer/menbeam01.dat +++ /dev/null @@ -1,32 +0,0 @@ -#fragment -| -#output - - -#fragment -| -#output - - -#fragment -| -#output - - -#fragment -| -| test - -#fragment -| -| "You should not see this text." -#output - - -#fragment -| -| class="test" -#output - diff --git a/tests/cases/serializer/menbeam02.dat b/tests/cases/serializer/menbeam02.dat deleted file mode 100644 index 7760020..0000000 --- a/tests/cases/serializer/menbeam02.dat +++ /dev/null @@ -1,34 +0,0 @@ -#document -| -#output - - -#document -| -| -#output - - -#document -| -| -#output - - -#document -| -| -#output - - -#document -| -| -#output - - -#document -| -| -#output - diff --git a/tests/cases/serializer/wpt01.dat b/tests/cases/serializer/wpt01.dat deleted file mode 100644 index 0074d36..0000000 --- a/tests/cases/serializer/wpt01.dat +++ /dev/null @@ -1,913 +0,0 @@ -#fragment -| -#output - - -#fragment -| -| -#output - - -#fragment -| -| -| b="c" -#output - - -#fragment -| -| -| b="&" -#output - - -#fragment -| -| -| b=" " -#output - - -#fragment -| -| -| b=""" -#output - - -#fragment -| -| -| b="<" -#output - - -#fragment -| -| -| b=">" -#output - - -#fragment -| -| -| href="javascript:"<>"" -#output - - -#fragment -| -| -| xlink xlink:href="a" -#output - - -#fragment -| -| -| xmlns xmlns:svg="test" -#output - - -#fragment -| -| "a" -#output -a - -#fragment -| -| "&" -#output -& - -#fragment -| -| " " -#output -  - -#fragment -| -| "<" -#output -< - -#fragment -| -| ">" -#output -> - -#fragment -| -| """ -#output -" - -#fragment -| -| - -#fragment -| -| - -#fragment -| - -#fragment -| -| -| "<&>" -#output -<span><xmp><&> - -#fragment -| -| - -#fragment -| -| -| "<&>" -#output -<span><noembed><&> - -#fragment -| -| -| "<&>" -#output -<span><noframes><&> - -#fragment -| -|