Skip to content

Commit 6192c1c

Browse files
Merge branch '3.4' into 4.0
* 3.4: 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 9f44418 + 3846c53 commit 6192c1c

36 files changed

+129
-129
lines changed

Application.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null
130130
};
131131
if ($phpHandler = set_exception_handler($renderException)) {
132132
restore_exception_handler();
133-
if (!is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
133+
if (!\is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
134134
$debugHandler = true;
135135
} elseif ($debugHandler = $phpHandler[0]->setExceptionHandler($renderException)) {
136136
$phpHandler[0]->setExceptionHandler($debugHandler);
@@ -444,11 +444,11 @@ public function add(Command $command)
444444
}
445445

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

450450
if (!$command->getName()) {
451-
throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', get_class($command)));
451+
throw new LogicException(sprintf('The command defined in "%s" cannot have an empty name.', \get_class($command)));
452452
}
453453

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

547547
if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
548-
if (1 == count($alternatives)) {
548+
if (1 == \count($alternatives)) {
549549
$message .= "\n\nDid you mean this?\n ";
550550
} else {
551551
$message .= "\n\nDid you mean one of these?\n ";
@@ -557,8 +557,8 @@ public function findNamespace($namespace)
557557
throw new CommandNotFoundException($message, $alternatives);
558558
}
559559

560-
$exact = in_array($namespace, $namespaces, true);
561-
if (count($namespaces) > 1 && !$exact) {
560+
$exact = \in_array($namespace, $namespaces, true);
561+
if (\count($namespaces) > 1 && !$exact) {
562562
throw new CommandNotFoundException(sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
563563
}
564564

@@ -591,7 +591,7 @@ public function find($name)
591591
}
592592

593593
// if no commands matched or we just matched namespaces
594-
if (empty($commands) || count(preg_grep('{^'.$expr.'$}i', $commands)) < 1) {
594+
if (empty($commands) || \count(preg_grep('{^'.$expr.'$}i', $commands)) < 1) {
595595
if (false !== $pos = strrpos($name, ':')) {
596596
// check if a namespace exists and contains commands
597597
$this->findNamespace(substr($name, 0, $pos));
@@ -600,7 +600,7 @@ public function find($name)
600600
$message = sprintf('Command "%s" is not defined.', $name);
601601

602602
if ($alternatives = $this->findAlternatives($name, $allCommands)) {
603-
if (1 == count($alternatives)) {
603+
if (1 == \count($alternatives)) {
604604
$message .= "\n\nDid you mean this?\n ";
605605
} else {
606606
$message .= "\n\nDid you mean one of these?\n ";
@@ -612,18 +612,18 @@ public function find($name)
612612
}
613613

614614
// filter out aliases for commands which are already on the list
615-
if (count($commands) > 1) {
615+
if (\count($commands) > 1) {
616616
$commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
617617
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
618618
$commandName = $commandList[$nameOrAlias] instanceof Command ? $commandList[$nameOrAlias]->getName() : $nameOrAlias;
619619
$aliases[$nameOrAlias] = $commandName;
620620

621-
return $commandName === $nameOrAlias || !in_array($commandName, $commands);
621+
return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
622622
}));
623623
}
624624

625-
$exact = in_array($name, $commands, true) || isset($aliases[$name]);
626-
if (count($commands) > 1 && !$exact) {
625+
$exact = \in_array($name, $commands, true) || isset($aliases[$name]);
626+
if (\count($commands) > 1 && !$exact) {
627627
$usableWidth = $this->terminal->getWidth() - 10;
628628
$abbrevs = array_values($commands);
629629
$maxLen = 0;
@@ -703,7 +703,7 @@ public static function getAbbreviations($names)
703703
{
704704
$abbrevs = array();
705705
foreach ($names as $name) {
706-
for ($len = strlen($name); $len > 0; --$len) {
706+
for ($len = \strlen($name); $len > 0; --$len) {
707707
$abbrev = substr($name, 0, $len);
708708
$abbrevs[$abbrev][] = $name;
709709
}
@@ -732,7 +732,7 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
732732
do {
733733
$message = trim($e->getMessage());
734734
if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
735-
$title = sprintf(' [%s%s] ', get_class($e), 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
735+
$title = sprintf(' [%s%s] ', \get_class($e), 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
736736
$len = Helper::strlen($title);
737737
} else {
738738
$len = 0;
@@ -772,7 +772,7 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
772772
// exception related properties
773773
$trace = $e->getTrace();
774774

775-
for ($i = 0, $count = count($trace); $i < $count; ++$i) {
775+
for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
776776
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
777777
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
778778
$function = $trace[$i]['function'];
@@ -800,7 +800,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
800800

801801
if (true === $input->hasParameterOption(array('--no-interaction', '-n'), true)) {
802802
$input->setInteractive(false);
803-
} elseif (function_exists('posix_isatty')) {
803+
} elseif (\function_exists('posix_isatty')) {
804804
$inputStream = null;
805805

806806
if ($input instanceof StreamableInputInterface) {
@@ -986,7 +986,7 @@ public function extractNamespace($name, $limit = null)
986986
$parts = explode(':', $name);
987987
array_pop($parts);
988988

989-
return implode(':', null === $limit ? $parts : array_slice($parts, 0, $limit));
989+
return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
990990
}
991991

992992
/**
@@ -1019,7 +1019,7 @@ private function findAlternatives($name, $collection)
10191019
}
10201020

10211021
$lev = levenshtein($subname, $parts[$i]);
1022-
if ($lev <= strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
1022+
if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
10231023
$alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
10241024
} elseif ($exists) {
10251025
$alternatives[$collectionName] += $threshold;
@@ -1029,7 +1029,7 @@ private function findAlternatives($name, $collection)
10291029

10301030
foreach ($collection as $item) {
10311031
$lev = levenshtein($name, $item);
1032-
if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
1032+
if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
10331033
$alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
10341034
}
10351035
}
@@ -1085,7 +1085,7 @@ private function splitStringByWidth($string, $width)
10851085
$line = $char;
10861086
}
10871087

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

10901090
mb_convert_variables($encoding, 'utf8', $lines);
10911091

@@ -1106,7 +1106,7 @@ private function extractAllNamespaces($name)
11061106
$namespaces = array();
11071107

11081108
foreach ($parts as $part) {
1109-
if (count($namespaces)) {
1109+
if (\count($namespaces)) {
11101110
$namespaces[] = end($namespaces).':'.$part;
11111111
} else {
11121112
$namespaces[] = $part;

Command/Command.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class Command
5555
*/
5656
public static function getDefaultName()
5757
{
58-
$class = get_called_class();
58+
$class = \get_called_class();
5959
$r = new \ReflectionProperty($class, 'defaultName');
6060

6161
return $class === $r->class ? static::$defaultName : null;
@@ -217,15 +217,15 @@ public function run(InputInterface $input, OutputInterface $output)
217217
$this->initialize($input, $output);
218218

219219
if (null !== $this->processTitle) {
220-
if (function_exists('cli_set_process_title')) {
220+
if (\function_exists('cli_set_process_title')) {
221221
if (!@cli_set_process_title($this->processTitle)) {
222222
if ('Darwin' === PHP_OS) {
223223
$output->writeln('<comment>Running "cli_set_process_title" as an unprivileged user is not supported on MacOS.</comment>', OutputInterface::VERBOSITY_VERY_VERBOSE);
224224
} else {
225225
cli_set_process_title($this->processTitle);
226226
}
227227
}
228-
} elseif (function_exists('setproctitle')) {
228+
} elseif (\function_exists('setproctitle')) {
229229
setproctitle($this->processTitle);
230230
} elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
231231
$output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
@@ -246,7 +246,7 @@ public function run(InputInterface $input, OutputInterface $output)
246246
$input->validate();
247247

248248
if ($this->code) {
249-
$statusCode = call_user_func($this->code, $input, $output);
249+
$statusCode = \call_user_func($this->code, $input, $output);
250250
} else {
251251
$statusCode = $this->execute($input, $output);
252252
}
@@ -542,7 +542,7 @@ public function getProcessedHelp()
542542
*/
543543
public function setAliases($aliases)
544544
{
545-
if (!is_array($aliases) && !$aliases instanceof \Traversable) {
545+
if (!\is_array($aliases) && !$aliases instanceof \Traversable) {
546546
throw new InvalidArgumentException('$aliases must be an array or an instance of \Traversable');
547547
}
548548

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
@@ -88,15 +88,15 @@ protected function describeInputOption(InputOption $option, array $options = arr
8888
*/
8989
protected function describeInputDefinition(InputDefinition $definition, array $options = array())
9090
{
91-
if ($showArguments = count($definition->getArguments()) > 0) {
91+
if ($showArguments = \count($definition->getArguments()) > 0) {
9292
$this->write('### Arguments');
9393
foreach ($definition->getArguments() as $argument) {
9494
$this->write("\n\n");
9595
$this->write($this->describeInputArgument($argument));
9696
}
9797
}
9898

99-
if (count($definition->getOptions()) > 0) {
99+
if (\count($definition->getOptions()) > 0) {
100100
if ($showArguments) {
101101
$this->write("\n\n");
102102
}

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
}
@@ -202,7 +202,7 @@ protected function describeApplication(Application $application, array $options
202202
}
203203

204204
// calculate max. width based on available commands per namespace
205-
$width = $this->getColumnWidth(call_user_func_array('array_merge', array_map(function ($namespace) use ($commands) {
205+
$width = $this->getColumnWidth(\call_user_func_array('array_merge', array_map(function ($namespace) use ($commands) {
206206
return array_intersect($namespace['commands'], array_keys($commands));
207207
}, $namespaces)));
208208

@@ -276,11 +276,11 @@ private function formatDefaultValue($default): string
276276
return 'INF';
277277
}
278278

279-
if (is_string($default)) {
279+
if (\is_string($default)) {
280280
$default = OutputFormatter::escape($default);
281-
} elseif (is_array($default)) {
281+
} elseif (\is_array($default)) {
282282
foreach ($default as $key => $value) {
283-
if (is_string($value)) {
283+
if (\is_string($value)) {
284284
$default[$key] = OutputFormatter::escape($value);
285285
}
286286
}

Descriptor/XmlDescriptor.php

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

202202
$objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
203-
$defaults = is_array($argument->getDefault()) ? $argument->getDefault() : (is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
203+
$defaults = \is_array($argument->getDefault()) ? $argument->getDefault() : (\is_bool($argument->getDefault()) ? array(var_export($argument->getDefault(), true)) : ($argument->getDefault() ? array($argument->getDefault()) : array()));
204204
foreach ($defaults as $default) {
205205
$defaultsXML->appendChild($defaultXML = $dom->createElement('default'));
206206
$defaultXML->appendChild($dom->createTextNode($default));
@@ -229,7 +229,7 @@ private function getInputOptionDocument(InputOption $option): \DOMDocument
229229
$descriptionXML->appendChild($dom->createTextNode($option->getDescription()));
230230

231231
if ($option->acceptValue()) {
232-
$defaults = is_array($option->getDefault()) ? $option->getDefault() : (is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));
232+
$defaults = \is_array($option->getDefault()) ? $option->getDefault() : (\is_bool($option->getDefault()) ? array(var_export($option->getDefault(), true)) : ($option->getDefault() ? array($option->getDefault()) : array()));
233233
$objectXML->appendChild($defaultsXML = $dom->createElement('defaults'));
234234

235235
if (!empty($defaults)) {

Event/ConsoleErrorEvent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@ public function setExitCode(int $exitCode): void
5353

5454
public function getExitCode(): int
5555
{
56-
return null !== $this->exitCode ? $this->exitCode : (is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1);
56+
return null !== $this->exitCode ? $this->exitCode : (\is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1);
5757
}
5858
}

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]) {
@@ -225,6 +225,6 @@ private function createStyleFromString(string $string)
225225
*/
226226
private function applyCurrentStyle(string $text): string
227227
{
228-
return $this->isDecorated() && strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
228+
return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
229229
}
230230
}

Formatter/OutputFormatterStyle.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function __construct(string $foreground = null, string $background = null
6969
if (null !== $background) {
7070
$this->setBackground($background);
7171
}
72-
if (count($options)) {
72+
if (\count($options)) {
7373
$this->setOptions($options);
7474
}
7575
}
@@ -143,7 +143,7 @@ public function setOption($option)
143143
));
144144
}
145145

146-
if (!in_array(static::$availableOptions[$option], $this->options)) {
146+
if (!\in_array(static::$availableOptions[$option], $this->options)) {
147147
$this->options[] = static::$availableOptions[$option];
148148
}
149149
}
@@ -203,14 +203,14 @@ public function apply($text)
203203
$setCodes[] = $this->background['set'];
204204
$unsetCodes[] = $this->background['unset'];
205205
}
206-
if (count($this->options)) {
206+
if (\count($this->options)) {
207207
foreach ($this->options as $option) {
208208
$setCodes[] = $option['set'];
209209
$unsetCodes[] = $option['unset'];
210210
}
211211
}
212212

213-
if (0 === count($setCodes)) {
213+
if (0 === \count($setCodes)) {
214214
return $text;
215215
}
216216

0 commit comments

Comments
 (0)