mirror of
https://github.com/laravel/valet.git
synced 2026-02-06 16:50:09 +01:00
Add type hints and return type hints to CommandLine
This commit is contained in:
@@ -12,7 +12,7 @@ class CommandLine
|
|||||||
* @param string $command
|
* @param string $command
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function quietly($command)
|
public function quietly(string $command): void
|
||||||
{
|
{
|
||||||
$this->runCommand($command.' > /dev/null 2>&1');
|
$this->runCommand($command.' > /dev/null 2>&1');
|
||||||
}
|
}
|
||||||
@@ -23,7 +23,7 @@ public function quietly($command)
|
|||||||
* @param string $command
|
* @param string $command
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function quietlyAsUser($command)
|
public function quietlyAsUser(string $command): void
|
||||||
{
|
{
|
||||||
$this->quietly('sudo -u "'.user().'" '.$command.' > /dev/null 2>&1');
|
$this->quietly('sudo -u "'.user().'" '.$command.' > /dev/null 2>&1');
|
||||||
}
|
}
|
||||||
@@ -34,7 +34,7 @@ public function quietlyAsUser($command)
|
|||||||
* @param string $command
|
* @param string $command
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function passthru($command)
|
public function passthru(string $command): void
|
||||||
{
|
{
|
||||||
passthru($command);
|
passthru($command);
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ public function passthru($command)
|
|||||||
* @param callable $onError
|
* @param callable $onError
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function run($command, callable $onError = null)
|
public function run(string $command, callable $onError = null): string
|
||||||
{
|
{
|
||||||
return $this->runCommand($command, $onError);
|
return $this->runCommand($command, $onError);
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ public function run($command, callable $onError = null)
|
|||||||
* @param callable $onError
|
* @param callable $onError
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function runAsUser($command, callable $onError = null)
|
public function runAsUser(string $command, callable $onError = null): string
|
||||||
{
|
{
|
||||||
return $this->runCommand('sudo -u "'.user().'" '.$command, $onError);
|
return $this->runCommand('sudo -u "'.user().'" '.$command, $onError);
|
||||||
}
|
}
|
||||||
@@ -70,7 +70,7 @@ public function runAsUser($command, callable $onError = null)
|
|||||||
* @param callable $onError
|
* @param callable $onError
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function runCommand($command, callable $onError = null)
|
public function runCommand(string $command, callable $onError = null): string
|
||||||
{
|
{
|
||||||
$onError = $onError ?: function () {
|
$onError = $onError ?: function () {
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -953,15 +953,17 @@ public function test_it_can_read_php_rc_version()
|
|||||||
|
|
||||||
class CommandLineFake extends CommandLine
|
class CommandLineFake extends CommandLine
|
||||||
{
|
{
|
||||||
public function runCommand($command, callable $onError = null)
|
public function runCommand(string $command, callable $onError = null): string
|
||||||
{
|
{
|
||||||
// noop
|
// noop
|
||||||
//
|
//
|
||||||
// This let's us pretend like every command executes correctly
|
// This lets us pretend like every command executes correctly
|
||||||
// so we can (elsewhere) ensure the things we meant to do
|
// so we can (elsewhere) ensure the things we meant to do
|
||||||
// (like "create a certificate") look like they
|
// (like "create a certificate") look like they
|
||||||
// happened without actually running any
|
// happened without actually running any
|
||||||
// commands for real.
|
// commands for real.
|
||||||
|
|
||||||
|
return 'hooray!';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user