You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.6 KiB

3 years ago
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\CssSelector\Exception;
  11. use Symfony\Component\CssSelector\Parser\Token;
  12. /**
  13. * ParseException is thrown when a CSS selector syntax is not valid.
  14. *
  15. * This component is a port of the Python cssselect library,
  16. * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
  17. *
  18. * @author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>
  19. */
  20. class SyntaxErrorException extends ParseException
  21. {
  22. /**
  23. * @return self
  24. */
  25. public static function unexpectedToken(string $expectedValue, Token $foundToken)
  26. {
  27. return new self(sprintf('Expected %s, but %s found.', $expectedValue, $foundToken));
  28. }
  29. /**
  30. * @return self
  31. */
  32. public static function pseudoElementFound(string $pseudoElement, string $unexpectedLocation)
  33. {
  34. return new self(sprintf('Unexpected pseudo-element "::%s" found %s.', $pseudoElement, $unexpectedLocation));
  35. }
  36. /**
  37. * @return self
  38. */
  39. public static function unclosedString(int $position)
  40. {
  41. return new self(sprintf('Unclosed/invalid string at %s.', $position));
  42. }
  43. /**
  44. * @return self
  45. */
  46. public static function nestedNot()
  47. {
  48. return new self('Got nested ::not().');
  49. }
  50. /**
  51. * @return self
  52. */
  53. public static function stringAsFunctionArgument()
  54. {
  55. return new self('String not allowed as function argument.');
  56. }
  57. }