Skip to content

Commit 9c62272

Browse files
Enable "native_constant_invocation" CS rule
1 parent 0614c9e commit 9c62272

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

Generator/UrlGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ protected function doGenerate($variables, $defaults, $requirements, $tokens, $pa
260260
unset($extra['_fragment']);
261261
}
262262

263-
if ($extra && $query = http_build_query($extra, '', '&', PHP_QUERY_RFC3986)) {
263+
if ($extra && $query = http_build_query($extra, '', '&', \PHP_QUERY_RFC3986)) {
264264
// "/" and "?" can be left decoded for better user experience, see
265265
// http://tools.ietf.org/html/rfc3986#section-3.4
266266
$url .= '?'.strtr($query, ['%2F' => '/']);

Loader/AnnotationFileLoader.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function load($file, $type = null)
7777
*/
7878
public function supports($resource, $type = null)
7979
{
80-
return \is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'annotation' === $type);
80+
return \is_string($resource) && 'php' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'annotation' === $type);
8181
}
8282

8383
/**
@@ -93,11 +93,11 @@ protected function findClass($file)
9393
$namespace = false;
9494
$tokens = token_get_all(file_get_contents($file));
9595

96-
if (1 === \count($tokens) && T_INLINE_HTML === $tokens[0][0]) {
96+
if (1 === \count($tokens) && \T_INLINE_HTML === $tokens[0][0]) {
9797
throw new \InvalidArgumentException(sprintf('The file "%s" does not contain PHP code. Did you forgot to add the "<?php" start tag at the beginning of the file?', $file));
9898
}
9999

100-
$nsTokens = [T_NS_SEPARATOR => true, T_STRING => true];
100+
$nsTokens = [\T_NS_SEPARATOR => true, \T_STRING => true];
101101
if (\defined('T_NAME_QUALIFIED')) {
102102
$nsTokens[T_NAME_QUALIFIED] = true;
103103
}
@@ -109,7 +109,7 @@ protected function findClass($file)
109109
continue;
110110
}
111111

112-
if (true === $class && T_STRING === $token[0]) {
112+
if (true === $class && \T_STRING === $token[0]) {
113113
return $namespace.'\\'.$token[1];
114114
}
115115

@@ -121,18 +121,18 @@ protected function findClass($file)
121121
$token = $tokens[$i];
122122
}
123123

124-
if (T_CLASS === $token[0]) {
124+
if (\T_CLASS === $token[0]) {
125125
// Skip usage of ::class constant and anonymous classes
126126
$skipClassToken = false;
127127
for ($j = $i - 1; $j > 0; --$j) {
128128
if (!isset($tokens[$j][1])) {
129129
break;
130130
}
131131

132-
if (T_DOUBLE_COLON === $tokens[$j][0] || T_NEW === $tokens[$j][0]) {
132+
if (\T_DOUBLE_COLON === $tokens[$j][0] || \T_NEW === $tokens[$j][0]) {
133133
$skipClassToken = true;
134134
break;
135-
} elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) {
135+
} elseif (!\in_array($tokens[$j][0], [\T_WHITESPACE, \T_DOC_COMMENT, \T_COMMENT])) {
136136
break;
137137
}
138138
}
@@ -142,7 +142,7 @@ protected function findClass($file)
142142
}
143143
}
144144

145-
if (T_NAMESPACE === $token[0]) {
145+
if (\T_NAMESPACE === $token[0]) {
146146
$namespace = true;
147147
}
148148
}

Loader/PhpFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function load($file, $type = null)
6363
*/
6464
public function supports($resource, $type = null)
6565
{
66-
return \is_string($resource) && 'php' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'php' === $type);
66+
return \is_string($resource) && 'php' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'php' === $type);
6767
}
6868
}
6969

