Skip to content

Commit 529903a

Browse files
committed
Merge pull request #20 from EmanueleMinotto/scrutinizer
part of scrutinizer fixes
2 parents 56dfb85 + c9af30e commit 529903a

10 files changed

+43
-35
lines changed

src/Handler/BindCommandHandler.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function handleList(Args $args, IO $io)
103103

104104
if ($printPackageName) {
105105
$prefix = $printBindingState ? ' ' : '';
106-
$io->writeLine("{$prefix}Package: $packageName");
106+
$io->writeLine(sprintf('%sPackage: %s', $prefix, $packageName));
107107
$io->writeLine('');
108108
}
109109

@@ -327,14 +327,19 @@ private function printBindingTable(IO $io, array $descriptors, $indentation = 0,
327327
$uuid = substr($descriptor->getUuid(), 0, 6);
328328

329329
if (!$enabled) {
330-
$uuid = "<bad>$uuid</bad>";
330+
$uuid = sprintf('<bad>%s</bad>', $uuid);
331331
}
332332

333333
$paramString = '';
334334

335335
if (!empty($parameters)) {
336336
// \xc2\xa0 is a non-breaking space
337-
$paramString = " <$paramTag>(".implode(",\xc2\xa0", $parameters).")</$paramTag>";
337+
$paramString = sprintf(
338+
' <%s>(%s)</%s>',
339+
$paramTag,
340+
implode(",\xc2\xa0", $parameters),
341+
$paramTag
342+
);
338343
}
339344

340345
if ($binding instanceof ResourceBinding) {
@@ -349,8 +354,8 @@ private function printBindingTable(IO $io, array $descriptors, $indentation = 0,
349354

350355
$table->addRow(array(
351356
$uuid,
352-
"<$artifactTag>$artifact</$artifactTag>",
353-
"<$typeTag>$typeString</$typeTag>".$paramString,
357+
sprintf('<%s>%s</%s>', $artifactTag, $artifact, $artifactTag),
358+
sprintf('<%s>%s</%s>%s', $typeTag, $typeString, $typeTag, $paramString),
354359
));
355360
}
356361

src/Handler/CatCommandHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function handle(Args $args, IO $io)
6161
$resources = $this->repo->find($path);
6262

6363
if (!count($resources)) {
64-
$io->errorLine("No resources found for path $path");
64+
$io->errorLine(sprintf('No resources found for path %s', $path));
6565

6666
return 1;
6767
}

src/Handler/ConfigCommandHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function handleList(Args $args, IO $io)
6161

6262
foreach ($effectiveValues as $key => $value) {
6363
$table->addRow(array(
64-
"<c1>$key</c1>",
64+
sprintf('<c1>%s</c1>', $key),
6565
array_key_exists($key, $userValues)
6666
? StringUtil::formatValue($userValues[$key], false)
6767
: '',

src/Handler/FindCommandHandler.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public function handle(Args $args, IO $io)
8787
$criteria['bindingType'] = $args->getOption('type');
8888
}
8989

90-
if (!$criteria) {
90+
if (empty($criteria)) {
9191
throw new RuntimeException('No search criteria specified.');
9292
}
9393

@@ -190,7 +190,7 @@ private function printTable(IO $io, array $matches)
190190
$table = new Table(TableStyle::borderless());
191191

192192
foreach ($matches as $path => $shortClass) {
193-
$table->addRow(array($shortClass, "<c1>$path</c1>"));
193+
$table->addRow(array($shortClass, sprintf('<c1>%s</c1>', $path)));
194194
}
195195

196196
$table->render($io);

src/Handler/InstallerCommandHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public function handleList(Args $args, IO $io)
6363

6464
$description = $descriptor->getDescription();
6565

66-
if ($parameters) {
66+
if (!empty($parameters)) {
6767
// non-breaking space
6868
$description .= ' <c1>('.implode(",\xc2\xa0", $parameters).')</c1>';
6969
}

src/Handler/LsCommandHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private function listLong(IO $io, ResourceCollection $resources)
157157
*
158158
* @param PuliResource $resource The resource.
159159
*
160-
* @return string The formatted name.
160+
* @return string|null The formatted name.
161161
*/
162162
private function formatName(PuliResource $resource)
163163
{

src/Handler/MapCommandHandler.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ public function handleList(Args $args, IO $io)
128128

129129
if ($printPackageName) {
130130
$prefix = $printState ? ' ' : '';
131-
$io->writeLine("{$prefix}Package: $packageName");
131+
$io->writeLine(sprintf('%sPackage: %s', $prefix, $packageName));
132132
$io->writeLine('');
133133
}
134134

@@ -270,7 +270,7 @@ private function printMappingTable(IO $io, array $mappings, $indentation = 0, $e
270270
}
271271

272272
$table->addRow(array(
273-
"<$pathTag>{$mapping->getRepositoryPath()}</$pathTag>",
273+
sprintf('<%s>%s</%s>', $pathTag, $mapping->getRepositoryPath(), $pathTag),
274274
$pathReferences,
275275
));
276276
}
@@ -305,7 +305,7 @@ private function printConflictTable(IO $io, array $mappings, $indentation = 0)
305305
$io->writeLine('');
306306
}
307307

308-
$io->writeLine("{$shortPrefix}Conflicting path: {$conflict->getRepositoryPath()}");
308+
$io->writeLine(sprintf('%sConflicting path: %s', $shortPrefix, $conflict->getRepositoryPath()));
309309
$io->writeLine('');
310310

311311
$table = new Table(PuliTableStyle::borderless());
@@ -320,7 +320,7 @@ private function printConflictTable(IO $io, array $mappings, $indentation = 0)
320320
));
321321
}
322322

323-
$io->writeLine("{$prefix}Mapped by the following mappings:");
323+
$io->writeLine(sprintf('%sMapped by the following mappings:', $prefix));
324324
$io->writeLine('');
325325

326326
$table->render($io, $indentation + 4);

src/Handler/PackageCommandHandler.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -312,11 +312,11 @@ private function printPackageState(IO $io, $packageState)
312312
/**
313313
* Prints a list of packages in a table.
314314
*
315-
* @param IO $io The I/O.
316-
* @param Package[] $packages The packages.
317-
* @param string $styleTag The tag used to style the output. If `null`,
318-
* the default colors are used.
319-
* @param bool $indent Whether to indent the output.
315+
* @param IO $io The I/O.
316+
* @param Package[] $packages The packages.
317+
* @param string|null $styleTag The tag used to style the output. If `null`,
318+
* the default colors are used.
319+
* @param bool $indent Whether to indent the output.
320320
*/
321321
private function printPackageTable(IO $io, array $packages, $styleTag = null, $indent = false)
322322
{
@@ -337,10 +337,10 @@ private function printPackageTable(IO $io, array $packages, $styleTag = null, $i
337337
$env = $installInfo ? $installInfo->getEnvironment() : Environment::PROD;
338338

339339
$table->addRow(array(
340-
$styleTag ? "<$styleTag>$packageName</$styleTag>" : $packageName,
341-
$installer ? "<$installerTag>$installer</$installerTag>" : '',
342-
"<$envTag>$env</$envTag>",
343-
"<$pathTag>$installPath</$pathTag>",
340+
$styleTag ? sprintf('<%s>%s</%s>', $styleTag, $packageName, $styleTag) : $packageName,
341+
$installer ? sprintf('<%s>%s</%s>', $installerTag, $installer, $installerTag) : '',
342+
sprintf('<%s>%s</%s>', $envTag, $env, $envTag),
343+
sprintf('<%s>%s</%s>', $pathTag, $installPath, $pathTag),
344344
));
345345
}
346346

@@ -380,7 +380,10 @@ private function printNotLoadablePackages(IO $io, array $packages, $indent = fal
380380
// Remove root directory
381381
$errorMessage = str_replace($rootDir.'/', '', $errorMessage);
382382

383-
$table->addRow(array("<bad>$packageName</bad>", "<bad>$errorMessage</bad>"));
383+
$table->addRow(array(
384+
sprintf('<bad>%s</bad>', $packageName),
385+
sprintf('<bad>%s</bad>', $errorMessage),
386+
));
384387
}
385388

386389
$table->render($io, $indent ? 4 : 0);

src/Handler/PluginCommandHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function handleList(Args $args, IO $io)
5959
}
6060

6161
foreach ($pluginClasses as $pluginClass) {
62-
$io->writeLine("<c1>$pluginClass</c1>");
62+
$io->writeLine(sprintf('<c1>%s</c1>', $pluginClass));
6363
}
6464

6565
return 0;

src/Handler/PublishCommandHandler.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public function handleList(Args $args, IO $io)
8585
$mappingsByServer[$serverName][] = $mapping;
8686
}
8787

88-
if (!$mappingsByServer) {
88+
if (empty($mappingsByServer)) {
8989
$io->writeLine('No public resources. Use "puli publish <path> <server>" to publish resources.');
9090

9191
return 0;
@@ -98,10 +98,10 @@ public function handleList(Args $args, IO $io)
9898
foreach ($servers as $serverName => $server) {
9999
$serverTitle = 'Server <bu>'.$serverName.'</bu>';
100100

101-
$io->writeLine(" <b>$serverTitle</b>");
102-
$io->writeLine(" Location: <c2>{$server->getDocumentRoot()}</c2>");
103-
$io->writeLine(" Installer: {$server->getInstallerName()}");
104-
$io->writeLine(" URL Format: <c1>{$server->getUrlFormat()}</c1>");
101+
$io->writeLine(sprintf(' <b>%s</b>', $serverTitle));
102+
$io->writeLine(sprintf(' Location: <c2>%s</c2>', $server->getDocumentRoot()));
103+
$io->writeLine(sprintf(' Installer: %s', $server->getInstallerName()));
104+
$io->writeLine(sprintf(' URL Format: <c1>%s</c1>', $server->getUrlFormat()));
105105
$io->writeLine('');
106106

107107
$this->printMappingTable($io, $mappingsByServer[$serverName]);
@@ -120,7 +120,7 @@ public function handleList(Args $args, IO $io)
120120
$io->writeLine('');
121121

122122
foreach ($nonExistingServers as $serverName => $_) {
123-
$io->writeLine(" <b>Server <bu>$serverName</bu></b>");
123+
$io->writeLine(sprintf(' <b>Server <bu>%s</bu></b>', $serverName));
124124
$io->writeLine('');
125125

126126
$this->printMappingTable($io, $mappingsByServer[$serverName], false);
@@ -248,13 +248,13 @@ private function printMappingTable(IO $io, array $mappings, $enabled = true)
248248
$serverPath = $mapping->getServerPath();
249249

250250
if (!$enabled) {
251-
$uuid = "<bad>$uuid</bad>";
251+
$uuid = sprintf('<bad>%s</bad>', $uuid);
252252
}
253253

254254
$table->addRow(array(
255255
$uuid,
256-
"<$globTag>$glob</$globTag>",
257-
"<$pathTag>$serverPath</$pathTag>",
256+
sprintf('<%s>%s</%s>', $globTag, $glob, $globTag),
257+
sprintf('<%s>%s</%s>', $pathTag, $serverPath, $pathTag),
258258
));
259259
}
260260

0 commit comments

Comments
 (0)