Skip to content

Commit 52e1ccc

Browse files
Merge branch '4.0' into 4.1
* 4.0: Fix Clidumper tests Enable the fixer enforcing fully-qualified calls for compiler-optimized functions Apply fixers Disable the native_constant_invocation fixer until it can be scoped Update the list of excluded files for the CS fixer
2 parents 81653bb + d9cc00b commit 52e1ccc

11 files changed

+32
-32
lines changed

Compiler.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function string($value)
110110
*/
111111
public function repr($value)
112112
{
113-
if (is_int($value) || is_float($value)) {
113+
if (\is_int($value) || \is_float($value)) {
114114
if (false !== $locale = setlocale(LC_NUMERIC, 0)) {
115115
setlocale(LC_NUMERIC, 'C');
116116
}
@@ -122,9 +122,9 @@ public function repr($value)
122122
}
123123
} elseif (null === $value) {
124124
$this->raw('null');
125-
} elseif (is_bool($value)) {
125+
} elseif (\is_bool($value)) {
126126
$this->raw($value ? 'true' : 'false');
127-
} elseif (is_array($value)) {
127+
} elseif (\is_array($value)) {
128128
$this->raw('array(');
129129
$first = true;
130130
foreach ($value as $key => $value) {

ExpressionFunction.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,23 @@ public function getEvaluator()
7676
public static function fromPhp($phpFunctionName, $expressionFunctionName = null)
7777
{
7878
$phpFunctionName = ltrim($phpFunctionName, '\\');
79-
if (!function_exists($phpFunctionName)) {
79+
if (!\function_exists($phpFunctionName)) {
8080
throw new \InvalidArgumentException(sprintf('PHP function "%s" does not exist.', $phpFunctionName));
8181
}
8282

8383
$parts = explode('\\', $phpFunctionName);
84-
if (!$expressionFunctionName && count($parts) > 1) {
84+
if (!$expressionFunctionName && \count($parts) > 1) {
8585
throw new \InvalidArgumentException(sprintf('An expression function name must be defined when PHP function "%s" is namespaced.', $phpFunctionName));
8686
}
8787

8888
$compiler = function () use ($phpFunctionName) {
89-
return sprintf('\%s(%s)', $phpFunctionName, implode(', ', func_get_args()));
89+
return sprintf('\%s(%s)', $phpFunctionName, implode(', ', \func_get_args()));
9090
};
9191

9292
$evaluator = function () use ($phpFunctionName) {
93-
$args = func_get_args();
93+
$args = \func_get_args();
9494

95-
return call_user_func_array($phpFunctionName, array_splice($args, 1));
95+
return \call_user_func_array($phpFunctionName, array_splice($args, 1));
9696
};
9797

9898
return new self($expressionFunctionName ?: end($parts), $compiler, $evaluator);

ExpressionLanguage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function parse($expression, $names)
8585
$cacheKeyItems = array();
8686

8787
foreach ($names as $nameKey => $name) {
88-
$cacheKeyItems[] = is_int($nameKey) ? $name : $nameKey.':'.$name;
88+
$cacheKeyItems[] = \is_int($nameKey) ? $name : $nameKey.':'.$name;
8989
}
9090

9191
$cacheItem = $this->cache->getItem(rawurlencode($expression.'//'.implode('|', $cacheKeyItems)));

Lexer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function tokenize($expression)
3333
$cursor = 0;
3434
$tokens = array();
3535
$brackets = array();
36-
$end = strlen($expression);
36+
$end = \strlen($expression);
3737

3838
while ($cursor < $end) {
3939
if (' ' == $expression[$cursor]) {
@@ -49,7 +49,7 @@ public function tokenize($expression)
4949
$number = (int) $match[0]; // integers lower than the maximum
5050
}
5151
$tokens[] = new Token(Token::NUMBER_TYPE, $number, $cursor + 1);
52-
$cursor += strlen($match[0]);
52+
$cursor += \strlen($match[0]);
5353
} elseif (false !== strpos('([{', $expression[$cursor])) {
5454
// opening bracket
5555
$brackets[] = array($expression[$cursor], $cursor);
@@ -72,19 +72,19 @@ public function tokenize($expression)
7272
} elseif (preg_match('/"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\'/As', $expression, $match, 0, $cursor)) {
7373
// strings
7474
$tokens[] = new Token(Token::STRING_TYPE, stripcslashes(substr($match[0], 1, -1)), $cursor + 1);
75-
$cursor += strlen($match[0]);
75+
$cursor += \strlen($match[0]);
7676
} elseif (preg_match('/not in(?=[\s(])|\!\=\=|not(?=[\s(])|and(?=[\s(])|\=\=\=|\>\=|or(?=[\s(])|\<\=|\*\*|\.\.|in(?=[\s(])|&&|\|\||matches|\=\=|\!\=|\*|~|%|\/|\>|\||\!|\^|&|\+|\<|\-/A', $expression, $match, 0, $cursor)) {
7777
// operators
7878
$tokens[] = new Token(Token::OPERATOR_TYPE, $match[0], $cursor + 1);
79-
$cursor += strlen($match[0]);
79+
$cursor += \strlen($match[0]);
8080
} elseif (false !== strpos('.,?:', $expression[$cursor])) {
8181
// punctuation
8282
$tokens[] = new Token(Token::PUNCTUATION_TYPE, $expression[$cursor], $cursor + 1);
8383
++$cursor;
8484
} elseif (preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A', $expression, $match, 0, $cursor)) {
8585
// names
8686
$tokens[] = new Token(Token::NAME_TYPE, $match[0], $cursor + 1);
87-
$cursor += strlen($match[0]);
87+
$cursor += \strlen($match[0]);
8888
} else {
8989
// unlexable
9090
throw new SyntaxError(sprintf('Unexpected character "%s"', $expression[$cursor]), $cursor, $expression);

Node/BinaryNode.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function evaluate($functions, $values)
9393
$right = $this->nodes['right']->evaluate($functions, $values);
9494

9595
if ('not in' === $operator) {
96-
return !in_array($left, $right);
96+
return !\in_array($left, $right);
9797
}
9898
$f = self::$functions[$operator];
9999

@@ -135,9 +135,9 @@ public function evaluate($functions, $values)
135135
case '<=':
136136
return $left <= $right;
137137
case 'not in':
138-
return !in_array($left, $right);
138+
return !\in_array($left, $right);
139139
case 'in':
140-
return in_array($left, $right);
140+
return \in_array($left, $right);
141141
case '+':
142142
return $left + $right;
143143
case '-':

Node/ConstantNode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function toArray()
5656
$array[] = 'null';
5757
} elseif (is_numeric($value)) {
5858
$array[] = $value;
59-
} elseif (!is_array($value)) {
59+
} elseif (!\is_array($value)) {
6060
$array[] = $this->dumpString($value);
6161
} elseif ($this->isHash($value)) {
6262
foreach ($value as $k => $v) {

Node/FunctionNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function compile(Compiler $compiler)
3737

3838
$function = $compiler->getFunction($this->attributes['name']);
3939

40-
$compiler->raw(call_user_func_array($function['compiler'], $arguments));
40+
$compiler->raw(\call_user_func_array($function['compiler'], $arguments));
4141
}
4242

4343
public function evaluate($functions, $values)
@@ -47,7 +47,7 @@ public function evaluate($functions, $values)
4747
$arguments[] = $node->evaluate($functions, $values);
4848
}
4949

50-
return call_user_func_array($functions[$this->attributes['name']]['evaluator'], $arguments);
50+
return \call_user_func_array($functions[$this->attributes['name']]['evaluator'], $arguments);
5151
}
5252

5353
public function toArray()

Node/GetAttrNode.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function evaluate($functions, $values)
6969
switch ($this->attributes['type']) {
7070
case self::PROPERTY_CALL:
7171
$obj = $this->nodes['node']->evaluate($functions, $values);
72-
if (!is_object($obj)) {
72+
if (!\is_object($obj)) {
7373
throw new \RuntimeException('Unable to get a property on a non-object.');
7474
}
7575

@@ -79,18 +79,18 @@ public function evaluate($functions, $values)
7979

8080
case self::METHOD_CALL:
8181
$obj = $this->nodes['node']->evaluate($functions, $values);
82-
if (!is_object($obj)) {
82+
if (!\is_object($obj)) {
8383
throw new \RuntimeException('Unable to get a property on a non-object.');
8484
}
85-
if (!is_callable($toCall = array($obj, $this->nodes['attribute']->attributes['value']))) {
86-
throw new \RuntimeException(sprintf('Unable to call method "%s" of object "%s".', $this->nodes['attribute']->attributes['value'], get_class($obj)));
85+
if (!\is_callable($toCall = array($obj, $this->nodes['attribute']->attributes['value']))) {
86+
throw new \RuntimeException(sprintf('Unable to call method "%s" of object "%s".', $this->nodes['attribute']->attributes['value'], \get_class($obj)));
8787
}
8888

89-
return call_user_func_array($toCall, $this->nodes['arguments']->evaluate($functions, $values));
89+
return \call_user_func_array($toCall, $this->nodes['arguments']->evaluate($functions, $values));
9090

9191
case self::ARRAY_CALL:
9292
$array = $this->nodes['node']->evaluate($functions, $values);
93-
if (!is_array($array) && !$array instanceof \ArrayAccess) {
93+
if (!\is_array($array) && !$array instanceof \ArrayAccess) {
9494
throw new \RuntimeException('Unable to get an item on a non-array.');
9595
}
9696

Node/Node.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ public function __toString()
4040
$attributes[] = sprintf('%s: %s', $name, str_replace("\n", '', var_export($value, true)));
4141
}
4242

43-
$repr = array(str_replace('Symfony\Component\ExpressionLanguage\Node\\', '', get_class($this)).'('.implode(', ', $attributes));
43+
$repr = array(str_replace('Symfony\Component\ExpressionLanguage\Node\\', '', \get_class($this)).'('.implode(', ', $attributes));
4444

45-
if (count($this->nodes)) {
45+
if (\count($this->nodes)) {
4646
foreach ($this->nodes as $node) {
4747
foreach (explode("\n", (string) $node) as $line) {
4848
$repr[] = ' '.$line;
@@ -76,7 +76,7 @@ public function evaluate($functions, $values)
7676

7777
public function toArray()
7878
{
79-
throw new \BadMethodCallException(sprintf('Dumping a "%s" instance is not supported yet.', get_class($this)));
79+
throw new \BadMethodCallException(sprintf('Dumping a "%s" instance is not supported yet.', \get_class($this)));
8080
}
8181

8282
public function dump()

Parser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,13 @@ public function parsePrimaryExpression()
200200

201201
$node = new Node\FunctionNode($token->value, $this->parseArguments());
202202
} else {
203-
if (!in_array($token->value, $this->names, true)) {
203+
if (!\in_array($token->value, $this->names, true)) {
204204
throw new SyntaxError(sprintf('Variable "%s" is not valid', $token->value), $token->cursor, $this->stream->getExpression(), $token->value, $this->names);
205205
}
206206

207207
// is the name used in the compiled code different
208208
// from the name used in the expression?
209-
if (is_int($name = array_search($token->value, $this->names))) {
209+
if (\is_int($name = array_search($token->value, $this->names))) {
210210
$name = $token->value;
211211
}
212212

Tests/LexerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function setUp()
3333
*/
3434
public function testTokenize($tokens, $expression)
3535
{
36-
$tokens[] = new Token('end of expression', null, strlen($expression) + 1);
36+
$tokens[] = new Token('end of expression', null, \strlen($expression) + 1);
3737
$this->assertEquals(new TokenStream($tokens, $expression), $this->lexer->tokenize($expression));
3838
}
3939

0 commit comments

Comments
 (0)