mirror of
https://github.com/laravel/valet.git
synced 2026-02-07 09:10:03 +01:00
Add type hints and return type hints to Diagnose
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Valet;
|
namespace Valet;
|
||||||
|
|
||||||
|
use Illuminate\Support\Collection;
|
||||||
use Symfony\Component\Console\Helper\ProgressBar;
|
use Symfony\Component\Console\Helper\ProgressBar;
|
||||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||||
|
|
||||||
@@ -70,8 +71,12 @@ public function __construct(CommandLine $cli, Filesystem $files)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Run diagnostics.
|
* Run diagnostics.
|
||||||
|
*
|
||||||
|
* @param boolean $print
|
||||||
|
* @param boolean $plainText
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function run($print, $plainText)
|
public function run(bool $print, bool $plainText): void
|
||||||
{
|
{
|
||||||
$this->print = $print;
|
$this->print = $print;
|
||||||
|
|
||||||
@@ -102,7 +107,7 @@ public function run($print, $plainText)
|
|||||||
$this->afterRun();
|
$this->afterRun();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function beforeRun()
|
public function beforeRun(): void
|
||||||
{
|
{
|
||||||
if ($this->print) {
|
if ($this->print) {
|
||||||
return;
|
return;
|
||||||
@@ -113,7 +118,7 @@ public function beforeRun()
|
|||||||
$this->progressBar->start();
|
$this->progressBar->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function afterRun()
|
public function afterRun(): void
|
||||||
{
|
{
|
||||||
if ($this->progressBar) {
|
if ($this->progressBar) {
|
||||||
$this->progressBar->finish();
|
$this->progressBar->finish();
|
||||||
@@ -122,21 +127,21 @@ public function afterRun()
|
|||||||
output('');
|
output('');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function runCommand($command)
|
public function runCommand(string $command): string
|
||||||
{
|
{
|
||||||
return strpos($command, 'sudo ') === 0
|
return strpos($command, 'sudo ') === 0
|
||||||
? $this->cli->run($command)
|
? $this->cli->run($command)
|
||||||
: $this->cli->runAsUser($command);
|
: $this->cli->runAsUser($command);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function beforeCommand($command)
|
public function beforeCommand(string $command): void
|
||||||
{
|
{
|
||||||
if ($this->print) {
|
if ($this->print) {
|
||||||
info(PHP_EOL."$ $command");
|
info(PHP_EOL."$ $command");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function afterCommand($command, $output)
|
public function afterCommand(string $command, string $output): void
|
||||||
{
|
{
|
||||||
if ($this->print) {
|
if ($this->print) {
|
||||||
output(trim($output));
|
output(trim($output));
|
||||||
@@ -145,12 +150,12 @@ public function afterCommand($command, $output)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function ignoreOutput($command)
|
public function ignoreOutput(string $command): bool
|
||||||
{
|
{
|
||||||
return strpos($command, '> /dev/null 2>&1') !== false;
|
return strpos($command, '> /dev/null 2>&1') !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function format($results, $plainText)
|
public function format(Collection $results, bool $plainText): string
|
||||||
{
|
{
|
||||||
return $results->map(function ($result) use ($plainText) {
|
return $results->map(function ($result) use ($plainText) {
|
||||||
$command = $result['command'];
|
$command = $result['command'];
|
||||||
|
|||||||
Reference in New Issue
Block a user