Skip to content

Commit 19b3af1

Browse files
committed
Merge branch '4.4' into 5.0
* 4.4: Add missing dots at the end of exception messages [DI][Form] Fixed test suite (TimeType changes & unresolved merge conflict) Fix bad merge Add missing dots at the end of exception messages
2 parents 67741ad + 208ceff commit 19b3af1

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

Lexer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ public function tokenize(string $expression)
5757
} elseif (false !== strpos(')]}', $expression[$cursor])) {
5858
// closing bracket
5959
if (empty($brackets)) {
60-
throw new SyntaxError(sprintf('Unexpected "%s"', $expression[$cursor]), $cursor, $expression);
60+
throw new SyntaxError(sprintf('Unexpected "%s".', $expression[$cursor]), $cursor, $expression);
6161
}
6262

6363
list($expect, $cur) = array_pop($brackets);
6464
if ($expression[$cursor] != strtr($expect, '([{', ')]}')) {
65-
throw new SyntaxError(sprintf('Unclosed "%s"', $expect), $cur, $expression);
65+
throw new SyntaxError(sprintf('Unclosed "%s".', $expect), $cur, $expression);
6666
}
6767

6868
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
@@ -85,15 +85,15 @@ public function tokenize(string $expression)
8585
$cursor += \strlen($match[0]);
8686
} else {
8787
// unlexable
88-
throw new SyntaxError(sprintf('Unexpected character "%s"', $expression[$cursor]), $cursor, $expression);
88+
throw new SyntaxError(sprintf('Unexpected character "%s".', $expression[$cursor]), $cursor, $expression);
8989
}
9090
}
9191

9292
$tokens[] = new Token(Token::EOF_TYPE, null, $cursor + 1);
9393

9494
if (!empty($brackets)) {
9595
list($expect, $cur) = array_pop($brackets);
96-
throw new SyntaxError(sprintf('Unclosed "%s"', $expect), $cur, $expression);
96+
throw new SyntaxError(sprintf('Unclosed "%s".', $expect), $cur, $expression);
9797
}
9898

9999
return new TokenStream($tokens, $expression);

Node/BinaryNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,13 @@ public function evaluate(array $functions, array $values)
148148
return $left * $right;
149149
case '/':
150150
if (0 == $right) {
151-
throw new \DivisionByZeroError('Division by zero');
151+
throw new \DivisionByZeroError('Division by zero.');
152152
}
153153

154154
return $left / $right;
155155
case '%':
156156
if (0 == $right) {
157-
throw new \DivisionByZeroError('Modulo by zero');
157+
throw new \DivisionByZeroError('Modulo by zero.');
158158
}
159159

160160
return $left % $right;

Parser.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function parse(TokenStream $stream, array $names = [])
9696

9797
$node = $this->parseExpression();
9898
if (!$stream->isEOF()) {
99-
throw new SyntaxError(sprintf('Unexpected token "%s" of value "%s"', $stream->current->type, $stream->current->value), $stream->current->cursor, $stream->getExpression());
99+
throw new SyntaxError(sprintf('Unexpected token "%s" of value "%s".', $stream->current->type, $stream->current->value), $stream->current->cursor, $stream->getExpression());
100100
}
101101

102102
return $node;
@@ -192,13 +192,13 @@ public function parsePrimaryExpression()
192192
default:
193193
if ('(' === $this->stream->current->value) {
194194
if (false === isset($this->functions[$token->value])) {
195-
throw new SyntaxError(sprintf('The function "%s" does not exist', $token->value), $token->cursor, $this->stream->getExpression(), $token->value, array_keys($this->functions));
195+
throw new SyntaxError(sprintf('The function "%s" does not exist.', $token->value), $token->cursor, $this->stream->getExpression(), $token->value, array_keys($this->functions));
196196
}
197197

198198
$node = new Node\FunctionNode($token->value, $this->parseArguments());
199199
} else {
200200
if (!\in_array($token->value, $this->names, true)) {
201-
throw new SyntaxError(sprintf('Variable "%s" is not valid', $token->value), $token->cursor, $this->stream->getExpression(), $token->value, $this->names);
201+
throw new SyntaxError(sprintf('Variable "%s" is not valid.', $token->value), $token->cursor, $this->stream->getExpression(), $token->value, $this->names);
202202
}
203203

204204
// is the name used in the compiled code different
@@ -224,7 +224,7 @@ public function parsePrimaryExpression()
224224
} elseif ($token->test(Token::PUNCTUATION_TYPE, '{')) {
225225
$node = $this->parseHashExpression();
226226
} else {
227-
throw new SyntaxError(sprintf('Unexpected token "%s" of value "%s"', $token->type, $token->value), $token->cursor, $this->stream->getExpression());
227+
throw new SyntaxError(sprintf('Unexpected token "%s" of value "%s".', $token->type, $token->value), $token->cursor, $this->stream->getExpression());
228228
}
229229
}
230230

@@ -286,7 +286,7 @@ public function parseHashExpression()
286286
} else {
287287
$current = $this->stream->current;
288288

289-
throw new SyntaxError(sprintf('A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s"', $current->type, $current->value), $current->cursor, $this->stream->getExpression());
289+
throw new SyntaxError(sprintf('A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "%s" of value "%s".', $current->type, $current->value), $current->cursor, $this->stream->getExpression());
290290
}
291291

292292
$this->stream->expect(Token::PUNCTUATION_TYPE, ':', 'A hash key must be followed by a colon (:)');
@@ -324,7 +324,7 @@ public function parsePostfixExpression(Node\Node $node)
324324
// As a result, if $token is NOT an operator OR $token->value is NOT a valid property or method name, an exception shall be thrown.
325325
(Token::OPERATOR_TYPE !== $token->type || !preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A', $token->value))
326326
) {
327-
throw new SyntaxError('Expected name', $token->cursor, $this->stream->getExpression());
327+
throw new SyntaxError('Expected name.', $token->cursor, $this->stream->getExpression());
328328
}
329329

330330
$arg = new Node\ConstantNode($token->value, true);

SyntaxError.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class SyntaxError extends \LogicException
1515
{
1616
public function __construct(string $message, int $cursor = 0, string $expression = '', string $subject = null, array $proposals = null)
1717
{
18-
$message = sprintf('%s around position %d', $message, $cursor);
18+
$message = sprintf('%s around position %d', rtrim($message, '.'), $cursor);
1919
if ($expression) {
2020
$message = sprintf('%s for expression `%s`', $message, $expression);
2121
}

TokenStream.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function next()
4949
++$this->position;
5050

5151
if (!isset($this->tokens[$this->position])) {
52-
throw new SyntaxError('Unexpected end of expression', $this->current->cursor, $this->expression);
52+
throw new SyntaxError('Unexpected end of expression.', $this->current->cursor, $this->expression);
5353
}
5454

5555
$this->current = $this->tokens[$this->position];
@@ -65,7 +65,7 @@ public function expect($type, string $value = null, string $message = null)
6565
{
6666
$token = $this->current;
6767
if (!$token->test($type, $value)) {
68-
throw new SyntaxError(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s)', $message ? $message.'. ' : '', $token->type, $token->value, $type, $value ? sprintf(' with value "%s"', $value) : ''), $token->cursor, $this->expression);
68+
throw new SyntaxError(sprintf('%sUnexpected token "%s" of value "%s" ("%s" expected%s).', $message ? $message.'. ' : '', $token->type, $token->value, $type, $value ? sprintf(' with value "%s"', $value) : ''), $token->cursor, $this->expression);
6969
}
7070
$this->next();
7171
}

0 commit comments

Comments
 (0)