Skip to content
This repository was archived by the owner on Sep 20, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 13 additions & 18 deletions Bin/Cs.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand All @@ -8,7 +10,7 @@
*
* New BSD License
*
* Copyright © 2007-2017, Hoa community. All rights reserved.
* Copyright © 2007-2018, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -43,16 +45,11 @@
* Class \Hoa\Devtools\Bin\Cs.
*
* Wrapper around `php-cs-fixer`.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Cs extends Console\Dispatcher\Kit
{
/**
* Options description.
*
* @var array
*/
protected $options = [
['dry-run', Console\GetOption::NO_ARGUMENT, 'd'],
Expand All @@ -66,10 +63,8 @@ class Cs extends Console\Dispatcher\Kit

/**
* The entry method.
*
* @return int
*/
public function main()
public function main(): int
{
$dryRun = false;
$diff = false;
Expand Down Expand Up @@ -100,14 +95,18 @@ public function main()
case 'h':
case '?':
default:
return $this->usage();
$this->usage();

return 0;
}
}

$this->parser->listInputs($path);

if (empty($path)) {
return $this->usage();
$this->usage();

return 0;
}

$phpCsFixer = Console\Processus::locate('php-cs-fixer');
Expand Down Expand Up @@ -141,22 +140,20 @@ public function main()
$processus->on('input', function () {
return false;
});
$processus->on('output', function (Event\Bucket $bucket) {
$processus->on('output', function (Event\Bucket $bucket): void {
echo $bucket->getData()['line'], "\n";

return;
});
$processus->run();

return;
return 0;
}

/**
* The command usage.
*
* @return int
*/
public function usage()
public function usage(): void
{
echo
'Usage : devtools:cs <options> path', "\n",
Expand All @@ -167,8 +164,6 @@ public function usage()
'v' => 'Be verbose.',
'help' => 'This help.'
]), "\n";

return;
}
}

Expand Down
29 changes: 12 additions & 17 deletions Bin/Dependency.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand All @@ -8,7 +10,7 @@
*
* New BSD License
*
* Copyright © 2007-2017, Hoa community. All rights reserved.
* Copyright © 2007-2018, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -42,16 +44,11 @@
* Class \Hoa\Devtools\Bin\Dependency.
*
* This command manipulates dependencies of a library.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Dependency extends Console\Dispatcher\Kit
{
/**
* Options description.
*
* @var array
*/
protected $options = [
['no-verbose', Console\GetOption::NO_ARGUMENT, 'V'],
Expand All @@ -65,10 +62,8 @@ class Dependency extends Console\Dispatcher\Kit

/**
* The entry method.
*
* @return int
*/
public function main()
public function main(): int
{
$verbose = Console::isDirect(STDOUT);
$print = 'both';
Expand All @@ -92,7 +87,9 @@ public function main()

case 'h':
case '?':
return $this->usage();
$this->usage();

return 0;

case '__ambiguous':
$this->resolveOptionAmbiguity($v);
Expand All @@ -104,7 +101,9 @@ public function main()
$this->parser->listInputs($library);

if (empty($library)) {
return $this->usage();
$this->usage();

return 0;
}

$library = ucfirst(strtolower($library));
Expand Down Expand Up @@ -151,15 +150,13 @@ public function main()
}
}

return;
return 0;
}

/**
* The command usage.
*
* @return int
*/
public function usage()
public function usage(): void
{
echo
'Usage : devtools:dependency <options> library', "\n",
Expand All @@ -171,8 +168,6 @@ public function usage()
'v' => 'Print only the version.',
'help' => 'This help.'
]), "\n";

return;
}
}

Expand Down
36 changes: 13 additions & 23 deletions Bin/Diagnostic.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

/**
* Hoa
*
Expand All @@ -8,7 +10,7 @@
*
* New BSD License
*
* Copyright © 2007-2017, Hoa community. All rights reserved.
* Copyright © 2007-2018, Hoa community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
Expand Down Expand Up @@ -42,16 +44,11 @@
* Class \Hoa\Devtools\Bin\Diagnostic.
*
* This command generates a diagnostic.
*
* @copyright Copyright © 2007-2017 Hoa community
* @license New BSD License
*/
class Diagnostic extends Console\Dispatcher\Kit
{
/**
* Options description.
*
* @var array
*/
protected $options = [
['section', Console\GetOption::REQUIRED_ARGUMENT, 's'],
Expand All @@ -64,10 +61,8 @@ class Diagnostic extends Console\Dispatcher\Kit

/**
* The entry method.
*
* @return int
*/
public function main()
public function main(): int
{
$sections = [];
$mail = null;
Expand All @@ -87,7 +82,9 @@ public function main()

case 'h':
case '?':
return $this->usage();
$this->usage();

return 0;

case '__ambiguous':
$this->resolveOptionAmbiguity($v);
Expand All @@ -96,7 +93,7 @@ public function main()
}
}

$store = function ($sections, $key, $value = null) use (&$diagnostic) {
$store = function ($sections, $key, $value = null) use (&$diagnostic): void {
if (is_array($key) && null === $value) {
foreach ($key as $i => $name) {
$diagnostic[$sections][$i] = $name;
Expand Down Expand Up @@ -131,7 +128,7 @@ public function main()
$store(
'system',
'lang',
isset($_SERVER['LANG']) ? $_SERVER['LANG'] : 'unknown'
$_SERVER['LANG'] ?? 'unknown'
);
$store(
'bin',
Expand Down Expand Up @@ -159,7 +156,7 @@ public function main()
$entry = 'extension-' . strtolower($extension);

if ('extension-standard' !== $entry &&
'extension-core' !== $entry) {
'extension-core' !== $entry) {
$entries = [];

foreach ($reflection->getINIEntries() as $key => $value) {
Expand Down Expand Up @@ -204,15 +201,13 @@ public function main()
return mail($mail, $subject, $ini) ? 0 : 1;
}

return;
return 0;
}

/**
* The command usage.
*
* @return int
*/
public function usage()
public function usage(): void
{
echo
'Usage : devtools:diagnostic <options>', "\n",
Expand All @@ -227,17 +222,12 @@ public function usage()
'm' => 'Email address where to send the diagnostic.',
'help' => 'This help.'
]), "\n";

return;
}

/**
* Transform an array into INI format.
*
* @param array $array Array to transform.
* @return string
*/
private function arrayToIni(array $array)
private function arrayToIni(array $array): ?string
{
$out = null;

Expand Down
Loading