[CssSelector] fixed coding standards: removed perl comment style

This commit is contained in:
Pascal Borreli 2010-04-02 23:48:10 +00:00 committed by Fabien Potencier
parent cb8fb71a73
commit 5d99cba7ab
8 changed files with 41 additions and 41 deletions

View File

@ -68,7 +68,7 @@ class AttribNode implements NodeInterface
} }
elseif ($this->operator == '!=') elseif ($this->operator == '!=')
{ {
# FIXME: this seems like a weird hack... // FIXME: this seems like a weird hack...
if ($value) if ($value)
{ {
$path->addCondition(sprintf('not(%s) or %s != %s', $attrib, $attrib, XPathExpr::xpathLiteral($value))); $path->addCondition(sprintf('not(%s) or %s != %s', $attrib, $attrib, XPathExpr::xpathLiteral($value)));
@ -77,7 +77,7 @@ class AttribNode implements NodeInterface
{ {
$path->addCondition(sprintf('%s != %s', $attrib, XPathExpr::xpathLiteral($value))); $path->addCondition(sprintf('%s != %s', $attrib, XPathExpr::xpathLiteral($value)));
} }
#path.addCondition('%s != %s' % (attrib, xpathLiteral(value))) // path.addCondition('%s != %s' % (attrib, xpathLiteral(value)))
} }
elseif ($this->operator == '~=') elseif ($this->operator == '~=')
{ {
@ -85,7 +85,7 @@ class AttribNode implements NodeInterface
} }
elseif ($this->operator == '|=') elseif ($this->operator == '|=')
{ {
# Weird, but true... // Weird, but true...
$path->addCondition(sprintf('%s = %s or starts-with(%s, %s)', $attrib, XPathExpr::xpathLiteral($value), $attrib, XPathExpr::xpathLiteral($value.'-'))); $path->addCondition(sprintf('%s = %s or starts-with(%s, %s)', $attrib, XPathExpr::xpathLiteral($value), $attrib, XPathExpr::xpathLiteral($value.'-')));
} }
elseif ($this->operator == '^=') elseif ($this->operator == '^=')
@ -94,12 +94,12 @@ class AttribNode implements NodeInterface
} }
elseif ($this->operator == '$=') elseif ($this->operator == '$=')
{ {
# Oddly there is a starts-with in XPath 1.0, but not ends-with // Oddly there is a starts-with in XPath 1.0, but not ends-with
$path->addCondition(sprintf('substring(%s, string-length(%s)-%s) = %s', $attrib, $attrib, strlen($value) - 1, XPathExpr::xpathLiteral($value))); $path->addCondition(sprintf('substring(%s, string-length(%s)-%s) = %s', $attrib, $attrib, strlen($value) - 1, XPathExpr::xpathLiteral($value)));
} }
elseif ($this->operator == '*=') elseif ($this->operator == '*=')
{ {
# FIXME: case sensitive? // FIXME: case sensitive?
$path->addCondition(sprintf('contains(%s, %s)', $attrib, XPathExpr::xpathLiteral($value))); $path->addCondition(sprintf('contains(%s, %s)', $attrib, XPathExpr::xpathLiteral($value)));
} }
else else
@ -112,7 +112,7 @@ class AttribNode implements NodeInterface
protected function xpathAttrib() protected function xpathAttrib()
{ {
# FIXME: if attrib is *? // FIXME: if attrib is *?
if ($this->namespace == '*') if ($this->namespace == '*')
{ {
return '@'.$this->attrib; return '@'.$this->attrib;

View File

@ -65,7 +65,7 @@ class CombinedSelectorNode implements NodeInterface
protected function _xpath_descendant($xpath, $sub) protected function _xpath_descendant($xpath, $sub)
{ {
# when sub is a descendant in any way of xpath // when sub is a descendant in any way of xpath
$xpath->join('/descendant::', $sub->toXpath()); $xpath->join('/descendant::', $sub->toXpath());
return $xpath; return $xpath;
@ -73,7 +73,7 @@ class CombinedSelectorNode implements NodeInterface
protected function _xpath_child($xpath, $sub) protected function _xpath_child($xpath, $sub)
{ {
# when sub is an immediate child of xpath // when sub is an immediate child of xpath
$xpath->join('/', $sub->toXpath()); $xpath->join('/', $sub->toXpath());
return $xpath; return $xpath;
@ -81,7 +81,7 @@ class CombinedSelectorNode implements NodeInterface
protected function _xpath_direct_adjacent($xpath, $sub) protected function _xpath_direct_adjacent($xpath, $sub)
{ {
# when sub immediately follows xpath // when sub immediately follows xpath
$xpath->join('/following-sibling::', $sub->toXpath()); $xpath->join('/following-sibling::', $sub->toXpath());
$xpath->addNameTest(); $xpath->addNameTest();
$xpath->addCondition('position() = 1'); $xpath->addCondition('position() = 1');
@ -91,7 +91,7 @@ class CombinedSelectorNode implements NodeInterface
protected function _xpath_indirect_adjacent($xpath, $sub) protected function _xpath_indirect_adjacent($xpath, $sub)
{ {
# when sub comes somewhere after xpath as a sibling // when sub comes somewhere after xpath as a sibling
$xpath->join('/following-sibling::', $sub->toXpath()); $xpath->join('/following-sibling::', $sub->toXpath());
return $xpath; return $xpath;

View File

@ -59,7 +59,7 @@ class ElementNode implements NodeInterface
} }
else else
{ {
# FIXME: Should we lowercase here? // FIXME: Should we lowercase here?
$el = sprintf('%s:%s', $this->namespace, $this->element); $el = sprintf('%s:%s', $this->namespace, $this->element);
} }

View File

@ -67,7 +67,7 @@ class FunctionNode implements NodeInterface
list($a, $b) = $this->parseSeries($expr); list($a, $b) = $this->parseSeries($expr);
if (!$a && !$b && !$last) if (!$a && !$b && !$last)
{ {
# a=0 means nothing is returned... // a=0 means nothing is returned...
$xpath->addCondition('false() and position() = 0'); $xpath->addCondition('false() and position() = 0');
return $xpath; return $xpath;
@ -92,7 +92,7 @@ class FunctionNode implements NodeInterface
if ($last) if ($last)
{ {
# FIXME: I'm not sure if this is right // FIXME: I'm not sure if this is right
$a = -$a; $a = -$a;
$b = -$b; $b = -$b;
} }
@ -131,13 +131,13 @@ class FunctionNode implements NodeInterface
} }
return $xpath; return $xpath;
# FIXME: handle an+b, odd, even /* FIXME: handle an+b, odd, even
# an+b means every-a, plus b, e.g., 2n+1 means odd an+b means every-a, plus b, e.g., 2n+1 means odd
# 0n+b means b 0n+b means b
# n+0 means a=1, i.e., all elements n+0 means a=1, i.e., all elements
# an means every a elements, i.e., 2n means even an means every a elements, i.e., 2n means even
# -n means -1n -n means -1n
# -1n+6 means elements 6 and previous -1n+6 means elements 6 and previous */
} }
protected function _xpath_nth_last_child($xpath, $expr) protected function _xpath_nth_last_child($xpath, $expr)
@ -162,23 +162,23 @@ class FunctionNode implements NodeInterface
protected function _xpath_contains($xpath, $expr) protected function _xpath_contains($xpath, $expr)
{ {
# text content, minus tags, must contain expr // text content, minus tags, must contain expr
if ($expr instanceof ElementNode) if ($expr instanceof ElementNode)
{ {
$expr = $expr->formatElement(); $expr = $expr->formatElement();
} }
$xpath->addCondition(sprintf('contains(css:lower-case(string(.)), %s)', XPathExpr::xpathLiteral(strtolower($expr)))); $xpath->addCondition(sprintf('contains(css:lower-case(string(.)), %s)', XPathExpr::xpathLiteral(strtolower($expr))));
# FIXME: Currently case insensitive matching doesn't seem to be happening // FIXME: Currently case insensitive matching doesn't seem to be happening
return $xpath; return $xpath;
} }
protected function _xpath_not($xpath, $expr) protected function _xpath_not($xpath, $expr)
{ {
# everything for which not expr applies // everything for which not expr applies
$expr = $expr->toXpath(); $expr = $expr->toXpath();
$cond = $expr->getCondition(); $cond = $expr->getCondition();
# FIXME: should I do something about element_path? // FIXME: should I do something about element_path?
$xpath->addCondition(sprintf('not(%s)', $cond)); $xpath->addCondition(sprintf('not(%s)', $cond));
return $xpath; return $xpath;
@ -194,13 +194,13 @@ class FunctionNode implements NodeInterface
if (!$s || $s == '*') if (!$s || $s == '*')
{ {
# Happens when there's nothing, which the CSS parser thinks of as * // Happens when there's nothing, which the CSS parser thinks of as *
return array(0, 0); return array(0, 0);
} }
if (is_string($s)) if (is_string($s))
{ {
# Happens when you just get a number // Happens when you just get a number
return array(0, $s); return array(0, $s);
} }
@ -219,7 +219,7 @@ class FunctionNode implements NodeInterface
if (false === strpos($s, 'n')) if (false === strpos($s, 'n'))
{ {
# Just a b // Just a b
return array(0, intval((string) $s)); return array(0, intval((string) $s));
} }

View File

@ -72,7 +72,7 @@ class PseudoNode implements NodeInterface
protected function xpath_checked($xpath) protected function xpath_checked($xpath)
{ {
# FIXME: is this really all the elements? // FIXME: is this really all the elements?
$xpath->addCondition("(@selected or @checked) and (name(.) = 'input' or name(.) = 'option')"); $xpath->addCondition("(@selected or @checked) and (name(.) = 'input' or name(.) = 'option')");
return $xpath; return $xpath;
@ -80,7 +80,7 @@ class PseudoNode implements NodeInterface
protected function xpath_root($xpath) protected function xpath_root($xpath)
{ {
# if this element is the root element // if this element is the root element
throw new SyntaxError(); throw new SyntaxError();
} }

View File

@ -123,7 +123,7 @@ class Parser
} }
elseif (in_array($peek, array('+', '>', '~'))) elseif (in_array($peek, array('+', '>', '~')))
{ {
# A combinator // A combinator
$combinator = (string) $stream->next(); $combinator = (string) $stream->next();
} }
else else
@ -184,8 +184,8 @@ class Parser
{ {
if ($has_hash) if ($has_hash)
{ {
# You can't have two hashes /* You can't have two hashes
# (FIXME: is there some more general rule I'm missing?) (FIXME: is there some more general rule I'm missing?) */
// @codeCoverageIgnoreStart // @codeCoverageIgnoreStart
break; break;
// @codeCoverageIgnoreEnd // @codeCoverageIgnoreEnd
@ -238,7 +238,7 @@ class Parser
} }
else else
{ {
# FIXME: parseSimpleSelector, or selector, or...? // FIXME: parseSimpleSelector, or selector, or...?
$selector = $this->parseSimpleSelector($stream); $selector = $this->parseSimpleSelector($stream);
} }
$next = $stream->next(); $next = $stream->next();
@ -265,7 +265,7 @@ class Parser
break; break;
} }
# FIXME: not sure what "negation" is // FIXME: not sure what "negation" is
} }
return $result; return $result;

View File

@ -90,7 +90,7 @@ class Tokenizer
if ($c === '"' || $c === "'") if ($c === '"' || $c === "'")
{ {
# Quoted string // Quoted string
$old_pos = $pos; $old_pos = $pos;
list($sym, $pos) = $this->tokenizeEscapedString($s, $pos); list($sym, $pos) = $this->tokenizeEscapedString($s, $pos);
@ -125,7 +125,7 @@ class Tokenizer
$result = substr($s, $start, $next - $start); $result = substr($s, $start, $next - $start);
if ('\\' === $result[strlen($result) - 1]) if ('\\' === $result[strlen($result) - 1])
{ {
# next quote character is escaped // next quote character is escaped
$pos = $next + 1; $pos = $next + 1;
$continue; $continue;
} }
@ -164,7 +164,7 @@ class Tokenizer
if (!preg_match('#[^\w\-]#', $s, $match, PREG_OFFSET_CAPTURE, $pos)) if (!preg_match('#[^\w\-]#', $s, $match, PREG_OFFSET_CAPTURE, $pos))
{ {
# Goes to end of s // Goes to end of s
return array(substr($s, $start), strlen($s)); return array(substr($s, $start), strlen($s));
} }

View File

@ -99,7 +99,7 @@ class XPathExpr
{ {
if ($this->element == '*') if ($this->element == '*')
{ {
# We weren't doing a test anyway // We weren't doing a test anyway
return; return;
} }
@ -132,8 +132,8 @@ class XPathExpr
$prefix .= $combiner; $prefix .= $combiner;
$path = $other->prefix.$other->path; $path = $other->prefix.$other->path;
# We don't need a star prefix if we are joining to this other /* We don't need a star prefix if we are joining to this other
# prefix; so we'll get rid of it prefix; so we'll get rid of it */
if ($other->starPrefix && $path == '*/') if ($other->starPrefix && $path == '*/')
{ {
$path = ''; $path = '';
@ -148,7 +148,7 @@ class XPathExpr
{ {
if ($s instanceof Node\ElementNode) if ($s instanceof Node\ElementNode)
{ {
# This is probably a symbol that looks like an expression... // This is probably a symbol that looks like an expression...
$s = $s->formatElement(); $s = $s->formatElement();
} }
else else