Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\CssSelector\Parser\Shortcut; Chris@0: Chris@0: use Symfony\Component\CssSelector\Node\ElementNode; Chris@0: use Symfony\Component\CssSelector\Node\SelectorNode; Chris@0: use Symfony\Component\CssSelector\Parser\ParserInterface; Chris@0: Chris@0: /** Chris@0: * CSS selector class parser shortcut. Chris@0: * Chris@0: * This shortcut ensure compatibility with previous version. Chris@0: * - The parser fails to parse an empty string. Chris@0: * - In the previous version, an empty string matches each tags. Chris@0: * Chris@0: * This component is a port of the Python cssselect library, Chris@0: * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect. Chris@0: * Chris@0: * @author Jean-François Simon Chris@0: * Chris@0: * @internal Chris@0: */ Chris@0: class EmptyStringParser implements ParserInterface Chris@0: { Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function parse($source) Chris@0: { Chris@0: // Matches an empty string Chris@14: if ('' == $source) { Chris@17: return [new SelectorNode(new ElementNode(null, '*'))]; Chris@0: } Chris@0: Chris@17: return []; Chris@0: } Chris@0: }