From a993849ec82056e976e8cfcfa22ea8f3c47fad19 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 2 Sep 2020 18:06:40 +0200 Subject: [PATCH] Enable "native_constant_invocation" CS rule --- Compiler.php | 6 +++--- ExpressionLanguage.php | 2 +- Lexer.php | 2 +- ParserCache/ArrayParserCache.php | 2 +- ParserCache/ParserCacheInterface.php | 2 +- SyntaxError.php | 2 +- Tests/ExpressionLanguageTest.php | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Compiler.php b/Compiler.php index 282e82d..1ae427b 100644 --- a/Compiler.php +++ b/Compiler.php @@ -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'); diff --git a/ExpressionLanguage.php b/ExpressionLanguage.php index ad06107..1647666 100644 --- a/ExpressionLanguage.php +++ b/ExpressionLanguage.php @@ -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)); diff --git a/Lexer.php b/Lexer.php index e534a56..ace847b 100644 --- a/Lexer.php +++ b/Lexer.php @@ -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); diff --git a/ParserCache/ArrayParserCache.php b/ParserCache/ArrayParserCache.php index 8f9d9f4..f009df7 100644 --- a/ParserCache/ArrayParserCache.php +++ b/ParserCache/ArrayParserCache.php @@ -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; diff --git a/ParserCache/ParserCacheInterface.php b/ParserCache/ParserCacheInterface.php index ed66b21..98a80ed 100644 --- a/ParserCache/ParserCacheInterface.php +++ b/ParserCache/ParserCacheInterface.php @@ -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; diff --git a/SyntaxError.php b/SyntaxError.php index 3340042..a942b8c 100644 --- a/SyntaxError.php +++ b/SyntaxError.php @@ -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) { diff --git a/Tests/ExpressionLanguageTest.php b/Tests/ExpressionLanguageTest.php index 5ee5c6e..97e915a 100644 --- a/Tests/ExpressionLanguageTest.php +++ b/Tests/ExpressionLanguageTest.php @@ -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")'));