Blame view

public/vendor/sabberworm/php-css-parser/src/Parsing/UnexpectedTokenException.php 1.44 KB
86143e36f   Андрей Ларионов   Коммит вторник
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  <?php
  
  namespace Sabberworm\CSS\Parsing;
  
  /**
   * Thrown if the CSS parser encounters a token it did not expect.
   */
  class UnexpectedTokenException extends SourceException
  {
      /**
       * @var string
       */
      private $sExpected;
  
      /**
       * @var string
       */
      private $sFound;
  
      /**
       * Possible values: literal, identifier, count, expression, search
       *
       * @var string
       */
      private $sMatchType;
  
      /**
       * @param string $sExpected
       * @param string $sFound
       * @param string $sMatchType
       * @param int $iLineNo
       */
      public function __construct($sExpected, $sFound, $sMatchType = 'literal', $iLineNo = 0)
      {
          $this->sExpected = $sExpected;
          $this->sFound = $sFound;
          $this->sMatchType = $sMatchType;
          $sMessage = "Token “{$sExpected}” ({$sMatchType}) not found. Got “{$sFound}”.";
          if ($this->sMatchType === 'search') {
              $sMessage = "Search for “{$sExpected}” returned no results. Context: “{$sFound}”.";
          } elseif ($this->sMatchType === 'count') {
              $sMessage = "Next token was expected to have {$sExpected} chars. Context: “{$sFound}”.";
          } elseif ($this->sMatchType === 'identifier') {
              $sMessage = "Identifier expected. Got “{$sFound}”";
          } elseif ($this->sMatchType === 'custom') {
              $sMessage = trim("$sExpected $sFound");
          }
  
          parent::__construct($sMessage, $iLineNo);
      }
  }