Skip to content

Commit ef3dede

Browse files
committed
Enable the fixer enforcing fully-qualified calls for compiler-optimized functions
1 parent f56824e commit ef3dede

16 files changed

+38
-38
lines changed

AppVariable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function getUser()
103103
}
104104

105105
$user = $token->getUser();
106-
if (is_object($user)) {
106+
if (\is_object($user)) {
107107
return $user;
108108
}
109109
}

Command/DebugCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,16 +139,16 @@ private function getMetadata($type, $entity)
139139
if (null === $cb) {
140140
return;
141141
}
142-
if (is_array($cb)) {
142+
if (\is_array($cb)) {
143143
if (!method_exists($cb[0], $cb[1])) {
144144
return;
145145
}
146146
$refl = new \ReflectionMethod($cb[0], $cb[1]);
147-
} elseif (is_object($cb) && method_exists($cb, '__invoke')) {
147+
} elseif (\is_object($cb) && method_exists($cb, '__invoke')) {
148148
$refl = new \ReflectionMethod($cb, '__invoke');
149-
} elseif (function_exists($cb)) {
149+
} elseif (\function_exists($cb)) {
150150
$refl = new \ReflectionFunction($cb);
151-
} elseif (is_string($cb) && preg_match('{^(.+)::(.+)$}', $cb, $m) && method_exists($m[1], $m[2])) {
151+
} elseif (\is_string($cb) && preg_match('{^(.+)::(.+)$}', $cb, $m) && method_exists($m[1], $m[2])) {
152152
$refl = new \ReflectionMethod($m[1], $m[2]);
153153
} else {
154154
throw new \UnexpectedValueException('Unsupported callback type');
@@ -198,8 +198,8 @@ private function getPrettyMetadata($type, $entity)
198198
}
199199

200200
if ('globals' === $type) {
201-
if (is_object($meta)) {
202-
return ' = object('.get_class($meta).')';
201+
if (\is_object($meta)) {
202+
return ' = object('.\get_class($meta).')';
203203
}
204204

205205
return ' = '.substr(@json_encode($meta), 0, 50);

Command/LintCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
9999

100100
$filenames = $input->getArgument('filename');
101101

102-
if (0 === count($filenames)) {
102+
if (0 === \count($filenames)) {
103103
if (0 !== ftell(STDIN)) {
104104
throw new \RuntimeException('Please provide a filename or pipe template content to STDIN.');
105105
}
@@ -184,9 +184,9 @@ private function displayTxt(OutputInterface $output, SymfonyStyle $io, $filesInf
184184
}
185185

186186
if (0 === $errors) {
187-
$io->success(sprintf('All %d Twig files contain valid syntax.', count($filesInfo)));
187+
$io->success(sprintf('All %d Twig files contain valid syntax.', \count($filesInfo)));
188188
} else {
189-
$io->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', count($filesInfo) - $errors, $errors));
189+
$io->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', \count($filesInfo) - $errors, $errors));
190190
}
191191

192192
return min($errors, 1);
@@ -206,7 +206,7 @@ private function displayJson(OutputInterface $output, $filesInfo)
206206
}
207207
});
208208

209-
$output->writeln(json_encode($filesInfo, defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0));
209+
$output->writeln(json_encode($filesInfo, \defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES : 0));
210210

211211
return min($errors, 1);
212212
}
@@ -239,7 +239,7 @@ private function getContext($template, $line, $context = 3)
239239
$lines = explode("\n", $template);
240240

241241
$position = max(0, $line - $context);
242-
$max = min(count($lines), $line - 1 + $context);
242+
$max = min(\count($lines), $line - 1 + $context);
243243

244244
$result = array();
245245
while ($position < $max) {

Extension/AssetExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ public function getFunctions()
6262
public function getAssetUrl($path, $packageName = null, $absolute = false, $version = null)
6363
{
6464
// BC layer to be removed in 3.0
65-
if (2 < $count = func_num_args()) {
65+
if (2 < $count = \func_num_args()) {
6666
@trigger_error('Generating absolute URLs with the Twig asset() function was deprecated in 2.7 and will be removed in 3.0. Please use absolute_url() instead.', E_USER_DEPRECATED);
6767
if (4 === $count) {
6868
@trigger_error('Forcing a version with the Twig asset() function was deprecated in 2.7 and will be removed in 3.0.', E_USER_DEPRECATED);
6969
}
7070

71-
$args = func_get_args();
71+
$args = \func_get_args();
7272

7373
return $this->getLegacyAssetUrl($path, $packageName, $args[2], isset($args[3]) ? $args[3] : null);
7474
}

Extension/CodeExtension.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class CodeExtension extends AbstractExtension
3333
public function __construct($fileLinkFormat, $rootDir, $charset)
3434
{
3535
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
36-
$this->rootDir = str_replace('/', DIRECTORY_SEPARATOR, dirname($rootDir)).DIRECTORY_SEPARATOR;
36+
$this->rootDir = str_replace('/', DIRECTORY_SEPARATOR, \dirname($rootDir)).DIRECTORY_SEPARATOR;
3737
$this->charset = $charset;
3838
}
3939

@@ -92,7 +92,7 @@ public function formatArgs($args)
9292
$short = array_pop($parts);
9393
$formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
9494
} elseif ('array' === $item[0]) {
95-
$formattedValue = sprintf('<em>array</em>(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
95+
$formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
9696
} elseif ('string' === $item[0]) {
9797
$formattedValue = sprintf("'%s'", htmlspecialchars($item[1], ENT_QUOTES, $this->charset));
9898
} elseif ('null' === $item[0]) {
@@ -105,7 +105,7 @@ public function formatArgs($args)
105105
$formattedValue = str_replace("\n", '', var_export(htmlspecialchars((string) $item[1], ENT_QUOTES, $this->charset), true));
106106
}
107107

108-
$result[] = is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
108+
$result[] = \is_int($key) ? $formattedValue : sprintf("'%s' => %s", $key, $formattedValue);
109109
}
110110

111111
return implode(', ', $result);
@@ -142,7 +142,7 @@ public function fileExcerpt($file, $line)
142142
$content = explode('<br />', $code);
143143

144144
$lines = array();
145-
for ($i = max($line - 3, 1), $max = min($line + 3, count($content)); $i <= $max; ++$i) {
145+
for ($i = max($line - 3, 1), $max = min($line + 3, \count($content)); $i <= $max; ++$i) {
146146
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>';
147147
}
148148

@@ -166,7 +166,7 @@ public function formatFile($file, $line, $text = null)
166166
if (null === $text) {
167167
$text = str_replace('/', DIRECTORY_SEPARATOR, $file);
168168
if (0 === strpos($text, $this->rootDir)) {
169-
$text = substr($text, strlen($this->rootDir));
169+
$text = substr($text, \strlen($this->rootDir));
170170
$text = explode(DIRECTORY_SEPARATOR, $text, 2);
171171
$text = sprintf('<abbr title="%s%2$s">%s</abbr>%s', $this->rootDir, $text[0], isset($text[1]) ? DIRECTORY_SEPARATOR.$text[1] : '');
172172
}

Extension/DumpExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function dump(Environment $env, $context)
5656
return;
5757
}
5858

59-
if (2 === func_num_args()) {
59+
if (2 === \func_num_args()) {
6060
$vars = array();
6161
foreach ($context as $key => $value) {
6262
if (!$value instanceof Template) {
@@ -66,7 +66,7 @@ public function dump(Environment $env, $context)
6666

6767
$vars = array($vars);
6868
} else {
69-
$vars = func_get_args();
69+
$vars = \func_get_args();
7070
unset($vars[0], $vars[1]);
7171
}
7272

Extension/FormExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ public function humanize($text)
152152
*/
153153
public function isSelectedChoice(ChoiceView $choice, $selectedValue)
154154
{
155-
if (is_array($selectedValue)) {
156-
return in_array($choice->value, $selectedValue, true);
155+
if (\is_array($selectedValue)) {
156+
return \in_array($choice->value, $selectedValue, true);
157157
}
158158

159159
return $choice->value === $selectedValue;

Extension/HttpFoundationExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function generateAbsoluteUrl($path)
9797

9898
if (!$path || '/' !== $path[0]) {
9999
$prefix = $request->getPathInfo();
100-
$last = strlen($prefix) - 1;
100+
$last = \strlen($prefix) - 1;
101101
if ($last !== $pos = strrpos($prefix, '/')) {
102102
$prefix = substr($prefix, 0, $pos).'/';
103103
}

Extension/RoutingExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function isUrlGenerationSafe(\Twig_Node $argsNode)
100100
$argsNode->hasNode(1) ? $argsNode->getNode(1) : null
101101
);
102102

103-
if (null === $paramsNode || $paramsNode instanceof ArrayExpression && count($paramsNode) <= 2 &&
103+
if (null === $paramsNode || $paramsNode instanceof ArrayExpression && \count($paramsNode) <= 2 &&
104104
(!$paramsNode->hasNode(1) || $paramsNode->getNode(1) instanceof ConstantExpression)
105105
) {
106106
return array('html');

Extension/YamlExtension.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ public function encode($input, $inline = 0, $dumpObjects = false)
4242
$dumper = new YamlDumper();
4343
}
4444

45-
if (defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) {
46-
return $dumper->dump($input, $inline, 0, is_bool($dumpObjects) ? Yaml::DUMP_OBJECT : 0);
45+
if (\defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) {
46+
return $dumper->dump($input, $inline, 0, \is_bool($dumpObjects) ? Yaml::DUMP_OBJECT : 0);
4747
}
4848

4949
return $dumper->dump($input, $inline, 0, false, $dumpObjects);
5050
}
5151

5252
public function dump($value, $inline = 0, $dumpObjects = false)
5353
{
54-
if (is_resource($value)) {
54+
if (\is_resource($value)) {
5555
return '%Resource%';
5656
}
5757

58-
if (is_array($value) || is_object($value)) {
59-
return '%'.gettype($value).'% '.$this->encode($value, $inline, $dumpObjects);
58+
if (\is_array($value) || \is_object($value)) {
59+
return '%'.\gettype($value).'% '.$this->encode($value, $inline, $dumpObjects);
6060
}
6161

6262
return $this->encode($value, $inline, $dumpObjects);

0 commit comments

Comments
 (0)