Skip to content

Commit

Permalink
Merge branch '2.8' into 3.4
Browse files Browse the repository at this point in the history
* 2.8:
  Fix Clidumper tests
  Enable the fixer enforcing fully-qualified calls for compiler-optimized functions
  Apply fixers
  Disable the native_constant_invocation fixer until it can be scoped
  Update the list of excluded files for the CS fixer
  • Loading branch information
nicolas-grekas committed Jul 26, 2018
2 parents d2ce522 + c2dfbf9 commit 64a32d5
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Node/AbstractNode.php
Expand Up @@ -34,7 +34,7 @@ abstract class AbstractNode implements NodeInterface
public function getNodeName()
{
if (null === $this->nodeName) {
$this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', get_called_class());
$this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', \get_called_class());
}

return $this->nodeName;
Expand Down
2 changes: 1 addition & 1 deletion Parser/Handler/HashHandler.php
Expand Up @@ -51,7 +51,7 @@ public function handle(Reader $reader, TokenStream $stream)

$value = $this->escaping->escapeUnicode($match[1]);
$stream->push(new Token(Token::TYPE_HASH, $value, $reader->getPosition()));
$reader->moveForward(strlen($match[0]));
$reader->moveForward(\strlen($match[0]));

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Parser/Handler/IdentifierHandler.php
Expand Up @@ -51,7 +51,7 @@ public function handle(Reader $reader, TokenStream $stream)

$value = $this->escaping->escapeUnicode($match[0]);
$stream->push(new Token(Token::TYPE_IDENTIFIER, $value, $reader->getPosition()));
$reader->moveForward(strlen($match[0]));
$reader->moveForward(\strlen($match[0]));

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Parser/Handler/NumberHandler.php
Expand Up @@ -47,7 +47,7 @@ public function handle(Reader $reader, TokenStream $stream)
}

$stream->push(new Token(Token::TYPE_NUMBER, $match[0], $reader->getPosition()));
$reader->moveForward(strlen($match[0]));
$reader->moveForward(\strlen($match[0]));

return true;
}
Expand Down
8 changes: 4 additions & 4 deletions Parser/Handler/StringHandler.php
Expand Up @@ -47,7 +47,7 @@ public function handle(Reader $reader, TokenStream $stream)
{
$quote = $reader->getSubstring(1);

if (!in_array($quote, array("'", '"'))) {
if (!\in_array($quote, array("'", '"'))) {
return false;
}

Expand All @@ -59,18 +59,18 @@ public function handle(Reader $reader, TokenStream $stream)
}

// check unclosed strings
if (strlen($match[0]) === $reader->getRemainingLength()) {
if (\strlen($match[0]) === $reader->getRemainingLength()) {
throw SyntaxErrorException::unclosedString($reader->getPosition() - 1);
}

// check quotes pairs validity
if ($quote !== $reader->getSubstring(1, strlen($match[0]))) {
if ($quote !== $reader->getSubstring(1, \strlen($match[0]))) {
throw SyntaxErrorException::unclosedString($reader->getPosition() - 1);
}

$string = $this->escaping->escapeUnicodeAndNewLine($match[0]);
$stream->push(new Token(Token::TYPE_STRING, $string, $reader->getPosition()));
$reader->moveForward(strlen($match[0]) + 1);
$reader->moveForward(\strlen($match[0]) + 1);

return true;
}
Expand Down
2 changes: 1 addition & 1 deletion Parser/Handler/WhitespaceHandler.php
Expand Up @@ -39,7 +39,7 @@ public function handle(Reader $reader, TokenStream $stream)
}

$stream->push(new Token(Token::TYPE_WHITESPACE, $match[0], $reader->getPosition()));
$reader->moveForward(strlen($match[0]));
$reader->moveForward(\strlen($match[0]));

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions Parser/Parser.php
Expand Up @@ -169,7 +169,7 @@ private function parseSimpleSelector(TokenStream $stream, $insideNegation = fals
{
$stream->skipWhitespace();

$selectorStart = count($stream->getUsed());
$selectorStart = \count($stream->getUsed());
$result = $this->parseElementNode($stream);
$pseudoElement = null;

Expand Down Expand Up @@ -206,7 +206,7 @@ private function parseSimpleSelector(TokenStream $stream, $insideNegation = fals
}

$identifier = $stream->getNextIdentifier();
if (in_array(strtolower($identifier), array('first-line', 'first-letter', 'before', 'after'))) {
if (\in_array(strtolower($identifier), array('first-line', 'first-letter', 'before', 'after'))) {
// Special case: CSS 2.1 pseudo-elements can have a single ':'.
// Any new pseudo-element must have two.
$pseudoElement = $identifier;
Expand Down Expand Up @@ -272,7 +272,7 @@ private function parseSimpleSelector(TokenStream $stream, $insideNegation = fals
}
}

if (count($stream->getUsed()) === $selectorStart) {
if (\count($stream->getUsed()) === $selectorStart) {
throw SyntaxErrorException::unexpectedToken('selector', $stream->getPeek());
}

Expand Down
2 changes: 1 addition & 1 deletion Parser/Reader.php
Expand Up @@ -33,7 +33,7 @@ class Reader
public function __construct($source)
{
$this->source = $source;
$this->length = strlen($source);
$this->length = \strlen($source);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Parser/Token.php
Expand Up @@ -92,7 +92,7 @@ public function isDelimiter(array $values = array())
return true;
}

return in_array($this->value, $values);
return \in_array($this->value, $values);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions Parser/Tokenizer/TokenizerEscaping.php
Expand Up @@ -65,13 +65,13 @@ private function replaceUnicodeSequences($value)
$c = hexdec($match[1]);

if (0x80 > $c %= 0x200000) {
return chr($c);
return \chr($c);
}
if (0x800 > $c) {
return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
return \chr(0xC0 | $c >> 6).\chr(0x80 | $c & 0x3F);
}
if (0x10000 > $c) {
return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
return \chr(0xE0 | $c >> 12).\chr(0x80 | $c >> 6 & 0x3F).\chr(0x80 | $c & 0x3F);
}
}, $value);
}
Expand Down
2 changes: 1 addition & 1 deletion Tests/Parser/Handler/AbstractHandlerTest.php
Expand Up @@ -63,7 +63,7 @@ protected function assertRemainingContent(Reader $reader, $remainingContent)
$this->assertEquals(0, $reader->getRemainingLength());
$this->assertTrue($reader->isEOF());
} else {
$this->assertEquals(strlen($remainingContent), $reader->getRemainingLength());
$this->assertEquals(\strlen($remainingContent), $reader->getRemainingLength());
$this->assertEquals(0, $reader->getOffset($remainingContent));
}
}
Expand Down
8 changes: 4 additions & 4 deletions Tests/XPath/TranslatorTest.php
Expand Up @@ -37,9 +37,9 @@ public function testXmlLang($css, array $elementsId)
$translator = new Translator();
$document = new \SimpleXMLElement(file_get_contents(__DIR__.'/Fixtures/lang.xml'));
$elements = $document->xpath($translator->cssToXPath($css));
$this->assertCount(count($elementsId), $elements);
$this->assertCount(\count($elementsId), $elements);
foreach ($elements as $element) {
$this->assertTrue(in_array($element->attributes()->id, $elementsId));
$this->assertTrue(\in_array($element->attributes()->id, $elementsId));
}
}