Loader/XmlFileLoader.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ protected function parseNode(RouteCollection $collection, \DOMElement $node, $pa
9393
*/
9494
public function supports($resource, $type = null)
9595
{
96-
return \is_string($resource) && 'xml' === pathinfo($resource, PATHINFO_EXTENSION) && (!$type || 'xml' === $type);
96+
return \is_string($resource) && 'xml' === pathinfo($resource, \PATHINFO_EXTENSION) && (!$type || 'xml' === $type);
9797
}
9898

9999
/**
@@ -111,8 +111,8 @@ protected function parseRoute(RouteCollection $collection, \DOMElement $node, $p
111111
throw new \InvalidArgumentException(sprintf('The <route> element in file "%s" must have an "id" and a "path" attribute.', $path));
112112
}
113113

114-
$schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY);
115-
$methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY);
114+
$schemes = preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, \PREG_SPLIT_NO_EMPTY);
115+
$methods = preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, \PREG_SPLIT_NO_EMPTY);
116116

117117
list($defaults, $requirements, $options, $condition) = $this->parseConfigs($node, $path);
118118

@@ -139,8 +139,8 @@ protected function parseImport(RouteCollection $collection, \DOMElement $node, $
139139
$type = $node->getAttribute('type');
140140
$prefix = $node->getAttribute('prefix');
141141
$host = $node->hasAttribute('host') ? $node->getAttribute('host') : null;
142-
$schemes = $node->hasAttribute('schemes') ? preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, PREG_SPLIT_NO_EMPTY) : null;
143-
$methods = $node->hasAttribute('methods') ? preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, PREG_SPLIT_NO_EMPTY) : null;
142+
$schemes = $node->hasAttribute('schemes') ? preg_split('/[\s,\|]++/', $node->getAttribute('schemes'), -1, \PREG_SPLIT_NO_EMPTY) : null;
143+
$methods = $node->hasAttribute('methods') ? preg_split('/[\s,\|]++/', $node->getAttribute('methods'), -1, \PREG_SPLIT_NO_EMPTY) : null;
144144

145145
list($defaults, $requirements, $options, $condition) = $this->parseConfigs($node, $path);
146146

Loader/YamlFileLoader.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function load($file, $type = null)
5858
}
5959

6060
$prevErrorHandler = set_error_handler(function ($level, $message, $script, $line) use ($file, &$prevErrorHandler) {
61-
$message = E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$file.'"$0', $message) : $message;
61+
$message = \E_USER_DEPRECATED === $level ? preg_replace('/ on line \d+/', ' in "'.$file.'"$0', $message) : $message;
6262

6363
return $prevErrorHandler ? $prevErrorHandler($level, $message, $script, $line) : false;
6464
});
@@ -102,7 +102,7 @@ public function load($file, $type = null)
102102
*/
103103
public function supports($resource, $type = null)
104104
{
105-
return \is_string($resource) && \in_array(pathinfo($resource, PATHINFO_EXTENSION), ['yml', 'yaml'], true) && (!$type || 'yaml' === $type);
105+
return \is_string($resource) && \in_array(pathinfo($resource, \PATHINFO_EXTENSION), ['yml', 'yaml'], true) && (!$type || 'yaml' === $type);
106106
}
107107

108108
/**

RouteCompiler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ private static function compilePattern(Route $route, $pattern, $isHost)
104104

105105
if (!$needsUtf8 && $useUtf8 && preg_match('/[\x80-\xFF]/', $pattern)) {
106106
$needsUtf8 = true;
107-
@trigger_error(sprintf('Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "%s".', $pattern), E_USER_DEPRECATED);
107+
@trigger_error(sprintf('Using UTF-8 route patterns without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for pattern "%s".', $pattern), \E_USER_DEPRECATED);
108108
}
109109
if (!$useUtf8 && $needsUtf8) {
110110
throw new \LogicException(sprintf('Cannot mix UTF-8 requirements with non-UTF-8 pattern "%s".', $pattern));
111111
}
112112

113113
// Match all variables enclosed in "{}" and iterate over them. But we only want to match the innermost variable
114114
// in case of nested "{}", e.g. {foo{bar}}. This in ensured because \w does not match "{" or "}" itself.
115-
preg_match_all('#\{\w+\}#', $pattern, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
115+
preg_match_all('#\{\w+\}#', $pattern, $matches, \PREG_OFFSET_CAPTURE | \PREG_SET_ORDER);
116116
foreach ($matches as $match) {
117117
$varName = substr($match[0][0], 1, -1);
118118
// get all static text preceding the current variable
@@ -177,7 +177,7 @@ private static function compilePattern(Route $route, $pattern, $isHost)
177177
$useUtf8 = false;
178178
} elseif (!$needsUtf8 && preg_match('/[\x80-\xFF]|(?<!\\\\)\\\\(?:\\\\\\\\)*+(?-i:X|[pP][\{CLMNPSZ]|x\{[A-Fa-f0-9]{3})/', $regexp)) {
179179
$needsUtf8 = true;
180-
@trigger_error(sprintf('Using UTF-8 route requirements without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for variable "%s" in pattern "%s".', $varName, $pattern), E_USER_DEPRECATED);
180+
@trigger_error(sprintf('Using UTF-8 route requirements without setting the "utf8" option is deprecated since Symfony 3.2 and will throw a LogicException in 4.0. Turn on the "utf8" route option for variable "%s" in pattern "%s".', $varName, $pattern), \E_USER_DEPRECATED);
181181
}
182182
if (!$useUtf8 && $needsUtf8) {
183183
throw new \LogicException(sprintf('Cannot mix UTF-8 requirement with non-UTF-8 charset for variable "%s" in pattern "%s".', $varName, $pattern));
@@ -193,7 +193,7 @@ private static function compilePattern(Route $route, $pattern, $isHost)
193193
}
194194

195195
// find the first optional token
196-
$firstOptional = PHP_INT_MAX;
196+
$firstOptional = \PHP_INT_MAX;
197197
if (!$isHost) {
198198
for ($i = \count($tokens) - 1; $i >= 0; --$i) {
199199
$token = $tokens[$i];

0 commit comments

Comments
 (0)