summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAsmir Mustafic <[email protected]>2014-06-17 09:32:43 +0200
committerAsmir Mustafic <[email protected]>2014-06-17 09:32:43 +0200
commit7b0931fb5bcc5fdf75bd0b8202bd992c388997e7 (patch)
tree38b1cd87d19d244a4e9a258f6ee51be7d3a9e43c /src
parent44f07f1f7ec5b995a5279eb4f61ea0dbb0cb616e (diff)
PSR-2 formatting
Diffstat (limited to 'src')
-rw-r--r--src/HTML5.php18
-rw-r--r--src/HTML5/Elements.php6
-rw-r--r--src/HTML5/Parser/CharacterReference.php2
-rw-r--r--src/HTML5/Parser/DOMTreeBuilder.php34
-rw-r--r--src/HTML5/Parser/EventHandler.php6
-rw-r--r--src/HTML5/Parser/InputStream.php2
-rw-r--r--src/HTML5/Parser/Scanner.php8
-rw-r--r--src/HTML5/Parser/StringInputStream.php16
-rw-r--r--src/HTML5/Parser/Tokenizer.php222
-rw-r--r--src/HTML5/Parser/TreeBuildingRules.php2
-rw-r--r--src/HTML5/Parser/UTF8Utils.php4
-rw-r--r--src/HTML5/Serializer/OutputRules.php12
-rw-r--r--src/HTML5/Serializer/Traverser.php6
13 files changed, 169 insertions, 169 deletions
diff --git a/src/HTML5.php b/src/HTML5.php
index 959c3d2..16187df 100644
--- a/src/HTML5.php
+++ b/src/HTML5.php
@@ -26,7 +26,7 @@ class HTML5
*/
private $options = array(
// If the serializer should encode all entities.
- 'encode_entities' => FALSE
+ 'encode_entities' => false
);
private $errors = array();
@@ -158,7 +158,7 @@ class HTML5
public function parse(\Masterminds\HTML5\Parser\InputStream $input)
{
$this->errors = array();
- $events = new DOMTreeBuilder(FALSE, $this->options);
+ $events = new DOMTreeBuilder(false, $this->options);
$scanner = new Scanner($input);
$parser = new Tokenizer($scanner, $events);
@@ -181,7 +181,7 @@ class HTML5
*/
public function parseFragment(\Masterminds\HTML5\Parser\InputStream $input)
{
- $events = new DOMTreeBuilder(TRUE, $this->options);
+ $events = new DOMTreeBuilder(true, $this->options);
$scanner = new Scanner($input);
$parser = new Tokenizer($scanner, $events);
@@ -200,15 +200,15 @@ class HTML5
* @param array $options
* Configuration options when serializing the DOM. These include:
* - encode_entities: Text written to the output is escaped by default and not all
- * entities are encoded. If this is set to TRUE all entities will be encoded.
- * Defaults to FALSE.
+ * entities are encoded. If this is set to true all entities will be encoded.
+ * Defaults to false.
*/
public function save($dom, $file, $options = array())
{
- $close = TRUE;
+ $close = true;
if (is_resource($file)) {
$stream = $file;
- $close = FALSE;
+ $close = false;
} else {
$stream = fopen($file, 'w');
}
@@ -231,8 +231,8 @@ class HTML5
* @param array $options
* Configuration options when serializing the DOM. These include:
* - encode_entities: Text written to the output is escaped by default and not all
- * entities are encoded. If this is set to TRUE all entities will be encoded.
- * Defaults to FALSE.
+ * entities are encoded. If this is set to true all entities will be encoded.
+ * Defaults to false.
*
* @return string A HTML5 documented generated from the DOM.
*/
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 (<foo/>)
* @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 = '</' . $this->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 <!--, <![CDATA[, or <!DOCTYPE. Got <!%s", $tok);
$this->bogusComment('<!');
- return TRUE;
+ return true;
}
/**
@@ -310,7 +310,7 @@ class Tokenizer
protected function endTag()
{
if ($this->scanner->current() != '/') {
- return FALSE;
+ return false;
}
$tok = $this->scanner->next();
@@ -320,8 +320,8 @@ class Tokenizer
// -> parse error
if (! ctype_alpha($tok)) {
$this->parseError("Expected tag name, got '%s'", $tok);
- if ($tok == "\0" || $tok === FALSE) {
- return FALSE;
+ if ($tok == "\0" || $tok === false) {
+ return false;
}
return $this->bogusComment('</');
}
@@ -338,7 +338,7 @@ class Tokenizer
$this->events->endTag($name);
$this->scanner->next();
- return TRUE;
+ return true;
}
/**
@@ -349,13 +349,13 @@ class Tokenizer
{
$tok = $this->scanner->current();
if (! ctype_alpha($tok)) {
- return FALSE;
+ return false;
}
// We know this is at least one char.
$name = strtolower($this->scanner->charsWhile(":0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"));
$attributes = array();
- $selfClose = FALSE;
+ $selfClose = false;
// Handle attribute parse exceptions here so that we can
// react by trying to build a sensible parse tree.
@@ -365,7 +365,7 @@ class Tokenizer
$this->attribute($attributes);
} while (! $this->isTagEnd($selfClose));
} catch (ParseError $e) {
- $selfClose = FALSE;
+ $selfClose = false;
}
$mode = $this->events->startTag($name, $attributes, $selfClose);
@@ -379,7 +379,7 @@ class Tokenizer
$this->scanner->next();
- return TRUE;
+ return true;
}
/**
@@ -392,28 +392,28 @@ class Tokenizer
$this->scanner->next();
$this->scanner->whitespace();
if ($this->scanner->current() == '>') {
- $selfClose = TRUE;
- return TRUE;
+ $selfClose = true;
+ return true;
}
- if ($this->scanner->current() === FALSE) {
+ if ($this->scanner->current() === false) {
$this->parseError("Unexpected EOF inside of tag.");
- return TRUE;
+ return true;
}
// Basically, we skip the / token and go on.
// See 8.2.4.43.
$this->parseError("Unexpected '%s' inside of a tag.", $this->scanner->current());
- return FALSE;
+ return false;
}
if ($this->scanner->current() == '>') {
- return TRUE;
+ return true;
}
- if ($this->scanner->current() === FALSE) {
+ if ($this->scanner->current() === false) {
$this->parseError("Unexpected EOF inside of tag.");
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
/**
@@ -422,8 +422,8 @@ class Tokenizer
protected function attribute(&$attributes)
{
$tok = $this->scanner->current();
- if ($tok == '/' || $tok == '>' || $tok === FALSE) {
- return FALSE;
+ if ($tok == '/' || $tok == '>' || $tok === false) {
+ return false;
}
if ($tok == '<') {
@@ -444,7 +444,7 @@ class Tokenizer
$this->scanner->next();
}
- $isValidAttribute = TRUE;
+ $isValidAttribute = true;
// Attribute names can contain most Unicode characters for HTML5.
// But method "DOMElement::setAttribute" is throwing exception
// because of it's own internal restriction so these have to be filtered.
@@ -452,7 +452,7 @@ class Tokenizer
// and http://www.w3.org/TR/2011/WD-html5-20110525/syntax.html#syntax-attribute-name
if (preg_match("/[\x1-\x2C\\/\x3B-\x40\x5B-\x5E\x60\x7B-\x7F]/u", $name)) {
$this->parseError("Unexpected characters in attribute name: %s", $name);
- $isValidAttribute = FALSE;
+ $isValidAttribute = false;
} // There is no limitation for 1st character in HTML5.
// But method "DOMElement::setAttribute" is throwing exception for the
// characters below so they have to be filtered.
@@ -461,7 +461,7 @@ class Tokenizer
else
if (preg_match("/^[0-9.-]/u", $name)) {
$this->parseError("Unexpected character at the begining of attribute name: %s", $name);
- $isValidAttribute = FALSE;
+ $isValidAttribute = false;
}
// 8.1.2.3
$this->scanner->whitespace();
@@ -470,7 +470,7 @@ class Tokenizer
if ($isValidAttribute) {
$attributes[$name] = $val;
}
- return TRUE;
+ return true;
}
/**
@@ -480,7 +480,7 @@ class Tokenizer
protected function attributeValue()
{
if ($this->scanner->current() != '=') {
- return NULL;
+ return null;
}
$this->scanner->next();
// 8.1.2.3
@@ -493,7 +493,7 @@ class Tokenizer
case " ":
case "\t":
// Whitespace here indicates an empty value.
- return NULL;
+ return null;
case '"':
case "'":
$this->scanner->next();
@@ -501,7 +501,7 @@ class Tokenizer
case '>':
// case '/': // 8.2.4.37 seems to allow foo=/ as a valid attr.
$this->parseError("Expected attribute value, got tag end.");
- return NULL;
+ return null;
case '=':
case '`':
$this->parseError("Expecting quotes, got %s.", $tok);
@@ -525,9 +525,9 @@ class Tokenizer
$stoplist = "\f" . $quote;
$val = '';
$tok = $this->scanner->current();
- while (strspn($tok, $stoplist) == 0 && $tok !== FALSE) {
+ while (strspn($tok, $stoplist) == 0 && $tok !== false) {
if ($tok == '&') {
- $val .= $this->decodeCharacterReference(TRUE);
+ $val .= $this->decodeCharacterReference(true);
$tok = $this->scanner->current();
} else {
$val .= $tok;
@@ -543,9 +543,9 @@ class Tokenizer
$stoplist = "\t\n\f >";
$val = '';
$tok = $this->scanner->current();
- while (strspn($tok, $stoplist) == 0 && $tok !== FALSE) {
+ while (strspn($tok, $stoplist) == 0 && $tok !== false) {
if ($tok == '&') {
- $val .= $this->decodeCharacterReference(TRUE);
+ $val .= $this->decodeCharacterReference(true);
$tok = $this->scanner->current();
} else {
if (strspn($tok, "\"'<=`") > 0) {
@@ -582,13 +582,13 @@ class Tokenizer
do {
$comment .= $tok;
$tok = $this->scanner->next();
- } while ($tok !== FALSE && $tok != '>');
+ } while ($tok !== false && $tok != '>');
$this->flushBuffer();
$this->events->comment($comment . $tok);
$this->scanner->next();
- return TRUE;
+ return true;
}
/**
@@ -607,7 +607,7 @@ class Tokenizer
$this->parseError("Expected comment data, got '>'");
$this->events->comment('');
$this->scanner->next();
- return TRUE;
+ return true;
}
// Replace NULL with the replacement char.
@@ -621,7 +621,7 @@ class Tokenizer
$this->events->comment($comment);
$this->scanner->next();
- return TRUE;
+ return true;
}
/**
@@ -630,25 +630,25 @@ class Tokenizer
protected function isCommentEnd()
{
// EOF
- if ($this->scanner->current() === FALSE) {
+ if ($this->scanner->current() === false) {
// Hit the end.
$this->parseError("Unexpected EOF in a comment.");
- return TRUE;
+ return true;
}
// If it doesn't start with -, not the end.
if ($this->scanner->current() != '-') {
- return FALSE;
+ return false;
}
// Advance one, and test for '->'
if ($this->scanner->next() == '-' && $this->scanner->peek() == '>') {
$this->scanner->next(); // Consume the last '>'
- return TRUE;
+ return true;
}
// Unread '-';
$this->scanner->unconsume(1);
- return FALSE;
+ return false;
}
/**
@@ -662,7 +662,7 @@ class Tokenizer
protected function doctype()
{
if (strcasecmp($this->scanner->current(), 'D')) {
- return FALSE;
+ return false;
}
// Check that string is DOCTYPE.
$chars = $this->scanner->charsWhile("DOCTYPEdoctype");
@@ -675,8 +675,8 @@ class Tokenizer
$tok = $this->scanner->current();
// EOF: die.
- if ($tok === FALSE) {
- $this->events->doctype('html5', EventHandler::DOCTYPE_NONE, '', TRUE);
+ if ($tok === false) {
+ $this->events->doctype('html5', EventHandler::DOCTYPE_NONE, '', true);
return $this->eof();
}
@@ -684,7 +684,7 @@ class Tokenizer
// NULL char: convert.
if ($tok === "\0") {
- $this->parseError("Unexpected NULL character in DOCTYPE.");
+ $this->parseError("Unexpected null character in DOCTYPE.");
$doctypeName .= UTF8::FFFD;
$tok = $this->scanner->next();
}
@@ -696,11 +696,11 @@ class Tokenizer
$tok = $this->scanner->current();
- // If FALSE, emit a parse error, DOCTYPE, and return.
- if ($tok === FALSE) {
+ // If false, emit a parse error, DOCTYPE, and return.
+ if ($tok === false) {
$this->parseError('Unexpected EOF in DOCTYPE declaration.');
- $this->events->doctype($doctypeName, EventHandler::DOCTYPE_NONE, NULL, TRUE);
- return TRUE;
+ $this->events->doctype($doctypeName, EventHandler::DOCTYPE_NONE, null, true);
+ return true;
}
// Short DOCTYPE, like <!DOCTYPE html>
@@ -708,13 +708,13 @@ class Tokenizer
// DOCTYPE without a name.
if (strlen($doctypeName) == 0) {
$this->parseError("Expected a DOCTYPE name. Got nothing.");
- $this->events->doctype($doctypeName, 0, NULL, TRUE);
+ $this->events->doctype($doctypeName, 0, null, true);
$this->scanner->next();
- return TRUE;
+ return true;
}
$this->events->doctype($doctypeName);
$this->scanner->next();
- return TRUE;
+ return true;
}
$this->scanner->whitespace();
@@ -727,33 +727,33 @@ class Tokenizer
// Get the sys ID.
$type = $pub == 'PUBLIC' ? EventHandler::DOCTYPE_PUBLIC : EventHandler::DOCTYPE_SYSTEM;
$id = $this->quotedString("\0>");
- if ($id === FALSE) {
- $this->events->doctype($doctypeName, $type, $pub, FALSE);
- return FALSE;
+ if ($id === false) {
+ $this->events->doctype($doctypeName, $type, $pub, false);
+ return false;
}
// Premature EOF.
- if ($this->scanner->current() === FALSE) {
+ if ($this->scanner->current() === false) {
$this->parseError("Unexpected EOF in DOCTYPE");
- $this->events->doctype($doctypeName, $type, $id, TRUE);
- return TRUE;
+ $this->events->doctype($doctypeName, $type, $id, true);
+ return true;
}
// Well-formed complete DOCTYPE.
$this->scanner->whitespace();
if ($this->scanner->current() == '>') {
- $this->events->doctype($doctypeName, $type, $id, FALSE);
+ $this->events->doctype($doctypeName, $type, $id, false);
$this->scanner->next();
- return TRUE;
+ return true;
}
// If we get here, we have <!DOCTYPE foo PUBLIC "bar" SOME_JUNK
- // Throw away the junk, parse error, quirks mode, return TRUE.
+ // Throw away the junk, parse error, quirks mode, return true.
$this->scanner->charsUntil(">");
$this->parseError("Malformed DOCTYPE.");
- $this->events->doctype($doctypeName, $type, $id, TRUE);
+ $this->events->doctype($doctypeName, $type, $id, true);
$this->scanner->next();
- return TRUE;
+ return true;
}
// Else it's a bogus DOCTYPE.
@@ -761,9 +761,9 @@ class Tokenizer
$this->scanner->charsUntil('>');
$this->parseError("Expected PUBLIC or SYSTEM. Got %s.", $pub);
- $this->events->doctype($doctypeName, 0, NULL, TRUE);
+ $this->events->doctype($doctypeName, 0, null, true);
$this->scanner->next();
- return TRUE;
+ return true;
}
/**
@@ -788,7 +788,7 @@ class Tokenizer
}
return $ret;
}
- return FALSE;
+ return false;
}
/**
@@ -797,7 +797,7 @@ class Tokenizer
protected function cdataSection()
{
if ($this->scanner->current() != '[') {
- return FALSE;
+ return false;
}
$cdata = '';
$this->scanner->next();
@@ -810,10 +810,10 @@ class Tokenizer
$tok = $this->scanner->next();
do {
- if ($tok === FALSE) {
+ if ($tok === false) {
$this->parseError('Unexpected EOF inside CDATA.');
$this->bogusComment('<![CDATA[' . $cdata);
- return TRUE;
+ return true;
}
$cdata .= $tok;
$tok = $this->scanner->next();
@@ -823,7 +823,7 @@ class Tokenizer
$this->scanner->consume(3);
$this->events->cdata($cdata);
- return TRUE;
+ return true;
}
// ================================================================
@@ -840,7 +840,7 @@ class Tokenizer
protected function processingInstruction()
{
if ($this->scanner->current() != '?') {
- return FALSE;
+ return false;
}
$tok = $this->scanner->next();
@@ -848,10 +848,10 @@ class Tokenizer
$white = strlen($this->scanner->whitespace());
// If not a PI, send to bogusComment.
- if (strlen($procName) == 0 || $white == 0 || $this->scanner->current() == FALSE) {
+ if (strlen($procName) == 0 || $white == 0 || $this->scanner->current() == false) {
$this->parseError("Expected processing instruction name, got $tok");
$this->bogusComment('<?' . $tok . $procName);
- return TRUE;
+ return true;
}
$data = '';
@@ -860,17 +860,17 @@ class Tokenizer
$data .= $this->scanner->current();
$tok = $this->scanner->next();
- if ($tok === FALSE) {
+ if ($tok === false) {
$this->parseError("Unexpected EOF in processing instruction.");
$this->events->processingInstruction($procName, $data);
- return TRUE;
+ return true;
}
}
$this->scanner->next(); // >
$this->scanner->next(); // Next token.
$this->events->processingInstruction($procName, $data);
- return TRUE;
+ return true;
}
// ================================================================
@@ -887,7 +887,7 @@ class Tokenizer
// Optimization for reading larger blocks faster.
$first = substr($sequence, 0, 1);
- while ($this->scanner->current() !== FALSE) {
+ while ($this->scanner->current() !== false) {
$buffer .= $this->scanner->charsUntil($first);
// Stop as soon as we hit the stopping condition.
@@ -907,10 +907,10 @@ class Tokenizer
* Check if upcomming chars match the given sequence.
*
* This will read the stream for the $sequence. If it's
- * found, this will return TRUE. If not, return FALSE.
+ * found, this will return true. If not, return false.
* Since this unconsumes any chars it reads, the caller
* will still need to read the next sequence, even if
- * this returns TRUE.
+ * this returns true.
*
* Example: $this->sequenceMatches('</script>') will
* see if the input stream is at the start of a
@@ -924,9 +924,9 @@ class Tokenizer
$buffer .= $this->scanner->current();
// EOF. Rewind and let the caller handle it.
- if ($this->scanner->current() === FALSE) {
+ if ($this->scanner->current() === false) {
$this->scanner->unconsume($i);
- return FALSE;
+ return false;
}
$this->scanner->next();
}
@@ -964,7 +964,7 @@ class Tokenizer
/**
* Emit a parse error.
*
- * A parse error always returns FALSE because it never consumes any
+ * A parse error always returns false because it never consumes any
* characters.
*/
protected function parseError($msg)
@@ -979,25 +979,25 @@ class Tokenizer
$line = $this->scanner->currentLine();
$col = $this->scanner->columnOffset();
$this->events->parseError($msg, $line, $col);
- return FALSE;
+ return false;
}
/**
* Decode a character reference and return the string.
*
- * Returns FALSE if the entity could not be found. If $inAttribute is set
- * to TRUE, a bare & will be returned as-is.
+ * Returns false if the entity could not be found. If $inAttribute is set
+ * to true, a bare & will be returned as-is.
*
* @param boolean $inAttribute
- * Set to TRUE if the text is inside of an attribute value.
- * FALSE otherwise.
+ * Set to true if the text is inside of an attribute value.
+ * false otherwise.
*/
- protected function decodeCharacterReference($inAttribute = FALSE)
+ protected function decodeCharacterReference($inAttribute = false)
{
// If it fails this, it's definitely not an entity.
if ($this->scanner->current() != '&') {
- return FALSE;
+ return false;
}
// Next char after &.
@@ -1005,7 +1005,7 @@ class Tokenizer
$entity = '';
$start = $this->scanner->position();
- if ($tok == FALSE) {
+ if ($tok == false) {
return '&';
}
@@ -1043,7 +1043,7 @@ class Tokenizer
else {
// Convert from decimal to char.
$numeric = $this->scanner->getNumeric();
- if ($numeric === FALSE) {
+ if ($numeric === false) {
$this->parseError("Expected &#DIGITS;, got &#%s", $tok);
$this->scanner->unconsume(2);
return '&';
@@ -1056,7 +1056,7 @@ class Tokenizer
// [a-zA-Z0-9]+;
$cname = $this->scanner->getAsciiAlpha();
$entity = CharacterReference::lookupName($cname);
- if ($entity == NULL) {
+ if ($entity == null) {
$this->parseError("No match in entity table for '%s'", $entity);
}
}
diff --git a/src/HTML5/Parser/TreeBuildingRules.php b/src/HTML5/Parser/TreeBuildingRules.php
index 4eb0a54..2af3c66 100644
--- a/src/HTML5/Parser/TreeBuildingRules.php
+++ b/src/HTML5/Parser/TreeBuildingRules.php
@@ -44,7 +44,7 @@ class TreeBuildingRules
}
/**
- * Returns TRUE if the given tagname has special processing rules.
+ * Returns true if the given tagname has special processing rules.
*/
public function hasRules($tagname)
{
diff --git a/src/HTML5/Parser/UTF8Utils.php b/src/HTML5/Parser/UTF8Utils.php
index ed35997..d319252 100644
--- a/src/HTML5/Parser/UTF8Utils.php
+++ b/src/HTML5/Parser/UTF8Utils.php
@@ -86,7 +86,7 @@ class UTF8Utils
// details.
if (function_exists('mb_convert_encoding')) {
// mb library has the following behaviors:
- // - UTF-16 surrogates result in FALSE.
+ // - UTF-16 surrogates result in false.
// - Overlongs and outside Plane 16 result in empty strings.
// Before we run mb_convert_encoding we need to tell it what to do with
@@ -138,7 +138,7 @@ class UTF8Utils
$errors = array();
/*
- * All U+0000 NULL characters in the input must be replaced by U+FFFD REPLACEMENT CHARACTERs. Any occurrences of such characters is a parse error.
+ * All U+0000 null characters in the input must be replaced by U+FFFD REPLACEMENT CHARACTERs. Any occurrences of such characters is a parse error.
*/
for ($i = 0, $count = substr_count($data, "\0"); $i < $count; $i ++) {
$errors[] = 'null-character';
diff --git a/src/HTML5/Serializer/OutputRules.php b/src/HTML5/Serializer/OutputRules.php
index 6f02956..2969383 100644
--- a/src/HTML5/Serializer/OutputRules.php
+++ b/src/HTML5/Serializer/OutputRules.php
@@ -24,7 +24,7 @@ class OutputRules implements \Masterminds\HTML5\Serializer\RulesInterface
protected $traverser;
- protected $encode = FALSE;
+ protected $encode = false;
protected $out;
@@ -179,7 +179,7 @@ class OutputRules implements \Masterminds\HTML5\Serializer\RulesInterface
$len = $map->length;
for ($i = 0; $i < $len; ++ $i) {
$node = $map->item($i);
- $val = $this->enc($node->value, TRUE);
+ $val = $this->enc($node->value, true);
// XXX: The spec says that we need to ensure that anything in
// the XML, XMLNS, or XLink NS's should use the canonical
@@ -249,7 +249,7 @@ class OutputRules implements \Masterminds\HTML5\Serializer\RulesInterface
/**
* Encode text.
*
- * When encode is set to FALSE, the default value, the text passed in is
+ * When encode is set to false, the default value, the text passed in is
* escaped per section 8.3 of the html5 spec. For details on how text is
* escaped see the escape() method.
*
@@ -275,7 +275,7 @@ class OutputRules implements \Masterminds\HTML5\Serializer\RulesInterface
*
* @return string The encoded text.
*/
- protected function enc($text, $attribute = FALSE)
+ protected function enc($text, $attribute = false)
{
// Escape the text rather than convert to named character references.
@@ -286,7 +286,7 @@ class OutputRules implements \Masterminds\HTML5\Serializer\RulesInterface
// If we are in PHP 5.4+ we can use the native html5 entity functionality to
// convert the named character references.
if (defined('ENT_HTML5')) {
- return htmlentities($text, ENT_HTML5 | ENT_SUBSTITUTE | ENT_QUOTES, 'UTF-8', FALSE);
+ return htmlentities($text, ENT_HTML5 | ENT_SUBSTITUTE | ENT_QUOTES, 'UTF-8', false);
} // If a version earlier than 5.4 html5 entities are not entirely handled.
// This manually handles them.
else {
@@ -313,7 +313,7 @@ class OutputRules implements \Masterminds\HTML5\Serializer\RulesInterface
* @param boolean $attribute
* True if we are escaping an attrubute, false otherwise
*/
- protected function escape($text, $attribute = FALSE)
+ protected function escape($text, $attribute = false)
{
// Not using htmlspecialchars because, while it does escaping, it doesn't
diff --git a/src/HTML5/Serializer/Traverser.php b/src/HTML5/Serializer/Traverser.php
index 3bd55b4..e910f3a 100644
--- a/src/HTML5/Serializer/Traverser.php
+++ b/src/HTML5/Serializer/Traverser.php
@@ -26,7 +26,7 @@ class Traverser
protected $options;
- protected $encode = FALSE;
+ protected $encode = false;
protected $rules;
@@ -43,7 +43,7 @@ class Traverser
* @param array $options
* An array or options for the traverser as key/value pairs. These include:
* - encode_entities: A bool to specify if full encding should happen for all named
- * charachter references. Defaults to FALSE which escapes &'<>".
+ * charachter references. Defaults to false which escapes &'<>".
* - output_rules: The path to the class handling the output rules.
*/
public function __construct($dom, $out, RulesInterface $rules, $options = array())
@@ -142,7 +142,7 @@ class Traverser
{
$uri = $ele->namespaceURI;
if (empty($uri)) {
- return FALSE;
+ return false;
}
return isset(static::$local_ns[$uri]);