Skip to content

Commit 2fad125

Browse files
committed
Enable the fixer enforcing fully-qualified calls for compiler-optimized functions
1 parent 42a0adc commit 2fad125

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+145
-145
lines changed

Application.php

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ public function add(Command $command)
369369
}
370370

371371
if (null === $command->getDefinition()) {
372-
throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', get_class($command)));
372+
throw new LogicException(sprintf('Command class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', \get_class($command)));
373373
}
374374

375375
$this->commands[$command->getName()] = $command;
@@ -466,7 +466,7 @@ public function findNamespace($namespace)
466466
$message = sprintf('There are no commands defined in the "%s" namespace.', $namespace);
467467

468468
if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
469-
if (1 == count($alternatives)) {
469+
if (1 == \count($alternatives)) {
470470
$message .= "\n\nDid you mean this?\n ";
471471
} else {
472472
$message .= "\n\nDid you mean one of these?\n ";
@@ -478,8 +478,8 @@ public function findNamespace($namespace)
478478
throw new CommandNotFoundException($message, $alternatives);
479479
}
480480

481-
$exact = in_array($namespace, $namespaces, true);
482-
if (count($namespaces) > 1 && !$exact) {
481+
$exact = \in_array($namespace, $namespaces, true);
482+
if (\count($namespaces) > 1 && !$exact) {
483483
throw new CommandNotFoundException(sprintf('The namespace "%s" is ambiguous (%s).', $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
484484
}
485485

@@ -506,7 +506,7 @@ public function find($name)
506506
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
507507
$commands = preg_grep('{^'.$expr.'}', $allCommands);
508508

509-
if (empty($commands) || count(preg_grep('{^'.$expr.'$}', $commands)) < 1) {
509+
if (empty($commands) || \count(preg_grep('{^'.$expr.'$}', $commands)) < 1) {
510510
if (false !== $pos = strrpos($name, ':')) {
511511
// check if a namespace exists and contains commands
512512
$this->findNamespace(substr($name, 0, $pos));
@@ -515,7 +515,7 @@ public function find($name)
515515
$message = sprintf('Command "%s" is not defined.', $name);
516516

517517
if ($alternatives = $this->findAlternatives($name, $allCommands)) {
518-
if (1 == count($alternatives)) {
518+
if (1 == \count($alternatives)) {
519519
$message .= "\n\nDid you mean this?\n ";
520520
} else {
521521
$message .= "\n\nDid you mean one of these?\n ";
@@ -527,18 +527,18 @@ public function find($name)
527527
}
528528

529529
// filter out aliases for commands which are already on the list
530-
if (count($commands) > 1) {
530+
if (\count($commands) > 1) {
531531
$commandList = $this->commands;
532532
$commands = array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
533533
$commandName = $commandList[$nameOrAlias]->getName();
534534
$aliases[$nameOrAlias] = $commandName;
535535

536-
return $commandName === $nameOrAlias || !in_array($commandName, $commands);
536+
return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
537537
});
538538
}
539539

540-
$exact = in_array($name, $commands, true) || isset($aliases[$name]);
541-
if (!$exact && count($commands) > 1) {
540+
$exact = \in_array($name, $commands, true) || isset($aliases[$name]);
541+
if (!$exact && \count($commands) > 1) {
542542
$suggestions = $this->getAbbreviationSuggestions(array_values($commands));
543543

544544
throw new CommandNotFoundException(sprintf('Command "%s" is ambiguous (%s).', $name, $suggestions), array_values($commands));
@@ -585,7 +585,7 @@ public static function getAbbreviations($names)
585585
{
586586
$abbrevs = array();
587587
foreach ($names as $name) {
588-
for ($len = strlen($name); $len > 0; --$len) {
588+
for ($len = \strlen($name); $len > 0; --$len) {
589589
$abbrev = substr($name, 0, $len);
590590
$abbrevs[$abbrev][] = $name;
591591
}
@@ -649,13 +649,13 @@ public function renderException($e, $output)
649649
$output->writeln('', OutputInterface::VERBOSITY_QUIET);
650650

651651
do {
652-
$title = sprintf(' [%s] ', get_class($e));
652+
$title = sprintf(' [%s] ', \get_class($e));
653653

654654
$len = Helper::strlen($title);
655655

656656
$width = $this->getTerminalWidth() ? $this->getTerminalWidth() - 1 : PHP_INT_MAX;
657657
// HHVM only accepts 32 bits integer in str_split, even when PHP_INT_MAX is a 64 bit integer: https://github.com/facebook/hhvm/issues/1327
658-
if (defined('HHVM_VERSION') && $width > 1 << 31) {
658+
if (\defined('HHVM_VERSION') && $width > 1 << 31) {
659659
$width = 1 << 31;
660660
}
661661
$lines = array();
@@ -692,7 +692,7 @@ public function renderException($e, $output)
692692
'args' => array(),
693693
));
694694

695-
for ($i = 0, $count = count($trace); $i < $count; ++$i) {
695+
for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
696696
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
697697
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
698698
$function = $trace[$i]['function'];
@@ -802,7 +802,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
802802

803803
if (true === $input->hasParameterOption(array('--no-interaction', '-n'))) {
804804
$input->setInteractive(false);
805-
} elseif (function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
805+
} elseif (\function_exists('posix_isatty') && $this->getHelperSet()->has('question')) {
806806
$inputStream = $this->getHelperSet()->get('question')->getInputStream();
807807
if (!@posix_isatty($inputStream) && false === getenv('SHELL_INTERACTIVE')) {
808808
$input->setInteractive(false);
@@ -951,13 +951,13 @@ protected function getDefaultHelperSet()
951951
*/
952952
private function getSttyColumns()
953953
{
954-
if (!function_exists('proc_open')) {
954+
if (!\function_exists('proc_open')) {
955955
return;
956956
}
957957

958958
$descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
959959
$process = proc_open('stty -a | grep columns', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
960-
if (is_resource($process)) {
960+
if (\is_resource($process)) {
961961
$info = stream_get_contents($pipes[1]);
962962
fclose($pipes[1]);
963963
fclose($pipes[2]);
@@ -974,13 +974,13 @@ private function getSttyColumns()
974974
*/
975975
private function getConsoleMode()
976976
{
977-
if (!function_exists('proc_open')) {
977+
if (!\function_exists('proc_open')) {
978978
return;
979979
}
980980

981981
$descriptorspec = array(1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
982982
$process = proc_open('mode CON', $descriptorspec, $pipes, null, null, array('suppress_errors' => true));
983-
if (is_resource($process)) {
983+
if (\is_resource($process)) {
984984
$info = stream_get_contents($pipes[1]);
985985
fclose($pipes[1]);
986986
fclose($pipes[2]);
@@ -1001,7 +1001,7 @@ private function getConsoleMode()
10011001
*/
10021002
private function getAbbreviationSuggestions($abbrevs)
10031003
{
1004-
return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], count($abbrevs) > 2 ? sprintf(' and %d more', count($abbrevs) - 2) : '');
1004+
return sprintf('%s, %s%s', $abbrevs[0], $abbrevs[1], \count($abbrevs) > 2 ? sprintf(' and %d more', \count($abbrevs) - 2) : '');
10051005
}
10061006

10071007
/**
@@ -1019,7 +1019,7 @@ public function extractNamespace($name, $limit = null)
10191019
$parts = explode(':', $name);
10201020
array_pop($parts);
10211021

1022-
return implode(':', null === $limit ? $parts : array_slice($parts, 0, $limit));
1022+
return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
10231023
}
10241024

10251025
/**
@@ -1052,7 +1052,7 @@ private function findAlternatives($name, $collection)
10521052
}
10531053

10541054
$lev = levenshtein($subname, $parts[$i]);
1055-
if ($lev <= strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
1055+
if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
10561056
$alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
10571057
} elseif ($exists) {
10581058
$alternatives[$collectionName] += $threshold;
@@ -1062,7 +1062,7 @@ private function findAlternatives($name, $collection)
10621062

10631063
foreach ($collection as $item) {
10641064
$lev = levenshtein($name, $item);
1065-
if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
1065+
if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
10661066
$alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
10671067
}
10681068
}
@@ -1106,7 +1106,7 @@ private function splitStringByWidth($string, $width)
11061106
$line = $char;
11071107
}
11081108

1109-
$lines[] = count($lines) ? str_pad($line, $width) : $line;
1109+
$lines[] = \count($lines) ? str_pad($line, $width) : $line;
11101110

11111111
mb_convert_variables($encoding, 'utf8', $lines);
11121112

@@ -1127,7 +1127,7 @@ private function extractAllNamespaces($name)
11271127
$namespaces = array();
11281128

11291129
foreach ($parts as $part) {
1130-
if (count($namespaces)) {
1130+
if (\count($namespaces)) {
11311131
$namespaces[] = end($namespaces).':'.$part;
11321132
} else {
11331133
$namespaces[] = $part;

Command/Command.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function __construct($name = null)
6363
$this->configure();
6464

6565
if (!$this->name) {
66-
throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', get_class($this)));
66+
throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($this)));
6767
}
6868
}
6969

@@ -207,15 +207,15 @@ public function run(InputInterface $input, OutputInterface $output)
207207
$this->initialize($input, $output);
208208

209209
if (null !== $this->processTitle) {
210-
if (function_exists('cli_set_process_title')) {
210+
if (\function_exists('cli_set_process_title')) {
211211
if (!@cli_set_process_title($this->processTitle)) {
212212
if ('Darwin' === PHP_OS) {
213213
$output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
214214
} else {
215215
cli_set_process_title($this->processTitle);
216216
}
217217
}
218-
} elseif (function_exists('setproctitle')) {
218+
} elseif (\function_exists('setproctitle')) {
219219
setproctitle($this->processTitle);
220220
} elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
221221
$output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
@@ -236,7 +236,7 @@ public function run(InputInterface $input, OutputInterface $output)
236236
$input->validate();
237237

238238
if ($this->code) {
239-
$statusCode = call_user_func($this->code, $input, $output);
239+
$statusCode = \call_user_func($this->code, $input, $output);
240240
} else {
241241
$statusCode = $this->execute($input, $output);
242242
}
@@ -260,7 +260,7 @@ public function run(InputInterface $input, OutputInterface $output)
260260
*/
261261
public function setCode($code)
262262
{
263-
if (!is_callable($code)) {
263+
if (!\is_callable($code)) {
264264
throw new InvalidArgumentException('Invalid callable provided to Command::setCode.');
265265
}
266266

@@ -524,7 +524,7 @@ public function getProcessedHelp()
524524
*/
525525
public function setAliases($aliases)
526526
{
527-
if (!is_array($aliases) && !$aliases instanceof \Traversable) {
527+
if (!\is_array($aliases) && !$aliases instanceof \Traversable) {
528528
throw new InvalidArgumentException('$aliases must be an array or an instance of \Traversable');
529529
}
530530

Descriptor/Descriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function describe(OutputInterface $output, $object, array $options = arra
5555
$this->describeApplication($object, $options);
5656
break;
5757
default:
58-
throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object)));
58+
throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
5959
}
6060
}
6161

Descriptor/MarkdownDescriptor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ protected function describeInputOption(InputOption $option, array $options = arr
6464
*/
6565
protected function describeInputDefinition(InputDefinition $definition, array $options = array())
6666
{
67-
if ($showArguments = count($definition->getArguments()) > 0) {
67+
if ($showArguments = \count($definition->getArguments()) > 0) {
6868
$this->write('### Arguments:');
6969
foreach ($definition->getArguments() as $argument) {
7070
$this->write("\n\n");
7171
$this->write($this->describeInputArgument($argument));
7272
}
7373
}
7474

75-
if (count($definition->getOptions()) > 0) {
75+
if (\count($definition->getOptions()) > 0) {
7676
if ($showArguments) {
7777
$this->write("\n\n");
7878
}

Descriptor/TextDescriptor.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ class TextDescriptor extends Descriptor
3333
*/
3434
protected function describeInputArgument(InputArgument $argument, array $options = array())
3535
{
36-
if (null !== $argument->getDefault() && (!is_array($argument->getDefault()) || count($argument->getDefault()))) {
36+
if (null !== $argument->getDefault() && (!\is_array($argument->getDefault()) || \count($argument->getDefault()))) {
3737
$default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($argument->getDefault()));
3838
} else {
3939
$default = '';
4040
}
4141

4242
$totalWidth = isset($options['total_width']) ? $options['total_width'] : Helper::strlen($argument->getName());
43-
$spacingWidth = $totalWidth - strlen($argument->getName());
43+
$spacingWidth = $totalWidth - \strlen($argument->getName());
4444

4545
$this->writeText(sprintf(' <info>%s</info> %s%s%s',
4646
$argument->getName(),
@@ -56,7 +56,7 @@ protected function describeInputArgument(InputArgument $argument, array $options
5656
*/
5757
protected function describeInputOption(InputOption $option, array $options = array())
5858
{
59-
if ($option->acceptValue() && null !== $option->getDefault() && (!is_array($option->getDefault()) || count($option->getDefault()))) {
59+
if ($option->acceptValue() && null !== $option->getDefault() && (!\is_array($option->getDefault()) || \count($option->getDefault()))) {
6060
$default = sprintf('<comment> [default: %s]</comment>', $this->formatDefaultValue($option->getDefault()));
6161
} else {
6262
$default = '';
@@ -117,7 +117,7 @@ protected function describeInputDefinition(InputDefinition $definition, array $o
117117

118118
$this->writeText('<comment>Options:</comment>', $options);
119119
foreach ($definition->getOptions() as $option) {
120-
if (strlen($option->getShortcut()) > 1) {
120+
if (\strlen($option->getShortcut()) > 1) {
121121
$laterOptions[] = $option;
122122
continue;
123123
}
@@ -241,11 +241,11 @@ private function formatDefaultValue($default)
241241
return 'INF';
242242
}
243243

244-
if (is_string($default)) {
244+
if (\is_string($default)) {
245245
$default = OutputFormatter::escape($default);
246-
} elseif (is_array($default)) {
246+
} elseif (\is_array($default)) {
247247
foreach ($default as $key => $value) {
248-
if (is_string($value)) {
248+
if (\is_string($value)) {
249249
$default[$key] = OutputFormatter::escape($value);
250250
}
251251
}
@@ -287,7 +287,7 @@ private function calculateTotalWidthForOptions(array $options)
287287
$totalWidth = 0;
288288
foreach ($options as $option) {
289289
// "-" + shortcut + ", --" + name
290-
$nameLength = 1 + max(strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
290+
$nameLength = 1 + max(\strlen($option->getShortcut()), 1) + 4 + Helper::strlen($option->getName());
291291

292292
if ($option->acceptValue()) {
293293
$valueLength = 1 + Helper::strlen($option->getName()); // = + value

Descriptor/XmlDescriptor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private function getInputArgumentDocument(InputArgument $argument)
202202
$descriptionXML->appendChild($dom->createTextNode($argument->getDescription()));
203203

204204
$objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
205-
$defaults = is_array($argument->getDefault()) ? $argument->getDefault() : (is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
205+
$defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
206206
foreach ($defaults as $default) {
207207
$defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
208208
$defaultXML->appendChild($dom->createTextNode($default));
@@ -234,7 +234,7 @@ private function getInputOptionDocument(InputOption $option)
234234
$descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
235235

236236
if ($option->acceptValue()) {
237-
$defaults = is_array($option->getDefault()) ? $option->getDefault() : (is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));
237+
$defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));
238238
$objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
239239

240240
if (!empty($defaults)) {

Formatter/OutputFormatter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ public static function escape($text)
5050
public static function escapeTrailingBackslash($text)
5151
{
5252
if ('\\' === substr($text, -1)) {
53-
$len = strlen($text);
53+
$len = \strlen($text);
5454
$text = rtrim($text, '\\');
5555
$text = str_replace("\0", '', $text);
56-
$text .= str_repeat("\0", $len - strlen($text));
56+
$text .= str_repeat("\0", $len - \strlen($text));
5757
}
5858

5959
return $text;
@@ -145,7 +145,7 @@ public function format($message)
145145

146146
// add the text up to the next tag
147147
$output .= $this->applyCurrentStyle(substr($message, $offset, $pos - $offset));
148-
$offset = $pos + strlen($text);
148+
$offset = $pos + \strlen($text);
149149

150150
// opening tag?
151151
if ($open = '/' != $text[1]) {
@@ -229,6 +229,6 @@ private function createStyleFromString($string)
229229
*/
230230
private function applyCurrentStyle($text)
231231
{
232-
return $this->isDecorated() && strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
232+
return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
233233
}
234234
}

0 commit comments

Comments
 (0)