Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 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  }