From 7538b2c73f6882ce7c651b4b839d7b57ca03ecb4 Mon Sep 17 00:00:00 2001 From: sebprt Date: Wed, 26 Jun 2024 16:04:07 +0200 Subject: [PATCH 1/8] Added some composer authentication types --- src/Adapter/Composer.php | 57 ++++++++++++++++++ src/Adapter/Docker/Factory.php | 9 ++- src/Adapter/Docker/SatelliteBuilder.php | 65 +++++++++++++++++++- src/Adapter/Filesystem/Factory.php | 9 ++- src/Adapter/Filesystem/SatelliteBuilder.php | 67 ++++++++++++++++++++- src/Feature/Composer/Configuration.php | 54 ++++++++++++++++- 6 files changed, 253 insertions(+), 8 deletions(-) diff --git a/src/Adapter/Composer.php b/src/Adapter/Composer.php index 611c5de7..2fb2af99 100644 --- a/src/Adapter/Composer.php +++ b/src/Adapter/Composer.php @@ -219,4 +219,61 @@ public function addAuthenticationToken(string $url, string $token): void $token ); } + + public function addGitlabOauthAuthentication(string $token, string $url = 'gitlab.com'): void + { + $this->command( + 'composer', + 'config', + '--auth', + sprintf('gitlab-oauth.%s', $url), + 'token', + $token + ); + } + + public function addGitlabTokenAuthentication(string $token, string $url = 'gitlab.com'): void + { + $this->command( + 'composer', + 'config', + '--auth', + sprintf('gitlab-token.%s', $url), + $token + ); + } + + public function addGithubOauthAuthentication(string $token): void + { + $this->command( + 'composer', + 'config', + '--auth', + 'github-oauth.github.com', + $token + ); + } + + public function addHttpBasicAuthentication(string $url, string $username, string $password): void + { + $this->command( + 'composer', + 'config', + '--auth', + sprintf('http-basic.%s', $url), + $username, + $password, + ); + } + + public function addHttpBearerAuthentication(string $url, string $token): void + { + $this->command( + 'composer', + 'config', + '--auth', + sprintf('bearer.%s', $url), + $token + ); + } } diff --git a/src/Adapter/Docker/Factory.php b/src/Adapter/Docker/Factory.php index 5c47ae94..ca6e23ba 100644 --- a/src/Adapter/Docker/Factory.php +++ b/src/Adapter/Docker/Factory.php @@ -76,7 +76,14 @@ public function __invoke(array $configuration): Configurator\SatelliteBuilderInt if (\array_key_exists('auth', $configuration['composer']) && (is_countable($configuration['composer']['auth']) ? \count($configuration['composer']['auth']) : 0) > 0) { foreach ($configuration['composer']['auth'] as $auth) { - $builder->withComposerAuthenticationToken($auth['url'], $auth['token']); + match ($auth['type']) { + 'gitlab-oauth' => $builder->withGitlabOauthAuthentication($auth['token'], $auth['url'] ?? 'gitlab.com'), + 'gitlab-token' => $builder->withGitlabTokenAuthentication($auth['token'], $auth['url'] ?? 'gitlab.com'), + 'github-oauth' => $builder->withGithubOauthAuthentication($auth['token'], $auth['url'] ?? 'github.com'), + 'http-basic' => $builder->withHttpBasicAuthentication($auth['url'], $auth['username'], $auth['password']), + 'http-bearer' => $builder->withHttpBearerAuthentication($auth['url'], $auth['token']), + default => throw new \LogicException(), + }; } } } diff --git a/src/Adapter/Docker/SatelliteBuilder.php b/src/Adapter/Docker/SatelliteBuilder.php index 1ad2594c..59b35d71 100644 --- a/src/Adapter/Docker/SatelliteBuilder.php +++ b/src/Adapter/Docker/SatelliteBuilder.php @@ -132,6 +132,60 @@ public function withComposerAuthenticationToken(string $url, string $auth): self return $this; } + public function withGithubOauthAuthentication(string $token, string $url = 'github.com'): self + { + $this->authenticationTokens[$url] = [ + 'type' => 'github-token', + 'url' => $url, + 'token' => $token + ]; + + return $this; + } + + public function withGitlabOauthAuthentication(string $token, string $url = 'gitlab.com'): self + { + $this->authenticationTokens[$url] = [ + 'type' => 'gitlab-oauth', + 'url' => $url, + 'token' => $token + ]; + + return $this; + } + + public function withGitlabTokenAuthentication(string $token, string $url = 'gitlab.com'): self + { + $this->authenticationTokens[$url] = [ + 'type' => 'gitlab-token', + 'url' => $url, + 'token' => $token + ]; + + return $this; + } + + public function withHttpBasicAuthentication(string $url, string $username, string $password): self + { + $this->authenticationTokens[$url] = [ + 'type' => 'http-basic', + 'username' => $username, + 'password' => $password, + ]; + + return $this; + } + + public function withHttpBearerAuthentication(string $url, string $token): self + { + $this->authenticationTokens[$url] = [ + 'type' => 'http-bearer', + 'token' => $token + ]; + + return $this; + } + public function withTags(string ...$tags): self { $this->tags = $tags; @@ -201,8 +255,15 @@ public function build(): Configurator\SatelliteInterface } if (\count($this->authenticationTokens) > 0) { - foreach ($this->authenticationTokens as $url => $token) { - $dockerfile->push(new Dockerfile\PHP\ComposerAuthenticationToken($url, $token)); + foreach ($this->authenticationTokens as $url => $authentication) { + match ($authentication['type']) { + 'gitlab-oauth' => $dockerfile->push(new Dockerfile\PHP\ComposerGitlabOauthAuthentication($authentication['token'])), + 'gitlab-token' => $dockerfile->push(new Dockerfile\PHP\ComposerGitlabTokenAuthentication($authentication['token'])), + 'github-oauth' => $dockerfile->push(new Dockerfile\PHP\ComposerGithubOauthAuthentication($authentication['token'])), + 'http-basic' => $dockerfile->push(new Dockerfile\PHP\ComposerHttpBasicAuthentication($url, $authentication['username'], $authentication['password'])), + 'http-bearer' => $dockerfile->push(new Dockerfile\PHP\ComposerHttpBearerAuthentication($url, $authentication['token'])), + default => new \LogicException(), + }; } } diff --git a/src/Adapter/Filesystem/Factory.php b/src/Adapter/Filesystem/Factory.php index 31f63d5f..f1b2b8e1 100644 --- a/src/Adapter/Filesystem/Factory.php +++ b/src/Adapter/Filesystem/Factory.php @@ -58,7 +58,14 @@ public function __invoke(array $configuration): Configurator\SatelliteBuilderInt if (\array_key_exists('auth', $configuration['composer']) && (is_countable($configuration['composer']['auth']) ? \count($configuration['composer']['auth']) : 0) > 0) { foreach ($configuration['composer']['auth'] as $auth) { - $builder->withAuthenticationToken($auth['url'], $auth['token']); + match ($auth['type']) { + 'gitlab-oauth' => $builder->withGitlabOauthAuthentication($auth['token'], $auth['url'] ?? 'gitlab.com'), + 'gitlab-token' => $builder->withGitlabTokenAuthentication($auth['token'], $auth['url'] ?? 'gitlab.com'), + 'github-oauth' => $builder->withGithubOauthAuthentication($auth['token'], $auth['url'] ?? 'github.com'), + 'http-basic' => $builder->withHttpBasicAuthentication($auth['url'], $auth['username'], $auth['password']), + 'http-bearer' => $builder->withHttpBearerAuthentication($auth['url'], $auth['token']), + default => throw new \LogicException(), + }; } } } diff --git a/src/Adapter/Filesystem/SatelliteBuilder.php b/src/Adapter/Filesystem/SatelliteBuilder.php index 1a400c38..532bbf66 100644 --- a/src/Adapter/Filesystem/SatelliteBuilder.php +++ b/src/Adapter/Filesystem/SatelliteBuilder.php @@ -106,6 +106,62 @@ public function withAuthenticationToken(string $domain, string $auth): self return $this; } + public function withGitlabOauthAuthentication(string $token, string $domain = 'gitlab.com'): self + { + $this->authenticationTokens[$domain] = [ + 'type' => 'gitlab-oauth', + 'url' => $domain, + 'token' => $token, + ]; + + return $this; + } + + public function withGitlabTokenAuthentication(string $token, string $domain = 'gitlab.com'): self + { + $this->authenticationTokens[$domain] = [ + 'type' => 'gitlab-token', + 'url' => $domain, + 'token' => $token, + ]; + + return $this; + } + + public function withGithubOauthAuthentication(string $token, string $domain = 'github.com'): self + { + $this->authenticationTokens[$domain] = [ + 'type' => 'github-oauth', + 'url' => $domain, + 'token' => $token, + ]; + + return $this; + } + + public function withHttpBasicAuthentication(string $domain, string $username, string $password): self + { + $this->authenticationTokens[$domain] = [ + 'type' => 'http-basic', + 'url' => $domain, + 'username' => $username, + 'password' => $password, + ]; + + return $this; + } + + public function withHttpBearerAuthentication(string $domain, string $token): self + { + $this->authenticationTokens[$domain] = [ + 'type' => 'http-basic', + 'url' => $domain, + 'token' => $token, + ]; + + return $this; + } + public function build(): Configurator\SatelliteInterface { if (!file_exists($this->workdir)) { @@ -153,8 +209,15 @@ public function build(): Configurator\SatelliteInterface } if (\count($this->authenticationTokens) > 0) { - foreach ($this->authenticationTokens as $url => $token) { - $composer->addAuthenticationToken($url, $token); + foreach ($this->authenticationTokens as $url => $authentication) { + match ($authentication['type']) { + 'gitlab-oauth' => $composer->addGitlabOauthAuthentication($authentication['token']), + 'gitlab-token' => $composer->addGitlabTokenAuthentication($authentication['token']), + 'github-oauth' => $composer->addGithubOauthAuthentication($authentication['token']), + 'http-basic' => $composer->addHttpBasicAuthentication($url, $authentication['username'], $authentication['password']), + 'http-bearer' => $composer->addHttpBearerAuthentication($url, $authentication['token']), + default => $composer->addAuthenticationToken($url, $authentication['token']), + }; } } diff --git a/src/Feature/Composer/Configuration.php b/src/Feature/Composer/Configuration.php index 8d88c12d..61d3fefb 100644 --- a/src/Feature/Composer/Configuration.php +++ b/src/Feature/Composer/Configuration.php @@ -71,14 +71,64 @@ public function getConfigTreeBuilder(): TreeBuilder ->end() ->arrayNode('auth') ->arrayPrototype() + ->beforeNormalization() + ->always(function ($value) { + if (isset($value['url']) && isset($value['token']) && !isset($value['type'])) { + $value['type'] = 'http-basic'; + $value['url'] = substr($value['url'], strpos($value['url'], 'http-basic.') + strlen('http-basic.')); + $value['username'] = $value['username'] ?? 'token'; + $value['password'] = $value['password'] ?? $value['token']; + unset($value['token']); + } + + return $value; + }) + ->end() + ->validate() + ->always(function ($v) { + switch ($v['type']) { + case 'http-basic': + if (empty($v['url']) || empty($v['username']) || empty($v['password'])) { + throw new \InvalidArgumentException('For http-basic auth, url, username, and password are required.'); + } + break; + case 'http-bearer': + if (empty($v['url']) || empty($v['token'])) { + throw new \InvalidArgumentException('For http-bearer auth, url and token are required.'); + } + break; + default: + if (empty($v['token'])) { + throw new \InvalidArgumentException('For gitlab-oauth, gitlab-token or github-oauth, only token is required and url is optional.'); + } + break; + } + return $v; + }) + ->end() ->children() - ->scalarNode('url')->isRequired()->end() + ->enumNode('type') + ->isRequired() + ->values(['http-basic', 'http-bearer', 'gitlab-oauth', 'gitlab-token', 'github-oauth']) + ->end() + ->scalarNode('url')->end() ->scalarNode('token') ->validate() ->ifTrue(isExpression()) ->then(asExpression()) ->end() - ->isRequired() + ->end() + ->scalarNode('username') + ->validate() + ->ifTrue(isExpression()) + ->then(asExpression()) + ->end() + ->end() + ->scalarNode('password') + ->validate() + ->ifTrue(isExpression()) + ->then(asExpression()) + ->end() ->end() ->end() ->end() From d0f3a06f0993f10fd1b1e2ba3a8d153527cf4a97 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Wed, 26 Jun 2024 14:21:34 +0000 Subject: [PATCH 2/8] [rector] Rector fixes --- src/Feature/Composer/Configuration.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Feature/Composer/Configuration.php b/src/Feature/Composer/Configuration.php index 61d3fefb..6715777a 100644 --- a/src/Feature/Composer/Configuration.php +++ b/src/Feature/Composer/Configuration.php @@ -75,9 +75,9 @@ public function getConfigTreeBuilder(): TreeBuilder ->always(function ($value) { if (isset($value['url']) && isset($value['token']) && !isset($value['type'])) { $value['type'] = 'http-basic'; - $value['url'] = substr($value['url'], strpos($value['url'], 'http-basic.') + strlen('http-basic.')); - $value['username'] = $value['username'] ?? 'token'; - $value['password'] = $value['password'] ?? $value['token']; + $value['url'] = substr((string) $value['url'], strpos((string) $value['url'], 'http-basic.') + strlen('http-basic.')); + $value['username'] ??= 'token'; + $value['password'] ??= $value['token']; unset($value['token']); } From de744454fcc2ceb323b2d4fa8e3aaf64dc5f95db Mon Sep 17 00:00:00 2001 From: sebprt Date: Wed, 26 Jun 2024 16:42:17 +0200 Subject: [PATCH 3/8] Renamed variables --- src/Adapter/Docker/SatelliteBuilder.php | 44 ++++++++++++------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Adapter/Docker/SatelliteBuilder.php b/src/Adapter/Docker/SatelliteBuilder.php index 59b35d71..6a0f72dd 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()]; @@ -132,42 +132,42 @@ public function withComposerAuthenticationToken(string $url, string $auth): self return $this; } - public function withGithubOauthAuthentication(string $token, string $url = 'github.com'): self + public function withGithubOauthAuthentication(string $token, string $domain = 'github.com'): self { - $this->authenticationTokens[$url] = [ + $this->authenticationTokens[$domain] = [ 'type' => 'github-token', - 'url' => $url, - 'token' => $token + 'url' => $domain, + 'token' => $token, ]; return $this; } - public function withGitlabOauthAuthentication(string $token, string $url = 'gitlab.com'): self + public function withGitlabOauthAuthentication(string $token, string $domain = 'gitlab.com'): self { - $this->authenticationTokens[$url] = [ + $this->authenticationTokens[$domain] = [ 'type' => 'gitlab-oauth', - 'url' => $url, - 'token' => $token + 'url' => $domain, + 'token' => $token, ]; return $this; } - public function withGitlabTokenAuthentication(string $token, string $url = 'gitlab.com'): self + public function withGitlabTokenAuthentication(string $token, string $domain = 'gitlab.com'): self { - $this->authenticationTokens[$url] = [ + $this->authenticationTokens[$domain] = [ 'type' => 'gitlab-token', - 'url' => $url, - 'token' => $token + 'url' => $domain, + 'token' => $token, ]; return $this; } - public function withHttpBasicAuthentication(string $url, string $username, string $password): self + public function withHttpBasicAuthentication(string $domain, string $username, string $password): self { - $this->authenticationTokens[$url] = [ + $this->authenticationTokens[$domain] = [ 'type' => 'http-basic', 'username' => $username, 'password' => $password, @@ -176,11 +176,11 @@ public function withHttpBasicAuthentication(string $url, string $username, strin return $this; } - public function withHttpBearerAuthentication(string $url, string $token): self + public function withHttpBearerAuthentication(string $domain, string $token): self { - $this->authenticationTokens[$url] = [ + $this->authenticationTokens[$domain] = [ 'type' => 'http-bearer', - 'token' => $token + 'token' => $token, ]; return $this; From 605afe2ddf65ace6964afdd2b67b6bc676561f0c Mon Sep 17 00:00:00 2001 From: sebprt Date: Thu, 27 Jun 2024 10:18:33 +0200 Subject: [PATCH 4/8] Applied suggestion --- src/Adapter/Composer.php | 4 ++-- src/Adapter/Docker/SatelliteBuilder.php | 9 +++----- src/Adapter/Filesystem/SatelliteBuilder.php | 23 ++++++++------------- 3 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/Adapter/Composer.php b/src/Adapter/Composer.php index 2fb2af99..4d743d83 100644 --- a/src/Adapter/Composer.php +++ b/src/Adapter/Composer.php @@ -243,13 +243,13 @@ public function addGitlabTokenAuthentication(string $token, string $url = 'gitla ); } - public function addGithubOauthAuthentication(string $token): void + public function addGithubOauthAuthentication(string $token, string $url = 'github.com'): void { $this->command( 'composer', 'config', '--auth', - 'github-oauth.github.com', + sprintf('github-oauth.%s', $url), $token ); } diff --git a/src/Adapter/Docker/SatelliteBuilder.php b/src/Adapter/Docker/SatelliteBuilder.php index 6a0f72dd..279699a2 100644 --- a/src/Adapter/Docker/SatelliteBuilder.php +++ b/src/Adapter/Docker/SatelliteBuilder.php @@ -136,7 +136,6 @@ public function withGithubOauthAuthentication(string $token, string $domain = 'g { $this->authenticationTokens[$domain] = [ 'type' => 'github-token', - 'url' => $domain, 'token' => $token, ]; @@ -147,7 +146,6 @@ public function withGitlabOauthAuthentication(string $token, string $domain = 'g { $this->authenticationTokens[$domain] = [ 'type' => 'gitlab-oauth', - 'url' => $domain, 'token' => $token, ]; @@ -158,7 +156,6 @@ public function withGitlabTokenAuthentication(string $token, string $domain = 'g { $this->authenticationTokens[$domain] = [ 'type' => 'gitlab-token', - 'url' => $domain, 'token' => $token, ]; @@ -257,9 +254,9 @@ public function build(): Configurator\SatelliteInterface if (\count($this->authenticationTokens) > 0) { foreach ($this->authenticationTokens as $url => $authentication) { match ($authentication['type']) { - 'gitlab-oauth' => $dockerfile->push(new Dockerfile\PHP\ComposerGitlabOauthAuthentication($authentication['token'])), - 'gitlab-token' => $dockerfile->push(new Dockerfile\PHP\ComposerGitlabTokenAuthentication($authentication['token'])), - 'github-oauth' => $dockerfile->push(new Dockerfile\PHP\ComposerGithubOauthAuthentication($authentication['token'])), + 'gitlab-oauth' => $dockerfile->push(new Dockerfile\PHP\ComposerGitlabOauthAuthentication($authentication['token'], $authentication['url'])), + 'gitlab-token' => $dockerfile->push(new Dockerfile\PHP\ComposerGitlabTokenAuthentication($authentication['token'], $authentication['url'])), + 'github-oauth' => $dockerfile->push(new Dockerfile\PHP\ComposerGithubOauthAuthentication($authentication['token'], $authentication['url'])), 'http-basic' => $dockerfile->push(new Dockerfile\PHP\ComposerHttpBasicAuthentication($url, $authentication['username'], $authentication['password'])), 'http-bearer' => $dockerfile->push(new Dockerfile\PHP\ComposerHttpBearerAuthentication($url, $authentication['token'])), default => new \LogicException(), diff --git a/src/Adapter/Filesystem/SatelliteBuilder.php b/src/Adapter/Filesystem/SatelliteBuilder.php index 532bbf66..aca758c4 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()]; @@ -110,7 +110,6 @@ public function withGitlabOauthAuthentication(string $token, string $domain = 'g { $this->authenticationTokens[$domain] = [ 'type' => 'gitlab-oauth', - 'url' => $domain, 'token' => $token, ]; @@ -121,7 +120,6 @@ public function withGitlabTokenAuthentication(string $token, string $domain = 'g { $this->authenticationTokens[$domain] = [ 'type' => 'gitlab-token', - 'url' => $domain, 'token' => $token, ]; @@ -132,7 +130,6 @@ public function withGithubOauthAuthentication(string $token, string $domain = 'g { $this->authenticationTokens[$domain] = [ 'type' => 'github-oauth', - 'url' => $domain, 'token' => $token, ]; @@ -143,7 +140,6 @@ public function withHttpBasicAuthentication(string $domain, string $username, st { $this->authenticationTokens[$domain] = [ 'type' => 'http-basic', - 'url' => $domain, 'username' => $username, 'password' => $password, ]; @@ -155,7 +151,6 @@ public function withHttpBearerAuthentication(string $domain, string $token): sel { $this->authenticationTokens[$domain] = [ 'type' => 'http-basic', - 'url' => $domain, 'token' => $token, ]; @@ -211,10 +206,10 @@ public function build(): Configurator\SatelliteInterface if (\count($this->authenticationTokens) > 0) { foreach ($this->authenticationTokens as $url => $authentication) { match ($authentication['type']) { - 'gitlab-oauth' => $composer->addGitlabOauthAuthentication($authentication['token']), - 'gitlab-token' => $composer->addGitlabTokenAuthentication($authentication['token']), - 'github-oauth' => $composer->addGithubOauthAuthentication($authentication['token']), - 'http-basic' => $composer->addHttpBasicAuthentication($url, $authentication['username'], $authentication['password']), + 'gitlab-oauth' => $composer->addGitlabOauthAuthentication($authentication['token'], $url), + 'gitlab-token' => $composer->addGitlabTokenAuthentication($authentication['token'], $url), + 'github-oauth' => $composer->addGithubOauthAuthentication($authentication['token'], $url), + 'http-basic' => $composer->addHttpBasicAuthentication($url, $authentication['username'], $url), 'http-bearer' => $composer->addHttpBearerAuthentication($url, $authentication['token']), default => $composer->addAuthenticationToken($url, $authentication['token']), }; From a18731fcd5da84fb47ab76dbabc84a30a9bf7685 Mon Sep 17 00:00:00 2001 From: sebprt Date: Thu, 27 Jun 2024 10:40:33 +0200 Subject: [PATCH 5/8] Fixed issues --- src/Adapter/Filesystem/SatelliteBuilder.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Adapter/Filesystem/SatelliteBuilder.php b/src/Adapter/Filesystem/SatelliteBuilder.php index aca758c4..83a47210 100644 --- a/src/Adapter/Filesystem/SatelliteBuilder.php +++ b/src/Adapter/Filesystem/SatelliteBuilder.php @@ -209,9 +209,9 @@ public function build(): Configurator\SatelliteInterface 'gitlab-oauth' => $composer->addGitlabOauthAuthentication($authentication['token'], $url), 'gitlab-token' => $composer->addGitlabTokenAuthentication($authentication['token'], $url), 'github-oauth' => $composer->addGithubOauthAuthentication($authentication['token'], $url), - 'http-basic' => $composer->addHttpBasicAuthentication($url, $authentication['username'], $url), + 'http-basic' => $composer->addHttpBasicAuthentication($url, $authentication['username'], $authentication['password']), 'http-bearer' => $composer->addHttpBearerAuthentication($url, $authentication['token']), - default => $composer->addAuthenticationToken($url, $authentication['token']), + default => throw new \LogicException(), }; } } From 96feec69f8825ec4e16ba7cda3754fd3d4bc9c23 Mon Sep 17 00:00:00 2001 From: sebprt Date: Mon, 1 Jul 2024 16:24:00 +0200 Subject: [PATCH 6/8] Ran php-cs-fixer --- composer.json | 2 +- composer.lock | 20 +++--- phpunit.xml | 63 +++++++---------- src/Action/ConfigurationApplier.php | 4 +- src/Action/Custom/Factory/Action.php | 4 +- src/Action/Custom/Service.php | 5 +- src/Adapter/ComposerFailureException.php | 2 +- src/Adapter/Tar/SatelliteBuilder.php | 10 +-- src/Cloud/Auth.php | 2 +- src/Cloud/CommandBus.php | 21 +++--- src/Cloud/Context.php | 2 +- src/Cloud/ContextInterface.php | 19 +++++ src/Cloud/DTO/JobList.php | 12 ++-- src/Cloud/Normalizer/ExpressionNormalizer.php | 4 +- src/Cloud/Pipeline.php | 2 +- src/Cloud/Workflow.php | 10 ++- src/ConfigLoader.php | 7 +- src/ExpressionLanguage/ExpressionLanguage.php | 2 +- src/Feature/Composer/Configuration.php | 5 +- .../Logger/Builder/Monolog/GelfBuilder.php | 4 +- .../Logger/Factory/ElasticSearchFactory.php | 4 +- src/Feature/Logger/Factory/GelfFactory.php | 4 +- src/Feature/Logger/Factory/StreamFactory.php | 4 +- src/Feature/Logger/Factory/SyslogFactory.php | 4 +- .../Rejection/Factory/RabbitMQFactory.php | 4 +- src/Plugin/Custom/Factory/Extractor.php | 4 +- src/Plugin/Custom/Factory/Loader.php | 4 +- src/Plugin/Custom/Factory/Transformer.php | 4 +- src/Plugin/Custom/Service.php | 9 ++- src/Plugin/FTP/Factory/Loader.php | 4 +- src/Plugin/FTP/Factory/Server.php | 4 +- src/Plugin/Filtering/Factory/Drop.php | 4 +- src/Plugin/Filtering/Factory/Reject.php | 4 +- src/Plugin/Filtering/Service.php | 7 +- src/Plugin/SFTP/Builder/Server.php | 2 +- src/Plugin/SFTP/Factory/Extractor.php | 2 +- src/Plugin/SFTP/Factory/Loader.php | 2 +- src/Plugin/SFTP/Factory/Server.php | 4 +- src/Runtime/RuntimeChoice.php | 10 +-- src/Service.php | 70 +++++++++---------- 40 files changed, 179 insertions(+), 175 deletions(-) create mode 100644 src/Cloud/ContextInterface.php diff --git a/composer.json b/composer.json index 62859396..77a641e9 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "php-etl/configurator-contracts": "0.8.*", "php-etl/satellite-toolbox": "*", "php-etl/gyroscops-api-client": "^0.3.0", - "php-etl/dockerfile": "*", + "php-etl/dockerfile": "dev-composer-authentication", "composer/composer": "*", "symfony/deprecation-contracts": "*", "react/child-process": "^0.7", diff --git a/composer.lock b/composer.lock index 6ec3a658..cec57132 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "546a5d2a5f2a1ec065e2ec9b2060f6fa", + "content-hash": "16b487ad7c3523adbcb82e4d60eda5c7", "packages": [ { "name": "clue/stream-filter", @@ -1483,16 +1483,16 @@ }, { "name": "php-etl/dockerfile", - "version": "v0.2.2", + "version": "dev-composer-authentication", "source": { "type": "git", "url": "https://github.com/php-etl/dockerfile.git", - "reference": "703bb1d58e95d4b8e68140b3f7712af27e5e7c1b" + "reference": "f49ec82ae87c903f2e5239b1b9bd6b668e75d5a6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-etl/dockerfile/zipball/703bb1d58e95d4b8e68140b3f7712af27e5e7c1b", - "reference": "703bb1d58e95d4b8e68140b3f7712af27e5e7c1b", + "url": "https://api.github.com/repos/php-etl/dockerfile/zipball/f49ec82ae87c903f2e5239b1b9bd6b668e75d5a6", + "reference": "f49ec82ae87c903f2e5239b1b9bd6b668e75d5a6", "shasum": "" }, "require": { @@ -1529,9 +1529,9 @@ ], "support": { "issues": "https://github.com/php-etl/dockerfile/issues", - "source": "https://github.com/php-etl/dockerfile/tree/v0.2.2" + "source": "https://github.com/php-etl/dockerfile/tree/composer-authentication" }, - "time": "2024-01-10T13:35:47+00:00" + "time": "2024-07-01T13:41:29+00:00" }, { "name": "php-etl/gyroscops-api-client", @@ -9245,7 +9245,9 @@ ], "aliases": [], "minimum-stability": "dev", - "stability-flags": [], + "stability-flags": { + "php-etl/dockerfile": 20 + }, "prefer-stable": true, "prefer-lowest": false, "platform": { @@ -9253,5 +9255,5 @@ "ext-json": "*" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.2.0" } diff --git a/phpunit.xml b/phpunit.xml index 69e8735d..688aa151 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,41 +1,26 @@ - - - - tests/schema/ - vendor/ - - - tests/functional/ - vendor/ - - - tests/integration/ - vendor/ - - - - - src - - - - - + + + + tests/schema/ + vendor/ + + + tests/functional/ + vendor/ + + + tests/integration/ + vendor/ + + + + + + + + + src + + 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/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/Context.php b/src/Cloud/Context.php index 56ddf252..b9c8bba5 100644 --- a/src/Cloud/Context.php +++ b/src/Cloud/Context.php @@ -8,7 +8,7 @@ use Kiboko\Component\Satellite\Cloud\DTO\OrganizationId; use Kiboko\Component\Satellite\Cloud\DTO\WorkspaceId; -final readonly class Context +final readonly class Context implements ContextInterface { public function __construct( private Api\Client $client, diff --git a/src/Cloud/ContextInterface.php b/src/Cloud/ContextInterface.php new file mode 100644 index 00000000..63dcf5c1 --- /dev/null +++ b/src/Cloud/ContextInterface.php @@ -0,0 +1,19 @@ +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/Cloud/Pipeline.php b/src/Cloud/Pipeline.php index ff7e9417..665d5557 100644 --- a/src/Cloud/Pipeline.php +++ b/src/Cloud/Pipeline.php @@ -18,7 +18,7 @@ final readonly class Pipeline implements PipelineInterface { public function __construct( - private Context $context, + private ContextInterface $context, ) { } diff --git a/src/Cloud/Workflow.php b/src/Cloud/Workflow.php index fec07ff9..45ca9e21 100644 --- a/src/Cloud/Workflow.php +++ b/src/Cloud/Workflow.php @@ -21,12 +21,16 @@ final readonly class Workflow implements WorkflowInterface { public function __construct( - private Context $context, + private ContextInterface $context, ) { } public static function fromLegacyConfiguration(array $configuration): DTO\Workflow { + if (empty($configuration)) { + throw new \RuntimeException('Workflow configuration is empty'); + } + $random = bin2hex(random_bytes(4)); return new DTO\Workflow( @@ -49,7 +53,7 @@ function (array $config, int $order) { return new DTO\Workflow\Pipeline( $name, new JobCode($code), - new StepList( + \count($config['pipeline']['steps']) > 0 ? new StepList( ...array_map(fn (array $step, int $order) => new Step( $step['name'] ?? sprintf('step%d', $order), new StepCode($step['code'] ?? sprintf('step%d', $order)), @@ -60,7 +64,7 @@ function (array $config, int $order) { $config['pipeline']['steps'], range(0, (is_countable($config['pipeline']['steps']) ? \count($config['pipeline']['steps']) : 0) - 1) ), - ), + ) : new StepList(), $order ); } 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/Composer/Configuration.php b/src/Feature/Composer/Configuration.php index 6715777a..c117bcec 100644 --- a/src/Feature/Composer/Configuration.php +++ b/src/Feature/Composer/Configuration.php @@ -73,9 +73,9 @@ public function getConfigTreeBuilder(): TreeBuilder ->arrayPrototype() ->beforeNormalization() ->always(function ($value) { - if (isset($value['url']) && isset($value['token']) && !isset($value['type'])) { + if (isset($value['url'], $value['token']) && !isset($value['type'])) { $value['type'] = 'http-basic'; - $value['url'] = substr((string) $value['url'], strpos((string) $value['url'], 'http-basic.') + strlen('http-basic.')); + $value['url'] = substr((string) $value['url'], strpos((string) $value['url'], 'http-basic.') + \strlen('http-basic.')); $value['username'] ??= 'token'; $value['password'] ??= $value['token']; unset($value['token']); @@ -103,6 +103,7 @@ public function getConfigTreeBuilder(): TreeBuilder } break; } + return $v; }) ->end() 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() ) ) ) From 80466ffa01ce672106aa8d8865e81afe8b6f70d3 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Mon, 1 Jul 2024 14:24:52 +0000 Subject: [PATCH 7/8] [rector] Rector fixes --- src/Cloud/Workflow.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Cloud/Workflow.php b/src/Cloud/Workflow.php index 45ca9e21..1e9e693e 100644 --- a/src/Cloud/Workflow.php +++ b/src/Cloud/Workflow.php @@ -53,7 +53,7 @@ function (array $config, int $order) { return new DTO\Workflow\Pipeline( $name, new JobCode($code), - \count($config['pipeline']['steps']) > 0 ? new StepList( + (is_countable($config['pipeline']['steps']) ? \count($config['pipeline']['steps']) : 0) > 0 ? new StepList( ...array_map(fn (array $step, int $order) => new Step( $step['name'] ?? sprintf('step%d', $order), new StepCode($step['code'] ?? sprintf('step%d', $order)), From 276c392d14117ee8702c6490b548052e7b2bcfc2 Mon Sep 17 00:00:00 2001 From: sebprt Date: Tue, 2 Jul 2024 09:45:21 +0200 Subject: [PATCH 8/8] Added rules into the php-cs-fixer configuration --- .php-cs-fixer.dist.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 218caa49..eff90bcc 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -35,6 +35,11 @@ 'ereg_to_preg' => true, 'dir_constant' => true, 'method_chaining_indentation' => false, + 'string_implicit_backslashes' => [ + 'single_quoted' => 'escape', + 'heredoc' => 'escape', + 'double_quoted' => 'escape' + ] ]) ->setFinder($finder) ->setCacheFile('.php-cs-fixer.cache') // forward compatibility with 3.x line