diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000..f02a64b
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,20 @@
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+insert_final_newline = true
+indent_style = space
+indent_size = 4
+trim_trailing_whitespace = true
+
+[*.md]
+trim_trailing_whitespace = false
+
+[*.yml]
+indent_style = space
+indent_size = 2
+
+[*.json]
+indent_style = space
+indent_size = 4
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..478a2db
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,10 @@
+* text=auto
+
+/.* export-ignore
+/example export-ignore
+/tests export-ignore
+/*.xml export-ignore
+/*.yml export-ignore
+/*.lock export-ignore
+/*.dist export-ignore
+/*.php export-ignore
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000..38798a2
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,3 @@
+# These are supported funding model platforms
+
+github: roadrunner-server
diff --git a/.github/workflows/cs-fix.yml b/.github/workflows/cs-fix.yml
new file mode 100644
index 0000000..0395b27
--- /dev/null
+++ b/.github/workflows/cs-fix.yml
@@ -0,0 +1,12 @@
+on:
+ push:
+ branches:
+ - '*'
+
+name: Fix Code Style
+
+jobs:
+ cs-fix:
+ permissions:
+ contents: write
+ uses: spiral/gh-actions/.github/workflows/cs-fix.yml@master
diff --git a/.github/workflows/psalm.yml b/.github/workflows/psalm.yml
new file mode 100644
index 0000000..adf59f0
--- /dev/null
+++ b/.github/workflows/psalm.yml
@@ -0,0 +1,14 @@
+on:
+ push:
+ branches:
+ - '*.*'
+ pull_request: null
+
+name: static analysis
+
+jobs:
+ psalm:
+ uses: spiral/gh-actions/.github/workflows/psalm.yml@master
+ with:
+ os: >-
+ ['ubuntu-latest']
diff --git a/.gitignore b/.gitignore
index ce65a4b..8ed15ee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
-# Dependency directories (remove the comment below to include it)
-# vendor/
-.idea
-vendor
+/runtime
+/vendor
+/.idea
+/.env
composer.lock
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
new file mode 100644
index 0000000..9f35f16
--- /dev/null
+++ b/.php-cs-fixer.dist.php
@@ -0,0 +1,12 @@
+include(__DIR__ . '/bin/rr')
+ ->include(__DIR__ . '/src')
+ ->include(__FILE__)
+ ->allowRisky(true)
+ ->build();
diff --git a/bin/rr b/bin/rr
index fae58ed..9d9c315 100644
--- a/bin/rr
+++ b/bin/rr
@@ -21,11 +21,11 @@ use Spiral\RoadRunner\Version;
//
if (PHP_SAPI !== 'cli' && PHP_SAPI !== 'phpdbg') {
- $error = vsprintf('Info CLI should be invoked via the CLI version of PHP, not the %s SAPI', [
+ $error = \vsprintf('Info CLI should be invoked via the CLI version of PHP, not the %s SAPI', [
PHP_SAPI,
]);
- fwrite(STDERR, $error);
+ \fwrite(STDERR, $error);
exit(1);
}
@@ -44,15 +44,15 @@ $composerAutoloadPaths = [
];
foreach ($composerAutoloadPaths as $file) {
- if (is_file($file)) {
- define('RR_COMPOSER_INSTALL', $file);
+ if (\is_file($file)) {
+ \define('RR_COMPOSER_INSTALL', $file);
break;
}
}
-if (! defined('RR_COMPOSER_INSTALL')) {
- fwrite(STDERR, <<<'RR_CLI_ERROR'
+if (! \defined('RR_COMPOSER_INSTALL')) {
+ \fwrite(STDERR, <<<'RR_CLI_ERROR'
You need to set up the project dependencies using Composer:
composer install
diff --git a/composer.json b/composer.json
index f4be9be..c7a692a 100644
--- a/composer.json
+++ b/composer.json
@@ -20,36 +20,40 @@
"support": {
"docs": "https://docs.roadrunner.dev",
"issues": "https://github.com/roadrunner-server/roadrunner/issues",
- "forum": "https://forum.roadrunner.dev/",
"chat": "https://discord.gg/V6EK4he"
},
+ "funding": [
+ {
+ "type": "github",
+ "url": "https://github.com/sponsors/roadrunner-server"
+ }
+ ],
"require": {
- "php": ">=7.4",
+ "php": ">=8.1",
"ext-json": "*",
- "composer/semver": "^3.2",
- "spiral/roadrunner-worker": ">=2.0.2",
- "spiral/tokenizer": "^2.13 || ^3.0",
+ "composer/semver": "^3.4",
+ "spiral/roadrunner-worker": "^2 || ^3",
+ "spiral/tokenizer": "^2.13 || ^3.15",
"symfony/console": "^5.3 || ^6.0 || ^7.0",
- "symfony/http-client": "^4.4.11 || ^5.0 || ^6.0 || ^7.0",
- "symfony/polyfill-php80": "^1.22",
- "symfony/yaml": "^5.4 || ^6.0 || ^7.0"
+ "symfony/http-client": "^4.4.51 || ^5.4.49 || ^6.4.17 || ^7.2",
+ "symfony/yaml": "^5.4.49 || ^6.4.17 || ^7.2"
},
"require-dev": {
- "jetbrains/phpstorm-attributes": "^1.0",
- "vimeo/psalm": "^5.17"
- },
- "scripts": {
- "analyze": "psalm"
+ "jetbrains/phpstorm-attributes": "^1.2",
+ "spiral/code-style": "^2.2.2",
+ "spiral/dumper": "^3.3",
+ "vimeo/psalm": "^6.0"
},
"autoload": {
"psr-4": {
"Spiral\\RoadRunner\\Console\\": "src"
}
},
- "extra": {
- "branch-alias": {
- "dev-master": "2.1.x-dev"
- }
+ "scripts": {
+ "cs:diff": "php-cs-fixer fix --dry-run -v --diff --show-progress dots",
+ "cs:fix": "php-cs-fixer fix -v",
+ "psalm": "psalm",
+ "psalm:baseline": "psalm --set-baseline=psalm-baseline.xml"
},
"config": {
"sort-packages": true
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
new file mode 100644
index 0000000..4a22a52
--- /dev/null
+++ b/psalm-baseline.xml
@@ -0,0 +1,158 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ]]>
+
+
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+ getAvailable()]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getOption('plugin')]]>
+ getOption('preset')]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getOption('plugin')]]>
+ getOption('preset')]]>
+
+
+
+
+
+
+
+
+ items, $callback))]]>
+ items, $filter))]]>
+ items))]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ stability]]>
+
+
+
+
+
+
+
+ ]]>
+
+
+
+
+
+
+
+
+
+ ]]>
+
+
+
+
+ stability->get($input, $io)]]>
+
+
+ getAssets()]]>
+
+
+
+
+
+
+
+
+
diff --git a/psalm.xml b/psalm.xml
index 3240886..c729c68 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -1,11 +1,22 @@
+
+
+
diff --git a/src/Archive/Archive.php b/src/Archive/Archive.php
index 666d338..57f70e2 100644
--- a/src/Archive/Archive.php
+++ b/src/Archive/Archive.php
@@ -13,28 +13,22 @@
abstract class Archive implements ArchiveInterface
{
- /**
- * @param \SplFileInfo $archive
- */
public function __construct(\SplFileInfo $archive)
{
$this->assertArchiveValid($archive);
}
- /**
- * @param \SplFileInfo $archive
- */
private function assertArchiveValid(\SplFileInfo $archive): void
{
if (! $archive->isFile()) {
throw new \InvalidArgumentException(
- \sprintf('Archive "%s" is not a file', $archive->getFilename())
+ \sprintf('Archive "%s" is not a file', $archive->getFilename()),
);
}
if (! $archive->isReadable()) {
throw new \InvalidArgumentException(
- \sprintf('Archive file "%s" is not readable', $archive->getFilename())
+ \sprintf('Archive file "%s" is not readable', $archive->getFilename()),
);
}
}
diff --git a/src/Archive/Factory.php b/src/Archive/Factory.php
index 74b80e4..48e9e9a 100644
--- a/src/Archive/Factory.php
+++ b/src/Archive/Factory.php
@@ -31,39 +31,6 @@ public function __construct()
$this->bootDefaultMatchers();
}
- /**
- * @return void
- */
- private function bootDefaultMatchers(): void
- {
- $this->extend($this->matcher('zip',
- static fn (\SplFileInfo $info): ArchiveInterface => new ZipPharArchive($info)
- ));
-
- $this->extend($this->matcher('tar.gz',
- static fn (\SplFileInfo $info): ArchiveInterface => new TarPharArchive($info)
- ));
-
- $this->extend($this->matcher('phar',
- static fn (\SplFileInfo $info): ArchiveInterface => new PharArchive($info)
- ));
- }
-
- /**
- * @param string $extension
- * @param ArchiveMatcher $then
- * @return ArchiveMatcher
- */
- private function matcher(string $extension, \Closure $then): \Closure
- {
- return static fn (\SplFileInfo $info): ?ArchiveInterface =>
- \str_ends_with(\strtolower($info->getFilename()), '.' . $extension) ? $then($info) : null
- ;
- }
-
- /**
- * {@inheritDoc}
- */
public function extend(\Closure $matcher): self
{
\array_unshift($this->matchers, $matcher);
@@ -71,10 +38,6 @@ public function extend(\Closure $matcher): self
return $this;
}
- /**
- * @param \SplFileInfo $file
- * @return ArchiveInterface
- */
public function create(\SplFileInfo $file): ArchiveInterface
{
$errors = [];
@@ -97,10 +60,7 @@ public function create(\SplFileInfo $file): ArchiveInterface
throw new \InvalidArgumentException($error);
}
- /**
- * {@inheritDoc}
- */
- public function fromAsset(AssetInterface $asset, \Closure $progress = null, string $temp = null): ArchiveInterface
+ public function fromAsset(AssetInterface $asset, ?\Closure $progress = null, ?string $temp = null): ArchiveInterface
{
$temp = $this->getTempDirectory($temp) . '/' . $asset->getName();
@@ -119,10 +79,35 @@ public function fromAsset(AssetInterface $asset, \Closure $progress = null, stri
return $this->create($file);
}
+ private function bootDefaultMatchers(): void
+ {
+ $this->extend($this->matcher(
+ 'zip',
+ static fn(\SplFileInfo $info): ArchiveInterface => new ZipPharArchive($info),
+ ));
+
+ $this->extend($this->matcher(
+ 'tar.gz',
+ static fn(\SplFileInfo $info): ArchiveInterface => new TarPharArchive($info),
+ ));
+
+ $this->extend($this->matcher(
+ 'phar',
+ static fn(\SplFileInfo $info): ArchiveInterface => new PharArchive($info),
+ ));
+ }
+
/**
- * @param string|null $temp
- * @return string
+ * @param ArchiveMatcher $then
+ * @return ArchiveMatcher
*/
+ private function matcher(string $extension, \Closure $then): \Closure
+ {
+ return static fn(\SplFileInfo $info): ?ArchiveInterface =>
+ \str_ends_with(\strtolower($info->getFilename()), '.' . $extension) ? $then($info) : null
+ ;
+ }
+
private function getTempDirectory(?string $temp): string
{
if ($temp) {
diff --git a/src/Archive/FactoryInterface.php b/src/Archive/FactoryInterface.php
index d40e66f..fa6d215 100644
--- a/src/Archive/FactoryInterface.php
+++ b/src/Archive/FactoryInterface.php
@@ -24,17 +24,7 @@ interface FactoryInterface
*/
public function extend(\Closure $matcher): self;
- /**
- * @param \SplFileInfo $file
- * @return ArchiveInterface
- */
public function create(\SplFileInfo $file): ArchiveInterface;
- /**
- * @param AssetInterface $asset
- * @param \Closure|null $progress
- * @param string|null $temp
- * @return ArchiveInterface
- */
- public function fromAsset(AssetInterface $asset, \Closure $progress = null, string $temp = null): ArchiveInterface;
+ public function fromAsset(AssetInterface $asset, ?\Closure $progress = null, ?string $temp = null): ArchiveInterface;
}
diff --git a/src/Archive/PharArchive.php b/src/Archive/PharArchive.php
index 61da185..4d28eb8 100644
--- a/src/Archive/PharArchive.php
+++ b/src/Archive/PharArchive.php
@@ -13,10 +13,6 @@
final class PharArchive extends PharAwareArchive
{
- /**
- * @param \SplFileInfo $file
- * @return \PharData
- */
protected function open(\SplFileInfo $file): \PharData
{
return new \PharData($file->getPathname());
diff --git a/src/Archive/PharAwareArchive.php b/src/Archive/PharAwareArchive.php
index ecd7c99..7dd4449 100644
--- a/src/Archive/PharAwareArchive.php
+++ b/src/Archive/PharAwareArchive.php
@@ -13,14 +13,8 @@
abstract class PharAwareArchive extends Archive
{
- /**
- * @var \PharData
- */
protected \PharData $archive;
- /**
- * @param \SplFileInfo $archive
- */
public function __construct(\SplFileInfo $archive)
{
parent::__construct($archive);
@@ -28,12 +22,6 @@ public function __construct(\SplFileInfo $archive)
$this->archive = $this->open($archive);
}
- /**
- * @param \SplFileInfo $file
- * @return \PharData
- */
- abstract protected function open(\SplFileInfo $file): \PharData;
-
/**
* @param iterable $mappings
* @return \Generator
@@ -55,4 +43,6 @@ public function extract(iterable $mappings): \Generator
}
}
}
+
+ abstract protected function open(\SplFileInfo $file): \PharData;
}
diff --git a/src/Archive/TarPharArchive.php b/src/Archive/TarPharArchive.php
index 0256c69..ba3d119 100644
--- a/src/Archive/TarPharArchive.php
+++ b/src/Archive/TarPharArchive.php
@@ -13,10 +13,6 @@
final class TarPharArchive extends PharAwareArchive
{
- /**
- * @param \SplFileInfo $file
- * @return \PharData
- */
protected function open(\SplFileInfo $file): \PharData
{
return new \PharData($file->getPathname());
diff --git a/src/Archive/ZipPharArchive.php b/src/Archive/ZipPharArchive.php
index 0b7cf9d..87f3581 100644
--- a/src/Archive/ZipPharArchive.php
+++ b/src/Archive/ZipPharArchive.php
@@ -13,10 +13,6 @@
final class ZipPharArchive extends PharAwareArchive
{
- /**
- * @param \SplFileInfo $file
- * @return \PharData
- */
protected function open(\SplFileInfo $file): \PharData
{
$format = \Phar::ZIP | \Phar::GZ;
diff --git a/src/Command.php b/src/Command.php
index a004e06..4eeab5e 100644
--- a/src/Command.php
+++ b/src/Command.php
@@ -15,7 +15,6 @@
use Spiral\RoadRunner\Console\Repository\GitHub\GitHubRepository;
use Spiral\RoadRunner\Console\Repository\RepositoriesCollection;
use Spiral\RoadRunner\Console\Repository\RepositoryInterface;
-use Spiral\RoadRunner\Console\Repository\Version1\StaticRepository;
use Symfony\Component\Console\Command\Command as BaseCommand;
use Symfony\Component\Console\Helper\QuestionHelper;
use Symfony\Component\Console\Input\InputInterface;
@@ -32,17 +31,14 @@ abstract class Command extends BaseCommand
*/
private const ENV_GITHUB_TOKEN = 'GITHUB_TOKEN';
- /**
- * @return RepositoryInterface
- */
protected function getRepository(): RepositoryInterface
{
$token = Environment::get(self::ENV_GITHUB_TOKEN);
$client = HttpClient::create([
'headers' => \array_filter([
- 'authorization' => $token ? 'token ' . $token : null
- ])
+ 'authorization' => $token ? 'token ' . $token : null,
+ ]),
]);
return new RepositoriesCollection([
@@ -50,22 +46,11 @@ protected function getRepository(): RepositoryInterface
]);
}
- /**
- * @param InputInterface $input
- * @param OutputInterface $output
- * @return StyleInterface
- */
protected function io(InputInterface $input, OutputInterface $output): StyleInterface
{
return new SymfonyStyle($input, $output);
}
- /**
- * @param InputInterface $input
- * @param OutputInterface $out
- * @param string $message
- * @return bool
- */
protected function confirm(InputInterface $input, OutputInterface $out, string $message): bool
{
$question = new ConfirmationQuestion($message);
@@ -73,6 +58,6 @@ protected function confirm(InputInterface $input, OutputInterface $out, string $
/** @var QuestionHelper $helper */
$helper = $this->getHelper('question');
- return (bool)$helper->ask($input, $out, $question);
+ return (bool) $helper->ask($input, $out, $question);
}
}
diff --git a/src/Command/ArchitectureOption.php b/src/Command/ArchitectureOption.php
index 376be5b..c572f0f 100644
--- a/src/Command/ArchitectureOption.php
+++ b/src/Command/ArchitectureOption.php
@@ -18,35 +18,11 @@
class ArchitectureOption extends Option
{
- /**
- * @param Command $command
- * @param string $name
- * @param string $short
- */
public function __construct(Command $command, string $name = 'arch', string $short = 'a')
{
parent::__construct($command, $name, $short);
}
- /**
- * {@inheritDoc}
- */
- protected function getDescription(): string
- {
- return 'Required processor architecture (one of: ' . $this->choices() . ')';
- }
-
- /**
- * {@inheritDoc}
- */
- protected function default(): string
- {
- return Architecture::createFromGlobals();
- }
-
- /**
- * {@inheritDoc}
- */
public function get(InputInterface $input, StyleInterface $io): string
{
$architecture = parent::get($input, $io);
@@ -59,9 +35,16 @@ public function get(InputInterface $input, StyleInterface $io): string
return $architecture;
}
- /**
- * @return string
- */
+ protected function getDescription(): string
+ {
+ return 'Required processor architecture (one of: ' . $this->choices() . ')';
+ }
+
+ protected function default(): string
+ {
+ return Architecture::createFromGlobals();
+ }
+
private function choices(): string
{
return \implode(', ', Architecture::all());
diff --git a/src/Command/InstallationLocationOption.php b/src/Command/InstallationLocationOption.php
index a66f2b3..dab28a0 100644
--- a/src/Command/InstallationLocationOption.php
+++ b/src/Command/InstallationLocationOption.php
@@ -17,35 +17,11 @@
class InstallationLocationOption extends Option
{
- /**
- * @param Command $command
- * @param string $name
- * @param string $short
- */
public function __construct(Command $command, string $name = 'location', string $short = 'l')
{
parent::__construct($command, $name, $short);
}
- /**
- * {@inheritDoc}
- */
- protected function getDescription(): string
- {
- return 'Installation directory';
- }
-
- /**
- * {@inheritDoc}
- */
- protected function default(): string
- {
- return \getcwd() ?: '.';
- }
-
- /**
- * {@inheritDoc}
- */
public function get(InputInterface $input, StyleInterface $io): string
{
$location = parent::get($input, $io);
@@ -61,4 +37,14 @@ public function get(InputInterface $input, StyleInterface $io): string
return $location;
}
+
+ protected function getDescription(): string
+ {
+ return 'Installation directory';
+ }
+
+ protected function default(): string
+ {
+ return \getcwd() ?: '.';
+ }
}
diff --git a/src/Command/OperatingSystemOption.php b/src/Command/OperatingSystemOption.php
index 4dcd8aa..df26d1e 100644
--- a/src/Command/OperatingSystemOption.php
+++ b/src/Command/OperatingSystemOption.php
@@ -18,35 +18,11 @@
class OperatingSystemOption extends Option
{
- /**
- * @param Command $command
- * @param string $name
- * @param string $short
- */
public function __construct(Command $command, string $name = 'os', string $short = 'o')
{
parent::__construct($command, $name, $short);
}
- /**
- * {@inheritDoc}
- */
- protected function getDescription(): string
- {
- return 'Required operating system (one of: ' . $this->choices() . ')';
- }
-
- /**
- * {@inheritDoc}
- */
- protected function default(): string
- {
- return OperatingSystem::createFromGlobals();
- }
-
- /**
- * {@inheritDoc}
- */
public function get(InputInterface $input, StyleInterface $io): string
{
$os = parent::get($input, $io);
@@ -59,9 +35,16 @@ public function get(InputInterface $input, StyleInterface $io): string
return $os;
}
- /**
- * @return string
- */
+ protected function getDescription(): string
+ {
+ return 'Required operating system (one of: ' . $this->choices() . ')';
+ }
+
+ protected function default(): string
+ {
+ return OperatingSystem::createFromGlobals();
+ }
+
private function choices(): string
{
return \implode(', ', OperatingSystem::all());
diff --git a/src/Command/Option.php b/src/Command/Option.php
index 9c71e46..ed9a2f4 100644
--- a/src/Command/Option.php
+++ b/src/Command/Option.php
@@ -21,39 +21,25 @@
*/
abstract class Option implements OptionInterface
{
- /**
- * @var string
- */
protected string $name;
- /**
- * @param Command $command
- * @param string $name
- * @param string|null $short
- */
- public function __construct(Command $command, string $name, string $short = null)
+ public function __construct(Command $command, string $name, ?string $short = null)
{
$this->name = $name;
$this->register($command, $name, $short ?? $name);
}
- /**
- * @return string
- */
public function getName(): string
{
return $this->name;
}
- /**
- * @param Command $command
- * @param string $name
- * @param string $short
- */
- private function register(Command $command, string $name, string $short): void
+ public function get(InputInterface $input, StyleInterface $io): string
{
- $command->addOption($name, $short, $this->getMode(), $this->getDescription(), $this->default());
+ $result = $input->getOption($this->name) ?: $this->default();
+
+ return \is_string($result) ? $result : '';
}
/**
@@ -64,25 +50,12 @@ protected function getMode(): int
return InputOption::VALUE_OPTIONAL;
}
- /**
- * @return string
- */
abstract protected function getDescription(): string;
- /**
- * @param InputInterface $input
- * @param StyleInterface $io
- * @return string
- */
- public function get(InputInterface $input, StyleInterface $io): string
- {
- $result = $input->getOption($this->name) ?: $this->default();
+ abstract protected function default(): ?string;
- return \is_string($result) ? $result : '';
+ private function register(Command $command, string $name, string $short): void
+ {
+ $command->addOption($name, $short, $this->getMode(), $this->getDescription(), $this->default());
}
-
- /**
- * @return string|null
- */
- abstract protected function default(): ?string;
}
diff --git a/src/Command/OptionInterface.php b/src/Command/OptionInterface.php
index 4b4a755..f84098d 100644
--- a/src/Command/OptionInterface.php
+++ b/src/Command/OptionInterface.php
@@ -16,15 +16,7 @@
interface OptionInterface
{
- /**
- * @return string
- */
public function getName(): string;
- /**
- * @param InputInterface $input
- * @param StyleInterface $io
- * @return string
- */
public function get(InputInterface $input, StyleInterface $io): string;
}
diff --git a/src/Command/StabilityOption.php b/src/Command/StabilityOption.php
index 67cebea..fb5ba5d 100644
--- a/src/Command/StabilityOption.php
+++ b/src/Command/StabilityOption.php
@@ -21,34 +21,13 @@
*/
class StabilityOption extends Option
{
- /**
- * @param Command $command
- * @param string $name
- * @param string $short
- */
public function __construct(Command $command, string $name = 'stability', string $short = 's')
{
parent::__construct($command, $name, $short);
}
/**
- * @return string
- */
- protected function getDescription(): string
- {
- return 'Release minimum stability flag';
- }
-
- /**
- * {@inheritDoc}
- */
- protected function default(): string
- {
- return Stability::STABILITY_STABLE;
- }
-
- /**
- * {@inheritDoc}
+ *
* @return StabilityType|string
*/
public function get(InputInterface $input, StyleInterface $io): string
@@ -63,9 +42,16 @@ public function get(InputInterface $input, StyleInterface $io): string
return $stability;
}
- /**
- * @return string
- */
+ protected function getDescription(): string
+ {
+ return 'Release minimum stability flag';
+ }
+
+ protected function default(): string
+ {
+ return Stability::STABILITY_STABLE;
+ }
+
private function choices(): string
{
return \implode(', ', Stability::all());
diff --git a/src/Command/VersionFilterOption.php b/src/Command/VersionFilterOption.php
index 4b64f5f..d823ef1 100644
--- a/src/Command/VersionFilterOption.php
+++ b/src/Command/VersionFilterOption.php
@@ -21,36 +21,11 @@
class VersionFilterOption extends Option
{
- /**
- * @param Command $command
- * @param string $name
- * @param string $short
- */
public function __construct(Command $command, string $name = 'filter', string $short = 'f')
{
parent::__construct($command, $name, $short);
}
- /**
- * {@inheritDoc}
- */
- protected function getDescription(): string
- {
- return 'Required version of RoadRunner binaries';
- }
-
- /**
- * {@inheritDoc}
- */
- protected function default(): string
- {
- return RoadRunnerVersion::constraint();
- }
-
- /**
- * @param ReleasesCollection $releases
- * @return string
- */
public function choices(ReleasesCollection $releases): string
{
$versions = $releases
@@ -61,12 +36,6 @@ public function choices(ReleasesCollection $releases): string
return \implode(', ', \array_unique($versions));
}
- /**
- * @param InputInterface $input
- * @param StyleInterface $io
- * @param RepositoryInterface $repo
- * @return ReleasesCollection
- */
public function find(InputInterface $input, StyleInterface $io, RepositoryInterface $repo): ReleasesCollection
{
$constraint = $this->get($input, $io);
@@ -84,11 +53,16 @@ public function find(InputInterface $input, StyleInterface $io, RepositoryInterf
return $filtered;
}
- /**
- * @param ReleasesCollection $filtered
- * @param ReleasesCollection $all
- * @param string $constraint
- */
+ protected function getDescription(): string
+ {
+ return 'Required version of RoadRunner binaries';
+ }
+
+ protected function default(): string
+ {
+ return RoadRunnerVersion::constraint();
+ }
+
private function validateNotEmpty(ReleasesCollection $filtered, ReleasesCollection $all, string $constraint): void
{
if ($filtered->empty()) {
diff --git a/src/Configuration/Generator.php b/src/Configuration/Generator.php
index 76b3dc8..24ed2da 100644
--- a/src/Configuration/Generator.php
+++ b/src/Configuration/Generator.php
@@ -11,15 +11,15 @@
class Generator
{
- /** @var SectionInterface[] */
- protected array $sections = [];
-
/** @psalm-var non-empty-array> */
protected const REQUIRED_SECTIONS = [
Version::class,
Rpc::class,
];
+ /** @var SectionInterface[] */
+ protected array $sections = [];
+
public function generate(Plugins $plugins): string
{
$this->collectSections($plugins->getPlugins());
@@ -46,7 +46,9 @@ protected function collectSections(array $plugins): void
}
}
- /** @psalm-return non-empty-array */
+ /**
+ * @psalm-return non-empty-array
+ */
protected function fromSection(SectionInterface $section): void
{
if (!isset($this->sections[\get_class($section)])) {
diff --git a/src/Configuration/Plugins.php b/src/Configuration/Plugins.php
index 3b5382a..4dedad8 100644
--- a/src/Configuration/Plugins.php
+++ b/src/Configuration/Plugins.php
@@ -65,7 +65,7 @@ public static function fromPreset(string $preset): self
$plugins = Presets::WEB_PLUGINS;
}
- return new self(\array_map(function (string $plugin) {
+ return new self(\array_map(static function (string $plugin) {
return $plugin::getShortName();
}, $plugins));
}
diff --git a/src/Configuration/Presets.php b/src/Configuration/Presets.php
index e300136..13c2625 100644
--- a/src/Configuration/Presets.php
+++ b/src/Configuration/Presets.php
@@ -10,9 +10,8 @@
final class Presets
{
public const WEB_PRESET_NANE = 'web';
-
public const WEB_PLUGINS = [
Http::class,
- Jobs::class
+ Jobs::class,
];
}
diff --git a/src/Configuration/Section/Amqp.php b/src/Configuration/Section/Amqp.php
index f55d39f..162b8be 100644
--- a/src/Configuration/Section/Amqp.php
+++ b/src/Configuration/Section/Amqp.php
@@ -8,17 +8,17 @@ final class Amqp extends AbstractSection
{
private const NAME = 'amqp';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
- 'addr' => 'amqp://guest:guest@127.0.0.1:5672/'
- ]
+ 'addr' => 'amqp://guest:guest@127.0.0.1:5672/',
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Beanstalk.php b/src/Configuration/Section/Beanstalk.php
index c195a9d..5c7c9a5 100644
--- a/src/Configuration/Section/Beanstalk.php
+++ b/src/Configuration/Section/Beanstalk.php
@@ -8,18 +8,18 @@ final class Beanstalk extends AbstractSection
{
private const NAME = 'beanstalk';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
'addr' => 'tcp://127.0.0.1:11300',
- 'timeout' => '10s'
- ]
+ 'timeout' => '10s',
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Boltdb.php b/src/Configuration/Section/Boltdb.php
index dcd64a4..4be4186 100644
--- a/src/Configuration/Section/Boltdb.php
+++ b/src/Configuration/Section/Boltdb.php
@@ -8,17 +8,17 @@ final class Boltdb extends AbstractSection
{
private const NAME = 'boltdb';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
- 'permissions' => 0777
- ]
+ 'permissions' => 0777,
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Broadcast.php b/src/Configuration/Section/Broadcast.php
index 117f0d1..d4bd2de 100644
--- a/src/Configuration/Section/Broadcast.php
+++ b/src/Configuration/Section/Broadcast.php
@@ -8,48 +8,48 @@ final class Broadcast extends AbstractSection
{
private const NAME = 'broadcast';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
'default' => [
'driver' => 'memory',
- 'config' => []
+ 'config' => [],
],
-// 'default-redis' => [
-// 'driver' => 'redis',
-// 'config' => [
-// 'addrs' => [
-// 'localhost:6379'
-// ],
-// 'master_name' => '',
-// 'username' => '',
-// 'password' => '',
-// 'db' => 0,
-// 'sentinel_password' => '',
-// 'route_by_latency' => false,
-// 'route_randomly' => false,
-// 'dial_timeout' => 0,
-// 'max_retries' => 1,
-// 'min_retry_backoff' => 0,
-// 'max_retry_backoff' => 0,
-// 'pool_size' => 0,
-// 'min_idle_conns' => 0,
-// 'max_conn_age' => 0,
-// 'read_timeout' => 0,
-// 'write_timeout' => 0,
-// 'pool_timeout' => 0,
-// 'idle_timeout' => 0,
-// 'idle_check_freq' => 0,
-// 'read_only' => false
-// ]
-// ]
- ]
+ // 'default-redis' => [
+ // 'driver' => 'redis',
+ // 'config' => [
+ // 'addrs' => [
+ // 'localhost:6379'
+ // ],
+ // 'master_name' => '',
+ // 'username' => '',
+ // 'password' => '',
+ // 'db' => 0,
+ // 'sentinel_password' => '',
+ // 'route_by_latency' => false,
+ // 'route_randomly' => false,
+ // 'dial_timeout' => 0,
+ // 'max_retries' => 1,
+ // 'min_retry_backoff' => 0,
+ // 'max_retry_backoff' => 0,
+ // 'pool_size' => 0,
+ // 'min_idle_conns' => 0,
+ // 'max_conn_age' => 0,
+ // 'read_timeout' => 0,
+ // 'write_timeout' => 0,
+ // 'pool_timeout' => 0,
+ // 'idle_timeout' => 0,
+ // 'idle_check_freq' => 0,
+ // 'read_only' => false
+ // ]
+ // ]
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Endure.php b/src/Configuration/Section/Endure.php
index 6dea614..60a17b7 100644
--- a/src/Configuration/Section/Endure.php
+++ b/src/Configuration/Section/Endure.php
@@ -8,19 +8,19 @@ final class Endure extends AbstractSection
{
private const NAME = 'endure';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
'grace_period' => '30s',
'print_graph' => false,
- 'log_level' => 'error'
- ]
+ 'log_level' => 'error',
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Fileserver.php b/src/Configuration/Section/Fileserver.php
index 5b25643..6e39af4 100644
--- a/src/Configuration/Section/Fileserver.php
+++ b/src/Configuration/Section/Fileserver.php
@@ -8,6 +8,11 @@ final class Fileserver extends AbstractSection
{
private const NAME = 'fileserver';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
@@ -16,30 +21,25 @@ public function render(): array
'calculate_etag' => true,
'weak' => false,
'stream_request_body' => true,
-// 'serve' => [
-// [
-// 'prefix' => '/foo',
-// 'root' => '../../../tests',
-// 'compress' => false,
-// 'cache_duration' => 10,
-// 'max_age' => 10,
-// 'bytes_range' => true
-// ],
-// [
-// 'prefix' => '/foo/bar',
-// 'root' => '../../../tests',
-// 'compress' => false,
-// 'cache_duration' => 10,
-// 'max_age' => 10,
-// 'bytes_range' => true
-// ]
-// ]
- ]
+ // 'serve' => [
+ // [
+ // 'prefix' => '/foo',
+ // 'root' => '../../../tests',
+ // 'compress' => false,
+ // 'cache_duration' => 10,
+ // 'max_age' => 10,
+ // 'bytes_range' => true
+ // ],
+ // [
+ // 'prefix' => '/foo/bar',
+ // 'root' => '../../../tests',
+ // 'compress' => false,
+ // 'cache_duration' => 10,
+ // 'max_age' => 10,
+ // 'bytes_range' => true
+ // ]
+ // ]
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Grpc.php b/src/Configuration/Section/Grpc.php
index 514ecbb..08ccbf8 100644
--- a/src/Configuration/Section/Grpc.php
+++ b/src/Configuration/Section/Grpc.php
@@ -8,6 +8,11 @@ final class Grpc extends AbstractSection
{
private const NAME = 'grpc';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
@@ -15,41 +20,36 @@ public function render(): array
'listen' => 'tcp://127.0.0.1:9001',
'proto' => [
'first.proto',
- 'second.proto'
+ 'second.proto',
],
-// 'tls' => [
-// 'key' => '',
-// 'cert' => '',
-// 'root_ca' => '',
-// 'client_auth_type' => 'no_client_certs'
-// ],
-// 'max_send_msg_size' => 50,
-// 'max_recv_msg_size' => 50,
-// 'max_connection_idle' => '0s',
-// 'max_connection_age' => '0s',
-// 'max_connection_age_grace' => '0s8h',
-// 'max_concurrent_streams' => 10,
-// 'ping_time' => '1s',
-// 'timeout' => '200s',
-// 'pool' => [
-// 'num_workers' => 2,
-// 'max_jobs' => 0,
-// 'allocate_timeout' => '60s',
-// 'destroy_timeout' => 60
-// ]
- ]
+ // 'tls' => [
+ // 'key' => '',
+ // 'cert' => '',
+ // 'root_ca' => '',
+ // 'client_auth_type' => 'no_client_certs'
+ // ],
+ // 'max_send_msg_size' => 50,
+ // 'max_recv_msg_size' => 50,
+ // 'max_connection_idle' => '0s',
+ // 'max_connection_age' => '0s',
+ // 'max_connection_age_grace' => '0s8h',
+ // 'max_concurrent_streams' => 10,
+ // 'ping_time' => '1s',
+ // 'timeout' => '200s',
+ // 'pool' => [
+ // 'num_workers' => 2,
+ // 'max_jobs' => 0,
+ // 'allocate_timeout' => '60s',
+ // 'destroy_timeout' => 60
+ // ]
+ ],
];
}
public function getRequired(): array
{
return [
- Server::class
+ Server::class,
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Http.php b/src/Configuration/Section/Http.php
index 46c60de..cc8efc7 100644
--- a/src/Configuration/Section/Http.php
+++ b/src/Configuration/Section/Http.php
@@ -8,6 +8,11 @@ final class Http extends AbstractSection
{
private const NAME = 'http';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
@@ -15,7 +20,7 @@ public function render(): array
'address' => '0.0.0.0:8080',
'middleware' => [
'gzip',
- 'static'
+ 'static',
],
'static' => [
'dir' => 'public',
@@ -24,22 +29,17 @@ public function render(): array
'pool' => [
'num_workers' => 1,
'supervisor' => [
- 'max_worker_memory' => 100
- ]
- ]
- ]
+ 'max_worker_memory' => 100,
+ ],
+ ],
+ ],
];
}
public function getRequired(): array
{
return [
- Server::class
+ Server::class,
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Jobs.php b/src/Configuration/Section/Jobs.php
index 4825a56..720913c 100644
--- a/src/Configuration/Section/Jobs.php
+++ b/src/Configuration/Section/Jobs.php
@@ -8,28 +8,28 @@ final class Jobs extends AbstractSection
{
private const NAME = 'jobs';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
'pool' => [
'num_workers' => 2,
- 'max_worker_memory' => 100
+ 'max_worker_memory' => 100,
],
- 'consume' => []
- ]
+ 'consume' => [],
+ ],
];
}
public function getRequired(): array
{
return [
- Server::class
+ Server::class,
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Kv.php b/src/Configuration/Section/Kv.php
index 9f11d4b..24d1645 100644
--- a/src/Configuration/Section/Kv.php
+++ b/src/Configuration/Section/Kv.php
@@ -8,6 +8,11 @@ final class Kv extends AbstractSection
{
private const NAME = 'kv';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
@@ -15,23 +20,18 @@ public function render(): array
'local' => [
'driver' => 'memory',
'config' => [
- 'interval' => 60
- ]
+ 'interval' => 60,
+ ],
],
-// 'redis' => [
-// 'driver' => 'redis',
-// 'config' => [
-// 'addrs' => [
-// 'localhost:6379'
-// ]
-// ]
-// ]
- ]
+ // 'redis' => [
+ // 'driver' => 'redis',
+ // 'config' => [
+ // 'addrs' => [
+ // 'localhost:6379'
+ // ]
+ // ]
+ // ]
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Logs.php b/src/Configuration/Section/Logs.php
index 36fdaf2..799b9f5 100644
--- a/src/Configuration/Section/Logs.php
+++ b/src/Configuration/Section/Logs.php
@@ -8,52 +8,52 @@ final class Logs extends AbstractSection
{
private const NAME = 'logs';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
'mode' => 'development',
'level' => 'debug',
-// 'encoding' => 'console',
-// 'line_ending' => '\n',
-// 'output' => 'stderr',
-// 'err_output' => 'stderr',
-// 'file_logger_options' => [
-// 'log_output' => '/tmp/my.log',
-// 'max_size' => 100,
-// 'max_age' => 1,
-// 'max_backups' => 5,
-// 'compress' => false
-// ],
-// 'channels' => [
-// 'http' => [
-// 'mode' => 'development',
-// 'level' => 'panic',
-// 'encoding' => 'console',
-// 'output' => 'stdout',
-// 'err_output' => 'stderr'
-// ],
-// 'server' => [
-// 'mode' => 'production',
-// 'level' => 'info',
-// 'encoding' => 'json',
-// 'output' => 'stdout',
-// 'err_output' => 'stdout'
-// ],
-// 'rpc' => [
-// 'mode' => 'raw',
-// 'level' => 'debug',
-// 'encoding' => 'console',
-// 'output' => 'stderr',
-// 'err_output' => 'stdout'
-// ]
-// ]
- ]
+ // 'encoding' => 'console',
+ // 'line_ending' => '\n',
+ // 'output' => 'stderr',
+ // 'err_output' => 'stderr',
+ // 'file_logger_options' => [
+ // 'log_output' => '/tmp/my.log',
+ // 'max_size' => 100,
+ // 'max_age' => 1,
+ // 'max_backups' => 5,
+ // 'compress' => false
+ // ],
+ // 'channels' => [
+ // 'http' => [
+ // 'mode' => 'development',
+ // 'level' => 'panic',
+ // 'encoding' => 'console',
+ // 'output' => 'stdout',
+ // 'err_output' => 'stderr'
+ // ],
+ // 'server' => [
+ // 'mode' => 'production',
+ // 'level' => 'info',
+ // 'encoding' => 'json',
+ // 'output' => 'stdout',
+ // 'err_output' => 'stdout'
+ // ],
+ // 'rpc' => [
+ // 'mode' => 'raw',
+ // 'level' => 'debug',
+ // 'encoding' => 'console',
+ // 'output' => 'stderr',
+ // 'err_output' => 'stdout'
+ // ]
+ // ]
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Metrics.php b/src/Configuration/Section/Metrics.php
index f059870..5666fff 100644
--- a/src/Configuration/Section/Metrics.php
+++ b/src/Configuration/Section/Metrics.php
@@ -8,17 +8,17 @@ final class Metrics extends AbstractSection
{
private const NAME = 'metrics';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
- 'address' => '127.0.0.1:2112'
- ]
+ 'address' => '127.0.0.1:2112',
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Nats.php b/src/Configuration/Section/Nats.php
index a3737cf..a4a0e38 100644
--- a/src/Configuration/Section/Nats.php
+++ b/src/Configuration/Section/Nats.php
@@ -8,17 +8,17 @@ final class Nats extends AbstractSection
{
private const NAME = 'nats';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
- 'addr' => 'demo.nats.io'
- ]
+ 'addr' => 'demo.nats.io',
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Otel.php b/src/Configuration/Section/Otel.php
index 5410444..f517ee3 100644
--- a/src/Configuration/Section/Otel.php
+++ b/src/Configuration/Section/Otel.php
@@ -8,6 +8,11 @@ final class Otel extends AbstractSection
{
private const NAME = 'otel';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
@@ -19,13 +24,8 @@ public function render(): array
'custom_url' => '',
'service_name' => 'RoadRunner',
'service_version' => '1.0.0',
- 'endpoint' => '127.0.0.1:4318'
- ]
+ 'endpoint' => '127.0.0.1:4318',
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Redis.php b/src/Configuration/Section/Redis.php
index 7def40b..18cccf7 100644
--- a/src/Configuration/Section/Redis.php
+++ b/src/Configuration/Section/Redis.php
@@ -8,39 +8,39 @@ final class Redis extends AbstractSection
{
private const NAME = 'redis';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
'addrs' => [
- 'localhost:6379'
+ 'localhost:6379',
],
-// 'master_name' => '',
-// 'username' => '',
-// 'password' => '',
-// 'db' => 0,
-// 'sentinel_password' => '',
-// 'route_by_latency' => false,
-// 'route_randomly' => false,
-// 'dial_timeout' => 0,
-// 'max_retries' => 1,
-// 'min_retry_backoff' => 0,
-// 'max_retry_backoff' => 0,
-// 'pool_size' => 0,
-// 'min_idle_conns' => 0,
-// 'max_conn_age' => 0,
-// 'read_timeout' => 0,
-// 'write_timeout' => 0,
-// 'pool_timeout' => 0,
-// 'idle_timeout' => 0,
-// 'idle_check_freq' => 0,
-// 'read_only' => false
- ]
+ // 'master_name' => '',
+ // 'username' => '',
+ // 'password' => '',
+ // 'db' => 0,
+ // 'sentinel_password' => '',
+ // 'route_by_latency' => false,
+ // 'route_randomly' => false,
+ // 'dial_timeout' => 0,
+ // 'max_retries' => 1,
+ // 'min_retry_backoff' => 0,
+ // 'max_retry_backoff' => 0,
+ // 'pool_size' => 0,
+ // 'min_idle_conns' => 0,
+ // 'max_conn_age' => 0,
+ // 'read_timeout' => 0,
+ // 'write_timeout' => 0,
+ // 'pool_timeout' => 0,
+ // 'idle_timeout' => 0,
+ // 'idle_check_freq' => 0,
+ // 'read_only' => false
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Reload.php b/src/Configuration/Section/Reload.php
index b607816..5e59d74 100644
--- a/src/Configuration/Section/Reload.php
+++ b/src/Configuration/Section/Reload.php
@@ -8,36 +8,36 @@ final class Reload extends AbstractSection
{
private const NAME = 'reload';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
'interval' => '1s',
'patterns' => [
- '.php'
+ '.php',
],
'services' => [
'http' => [
'dirs' => [
- '.'
+ '.',
],
'recursive' => true,
'ignore' => [
- 'vendor'
+ 'vendor',
],
'patterns' => [
'.php',
'.go',
- '.md'
- ]
- ]
- ]
- ]
+ '.md',
+ ],
+ ],
+ ],
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Rpc.php b/src/Configuration/Section/Rpc.php
index c25cb97..4e7e860 100644
--- a/src/Configuration/Section/Rpc.php
+++ b/src/Configuration/Section/Rpc.php
@@ -8,17 +8,17 @@ final class Rpc extends AbstractSection
{
private const NAME = 'rpc';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
- 'listen' => 'tcp://127.0.0.1:6001'
- ]
+ 'listen' => 'tcp://127.0.0.1:6001',
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/SectionInterface.php b/src/Configuration/Section/SectionInterface.php
index d9d5608..10c898b 100644
--- a/src/Configuration/Section/SectionInterface.php
+++ b/src/Configuration/Section/SectionInterface.php
@@ -6,9 +6,9 @@
interface SectionInterface
{
+ public static function getShortName(): string;
+
public function render(): array;
public function getRequired(): array;
-
- public static function getShortName(): string;
}
diff --git a/src/Configuration/Section/Server.php b/src/Configuration/Section/Server.php
index 20afe72..2699773 100644
--- a/src/Configuration/Section/Server.php
+++ b/src/Configuration/Section/Server.php
@@ -8,18 +8,18 @@ final class Server extends AbstractSection
{
private const NAME = 'server';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
'command' => 'php app.php',
- 'relay' => 'pipes'
- ]
+ 'relay' => 'pipes',
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Service.php b/src/Configuration/Section/Service.php
index 6011d1c..fdfbeb7 100644
--- a/src/Configuration/Section/Service.php
+++ b/src/Configuration/Section/Service.php
@@ -8,6 +8,11 @@ final class Service extends AbstractSection
{
private const NAME = 'service';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
@@ -16,30 +21,25 @@ public function render(): array
'command' => 'php tests/plugins/service/test_files/loop.php',
'env' => [
'foo' => 'BAR',
- 'foo2' => 'BAR2'
+ 'foo2' => 'BAR2',
],
'process_num' => 1,
'exec_timeout' => 0,
'remain_after_exit' => true,
- 'restart_sec' => 1
+ 'restart_sec' => 1,
],
'some_service_2' => [
'command' => 'binary',
'env' => [
'foo' => 'BAR',
- 'foo2' => 'BAR2'
+ 'foo2' => 'BAR2',
],
'process_num' => 1,
'exec_timeout' => 0,
'remain_after_exit' => true,
- 'restart_sec' => 1
- ]
- ]
+ 'restart_sec' => 1,
+ ],
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Sqs.php b/src/Configuration/Section/Sqs.php
index ee4dc3d..a9c1f0c 100644
--- a/src/Configuration/Section/Sqs.php
+++ b/src/Configuration/Section/Sqs.php
@@ -8,6 +8,11 @@ final class Sqs extends AbstractSection
{
private const NAME = 'sqs';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
@@ -16,13 +21,8 @@ public function render(): array
'secret' => 'api-secret',
'region' => 'us-west-1',
'session_token' => 'test',
- 'endpoint' => 'http://127.0.0.1:9324'
- ]
+ 'endpoint' => 'http://127.0.0.1:9324',
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Status.php b/src/Configuration/Section/Status.php
index 78d5d02..5ede9e1 100644
--- a/src/Configuration/Section/Status.php
+++ b/src/Configuration/Section/Status.php
@@ -8,18 +8,18 @@ final class Status extends AbstractSection
{
private const NAME = 'status';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
'address' => '127.0.0.1:2114',
- 'unavailable_status_code' => 503
- ]
+ 'unavailable_status_code' => 503,
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Tcp.php b/src/Configuration/Section/Tcp.php
index 773b597..a2c148d 100644
--- a/src/Configuration/Section/Tcp.php
+++ b/src/Configuration/Section/Tcp.php
@@ -8,6 +8,11 @@ final class Tcp extends AbstractSection
{
private const NAME = 'tcp';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
@@ -15,39 +20,34 @@ public function render(): array
'servers' => [
'server1' => [
'addr' => '127.0.0.1:7778',
-// 'delimiter' => '\r\n',
-// 'read_buf_size' => 1
+ // 'delimiter' => '\r\n',
+ // 'read_buf_size' => 1
],
-// 'server2' => [
-// 'addr' => '127.0.0.1:8811',
-// 'read_buf_size' => 10
-// ],
-// 'server3' => [
-// 'addr' => '127.0.0.1:8812',
-// 'delimiter' => '\r\n',
-// 'read_buf_size' => 1
-// ]
+ // 'server2' => [
+ // 'addr' => '127.0.0.1:8811',
+ // 'read_buf_size' => 10
+ // ],
+ // 'server3' => [
+ // 'addr' => '127.0.0.1:8812',
+ // 'delimiter' => '\r\n',
+ // 'read_buf_size' => 1
+ // ]
],
'pool' => [
'command' => '',
'num_workers' => 5,
'max_jobs' => 0,
'allocate_timeout' => '60s',
- 'destroy_timeout' => '60s'
- ]
- ]
+ 'destroy_timeout' => '60s',
+ ],
+ ],
];
}
public function getRequired(): array
{
return [
- Server::class
+ Server::class,
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Temporal.php b/src/Configuration/Section/Temporal.php
index a025b49..ae6aaae 100644
--- a/src/Configuration/Section/Temporal.php
+++ b/src/Configuration/Section/Temporal.php
@@ -8,41 +8,41 @@ final class Temporal extends AbstractSection
{
private const NAME = 'temporal';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
'address' => '127.0.0.1:7233',
-// 'cache_size' => 10000,
-// 'namespace' => 'default',
-// 'codec' => 'proto',
-// 'debug_level' => 2,
-// 'metrics' => [
-// 'address' => '127.0.0.1:9091',
-// 'type' => 'summary',
-// 'prefix' => 'foobar'
-// ],
-// 'activities' => [
-// 'debug' => false,
-// 'command' => 'php my-super-app.php',
-// 'num_workers' => 0,
-// 'max_jobs' => 64,
-// 'allocate_timeout' => '60s',
-// 'destroy_timeout' => '60s',
-// 'supervisor' => [
-// 'watch_tick' => '1s',
-// 'ttl' => '0s',
-// 'idle_ttl' => '10s',
-// 'max_worker_memory' => 128,
-// 'exec_ttl' => '60s'
-// ]
-// ]
- ]
+ // 'cache_size' => 10000,
+ // 'namespace' => 'default',
+ // 'codec' => 'proto',
+ // 'debug_level' => 2,
+ // 'metrics' => [
+ // 'address' => '127.0.0.1:9091',
+ // 'type' => 'summary',
+ // 'prefix' => 'foobar'
+ // ],
+ // 'activities' => [
+ // 'debug' => false,
+ // 'command' => 'php my-super-app.php',
+ // 'num_workers' => 0,
+ // 'max_jobs' => 64,
+ // 'allocate_timeout' => '60s',
+ // 'destroy_timeout' => '60s',
+ // 'supervisor' => [
+ // 'watch_tick' => '1s',
+ // 'ttl' => '0s',
+ // 'idle_ttl' => '10s',
+ // 'max_worker_memory' => 128,
+ // 'exec_ttl' => '60s'
+ // ]
+ // ]
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/Configuration/Section/Version.php b/src/Configuration/Section/Version.php
index 4ac72ab..0c47cc4 100644
--- a/src/Configuration/Section/Version.php
+++ b/src/Configuration/Section/Version.php
@@ -9,15 +9,15 @@ final class Version extends AbstractSection
private const NAME = 'version';
private const CONFIG_VERSION = '3';
- public function render(): array
+ public static function getShortName(): string
{
- return [
- self::NAME => self::CONFIG_VERSION
- ];
+ return self::NAME;
}
- public static function getShortName(): string
+ public function render(): array
{
- return self::NAME;
+ return [
+ self::NAME => self::CONFIG_VERSION,
+ ];
}
}
diff --git a/src/Configuration/Section/Websockets.php b/src/Configuration/Section/Websockets.php
index 80fbed1..4692d1b 100644
--- a/src/Configuration/Section/Websockets.php
+++ b/src/Configuration/Section/Websockets.php
@@ -8,19 +8,19 @@ final class Websockets extends AbstractSection
{
private const NAME = 'websockets';
+ public static function getShortName(): string
+ {
+ return self::NAME;
+ }
+
public function render(): array
{
return [
self::NAME => [
'broker' => 'default-redis',
'allowed_origin' => '*',
- 'path' => '/ws'
- ]
+ 'path' => '/ws',
+ ],
];
}
-
- public static function getShortName(): string
- {
- return self::NAME;
- }
}
diff --git a/src/DownloadProtocBinaryCommand.php b/src/DownloadProtocBinaryCommand.php
index 4179565..13ebd0b 100644
--- a/src/DownloadProtocBinaryCommand.php
+++ b/src/DownloadProtocBinaryCommand.php
@@ -33,7 +33,7 @@ final class DownloadProtocBinaryCommand extends Command
private StabilityOption $stability;
private InstallationLocationOption $location;
- public function __construct(string $name = null)
+ public function __construct(?string $name = null)
{
parent::__construct($name ?? 'download-protoc-binary');
@@ -77,7 +77,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
$output->writeln(
\sprintf(" - %s", $release->getRepositoryName()) .
\sprintf(' (%s):', $release->getVersion()) .
- ' Downloading...'
+ ' Downloading...',
);
if ($output->isVerbose()) {
@@ -102,7 +102,7 @@ private function installBinary(
ReleaseInterface $release,
AssetInterface $asset,
StyleInterface $io,
- OutputInterface $out
+ OutputInterface $out,
): ?\SplFileInfo {
$extractor = $this->assetToArchive($asset, $out)
->extract([
@@ -128,7 +128,7 @@ private function installBinary(
$extractor->next();
if (!$file->isExecutable()) {
- @chmod($file->getRealPath(), 0755);
+ @\chmod($file->getRealPath(), 0755);
}
}
@@ -154,7 +154,7 @@ private function findAsset(
RepositoryInterface $repo,
ReleasesCollection $releases,
InputInterface $in,
- StyleInterface $io
+ StyleInterface $io,
): array {
$osOption = $this->os->get($in, $io);
$archOption = $this->arch->get($in, $io);
@@ -168,8 +168,8 @@ private function findAsset(
foreach ($filtered as $release) {
$asset = $release->getAssets()
->filter(
- static fn (AssetInterface $asset): bool =>
- \str_starts_with($asset->getName(), 'protoc-gen-php-grpc')
+ static fn(AssetInterface $asset): bool =>
+ \str_starts_with($asset->getName(), 'protoc-gen-php-grpc'),
)
->whereArchitecture($archOption)
->whereOperatingSystem($osOption)
@@ -180,7 +180,7 @@ private function findAsset(
\vsprintf('%s %s does not contain available assembly (further search in progress)', [
$repo->getName(),
$release->getVersion(),
- ])
+ ]),
);
continue;
@@ -202,7 +202,7 @@ private function findAsset(
throw new \UnexpectedValueException($message);
}
- private function assetToArchive(AssetInterface $asset, OutputInterface $out, string $temp = null): ArchiveInterface
+ private function assetToArchive(AssetInterface $asset, OutputInterface $out, ?string $temp = null): ArchiveInterface
{
$factory = new Factory();
@@ -213,7 +213,7 @@ private function assetToArchive(AssetInterface $asset, OutputInterface $out, str
$progress->display();
try {
- return $factory->fromAsset($asset, function (int $size, int $total) use ($progress) {
+ return $factory->fromAsset($asset, static function (int $size, int $total) use ($progress): void {
if ($progress->getMaxSteps() !== $total) {
$progress->setMaxSteps($total);
}
diff --git a/src/Environment/Architecture.php b/src/Environment/Architecture.php
index b3fc06e..b04dc72 100644
--- a/src/Environment/Architecture.php
+++ b/src/Environment/Architecture.php
@@ -23,6 +23,7 @@ final class Architecture
* @var string
*/
public const ARCH_X86_64 = 'amd64';
+
/**
* @var string
*/
@@ -52,10 +53,6 @@ public static function all(): array
return $values;
}
- /**
- * @param string $value
- * @return bool
- */
public static function isValid(string $value): bool
{
return \in_array($value, self::all(), true);
diff --git a/src/Environment/Enum.php b/src/Environment/Enum.php
index 77ae3e2..31e2273 100644
--- a/src/Environment/Enum.php
+++ b/src/Environment/Enum.php
@@ -19,7 +19,6 @@ final class Enum
{
/**
* @param class-string $class
- * @param string $prefix
* @return array
*/
public static function values(string $class, string $prefix): array
diff --git a/src/Environment/Environment.php b/src/Environment/Environment.php
index ad86aee..57a250d 100644
--- a/src/Environment/Environment.php
+++ b/src/Environment/Environment.php
@@ -14,14 +14,10 @@
final class Environment
{
/**
- * @param string $key
- * @param string|null $default
- * @param array $variables
- * @return string|null
*
* @psalm-return ($default is string ? string : string|null)
*/
- public static function get(string $key, string $default = null, array $variables = []): ?string
+ public static function get(string $key, ?string $default = null, array $variables = []): ?string
{
/** @var mixed $result */
$result = $variables[$key] ?? $_ENV[$key] ?? $_SERVER[$key] ?? null;
diff --git a/src/Environment/OperatingSystem.php b/src/Environment/OperatingSystem.php
index a0ec6ff..8ba71a0 100644
--- a/src/Environment/OperatingSystem.php
+++ b/src/Environment/OperatingSystem.php
@@ -45,20 +45,14 @@ final class OperatingSystem
public const OS_ALPINE = 'unknown-musl';
/**
- * @param array|null $variables
* @return OperatingSystemType
*/
#[ExpectedValues(valuesFromClass: OperatingSystem::class)]
- public static function createFromGlobals(array $variables = null): string
+ public static function createFromGlobals(?array $variables = null): string
{
return (new Factory())->createFromGlobals($variables);
}
-
- /**
- * @param string $value
- * @return bool
- */
public static function isValid(string $value): bool
{
return \in_array($value, self::all(), true);
diff --git a/src/Environment/Stability.php b/src/Environment/Stability.php
index 3f856b1..30fb089 100644
--- a/src/Environment/Stability.php
+++ b/src/Environment/Stability.php
@@ -76,10 +76,6 @@ public static function all(): array
return $values;
}
- /**
- * @param string $value
- * @return bool
- */
public static function isValid(string $value): bool
{
return \in_array($value, self::all(), true);
diff --git a/src/GetBinaryCommand.php b/src/GetBinaryCommand.php
index e1a8e1c..b7c1401 100644
--- a/src/GetBinaryCommand.php
+++ b/src/GetBinaryCommand.php
@@ -39,35 +39,13 @@ class GetBinaryCommand extends Command
'Could not find any available RoadRunner binary version which meets criterion (--%s=%s --%s=%s --%s=%s). ' .
'Available: %s';
- /**
- * @var OperatingSystemOption
- */
private OperatingSystemOption $os;
-
- /**
- * @var ArchitectureOption
- */
private ArchitectureOption $arch;
-
- /**
- * @var VersionFilterOption
- */
private VersionFilterOption $version;
-
- /**
- * @var StabilityOption
- */
private StabilityOption $stability;
-
- /**
- * @var InstallationLocationOption
- */
private InstallationLocationOption $location;
- /**
- * @param string|null $name
- */
- public function __construct(string $name = null)
+ public function __construct(?string $name = null)
{
parent::__construct($name ?? 'get-binary');
@@ -78,40 +56,13 @@ public function __construct(string $name = null)
$this->stability = new StabilityOption($this);
}
- protected function configure(): void
- {
- $this->addOption(
- 'plugin',
- 'p',
- InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
- 'Generate configuration with selected plugins.'
- );
-
- $this->addOption(
- 'preset',
- null,
- InputOption::VALUE_OPTIONAL,
- 'Generate configuration with plugins in a selected preset.'
- );
-
- $this->addOption(
- 'no-config',
- null,
- InputOption::VALUE_NONE,
- 'Do not generate configuration at all.'
- );
- }
-
- /**
- * {@inheritDoc}
- */
public function getDescription(): string
{
return 'Install or update RoadRunner binary';
}
/**
- * {@inheritDoc}
+ *
* @throws \Throwable
*/
public function execute(InputInterface $input, OutputInterface $output): int
@@ -143,7 +94,7 @@ public function execute(InputInterface $input, OutputInterface $output): int
$output->writeln(
\sprintf(" - %s", $release->getRepositoryName()) .
\sprintf(' (%s):', $release->getVersion()) .
- ' Downloading...'
+ ' Downloading...',
);
if ($output->isVerbose()) {
@@ -171,20 +122,38 @@ public function execute(InputInterface $input, OutputInterface $output): int
'https://roadrunner.dev>',
// 2)
- 'To run the application, use the following command: '.
+ 'To run the application, use the following command: ' .
'$ ' . $file->getFilename() . ' serve',
]);
return 0;
}
+ protected function configure(): void
+ {
+ $this->addOption(
+ 'plugin',
+ 'p',
+ InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
+ 'Generate configuration with selected plugins.',
+ );
+
+ $this->addOption(
+ 'preset',
+ null,
+ InputOption::VALUE_OPTIONAL,
+ 'Generate configuration with plugins in a selected preset.',
+ );
+
+ $this->addOption(
+ 'no-config',
+ null,
+ InputOption::VALUE_NONE,
+ 'Do not generate configuration at all.',
+ );
+ }
+
/**
- * @param string $target
- * @param ReleaseInterface $release
- * @param AssetInterface $asset
- * @param StyleInterface $io
- * @param OutputInterface $out
- * @return \SplFileInfo|null
* @throws \Throwable
*/
private function installBinary(
@@ -192,7 +161,7 @@ private function installBinary(
ReleaseInterface $release,
AssetInterface $asset,
StyleInterface $io,
- OutputInterface $out
+ OutputInterface $out,
): ?\SplFileInfo {
$extractor = $this->assetToArchive($asset, $out)
->extract([
@@ -219,7 +188,7 @@ private function installBinary(
$extractor->next();
if (! $file->isExecutable()) {
- @chmod($file->getRealPath(), 0755);
+ @\chmod($file->getRealPath(), 0755);
}
}
@@ -230,7 +199,7 @@ private function installConfig(string $to, InputInterface $in, StyleInterface $i
{
$to .= '/.rr.yaml';
- if (\is_file($to) || \is_file(\getcwd().'/.rr.yaml')) {
+ if (\is_file($to) || \is_file(\getcwd() . '/.rr.yaml')) {
return false;
}
@@ -254,11 +223,6 @@ private function installConfig(string $to, InputInterface $in, StyleInterface $i
return true;
}
- /**
- * @param \SplFileInfo $bin
- * @param StyleInterface $io
- * @return bool
- */
private function checkExisting(\SplFileInfo $bin, StyleInterface $io): bool
{
if (\is_file($bin->getPathname())) {
@@ -275,17 +239,13 @@ private function checkExisting(\SplFileInfo $bin, StyleInterface $io): bool
}
/**
- * @param RepositoryInterface $repo
- * @param ReleasesCollection $releases
- * @param InputInterface $in
- * @param StyleInterface $io
* @return array{0: AssetInterface, 1: ReleaseInterface}
*/
private function findAsset(
RepositoryInterface $repo,
ReleasesCollection $releases,
InputInterface $in,
- StyleInterface $io
+ StyleInterface $io,
): array {
$osOption = $this->os->get($in, $io);
$archOption = $this->arch->get($in, $io);
@@ -332,13 +292,9 @@ private function findAsset(
}
/**
- * @param AssetInterface $asset
- * @param OutputInterface $out
- * @param string|null $temp
- * @return ArchiveInterface
* @throws \Throwable
*/
- private function assetToArchive(AssetInterface $asset, OutputInterface $out, string $temp = null): ArchiveInterface
+ private function assetToArchive(AssetInterface $asset, OutputInterface $out, ?string $temp = null): ArchiveInterface
{
$factory = new Factory();
@@ -349,7 +305,7 @@ private function assetToArchive(AssetInterface $asset, OutputInterface $out, str
$progress->display();
try {
- return $factory->fromAsset($asset, function (int $size, int $total) use ($progress) {
+ return $factory->fromAsset($asset, static function (int $size, int $total) use ($progress): void {
if ($progress->getMaxSteps() !== $total) {
$progress->setMaxSteps($total);
}
diff --git a/src/MakeConfigCommand.php b/src/MakeConfigCommand.php
index aafb98f..8a531da 100644
--- a/src/MakeConfigCommand.php
+++ b/src/MakeConfigCommand.php
@@ -15,31 +15,14 @@ class MakeConfigCommand extends Command
{
private InstallationLocationOption $location;
- public function __construct(string $name = null)
+ public function __construct(?string $name = null)
{
parent::__construct($name ?? 'make-config');
$this->location = new InstallationLocationOption($this);
}
- protected function configure(): void
- {
- $this->addOption(
- 'plugin',
- 'p',
- InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
- 'Generate configuration with selected plugins.'
- );
-
- $this->addOption(
- 'preset',
- null,
- InputOption::VALUE_OPTIONAL,
- 'Generate configuration with plugins in a selected preset.'
- );
- }
-
/**
- * {@inheritDoc}
+ *
* @throws \Throwable
*/
public function execute(InputInterface $input, OutputInterface $output): int
@@ -68,4 +51,21 @@ public function execute(InputInterface $input, OutputInterface $output): int
return self::SUCCESS;
}
-}
\ No newline at end of file
+
+ protected function configure(): void
+ {
+ $this->addOption(
+ 'plugin',
+ 'p',
+ InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
+ 'Generate configuration with selected plugins.',
+ );
+
+ $this->addOption(
+ 'preset',
+ null,
+ InputOption::VALUE_OPTIONAL,
+ 'Generate configuration with plugins in a selected preset.',
+ );
+ }
+}
diff --git a/src/Repository/Asset.php b/src/Repository/Asset.php
index 8e1eda6..456607c 100644
--- a/src/Repository/Asset.php
+++ b/src/Repository/Asset.php
@@ -13,37 +13,20 @@
abstract class Asset implements AssetInterface
{
- /**
- * @var string
- */
protected string $name;
-
- /**
- * @var string
- */
protected string $uri;
- /**
- * @param string $name
- * @param string $uri
- */
public function __construct(string $name, string $uri)
{
$this->name = $name;
$this->uri = $uri;
}
- /**
- * @return string
- */
public function getName(): string
{
return $this->name;
}
- /**
- * @return string
- */
public function getUri(): string
{
return $this->uri;
diff --git a/src/Repository/AssetInterface.php b/src/Repository/AssetInterface.php
index fe08aa4..b866e95 100644
--- a/src/Repository/AssetInterface.php
+++ b/src/Repository/AssetInterface.php
@@ -13,19 +13,12 @@
interface AssetInterface
{
- /**
- * @return string
- */
public function getName(): string;
- /**
- * @return string
- */
public function getUri(): string;
/**
- * @param \Closure|null $progress
* @return iterable
*/
- public function download(\Closure $progress = null): iterable;
+ public function download(?\Closure $progress = null): iterable;
}
diff --git a/src/Repository/AssetsCollection.php b/src/Repository/AssetsCollection.php
index 09302d6..781f47a 100644
--- a/src/Repository/AssetsCollection.php
+++ b/src/Repository/AssetsCollection.php
@@ -21,8 +21,9 @@ final class AssetsCollection extends Collection
*/
public function onlyRoadrunner(): self
{
- return $this->filter(static fn (AssetInterface $asset): bool =>
- \str_starts_with($asset->getName(), 'roadrunner')
+ return $this->filter(
+ static fn(AssetInterface $asset): bool =>
+ \str_starts_with($asset->getName(), 'roadrunner'),
);
}
@@ -31,30 +32,31 @@ public function onlyRoadrunner(): self
*/
public function exceptDebPackages(): self
{
- return $this->except(static fn (AssetInterface $asset): bool =>
- \str_ends_with(\strtolower($asset->getName()), '.deb')
+ return $this->except(
+ static fn(AssetInterface $asset): bool =>
+ \str_ends_with(\strtolower($asset->getName()), '.deb'),
);
}
/**
- * @param string $arch
* @return $this
*/
public function whereArchitecture(string $arch): self
{
- return $this->filter(static fn (AssetInterface $asset): bool =>
- \str_contains($asset->getName(), '-' . \strtolower($arch) . '.')
+ return $this->filter(
+ static fn(AssetInterface $asset): bool =>
+ \str_contains($asset->getName(), '-' . \strtolower($arch) . '.'),
);
}
/**
- * @param string $os
* @return $this
*/
public function whereOperatingSystem(string $os): self
{
- return $this->filter(static fn (AssetInterface $asset): bool =>
- \str_contains($asset->getName(), '-' . \strtolower($os) . '-')
+ return $this->filter(
+ static fn(AssetInterface $asset): bool =>
+ \str_contains($asset->getName(), '-' . \strtolower($os) . '-'),
);
}
}
diff --git a/src/Repository/Collection.php b/src/Repository/Collection.php
index 8fde791..87297e2 100644
--- a/src/Repository/Collection.php
+++ b/src/Repository/Collection.php
@@ -47,6 +47,7 @@ public static function create($items): self
case $items instanceof \Traversable:
$items = \iterator_to_array($items);
+ // no break
case \is_array($items):
return new static($items);
@@ -55,13 +56,12 @@ public static function create($items): self
default:
throw new \InvalidArgumentException(
- \sprintf('Unsupported iterable type %s', \get_debug_type($items))
+ \sprintf('Unsupported iterable type %s', \get_debug_type($items)),
);
}
}
/**
- * @param \Closure $generator
* @return static
*/
public static function from(\Closure $generator): self
@@ -96,7 +96,7 @@ public function map(callable $map): self
*/
public function except(callable $filter): self
{
- $callback = static fn (...$args): bool => ! $filter(...$args);
+ $callback = static fn(...$args): bool => ! $filter(...$args);
return new static(\array_filter($this->items, $callback));
}
@@ -105,7 +105,7 @@ public function except(callable $filter): self
* @param null|callable(T): bool $filter
* @return T|null
*/
- public function first(callable $filter = null): ?object
+ public function first(?callable $filter = null): ?object
{
$self = $filter === null ? $this : $this->filter($filter);
@@ -117,29 +117,22 @@ public function first(callable $filter = null): ?object
* @param null|callable(T): bool $filter
* @return T
*/
- public function firstOr(callable $otherwise, callable $filter = null): object
+ public function firstOr(callable $otherwise, ?callable $filter = null): object
{
return $this->first($filter) ?? $otherwise();
}
- /**
- * {@inheritDoc}
- */
public function getIterator(): \Traversable
{
return new \ArrayIterator($this->items);
}
- /**
- * {@inheritDoc}
- */
public function count(): int
{
return \count($this->items);
}
/**
- * @param callable $then
* @return $this
*/
public function whenEmpty(callable $then): self
@@ -151,9 +144,6 @@ public function whenEmpty(callable $then): self
return $this;
}
- /**
- * @return bool
- */
public function empty(): bool
{
return $this->items === [];
diff --git a/src/Repository/GitHub/GitHubAsset.php b/src/Repository/GitHub/GitHubAsset.php
index bd7b7cb..7f2fd8c 100644
--- a/src/Repository/GitHub/GitHubAsset.php
+++ b/src/Repository/GitHub/GitHubAsset.php
@@ -23,16 +23,8 @@
*/
final class GitHubAsset extends Asset
{
- /**
- * @var HttpClientInterface
- */
private HttpClientInterface $client;
- /**
- * @param HttpClientInterface $client
- * @param string $name
- * @param string $uri
- */
public function __construct(HttpClientInterface $client, string $name, string $uri)
{
$this->client = $client;
@@ -41,7 +33,6 @@ public function __construct(HttpClientInterface $client, string $name, string $u
}
/**
- * @param HttpClientInterface $client
* @param GitHubAssetApiResponse $asset
* @return static
*
@@ -52,14 +43,14 @@ public static function fromApiResponse(HttpClientInterface $client, array $asset
// Validate name
if (! isset($asset['name']) || ! \is_string($asset['name'])) {
throw new \InvalidArgumentException(
- 'Passed array must contain "name" value of type string'
+ 'Passed array must contain "name" value of type string',
);
}
// Validate uri
if (! isset($asset['browser_download_url']) || ! \is_string($asset['browser_download_url'])) {
throw new \InvalidArgumentException(
- 'Passed array must contain "browser_download_url" key of type string'
+ 'Passed array must contain "browser_download_url" key of type string',
);
}
@@ -67,10 +58,10 @@ public static function fromApiResponse(HttpClientInterface $client, array $asset
}
/**
- * {@inheritDoc}
+ *
* @throws ExceptionInterface
*/
- public function download(\Closure $progress = null): \Traversable
+ public function download(?\Closure $progress = null): \Traversable
{
$response = $this->client->request('GET', $this->getUri(), [
'on_progress' => $progress,
diff --git a/src/Repository/GitHub/GitHubRelease.php b/src/Repository/GitHub/GitHubRelease.php
index f1589f5..c9e1a55 100644
--- a/src/Repository/GitHub/GitHubRelease.php
+++ b/src/Repository/GitHub/GitHubRelease.php
@@ -26,16 +26,9 @@
*/
final class GitHubRelease extends Release
{
- /**
- * @var HttpClientInterface
- */
private HttpClientInterface $client;
/**
- * @param HttpClientInterface $client
- * @param string $name
- * @param string $version
- * @param string $repository
* @param iterable|array $assets
*/
public function __construct(
@@ -43,7 +36,7 @@ public function __construct(
string $name,
string $version,
string $repository,
- iterable $assets = []
+ iterable $assets = [],
) {
$this->client = $client;
@@ -51,23 +44,6 @@ public function __construct(
}
/**
- * {@inheritDoc}
- */
- public function getConfig(): string
- {
- $config = \vsprintf('https://raw.githubusercontent.com/%s/%s/.rr.yaml', [
- $this->getRepositoryName(),
- $this->getVersion(),
- ]);
-
- $response = $this->client->request('GET', $config);
-
- return $response->getContent();
- }
-
- /**
- * @param GitHubRepository $repository
- * @param HttpClientInterface $client
* @param GitHubReleaseApiResponse $release
* @return static
*/
@@ -75,7 +51,7 @@ public static function fromApiResponse(GitHubRepository $repository, HttpClientI
{
if (! isset($release['name'])) {
throw new \InvalidArgumentException(
- 'Passed array must contain "name" value of type string'
+ 'Passed array must contain "name" value of type string',
);
}
@@ -91,6 +67,18 @@ public static function fromApiResponse(GitHubRepository $repository, HttpClientI
return new self($client, $name, $version, $repository->getName(), AssetsCollection::from($instantiator));
}
+ public function getConfig(): string
+ {
+ $config = \vsprintf('https://raw.githubusercontent.com/%s/%s/.rr.yaml', [
+ $this->getRepositoryName(),
+ $this->getVersion(),
+ ]);
+
+ $response = $this->client->request('GET', $config);
+
+ return $response->getContent();
+ }
+
/**
* Returns pretty-formatted tag (release) name.
*
@@ -98,7 +86,6 @@ public static function fromApiResponse(GitHubRepository $repository, HttpClientI
* tag physically exists.
*
* @param array { tag_name: string, name: string } $release
- * @return string
*/
private static function getTagName(array $release): string
{
diff --git a/src/Repository/GitHub/GitHubRepository.php b/src/Repository/GitHub/GitHubRepository.php
index 6335b53..4351e14 100644
--- a/src/Repository/GitHub/GitHubRepository.php
+++ b/src/Repository/GitHub/GitHubRepository.php
@@ -29,14 +29,7 @@ final class GitHubRepository implements RepositoryInterface
*/
private const URL_RELEASES = 'https://api.github.com/repos/%s/releases';
- /**
- * @var HttpClientInterface
- */
private HttpClientInterface $client;
-
- /**
- * @var string
- */
private string $name;
/**
@@ -46,30 +39,19 @@ final class GitHubRepository implements RepositoryInterface
'accept' => 'application/vnd.github.v3+json',
];
- /**
- * @param string $owner
- * @param string $repository
- * @param HttpClientInterface|null $client
- */
- public function __construct(string $owner, string $repository, HttpClientInterface $client = null)
+ public function __construct(string $owner, string $repository, ?HttpClientInterface $client = null)
{
$this->name = $owner . '/' . $repository;
$this->client = $client ?? HttpClient::create();
}
- /**
- * @param string $owner
- * @param string $name
- * @param HttpClientInterface|null $client
- * @return GitHubRepository
- */
- public static function create(string $owner, string $name, HttpClientInterface $client = null): GitHubRepository
+ public static function create(string $owner, string $name, ?HttpClientInterface $client = null): GitHubRepository
{
return new GitHubRepository($owner, $name, $client);
}
/**
- * {@inheritDoc}
+ *
* @throws ExceptionInterface
*/
public function getReleases(): ReleasesCollection
@@ -88,56 +70,42 @@ public function getReleases(): ReleasesCollection
});
}
- /**
- * @param positive-int $page
- * @return ResponseInterface
- * @throws TransportExceptionInterface
- */
- private function releasesRequest(int $page): ResponseInterface
+ public function getName(): string
{
- return $this->request('GET', $this->uri(self::URL_RELEASES), [
- 'query' => [
- 'page' => $page,
- ],
- ]);
+ return $this->name;
}
/**
- * @param string $method
- * @param string $uri
- * @param array $options
- * @return ResponseInterface
* @throws TransportExceptionInterface
* @see HttpClientInterface::request()
*/
protected function request(string $method, string $uri, array $options = []): ResponseInterface
{
// Merge headers with defaults
- $options['headers'] = \array_merge($this->headers, (array)($options['headers'] ?? []));
+ $options['headers'] = \array_merge($this->headers, (array) ($options['headers'] ?? []));
return $this->client->request($method, $uri, $options);
}
/**
- * @param string $pattern
- * @return string
+ * @param positive-int $page
+ * @throws TransportExceptionInterface
*/
- private function uri(string $pattern): string
+ private function releasesRequest(int $page): ResponseInterface
{
- return \sprintf($pattern, $this->getName());
+ return $this->request('GET', $this->uri(self::URL_RELEASES), [
+ 'query' => [
+ 'page' => $page,
+ ],
+ ]);
}
- /**
- * @return string
- */
- public function getName(): string
+ private function uri(string $pattern): string
{
- return $this->name;
+ return \sprintf($pattern, $this->getName());
}
/**
- * @param ResponseInterface $response
- * @return bool
* @throws ExceptionInterface
*/
private function hasNextPage(ResponseInterface $response): bool
diff --git a/src/Repository/Release.php b/src/Repository/Release.php
index 168d237..d3d03be 100644
--- a/src/Repository/Release.php
+++ b/src/Repository/Release.php
@@ -18,38 +18,15 @@
abstract class Release implements ReleaseInterface
{
- /**
- * @var string
- */
private string $name;
- /**
- * @var string
- */
#[ExpectedValues(valuesFromClass: Stability::class)]
private string $stability;
- /**
- * @var string
- */
private string $version;
-
- /**
- * @var AssetsCollection
- */
private AssetsCollection $assets;
-
- /**
- * @var string
- */
private string $repository;
- /**
- * @param string $name
- * @param string $version
- * @param string $repository
- * @param iterable $assets
- */
public function __construct(string $name, string $version, string $repository, iterable $assets = [])
{
$this->version = $version;
@@ -61,78 +38,52 @@ public function __construct(string $name, string $version, string $repository, i
$this->stability = $this->parseStability($version);
}
- /**
- * @param string $version
- * @return string
- */
- private function parseStability(string $version): string
- {
- return VersionParser::parseStability($version);
- }
-
- /**
- * @param string $name
- * @return string
- */
- private function simplifyReleaseName(string $name): string
- {
- $version = (new VersionParser())->normalize($name);
-
- $parts = \explode('-', $version);
- $number = \substr($parts[0], 0, -2);
-
- return isset($parts[1])
- ? $number . '-' . $parts[1]
- : $number
- ;
- }
-
- /**
- * {@inheritDoc}
- */
public function getName(): string
{
return $this->name;
}
- /**
- * {@inheritDoc}
- */
public function getVersion(): string
{
return $this->version;
}
- /**
- * @return string
- */
public function getRepositoryName(): string
{
return $this->repository;
}
- /**
- * {@inheritDoc}
- */
#[ExpectedValues(valuesFromClass: Stability::class)]
public function getStability(): string
{
return $this->stability;
}
- /**
- * {@inheritDoc}
- */
public function getAssets(): AssetsCollection
{
return $this->assets;
}
- /**
- * {@inheritDoc}
- */
public function satisfies(string $constraint): bool
{
return Semver::satisfies($this->getName(), $constraint);
}
+
+ private function parseStability(string $version): string
+ {
+ return VersionParser::parseStability($version);
+ }
+
+ private function simplifyReleaseName(string $name): string
+ {
+ $version = (new VersionParser())->normalize($name);
+
+ $parts = \explode('-', $version);
+ $number = \substr($parts[0], 0, -2);
+
+ return isset($parts[1])
+ ? $number . '-' . $parts[1]
+ : $number
+ ;
+ }
}
diff --git a/src/Repository/ReleaseInterface.php b/src/Repository/ReleaseInterface.php
index 4302f0e..5828d6e 100644
--- a/src/Repository/ReleaseInterface.php
+++ b/src/Repository/ReleaseInterface.php
@@ -22,7 +22,6 @@ interface ReleaseInterface
/**
* Returns Composer's compatible "pretty" release version.
*
- * @return string
*/
public function getName(): string;
@@ -31,13 +30,9 @@ public function getName(): string;
* Please note that this version may not be compatible with Composer's
* comparators.
*
- * @return string
*/
public function getVersion(): string;
- /**
- * @return string
- */
public function getRepositoryName(): string;
/**
@@ -51,14 +46,7 @@ public function getStability(): string;
*/
public function getAssets(): AssetsCollection;
- /**
- * @param string $constraint
- * @return bool
- */
public function satisfies(string $constraint): bool;
- /**
- * @return string
- */
public function getConfig(): string;
}
diff --git a/src/Repository/ReleasesCollection.php b/src/Repository/ReleasesCollection.php
index 559a025..3048f0d 100644
--- a/src/Repository/ReleasesCollection.php
+++ b/src/Repository/ReleasesCollection.php
@@ -20,7 +20,6 @@
final class ReleasesCollection extends Collection
{
/**
- * @param string ...$constraints
* @return $this
*/
public function satisfies(string ...$constraints): self
@@ -35,7 +34,6 @@ public function satisfies(string ...$constraints): self
}
/**
- * @param string ...$constraints
* @return $this
*/
public function notSatisfies(string ...$constraints): self
@@ -49,34 +47,14 @@ public function notSatisfies(string ...$constraints): self
return $result;
}
- /**
- * @param array $constraints
- * @return array
- */
- private function constraints(array $constraints): array
- {
- $result = [];
-
- foreach ($constraints as $constraint) {
- foreach (\explode('|', $constraint) as $expression) {
- $result[] = $expression;
- }
- }
-
- return \array_unique(
- \array_filter(
- \array_map('\\trim', $result)
- )
- );
- }
-
/**
* @return $this
*/
public function withAssets(): self
{
- return $this->filter(static fn(ReleaseInterface $r): bool => ! $r->getAssets()
- ->empty()
+ return $this->filter(
+ static fn(ReleaseInterface $r): bool => ! $r->getAssets()
+ ->empty(),
);
}
@@ -96,18 +74,6 @@ public function sortByVersion(): self
return new self($result);
}
- /**
- * @param ReleaseInterface $release
- * @return string
- */
- private function comparisonVersionString(ReleaseInterface $release): string
- {
- $stability = $release->getStability();
- $weight = Stability::toInt($stability);
-
- return \str_replace('-' . $stability, '.' . $weight . '.', $release->getVersion());
- }
-
/**
* @return $this
*/
@@ -135,8 +101,37 @@ public function minimumStability(string $stability): self
{
$weight = Stability::toInt($stability);
- return $this->filter(function (ReleaseInterface $release) use ($weight): bool {
+ return $this->filter(static function (ReleaseInterface $release) use ($weight): bool {
return Stability::toInt($release->getStability()) >= $weight;
});
}
+
+ /**
+ * @param array $constraints
+ * @return array
+ */
+ private function constraints(array $constraints): array
+ {
+ $result = [];
+
+ foreach ($constraints as $constraint) {
+ foreach (\explode('|', $constraint) as $expression) {
+ $result[] = $expression;
+ }
+ }
+
+ return \array_unique(
+ \array_filter(
+ \array_map('\\trim', $result),
+ ),
+ );
+ }
+
+ private function comparisonVersionString(ReleaseInterface $release): string
+ {
+ $stability = $release->getStability();
+ $weight = Stability::toInt($stability);
+
+ return \str_replace('-' . $stability, '.' . $weight . '.', $release->getVersion());
+ }
}
diff --git a/src/Repository/RepositoriesCollection.php b/src/Repository/RepositoriesCollection.php
index 62a05f5..6ebfd2b 100644
--- a/src/Repository/RepositoriesCollection.php
+++ b/src/Repository/RepositoriesCollection.php
@@ -26,17 +26,11 @@ public function __construct(array $repositories)
$this->repositories = $repositories;
}
- /**
- * @return string
- */
public function getName(): string
{
return 'unknown/unknown';
}
- /**
- * @return ReleasesCollection
- */
public function getReleases(): ReleasesCollection
{
return ReleasesCollection::from(function () {
diff --git a/src/Repository/RepositoryInterface.php b/src/Repository/RepositoryInterface.php
index ba130d4..fe1ba66 100644
--- a/src/Repository/RepositoryInterface.php
+++ b/src/Repository/RepositoryInterface.php
@@ -13,9 +13,6 @@
interface RepositoryInterface
{
- /**
- * @return string
- */
public function getName(): string;
/**
diff --git a/src/Repository/Version1/StaticRepository.php b/src/Repository/Version1/StaticRepository.php
index d477f46..785ccac 100644
--- a/src/Repository/Version1/StaticRepository.php
+++ b/src/Repository/Version1/StaticRepository.php
@@ -1213,15 +1213,9 @@ final class StaticRepository implements RepositoryInterface
*/
private array $releases = [];
- /**
- * @var HttpClientInterface
- */
private HttpClientInterface $client;
- /**
- * @param HttpClientInterface|null $client
- */
- public function __construct(HttpClientInterface $client = null)
+ public function __construct(?HttpClientInterface $client = null)
{
$this->client = $client ?? HttpClient::create();
@@ -1230,9 +1224,18 @@ public function __construct(HttpClientInterface $client = null)
}
}
+ public function getName(): string
+ {
+ return 'spiral/roadrunner';
+ }
+
+ public function getReleases(): ReleasesCollection
+ {
+ return new ReleasesCollection($this->releases);
+ }
+
/**
* @param array{name: string, version: string, assets: array} $release
- * @return ReleaseInterface
*/
private function createRelease(array $release): ReleaseInterface
{
@@ -1247,27 +1250,9 @@ private function createRelease(array $release): ReleaseInterface
/**
* @param array{name: string, uri: string} $asset
- * @return AssetInterface
*/
private function createAsset(array $asset): AssetInterface
{
return new GitHubAsset($this->client, $asset['name'], $asset['uri']);
}
-
- /**
- * {@inheritDoc}
- */
- public function getName(): string
- {
- return 'spiral/roadrunner';
- }
-
- /**
- * {@inheritDoc}
- */
- public function getReleases(): ReleasesCollection
- {
- return new ReleasesCollection($this->releases);
- }
}
-
diff --git a/src/VersionsCommand.php b/src/VersionsCommand.php
index 24b5779..7521c51 100644
--- a/src/VersionsCommand.php
+++ b/src/VersionsCommand.php
@@ -24,30 +24,12 @@
class VersionsCommand extends Command
{
- /**
- * @var OperatingSystemOption
- */
private OperatingSystemOption $os;
-
- /**
- * @var ArchitectureOption
- */
private ArchitectureOption $arch;
-
- /**
- * @var VersionFilterOption
- */
private VersionFilterOption $version;
-
- /**
- * @var StabilityOption
- */
private StabilityOption $stability;
- /**
- * @param string|null $name
- */
- public function __construct(string $name = null)
+ public function __construct(?string $name = null)
{
parent::__construct($name ?? 'versions');
@@ -63,17 +45,11 @@ protected function default(): string
};
}
- /**
- * {@inheritDoc}
- */
public function getDescription(): string
{
return 'Returns a list of all available RoadRunner versions';
}
- /**
- * {@inheritDoc}
- */
public function execute(InputInterface $input, OutputInterface $output): int
{
$io = $this->io($input, $output);
@@ -108,12 +84,6 @@ public function execute(InputInterface $input, OutputInterface $output): int
return 0;
}
- /**
- * @param ReleaseInterface $release
- * @param InputInterface $input
- * @param StyleInterface $io
- * @return string
- */
private function compatibilityToString(ReleaseInterface $release, InputInterface $input, StyleInterface $io): string
{
$template = ' ✖ > (reason: %s)';
@@ -132,7 +102,7 @@ private function compatibilityToString(ReleaseInterface $release, InputInterface
// Validate OS
$assets = $assets->whereOperatingSystem(
- $os = $this->os->get($input, $io)
+ $os = $this->os->get($input, $io),
);
if ($assets->empty()) {
@@ -141,7 +111,7 @@ private function compatibilityToString(ReleaseInterface $release, InputInterface
// Validate architecture
$assets = $assets->whereArchitecture(
- $arch = $this->arch->get($input, $io)
+ $arch = $this->arch->get($input, $io),
);
if ($assets->empty()) {
@@ -151,19 +121,11 @@ private function compatibilityToString(ReleaseInterface $release, InputInterface
return ' ✓ >';
}
- /**
- * @param ReleaseInterface $release
- * @return string
- */
private function versionToString(ReleaseInterface $release): string
{
return $release->getName();
}
- /**
- * @param ReleaseInterface $release
- * @return string
- */
private function stabilityToString(ReleaseInterface $release): string
{
$stability = $release->getStability();
@@ -186,10 +148,6 @@ private function stabilityToString(ReleaseInterface $release): string
}
}
- /**
- * @param ReleaseInterface $release
- * @return string
- */
private function assetsToString(ReleaseInterface $release): string
{
$count = $release->getAssets()