From 252325d76e6abb86da8ad398a7866f6b59f8b999 Mon Sep 17 00:00:00 2001 From: sebprt Date: Wed, 14 Jun 2023 16:24:22 +0200 Subject: [PATCH 1/5] Integration of custom actions + automatic management of actions in the .gyro file --- composer.json | 4 + src/Action/Custom/Builder/Action.php | 47 +++ src/Action/Custom/Configuration.php | 43 +++ src/Action/Custom/Factory/Action.php | 91 +++++ .../Custom/Factory/Repository/Action.php | 32 ++ .../Factory/Repository/RepositoryTrait.php | 42 +++ src/Action/Custom/Service.php | 81 ++++ src/Action/SFTP/Builder/Action.php | 2 +- src/ComposerScripts.php | 1 + src/Plugin/SFTP/Builder/Extractor.php | 352 ++++++++++++++++++ src/Plugin/SFTP/Factory/Extractor.php | 94 +++++ src/Plugin/SFTP/Service.php | 9 + src/Service.php | 1 + 13 files changed, 798 insertions(+), 1 deletion(-) create mode 100644 src/Action/Custom/Builder/Action.php create mode 100644 src/Action/Custom/Configuration.php create mode 100644 src/Action/Custom/Factory/Action.php create mode 100644 src/Action/Custom/Factory/Repository/Action.php create mode 100644 src/Action/Custom/Factory/Repository/RepositoryTrait.php create mode 100644 src/Action/Custom/Service.php create mode 100644 src/Plugin/SFTP/Builder/Extractor.php create mode 100644 src/Plugin/SFTP/Factory/Extractor.php diff --git a/composer.json b/composer.json index 0b256f78..c6d8fd24 100644 --- a/composer.json +++ b/composer.json @@ -111,6 +111,10 @@ "Kiboko\\Component\\Satellite\\Plugin\\FTP\\Service", "Kiboko\\Component\\Satellite\\Plugin\\Batching\\Service", "Kiboko\\Component\\Satellite\\Plugin\\Filtering\\Service" + ], + "actions": [ + "Kiboko\\Component\\Satellite\\Action\\SFTP\\Service", + "Kiboko\\Component\\Satellite\\Action\\Custom\\Service" ] } }, diff --git a/src/Action/Custom/Builder/Action.php b/src/Action/Custom/Builder/Action.php new file mode 100644 index 00000000..c5271bb1 --- /dev/null +++ b/src/Action/Custom/Builder/Action.php @@ -0,0 +1,47 @@ +logger = $logger; + + return $this; + } + + public function withState(Node\Expr $state): self + { + $this->state = $state; + + return $this; + } + + public function getNode(): Node + { + return new Node\Expr\MethodCall( + var: new Node\Expr\New_( + class: new Node\Name\FullyQualified($this->containerNamespace) + ), + name: new Node\Identifier('get'), + args: [ + new Node\Arg( + $this->service + ), + ] + ); + } +} diff --git a/src/Action/Custom/Configuration.php b/src/Action/Custom/Configuration.php new file mode 100644 index 00000000..2ca2c3ea --- /dev/null +++ b/src/Action/Custom/Configuration.php @@ -0,0 +1,43 @@ +getRootNode() + ->children() + ->arrayNode('expression_language') + ->scalarPrototype()->end() + ->end() + ->append((new ServicesConfiguration())->getConfigTreeBuilder()->getRootNode()) + ->scalarNode('use') + ->isRequired() + ->end() + ->arrayNode('parameters') + ->useAttributeAsKey('keyparam') + ->scalarPrototype() + ->cannotBeEmpty() + ->validate() + ->ifTrue(isExpression()) + ->then(asExpression()) + ->end() + ->end() + ->end() + ->end() + ; + + return $builder; + } +} diff --git a/src/Action/Custom/Factory/Action.php b/src/Action/Custom/Factory/Action.php new file mode 100644 index 00000000..29279a9c --- /dev/null +++ b/src/Action/Custom/Factory/Action.php @@ -0,0 +1,91 @@ +processor = new Processor(); + $this->configuration = new Configuration(); + } + + public function configuration(): ConfigurationInterface + { + return $this->configuration; + } + + /** + * @throws Configurator\ConfigurationExceptionInterface + */ + public function normalize(array $config): array + { + try { + return $this->processor->processConfiguration($this->configuration, $config); + } catch (Symfony\InvalidTypeException|Symfony\InvalidConfigurationException $exception) { + throw new Configurator\InvalidConfigurationException($exception->getMessage(), 0, $exception); + } + } + + public function validate(array $config): bool + { + try { + $this->processor->processConfiguration($this->configuration, $config); + + return true; + } catch (Symfony\InvalidTypeException|Symfony\InvalidConfigurationException) { + return false; + } + } + + /** + * @throws Configurator\ConfigurationExceptionInterface + */ + public function compile(array $config): Repository\Action + { + $containerName = sprintf('ProjectServiceContainer%s', ByteString::fromRandom(8)->toString()); + + $builder = new Custom\Builder\Action( + compileValueWhenExpression($this->interpreter, $config['use']), + sprintf('GyroscopsGenerated\\%s', $containerName), + ); + + $container = (new SatelliteDependencyInjection(...$this->providers))($config); + + $repository = new Repository\Action($builder); + + $dumper = new PhpDumper($container); + $repository->addFiles( + new Packaging\File( + sprintf('%s.php', $containerName), + new Packaging\Asset\InMemory( + $dumper->dump(['class' => $containerName, 'namespace' => 'GyroscopsGenerated']) + ) + ), + ); + + return $repository; + } +} diff --git a/src/Action/Custom/Factory/Repository/Action.php b/src/Action/Custom/Factory/Repository/Action.php new file mode 100644 index 00000000..42578f48 --- /dev/null +++ b/src/Action/Custom/Factory/Repository/Action.php @@ -0,0 +1,32 @@ +files = []; + $this->packages = []; + } + + public function getBuilder(): Custom\Builder\Action + { + return $this->builder; + } + + public function merge(Configurator\RepositoryInterface $friend): self + { + array_push($this->files, ...$friend->getFiles()); + array_push($this->packages, ...$friend->getPackages()); + + return $this; + } +} diff --git a/src/Action/Custom/Factory/Repository/RepositoryTrait.php b/src/Action/Custom/Factory/Repository/RepositoryTrait.php new file mode 100644 index 00000000..200ef6c0 --- /dev/null +++ b/src/Action/Custom/Factory/Repository/RepositoryTrait.php @@ -0,0 +1,42 @@ + */ + private array $files; + /** @var string[] */ + private array $packages; + + public function addFiles(Packaging\FileInterface|Packaging\DirectoryInterface ...$files): Configurator\RepositoryInterface + { + array_push($this->files, ...$files); + + return $this; + } + + /** @return iterable */ + public function getFiles(): iterable + { + return $this->files; + } + + public function addPackages(string ...$packages): Configurator\RepositoryInterface + { + array_push($this->packages, ...$packages); + + return $this; + } + + /** @return iterable */ + public function getPackages(): iterable + { + return $this->packages; + } +} diff --git a/src/Action/Custom/Service.php b/src/Action/Custom/Service.php new file mode 100644 index 00000000..173338fe --- /dev/null +++ b/src/Action/Custom/Service.php @@ -0,0 +1,81 @@ +processor = new Processor(); + $this->configuration = new Custom\Configuration(); + } + + public function interpreter(): ExpressionLanguage + { + return $this->interpreter; + } + + public function configuration(): Configurator\ActionConfigurationInterface + { + return $this->configuration; + } + + /** + * @throws Configurator\ConfigurationExceptionInterface + */ + public function normalize(array $config): array + { + try { + return $this->processor->processConfiguration($this->configuration, $config); + } catch (Symfony\InvalidTypeException|Symfony\InvalidConfigurationException $exception) { + throw new Configurator\InvalidConfigurationException($exception->getMessage(), 0, $exception); + } + } + + public function validate(array $config): bool + { + try { + $this->processor->processConfiguration($this->configuration, $config); + + return true; + } catch (Symfony\InvalidTypeException|Symfony\InvalidConfigurationException) { + return false; + } + } + + /** + * @throws Configurator\ConfigurationExceptionInterface + */ + public function compile(array $config): Configurator\RepositoryInterface + { + $interpreter = clone $this->interpreter; + + if (\array_key_exists('expression_language', $config) + && \is_array($config['expression_language']) + && \count($config['expression_language']) + ) { + foreach ($config['expression_language'] as $provider) { + $interpreter->registerProvider(new $provider()); + } + } + + $actionFactory = new Custom\Factory\Action($this->interpreter); + return $actionFactory->compile($config); + } +} diff --git a/src/Action/SFTP/Builder/Action.php b/src/Action/SFTP/Builder/Action.php index c950ce26..ea0ca1b5 100644 --- a/src/Action/SFTP/Builder/Action.php +++ b/src/Action/SFTP/Builder/Action.php @@ -38,7 +38,7 @@ public function withState(Node\Expr $state): self public function getNode(): Node { return new Node\Expr\New_( - class: new Node\Name\FullyQualified('Kiboko\Component\Action\Flow\SFTP\Action'), + class: new Node\Name\FullyQualified('Kiboko\Component\Action\Flow\SFTP\UploadFile'), args: [ new Node\Arg( value: $this->host, diff --git a/src/ComposerScripts.php b/src/ComposerScripts.php index 0037485b..d89e8c4a 100644 --- a/src/ComposerScripts.php +++ b/src/ComposerScripts.php @@ -46,6 +46,7 @@ private static function updatePlugins( } if ('satellite-plugin' !== $package->getType() && 'gyroscops-plugin' !== $package->getType() + && 'gyroscops-action' !== $package->getType() && 'php-etl/satellite' !== $package->getName() ) { continue; diff --git a/src/Plugin/SFTP/Builder/Extractor.php b/src/Plugin/SFTP/Builder/Extractor.php new file mode 100644 index 00000000..93b7a845 --- /dev/null +++ b/src/Plugin/SFTP/Builder/Extractor.php @@ -0,0 +1,352 @@ +logger = $logger; + + return $this; + } + + public function withRejection(Node\Expr $rejection): self + { + $this->rejection = $rejection; + + return $this; + } + + public function withState(Node\Expr $state): self + { + $this->state = $state; + + return $this; + } + + public function withServer(array $config, Node ...$server): self + { + $this->servers[] = array_merge($config, [...$server]); + + return $this; + } + + public function withPut( + Node\Expr $path, + Node\Expr $content, + ?Node\Expr $mode, + ?Node\Expr $condition, + ): self { + $this->putStatements[] = [$path, $content, $mode, $condition]; + + return $this; + } + + private function compilePutStatements(): iterable + { + foreach ($this->putStatements as [$path, $content, $mode, $condition]) { + foreach ($this->servers as $index => $server) { + if (null != $condition) { + yield new Node\Stmt\If_( + cond: $condition, + subNodes: [ + 'stmts' => [ + ...$this->getPutNode($index, $server, $path, $content, $mode), + ], + ] + ); + } else { + yield from $this->getPutNode($index, $server, $path, $content, $mode); + } + } + } + } + + public function getNode(): Node + { + return new Node\Expr\New_( + class: new Node\Stmt\Class_( + name: null, + subNodes: [ + 'implements' => [ + new Node\Name\FullyQualified(\Kiboko\Contract\Pipeline\LoaderInterface::class), + ], + 'stmts' => [ + new Node\Stmt\ClassMethod( + name: new Node\Identifier('__construct'), + subNodes: [ + 'flags' => Node\Stmt\Class_::MODIFIER_PUBLIC, + 'stmts' => array_map( + fn ($server, $index) => new Node\Stmt\Expression( + new Node\Expr\Assign( + new Node\Expr\ArrayDimFetch( + new Node\Expr\PropertyFetch( + new Node\Expr\Variable('this'), + new Node\Identifier('servers') + ), + new Node\Scalar\LNumber($index), + ), + $server[0] + ) + ), + $this->servers, + array_keys($this->servers), + ), + ], + ), + new Node\Stmt\ClassMethod( + name: new Node\Identifier('load'), + subNodes: [ + 'flags' => Node\Stmt\Class_::MODIFIER_PUBLIC, + 'stmts' => [ + new Node\Stmt\Expression( + expr: new Node\Expr\Assign( + var: new Node\Expr\Variable('input'), + expr: new Node\Expr\Yield_(), + ), + ), + new Node\Stmt\Do_( + cond: new Node\Expr\Assign( + var: new Node\Expr\Variable('input'), + expr: new Node\Expr\Yield_( + value: new Node\Expr\Variable('bucket'), + ), + ), + stmts: [ + new Node\Stmt\Expression( + new Node\Expr\Assign( + var: new Node\Expr\Variable('bucket'), + expr: new Node\Expr\New_( + class: new Node\Name\FullyQualified(\Kiboko\Component\Bucket\ComplexResultBucket::class) + ) + ) + ), + ...$this->compilePutStatements(), + new Node\Stmt\Expression( + new Node\Expr\MethodCall( + var: new Node\Expr\Variable('bucket'), + name: new Node\Name('accept'), + args: [ + new Node\Arg( + new Node\Expr\Variable('input'), + ), + ] + ) + ), + ], + ), + new Node\Stmt\Expression( + new Node\Expr\Yield_( + value: new Node\Expr\Variable('bucket') + ), + ), + ], + 'returnType' => new Node\Name\FullyQualified('Generator'), + ], + ), + ], + ], + ), + ); + } + + private function getPutNode($index, $server, $path, $content, $mode): array + { + return [ + new Node\Stmt\Expression( + new Node\Expr\FuncCall( + name: new Node\Name('ssh2_sftp_mkdir'), + args: [ + new Node\Arg( + new Node\Expr\ArrayDimFetch( + var: new Node\Expr\PropertyFetch( + var: new Node\Expr\Variable('this'), + name: new Node\Identifier('servers'), + ), + dim: new Node\Scalar\LNumber($index) + ), + ), + new Node\Arg( + new Node\Expr\FuncCall( + name: new Node\Name('dirname'), + args: [ + new Node\Arg( + value: new Node\Expr\BinaryOp\Concat( + new Node\Expr\BinaryOp\Concat( + compileValueWhenExpression($this->interpreter, $server['base_path']), + new Node\Scalar\String_('/'), + ), + $path, + ) + ), + ] + ), + ), + new Node\Arg( + new Node\Expr\FuncCall( + name: new Node\Name('octdec'), + args: [ + $mode, + ], + ), + ), + new Node\Arg( + new Node\Expr\ConstFetch( + name: new Node\Name('true') + ), + ), + ] + ) + ), + new Node\Stmt\Expression( + new Node\Expr\Assign( + var: new Node\Expr\Variable('stream'), + expr: new Node\Expr\FuncCall( + name: new Node\Name('fopen'), + args: [ + new Node\Arg( + value: new Node\Expr\BinaryOp\Concat( + new Node\Expr\BinaryOp\Concat( + new Node\Expr\BinaryOp\Concat( + new Node\Scalar\String_('ssh2.sftp://'), + new Node\Expr\FuncCall( + name: new Node\Name('intval'), + args: [ + new Node\Arg( + new Node\Expr\ArrayDimFetch( + var: new Node\Expr\PropertyFetch( + var: new Node\Expr\Variable('this'), + name: new Node\Identifier('servers'), + ), + dim: new Node\Scalar\LNumber($index) + ), + ), + ] + ) + ), + new Node\Expr\BinaryOp\Concat( + compileValueWhenExpression($this->interpreter, $server['base_path']), + new Node\Scalar\String_('/'), + ) + ), + $path, + ), + ), + new Node\Arg(new Node\Scalar\String_('w')), + ], + ), + ), + ), + new Node\Stmt\If_( + cond: new Node\Expr\BinaryOp\Identical( + left: new Node\Expr\FuncCall( + name: new Node\Name('stream_copy_to_stream'), + args: [ + new Node\Arg($content), + new Node\Arg(new Node\Expr\Variable('stream')), + ], + ), + right: new Node\Expr\ConstFetch( + name: new Node\Name('false') + ), + ), + subNodes: [ + 'stmts' => [ + new Node\Stmt\Expression( + new Node\Expr\MethodCall( + var: new Node\Expr\PropertyFetch( + var: new Node\Expr\Variable('this'), + name: new Node\Name('logger'), + ), + name: new Node\Name('alert'), + args: [ + new Node\Arg( + new Node\Expr\FuncCall( + name: new Node\Name('strtr'), + args: [ + new Node\Arg( + new Node\Scalar\String_('Error while uploading file "%path%" to "%server%" server') + ), + new Node\Arg( + new Node\Expr\Array_( + items: [new Node\Expr\ArrayItem( + value: compileValueWhenExpression($this->interpreter, $server['base_path']), + key: new Node\Scalar\String_('%path%'), + ), new Node\Expr\ArrayItem( + value: compileValueWhenExpression($this->interpreter, $server['host']), + key: new Node\Scalar\String_('%server%'), + )], + attributes: [ + 'kind' => Node\Expr\Array_::KIND_SHORT, + ] + ) + ), + ] + ) + ), + ] + ) + ), + new Node\Stmt\Expression( + new Node\Expr\MethodCall( + var: new Node\Expr\Variable('bucket'), + name: new Node\Name('reject'), + args: [ + new Node\Arg( + new Node\Expr\Array_( + items: [new Node\Expr\ArrayItem( + value: compileValueWhenExpression($this->interpreter, $server['base_path']), + key: new Node\Scalar\String_('%path%'), + ), new Node\Expr\ArrayItem( + value: compileValueWhenExpression($this->interpreter, $server['host']), + key: new Node\Scalar\String_('%server%'), + )], + attributes: [ + 'kind' => Node\Expr\Array_::KIND_SHORT, + ] + ) + ), + ] + ) + ), + ], + ], + ), + new Node\Stmt\Expression( + expr: new Node\Expr\FuncCall( + name: new Node\Name('fclose'), + args: [ + new Node\Arg($content), + ] + ) + ), + new Node\Stmt\Expression( + expr: new Node\Expr\FuncCall( + name: new Node\Name('fclose'), + args: [ + new Node\Arg(new Node\Expr\Variable('stream')), + ] + ) + ), + ]; + } +} diff --git a/src/Plugin/SFTP/Factory/Extractor.php b/src/Plugin/SFTP/Factory/Extractor.php new file mode 100644 index 00000000..dd9c8f9f --- /dev/null +++ b/src/Plugin/SFTP/Factory/Extractor.php @@ -0,0 +1,94 @@ +processor = new Processor(); + $this->configuration = new SFTP\Configuration(); + } + + public function configuration(): ConfigurationInterface + { + return $this->configuration; + } + + /** + * @throws Configurator\ConfigurationExceptionInterface + */ + public function normalize(array $config): array + { + try { + return $this->processor->processConfiguration($this->configuration, $config); + } catch (Symfony\InvalidTypeException|Symfony\InvalidConfigurationException $exception) { + throw new Configurator\InvalidConfigurationException($exception->getMessage(), 0, $exception); + } + } + + public function validate(array $config): bool + { + try { + $this->normalize($config); + + return true; + } catch (Symfony\InvalidTypeException|Symfony\InvalidConfigurationException) { + return false; + } + } + + public function compile(array $config): Repository + { + $builder = new SFTP\Builder\Extractor($this->interpreter); + + if (\array_key_exists('servers', $config['loader']) + && \is_array($config['loader']['servers']) + ) { + foreach ($config['loader']['servers'] as $server) { + $serverFactory = new Server($this->interpreter); + + $loader = $serverFactory->compile($server); + $serverBuilder = $loader->getBuilder(); + + $builder->withServer($server, $serverBuilder->getNode()); + } + } + + if (\array_key_exists('put', $config['loader']) + && \is_array($config['loader']['put']) + ) { + foreach ($config['loader']['put'] as $put) { + $builder->withPut( + compileValueWhenExpression($this->interpreter, $put['path']), + compileValueWhenExpression($this->interpreter, $put['content']), + \array_key_exists('mode', $put) ? compileValueWhenExpression($this->interpreter, $put['mode']) : null, + \array_key_exists('if', $put) ? compileValueWhenExpression($this->interpreter, $put['if']) : null, + ); + } + } + + try { + return new Repository($builder); + } catch (Symfony\InvalidTypeException|Symfony\InvalidConfigurationException $exception) { + throw new Configurator\InvalidConfigurationException(message: $exception->getMessage(), previous: $exception); + } + } +} diff --git a/src/Plugin/SFTP/Service.php b/src/Plugin/SFTP/Service.php index 6afbecc5..ba5992c5 100644 --- a/src/Plugin/SFTP/Service.php +++ b/src/Plugin/SFTP/Service.php @@ -76,6 +76,15 @@ public function compile(array $config): Configurator\RepositoryInterface } } + if (\array_key_exists('extractor', $config)) { + $factory = new Factory\Extractor($this->interpreter); + + $loader = $factory->compile($config); + $builder = $loader->getBuilder(); + + return new Repository($builder); + } + if (\array_key_exists('loader', $config)) { $loaderFactory = new Factory\Loader($this->interpreter); diff --git a/src/Service.php b/src/Service.php index 6d6051ef..8b0291dd 100644 --- a/src/Service.php +++ b/src/Service.php @@ -293,6 +293,7 @@ private function compileWorkflow(array $config): Satellite\Builder\Repository\Wo $action = $this->compileActionJob($job); $actionFilename = sprintf('%s.php', uniqid('action')); + $repository->merge($action); $repository->addFiles( new Packaging\File( $actionFilename, From 6f4348a4c2b25d57475bb1688ff2d5acf979bd95 Mon Sep 17 00:00:00 2001 From: sebprt Date: Wed, 14 Jun 2023 16:31:26 +0200 Subject: [PATCH 2/5] Ran php-cs-fixer --- src/Action/Custom/Configuration.php | 1 + src/Action/Custom/Service.php | 1 + src/Plugin/SFTP/Builder/Extractor.php | 1 + src/Plugin/SFTP/Factory/Extractor.php | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Action/Custom/Configuration.php b/src/Action/Custom/Configuration.php index 2ca2c3ea..31f5824a 100644 --- a/src/Action/Custom/Configuration.php +++ b/src/Action/Custom/Configuration.php @@ -7,6 +7,7 @@ use Kiboko\Component\Satellite\DependencyInjection\Configuration\ServicesConfiguration; use Kiboko\Contract\Configurator\ActionConfigurationInterface; use Symfony\Component\Config\Definition\Builder\TreeBuilder; + use function Kiboko\Component\SatelliteToolbox\Configuration\asExpression; use function Kiboko\Component\SatelliteToolbox\Configuration\isExpression; diff --git a/src/Action/Custom/Service.php b/src/Action/Custom/Service.php index 173338fe..be6c7550 100644 --- a/src/Action/Custom/Service.php +++ b/src/Action/Custom/Service.php @@ -76,6 +76,7 @@ public function compile(array $config): Configurator\RepositoryInterface } $actionFactory = new Custom\Factory\Action($this->interpreter); + return $actionFactory->compile($config); } } diff --git a/src/Plugin/SFTP/Builder/Extractor.php b/src/Plugin/SFTP/Builder/Extractor.php index 93b7a845..fcee987a 100644 --- a/src/Plugin/SFTP/Builder/Extractor.php +++ b/src/Plugin/SFTP/Builder/Extractor.php @@ -8,6 +8,7 @@ use Kiboko\Contract\Configurator\StepBuilderInterface; use PhpParser\Node; use Symfony\Component\ExpressionLanguage\ExpressionLanguage; + use function Kiboko\Component\SatelliteToolbox\Configuration\compileValueWhenExpression; final class Extractor implements StepBuilderInterface diff --git a/src/Plugin/SFTP/Factory/Extractor.php b/src/Plugin/SFTP/Factory/Extractor.php index dd9c8f9f..014eb4e9 100644 --- a/src/Plugin/SFTP/Factory/Extractor.php +++ b/src/Plugin/SFTP/Factory/Extractor.php @@ -7,12 +7,12 @@ use Kiboko\Component\Satellite\ExpressionLanguage as Satellite; use Kiboko\Component\Satellite\Plugin\SFTP; use Kiboko\Component\Satellite\Plugin\SFTP\Factory\Repository\Repository; -use Kiboko\Component\Satellite\Plugin\SFTP\Factory\Server; use Kiboko\Contract\Configurator; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\Config\Definition\Exception as Symfony; use Symfony\Component\Config\Definition\Processor; use Symfony\Component\ExpressionLanguage\ExpressionLanguage; + use function Kiboko\Component\SatelliteToolbox\Configuration\compileValueWhenExpression; class Extractor implements Configurator\FactoryInterface From 52e3c546554f5ab1f53e854f4f1cfae2a25997ca Mon Sep 17 00:00:00 2001 From: sebprt Date: Thu, 15 Jun 2023 09:04:08 +0200 Subject: [PATCH 3/5] Updated name of actions --- .github/workflows/phpstan-6.yaml | 2 +- .github/workflows/phpstan-7.yaml | 2 +- .github/workflows/phpstan-8.yaml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/phpstan-6.yaml b/.github/workflows/phpstan-6.yaml index 8fe418d9..1dd1abfa 100644 --- a/.github/workflows/phpstan-6.yaml +++ b/.github/workflows/phpstan-6.yaml @@ -1,7 +1,7 @@ name: PHPStan level 6 on: push jobs: - phpstan: + phpstan6: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/phpstan-7.yaml b/.github/workflows/phpstan-7.yaml index e7d8d6e1..a2f393ca 100644 --- a/.github/workflows/phpstan-7.yaml +++ b/.github/workflows/phpstan-7.yaml @@ -1,7 +1,7 @@ name: PHPStan level 7 on: push jobs: - phpstan: + phpstan7: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/phpstan-8.yaml b/.github/workflows/phpstan-8.yaml index 39cebe0f..addb6be2 100644 --- a/.github/workflows/phpstan-8.yaml +++ b/.github/workflows/phpstan-8.yaml @@ -1,7 +1,7 @@ name: PHPStan level 8 on: push jobs: - phpstan: + phpstan8: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 From 3423d0908adf538742fd4be2919b0e87fb85d52f Mon Sep 17 00:00:00 2001 From: sebprt Date: Wed, 5 Jul 2023 10:24:04 +0200 Subject: [PATCH 4/5] Ran php-cs-fixer --- src/Adapter/ComposerFailureException.php | 2 +- src/Adapter/Docker/SatelliteBuilder.php | 6 +++--- src/Adapter/Filesystem/SatelliteBuilder.php | 6 +++--- src/Adapter/Tar/SatelliteBuilder.php | 6 +++--- src/Cloud/Auth.php | 2 +- src/Plugin/SFTP/Builder/Server.php | 2 +- src/Service.php | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Adapter/ComposerFailureException.php b/src/Adapter/ComposerFailureException.php index 9645c1c1..ab012812 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, null|\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 9bfe8515..43e11363 100644 --- a/src/Adapter/Docker/SatelliteBuilder.php +++ b/src/Adapter/Docker/SatelliteBuilder.php @@ -67,7 +67,7 @@ public function withComposerRequire(string ...$package): self public function withComposerFile( PackagingContract\FileInterface|PackagingContract\AssetInterface $composerJsonFile, - null|PackagingContract\FileInterface|PackagingContract\AssetInterface $composerLockFile = null + PackagingContract\FileInterface|PackagingContract\AssetInterface $composerLockFile = null ): self { $this->composerJsonFile = $composerJsonFile; $this->composerLockFile = $composerLockFile; @@ -77,7 +77,7 @@ public function withComposerFile( public function withFile( PackagingContract\FileInterface|PackagingContract\AssetInterface $source, - null|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, null|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 7d554359..9107b136 100644 --- a/src/Adapter/Filesystem/SatelliteBuilder.php +++ b/src/Adapter/Filesystem/SatelliteBuilder.php @@ -55,7 +55,7 @@ public function withComposerRequire(string ...$package): self public function withComposerFile( PackagingContract\FileInterface|PackagingContract\AssetInterface $composerJsonFile, - null|PackagingContract\FileInterface|PackagingContract\AssetInterface $composerLockFile = null + PackagingContract\FileInterface|PackagingContract\AssetInterface $composerLockFile = null ): self { $this->composerJsonFile = $composerJsonFile; $this->composerLockFile = $composerLockFile; @@ -65,7 +65,7 @@ public function withComposerFile( public function withFile( PackagingContract\FileInterface|PackagingContract\AssetInterface $source, - null|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, null|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 a48680d1..c65ac1c7 100644 --- a/src/Adapter/Tar/SatelliteBuilder.php +++ b/src/Adapter/Tar/SatelliteBuilder.php @@ -48,7 +48,7 @@ public function withComposerRequire(string ...$package): self public function withComposerFile( PackagingContract\FileInterface|PackagingContract\AssetInterface $composerJsonFile, - null|PackagingContract\FileInterface|PackagingContract\AssetInterface $composerLockFile = null + PackagingContract\FileInterface|PackagingContract\AssetInterface $composerLockFile = null ): self { $this->composerJsonFile = $composerJsonFile; $this->composerLockFile = $composerLockFile; @@ -58,7 +58,7 @@ public function withComposerFile( public function withFile( PackagingContract\FileInterface|PackagingContract\AssetInterface $source, - null|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, null|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 648886df..1a069ccd 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(null|string $pathName = null) + public function __construct(string $pathName = null) { if (null === $pathName) { $this->pathName = getenv('HOME').'/.gyroscops/'; diff --git a/src/Plugin/SFTP/Builder/Server.php b/src/Plugin/SFTP/Builder/Server.php index a375b9f7..dbbef64c 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, null|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/Service.php b/src/Service.php index 8b0291dd..05a6d683 100644 --- a/src/Service.php +++ b/src/Service.php @@ -33,7 +33,7 @@ final class Service implements Configurator\FactoryInterface /** @var array */ private array $actionPlugins = []; - public function __construct(null|ExpressionLanguage $expressionLanguage = null) + public function __construct(ExpressionLanguage $expressionLanguage = null) { $this->processor = new Processor(); $this->configuration = new Satellite\Configuration(); From 436885f3771af45c923f84a84349d36901b0075a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20PLANCHAT?= Date: Wed, 5 Jul 2023 10:51:24 +0200 Subject: [PATCH 5/5] Update phpstan-5.yaml --- .github/workflows/phpstan-5.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/phpstan-5.yaml b/.github/workflows/phpstan-5.yaml index 862625d3..df9cb01b 100644 --- a/.github/workflows/phpstan-5.yaml +++ b/.github/workflows/phpstan-5.yaml @@ -1,7 +1,7 @@ name: PHPStan level 5 on: push jobs: - phpstan: + phpstan5: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3