Skip to content

Commit

Permalink
chore: Apply code style fixes for php 8.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Huber committed Dec 8, 2024
1 parent 03268c5 commit 7494d2c
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/Command/BaseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function runCommand(
array $args,
InputInterface $original_input,
OutputInterface $output,
TaskContextInterface $context_to_pass = null
?TaskContextInterface $context_to_pass = null
) {
$cmd = $this->getApplication()->find($command);

Expand Down Expand Up @@ -257,7 +257,7 @@ protected function startInteractiveShell(
TaskContextInterface $context,
ShellProviderInterface $shell,
array $command = [],
ShellOptions $options = null
?ShellOptions $options = null
) {
$fn = function ($type, $buffer) use ($context) {
if ($type == Process::ERR) {
Expand Down
6 changes: 4 additions & 2 deletions src/Command/StartRemoteAccessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
class StartRemoteAccessCommand extends BaseCommand
{

protected function configure(): void {
protected function configure(): void
{
$host= gethostname();
$ip = false;

Expand Down Expand Up @@ -104,7 +105,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return $this->getContext()->getResult('exitCode', 0);
}

private function getSchemeFromPort($port): string {
private function getSchemeFromPort($port): string
{
$mapping = [
'80' => 'http',
'443' => 'https',
Expand Down
2 changes: 1 addition & 1 deletion src/Method/Callbacks/WebHookCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function requires(): string
return "3.6";
}

public function __construct(WebhookMethod $method = null)
public function __construct(?WebhookMethod $method = null)
{
$this->method = $method;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Scaffolder/Scaffolder.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function scaffold(
$root_folder,
TaskContextInterface $in_context,
array $tokens = [],
Options $options = null
?Options $options = null
) {
if (!$options) {
$options = new Options();
Expand Down
2 changes: 1 addition & 1 deletion src/ShellProvider/DryRunShellProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function getShellCommand(array $program_to_call, ShellOptions $options):
throw new \RuntimeException("getShellCommand not implemented!");
}

public function createShellProcess(array $command = [], ShellOptions $options = null): Process
public function createShellProcess(array $command = [], ?ShellOptions $options = null): Process
{
throw new \RuntimeException("createShellProcess not implemented!");
}
Expand Down
2 changes: 1 addition & 1 deletion src/ShellProvider/KubectlShellProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function validateConfig(Node $config, ValidationErrorBagInterface $errors
}
}

public function createShellProcess(array $command = [], ShellOptions $options = null): Process
public function createShellProcess(array $command = [], ?ShellOptions $options = null): Process
{
// Apply kubectl environment vars.
$this->setShellEnvironmentVars($this->hostConfig['kube']['environment']);
Expand Down
2 changes: 1 addition & 1 deletion src/ShellProvider/LocalShellProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public function validateConfig(Node $config, ValidationErrorBagInterface $errors
);
}

public function createShellProcess(array $command = [], ShellOptions $options = null): Process
public function createShellProcess(array $command = [], ?ShellOptions $options = null): Process
{
if (!$options) {
$options = new ShellOptions();
Expand Down
10 changes: 6 additions & 4 deletions src/ShellProvider/RunOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

namespace Phabalicious\ShellProvider;

enum RunOptions {
enum RunOptions
{
case NONE;
case CAPTURE_OUTPUT;
case HIDE_OUTPUT;
case CAPTURE_AND_HIDE_OUTPUT;

public function isCapturingOutput(): bool {
public function isCapturingOutput(): bool
{
return $this === self::CAPTURE_OUTPUT || $this === self::CAPTURE_AND_HIDE_OUTPUT;
}

public function hideOutput(): bool {
public function hideOutput(): bool
{
return $this === self::HIDE_OUTPUT || $this === self::CAPTURE_AND_HIDE_OUTPUT;
}

}
3 changes: 2 additions & 1 deletion src/ShellProvider/ShellOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public function setQuiet(bool $quiet): ShellOptions
return $this;
}

public function isShellExecutableProvided(): bool {
public function isShellExecutableProvided(): bool
{
return $this->shellExecutableProvided;
}

Expand Down
2 changes: 1 addition & 1 deletion src/ShellProvider/ShellProviderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function runProcess(array $cmd, TaskContextInterface $context, $interacti

public function getShellCommand(array $program_to_call, ShellOptions $options): array;

public function createShellProcess(array $command = [], ShellOptions $options = null): Process;
public function createShellProcess(array $command = [], ?ShellOptions $options = null): Process;

public function createTunnelProcess(HostConfig $target_config, array $prefix = []): Process;

Expand Down
5 changes: 3 additions & 2 deletions src/ShellProvider/SubShellProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function getShellCommand(array $program_to_call, ShellOptions $options):
throw new \LogicException("getShellCommand not implemented");
}

public function createShellProcess(array $command = [], ShellOptions $options = null): Process
public function createShellProcess(array $command = [], ?ShellOptions $options = null): Process
{
throw new \LogicException("createShellProcess not implemented");
}
Expand All @@ -85,7 +85,8 @@ public function wrapCommandInLoginShell(array $command): array
throw new \LogicException("wrapCommandInLoginShell not implemented");
}

public function terminate(): void {
public function terminate(): void
{
$this->parentShell->terminate();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public function createHostToHostTunnel(
HostConfig $source_config,
HostConfig $dest_config,
TaskContextInterface $context,
TunnelDataInterface $tunnel_data = null
?TunnelDataInterface $tunnel_data = null
): TunnelDataInterface;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ interface LocalToHostTunnelInterface
public function createLocalToHostTunnel(
HostConfig $config,
TaskContextInterface $context,
TunnelDataInterface $tunnel_data = null
?TunnelDataInterface $tunnel_data = null
): TunnelDataInterface;
}
6 changes: 3 additions & 3 deletions src/ShellProvider/TunnelHelper/SshTunnelHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class SshTunnelHelper extends TunnelHelperBase implements HostToHostTunnelInterf
public function createLocalToHostTunnel(
HostConfig $config,
TaskContextInterface $context,
TunnelDataInterface $tunnel_data = null
?TunnelDataInterface $tunnel_data = null
): TunnelDataInterface {
return $this->createTunnel($config, $config, false, $context, $tunnel_data);
}
Expand All @@ -23,7 +23,7 @@ public function createHostToHostTunnel(
HostConfig $source_config,
HostConfig $target_config,
TaskContextInterface $context,
TunnelDataInterface $tunnel_data = null
?TunnelDataInterface $tunnel_data = null
): TunnelDataInterface {
return $this->createTunnel($source_config, $target_config, true, $context, $tunnel_data);
}
Expand All @@ -43,7 +43,7 @@ private function createTunnel(
HostConfig $target_config,
bool $remote,
TaskContextInterface $context,
TunnelDataInterface $tunnel_data = null
?TunnelDataInterface $tunnel_data = null
) {
$key = $source_config->getConfigName() . '->' . $target_config->getConfigName();
if ($remote) {
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/EnsureKnownHosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class EnsureKnownHosts
public static function ensureKnownHosts(
ConfigurationService $config,
array $known_hosts,
ShellProviderInterface $shell = null
?ShellProviderInterface $shell = null
) {
if (!$shell) {
$shell = ShellProviderFactory::create('local', $config->getLogger());
Expand Down
2 changes: 1 addition & 1 deletion src/Utilities/ParallelExecutorRun.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ParallelExecutorRun extends ProcessRun

protected $identifier;

public function __construct(string $identifier, $command_line, ConsoleSectionOutput $output = null)
public function __construct(string $identifier, $command_line, ?ConsoleSectionOutput $output = null)
{
$this->identifier = $identifier;
$this->output = $output;
Expand Down

0 comments on commit 7494d2c

Please sign in to comment.