Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   1  <?php
   2  
   3  namespace Sabberworm\CSS\Parsing;
   4  
   5  /**
   6  * Thrown if the CSS parsers encounters a token it did not expect
   7  */
   8  class UnexpectedTokenException extends SourceException {
   9  	 private $sExpected;
  10  	 private $sFound;
  11  	 // Possible values: literal, identifier, count, expression, search
  12  	 private $sMatchType;
  13  
  14  	public function __construct($sExpected, $sFound, $sMatchType = 'literal', $iLineNo = 0) {
  15  	 	 $this->sExpected = $sExpected;
  16  	 	 $this->sFound = $sFound;
  17  	 	 $this->sMatchType = $sMatchType;
  18  	 	 $sMessage = "Token “{$sExpected}” ({$sMatchType}) not found. Got “{$sFound}”.";
  19  	 	 if($this->sMatchType === 'search') {
  20  	 	 	 $sMessage = "Search for “{$sExpected}” returned no results. Context: “{$sFound}”.";
  21  	 	 } else if($this->sMatchType === 'count') {
  22  	 	 	 $sMessage = "Next token was expected to have {$sExpected} chars. Context: “{$sFound}”.";
  23  	 	 } else if($this->sMatchType === 'identifier') {
  24  	 	 	 $sMessage = "Identifier expected. Got “{$sFound}”";
  25  	 	 } else if($this->sMatchType === 'custom') {
  26  	 	 	 $sMessage = trim("$sExpected $sFound");
  27  	 	 }
  28  
  29  	 	 parent::__construct($sMessage, $iLineNo);
  30  	 }
  31  }