Expand All @@ -54,10 +54,10 @@ public function testHtmlIds($css, array $elementsId)
$document->loadHTMLFile(__DIR__.'/Fixtures/ids.html');
$document = simplexml_import_dom($document);
$elements = $document->xpath($translator->cssToXPath($css));
$this->assertCount(count($elementsId), $elementsId);
$this->assertCount(\count($elementsId), $elementsId);
foreach ($elements as $element) {
if (null !== $element->attributes()->id) {
$this->assertTrue(in_array($element->attributes()->id, $elementsId));
$this->assertTrue(\in_array($element->attributes()->id, $elementsId));
}
}
libxml_clear_errors();
Expand Down
2 changes: 1 addition & 1 deletion XPath/Extension/AttributeMatchingExtension.php
Expand Up @@ -128,7 +128,7 @@ public function translateSuffixMatch(XPathExpr $xpath, $attribute, $value)
return $xpath->addCondition($value ? sprintf(
'%1$s and substring(%1$s, string-length(%1$s)-%2$s) = %3$s',
$attribute,
strlen($value) - 1,
\strlen($value) - 1,
Translator::getXpathLiteral($value)
) : '0');
}
Expand Down
10 changes: 5 additions & 5 deletions XPath/Translator.php
Expand Up @@ -176,7 +176,7 @@ public function nodeToXPath(NodeInterface $node)
throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName()));
}

return call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this);
return \call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this);
}

/**
Expand All @@ -194,7 +194,7 @@ public function addCombination($combiner, NodeInterface $xpath, NodeInterface $c
throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner));
}

return call_user_func($this->combinationTranslators[$combiner], $this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
return \call_user_func($this->combinationTranslators[$combiner], $this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
}

/**
Expand All @@ -208,7 +208,7 @@ public function addFunction(XPathExpr $xpath, FunctionNode $function)
throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName()));
}

return call_user_func($this->functionTranslators[$function->getName()], $xpath, $function);
return \call_user_func($this->functionTranslators[$function->getName()], $xpath, $function);
}

/**
Expand All @@ -225,7 +225,7 @@ public function addPseudoClass(XPathExpr $xpath, $pseudoClass)
throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass));
}

return call_user_func($this->pseudoClassTranslators[$pseudoClass], $xpath);
return \call_user_func($this->pseudoClassTranslators[$pseudoClass], $xpath);
}

/**
Expand All @@ -244,7 +244,7 @@ public function addAttributeMatching(XPathExpr $xpath, $operator, $attribute, $v
throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator));
}

return call_user_func($this->attributeMatchingTranslators[$operator], $xpath, $attribute, $value);
return \call_user_func($this->attributeMatchingTranslators[$operator], $xpath, $attribute, $value);
}

/**
Expand Down

0 comments on commit 64a32d5

Please sign in to comment.