Skip to content

Commit 691075a

Browse files
committed
Prefix all sprintf() calls
1 parent 14a66d3 commit 691075a

File tree

9 files changed

+73
-73
lines changed

9 files changed

+73
-73
lines changed

Command/LintCommand.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ protected function configure(): void
5454
{
5555
$this
5656
->addArgument('filename', InputArgument::IS_ARRAY, 'A file, a directory or "-" for reading from STDIN')
57-
->addOption('format', null, InputOption::VALUE_REQUIRED, sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())))
57+
->addOption('format', null, InputOption::VALUE_REQUIRED, \sprintf('The output format ("%s")', implode('", "', $this->getAvailableFormatOptions())))
5858
->addOption('exclude', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Path(s) to exclude')
5959
->addOption('parse-tags', null, InputOption::VALUE_NEGATABLE, 'Parse custom tags', null)
6060
->setHelp(<<<EOF
@@ -111,7 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
111111
$filesInfo = [];
112112
foreach ($filenames as $filename) {
113113
if (!$this->isReadable($filename)) {
114-
throw new RuntimeException(sprintf('File or directory "%s" is not readable.', $filename));
114+
throw new RuntimeException(\sprintf('File or directory "%s" is not readable.', $filename));
115115
}
116116

117117
foreach ($this->getFiles($filename) as $file) {
@@ -151,7 +151,7 @@ private function display(SymfonyStyle $io, array $files): int
151151
'txt' => $this->displayTxt($io, $files),
152152
'json' => $this->displayJson($io, $files),
153153
'github' => $this->displayTxt($io, $files, true),
154-
default => throw new InvalidArgumentException(sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
154+
default => throw new InvalidArgumentException(\sprintf('Supported formats are "%s".', implode('", "', $this->getAvailableFormatOptions()))),
155155
};
156156
}
157157

@@ -167,11 +167,11 @@ private function displayTxt(SymfonyStyle $io, array $filesInfo, bool $errorAsGit
167167

168168
foreach ($filesInfo as $info) {
169169
if ($info['valid'] && $this->displayCorrectFiles) {
170-
$io->comment('<info>OK</info>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
170+
$io->comment('<info>OK</info>'.($info['file'] ? \sprintf(' in %s', $info['file']) : ''));
171171
} elseif (!$info['valid']) {
172172
++$erroredFiles;
173-
$io->text('<error> ERROR </error>'.($info['file'] ? sprintf(' in %s', $info['file']) : ''));
174-
$io->text(sprintf('<error> >> %s</error>', $info['message']));
173+
$io->text('<error> ERROR </error>'.($info['file'] ? \sprintf(' in %s', $info['file']) : ''));
174+
$io->text(\sprintf('<error> >> %s</error>', $info['message']));
175175

176176
if (str_contains($info['message'], 'PARSE_CUSTOM_TAGS')) {
177177
$suggestTagOption = true;
@@ -184,9 +184,9 @@ private function displayTxt(SymfonyStyle $io, array $filesInfo, bool $errorAsGit
184184
}
185185

186186
if (0 === $erroredFiles) {
187-
$io->success(sprintf('All %d YAML files contain valid syntax.', $countFiles));
187+
$io->success(\sprintf('All %d YAML files contain valid syntax.', $countFiles));
188188
} else {
189-
$io->warning(sprintf('%d YAML files have valid syntax and %d contain errors.%s', $countFiles - $erroredFiles, $erroredFiles, $suggestTagOption ? ' Use the --parse-tags option if you want parse custom tags.' : ''));
189+
$io->warning(\sprintf('%d YAML files have valid syntax and %d contain errors.%s', $countFiles - $erroredFiles, $erroredFiles, $suggestTagOption ? ' Use the --parse-tags option if you want parse custom tags.' : ''));
190190
}
191191

192192
return min($erroredFiles, 1);

Dumper.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,28 +81,28 @@ public function dump(mixed $input, int $inline = 0, int $indent = 0, int $flags
8181
$blockChompingIndicator = '-';
8282
}
8383

84-
$output .= sprintf('%s%s%s |%s%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator, $blockChompingIndicator);
84+
$output .= \sprintf('%s%s%s |%s%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', '', $blockIndentationIndicator, $blockChompingIndicator);
8585

8686
foreach (explode("\n", $value) as $row) {
8787
if ('' === $row) {
8888
$output .= "\n";
8989
} else {
90-
$output .= sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
90+
$output .= \sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
9191
}
9292
}
9393

9494
continue;
9595
}
9696

9797
if ($value instanceof TaggedValue) {
98-
$output .= sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag());
98+
$output .= \sprintf('%s%s !%s', $prefix, $dumpAsMap ? Inline::dump($key, $flags).':' : '-', $value->getTag());
9999

100100
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) {
101101
$blockIndentationIndicator = $this->getBlockIndentationIndicator($value->getValue());
102-
$output .= sprintf(' |%s', $blockIndentationIndicator);
102+
$output .= \sprintf(' |%s', $blockIndentationIndicator);
103103

104104
foreach (explode("\n", $value->getValue()) as $row) {
105-
$output .= sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
105+
$output .= \sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
106106
}
107107

108108
continue;
@@ -126,7 +126,7 @@ public function dump(mixed $input, int $inline = 0, int $indent = 0, int $flags
126126

127127
$willBeInlined = $inline - 1 <= 0 || !\is_array($value) && $dumpObjectAsInlineMap || !$value;
128128

129-
$output .= sprintf('%s%s%s%s',
129+
$output .= \sprintf('%s%s%s%s',
130130
$prefix,
131131
$dumpAsMap ? Inline::dump($key, $flags).':' : '-',
132132
$willBeInlined ? ' ' : "\n",
@@ -140,14 +140,14 @@ public function dump(mixed $input, int $inline = 0, int $indent = 0, int $flags
140140

141141
private function dumpTaggedValue(TaggedValue $value, int $inline, int $indent, int $flags, string $prefix): string
142142
{
143-
$output = sprintf('%s!%s', $prefix ? $prefix.' ' : '', $value->getTag());
143+
$output = \sprintf('%s!%s', $prefix ? $prefix.' ' : '', $value->getTag());
144144

145145
if (Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK & $flags && \is_string($value->getValue()) && str_contains($value->getValue(), "\n") && !str_contains($value->getValue(), "\r\n")) {
146146
$blockIndentationIndicator = $this->getBlockIndentationIndicator($value->getValue());
147-
$output .= sprintf(' |%s', $blockIndentationIndicator);
147+
$output .= \sprintf(' |%s', $blockIndentationIndicator);
148148

149149
foreach (explode("\n", $value->getValue()) as $row) {
150-
$output .= sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
150+
$output .= \sprintf("\n%s%s%s", $prefix, str_repeat(' ', $this->indentation), $row);
151151
}
152152

153153
return $output;

Escaper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public static function requiresDoubleQuoting(string $value): bool
6262
*/
6363
public static function escapeWithDoubleQuotes(string $value): string
6464
{
65-
return sprintf('"%s"', str_replace(self::ESCAPEES, self::ESCAPED, $value));
65+
return \sprintf('"%s"', str_replace(self::ESCAPEES, self::ESCAPED, $value));
6666
}
6767

6868
/**
@@ -90,6 +90,6 @@ public static function requiresSingleQuoting(string $value): bool
9090
*/
9191
public static function escapeWithSingleQuotes(string $value): string
9292
{
93-
return sprintf("'%s'", str_replace('\'', '\'\'', $value));
93+
return \sprintf("'%s'", str_replace('\'', '\'\'', $value));
9494
}
9595
}

Exception/ParseException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ private function updateRepr(): void
103103
}
104104

105105
if (null !== $this->parsedFile) {
106-
$this->message .= sprintf(' in %s', json_encode($this->parsedFile, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
106+
$this->message .= \sprintf(' in %s', json_encode($this->parsedFile, \JSON_UNESCAPED_SLASHES | \JSON_UNESCAPED_UNICODE));
107107
}
108108

109109
if ($this->parsedLine >= 0) {
110-
$this->message .= sprintf(' at line %d', $this->parsedLine);
110+
$this->message .= \sprintf(' at line %d', $this->parsedLine);
111111
}
112112

113113
if ($this->snippet) {
114-
$this->message .= sprintf(' (near "%s")', $this->snippet);
114+
$this->message .= \sprintf(' (near "%s")', $this->snippet);
115115
}
116116

117117
if ($dot) {

0 commit comments

Comments
 (0)