Skip to content

Commit 48c93e8

Browse files
Merge branch '2.8' into 3.4
* 2.8: 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 be24a25 + ef3dede commit 48c93e8

16 files changed

+49
-49
lines changed

AppVariable.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getUser()
8383
}
8484

8585
$user = $token->getUser();
86-
if (is_object($user)) {
86+
if (\is_object($user)) {
8787
return $user;
8888
}
8989
}
@@ -169,7 +169,7 @@ public function getFlashes($types = null)
169169
return $session->getFlashBag()->all();
170170
}
171171

172-
if (is_string($types)) {
172+
if (\is_string($types)) {
173173
return $session->getFlashBag()->get($types);
174174
}
175175

Command/DebugCommand.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
102102
$io = new SymfonyStyle($input, $output);
103103

104104
// BC to be removed in 4.0
105-
if (__CLASS__ !== get_class($this)) {
105+
if (__CLASS__ !== \get_class($this)) {
106106
$r = new \ReflectionMethod($this, 'getTwigEnvironment');
107107
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
108-
@trigger_error(sprintf('Usage of method "%s" is deprecated since Symfony 3.4 and will no longer be supported in 4.0. Construct the command with its required arguments instead.', get_class($this).'::getTwigEnvironment'), E_USER_DEPRECATED);
108+
@trigger_error(sprintf('Usage of method "%s" is deprecated since Symfony 3.4 and will no longer be supported in 4.0. Construct the command with its required arguments instead.', \get_class($this).'::getTwigEnvironment'), E_USER_DEPRECATED);
109109

110110
$this->twig = $this->getTwigEnvironment();
111111
}
@@ -154,15 +154,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
154154
$firstNamespace = true;
155155
$prevHasSeparator = false;
156156
foreach ($this->getLoaderPaths() as $namespace => $paths) {
157-
if (!$firstNamespace && !$prevHasSeparator && count($paths) > 1) {
157+
if (!$firstNamespace && !$prevHasSeparator && \count($paths) > 1) {
158158
$rows[] = array('', '');
159159
}
160160
$firstNamespace = false;
161161
foreach ($paths as $path) {
162162
$rows[] = array($namespace, $path.DIRECTORY_SEPARATOR);
163163
$namespace = '';
164164
}
165-
if (count($paths) > 1) {
165+
if (\count($paths) > 1) {
166166
$rows[] = array('', '');
167167
$prevHasSeparator = true;
168168
} else {
@@ -188,7 +188,7 @@ private function getLoaderPaths()
188188
foreach ($loader->getNamespaces() as $namespace) {
189189
$paths = array_map(function ($path) {
190190
if (null !== $this->projectDir && 0 === strpos($path, $this->projectDir)) {
191-
$path = ltrim(substr($path, strlen($this->projectDir)), DIRECTORY_SEPARATOR);
191+
$path = ltrim(substr($path, \strlen($this->projectDir)), DIRECTORY_SEPARATOR);
192192
}
193193

194194
return $path;
@@ -219,16 +219,16 @@ private function getMetadata($type, $entity)
219219
if (null === $cb) {
220220
return;
221221
}
222-
if (is_array($cb)) {
222+
if (\is_array($cb)) {
223223
if (!method_exists($cb[0], $cb[1])) {
224224
return;
225225
}
226226
$refl = new \ReflectionMethod($cb[0], $cb[1]);
227-
} elseif (is_object($cb) && method_exists($cb, '__invoke')) {
227+
} elseif (\is_object($cb) && method_exists($cb, '__invoke')) {
228228
$refl = new \ReflectionMethod($cb, '__invoke');
229-
} elseif (function_exists($cb)) {
229+
} elseif (\function_exists($cb)) {
230230
$refl = new \ReflectionFunction($cb);
231-
} elseif (is_string($cb) && preg_match('{^(.+)::(.+)$}', $cb, $m) && method_exists($m[1], $m[2])) {
231+
} elseif (\is_string($cb) && preg_match('{^(.+)::(.+)$}', $cb, $m) && method_exists($m[1], $m[2])) {
232232
$refl = new \ReflectionMethod($m[1], $m[2]);
233233
} else {
234234
throw new \UnexpectedValueException('Unsupported callback type');
@@ -278,8 +278,8 @@ private function getPrettyMetadata($type, $entity)
278278
}
279279

280280
if ('globals' === $type) {
281-
if (is_object($meta)) {
282-
return ' = object('.get_class($meta).')';
281+
if (\is_object($meta)) {
282+
return ' = object('.\get_class($meta).')';
283283
}
284284

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

Command/LintCommand.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
105105
$io = new SymfonyStyle($input, $output);
106106

107107
// BC to be removed in 4.0
108-
if (__CLASS__ !== get_class($this)) {
108+
if (__CLASS__ !== \get_class($this)) {
109109
$r = new \ReflectionMethod($this, 'getTwigEnvironment');
110110
if (__CLASS__ !== $r->getDeclaringClass()->getName()) {
111-
@trigger_error(sprintf('Usage of method "%s" is deprecated since Symfony 3.4 and will no longer be supported in 4.0. Construct the command with its required arguments instead.', get_class($this).'::getTwigEnvironment'), E_USER_DEPRECATED);
111+
@trigger_error(sprintf('Usage of method "%s" is deprecated since Symfony 3.4 and will no longer be supported in 4.0. Construct the command with its required arguments instead.', \get_class($this).'::getTwigEnvironment'), E_USER_DEPRECATED);
112112

113113
$this->twig = $this->getTwigEnvironment();
114114
}
@@ -119,7 +119,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
119119

120120
$filenames = $input->getArgument('filename');
121121

122-
if (0 === count($filenames)) {
122+
if (0 === \count($filenames)) {
123123
if (0 !== ftell(STDIN)) {
124124
throw new RuntimeException('Please provide a filename or pipe template content to STDIN.');
125125
}
@@ -204,9 +204,9 @@ private function displayTxt(OutputInterface $output, SymfonyStyle $io, $filesInf
204204
}
205205

206206
if (0 === $errors) {
207-
$io->success(sprintf('All %d Twig files contain valid syntax.', count($filesInfo)));
207+
$io->success(sprintf('All %d Twig files contain valid syntax.', \count($filesInfo)));
208208
} else {
209-
$io->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', count($filesInfo) - $errors, $errors));
209+
$io->warning(sprintf('%d Twig files have valid syntax and %d contain errors.', \count($filesInfo) - $errors, $errors));
210210
}
211211

212212
return min($errors, 1);
@@ -259,7 +259,7 @@ private function getContext($template, $line, $context = 3)
259259
$lines = explode("\n", $template);
260260

261261
$position = max(0, $line - $context);
262-
$max = min(count($lines), $line - 1 + $context);
262+
$max = min(\count($lines), $line - 1 + $context);
263263

264264
$result = array();
265265
while ($position < $max) {

Extension/CodeExtension.php

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

@@ -94,7 +94,7 @@ public function formatArgs($args)
9494
$short = array_pop($parts);
9595
$formattedValue = sprintf('<em>object</em>(<abbr title="%s">%s</abbr>)', $item[1], $short);
9696
} elseif ('array' === $item[0]) {
97-
$formattedValue = sprintf('<em>array</em>(%s)', is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
97+
$formattedValue = sprintf('<em>array</em>(%s)', \is_array($item[1]) ? $this->formatArgs($item[1]) : $item[1]);
9898
} elseif ('null' === $item[0]) {
9999
$formattedValue = '<em>null</em>';
100100
} elseif ('boolean' === $item[0]) {
@@ -105,7 +105,7 @@ public function formatArgs($args)
105105
$formattedValue = str_replace("\n", '', htmlspecialchars(var_export($item[1], true), ENT_COMPAT | ENT_SUBSTITUTE, $this->charset));
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);
@@ -148,10 +148,10 @@ public function fileExcerpt($file, $line, $srcContext = 3)
148148

149149
$lines = array();
150150
if (0 > $srcContext) {
151-
$srcContext = count($content);
151+
$srcContext = \count($content);
152152
}
153153

154-
for ($i = max($line - $srcContext, 1), $max = min($line + $srcContext, count($content)); $i <= $max; ++$i) {
154+
for ($i = max($line - $srcContext, 1), $max = min($line + $srcContext, \count($content)); $i <= $max; ++$i) {
155155
$lines[] = '<li'.($i == $line ? ' class="selected"' : '').'><a class="anchor" name="line'.$i.'"></a><code>'.self::fixCodeMarkup($content[$i - 1]).'</code></li>';
156156
}
157157

@@ -175,7 +175,7 @@ public function formatFile($file, $line, $text = null)
175175
if (null === $text) {
176176
$text = str_replace('/', DIRECTORY_SEPARATOR, $file);
177177
if (0 === strpos($text, $this->rootDir)) {
178-
$text = substr($text, strlen($this->rootDir));
178+
$text = substr($text, \strlen($this->rootDir));
179179
$text = explode(DIRECTORY_SEPARATOR, $text, 2);
180180
$text = sprintf('<abbr title="%s%2$s">%s</abbr>%s', $this->rootDir, $text[0], isset($text[1]) ? DIRECTORY_SEPARATOR.$text[1] : '');
181181
}
@@ -203,7 +203,7 @@ public function formatFile($file, $line, $text = null)
203203
public function getFileLink($file, $line)
204204
{
205205
if ($fmt = $this->fileLinkFormat) {
206-
return is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line);
206+
return \is_string($fmt) ? strtr($fmt, array('%f' => $file, '%l' => $line)) : $fmt->format($file, $line);
207207
}
208208

209209
return false;

Extension/DumpExtension.php

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

61-
if (2 === func_num_args()) {
61+
if (2 === \func_num_args()) {
6262
$vars = array();
6363
foreach ($context as $key => $value) {
6464
if (!$value instanceof Template) {
@@ -68,7 +68,7 @@ public function dump(Environment $env, $context)
6868

6969
$vars = array($vars);
7070
} else {
71-
$vars = func_get_args();
71+
$vars = \func_get_args();
7272
unset($vars[0], $vars[1]);
7373
}
7474

Extension/FormExtension.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function __construct($renderer = null)
4040
{
4141
if ($renderer instanceof TwigRendererInterface) {
4242
@trigger_error(sprintf('Passing a Twig Form Renderer to the "%s" constructor is deprecated since Symfony 3.2 and won\'t be possible in 4.0. Pass the Twig\Environment to the TwigRendererEngine constructor instead.', static::class), E_USER_DEPRECATED);
43-
} elseif (null !== $renderer && !(is_array($renderer) && isset($renderer[0], $renderer[1]) && $renderer[0] instanceof ContainerInterface)) {
43+
} elseif (null !== $renderer && !(\is_array($renderer) && isset($renderer[0], $renderer[1]) && $renderer[0] instanceof ContainerInterface)) {
4444
throw new \InvalidArgumentException(sprintf('Passing any arguments the constructor of %s is reserved for internal use.', __CLASS__));
4545
}
4646
$this->renderer = $renderer;
@@ -55,7 +55,7 @@ public function initRuntime(Environment $environment)
5555
{
5656
if ($this->renderer instanceof TwigRendererInterface) {
5757
$this->renderer->setEnvironment($environment);
58-
} elseif (is_array($this->renderer)) {
58+
} elseif (\is_array($this->renderer)) {
5959
$this->renderer[2] = $environment;
6060
}
6161
}
@@ -119,7 +119,7 @@ public function __get($name)
119119
if ('renderer' === $name) {
120120
@trigger_error(sprintf('Using the "%s::$renderer" property is deprecated since Symfony 3.2 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
121121

122-
if (is_array($this->renderer)) {
122+
if (\is_array($this->renderer)) {
123123
$renderer = $this->renderer[0]->get($this->renderer[1]);
124124
if (isset($this->renderer[2]) && $renderer instanceof TwigRendererInterface) {
125125
$renderer->setEnvironment($this->renderer[2]);
@@ -189,8 +189,8 @@ public function getName()
189189
*/
190190
function twig_is_selected_choice(ChoiceView $choice, $selectedValue)
191191
{
192-
if (is_array($selectedValue)) {
193-
return in_array($choice->value, $selectedValue, true);
192+
if (\is_array($selectedValue)) {
193+
return \in_array($choice->value, $selectedValue, true);
194194
}
195195

196196
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,8 +42,8 @@ public function encode($input, $inline = 0, $dumpObjects = 0)
4242
$dumper = new YamlDumper();
4343
}
4444

45-
if (defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) {
46-
if (is_bool($dumpObjects)) {
45+
if (\defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) {
46+
if (\is_bool($dumpObjects)) {
4747
@trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', E_USER_DEPRECATED);
4848

4949
$flags = $dumpObjects ? Yaml::DUMP_OBJECT : 0;
@@ -59,12 +59,12 @@ public function encode($input, $inline = 0, $dumpObjects = 0)
5959

6060
public function dump($value, $inline = 0, $dumpObjects = false)
6161
{
62-
if (is_resource($value)) {
62+
if (\is_resource($value)) {
6363
return '%Resource%';
6464
}
6565

66-
if (is_array($value) || is_object($value)) {
67-
return '%'.gettype($value).'% '.$this->encode($value, $inline, $dumpObjects);
66+
if (\is_array($value) || \is_object($value)) {
67+
return '%'.\gettype($value).'% '.$this->encode($value, $inline, $dumpObjects);
6868
}
6969

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

Form/TwigRendererEngine.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ protected function loadResourceForBlockName($cacheKey, FormView $view, $blockNam
116116

117117
// Check each theme whether it contains the searched block
118118
if (isset($this->themes[$cacheKey])) {
119-
for ($i = count($this->themes[$cacheKey]) - 1; $i >= 0; --$i) {
119+
for ($i = \count($this->themes[$cacheKey]) - 1; $i >= 0; --$i) {
120120
$this->loadResourcesFromTheme($cacheKey, $this->themes[$cacheKey][$i]);
121121
// CONTINUE LOADING (see doc comment)
122122
}
@@ -125,7 +125,7 @@ protected function loadResourceForBlockName($cacheKey, FormView $view, $blockNam
125125
// Check the default themes once we reach the root view without success
126126
if (!$view->parent) {
127127
if (!isset($this->useDefaultThemes[$cacheKey]) || $this->useDefaultThemes[$cacheKey]) {
128-
for ($i = count($this->defaultThemes) - 1; $i >= 0; --$i) {
128+
for ($i = \count($this->defaultThemes) - 1; $i >= 0; --$i) {
129129
$this->loadResourcesFromTheme($cacheKey, $this->defaultThemes[$i]);
130130
// CONTINUE LOADING (see doc comment)
131131
}

0 commit comments

Comments
 (0)