Skip to content

Commit e725c2e

Browse files
authored
[CLEANUP] Avoid Hungarian notation in the exception classes (#981)
Part of #756
1 parent c71c8a3 commit e725c2e

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/Parsing/SourceException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class SourceException extends \Exception
1414
/**
1515
* @param int<0, max> $lineNumber
1616
*/
17-
public function __construct(string $sMessage, int $lineNumber = 0)
17+
public function __construct(string $message, int $lineNumber = 0)
1818
{
1919
$this->lineNumber = $lineNumber;
2020
if ($lineNumber !== 0) {
21-
$sMessage .= " [line no: $lineNumber]";
21+
$message .= " [line no: $lineNumber]";
2222
}
23-
parent::__construct($sMessage);
23+
parent::__construct($message);
2424
}
2525

2626
/**

src/Parsing/UnexpectedTokenException.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,38 @@ class UnexpectedTokenException extends SourceException
1212
/**
1313
* @var string
1414
*/
15-
private $sExpected;
15+
private $expected;
1616

1717
/**
1818
* @var string
1919
*/
20-
private $sFound;
20+
private $found;
2121

2222
/**
2323
* @var 'literal'|'identifier'|'count'|'expression'|'search'|'custom'
2424
*/
25-
private $sMatchType;
25+
private $matchType;
2626

2727
/**
28-
* @param 'literal'|'identifier'|'count'|'expression'|'search'|'custom' $sMatchType
28+
* @param 'literal'|'identifier'|'count'|'expression'|'search'|'custom' $matchType
2929
* @param int<0, max> $lineNumber
3030
*/
31-
public function __construct(string $sExpected, string $sFound, string $sMatchType = 'literal', int $lineNumber = 0)
31+
public function __construct(string $expected, string $found, string $matchType = 'literal', int $lineNumber = 0)
3232
{
33-
$this->sExpected = $sExpected;
34-
$this->sFound = $sFound;
35-
$this->sMatchType = $sMatchType;
36-
$sMessage = "Token “{$sExpected}” ({$sMatchType}) not found. Got “{$sFound}”.";
37-
if ($this->sMatchType === 'search') {
38-
$sMessage = "Search for “{$sExpected}” returned no results. Context: “{$sFound}”.";
39-
} elseif ($this->sMatchType === 'count') {
40-
$sMessage = "Next token was expected to have {$sExpected} chars. Context: “{$sFound}”.";
41-
} elseif ($this->sMatchType === 'identifier') {
42-
$sMessage = "Identifier expected. Got “{$sFound}";
43-
} elseif ($this->sMatchType === 'custom') {
44-
$sMessage = \trim("$sExpected $sFound");
33+
$this->expected = $expected;
34+
$this->found = $found;
35+
$this->matchType = $matchType;
36+
$message = "Token “{$expected}” ({$matchType}) not found. Got “{$found}”.";
37+
if ($this->matchType === 'search') {
38+
$message = "Search for “{$expected}” returned no results. Context: “{$found}”.";
39+
} elseif ($this->matchType === 'count') {
40+
$message = "Next token was expected to have {$expected} chars. Context: “{$found}”.";
41+
} elseif ($this->matchType === 'identifier') {
42+
$message = "Identifier expected. Got “{$found}";
43+
} elseif ($this->matchType === 'custom') {
44+
$message = \trim("$expected $found");
4545
}
4646

47-
parent::__construct($sMessage, $lineNumber);
47+
parent::__construct($message, $lineNumber);
4848
}
4949
}

0 commit comments

Comments
 (0)