From 7b0931fb5bcc5fdf75bd0b8202bd992c388997e7 Mon Sep 17 00:00:00 2001 From: Asmir Mustafic Date: Tue, 17 Jun 2014 09:32:43 +0200 Subject: PSR-2 formatting --- src/HTML5/Elements.php | 6 +- src/HTML5/Parser/CharacterReference.php | 2 +- src/HTML5/Parser/DOMTreeBuilder.php | 34 ++--- src/HTML5/Parser/EventHandler.php | 6 +- src/HTML5/Parser/InputStream.php | 2 +- src/HTML5/Parser/Scanner.php | 8 +- src/HTML5/Parser/StringInputStream.php | 16 +-- src/HTML5/Parser/Tokenizer.php | 222 ++++++++++++++++---------------- src/HTML5/Parser/TreeBuildingRules.php | 2 +- src/HTML5/Parser/UTF8Utils.php | 4 +- src/HTML5/Serializer/OutputRules.php | 12 +- src/HTML5/Serializer/Traverser.php | 6 +- 12 files changed, 160 insertions(+), 160 deletions(-) (limited to 'src/HTML5') diff --git a/src/HTML5/Elements.php b/src/HTML5/Elements.php index 2b9ba63..819ce0e 100644 --- a/src/HTML5/Elements.php +++ b/src/HTML5/Elements.php @@ -476,12 +476,12 @@ class Elements * The element name. * @param int $mask * One of the constants on this class. - * @return boolean TRUE if the element matches the mask, FALSE otherwise. + * @return boolean true if the element matches the mask, false otherwise. */ public static function isA($name, $mask) { if (! static::isElement($name)) { - return FALSE; + return false; } return (static::element($name) & $mask) == $mask; @@ -566,7 +566,7 @@ class Elements return static::$mathml[$name]; } - return FALSE; + return false; } /** diff --git a/src/HTML5/Parser/CharacterReference.php b/src/HTML5/Parser/CharacterReference.php index 24cc687..c1617e7 100644 --- a/src/HTML5/Parser/CharacterReference.php +++ b/src/HTML5/Parser/CharacterReference.php @@ -30,7 +30,7 @@ class CharacterReference public static function lookupName($name) { // Do we really want to return NULL here? or FFFD - return isset(Entities::$byName[$name]) ? Entities::$byName[$name] : NULL; + return isset(Entities::$byName[$name]) ? Entities::$byName[$name] : null; } /** diff --git a/src/HTML5/Parser/DOMTreeBuilder.php b/src/HTML5/Parser/DOMTreeBuilder.php index a1723de..731d1d8 100644 --- a/src/HTML5/Parser/DOMTreeBuilder.php +++ b/src/HTML5/Parser/DOMTreeBuilder.php @@ -143,9 +143,9 @@ class DOMTreeBuilder implements EventHandler * Any document that is missing the * DT will be considered to be in quirks mode. */ - protected $quirks = TRUE; + protected $quirks = true; - public function __construct($isFragment = FALSE, array $options = array()) + public function __construct($isFragment = false, array $options = array()) { $this->options = $options; @@ -155,7 +155,7 @@ class DOMTreeBuilder implements EventHandler // documents, and attempting to up-convert any older DTDs to HTML5. $dt = $impl->createDocumentType('html'); // $this->doc = \DOMImplementation::createDocument(NULL, 'html', $dt); - $this->doc = $impl->createDocument(NULL, NULL, $dt); + $this->doc = $impl->createDocument(null, null, $dt); $this->doc->errors = array(); $this->current = $this->doc; // ->documentElement; @@ -210,7 +210,7 @@ class DOMTreeBuilder implements EventHandler $this->processor = $proc; } - public function doctype($name, $idType = 0, $id = NULL, $quirks = FALSE) + public function doctype($name, $idType = 0, $id = null, $quirks = false) { // This is used solely for setting quirks mode. Currently we don't // try to preserve the inbound DT. We convert it to HTML5. @@ -232,7 +232,7 @@ class DOMTreeBuilder implements EventHandler * - XLink, MathML and SVG namespace handling * - Omission rules: 8.1.2.4 Optional tags */ - public function startTag($name, $attributes = array(), $selfClosing = FALSE) + public function startTag($name, $attributes = array(), $selfClosing = false) { // fprintf(STDOUT, $name); $lname = $this->normalizeTagName($name); @@ -244,7 +244,7 @@ class DOMTreeBuilder implements EventHandler // Set quirks mode if we're at IM_INITIAL with no doctype. if ($this->insertMode == static::IM_INITIAL) { - $this->quirks = TRUE; + $this->quirks = true; $this->parseError("No DOCTYPE specified."); } @@ -301,7 +301,7 @@ class DOMTreeBuilder implements EventHandler $pushes ++; } if (isset($this->options["xmlNamespaces"]) && $this->options["xmlNamespaces"]) { - // when xmlNamespaces is TRUE a and we found a 'xmlns' or 'xmlns:*' attribute, we should add a new item to the $nsStack + // when xmlNamespaces is true a and we found a 'xmlns' or 'xmlns:*' attribute, we should add a new item to the $nsStack foreach ($attributes as $aName => $aVal) { if ($aName === 'xmlns') { array_unshift($this->nsStack, array( @@ -364,7 +364,7 @@ class DOMTreeBuilder implements EventHandler // This is necessary on a non-DTD schema, like HTML5. if ($aName == 'id') { - $ele->setIdAttribute('id', TRUE); + $ele->setIdAttribute('id', true); } } @@ -510,7 +510,7 @@ class DOMTreeBuilder implements EventHandler $this->current->appendChild($node); } - public function processingInstruction($name, $data = NULL) + public function processingInstruction($name, $data = null) { // XXX: Ignore initial XML declaration, per the spec. if ($this->insertMode == static::IM_INITIAL && 'xml' == strtolower($name)) { @@ -550,7 +550,7 @@ class DOMTreeBuilder implements EventHandler protected function normalizeTagName($name) { /* - * Section 2.9 suggests that we should not do this. if (strpos($name, ':') !== FALSE) { // We know from the grammar that there must be at least one other // char besides :, since : is not a legal tag start. $parts = explode(':', $name); return array_pop($parts); } + * Section 2.9 suggests that we should not do this. if (strpos($name, ':') !== false) { // We know from the grammar that there must be at least one other // char besides :, since : is not a legal tag start. $parts = explode(':', $name); return array_pop($parts); } */ return $name; } @@ -568,38 +568,38 @@ class DOMTreeBuilder implements EventHandler $working = $this->current; do { if ($working->nodeType != XML_ELEMENT_NODE) { - return FALSE; + return false; } if ($working->tagName == $tag) { $this->current = $working->parentNode; - return TRUE; + return true; } } while ($working = $working->parentNode); - return FALSE; + return false; } /** * Checks if the given tagname is an ancestor of the present candidate. * * If $this->current or anything above $this->current matches the given tag - * name, this returns TRUE. + * name, this returns true. */ protected function isAncestor($tagname) { $candidate = $this->current; while ($candidate->nodeType === XML_ELEMENT_NODE) { if ($candidate->tagName == $tagname) { - return TRUE; + return true; } $candidate = $candidate->parentNode; } - return FALSE; + return false; } /** - * Returns TRUE if the immediate parent element is of the given tagname. + * Returns true if the immediate parent element is of the given tagname. */ protected function isParent($tagname) { diff --git a/src/HTML5/Parser/EventHandler.php b/src/HTML5/Parser/EventHandler.php index ef80909..2d55347 100644 --- a/src/HTML5/Parser/EventHandler.php +++ b/src/HTML5/Parser/EventHandler.php @@ -40,7 +40,7 @@ interface EventHandler * @param boolean $quirks * Indicates whether the builder should enter quirks mode. */ - public function doctype($name, $idType = 0, $id = NULL, $quirks = FALSE); + public function doctype($name, $idType = 0, $id = null, $quirks = false); /** * A start tag. @@ -71,7 +71,7 @@ interface EventHandler * An indicator of whether or not this tag is self-closing () * @return numeric One of the Tokenizer::TEXTMODE_* constants. */ - public function startTag($name, $attributes = array(), $selfClosing = FALSE); + public function startTag($name, $attributes = array(), $selfClosing = false); /** * An end-tag. @@ -118,5 +118,5 @@ interface EventHandler * @param string $data * The unparsed data. */ - public function processingInstruction($name, $data = NULL); + public function processingInstruction($name, $data = null); } diff --git a/src/HTML5/Parser/InputStream.php b/src/HTML5/Parser/InputStream.php index 7113d6c..0bdc803 100644 --- a/src/HTML5/Parser/InputStream.php +++ b/src/HTML5/Parser/InputStream.php @@ -51,7 +51,7 @@ interface InputStream extends \Iterator * Bytes to match. * @param int $max * Maximum number of bytes to scan. - * @return mixed Index or FALSE if no match is found. You should use strong + * @return mixed Index or false if no match is found. You should use strong * equality when checking the result, since index could be 0. */ public function charsUntil($bytes, $max = null); diff --git a/src/HTML5/Parser/Scanner.php b/src/HTML5/Parser/Scanner.php index a262004..a92c608 100644 --- a/src/HTML5/Parser/Scanner.php +++ b/src/HTML5/Parser/Scanner.php @@ -17,8 +17,8 @@ class Scanner protected $is; - // Flipping this to TRUE will give minisculely more debugging info. - public $debug = FALSE; + // Flipping this to true will give minisculely more debugging info. + public $debug = false; /** * Create a new Scanner. @@ -67,7 +67,7 @@ class Scanner return $this->is->current(); } - return FALSE; + return false; } /** @@ -83,7 +83,7 @@ class Scanner return $this->is->current(); } - return FALSE; + return false; } /** diff --git a/src/HTML5/Parser/StringInputStream.php b/src/HTML5/Parser/StringInputStream.php index 9648bce..4cac3c2 100644 --- a/src/HTML5/Parser/StringInputStream.php +++ b/src/HTML5/Parser/StringInputStream.php @@ -152,7 +152,7 @@ class StringInputStream implements InputStream // However, for here we want the length up until the next byte to be // processed, so add one to the current byte ($this->char). - if ($lastLine !== FALSE) { + if ($lastLine !== false) { $findLengthOf = substr($this->data, $lastLine + 1, $this->char - 1 - $lastLine); } else { // After a newline. @@ -207,10 +207,10 @@ class StringInputStream implements InputStream public function valid() { if ($this->char < $this->EOF) { - return TRUE; + return true; } - return FALSE; + return false; } /** @@ -233,7 +233,7 @@ class StringInputStream implements InputStream return $data; } - return ''; // FALSE; + return ''; // false; } /** @@ -248,13 +248,13 @@ class StringInputStream implements InputStream * Bytes to match. * @param int $max * Maximum number of bytes to scan. - * @return mixed Index or FALSE if no match is found. You should use strong + * @return mixed Index or false if no match is found. You should use strong * equality when checking the result, since index could be 0. */ public function charsUntil($bytes, $max = null) { if ($this->char >= $this->EOF) { - return FALSE; + return false; } if ($max === 0 || $max) { @@ -285,7 +285,7 @@ class StringInputStream implements InputStream public function charsWhile($bytes, $max = null) { if ($this->char >= $this->EOF) { - return FALSE; + return false; } if ($max === 0 || $max) { @@ -321,7 +321,7 @@ class StringInputStream implements InputStream return $this->data[$this->char + 1]; } - return FALSE; + return false; } public function key() diff --git a/src/HTML5/Parser/Tokenizer.php b/src/HTML5/Parser/Tokenizer.php index 0db9ee1..8f34494 100644 --- a/src/HTML5/Parser/Tokenizer.php +++ b/src/HTML5/Parser/Tokenizer.php @@ -38,10 +38,10 @@ class Tokenizer protected $text = ''; // When this goes to false, the parser stops. - protected $carryOn = TRUE; + protected $carryOn = true; protected $textMode = 0; // TEXTMODE_NORMAL; - protected $untilTag = NULL; + protected $untilTag = null; const WHITE = "\t\n\f "; @@ -106,7 +106,7 @@ class Tokenizer * The tag that should stop RAW or RCDATA mode. Normal mode does not * use this indicator. */ - public function setTextMode($textmode, $untilTag = NULL) + public function setTextMode($textmode, $untilTag = null) { $this->textMode = $textmode & (Elements::TEXT_RAW | Elements::TEXT_RCDATA); $this->untilTag = $untilTag; @@ -139,8 +139,8 @@ class Tokenizer */ protected function characterData() { - if ($this->scanner->current() === FALSE) { - return FALSE; + if ($this->scanner->current() === false) { + return false; } switch ($this->textMode) { case Elements::TEXT_RAW: @@ -150,7 +150,7 @@ class Tokenizer default: $tok = $this->scanner->current(); if (strspn($tok, "<&")) { - return FALSE; + return false; } return $this->text(); } @@ -164,17 +164,17 @@ class Tokenizer $tok = $this->scanner->current(); // This should never happen... - if ($tok === FALSE) { - return FALSE; + if ($tok === false) { + return false; } // Null if ($tok === "\00") { - $this->parseError("Received NULL character."); + $this->parseError("Received null character."); } // fprintf(STDOUT, "Writing '%s'", $tok); $this->buffer($tok); $this->scanner->next(); - return TRUE; + return true; } /** @@ -203,7 +203,7 @@ class Tokenizer $sequence = 'untilTag . '>'; $txt = ''; $tok = $this->scanner->current(); - while ($tok !== FALSE && ! ($tok == '<' && ($this->sequenceMatches($sequence) || $this->sequenceMatches(strtoupper($sequence))))) { + while ($tok !== false && ! ($tok == '<' && ($this->sequenceMatches($sequence) || $this->sequenceMatches(strtoupper($sequence))))) { if ($tok == '&') { $txt .= $this->decodeCharacterReference(); $tok = $this->scanner->current(); @@ -222,14 +222,14 @@ class Tokenizer */ protected function eof() { - if ($this->scanner->current() === FALSE) { + if ($this->scanner->current() === false) { // fprintf(STDOUT, "EOF"); $this->flushBuffer(); $this->events->eof(); - $this->carryOn = FALSE; - return TRUE; + $this->carryOn = false; + return true; } - return FALSE; + return false; } /** @@ -243,11 +243,11 @@ class Tokenizer protected function characterReference() { $ref = $this->decodeCharacterReference(); - if ($ref !== FALSE) { + if ($ref !== false) { $this->buffer($ref); - return TRUE; + return true; } - return FALSE; + return false; } /** @@ -258,7 +258,7 @@ class Tokenizer protected function tagOpen() { if ($this->scanner->current() != '<') { - return FALSE; + return false; } // Any buffered text data can go out now. @@ -277,7 +277,7 @@ class Tokenizer protected function markupDeclaration() { if ($this->scanner->current() != '!') { - return FALSE; + return false; } $tok = $this->scanner->next(); @@ -300,7 +300,7 @@ class Tokenizer // FINISH $this->parseError("Expected