diff --git a/LICENSE b/LICENSE index 0083704..0138f8f 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2004-2023 Fabien Potencier +Copyright (c) 2004-present Fabien Potencier Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Tests/CssSelectorConverterTest.php b/Tests/CssSelectorConverterTest.php index 5fca693..36d39f3 100644 --- a/Tests/CssSelectorConverterTest.php +++ b/Tests/CssSelectorConverterTest.php @@ -60,7 +60,7 @@ public function testCssToXPathWithoutPrefix($css, $xpath) $this->assertEquals($xpath, $converter->toXPath($css, ''), '->parse() parses an input string and returns a node'); } - public function getCssToXPathWithoutPrefixTestData() + public static function getCssToXPathWithoutPrefixTestData() { return [ ['h1', 'h1'], diff --git a/Tests/Node/AbstractNodeTest.php b/Tests/Node/AbstractNodeTestCase.php similarity index 80% rename from Tests/Node/AbstractNodeTest.php rename to Tests/Node/AbstractNodeTestCase.php index 5955513..521e6d8 100644 --- a/Tests/Node/AbstractNodeTest.php +++ b/Tests/Node/AbstractNodeTestCase.php @@ -14,7 +14,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\CssSelector\Node\NodeInterface; -abstract class AbstractNodeTest extends TestCase +abstract class AbstractNodeTestCase extends TestCase { /** @dataProvider getToStringConversionTestData */ public function testToStringConversion(NodeInterface $node, $representation) @@ -28,7 +28,7 @@ public function testSpecificityValue(NodeInterface $node, $value) $this->assertEquals($value, $node->getSpecificity()->getValue()); } - abstract public function getToStringConversionTestData(); + abstract public static function getToStringConversionTestData(); - abstract public function getSpecificityValueTestData(); + abstract public static function getSpecificityValueTestData(); } diff --git a/Tests/Node/AttributeNodeTest.php b/Tests/Node/AttributeNodeTest.php index 4d60074..62364c4 100644 --- a/Tests/Node/AttributeNodeTest.php +++ b/Tests/Node/AttributeNodeTest.php @@ -14,9 +14,9 @@ use Symfony\Component\CssSelector\Node\AttributeNode; use Symfony\Component\CssSelector\Node\ElementNode; -class AttributeNodeTest extends AbstractNodeTest +class AttributeNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 'Attribute[Element[*][attribute]]'], @@ -25,7 +25,7 @@ public function getToStringConversionTestData() ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 10], diff --git a/Tests/Node/ClassNodeTest.php b/Tests/Node/ClassNodeTest.php index aa80c92..3c0c67a 100644 --- a/Tests/Node/ClassNodeTest.php +++ b/Tests/Node/ClassNodeTest.php @@ -14,16 +14,16 @@ use Symfony\Component\CssSelector\Node\ClassNode; use Symfony\Component\CssSelector\Node\ElementNode; -class ClassNodeTest extends AbstractNodeTest +class ClassNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new ClassNode(new ElementNode(), 'class'), 'Class[Element[*].class]'], ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new ClassNode(new ElementNode(), 'class'), 10], diff --git a/Tests/Node/CombinedSelectorNodeTest.php b/Tests/Node/CombinedSelectorNodeTest.php index 435eaa6..bf9ed06 100644 --- a/Tests/Node/CombinedSelectorNodeTest.php +++ b/Tests/Node/CombinedSelectorNodeTest.php @@ -14,9 +14,9 @@ use Symfony\Component\CssSelector\Node\CombinedSelectorNode; use Symfony\Component\CssSelector\Node\ElementNode; -class CombinedSelectorNodeTest extends AbstractNodeTest +class CombinedSelectorNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 'CombinedSelector[Element[*] > Element[*]]'], @@ -24,7 +24,7 @@ public function getToStringConversionTestData() ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 0], diff --git a/Tests/Node/ElementNodeTest.php b/Tests/Node/ElementNodeTest.php index e0797ff..e864eec 100644 --- a/Tests/Node/ElementNodeTest.php +++ b/Tests/Node/ElementNodeTest.php @@ -13,9 +13,9 @@ use Symfony\Component\CssSelector\Node\ElementNode; -class ElementNodeTest extends AbstractNodeTest +class ElementNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new ElementNode(), 'Element[*]'], @@ -24,7 +24,7 @@ public function getToStringConversionTestData() ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new ElementNode(), 0], diff --git a/Tests/Node/FunctionNodeTest.php b/Tests/Node/FunctionNodeTest.php index 0932393..b8d2e7a 100644 --- a/Tests/Node/FunctionNodeTest.php +++ b/Tests/Node/FunctionNodeTest.php @@ -15,9 +15,9 @@ use Symfony\Component\CssSelector\Node\FunctionNode; use Symfony\Component\CssSelector\Parser\Token; -class FunctionNodeTest extends AbstractNodeTest +class FunctionNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new FunctionNode(new ElementNode(), 'function'), 'Function[Element[*]:function()]'], @@ -31,7 +31,7 @@ public function getToStringConversionTestData() ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new FunctionNode(new ElementNode(), 'function'), 10], diff --git a/Tests/Node/HashNodeTest.php b/Tests/Node/HashNodeTest.php index ad6765b..a33cdd9 100644 --- a/Tests/Node/HashNodeTest.php +++ b/Tests/Node/HashNodeTest.php @@ -14,16 +14,16 @@ use Symfony\Component\CssSelector\Node\ElementNode; use Symfony\Component\CssSelector\Node\HashNode; -class HashNodeTest extends AbstractNodeTest +class HashNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new HashNode(new ElementNode(), 'id'), 'Hash[Element[*]#id]'], ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new HashNode(new ElementNode(), 'id'), 100], diff --git a/Tests/Node/NegationNodeTest.php b/Tests/Node/NegationNodeTest.php index 90b684c..f90fa36 100644 --- a/Tests/Node/NegationNodeTest.php +++ b/Tests/Node/NegationNodeTest.php @@ -15,16 +15,16 @@ use Symfony\Component\CssSelector\Node\ElementNode; use Symfony\Component\CssSelector\Node\NegationNode; -class NegationNodeTest extends AbstractNodeTest +class NegationNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 'Negation[Element[*]:not(Class[Element[*].class])]'], ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 10], diff --git a/Tests/Node/PseudoNodeTest.php b/Tests/Node/PseudoNodeTest.php index 4e78776..f4c7404 100644 --- a/Tests/Node/PseudoNodeTest.php +++ b/Tests/Node/PseudoNodeTest.php @@ -14,16 +14,16 @@ use Symfony\Component\CssSelector\Node\ElementNode; use Symfony\Component\CssSelector\Node\PseudoNode; -class PseudoNodeTest extends AbstractNodeTest +class PseudoNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new PseudoNode(new ElementNode(), 'pseudo'), 'Pseudo[Element[*]:pseudo]'], ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new PseudoNode(new ElementNode(), 'pseudo'), 10], diff --git a/Tests/Node/SelectorNodeTest.php b/Tests/Node/SelectorNodeTest.php index 85e3bda..3bf6666 100644 --- a/Tests/Node/SelectorNodeTest.php +++ b/Tests/Node/SelectorNodeTest.php @@ -14,9 +14,9 @@ use Symfony\Component\CssSelector\Node\ElementNode; use Symfony\Component\CssSelector\Node\SelectorNode; -class SelectorNodeTest extends AbstractNodeTest +class SelectorNodeTest extends AbstractNodeTestCase { - public function getToStringConversionTestData() + public static function getToStringConversionTestData() { return [ [new SelectorNode(new ElementNode()), 'Selector[Element[*]]'], @@ -24,7 +24,7 @@ public function getToStringConversionTestData() ]; } - public function getSpecificityValueTestData() + public static function getSpecificityValueTestData() { return [ [new SelectorNode(new ElementNode()), 0], diff --git a/Tests/Node/SpecificityTest.php b/Tests/Node/SpecificityTest.php index bf48d49..8802e0c 100644 --- a/Tests/Node/SpecificityTest.php +++ b/Tests/Node/SpecificityTest.php @@ -28,7 +28,7 @@ public function testPlusValue(Specificity $specificity, $value) $this->assertEquals($value + 123, $specificity->plus(new Specificity(1, 2, 3))->getValue()); } - public function getValueTestData() + public static function getValueTestData() { return [ [new Specificity(0, 0, 0), 0], @@ -45,7 +45,7 @@ public function testCompareTo(Specificity $a, Specificity $b, $result) $this->assertEquals($result, $a->compareTo($b)); } - public function getCompareTestData() + public static function getCompareTestData() { return [ [new Specificity(0, 0, 0), new Specificity(0, 0, 0), 0], diff --git a/Tests/Parser/Handler/AbstractHandlerTest.php b/Tests/Parser/Handler/AbstractHandlerTestCase.php similarity index 91% rename from Tests/Parser/Handler/AbstractHandlerTest.php rename to Tests/Parser/Handler/AbstractHandlerTestCase.php index 8afc7ae..30ce10e 100644 --- a/Tests/Parser/Handler/AbstractHandlerTest.php +++ b/Tests/Parser/Handler/AbstractHandlerTestCase.php @@ -19,7 +19,7 @@ /** * @author Jean-François Simon */ -abstract class AbstractHandlerTest extends TestCase +abstract class AbstractHandlerTestCase extends TestCase { /** @dataProvider getHandleValueTestData */ public function testHandleValue($value, Token $expectedToken, $remainingContent) @@ -43,9 +43,9 @@ public function testDontHandleValue($value) $this->assertRemainingContent($reader, $value); } - abstract public function getHandleValueTestData(); + abstract public static function getHandleValueTestData(); - abstract public function getDontHandleValueTestData(); + abstract public static function getDontHandleValueTestData(); abstract protected function generateHandler(); diff --git a/Tests/Parser/Handler/CommentHandlerTest.php b/Tests/Parser/Handler/CommentHandlerTest.php index de40047..c3be7f4 100644 --- a/Tests/Parser/Handler/CommentHandlerTest.php +++ b/Tests/Parser/Handler/CommentHandlerTest.php @@ -16,7 +16,7 @@ use Symfony\Component\CssSelector\Parser\Token; use Symfony\Component\CssSelector\Parser\TokenStream; -class CommentHandlerTest extends AbstractHandlerTest +class CommentHandlerTest extends AbstractHandlerTestCase { /** @dataProvider getHandleValueTestData */ public function testHandleValue($value, Token $unusedArgument, $remainingContent) @@ -30,7 +30,7 @@ public function testHandleValue($value, Token $unusedArgument, $remainingContent $this->assertRemainingContent($reader, $remainingContent); } - public function getHandleValueTestData() + public static function getHandleValueTestData() { return [ // 2nd argument only exists for inherited method compatibility @@ -39,7 +39,7 @@ public function getHandleValueTestData() ]; } - public function getDontHandleValueTestData() + public static function getDontHandleValueTestData() { return [ ['>'], diff --git a/Tests/Parser/Handler/HashHandlerTest.php b/Tests/Parser/Handler/HashHandlerTest.php index 9444f51..c2ad031 100644 --- a/Tests/Parser/Handler/HashHandlerTest.php +++ b/Tests/Parser/Handler/HashHandlerTest.php @@ -16,9 +16,9 @@ use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; -class HashHandlerTest extends AbstractHandlerTest +class HashHandlerTest extends AbstractHandlerTestCase { - public function getHandleValueTestData() + public static function getHandleValueTestData() { return [ ['#id', new Token(Token::TYPE_HASH, 'id', 0), ''], @@ -29,7 +29,7 @@ public function getHandleValueTestData() ]; } - public function getDontHandleValueTestData() + public static function getDontHandleValueTestData() { return [ ['id'], diff --git a/Tests/Parser/Handler/IdentifierHandlerTest.php b/Tests/Parser/Handler/IdentifierHandlerTest.php index c54ba53..a39abb6 100644 --- a/Tests/Parser/Handler/IdentifierHandlerTest.php +++ b/Tests/Parser/Handler/IdentifierHandlerTest.php @@ -16,9 +16,9 @@ use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; -class IdentifierHandlerTest extends AbstractHandlerTest +class IdentifierHandlerTest extends AbstractHandlerTestCase { - public function getHandleValueTestData() + public static function getHandleValueTestData() { return [ ['foo', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ''], @@ -29,7 +29,7 @@ public function getHandleValueTestData() ]; } - public function getDontHandleValueTestData() + public static function getDontHandleValueTestData() { return [ ['>'], diff --git a/Tests/Parser/Handler/NumberHandlerTest.php b/Tests/Parser/Handler/NumberHandlerTest.php index b43d369..7087a6b 100644 --- a/Tests/Parser/Handler/NumberHandlerTest.php +++ b/Tests/Parser/Handler/NumberHandlerTest.php @@ -15,9 +15,9 @@ use Symfony\Component\CssSelector\Parser\Token; use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; -class NumberHandlerTest extends AbstractHandlerTest +class NumberHandlerTest extends AbstractHandlerTestCase { - public function getHandleValueTestData() + public static function getHandleValueTestData() { return [ ['12', new Token(Token::TYPE_NUMBER, '12', 0), ''], @@ -30,7 +30,7 @@ public function getHandleValueTestData() ]; } - public function getDontHandleValueTestData() + public static function getDontHandleValueTestData() { return [ ['hello'], diff --git a/Tests/Parser/Handler/StringHandlerTest.php b/Tests/Parser/Handler/StringHandlerTest.php index baa7273..9a984ed 100644 --- a/Tests/Parser/Handler/StringHandlerTest.php +++ b/Tests/Parser/Handler/StringHandlerTest.php @@ -16,9 +16,9 @@ use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; -class StringHandlerTest extends AbstractHandlerTest +class StringHandlerTest extends AbstractHandlerTestCase { - public function getHandleValueTestData() + public static function getHandleValueTestData() { return [ ['"hello"', new Token(Token::TYPE_STRING, 'hello', 1), ''], @@ -31,7 +31,7 @@ public function getHandleValueTestData() ]; } - public function getDontHandleValueTestData() + public static function getDontHandleValueTestData() { return [ ['hello'], diff --git a/Tests/Parser/Handler/WhitespaceHandlerTest.php b/Tests/Parser/Handler/WhitespaceHandlerTest.php index 67509ef..81dd761 100644 --- a/Tests/Parser/Handler/WhitespaceHandlerTest.php +++ b/Tests/Parser/Handler/WhitespaceHandlerTest.php @@ -14,9 +14,9 @@ use Symfony\Component\CssSelector\Parser\Handler\WhitespaceHandler; use Symfony\Component\CssSelector\Parser\Token; -class WhitespaceHandlerTest extends AbstractHandlerTest +class WhitespaceHandlerTest extends AbstractHandlerTestCase { - public function getHandleValueTestData() + public static function getHandleValueTestData() { return [ [' ', new Token(Token::TYPE_WHITESPACE, ' ', 0), ''], @@ -28,7 +28,7 @@ public function getHandleValueTestData() ]; } - public function getDontHandleValueTestData() + public static function getDontHandleValueTestData() { return [ ['>'], diff --git a/Tests/Parser/ParserTest.php b/Tests/Parser/ParserTest.php index 77ce5d5..e36731b 100644 --- a/Tests/Parser/ParserTest.php +++ b/Tests/Parser/ParserTest.php @@ -93,7 +93,7 @@ public function testParseSeriesException($series) Parser::parseSeries($function->getArguments()); } - public function getParserTestData() + public static function getParserTestData() { return [ ['*', ['Element[*]']], @@ -151,7 +151,7 @@ public function getParserTestData() ]; } - public function getParserExceptionTestData() + public static function getParserExceptionTestData() { return [ ['attributes(href)/html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()], @@ -181,7 +181,7 @@ public function getParserExceptionTestData() ]; } - public function getPseudoElementsTestData() + public static function getPseudoElementsTestData() { return [ ['foo', 'Element[foo]', ''], @@ -203,7 +203,7 @@ public function getPseudoElementsTestData() ]; } - public function getSpecificityTestData() + public static function getSpecificityTestData() { return [ ['*', 0], @@ -231,7 +231,7 @@ public function getSpecificityTestData() ]; } - public function getParseSeriesTestData() + public static function getParseSeriesTestData() { return [ ['1n+3', 1, 3], @@ -253,7 +253,7 @@ public function getParseSeriesTestData() ]; } - public function getParseSeriesExceptionTestData() + public static function getParseSeriesExceptionTestData() { return [ ['foo'], diff --git a/Tests/Parser/Shortcut/ClassParserTest.php b/Tests/Parser/Shortcut/ClassParserTest.php index 29d9d5f..ded92ea 100644 --- a/Tests/Parser/Shortcut/ClassParserTest.php +++ b/Tests/Parser/Shortcut/ClassParserTest.php @@ -32,7 +32,7 @@ public function testParse($source, $representation) $this->assertEquals($representation, (string) $selector->getTree()); } - public function getParseTestData() + public static function getParseTestData() { return [ ['.testclass', 'Class[Element[*].testclass]'], diff --git a/Tests/Parser/Shortcut/ElementParserTest.php b/Tests/Parser/Shortcut/ElementParserTest.php index 79cc227..4c10029 100644 --- a/Tests/Parser/Shortcut/ElementParserTest.php +++ b/Tests/Parser/Shortcut/ElementParserTest.php @@ -32,7 +32,7 @@ public function testParse($source, $representation) $this->assertEquals($representation, (string) $selector->getTree()); } - public function getParseTestData() + public static function getParseTestData() { return [ ['*', 'Element[*]'], diff --git a/Tests/Parser/Shortcut/HashParserTest.php b/Tests/Parser/Shortcut/HashParserTest.php index a7c79d6..c8bfdef 100644 --- a/Tests/Parser/Shortcut/HashParserTest.php +++ b/Tests/Parser/Shortcut/HashParserTest.php @@ -32,7 +32,7 @@ public function testParse($source, $representation) $this->assertEquals($representation, (string) $selector->getTree()); } - public function getParseTestData() + public static function getParseTestData() { return [ ['#testid', 'Hash[Element[*]#testid]'], diff --git a/Tests/XPath/TranslatorTest.php b/Tests/XPath/TranslatorTest.php index 0a1ba4d..d330600 100644 --- a/Tests/XPath/TranslatorTest.php +++ b/Tests/XPath/TranslatorTest.php @@ -165,7 +165,7 @@ public function testOnlyOfTypeFindsSingleChildrenOfGivenType() $this->assertSame('A', $nodeList->item(0)->textContent); } - public function getXpathLiteralTestData() + public static function getXpathLiteralTestData() { return [ ['foo', "'foo'"], @@ -175,7 +175,7 @@ public function getXpathLiteralTestData() ]; } - public function getCssToXPathTestData() + public static function getCssToXPathTestData() { return [ ['*', '*'], @@ -222,7 +222,7 @@ public function getCssToXPathTestData() ]; } - public function getXmlLangTestData() + public static function getXmlLangTestData() { return [ [':lang("EN")', ['first', 'second', 'third', 'fourth']], @@ -237,7 +237,7 @@ public function getXmlLangTestData() ]; } - public function getHtmlIdsTestData() + public static function getHtmlIdsTestData() { return [ ['div', ['outer-div', 'li-div', 'foobar-div']], @@ -362,7 +362,7 @@ public function getHtmlIdsTestData() ]; } - public function getHtmlShakespearTestData() + public static function getHtmlShakespearTestData() { return [ ['*', 246],