Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell committed Apr 23, 2024
1 parent 0b917f2 commit c8b517f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Command/Remote/DrushCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function execute(InputInterface $input, OutputInterface $output): ?int
// When available, provide the default domain to drush.
if (!empty($environment->default_domain)) {
// Insert at the beginning so a user-supplied --uri arg will override.
array_unshift($drushArguments, "--uri=http://{$environment->default_domain}");
array_unshift($drushArguments, "--uri=http://$environment->default_domain");
}
$drushCommandArguments = [
"cd /var/www/html/$alias/docroot; ",
Expand Down
20 changes: 9 additions & 11 deletions src/Helpers/LocalMachineHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class LocalMachineHelper {
private SymfonyStyle $io;

public function __construct(
private InputInterface $input,
private OutputInterface $output,
private readonly InputInterface $input,
private readonly OutputInterface $output,
LoggerInterface $logger
) {
$this->setLogger($logger);
Expand All @@ -48,12 +48,10 @@ public function __construct(
*
* This won't find aliases or shell built-ins, so use it mindfully (e.g. only
* for commands that you _know_ to be system commands).
*
* @param $command
*/
public function commandExists(mixed $command): bool {
public function commandExists(string $command): bool {
if (array_key_exists($command, $this->installedBinaries)) {
return (bool) $this->installedBinaries[$command];
return $this->installedBinaries[$command];
}
$osCommand = OsInfo::isWindows() ? ['where', $command] : ['which', $command];
$exists = $this->execute($osCommand, NULL, NULL, FALSE, NULL, NULL, FALSE)->isSuccessful();
Expand Down Expand Up @@ -104,7 +102,7 @@ public function executeFromCmd(string $cmd, callable $callback = NULL, string $c
* @param array|null $env
*/
private function configureProcess(Process $process, string $cwd = NULL, ?bool $printOutput = TRUE, float $timeout = NULL, array $env = NULL, bool $stdin = TRUE): Process {
if (function_exists('posix_isatty') && !@posix_isatty(STDIN) && $stdin) {
if (function_exists('posix_isatty') && $stdin && !@posix_isatty(STDIN)) {
$process->setInput(STDIN);
}
if ($cwd) {
Expand Down Expand Up @@ -251,7 +249,7 @@ public static function getConfigDir(): string {
* This method assumes you are running `acli` in a directory containing a
* Drupal docroot either as a sibling or parent(N) of the working directory.
*
* Typically the root directory would also be a Git repository root, though it
* Typically, the root directory would also be a Git repository root, though it
* doesn't have to be (such as for brand-new projects that haven't initialized
* Git yet).
*/
Expand Down Expand Up @@ -344,9 +342,9 @@ public function startBrowser(string $uri = NULL, string $browser = NULL): bool {

// Validate that the host part of the URL resolves, so we don't attempt to
// open the browser for http://default or similar invalid hosts.
$hosterror = (gethostbynamel($host) === FALSE);
$iperror = (ip2long($host) && gethostbyaddr($host) == $host);
if ($hosterror || $iperror) {
$hostError = (gethostbynamel($host) === FALSE);
$ipError = (ip2long($host) && gethostbyaddr($host) === $host);
if ($hostError || $ipError) {
$this->logger->warning(
'!host does not appear to be a resolvable hostname or IP, not starting browser.',
['!host' => $host]
Expand Down
6 changes: 3 additions & 3 deletions src/Helpers/SshHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ class SshHelper implements LoggerAwareInterface {
* SshHelper constructor.
*/
public function __construct(
private OutputInterface $output,
private LocalMachineHelper $localMachineHelper,
private readonly OutputInterface $output,
private readonly LocalMachineHelper $localMachineHelper,
LoggerInterface $logger
) {
$this->setLogger($logger);
Expand Down Expand Up @@ -70,7 +70,7 @@ private function firstArguments(array $commandArgs): string {
$result = '';
while (!empty($commandArgs)) {
$first = array_shift($commandArgs);
if ($first != '' && $first[0] == '-') {
if ($first !== '' && $first[0] === '-') {
return $result;
}
$result .= " $first";
Expand Down

0 comments on commit c8b517f

Please sign in to comment.