diff --git a/src/Action/ConfigurationApplier.php b/src/Action/ConfigurationApplier.php index 014be7b1..1dcc4011 100644 --- a/src/Action/ConfigurationApplier.php +++ b/src/Action/ConfigurationApplier.php @@ -10,7 +10,7 @@ final class ConfigurationApplier { - private ?Satellite\Action\Action $action = null; + private ?Action $action = null; private array $packages = []; public function __construct( @@ -22,7 +22,7 @@ public function __construct( public function withAction(): self { - $this->action = new Satellite\Action\Action($this->plugin, clone $this->interpreter); + $this->action = new Action($this->plugin, clone $this->interpreter); return $this; } diff --git a/src/Action/Custom/Factory/Action.php b/src/Action/Custom/Factory/Action.php index 2780917c..eb70c1ec 100644 --- a/src/Action/Custom/Factory/Action.php +++ b/src/Action/Custom/Factory/Action.php @@ -63,7 +63,7 @@ public function validate(array $config): bool /** * @throws Configurator\ConfigurationExceptionInterface */ - public function compile(array $config): Custom\Factory\Repository\Action + public function compile(array $config): Repository\Action { $containerName = sprintf('ProjectServiceContainer%s', ByteString::fromRandom(8)->toString()); @@ -74,7 +74,7 @@ public function compile(array $config): Custom\Factory\Repository\Action $container = (new SatelliteDependencyInjection(...$this->providers))($config); - $repository = new Custom\Factory\Repository\Action($builder); + $repository = new Repository\Action($builder); $dumper = new PhpDumper($container); $repository->addFiles( diff --git a/src/Action/Custom/Service.php b/src/Action/Custom/Service.php index a7694a1c..0bc55314 100644 --- a/src/Action/Custom/Service.php +++ b/src/Action/Custom/Service.php @@ -4,7 +4,6 @@ namespace Kiboko\Component\Satellite\Action\Custom; -use Kiboko\Component\Satellite\Action\Custom; use Kiboko\Component\Satellite\ExpressionLanguage as Satellite; use Kiboko\Contract\Configurator; use Symfony\Component\Config\Definition\Exception as Symfony; @@ -26,7 +25,7 @@ public function __construct( private ExpressionLanguage $interpreter = new Satellite\ExpressionLanguage() ) { $this->processor = new Processor(); - $this->configuration = new Custom\Configuration(); + $this->configuration = new Configuration(); } public function interpreter(): ExpressionLanguage @@ -78,7 +77,7 @@ public function compile(array $config): Configurator\RepositoryInterface } } - $actionFactory = new Custom\Factory\Action($this->interpreter); + $actionFactory = new Factory\Action($this->interpreter); return $actionFactory->compile($config); } diff --git a/src/Adapter/ComposerFailureException.php b/src/Adapter/ComposerFailureException.php index ab012812..dcf19b37 100644 --- a/src/Adapter/ComposerFailureException.php +++ b/src/Adapter/ComposerFailureException.php @@ -6,7 +6,7 @@ final class ComposerFailureException extends \RuntimeException { - public function __construct(private readonly string $command = '', string $message = '', int $code = 0, \Throwable $previous = null) + public function __construct(private readonly string $command = '', string $message = '', int $code = 0, ?\Throwable $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/src/Adapter/Docker/SatelliteBuilder.php b/src/Adapter/Docker/SatelliteBuilder.php index 1ad2594c..e50c58c1 100644 --- a/src/Adapter/Docker/SatelliteBuilder.php +++ b/src/Adapter/Docker/SatelliteBuilder.php @@ -23,8 +23,8 @@ final class SatelliteBuilder implements Configurator\SatelliteBuilderInterface private iterable $command = []; /** @var iterable */ private iterable $tags = []; - private null|PackagingContract\AssetInterface|PackagingContract\FileInterface $composerJsonFile = null; - private null|PackagingContract\AssetInterface|PackagingContract\FileInterface $composerLockFile = null; + private PackagingContract\AssetInterface|PackagingContract\FileInterface|null $composerJsonFile = null; + private PackagingContract\AssetInterface|PackagingContract\FileInterface|null $composerLockFile = null; /** @var iterable> */ private iterable $paths = []; /** @var \AppendIterator> */ @@ -67,7 +67,7 @@ public function withComposerRequire(string ...$package): self public function withComposerFile( PackagingContract\AssetInterface|PackagingContract\FileInterface $composerJsonFile, - PackagingContract\AssetInterface|PackagingContract\FileInterface $composerLockFile = null + PackagingContract\AssetInterface|PackagingContract\FileInterface|null $composerLockFile = null ): self { $this->composerJsonFile = $composerJsonFile; $this->composerLockFile = $composerLockFile; @@ -77,7 +77,7 @@ public function withComposerFile( public function withFile( PackagingContract\AssetInterface|PackagingContract\FileInterface $source, - string $destinationPath = null + ?string $destinationPath = null ): self { if (!$source instanceof PackagingContract\FileInterface) { $source = new Packaging\VirtualFile($source); @@ -92,7 +92,7 @@ public function withFile( return $this; } - public function withDirectory(PackagingContract\DirectoryInterface $source, string $destinationPath = null): self + public function withDirectory(PackagingContract\DirectoryInterface $source, ?string $destinationPath = null): self { $this->paths[] = [$source->getPath(), $destinationPath ?? $source->getPath()]; diff --git a/src/Adapter/Filesystem/SatelliteBuilder.php b/src/Adapter/Filesystem/SatelliteBuilder.php index 1a400c38..8e2c4e13 100644 --- a/src/Adapter/Filesystem/SatelliteBuilder.php +++ b/src/Adapter/Filesystem/SatelliteBuilder.php @@ -20,8 +20,8 @@ final class SatelliteBuilder implements Configurator\SatelliteBuilderInterface ]; private array $authenticationTokens = []; private array $repositories = []; - private null|PackagingContract\AssetInterface|PackagingContract\FileInterface $composerJsonFile = null; - private null|PackagingContract\AssetInterface|PackagingContract\FileInterface $composerLockFile = null; + private PackagingContract\AssetInterface|PackagingContract\FileInterface|null $composerJsonFile = null; + private PackagingContract\AssetInterface|PackagingContract\FileInterface|null $composerLockFile = null; /** @var iterable> */ private iterable $paths = []; /** @var \AppendIterator> */ @@ -55,7 +55,7 @@ public function withComposerRequire(string ...$package): self public function withComposerFile( PackagingContract\AssetInterface|PackagingContract\FileInterface $composerJsonFile, - PackagingContract\AssetInterface|PackagingContract\FileInterface $composerLockFile = null + PackagingContract\AssetInterface|PackagingContract\FileInterface|null $composerLockFile = null ): self { $this->composerJsonFile = $composerJsonFile; $this->composerLockFile = $composerLockFile; @@ -65,7 +65,7 @@ public function withComposerFile( public function withFile( PackagingContract\AssetInterface|PackagingContract\FileInterface $source, - string $destinationPath = null + ?string $destinationPath = null ): self { if (!$source instanceof PackagingContract\FileInterface) { $source = new Packaging\VirtualFile($source); @@ -80,7 +80,7 @@ public function withFile( return $this; } - public function withDirectory(PackagingContract\DirectoryInterface $source, string $destinationPath = null): self + public function withDirectory(PackagingContract\DirectoryInterface $source, ?string $destinationPath = null): self { $this->paths[] = [$source->getPath(), $destinationPath ?? $source->getPath()]; diff --git a/src/Adapter/Tar/SatelliteBuilder.php b/src/Adapter/Tar/SatelliteBuilder.php index 68c89afd..650b9511 100644 --- a/src/Adapter/Tar/SatelliteBuilder.php +++ b/src/Adapter/Tar/SatelliteBuilder.php @@ -13,8 +13,8 @@ final class SatelliteBuilder implements Configurator\SatelliteBuilderInterface { /** @var iterable */ private iterable $composerRequire = []; - private null|PackagingContract\AssetInterface|PackagingContract\FileInterface $composerJsonFile = null; - private null|PackagingContract\AssetInterface|PackagingContract\FileInterface $composerLockFile = null; + private PackagingContract\AssetInterface|PackagingContract\FileInterface|null $composerJsonFile = null; + private PackagingContract\AssetInterface|PackagingContract\FileInterface|null $composerLockFile = null; /** @var \AppendIterator> */ private readonly iterable $files; /** @var array> */ @@ -48,7 +48,7 @@ public function withComposerRequire(string ...$package): self public function withComposerFile( PackagingContract\AssetInterface|PackagingContract\FileInterface $composerJsonFile, - PackagingContract\AssetInterface|PackagingContract\FileInterface $composerLockFile = null + PackagingContract\AssetInterface|PackagingContract\FileInterface|null $composerLockFile = null ): self { $this->composerJsonFile = $composerJsonFile; $this->composerLockFile = $composerLockFile; @@ -58,7 +58,7 @@ public function withComposerFile( public function withFile( PackagingContract\AssetInterface|PackagingContract\FileInterface $source, - string $destinationPath = null + ?string $destinationPath = null ): self { if (!$source instanceof PackagingContract\FileInterface) { $source = new Packaging\VirtualFile($source); @@ -71,7 +71,7 @@ public function withFile( return $this; } - public function withDirectory(PackagingContract\DirectoryInterface $source, string $destinationPath = null): self + public function withDirectory(PackagingContract\DirectoryInterface $source, ?string $destinationPath = null): self { $this->files->append(new \RecursiveIteratorIterator($source, \RecursiveIteratorIterator::SELF_FIRST)); diff --git a/src/Cloud/Auth.php b/src/Cloud/Auth.php index 838a87b1..d88cd87c 100644 --- a/src/Cloud/Auth.php +++ b/src/Cloud/Auth.php @@ -13,7 +13,7 @@ final class Auth private string $pathName; private array $configuration; - public function __construct(string $pathName = null) + public function __construct(?string $pathName = null) { if (null === $pathName) { $this->pathName = getenv('HOME').'/.gyroscops/'; diff --git a/src/Cloud/CommandBus.php b/src/Cloud/CommandBus.php index ce856758..2cf8e03c 100644 --- a/src/Cloud/CommandBus.php +++ b/src/Cloud/CommandBus.php @@ -5,7 +5,6 @@ namespace Kiboko\Component\Satellite\Cloud; use Gyroscops\Api\Client; -use Kiboko\Component\Satellite; use React\Promise\Deferred; use React\Promise\PromiseInterface; @@ -22,16 +21,16 @@ public function __construct( public static function withStandardHandlers(Client $client): self { return new self([ - Satellite\Cloud\Command\Pipeline\DeclarePipelineCommand::class => new Satellite\Cloud\Handler\Pipeline\DeclarePipelineCommandHandler($client), - Satellite\Cloud\Command\Pipeline\AddPipelineComposerPSR4AutoloadCommand::class => new Satellite\Cloud\Handler\Pipeline\AddPipelineComposerPSR4AutoloadCommandHandler($client), - Satellite\Cloud\Command\Pipeline\AppendPipelineStepCommand::class => new Satellite\Cloud\Handler\Pipeline\AppendPipelineStepCommandHandler($client), - Satellite\Cloud\Command\Pipeline\RemovePipelineCommand::class => new Satellite\Cloud\Handler\Pipeline\RemovePipelineCommandHandler($client), - Satellite\Cloud\Command\Pipeline\AddAfterPipelineStepCommand::class => new Satellite\Cloud\Handler\Pipeline\AddAfterPipelineStepCommandHandler($client), - Satellite\Cloud\Command\Pipeline\AddBeforePipelineStepCommand::class => new Satellite\Cloud\Handler\Pipeline\AddBeforePipelineStepCommandHandler($client), - Satellite\Cloud\Command\Pipeline\ReplacePipelineStepCommand::class => new Satellite\Cloud\Handler\Pipeline\ReplacePipelineStepCommandHandler($client), - Satellite\Cloud\Command\Pipeline\RemovePipelineStepCommand::class => new Satellite\Cloud\Handler\Pipeline\RemovePipelineStepCommandHandler($client), - Satellite\Cloud\Command\Workflow\DeclareWorkflowCommand::class => new Satellite\Cloud\Handler\Workflow\DeclareWorkflowCommandHandler($client), - Satellite\Cloud\Command\Workflow\RemoveWorkflowCommand::class => new Satellite\Cloud\Handler\Workflow\RemoveWorkflowCommandHandler($client), + Command\Pipeline\DeclarePipelineCommand::class => new Handler\Pipeline\DeclarePipelineCommandHandler($client), + Command\Pipeline\AddPipelineComposerPSR4AutoloadCommand::class => new Handler\Pipeline\AddPipelineComposerPSR4AutoloadCommandHandler($client), + Command\Pipeline\AppendPipelineStepCommand::class => new Handler\Pipeline\AppendPipelineStepCommandHandler($client), + Command\Pipeline\RemovePipelineCommand::class => new Handler\Pipeline\RemovePipelineCommandHandler($client), + Command\Pipeline\AddAfterPipelineStepCommand::class => new Handler\Pipeline\AddAfterPipelineStepCommandHandler($client), + Command\Pipeline\AddBeforePipelineStepCommand::class => new Handler\Pipeline\AddBeforePipelineStepCommandHandler($client), + Command\Pipeline\ReplacePipelineStepCommand::class => new Handler\Pipeline\ReplacePipelineStepCommandHandler($client), + Command\Pipeline\RemovePipelineStepCommand::class => new Handler\Pipeline\RemovePipelineStepCommandHandler($client), + Command\Workflow\DeclareWorkflowCommand::class => new Handler\Workflow\DeclareWorkflowCommandHandler($client), + Command\Workflow\RemoveWorkflowCommand::class => new Handler\Workflow\RemoveWorkflowCommandHandler($client), ]); } diff --git a/src/Cloud/DTO/JobList.php b/src/Cloud/DTO/JobList.php index 6dc57b87..c19c7821 100644 --- a/src/Cloud/DTO/JobList.php +++ b/src/Cloud/DTO/JobList.php @@ -4,14 +4,12 @@ namespace Kiboko\Component\Satellite\Cloud\DTO; -use Kiboko\Component\Satellite\Cloud\DTO; - readonly class JobList implements \Countable, \IteratorAggregate { private array $jobs; public function __construct( - DTO\Workflow\JobInterface ...$job, + Workflow\JobInterface ...$job, ) { $this->jobs = $job; } @@ -21,7 +19,7 @@ public function getIterator(): \Traversable $jobs = $this->jobs; /* @phpstan-ignore-next-line */ - usort($jobs, fn (DTO\Workflow\JobInterface $left, DTO\Workflow\JobInterface $right) => $left->order <=> $right->order); + usort($jobs, fn (Workflow\JobInterface $left, Workflow\JobInterface $right) => $left->order <=> $right->order); return new \ArrayIterator($jobs); } @@ -31,13 +29,13 @@ public function codes(): array $jobs = $this->jobs; /* @phpstan-ignore-next-line */ - usort($jobs, fn (DTO\Workflow\JobInterface $left, DTO\Workflow\JobInterface $right) => $left->order <=> $right->order); + usort($jobs, fn (Workflow\JobInterface $left, Workflow\JobInterface $right) => $left->order <=> $right->order); /* @phpstan-ignore-next-line */ - return array_map(fn (DTO\Workflow\JobInterface $job) => $job->code->asString(), $jobs); + return array_map(fn (Workflow\JobInterface $job) => $job->code->asString(), $jobs); } - public function get(string $code): DTO\Workflow\JobInterface + public function get(string $code): Workflow\JobInterface { foreach ($this->jobs as $job) { if ($job->code->asString() === $code) { diff --git a/src/Cloud/Normalizer/ExpressionNormalizer.php b/src/Cloud/Normalizer/ExpressionNormalizer.php index 3d26e4e7..a4f62820 100644 --- a/src/Cloud/Normalizer/ExpressionNormalizer.php +++ b/src/Cloud/Normalizer/ExpressionNormalizer.php @@ -9,12 +9,12 @@ class ExpressionNormalizer implements NormalizerInterface { - public function normalize(mixed $object, string $format = null, array $context = []): string + public function normalize(mixed $object, ?string $format = null, array $context = []): string { return (string) $object; } - public function supportsNormalization(mixed $data, string $format = null): bool + public function supportsNormalization(mixed $data, ?string $format = null): bool { return $data instanceof Expression; } diff --git a/src/ConfigLoader.php b/src/ConfigLoader.php index f299dfe0..d0045329 100644 --- a/src/ConfigLoader.php +++ b/src/ConfigLoader.php @@ -4,11 +4,10 @@ namespace Kiboko\Component\Satellite; -use Kiboko\Component\Satellite; use Kiboko\Contract\Configurator\InvalidConfigurationException; use Symfony\Component\Config; -class ConfigLoader implements Satellite\ConfigLoaderInterface +class ConfigLoader implements ConfigLoaderInterface { public function __construct(private readonly string $basePath) { @@ -120,8 +119,8 @@ public function loadFile(string $file): array $locator = new Config\FileLocator([$this->basePath]); $loaderResolver = new Config\Loader\LoaderResolver([ - new Satellite\Console\Config\YamlFileLoader($locator), - new Satellite\Console\Config\JsonFileLoader($locator), + new Console\Config\YamlFileLoader($locator), + new Console\Config\JsonFileLoader($locator), ]); $delegatingLoader = new Config\Loader\DelegatingLoader($loaderResolver); diff --git a/src/ExpressionLanguage/ExpressionLanguage.php b/src/ExpressionLanguage/ExpressionLanguage.php index 391fe305..99f955ad 100644 --- a/src/ExpressionLanguage/ExpressionLanguage.php +++ b/src/ExpressionLanguage/ExpressionLanguage.php @@ -9,7 +9,7 @@ final class ExpressionLanguage extends BaseExpressionLanguage { - public function __construct(CacheItemPoolInterface $cache = null, array $providers = []) + public function __construct(?CacheItemPoolInterface $cache = null, array $providers = []) { parent::__construct($cache, [ ...$providers, diff --git a/src/Feature/Logger/Builder/Monolog/GelfBuilder.php b/src/Feature/Logger/Builder/Monolog/GelfBuilder.php index c5f91540..9e15116f 100644 --- a/src/Feature/Logger/Builder/Monolog/GelfBuilder.php +++ b/src/Feature/Logger/Builder/Monolog/GelfBuilder.php @@ -25,7 +25,7 @@ public function withLevel(string $level): self return $this; } - public function withTCPTransport(string $host = null, int $port = null): self + public function withTCPTransport(?string $host = null, ?int $port = null): self { $this->transport = 'tcp'; $this->host = $host; @@ -34,7 +34,7 @@ public function withTCPTransport(string $host = null, int $port = null): self return $this; } - public function withAMQPTransport(string $queue, string $channel, string $vhost, string $host = null, int $port = null, float $timeout = null): self + public function withAMQPTransport(string $queue, string $channel, string $vhost, ?string $host = null, ?int $port = null, ?float $timeout = null): self { $this->transport = 'amqp'; $this->queue = $queue; diff --git a/src/Feature/Logger/Factory/ElasticSearchFactory.php b/src/Feature/Logger/Factory/ElasticSearchFactory.php index 4e681b5a..7e265448 100644 --- a/src/Feature/Logger/Factory/ElasticSearchFactory.php +++ b/src/Feature/Logger/Factory/ElasticSearchFactory.php @@ -53,7 +53,7 @@ public function validate(array $config): bool return false; } - public function compile(array $config): Logger\Factory\Repository\ElasticSearchRepository + public function compile(array $config): Repository\ElasticSearchRepository { $builder = new Logger\Builder\Monolog\ElasticSearchBuilder($this->interpreter); @@ -69,6 +69,6 @@ public function compile(array $config): Logger\Factory\Repository\ElasticSearchR $builder->withIndex($config['index']); } - return new Logger\Factory\Repository\ElasticSearchRepository($builder); + return new Repository\ElasticSearchRepository($builder); } } diff --git a/src/Feature/Logger/Factory/GelfFactory.php b/src/Feature/Logger/Factory/GelfFactory.php index d510c07d..c7017afe 100644 --- a/src/Feature/Logger/Factory/GelfFactory.php +++ b/src/Feature/Logger/Factory/GelfFactory.php @@ -50,7 +50,7 @@ public function validate(array $config): bool return false; } - public function compile(array $config): Logger\Factory\Repository\GelfRepository + public function compile(array $config): Repository\GelfRepository { $builder = new Logger\Builder\Monolog\GelfBuilder(); @@ -74,6 +74,6 @@ public function compile(array $config): Logger\Factory\Repository\GelfRepository ); } - return new Logger\Factory\Repository\GelfRepository($builder); + return new Repository\GelfRepository($builder); } } diff --git a/src/Feature/Logger/Factory/StreamFactory.php b/src/Feature/Logger/Factory/StreamFactory.php index 2c98d56c..0048058d 100644 --- a/src/Feature/Logger/Factory/StreamFactory.php +++ b/src/Feature/Logger/Factory/StreamFactory.php @@ -50,7 +50,7 @@ public function validate(array $config): bool return false; } - public function compile(array $config): Logger\Factory\Repository\StreamRepository + public function compile(array $config): Repository\StreamRepository { $builder = new Logger\Builder\Monolog\StreamBuilder($config['path']); @@ -66,6 +66,6 @@ public function compile(array $config): Logger\Factory\Repository\StreamReposito $builder->withLocking($config['use_locking']); } - return new Logger\Factory\Repository\StreamRepository($builder); + return new Repository\StreamRepository($builder); } } diff --git a/src/Feature/Logger/Factory/SyslogFactory.php b/src/Feature/Logger/Factory/SyslogFactory.php index 30d9fd6e..9d2ad46c 100644 --- a/src/Feature/Logger/Factory/SyslogFactory.php +++ b/src/Feature/Logger/Factory/SyslogFactory.php @@ -50,7 +50,7 @@ public function validate(array $config): bool return false; } - public function compile(array $config): Logger\Factory\Repository\SyslogRepository + public function compile(array $config): Repository\SyslogRepository { $builder = new Logger\Builder\Monolog\SyslogBuilder($config['ident']); @@ -66,6 +66,6 @@ public function compile(array $config): Logger\Factory\Repository\SyslogReposito $builder->withLogopts($config['logopts']); } - return new Logger\Factory\Repository\SyslogRepository($builder); + return new Repository\SyslogRepository($builder); } } diff --git a/src/Feature/Rejection/Factory/RabbitMQFactory.php b/src/Feature/Rejection/Factory/RabbitMQFactory.php index 66813ca4..7de68b4f 100644 --- a/src/Feature/Rejection/Factory/RabbitMQFactory.php +++ b/src/Feature/Rejection/Factory/RabbitMQFactory.php @@ -55,7 +55,7 @@ public function validate(array $config): bool return false; } - public function compile(array $config): Rejection\Factory\Repository\RabbitMQRepository + public function compile(array $config): Repository\RabbitMQRepository { $builder = new Rejection\Builder\RabbitMQBuilder( stepUuid: compileValueWhenExpression($this->interpreter, uniqid()), @@ -76,6 +76,6 @@ public function compile(array $config): Rejection\Factory\Repository\RabbitMQRep $builder->withExchange(compileValueWhenExpression($this->interpreter, $config['exchange'])); } - return new Rejection\Factory\Repository\RabbitMQRepository($builder); + return new Repository\RabbitMQRepository($builder); } } diff --git a/src/Plugin/Custom/Factory/Extractor.php b/src/Plugin/Custom/Factory/Extractor.php index 848688bc..5690023d 100644 --- a/src/Plugin/Custom/Factory/Extractor.php +++ b/src/Plugin/Custom/Factory/Extractor.php @@ -63,7 +63,7 @@ public function validate(array $config): bool /** * @throws Configurator\ConfigurationExceptionInterface */ - public function compile(array $config): Custom\Factory\Repository\Extractor + public function compile(array $config): Repository\Extractor { $containerName = sprintf('ProjectServiceContainer%s', ByteString::fromRandom(8)->toString()); @@ -74,7 +74,7 @@ public function compile(array $config): Custom\Factory\Repository\Extractor $container = (new SatelliteDependencyInjection(...$this->providers))($config); - $repository = new Custom\Factory\Repository\Extractor($builder); + $repository = new Repository\Extractor($builder); $dumper = new PhpDumper($container); $repository->addFiles( diff --git a/src/Plugin/Custom/Factory/Loader.php b/src/Plugin/Custom/Factory/Loader.php index 9fd5d1b3..69a17a52 100644 --- a/src/Plugin/Custom/Factory/Loader.php +++ b/src/Plugin/Custom/Factory/Loader.php @@ -63,7 +63,7 @@ public function validate(array $config): bool /** * @throws Configurator\ConfigurationExceptionInterface */ - public function compile(array $config): Custom\Factory\Repository\Loader + public function compile(array $config): Repository\Loader { $containerName = sprintf('ProjectServiceContainer%s', ByteString::fromRandom(8)->toString()); @@ -74,7 +74,7 @@ public function compile(array $config): Custom\Factory\Repository\Loader $container = (new SatelliteDependencyInjection(...$this->providers))($config); - $repository = new Custom\Factory\Repository\Loader($builder); + $repository = new Repository\Loader($builder); $dumper = new PhpDumper($container); $repository->addFiles( diff --git a/src/Plugin/Custom/Factory/Transformer.php b/src/Plugin/Custom/Factory/Transformer.php index e1c29e41..5beb12e3 100644 --- a/src/Plugin/Custom/Factory/Transformer.php +++ b/src/Plugin/Custom/Factory/Transformer.php @@ -63,7 +63,7 @@ public function validate(array $config): bool /** * @throws Configurator\ConfigurationExceptionInterface */ - public function compile(array $config): Custom\Factory\Repository\Transformer + public function compile(array $config): Repository\Transformer { $containerName = sprintf('ProjectServiceContainer%s', ByteString::fromRandom(8)->toString()); @@ -74,7 +74,7 @@ public function compile(array $config): Custom\Factory\Repository\Transformer $container = (new SatelliteDependencyInjection(...$this->providers))($config); - $repository = new Custom\Factory\Repository\Transformer($builder); + $repository = new Repository\Transformer($builder); $dumper = new PhpDumper($container); $repository->addFiles( diff --git a/src/Plugin/Custom/Service.php b/src/Plugin/Custom/Service.php index de5fdf72..6e2fe4f4 100644 --- a/src/Plugin/Custom/Service.php +++ b/src/Plugin/Custom/Service.php @@ -5,7 +5,6 @@ namespace Kiboko\Component\Satellite\Plugin\Custom; use Kiboko\Component\Satellite\ExpressionLanguage as Satellite; -use Kiboko\Component\Satellite\Plugin\Custom; use Kiboko\Contract\Configurator; use Symfony\Component\Config\Definition\Exception as Symfony; use Symfony\Component\Config\Definition\Processor; @@ -30,7 +29,7 @@ public function __construct( private ExpressionLanguage $interpreter = new Satellite\ExpressionLanguage() ) { $this->processor = new Processor(); - $this->configuration = new Custom\Configuration(); + $this->configuration = new Configuration(); } public function interpreter(): ExpressionLanguage @@ -83,13 +82,13 @@ public function compile(array $config): Configurator\RepositoryInterface } if (\array_key_exists('extractor', $config)) { - return (new Custom\Factory\Extractor($interpreter, $config['expression_language'] ?? []))->compile($config['extractor']); + return (new Factory\Extractor($interpreter, $config['expression_language'] ?? []))->compile($config['extractor']); } if (\array_key_exists('transformer', $config)) { - return (new Custom\Factory\Transformer($interpreter, $config['expression_language'] ?? []))->compile($config['transformer']); + return (new Factory\Transformer($interpreter, $config['expression_language'] ?? []))->compile($config['transformer']); } if (\array_key_exists('loader', $config)) { - return (new Custom\Factory\Loader($interpreter, $config['expression_language'] ?? []))->compile($config['loader']); + return (new Factory\Loader($interpreter, $config['expression_language'] ?? []))->compile($config['loader']); } throw new \RuntimeException('No possible pipeline step, expecting "extractor", "transformer" or "loader".'); diff --git a/src/Plugin/FTP/Factory/Loader.php b/src/Plugin/FTP/Factory/Loader.php index f9caa4a7..3d74988d 100644 --- a/src/Plugin/FTP/Factory/Loader.php +++ b/src/Plugin/FTP/Factory/Loader.php @@ -63,7 +63,7 @@ public function compile(array $config): RepositoryInterface && \is_array($config['loader']['servers']) ) { foreach ($config['loader']['servers'] as $server) { - $serverFactory = new FTP\Factory\Server($this->interpreter); + $serverFactory = new Server($this->interpreter); $builder->addServerBasePath(compileValueWhenExpression($this->interpreter, $server['base_path'])); $loader = $serverFactory->compile($server); @@ -87,7 +87,7 @@ public function compile(array $config): RepositoryInterface } try { - return new FTP\Factory\Repository\Repository($builder); + return new Repository\Repository($builder); } catch (Symfony\InvalidConfigurationException|Symfony\InvalidTypeException $exception) { throw new Configurator\InvalidConfigurationException(message: $exception->getMessage(), previous: $exception); } diff --git a/src/Plugin/FTP/Factory/Server.php b/src/Plugin/FTP/Factory/Server.php index 8bd71dd2..d490bbfc 100644 --- a/src/Plugin/FTP/Factory/Server.php +++ b/src/Plugin/FTP/Factory/Server.php @@ -54,7 +54,7 @@ public function validate(array $config): bool } } - public function compile(array $config): FTP\Factory\Repository\Repository + public function compile(array $config): Repository\Repository { $builder = new FTP\Builder\Server(compileValueWhenExpression($this->interpreter, $config['host']), compileValueWhenExpression($this->interpreter, $config['port']), compileValueWhenExpression($this->interpreter, $config['timeout'])); @@ -74,7 +74,7 @@ public function compile(array $config): FTP\Factory\Repository\Repository $builder->withPassiveMode(compileValueWhenExpression($this->interpreter, $config['passif_mode'])); try { - return new FTP\Factory\Repository\Repository($builder); + return new Repository\Repository($builder); } catch (Symfony\InvalidConfigurationException|Symfony\InvalidTypeException $exception) { throw new Configurator\InvalidConfigurationException(message: $exception->getMessage(), previous: $exception); } diff --git a/src/Plugin/Filtering/Factory/Drop.php b/src/Plugin/Filtering/Factory/Drop.php index 4648a092..0736b536 100644 --- a/src/Plugin/Filtering/Factory/Drop.php +++ b/src/Plugin/Filtering/Factory/Drop.php @@ -59,13 +59,13 @@ public function validate(array $config): bool /** * @throws Configurator\ConfigurationExceptionInterface */ - public function compile(array $config): Filtering\Factory\Repository\Drop + public function compile(array $config): Repository\Drop { $interpreter = clone $this->interpreter; $builder = new Filtering\Builder\Drop(); - $repository = new Filtering\Factory\Repository\Drop($builder); + $repository = new Repository\Drop($builder); foreach ($config as $condition) { $builder->withExclusions( diff --git a/src/Plugin/Filtering/Factory/Reject.php b/src/Plugin/Filtering/Factory/Reject.php index 3de1a3c8..73cb67a0 100644 --- a/src/Plugin/Filtering/Factory/Reject.php +++ b/src/Plugin/Filtering/Factory/Reject.php @@ -59,13 +59,13 @@ public function validate(array $config): bool /** * @throws Configurator\ConfigurationExceptionInterface */ - public function compile(array $config): Filtering\Factory\Repository\Reject + public function compile(array $config): Repository\Reject { $interpreter = clone $this->interpreter; $builder = new Filtering\Builder\Reject(); - $repository = new Filtering\Factory\Repository\Reject($builder); + $repository = new Repository\Reject($builder); foreach ($config as $condition) { $builder->withExclusions( diff --git a/src/Plugin/Filtering/Service.php b/src/Plugin/Filtering/Service.php index 364773a1..525ef830 100644 --- a/src/Plugin/Filtering/Service.php +++ b/src/Plugin/Filtering/Service.php @@ -5,7 +5,6 @@ namespace Kiboko\Component\Satellite\Plugin\Filtering; use Kiboko\Component\Satellite\ExpressionLanguage as Satellite; -use Kiboko\Component\Satellite\Plugin\Filtering; use Kiboko\Contract\Configurator; use Symfony\Component\Config\Definition\Exception as Symfony; use Symfony\Component\Config\Definition\Processor; @@ -26,7 +25,7 @@ public function __construct( private ExpressionLanguage $interpreter = new Satellite\ExpressionLanguage() ) { $this->processor = new Processor(); - $this->configuration = new Filtering\Configuration(); + $this->configuration = new Configuration(); } public function interpreter(): ExpressionLanguage @@ -79,11 +78,11 @@ public function compile(array $config): Configurator\RepositoryInterface } if (\array_key_exists('reject', $config)) { - return (new Filtering\Factory\Reject($interpreter, $config['expression_language'] ?? []))->compile($config['reject']); + return (new Factory\Reject($interpreter, $config['expression_language'] ?? []))->compile($config['reject']); } if (\array_key_exists('drop', $config)) { - return (new Filtering\Factory\Drop($interpreter, $config['expression_language'] ?? []))->compile($config['drop']); + return (new Factory\Drop($interpreter, $config['expression_language'] ?? []))->compile($config['drop']); } throw new \RuntimeException('No possible pipeline step, expecting "extractor", "transformer" or "loader".'); diff --git a/src/Plugin/SFTP/Builder/Server.php b/src/Plugin/SFTP/Builder/Server.php index dbbef64c..1e90198f 100644 --- a/src/Plugin/SFTP/Builder/Server.php +++ b/src/Plugin/SFTP/Builder/Server.php @@ -77,7 +77,7 @@ public function withPasswordAuthentication(Node\Expr $username, Node\Expr $passw return $this; } - public function withPrivateKeyAuthentication(Node\Expr $username, Node\Expr $publicKey, Node\Expr $privateKey, Node\Expr $privateKeyPassphrase = null): self + public function withPrivateKeyAuthentication(Node\Expr $username, Node\Expr $publicKey, Node\Expr $privateKey, ?Node\Expr $privateKeyPassphrase = null): self { $this->username = $username; $this->publicKey = $publicKey; diff --git a/src/Plugin/SFTP/Factory/Extractor.php b/src/Plugin/SFTP/Factory/Extractor.php index 0d5ea13d..dc4e97ed 100644 --- a/src/Plugin/SFTP/Factory/Extractor.php +++ b/src/Plugin/SFTP/Factory/Extractor.php @@ -63,7 +63,7 @@ public function compile(array $config): Repository && \is_array($config['loader']['servers']) ) { foreach ($config['loader']['servers'] as $server) { - $serverFactory = new SFTP\Factory\Server($this->interpreter); + $serverFactory = new Server($this->interpreter); $loader = $serverFactory->compile($server); $serverBuilder = $loader->getBuilder(); diff --git a/src/Plugin/SFTP/Factory/Loader.php b/src/Plugin/SFTP/Factory/Loader.php index 6ef47e8b..e24b3611 100644 --- a/src/Plugin/SFTP/Factory/Loader.php +++ b/src/Plugin/SFTP/Factory/Loader.php @@ -63,7 +63,7 @@ public function compile(array $config): Repository && \is_array($config['loader']['servers']) ) { foreach ($config['loader']['servers'] as $server) { - $serverFactory = new SFTP\Factory\Server($this->interpreter); + $serverFactory = new Server($this->interpreter); $loader = $serverFactory->compile($server); $serverBuilder = $loader->getBuilder(); diff --git a/src/Plugin/SFTP/Factory/Server.php b/src/Plugin/SFTP/Factory/Server.php index 1a2f7d02..2dc65062 100644 --- a/src/Plugin/SFTP/Factory/Server.php +++ b/src/Plugin/SFTP/Factory/Server.php @@ -54,7 +54,7 @@ public function validate(array $config): bool } } - public function compile(array $config): SFTP\Factory\Repository\Repository + public function compile(array $config): Repository\Repository { $builder = new SFTP\Builder\Server(compileValueWhenExpression($this->interpreter, $config['host']), compileValueWhenExpression($this->interpreter, $config['port'])); @@ -83,7 +83,7 @@ public function compile(array $config): SFTP\Factory\Repository\Repository } try { - return new SFTP\Factory\Repository\Repository($builder); + return new Repository\Repository($builder); } catch (Symfony\InvalidConfigurationException|Symfony\InvalidTypeException $exception) { throw new Configurator\InvalidConfigurationException(message: $exception->getMessage(), previous: $exception); } diff --git a/src/Runtime/RuntimeChoice.php b/src/Runtime/RuntimeChoice.php index 3dccba45..8d0feb8a 100644 --- a/src/Runtime/RuntimeChoice.php +++ b/src/Runtime/RuntimeChoice.php @@ -17,18 +17,18 @@ public function __construct( ) { } - public function __invoke(array $configuration): Satellite\Runtime\RuntimeInterface + public function __invoke(array $configuration): RuntimeInterface { $satellite = ($this->adapterChoice)($configuration)->build(); if (\array_key_exists('http_api', $configuration)) { - $factory = new Satellite\Runtime\Api\Factory(); + $factory = new Api\Factory(); } elseif (\array_key_exists('http_hook', $configuration)) { - $factory = new Satellite\Runtime\HttpHook\Factory(); + $factory = new HttpHook\Factory(); } elseif (\array_key_exists('pipeline', $configuration)) { - $factory = new Satellite\Runtime\Pipeline\Factory(); + $factory = new Pipeline\Factory(); } elseif (\array_key_exists('workflow', $configuration)) { - $factory = new Satellite\Runtime\Workflow\Factory(); + $factory = new Workflow\Factory(); } else { throw new \RuntimeException('No compatible runtime was found for your satellite configuration.'); } diff --git a/src/Service.php b/src/Service.php index e73fe8b2..d72448f0 100644 --- a/src/Service.php +++ b/src/Service.php @@ -18,7 +18,7 @@ final class Service implements Configurator\FactoryInterface { private readonly Processor $processor; - private readonly Satellite\Configuration $configuration; + private readonly Configuration $configuration; private readonly ExpressionLanguage $interpreter; /** @var array */ private array $adapters = []; @@ -35,16 +35,16 @@ final class Service implements Configurator\FactoryInterface /** @var array */ private array $actionPlugins = []; - public function __construct(ExpressionLanguage $expressionLanguage = null) + public function __construct(?ExpressionLanguage $expressionLanguage = null) { $this->processor = new Processor(); - $this->configuration = new Satellite\Configuration(); + $this->configuration = new Configuration(); $this->interpreter = $expressionLanguage ?? new Satellite\ExpressionLanguage\ExpressionLanguage(); } - public function adapterChoice(): Satellite\Adapter\AdapterChoice + public function adapterChoice(): Adapter\AdapterChoice { - return new Satellite\Adapter\AdapterChoice($this->adapters); + return new Adapter\AdapterChoice($this->adapters); } private function addAdapter(Configurator\Adapter $attribute, Configurator\Adapter\FactoryInterface $adapter): self @@ -55,7 +55,7 @@ private function addAdapter(Configurator\Adapter $attribute, Configurator\Adapte return $this; } - private function addRuntime(Configurator\Runtime $attribute, Satellite\Runtime\FactoryInterface $runtime): self + private function addRuntime(Configurator\Runtime $attribute, Runtime\FactoryInterface $runtime): self { $this->runtimes[$attribute->name] = $runtime; $this->configuration->addRuntime($attribute->name, $runtime->configuration()); @@ -87,7 +87,7 @@ private function addPipelinePlugin( $this->configuration->addPlugin($attribute->name, $plugin->configuration()); $this->pipelines[$attribute->name] = $plugin; - $this->plugins[$attribute->name] = $applier = new Satellite\Pipeline\ConfigurationApplier($attribute->name, $plugin, $plugin->interpreter()); + $this->plugins[$attribute->name] = $applier = new Pipeline\ConfigurationApplier($attribute->name, $plugin, $plugin->interpreter()); $applier->withPackages(...$attribute->dependencies); foreach ($attribute->steps as $step) { @@ -112,7 +112,7 @@ private function addAction( $this->configuration->addAction($attribute->name, $action->configuration()); $this->actions[$attribute->name] = $action; - $this->actionPlugins[$attribute->name] = $applier = new Satellite\Action\ConfigurationApplier($attribute->name, $action, $action->interpreter()); + $this->actionPlugins[$attribute->name] = $applier = new Action\ConfigurationApplier($attribute->name, $action, $action->interpreter()); $applier->withPackages(...$attribute->dependencies); $applier->withAction(); @@ -128,14 +128,14 @@ public function registerAdapters(Configurator\Adapter\FactoryInterface ...$adapt foreach (expectAttributes($adapter, Configurator\Adapter::class) as $attribute) { $this->addAdapter($attribute, $adapter); } - } catch (Satellite\MissingAttributeException) { + } catch (MissingAttributeException) { } } return $this; } - public function registerRuntimes(Satellite\Runtime\FactoryInterface ...$runtimes): self + public function registerRuntimes(Runtime\FactoryInterface ...$runtimes): self { foreach ($runtimes as $runtime) { /** @var Configurator\Runtime $attribute */ @@ -225,13 +225,13 @@ public function compile(array $config): Configurator\RepositoryInterface throw new \LogicException('Not implemented'); } - private function compileWorkflow(array $config): Satellite\Builder\Repository\Workflow + private function compileWorkflow(array $config): Builder\Repository\Workflow { - $workflow = new Satellite\Builder\Workflow( + $workflow = new Builder\Workflow( new Node\Expr\Variable('runtime') ); - $repository = new Satellite\Builder\Repository\Workflow($workflow); + $repository = new Builder\Repository\Workflow($workflow); $repository->addPackages( 'php-etl/satellite-contracts:>=0.1.1 <0.2', @@ -274,7 +274,7 @@ private function compileWorkflow(array $config): Satellite\Builder\Repository\Wo 'runtime.php', new Packaging\Asset\AST( new Node\Stmt\Return_( - (new Satellite\Builder\Workflow\WorkflowRuntime())->getNode() + (new Builder\Workflow\WorkflowRuntime())->getNode() ) ) ) @@ -291,7 +291,7 @@ private function compileWorkflow(array $config): Satellite\Builder\Repository\Wo $pipelineFilename, new Packaging\Asset\AST( new Node\Stmt\Return_( - (new Satellite\Builder\Workflow\PipelineBuilder($pipeline->getBuilder()))->getNode() + (new Builder\Workflow\PipelineBuilder($pipeline->getBuilder()))->getNode() ) ) ) @@ -308,7 +308,7 @@ private function compileWorkflow(array $config): Satellite\Builder\Repository\Wo $actionFilename, new Packaging\Asset\AST( new Node\Stmt\Return_( - (new Satellite\Builder\Workflow\ActionBuilder($action->getBuilder()))->getNode() + (new Builder\Workflow\ActionBuilder($action->getBuilder()))->getNode() ) ) ) @@ -323,13 +323,13 @@ private function compileWorkflow(array $config): Satellite\Builder\Repository\Wo return $repository; } - private function compilePipelineJob(array $config): Satellite\Builder\Repository\Pipeline + private function compilePipelineJob(array $config): Builder\Repository\Pipeline { - $pipeline = new Satellite\Builder\Pipeline( + $pipeline = new Builder\Pipeline( new Node\Expr\Variable('runtime'), ); - $repository = new Satellite\Builder\Repository\Pipeline($pipeline); + $repository = new Builder\Repository\Pipeline($pipeline); $repository->addPackages( 'php-etl/satellite-contracts:>=0.1.1 <0.2', @@ -360,13 +360,13 @@ private function compilePipelineJob(array $config): Satellite\Builder\Repository return $repository; } - private function compileActionJob(array $config): Satellite\Builder\Repository\Action + private function compileActionJob(array $config): Builder\Repository\Action { - $action = new Satellite\Builder\Action( + $action = new Builder\Action( new Node\Expr\Variable('runtime'), ); - $repository = new Satellite\Builder\Repository\Action($action); + $repository = new Builder\Repository\Action($action); $actions = array_intersect_key($this->actionPlugins, $config['action']); foreach ($actions as $action) { @@ -376,7 +376,7 @@ private function compileActionJob(array $config): Satellite\Builder\Repository\A return $repository; } - private function compilePipeline(array $config): Satellite\Builder\Repository\Pipeline + private function compilePipeline(array $config): Builder\Repository\Pipeline { $repository = $this->compilePipelineJob($config); @@ -411,7 +411,7 @@ private function compilePipeline(array $config): Satellite\Builder\Repository\Pi 'runtime.php', new Packaging\Asset\AST( new Node\Stmt\Return_( - (new Satellite\Builder\Pipeline\ConsoleRuntime())->getNode() + (new Builder\Pipeline\ConsoleRuntime())->getNode() ) ) ) @@ -420,11 +420,11 @@ private function compilePipeline(array $config): Satellite\Builder\Repository\Pi return $repository; } - private function compileApi(array $config): Satellite\Builder\Repository\API + private function compileApi(array $config): Builder\Repository\API { - $apiBuilder = new Satellite\Builder\API(); + $apiBuilder = new Builder\API(); - $repository = new Satellite\Builder\Repository\API($apiBuilder); + $repository = new Builder\Repository\API($apiBuilder); $pipelineMapping = []; @@ -440,7 +440,7 @@ private function compileApi(array $config): Satellite\Builder\Repository\API $pipelineFilename, new Packaging\Asset\AST( new Node\Stmt\Return_( - (new Satellite\Builder\API\PipelineBuilder($pipeline->getBuilder()))->getNode() + (new Builder\API\PipelineBuilder($pipeline->getBuilder()))->getNode() ) ) ) @@ -492,7 +492,7 @@ private function compileApi(array $config): Satellite\Builder\Repository\API 'hook.php', new Packaging\Asset\AST( new Node\Stmt\Return_( - (new Satellite\Builder\Hook\HookRuntime())->getNode() + (new Builder\Hook\HookRuntime())->getNode() ) ) ) @@ -503,7 +503,7 @@ private function compileApi(array $config): Satellite\Builder\Repository\API 'runtime.php', new Packaging\Asset\AST( new Node\Stmt\Return_( - (new Satellite\Builder\API\APIRuntime())->getNode() + (new Builder\API\APIRuntime())->getNode() ) ) ) @@ -524,11 +524,11 @@ private function compileApi(array $config): Satellite\Builder\Repository\API return $repository; } - private function compileHook(array $config): Satellite\Builder\Repository\Hook + private function compileHook(array $config): Builder\Repository\Hook { - $hookBuilder = new Satellite\Builder\Hook(); + $hookBuilder = new Builder\Hook(); - $repository = new Satellite\Builder\Repository\Hook($hookBuilder); + $repository = new Builder\Repository\Hook($hookBuilder); $repository->addFiles( new Packaging\File( @@ -563,7 +563,7 @@ private function compileHook(array $config): Satellite\Builder\Repository\Hook 'runtime.php', new Packaging\Asset\AST( new Node\Stmt\Return_( - (new Satellite\Builder\Hook\HookRuntime())->getNode() + (new Builder\Hook\HookRuntime())->getNode() ) ) ) @@ -591,7 +591,7 @@ private function compileHook(array $config): Satellite\Builder\Repository\Hook $pipelineFilename, new Packaging\Asset\AST( new Node\Stmt\Return_( - (new Satellite\Builder\Hook\PipelineBuilder($pipeline->getBuilder()))->getNode() + (new Builder\Hook\PipelineBuilder($pipeline->getBuilder()))->getNode() ) ) )