Skip to content

Commit

Permalink
Add phpcs check with PSR12
Browse files Browse the repository at this point in the history
  • Loading branch information
mischabraam committed Jan 28, 2024
1 parent 11c29f7 commit 0256b8a
Show file tree
Hide file tree
Showing 23 changed files with 146 additions and 100 deletions.
10 changes: 6 additions & 4 deletions cli/ValetPlus/AbstractDockerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,21 @@
use Illuminate\Support\Collection;
use Valet\CommandLine;
use Valet\Filesystem;

use function Valet\info;
use function Valet\warning;

/**
* Docker container service. Please note that container names are restricted to the following characters [a-zA-Z0-9][a-zA-Z0-9_.-].
* Docker container service.
* Please note that container names are restricted to the following characters [a-zA-Z0-9][a-zA-Z0-9_.-].
* Obviously this has a dependency on the installation of Docker. For convenience install Docker Desktop.
*/
abstract class AbstractDockerService
{
/** @var string */
const DOCKER_COMPOSE_STUB = __DIR__ . '/../stubs/%s/%s/docker-compose.yml';
protected const DOCKER_COMPOSE_STUB = __DIR__ . '/../stubs/%s/%s/docker-compose.yml';
/** @var string */
const DOCKER_COMPOSE_PATH = VALET_HOME_PATH . '/Docker/%s/%s/docker-compose.yml';
protected const DOCKER_COMPOSE_PATH = VALET_HOME_PATH . '/Docker/%s/%s/docker-compose.yml';

/** @var CommandLine */
protected $cli;
Expand All @@ -35,7 +37,7 @@ abstract class AbstractDockerService
*/
public function __construct(
CommandLine $cli,
Filesystem $files
Filesystem $files
) {
$this->cli = $cli;
$this->files = $files;
Expand Down
5 changes: 3 additions & 2 deletions cli/ValetPlus/AbstractPhpExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Valet\Brew;
use Valet\PhpFpm;

use function Valet\info;
use function Valet\output;
use function Valet\warning;
Expand Down Expand Up @@ -33,8 +34,8 @@ abstract class AbstractPhpExtension
* @param PhpExtension $phpExtension
*/
public function __construct(
Brew $brew,
PhpFpm $phpFpm,
Brew $brew,
PhpFpm $phpFpm,
PhpExtension $phpExtension
) {
$this->brew = $brew;
Expand Down
6 changes: 3 additions & 3 deletions cli/ValetPlus/AbstractService.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ abstract class AbstractService
*/
public function __construct(
Configuration $configuration,
Brew $brew,
Filesystem $files,
CommandLine $cli
Brew $brew,
Filesystem $files,
CommandLine $cli
) {
$this->configuration = $configuration;
$this->brew = $brew;
Expand Down
14 changes: 10 additions & 4 deletions cli/ValetPlus/Binary.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Valet\Brew;
use Valet\CommandLine;
use Valet\Filesystem;

use function Valet\info;
use function Valet\warning;

Expand Down Expand Up @@ -68,9 +69,9 @@ class Binary
* @param Filesystem $files
*/
public function __construct(
Brew $brew,
Brew $brew,
CommandLine $cli,
Filesystem $files
Filesystem $files
) {
$this->brew = $brew;
$this->cli = $cli;
Expand Down Expand Up @@ -150,7 +151,10 @@ public function installBinary($binary)
// Check the checksum of downloaded file.
if (!$this->checkShasum($binary, $fileName)) {
$this->cli->runAsUser("rm /tmp/$fileName");
warning("Binary $binary could not be installed, $fileName checksum does not match: " . $this->getShasum($binary));
warning(
"Binary $binary could not be installed, $fileName checksum does not match: " .
$this->getShasum($binary)
);

return;
}
Expand Down Expand Up @@ -195,7 +199,9 @@ public function uninstallBinary($binary)
$binaryLocation = $this->getBinLocation($binary);
$this->cli->runAsUser('rm ' . $binaryLocation);
if ($this->files->exists($binaryLocation)) {
throw new DomainException('Could not remove binary! Please remove manually using: rm ' . $binaryLocation);
throw new DomainException(
'Could not remove binary! Please remove manually using: rm ' . $binaryLocation
);
}
info("Binary $binary successfully uninstalled!");
}
Expand Down
1 change: 1 addition & 0 deletions cli/ValetPlus/DriverConfigs/Magento2ValetDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace WeProvide\ValetPlus\DriverConfigs;

use WeProvide\ValetPlus\DriverConfigurator;

use function Valet\info;
use function Valet\output;

Expand Down
1 change: 1 addition & 0 deletions cli/ValetPlus/DriverConfigs/Shopware5ValetDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace WeProvide\ValetPlus\DriverConfigs;

use WeProvide\ValetPlus\DriverConfigurator;

use function Valet\info;
use function Valet\output;

Expand Down
8 changes: 4 additions & 4 deletions cli/ValetPlus/DriverConfigurator.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Valet\Drivers\ValetDriver;
use Valet\Filesystem;
use Valet\Site;

use function Valet\info;

class DriverConfigurator
Expand All @@ -29,9 +30,9 @@ class DriverConfigurator
*/
public function __construct(
CommandLine $cli,
Filesystem $files,
Site $site,
Redis $redis
Filesystem $files,
Site $site,
Redis $redis
) {
$this->cli = $cli;
$this->files = $files;
Expand Down Expand Up @@ -61,7 +62,6 @@ public function configure()

return $driver->configure();
} catch (\Throwable $throwable) {

}

info('No configuration settings found.');
Expand Down
17 changes: 11 additions & 6 deletions cli/ValetPlus/Elasticsearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
use Valet\Brew;
use Valet\CommandLine;
use Valet\Filesystem;

use function Valet\info;

class Elasticsearch extends AbstractDockerService
{
/** @var string */
const NGINX_CONFIGURATION_STUB = __DIR__ . '/../stubs/elasticsearch/elasticsearch.conf';
protected const NGINX_CONFIGURATION_STUB = __DIR__ . '/../stubs/elasticsearch/elasticsearch.conf';
/** @var string */
const NGINX_CONFIGURATION_PATH = VALET_HOME_PATH . '/Nginx/elasticsearch.conf';
protected const NGINX_CONFIGURATION_PATH = VALET_HOME_PATH . '/Nginx/elasticsearch.conf';

/** @var string */
protected const ES_DEFAULT_VERSION = 'opensearch'; // which is v2 in Brew, @todo; maybe support v1.2 using docker?
Expand All @@ -36,8 +37,8 @@ class Elasticsearch extends AbstractDockerService
*/
public function __construct(
CommandLine $cli,
Filesystem $files,
Brew $brew
Filesystem $files,
Brew $brew
) {
parent::__construct($cli, $files);

Expand Down Expand Up @@ -122,7 +123,10 @@ public function useVersion($version = self::ES_DEFAULT_VERSION, $tld = 'test')
{
if (!$this->isSupportedVersion($version)) {
throw new DomainException(
sprintf('Invalid Elasticsearch version given. Available versions: %s', implode(', ', static::ES_SUPPORTED_VERSIONS))
sprintf(
'Invalid Elasticsearch version given. Available versions: %s',
implode(', ', static::ES_SUPPORTED_VERSIONS)
)
);
}

Expand Down Expand Up @@ -217,7 +221,8 @@ public function install($version = self::ES_DEFAULT_VERSION, $tld = 'test')
// opensearch requires openjdk (installed automatically)
// elasticsearch@6 requires openjdk@17 (installed automatically)
// seems like there can be only one openjdk when installing. after installing it doesn't matter.
// if this dependency is installed we need to launch es with this java version, see https://github.com/Homebrew/homebrew-core/issues/100260
// if this dependency is installed we need to launch es with this java version,
// see https://github.com/Homebrew/homebrew-core/issues/100260

$this->brew->ensureInstalled($version);

Expand Down
2 changes: 1 addition & 1 deletion cli/ValetPlus/Extended/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ protected function installNewsysLogRotation(): void
$contents
);

//@todo; Set up log rotation for BREW_PREFIX . '/var/log/' to rotate elasticsearch logs
//@todo; Set up log rotation for BREW_PREFIX . '/var/log/' to rotate elasticsearch logs
}
}
16 changes: 8 additions & 8 deletions cli/ValetPlus/Extended/PhpFpm.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ class PhpFpm extends ValetPhpFpm
* @param PhpExtension $phpExtension
*/
public function __construct(
Brew $brew,
CommandLine $cli,
Filesystem $files,
Brew $brew,
CommandLine $cli,
Filesystem $files,
Configuration $config,
Site $site,
Nginx $nginx,
PhpExtension $phpExtension
Site $site,
Nginx $nginx,
PhpExtension $phpExtension
) {
parent::__construct($brew, $cli, $files, $config, $site, $nginx);

Expand Down Expand Up @@ -117,7 +117,7 @@ public function createConfigurationFiles(string $phpVersion): void
$event = new DataEvent();
$event->set('php_version', $phpVersion);
$event->set('php_dir', $destDir);

$this->eventDispatcher->dispatch($event, 'after_create_php_config'); //@todo; dispatch event when config should be removed?
//@todo; dispatch event when config should be removed?
$this->eventDispatcher->dispatch($event, 'after_create_php_config');
}
}
16 changes: 8 additions & 8 deletions cli/ValetPlus/Extended/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ class Status extends ValetStatus
*/
public function __construct(
Configuration $config,
Brew $brew,
CommandLine $cli,
Filesystem $files,
Mysql $mysql,
Mailhog $mailhog,
Varnish $varnish,
Redis $redis,
Rabbitmq $rabbitmq
Brew $brew,
CommandLine $cli,
Filesystem $files,
Mysql $mysql,
Mailhog $mailhog,
Varnish $varnish,
Redis $redis,
Rabbitmq $rabbitmq
) {
parent::__construct($config, $brew, $cli, $files);

Expand Down
15 changes: 8 additions & 7 deletions cli/ValetPlus/Mailhog.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@
use Valet\Configuration;
use Valet\Filesystem;
use WeProvide\ValetPlus\Event\DataEvent;

use function Valet\info;

class Mailhog extends AbstractService
{
/** @var string */
const SERVICE_NAME = 'mailhog';
protected const SERVICE_NAME = 'mailhog';

/** @var string */
const PHP_CONFIGURATION_STUB = __DIR__ . '/../stubs/mailhog.ini';
protected const PHP_CONFIGURATION_STUB = __DIR__ . '/../stubs/mailhog.ini';
/** @var string */
const NGINX_CONFIGURATION_STUB = __DIR__ . '/../stubs/mailhog.conf';
protected const NGINX_CONFIGURATION_STUB = __DIR__ . '/../stubs/mailhog.conf';
/** @var string */
const NGINX_CONFIGURATION_PATH = VALET_HOME_PATH . '/Nginx/mailhog.conf';
protected const NGINX_CONFIGURATION_PATH = VALET_HOME_PATH . '/Nginx/mailhog.conf';

/** @var EventDispatcher */
protected $eventDispatcher;
Expand All @@ -36,9 +37,9 @@ class Mailhog extends AbstractService
*/
public function __construct(
Configuration $configuration,
Brew $brew,
Filesystem $files,
CommandLine $cli
Brew $brew,
Filesystem $files,
CommandLine $cli
) {
parent::__construct($configuration, $brew, $files, $cli);

Expand Down
Loading

0 comments on commit 0256b8a

Please sign in to comment.