Skip to content

Commit 766ac3e

Browse files
Fix some issues found by phpstan
1 parent 2fe8383 commit 766ac3e

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ parameters:
55
ignoreErrors:
66
- '#Call to an undefined method SebastianFeldmann\\Ftp\\Client::delete\(\)#'
77
- '#Call to an undefined method ObjectStorage_Abstract::setLocalFile\(\)#'
8+
- '#Parameter \#1 \$buffer \(array\) of method phpbu\\App\\Log\\Json::write\(\) should be compatible with parameter \$buffer \(string\) of method phpbu\\App\\Log\\File::write\(\)#'

src/Cmd.php

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@
3535
use phpbu\App\Cmd\Args;
3636
use phpbu\App\Configuration\Bootstrapper;
3737
use phpbu\App\Util\Arr;
38+
use function fgets;
39+
use function file_put_contents;
40+
use function getcwd;
41+
use function sprintf;
42+
use function trim;
43+
use const PHP_EOL;
44+
use const STDIN;
3845

3946
/**
4047
* Main application class.
@@ -46,7 +53,7 @@
4653
* @link https://phpbu.de/
4754
* @since Class available since Release 1.0.0
4855
*/
49-
class Cmd
56+
final class Cmd
5057
{
5158
const EXIT_SUCCESS = 0;
5259
const EXIT_FAILURE = 1;
@@ -193,16 +200,16 @@ protected function createConfiguration(string $configurationFile, Factory $facto
193200
$configLoader = Configuration\Loader\Factory::createLoader($configurationFile, $bootstrapper);
194201

195202
if ($configLoader->hasValidationErrors()) {
196-
echo " Warning - The configuration file did not pass validation!" . \PHP_EOL .
197-
" The following problems have been detected:" . \PHP_EOL;
203+
echo " Warning - The configuration file did not pass validation!" . PHP_EOL .
204+
" The following problems have been detected:" . PHP_EOL;
198205

199206
foreach ($configLoader->getValidationErrors() as $line => $errors) {
200-
echo \sprintf("\n Line %d:\n", $line);
207+
echo sprintf("\n Line %d:\n", $line);
201208
foreach ($errors as $msg) {
202-
echo \sprintf(" - %s\n", $msg);
209+
echo sprintf(" - %s\n", $msg);
203210
}
204211
}
205-
echo \PHP_EOL;
212+
echo PHP_EOL;
206213
}
207214

208215
$configuration = $configLoader->getConfiguration($factory);
@@ -315,22 +322,22 @@ private function handleConfigGeneration() : void
315322
$this->printVersionString();
316323

317324
print 'Configuration file format: xml|json (default: xml): ';
318-
$format = \trim(\fgets(\STDIN)) === 'json' ? 'json' : 'xml';
325+
$format = trim(fgets(STDIN)) === 'json' ? 'json' : 'xml';
319326
$file = 'phpbu.' . $format;
320327

321328
if (file_exists($file)) {
322-
echo ' FAILED: The configuration file already exists.' . \PHP_EOL;
329+
echo ' FAILED: The configuration file already exists.' . PHP_EOL;
323330
exit(self::EXIT_EXCEPTION);
324331
}
325332

326-
print \PHP_EOL . 'Generating ' . $file . ' in ' . \getcwd() . \PHP_EOL . \PHP_EOL;
333+
print PHP_EOL . 'Generating ' . $file . ' in ' . getcwd() . PHP_EOL . PHP_EOL;
327334

328335
print 'Bootstrap script (relative to path shown above; e.g: vendor/autoload.php): ';
329-
$bootstrapScript = \trim(\fgets(\STDIN));
336+
$bootstrapScript = trim(fgets(STDIN));
330337

331338
$generator = new Configuration\Generator;
332339

333-
\file_put_contents(
340+
file_put_contents(
334341
$file,
335342
$generator->generateConfigurationSkeleton(
336343
Version::minor(),
@@ -339,9 +346,9 @@ private function handleConfigGeneration() : void
339346
)
340347
);
341348

342-
print \PHP_EOL . 'Generated ' . $file . ' in ' . \getcwd() . \PHP_EOL . \PHP_EOL .
343-
'ATTENTION:' . \PHP_EOL .
344-
'The created configuration is just a skeleton. You have to finish the configuration manually.' . \PHP_EOL;
349+
print PHP_EOL . 'Generated ' . $file . ' in ' . getcwd() . PHP_EOL . PHP_EOL .
350+
'ATTENTION:' . PHP_EOL .
351+
'The created configuration is just a skeleton. You have to finish the configuration manually.' . PHP_EOL;
345352
}
346353

347354
/**

0 commit comments

Comments
 (0)