diff --git a/CHANGELOG.md b/CHANGELOG.md index de02deb3..721ad8d7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,7 @@ Please also have a look at our - Only allow `string` for some `OutputFormat` properties (#885) - Make all non-private properties `@internal` (#886) - Use more native type declarations and strict mode - (#641, #772, #774, #778, #804, #841, #873, #875, #891) + (#641, #772, #774, #778, #804, #841, #873, #875, #891, #922) - Add visibility to all class/interface constants (#469) ### Deprecated diff --git a/src/Parsing/OutputException.php b/src/Parsing/OutputException.php index 63b32207..f715080d 100644 --- a/src/Parsing/OutputException.php +++ b/src/Parsing/OutputException.php @@ -10,10 +10,9 @@ final class OutputException extends SourceException { /** - * @param string $sMessage * @param int<0, max> $lineNumber */ - public function __construct($sMessage, $lineNumber = 0) + public function __construct(string $sMessage, int $lineNumber = 0) { parent::__construct($sMessage, $lineNumber); } diff --git a/src/Parsing/ParserState.php b/src/Parsing/ParserState.php index 651c6d64..f4263a99 100644 --- a/src/Parsing/ParserState.php +++ b/src/Parsing/ParserState.php @@ -146,7 +146,7 @@ public function parseIdentifier($bIgnoreCase = true) } $sResult = $this->parseCharacter(true); if ($sResult === null) { - throw new UnexpectedTokenException($sResult, $this->peek(5), 'identifier', $this->lineNumber); + throw new UnexpectedTokenException('', $this->peek(5), 'identifier', $this->lineNumber); } $sCharacter = null; while (!$this->isEnd() && ($sCharacter = $this->parseCharacter(true)) !== null) { @@ -294,14 +294,19 @@ public function consume($mValue = 1): string $iLineCount = \substr_count($mValue, "\n"); $iLength = $this->strlen($mValue); if (!$this->streql($this->substr($this->iCurrentPosition, $iLength), $mValue)) { - throw new UnexpectedTokenException($mValue, $this->peek(\max($iLength, 5)), $this->lineNumber); + throw new UnexpectedTokenException( + $mValue, + $this->peek(\max($iLength, 5)), + 'literal', + $this->lineNumber + ); } $this->lineNumber += $iLineCount; $this->iCurrentPosition += $this->strlen($mValue); return $mValue; } else { if ($this->iCurrentPosition + $mValue > $this->iLength) { - throw new UnexpectedEOFException($mValue, $this->peek(5), 'count', $this->lineNumber); + throw new UnexpectedEOFException((string) $mValue, $this->peek(5), 'count', $this->lineNumber); } $sResult = $this->substr($this->iCurrentPosition, $mValue); $iLineCount = \substr_count($sResult, "\n"); diff --git a/src/Parsing/SourceException.php b/src/Parsing/SourceException.php index 1af7affc..31fc0a59 100644 --- a/src/Parsing/SourceException.php +++ b/src/Parsing/SourceException.php @@ -7,15 +7,14 @@ class SourceException extends \Exception { /** - * @var int + * @var int<0, max> */ private $lineNumber; /** - * @param string $sMessage * @param int<0, max> $lineNumber */ - public function __construct($sMessage, $lineNumber = 0) + public function __construct(string $sMessage, int $lineNumber = 0) { $this->lineNumber = $lineNumber; if ($lineNumber !== 0) { diff --git a/src/Parsing/UnexpectedTokenException.php b/src/Parsing/UnexpectedTokenException.php index 441397f1..95fd3d6d 100644 --- a/src/Parsing/UnexpectedTokenException.php +++ b/src/Parsing/UnexpectedTokenException.php @@ -20,19 +20,15 @@ class UnexpectedTokenException extends SourceException private $sFound; /** - * Possible values: literal, identifier, count, expression, search - * - * @var string + * @var 'literal'|'identifier'|'count'|'expression'|'search'|'custom' */ private $sMatchType; /** - * @param string $sExpected - * @param string $sFound - * @param string $sMatchType + * @param 'literal'|'identifier'|'count'|'expression'|'search'|'custom' $sMatchType * @param int<0, max> $lineNumber */ - public function __construct($sExpected, $sFound, $sMatchType = 'literal', $lineNumber = 0) + public function __construct(string $sExpected, string $sFound, string $sMatchType = 'literal', int $lineNumber = 0) { $this->sExpected = $sExpected; $this->sFound = $sFound;