annotate vendor/masterminds/html5/src/HTML5/InstructionProcessor.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 129ea1e6d783
rev   line source
Chris@0 1 <?php
Chris@0 2 /**
Chris@0 3 * A handler for processor instructions.
Chris@0 4 */
Chris@0 5 namespace Masterminds\HTML5;
Chris@0 6
Chris@0 7 /**
Chris@0 8 * Provide an processor to handle embedded instructions.
Chris@0 9 *
Chris@0 10 * XML defines a mechanism for inserting instructions (like PHP) into a
Chris@0 11 * document. These are called "Processor Instructions." The HTML5 parser
Chris@0 12 * provides an opportunity to handle these processor instructions during
Chris@0 13 * the tree-building phase (before the DOM is constructed), which makes
Chris@0 14 * it possible to alter the document as it is being created.
Chris@0 15 *
Chris@0 16 * One could, for example, use this mechanism to execute well-formed PHP
Chris@0 17 * code embedded inside of an HTML5 document.
Chris@0 18 */
Chris@0 19 interface InstructionProcessor
Chris@0 20 {
Chris@0 21
Chris@0 22 /**
Chris@0 23 * Process an individual processing instruction.
Chris@0 24 *
Chris@0 25 * The process() function is responsible for doing the following:
Chris@0 26 * - Determining whether $name is an instruction type it can handle.
Chris@0 27 * - Determining what to do with the data passed in.
Chris@0 28 * - Making any subsequent modifications to the DOM by modifying the
Chris@0 29 * DOMElement or its attached DOM tree.
Chris@0 30 *
Chris@0 31 * @param DOMElement $element
Chris@0 32 * The parent element for the current processing instruction.
Chris@0 33 * @param string $name
Chris@0 34 * The instruction's name. E.g. `&lt;?php` has the name `php`.
Chris@0 35 * @param string $data
Chris@0 36 * All of the data between the opening and closing PI marks.
Chris@0 37 * @return DOMElement The element that should be considered "Current". This may just be
Chris@0 38 * the element passed in, but if the processor added more elements,
Chris@0 39 * it may choose to reset the current element to one of the elements
Chris@0 40 * it created. (When in doubt, return the element passed in.)
Chris@0 41 */
Chris@0 42 public function process(\DOMElement $element, $name, $data);
Chris@0 43 }