Drupal investigation

SyntaxErrorException.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * @param string $expectedValue
  24. * @param Token $foundToken
  25. *
  26. * @return self
  27. */
  28. public static function unexpectedToken($expectedValue, Token $foundToken)
  29. {
  30. return new self(sprintf('Expected %s, but %s found.', $expectedValue, $foundToken));
  31. }
  32. /**
  33. * @param string $pseudoElement
  34. * @param string $unexpectedLocation
  35. *
  36. * @return self
  37. */
  38. public static function pseudoElementFound($pseudoElement, $unexpectedLocation)
  39. {
  40. return new self(sprintf('Unexpected pseudo-element "::%s" found %s.', $pseudoElement, $unexpectedLocation));
  41. }
  42. /**
  43. * @param int $position
  44. *
  45. * @return self
  46. */
  47. public static function unclosedString($position)
  48. {
  49. return new self(sprintf('Unclosed/invalid string at %s.', $position));
  50. }
  51. /**
  52. * @return self
  53. */
  54. public static function nestedNot()
  55. {
  56. return new self('Got nested ::not().');
  57. }
  58. /**
  59. * @return self
  60. */
  61. public static function stringAsFunctionArgument()
  62. {
  63. return new self('String not allowed as function argument.');
  64. }
  65. }