Skip to content

Commit

Permalink
minor #22325 [ExpressionLanguage] Avoid ExpressionLanguage dependency…
Browse files Browse the repository at this point in the history
… on ctype (nijel)

This PR was submitted for the 3.2 branch but it was merged into the 2.7 branch instead (closes #22325).

Discussion
----------

[ExpressionLanguage] Avoid ExpressionLanguage dependency on ctype

| Q             | A
| ------------- | ---
| Branch?       | 3.2
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | none
| License       | MIT
| Doc PR        | none

There is undocumented dependency on ctype extension in ExpressionLanguage. I've chosen to remove it rather than document as we're using ExpressionLanguage in phpMyAdmin and this is only dependency which needs ctype.

I'm submitting this against 3.2 to get this fix to released version sooner, but it can be without problems applied to master as well.

Commits
-------

81de5fe [ExpressionLanguage] Avoid dependency on ctype
  • Loading branch information
fabpot committed Apr 7, 2017
2 parents d48fae7 + 81de5fe commit 0eed690
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Symfony/Component/ExpressionLanguage/Lexer.php
Expand Up @@ -45,7 +45,7 @@ public function tokenize($expression)
if (preg_match('/[0-9]+(?:\.[0-9]+)?/A', $expression, $match, null, $cursor)) {
// numbers
$number = (float) $match[0]; // floats
if (ctype_digit($match[0]) && $number <= PHP_INT_MAX) {
if (preg_match('/^[0-9]+$/', $match[0]) && $number <= PHP_INT_MAX) {
$number = (int) $match[0]; // integers lower than the maximum
}
$tokens[] = new Token(Token::NUMBER_TYPE, $number, $cursor + 1);
Expand Down

0 comments on commit 0eed690

Please sign in to comment.