Skip to content

Commit a93c40c

Browse files
Merge branch '4.1'
* 4.1: 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 1c70c40 + 039e295 commit a93c40c

36 files changed

+131
-131
lines changed

Application.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null
132132
};
133133
if ($phpHandler = set_exception_handler($renderException)) {
134134
restore_exception_handler();
135-
if (!is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
135+
if (!\is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
136136
$debugHandler = true;
137137
} elseif ($debugHandler = $phpHandler[0]->setExceptionHandler($renderException)) {
138138
$phpHandler[0]->setExceptionHandler($debugHandler);
@@ -225,7 +225,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
225225
// the command name MUST be the first element of the input
226226
$command = $this->find($name);
227227
} catch (\Throwable $e) {
228-
if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) {
228+
if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== \count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) {
229229
if (null !== $this->dispatcher) {
230230
$event = new ConsoleErrorEvent($input, $output, $e);
231231
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
@@ -465,11 +465,11 @@ public function add(Command $command)
465465
}
466466

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

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

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

568568
if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
569-
if (1 == count($alternatives)) {
569+
if (1 == \count($alternatives)) {
570570
$message .= "\n\nDid you mean this?\n ";
571571
} else {
572572
$message .= "\n\nDid you mean one of these?\n ";
@@ -578,8 +578,8 @@ public function findNamespace($namespace)
578578
throw new NamespaceNotFoundException($message, $alternatives);
579579
}
580580

581-
$exact = in_array($namespace, $namespaces, true);
582-
if (count($namespaces) > 1 && !$exact) {
581+
$exact = \in_array($namespace, $namespaces, true);
582+
if (\count($namespaces) > 1 && !$exact) {
583583
throw new NamespaceNotFoundException(sprintf("The namespace \"%s\" is ambiguous.\nDid you mean one of these?\n%s", $namespace, $this->getAbbreviationSuggestions(array_values($namespaces))), array_values($namespaces));
584584
}
585585

@@ -612,7 +612,7 @@ public function find($name)
612612
}
613613

614614
// if no commands matched or we just matched namespaces
615-
if (empty($commands) || count(preg_grep('{^'.$expr.'$}i', $commands)) < 1) {
615+
if (empty($commands) || \count(preg_grep('{^'.$expr.'$}i', $commands)) < 1) {
616616
if (false !== $pos = strrpos($name, ':')) {
617617
// check if a namespace exists and contains commands
618618
$this->findNamespace(substr($name, 0, $pos));
@@ -621,7 +621,7 @@ public function find($name)
621621
$message = sprintf('Command "%s" is not defined.', $name);
622622

623623
if ($alternatives = $this->findAlternatives($name, $allCommands)) {
624-
if (1 == count($alternatives)) {
624+
if (1 == \count($alternatives)) {
625625
$message .= "\n\nDid you mean this?\n ";
626626
} else {
627627
$message .= "\n\nDid you mean one of these?\n ";
@@ -633,18 +633,18 @@ public function find($name)
633633
}
634634

635635
// filter out aliases for commands which are already on the list
636-
if (count($commands) > 1) {
636+
if (\count($commands) > 1) {
637637
$commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
638638
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
639639
$commandName = $commandList[$nameOrAlias] instanceof Command ? $commandList[$nameOrAlias]->getName() : $nameOrAlias;
640640
$aliases[$nameOrAlias] = $commandName;
641641

642-
return $commandName === $nameOrAlias || !in_array($commandName, $commands);
642+
return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
643643
}));
644644
}
645645

646-
$exact = in_array($name, $commands, true) || isset($aliases[$name]);
647-
if (count($commands) > 1 && !$exact) {
646+
$exact = \in_array($name, $commands, true) || isset($aliases[$name]);
647+
if (\count($commands) > 1 && !$exact) {
648648
$usableWidth = $this->terminal->getWidth() - 10;
649649
$abbrevs = array_values($commands);
650650
$maxLen = 0;
@@ -724,7 +724,7 @@ public static function getAbbreviations($names)
724724
{
725725
$abbrevs = array();
726726
foreach ($names as $name) {
727-
for ($len = strlen($name); $len > 0; --$len) {
727+
for ($len = \strlen($name); $len > 0; --$len) {
728728
$abbrev = substr($name, 0, $len);
729729
$abbrevs[$abbrev][] = $name;
730730
}
@@ -753,7 +753,7 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
753753
do {
754754
$message = trim($e->getMessage());
755755
if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
756-
$title = sprintf(' [%s%s] ', get_class($e), 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
756+
$title = sprintf(' [%s%s] ', \get_class($e), 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
757757
$len = Helper::strlen($title);
758758
} else {
759759
$len = 0;
@@ -793,7 +793,7 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
793793
// exception related properties
794794
$trace = $e->getTrace();
795795

796-
for ($i = 0, $count = count($trace); $i < $count; ++$i) {
796+
for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
797797
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
798798
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
799799
$function = $trace[$i]['function'];
@@ -821,7 +821,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
821821

822822
if (true === $input->hasParameterOption(array('--no-interaction', '-n'), true)) {
823823
$input->setInteractive(false);
824-
} elseif (function_exists('posix_isatty')) {
824+
} elseif (\function_exists('posix_isatty')) {
825825
$inputStream = null;
826826

827827
if ($input instanceof StreamableInputInterface) {
@@ -1007,7 +1007,7 @@ public function extractNamespace($name, $limit = null)
10071007
$parts = explode(':', $name);
10081008
array_pop($parts);
10091009

1010-
return implode(':', null === $limit ? $parts : array_slice($parts, 0, $limit));
1010+
return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
10111011
}
10121012

10131013
/**
@@ -1040,7 +1040,7 @@ private function findAlternatives($name, $collection)
10401040
}
10411041

10421042
$lev = levenshtein($subname, $parts[$i]);
1043-
if ($lev <= strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
1043+
if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
10441044
$alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
10451045
} elseif ($exists) {
10461046
$alternatives[$collectionName] += $threshold;
@@ -1050,7 +1050,7 @@ private function findAlternatives($name, $collection)
10501050

10511051
foreach ($collection as $item) {
10521052
$lev = levenshtein($name, $item);
1053-
if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
1053+
if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
10541054
$alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
10551055
}
10561056
}
@@ -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: 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: 7 additions & 7 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
}
@@ -284,11 +284,11 @@ private function formatDefaultValue($default): string
284284
return 'INF';
285285
}
286286

287-
if (is_string($default)) {
287+
if (\is_string($default)) {
288288
$default = OutputFormatter::escape($default);
289-
} elseif (is_array($default)) {
289+
} elseif (\is_array($default)) {
290290
foreach ($default as $key => $value) {
291-
if (is_string($value)) {
291+
if (\is_string($value)) {
292292
$default[$key] = OutputFormatter::escape($value);
293293
}
294294
}

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
}

0 commit comments

Comments
 (0)