Skip to content

Commit

Permalink
Enable "native_constant_invocation" CS rule
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Sep 2, 2020
1 parent 5ceca59 commit a993849
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Compiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ public function string($value)
public function repr($value)
{
if (\is_int($value) || \is_float($value)) {
if (false !== $locale = setlocale(LC_NUMERIC, 0)) {
setlocale(LC_NUMERIC, 'C');
if (false !== $locale = setlocale(\LC_NUMERIC, 0)) {
setlocale(\LC_NUMERIC, 'C');
}

$this->raw($value);

if (false !== $locale) {
setlocale(LC_NUMERIC, $locale);
setlocale(\LC_NUMERIC, $locale);
}
} elseif (null === $value) {
$this->raw('null');
Expand Down
2 changes: 1 addition & 1 deletion ExpressionLanguage.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct($cache = null, array $providers = [])
{
if (null !== $cache) {
if ($cache instanceof ParserCacheInterface) {
@trigger_error(sprintf('Passing an instance of %s as constructor argument for %s is deprecated as of 3.2 and will be removed in 4.0. Pass an instance of %s instead.', ParserCacheInterface::class, self::class, CacheItemPoolInterface::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Passing an instance of %s as constructor argument for %s is deprecated as of 3.2 and will be removed in 4.0. Pass an instance of %s instead.', ParserCacheInterface::class, self::class, CacheItemPoolInterface::class), \E_USER_DEPRECATED);
$cache = new ParserCacheAdapter($cache);
} elseif (!$cache instanceof CacheItemPoolInterface) {
throw new \InvalidArgumentException(sprintf('Cache argument has to implement "%s".', CacheItemPoolInterface::class));
Expand Down
2 changes: 1 addition & 1 deletion Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function tokenize($expression)
if (preg_match('/[0-9]+(?:\.[0-9]+)?/A', $expression, $match, 0, $cursor)) {
// numbers
$number = (float) $match[0]; // floats
if (preg_match('/^[0-9]+$/', $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
2 changes: 1 addition & 1 deletion ParserCache/ArrayParserCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\ExpressionLanguage\ParserCache;

@trigger_error('The '.__NAMESPACE__.'\ArrayParserCache class is deprecated since Symfony 3.2 and will be removed in 4.0. Use the Symfony\Component\Cache\Adapter\ArrayAdapter class instead.', E_USER_DEPRECATED);
@trigger_error('The '.__NAMESPACE__.'\ArrayParserCache class is deprecated since Symfony 3.2 and will be removed in 4.0. Use the Symfony\Component\Cache\Adapter\ArrayAdapter class instead.', \E_USER_DEPRECATED);

use Symfony\Component\ExpressionLanguage\ParsedExpression;

Expand Down
2 changes: 1 addition & 1 deletion ParserCache/ParserCacheInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Component\ExpressionLanguage\ParserCache;

@trigger_error('The '.__NAMESPACE__.'\ParserCacheInterface interface is deprecated since Symfony 3.2 and will be removed in 4.0. Use Psr\Cache\CacheItemPoolInterface instead.', E_USER_DEPRECATED);
@trigger_error('The '.__NAMESPACE__.'\ParserCacheInterface interface is deprecated since Symfony 3.2 and will be removed in 4.0. Use Psr\Cache\CacheItemPoolInterface instead.', \E_USER_DEPRECATED);

use Symfony\Component\ExpressionLanguage\ParsedExpression;

Expand Down
2 changes: 1 addition & 1 deletion SyntaxError.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct($message, $cursor = 0, $expression = '', $subject =
$message .= '.';

if (null !== $subject && null !== $proposals) {
$minScore = INF;
$minScore = \INF;
foreach ($proposals as $proposal) {
$distance = levenshtein($subject, $proposal);
if ($distance < $minScore) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/ExpressionLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function testWrongCacheImplementation()
public function testConstantFunction()
{
$expressionLanguage = new ExpressionLanguage();
$this->assertEquals(PHP_VERSION, $expressionLanguage->evaluate('constant("PHP_VERSION")'));
$this->assertEquals(\PHP_VERSION, $expressionLanguage->evaluate('constant("PHP_VERSION")'));

$expressionLanguage = new ExpressionLanguage();
$this->assertEquals('\constant("PHP_VERSION")', $expressionLanguage->compile('constant("PHP_VERSION")'));
Expand Down

0 comments on commit a993849

Please sign in to comment.