Skip to content

Commit 3846c53

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 e54f84c + 2fad125 commit 3846c53

38 files changed

+138
-138
lines changed

Application.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function run(InputInterface $input = null, OutputInterface $output = null
131131
};
132132
if ($phpHandler = set_exception_handler($renderException)) {
133133
restore_exception_handler();
134-
if (!is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
134+
if (!\is_array($phpHandler) || !$phpHandler[0] instanceof ErrorHandler) {
135135
$debugHandler = true;
136136
} elseif ($debugHandler = $phpHandler[0]->setExceptionHandler($renderException)) {
137137
$phpHandler[0]->setExceptionHandler($debugHandler);
@@ -451,11 +451,11 @@ public function add(Command $command)
451451
}
452452

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

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

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

554554
if ($alternatives = $this->findAlternatives($namespace, $allNamespaces)) {
555-
if (1 == count($alternatives)) {
555+
if (1 == \count($alternatives)) {
556556
$message .= "\n\nDid you mean this?\n ";
557557
} else {
558558
$message .= "\n\nDid you mean one of these?\n ";
@@ -564,8 +564,8 @@ public function findNamespace($namespace)
564564
throw new CommandNotFoundException($message, $alternatives);
565565
}
566566

567-
$exact = in_array($namespace, $namespaces, true);
568-
if (count($namespaces) > 1 && !$exact) {
567+
$exact = \in_array($namespace, $namespaces, true);
568+
if (\count($namespaces) > 1 && !$exact) {
569569
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));
570570
}
571571

@@ -598,7 +598,7 @@ public function find($name)
598598
}
599599

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

609609
if ($alternatives = $this->findAlternatives($name, $allCommands)) {
610-
if (1 == count($alternatives)) {
610+
if (1 == \count($alternatives)) {
611611
$message .= "\n\nDid you mean this?\n ";
612612
} else {
613613
$message .= "\n\nDid you mean one of these?\n ";
@@ -619,18 +619,18 @@ public function find($name)
619619
}
620620

621621
// filter out aliases for commands which are already on the list
622-
if (count($commands) > 1) {
622+
if (\count($commands) > 1) {
623623
$commandList = $this->commandLoader ? array_merge(array_flip($this->commandLoader->getNames()), $this->commands) : $this->commands;
624624
$commands = array_unique(array_filter($commands, function ($nameOrAlias) use ($commandList, $commands, &$aliases) {
625625
$commandName = $commandList[$nameOrAlias] instanceof Command ? $commandList[$nameOrAlias]->getName() : $nameOrAlias;
626626
$aliases[$nameOrAlias] = $commandName;
627627

628-
return $commandName === $nameOrAlias || !in_array($commandName, $commands);
628+
return $commandName === $nameOrAlias || !\in_array($commandName, $commands);
629629
}));
630630
}
631631

632-
$exact = in_array($name, $commands, true) || isset($aliases[$name]);
633-
if (count($commands) > 1 && !$exact) {
632+
$exact = \in_array($name, $commands, true) || isset($aliases[$name]);
633+
if (\count($commands) > 1 && !$exact) {
634634
$usableWidth = $this->terminal->getWidth() - 10;
635635
$abbrevs = array_values($commands);
636636
$maxLen = 0;
@@ -710,7 +710,7 @@ public static function getAbbreviations($names)
710710
{
711711
$abbrevs = array();
712712
foreach ($names as $name) {
713-
for ($len = strlen($name); $len > 0; --$len) {
713+
for ($len = \strlen($name); $len > 0; --$len) {
714714
$abbrev = substr($name, 0, $len);
715715
$abbrevs[$abbrev][] = $name;
716716
}
@@ -739,15 +739,15 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
739739
do {
740740
$message = trim($e->getMessage());
741741
if ('' === $message || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
742-
$title = sprintf(' [%s%s] ', get_class($e), 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
742+
$title = sprintf(' [%s%s] ', \get_class($e), 0 !== ($code = $e->getCode()) ? ' ('.$code.')' : '');
743743
$len = Helper::strlen($title);
744744
} else {
745745
$len = 0;
746746
}
747747

748748
$width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : PHP_INT_MAX;
749749
// 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
750-
if (defined('HHVM_VERSION') && $width > 1 << 31) {
750+
if (\defined('HHVM_VERSION') && $width > 1 << 31) {
751751
$width = 1 << 31;
752752
}
753753
$lines = array();
@@ -783,7 +783,7 @@ protected function doRenderException(\Exception $e, OutputInterface $output)
783783
// exception related properties
784784
$trace = $e->getTrace();
785785

786-
for ($i = 0, $count = count($trace); $i < $count; ++$i) {
786+
for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
787787
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
788788
$type = isset($trace[$i]['type']) ? $trace[$i]['type'] : '';
789789
$function = $trace[$i]['function'];
@@ -875,7 +875,7 @@ protected function configureIO(InputInterface $input, OutputInterface $output)
875875

876876
if (true === $input->hasParameterOption(array('--no-interaction', '-n'), true)) {
877877
$input->setInteractive(false);
878-
} elseif (function_exists('posix_isatty')) {
878+
} elseif (\function_exists('posix_isatty')) {
879879
$inputStream = null;
880880

881881
if ($input instanceof StreamableInputInterface) {
@@ -1079,7 +1079,7 @@ public function extractNamespace($name, $limit = null)
10791079
$parts = explode(':', $name);
10801080
array_pop($parts);
10811081

1082-
return implode(':', null === $limit ? $parts : array_slice($parts, 0, $limit));
1082+
return implode(':', null === $limit ? $parts : \array_slice($parts, 0, $limit));
10831083
}
10841084

10851085
/**
@@ -1112,7 +1112,7 @@ private function findAlternatives($name, $collection)
11121112
}
11131113

11141114
$lev = levenshtein($subname, $parts[$i]);
1115-
if ($lev <= strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
1115+
if ($lev <= \strlen($subname) / 3 || '' !== $subname && false !== strpos($parts[$i], $subname)) {
11161116
$alternatives[$collectionName] = $exists ? $alternatives[$collectionName] + $lev : $lev;
11171117
} elseif ($exists) {
11181118
$alternatives[$collectionName] += $threshold;
@@ -1122,7 +1122,7 @@ private function findAlternatives($name, $collection)
11221122

11231123
foreach ($collection as $item) {
11241124
$lev = levenshtein($name, $item);
1125-
if ($lev <= strlen($name) / 3 || false !== strpos($item, $name)) {
1125+
if ($lev <= \strlen($name) / 3 || false !== strpos($item, $name)) {
11261126
$alternatives[$item] = isset($alternatives[$item]) ? $alternatives[$item] - $lev : $lev;
11271127
}
11281128
}
@@ -1178,7 +1178,7 @@ private function splitStringByWidth($string, $width)
11781178
$line = $char;
11791179
}
11801180

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

11831183
mb_convert_variables($encoding, 'utf8', $lines);
11841184

@@ -1199,7 +1199,7 @@ private function extractAllNamespaces($name)
11991199
$namespaces = array();
12001200

12011201
foreach ($parts as $part) {
1202-
if (count($namespaces)) {
1202+
if (\count($namespaces)) {
12031203
$namespaces[] = end($namespaces).':'.$part;
12041204
} else {
12051205
$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
}
@@ -550,7 +550,7 @@ public function getProcessedHelp()
550550
*/
551551
public function setAliases($aliases)
552552
{
553-
if (!is_array($aliases) && !$aliases instanceof \Traversable) {
553+
if (!\is_array($aliases) && !$aliases instanceof \Traversable) {
554554
throw new InvalidArgumentException('$aliases must be an array or an instance of \Traversable');
555555
}
556556

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

@@ -280,11 +280,11 @@ private function formatDefaultValue($default)
280280
return 'INF';
281281
}
282282

283-
if (is_string($default)) {
283+
if (\is_string($default)) {
284284
$default = OutputFormatter::escape($default);
285-
} elseif (is_array($default)) {
285+
} elseif (\is_array($default)) {
286286
foreach ($default as $key => $value) {
287-
if (is_string($value)) {
287+
if (\is_string($value)) {
288288
$default[$key] = OutputFormatter::escape($value);
289289
}
290290
}

Descriptor/XmlDescriptor.php

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

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

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

241241
if (!empty($defaults)) {

Event/ConsoleErrorEvent.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function getError()
5151
public function setError($error)
5252
{
5353
if (!$error instanceof \Throwable && !$error instanceof \Exception) {
54-
throw new InvalidArgumentException(sprintf('The error passed to ConsoleErrorEvent must be an instance of \Throwable or \Exception, "%s" was passed instead.', is_object($error) ? get_class($error) : gettype($error)));
54+
throw new InvalidArgumentException(sprintf('The error passed to ConsoleErrorEvent must be an instance of \Throwable or \Exception, "%s" was passed instead.', \is_object($error) ? \get_class($error) : \gettype($error)));
5555
}
5656

5757
$this->error = $error;
@@ -78,6 +78,6 @@ public function setExitCode($exitCode)
7878
*/
7979
public function getExitCode()
8080
{
81-
return null !== $this->exitCode ? $this->exitCode : (is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1);
81+
return null !== $this->exitCode ? $this->exitCode : (\is_int($this->error->getCode()) && 0 !== $this->error->getCode() ? $this->error->getCode() : 1);
8282
}
8383
}

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]) {
@@ -237,6 +237,6 @@ private function createStyleFromString($string)
237237
*/
238238
private function applyCurrentStyle($text)
239239
{
240-
return $this->isDecorated() && strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
240+
return $this->isDecorated() && \strlen($text) > 0 ? $this->styleStack->getCurrent()->apply($text) : $text;
241241
}
242242
}

0 commit comments

Comments
 (0)