From 4ac0413b20a8c05ac3e839abe289ebce64ef8ba4 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 15 Dec 2020 15:33:19 -0300 Subject: [PATCH 01/85] Updated dependencies to the latest versions --- .php_cs | 47 ++++++++++++++++++++++++++++------------------- composer.json | 21 ++++++++++++--------- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/.php_cs b/.php_cs index 3eaf3dae5..2555e1b84 100644 --- a/.php_cs +++ b/.php_cs @@ -10,29 +10,38 @@ $finder = \PhpCsFixer\Finder::create() return \PhpCsFixer\Config::create() ->setRules([ - '@Symfony' => true, - '@Symfony:risky' => true, - '@PHP56Migration' => true, - '@PHP56Migration:risky' => true, - '@PHP70Migration' => true, - '@PHP70Migration:risky' => true, - '@PHP71Migration' => true, - '@PHP71Migration:risky' => true, - 'array_syntax' => [ + '@Symfony' => true, + '@Symfony:risky' => true, + '@PHP56Migration' => true, + '@PHP56Migration:risky' => true, + '@PHP70Migration' => true, + '@PHP70Migration:risky' => true, + '@PHP71Migration' => true, + '@PHP71Migration:risky' => true, + '@PHP73Migration' => true, + '@PHP74Migration' => true, + '@PHP74Migration:risky' => true, + '@PHP80Migration' => true, + '@PHP80Migration:risky' => true, + '@PHPUnit75Migration:risky' => true, + '@PHPUnit84Migration:risky' => true, + 'array_syntax' => [ 'syntax' => 'short' ], - 'combine_consecutive_unsets' => true, - 'declare_strict_types' => true, + 'combine_consecutive_unsets' => true, + 'declare_strict_types' => true, 'linebreak_after_opening_tag' => true, - 'modernize_types_casting' => true, - 'native_function_invocation' => true, - 'no_php4_constructor' => true, - 'ordered_imports' => true, - 'php_unit_strict' => true, - 'phpdoc_order' => true, - 'strict_comparison' => true, - 'strict_param' => true, + 'modernize_types_casting' => true, + 'native_function_invocation' => true, + 'no_php4_constructor' => true, + 'ordered_imports' => true, + 'php_unit_strict' => true, + 'phpdoc_order' => true, + 'strict_comparison' => true, + 'strict_param' => true, ]) ->setRiskyAllowed(true) + ->setIndent(' ') + ->setLineEnding("\n") ->setFinder($finder) ; diff --git a/composer.json b/composer.json index 64019814f..a9b31de1c 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,11 @@ { - "name": "docker-php/docker-php", + "name": "beluga-php/docker-php", "license": "MIT", "type": "library", "description": "A Docker PHP client", + "config": { + "sort-packages": true + }, "autoload": { "psr-4": { "Docker\\": "src/" @@ -15,21 +18,21 @@ }, "require": { "php": ">=7.1", - "docker-php/docker-php-api": "4.1.*", + "beluga-php/docker-php-api": "6.1.*", "guzzlehttp/psr7": "^1.2", - "php-http/client-common": "^1.6", - "php-http/socket-client": "^1.3", - "php-http/message": "^1.0", - "symfony/filesystem": "^2.3 || ^3.0 || ^4.0", - "symfony/process": "^2.3 || ^3.0 || ^4.0" + "php-http/client-common": "^2.3", + "php-http/socket-client": "^2.0", + "psr/http-message": "^1.0", + "symfony/filesystem": "^5.2", + "symfony/process": "^5.2" }, "suggest": { "php-http/httplug-bundle": "For integration with Symfony", "amphp/artax": "To use the async api" }, "require-dev": { - "phpunit/phpunit": "^6.0", - "friendsofphp/php-cs-fixer": "2.8.1", + "phpunit/phpunit": "^9.5", + "friendsofphp/php-cs-fixer": "^2.17", "amphp/artax": "^3.0", "amphp/socket": "^0.10.5" }, From d5bc99a6b73d85de749d33aec2362f6ea6075e1c Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 15 Dec 2020 16:34:48 -0300 Subject: [PATCH 02/85] Removed async related code as Jane dropped it --- composer.json | 7 +- src/Client/AmpArtaxStreamEndpoint.php | 26 ------ src/Client/AmpArtaxStreamEndpointTrait.php | 41 ---------- src/Client/ProvideAmpArtaxClientOptions.php | 15 ---- src/DockerAsync.php | 74 ------------------ src/DockerAsyncClient.php | 87 --------------------- src/Stream/ArtaxCallbackStream.php | 78 ------------------ tests/DockerAsyncTest.php | 86 -------------------- 8 files changed, 2 insertions(+), 412 deletions(-) delete mode 100644 src/Client/AmpArtaxStreamEndpoint.php delete mode 100644 src/Client/AmpArtaxStreamEndpointTrait.php delete mode 100644 src/Client/ProvideAmpArtaxClientOptions.php delete mode 100644 src/DockerAsync.php delete mode 100644 src/DockerAsyncClient.php delete mode 100644 src/Stream/ArtaxCallbackStream.php delete mode 100644 tests/DockerAsyncTest.php diff --git a/composer.json b/composer.json index a9b31de1c..500a8e1bd 100644 --- a/composer.json +++ b/composer.json @@ -27,14 +27,11 @@ "symfony/process": "^5.2" }, "suggest": { - "php-http/httplug-bundle": "For integration with Symfony", - "amphp/artax": "To use the async api" + "php-http/httplug-bundle": "For integration with Symfony" }, "require-dev": { "phpunit/phpunit": "^9.5", - "friendsofphp/php-cs-fixer": "^2.17", - "amphp/artax": "^3.0", - "amphp/socket": "^0.10.5" + "friendsofphp/php-cs-fixer": "^2.17" }, "conflict": { "amphp/socket": "<0.10.5", diff --git a/src/Client/AmpArtaxStreamEndpoint.php b/src/Client/AmpArtaxStreamEndpoint.php deleted file mode 100644 index ec7f3b9a0..000000000 --- a/src/Client/AmpArtaxStreamEndpoint.php +++ /dev/null @@ -1,26 +0,0 @@ -transformResponseBody($chunk, $response->getStatus(), $serializer); - }; - } - - return new ArtaxCallbackStream($response->getBody(), $cancellationTokenSource, $responseTransformer); - }); - } -} diff --git a/src/Client/ProvideAmpArtaxClientOptions.php b/src/Client/ProvideAmpArtaxClientOptions.php deleted file mode 100644 index cd1aa87db..000000000 --- a/src/Client/ProvideAmpArtaxClientOptions.php +++ /dev/null @@ -1,15 +0,0 @@ -executeArtaxEndpoint(new SystemEvents($queryParameters), $fetch); - } - - /** - * {@inheritdoc} - */ - public function executeArtaxEndpoint(AmpArtaxEndpoint $endpoint, string $fetch = self::FETCH_OBJECT): Promise - { - return call(function () use ($endpoint, $fetch) { - [$bodyHeaders, $body] = $endpoint->getBody($this->serializer); - $queryString = $endpoint->getQueryString(); - $uri = '' !== $queryString ? $endpoint->getUri().'?'.$queryString : $endpoint->getUri(); - $request = new Request($uri, $endpoint->getMethod()); - $request = $request->withBody($body); - $request = $request->withHeaders($endpoint->getHeaders($bodyHeaders)); - $options = []; - if ($endpoint instanceof ProvideAmpArtaxClientOptions) { - $options = $endpoint->getAmpArtaxClientOptions(); - } - - if ($endpoint instanceof AmpArtaxStreamEndpoint) { - $cancellationTokenSource = new CancellationTokenSource(); - - return $endpoint->parseArtaxStreamResponse( - yield $this->httpClient->request($request, $options, $cancellationTokenSource->getToken()), - $this->serializer, - $cancellationTokenSource, - $fetch - ); - } - - return $endpoint->parseArtaxResponse( - yield $this->httpClient->request($request, $options), - $this->serializer, - $fetch - ); - }); - } -} diff --git a/src/DockerAsyncClient.php b/src/DockerAsyncClient.php deleted file mode 100644 index ca440bd7b..000000000 --- a/src/DockerAsyncClient.php +++ /dev/null @@ -1,87 +0,0 @@ -resolveOptions($options); - $socketPool = new HttpSocketPool(new StaticSocketPool($options['remote_socket'], new BasicSocketPool())); - $this->client = new DefaultClient(null, $socketPool, $options['ssl']); - } - - public function request($uriOrRequest, array $options = [], CancellationToken $cancellation = null): Promise - { - if ($uriOrRequest instanceof Request) { - $uriOrRequest = $uriOrRequest->withUri('http://localhost'.$uriOrRequest->getUri()); - } - - return $this->client->request($uriOrRequest, $options, $cancellation); - } - - protected function resolveOptions(array $options = []): array - { - $resolver = new OptionsResolver(); - - $resolver->setDefaults([ - 'ssl' => null, - ]); - - $resolver->setRequired([ - 'remote_socket', - ]); - - $resolver->setAllowedTypes('ssl', ['null', ClientTlsContext::class]); - - return $resolver->resolve($options); - } - - public static function createFromEnv(): self - { - $options = [ - 'remote_socket' => \getenv('DOCKER_HOST') ? \getenv('DOCKER_HOST') : 'unix:///var/run/docker.sock', - ]; - - if (\getenv('DOCKER_TLS_VERIFY') && '1' === \getenv('DOCKER_TLS_VERIFY')) { - if (!\getenv('DOCKER_CERT_PATH')) { - throw new \RuntimeException('Connection to docker has been set to use TLS, but no PATH is defined for certificate in DOCKER_CERT_PATH docker environment variable'); - } - - $tlsContext = new ClientTlsContext(); - - $cafile = \getenv('DOCKER_CERT_PATH').DIRECTORY_SEPARATOR.'ca.pem'; - $certfile = \getenv('DOCKER_CERT_PATH').DIRECTORY_SEPARATOR.'cert.pem'; - $keyfile = \getenv('DOCKER_CERT_PATH').DIRECTORY_SEPARATOR.'key.pem'; - - $certificate = new Certificate($certfile, $keyfile); - - $tlsContext = $tlsContext->withCaFile($cafile); - $tlsContext = $tlsContext->withCertificate($certificate); - - if (\getenv('DOCKER_PEER_NAME')) { - $tlsContext = $tlsContext->withPeerName(\getenv('DOCKER_PEER_NAME')); - } - - $options['ssl'] = $tlsContext; - } - - return new static($options); - } -} diff --git a/src/Stream/ArtaxCallbackStream.php b/src/Stream/ArtaxCallbackStream.php deleted file mode 100644 index f85d5219e..000000000 --- a/src/Stream/ArtaxCallbackStream.php +++ /dev/null @@ -1,78 +0,0 @@ -stream = $stream; - $this->cancellationTokenSource = $cancellationTokenSource; - $this->chunkTransformer = $chunkTransformer; - } - - /** - * Called when there is a new frame from the stream. - * - * @param callable $onNewFrame - */ - public function onFrame(callable $onNewFrame): void - { - $this->onNewFrameCallables[] = $onNewFrame; - } - - /** - * Consume stream chunks. - * - * @return Promise - */ - public function listen(): Promise - { - return call(function () { - while (null !== ($chunk = yield $this->stream->read())) { - foreach ($this->onNewFrameCallables as $newFrameCallable) { - $newFrameCallable($this->transformChunk($chunk)); - } - } - }); - } - - /** - * Stop consuming stream chunks. - */ - public function cancel(): void - { - $this->cancellationTokenSource->cancel(); - } - - /** - * Transform stream chunks if required. - * - * @param string $chunk - * - * @return mixed The raw chunk or the transformed chunk - */ - private function transformChunk(string $chunk) - { - if (null === $this->chunkTransformer) { - return $chunk; - } - - return \call_user_func($this->chunkTransformer, $chunk); - } -} diff --git a/tests/DockerAsyncTest.php b/tests/DockerAsyncTest.php deleted file mode 100644 index 29b2f3bf1..000000000 --- a/tests/DockerAsyncTest.php +++ /dev/null @@ -1,86 +0,0 @@ -assertInstanceOf(DockerAsync::class, DockerAsync::create()); - } - - public function testAsync(): void - { - Loop::run(function () { - $docker = DockerAsync::create(); - - $containerConfig = new ContainersCreatePostBody(); - $containerConfig->setImage('busybox:latest'); - $containerConfig->setCmd(['echo', '-n', 'output']); - $containerConfig->setAttachStdout(true); - $containerConfig->setLabels(new \ArrayObject(['docker-php-test' => 'true'])); - - $response = yield $docker->imageCreate('', [ - 'fromImage' => 'busybox:latest', - ], [], DockerAsync::FETCH_RESPONSE); - - yield $response->getBody(); - - $containerCreate = yield $docker->containerCreate($containerConfig); - $containerStart = yield $docker->containerStart($containerCreate->getId()); - $containerInfo = yield $docker->containerInspect($containerCreate->getId()); - - $this->assertSame($containerCreate->getId(), $containerInfo->getId()); - }); - } - - public function testSystemEventsAllowTheConsumptionOfDockerEvents(): void - { - $matchedEvents = []; - - Loop::run(function () use (&$matchedEvents) { - $docker = DockerAsync::create(); - - /** @var ArtaxCallbackStream $events */ - $events = yield $docker->systemEvents([ - 'filters' => \json_encode( - [ - 'type' => ['container'], - 'action' => ['create'], - ] - ), - ]); - $events->onFrame(function ($event) use (&$matchedEvents): void { - if (\is_object($event) - && $event instanceof EventsGetResponse200 - && 'create' === $event->getAction() - && 'container' === $event->getType() - ) { - $matchedEvents[] = $event; - } - }); - - $events->listen(); - - $containerConfig = new ContainersCreatePostBody(); - $containerConfig->setImage('busybox:latest'); - $containerConfig->setCmd(['echo', '-n', 'output']); - - yield $docker->containerCreate($containerConfig); - - Loop::delay(1000, function (): void { - Loop::stop(); - }); - }); - - $this->assertCount(1, $matchedEvents); - } -} From 9743fe3c0071d124546c84ed305ab940f897e97e Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 15 Dec 2020 16:37:23 -0300 Subject: [PATCH 03/85] Updated phpunit configuration to follow version update --- phpunit.xml.dist | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c40525666..d1446e798 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,27 +1,25 @@ - - + - - - - tests/ - - - - - src - - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd" + backupGlobals="false" + backupStaticAttributes="false" + colors="true" + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + processIsolation="false" + stopOnFailure="false" + bootstrap="vendor/autoload.php"> + + + src + + + + + tests/ + + From cf74ddb1dee144a958a4dad3695fe5369d24db8e Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 15 Dec 2020 17:19:32 -0300 Subject: [PATCH 04/85] Updated README.md and CONTRIBUTING.md --- CONTRIBUTING.md | 4 ++-- README.md | 32 +++++++++++--------------------- 2 files changed, 13 insertions(+), 23 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6be589b9f..d25bfef16 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,9 +67,9 @@ $ git pull --rebase upstream master $ git push -f origin feature-or-bug-fix-description ``` -## Internal +## Internal -This library consist, for the most part, of auto generated code where the reference is an [Open API Specification (Swagger v2)](https://openapis.org/). In order to modify API +This library consist, for the most part, of auto generated code where the reference is an [Open API Specification (Swagger v2)](https://openapis.org/). In order to modify API endpoint or requested / returned object, you will need to update the `docker-swagger.json` file instead of files in the `generated` directory. There is a bash script at the root of this repository `generate.sh` which helps launching the command to generate files according to the diff --git a/README.md b/README.md index 27464be66..933def843 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,4 @@ -# No longer maintained - -I'm backing off maintaining this library due to a lack of motivation, time and usage of docker, contact me on twitter https://twitter.com/joelwurtz if you wish to take over this repository (or just do a fork). - -Docker PHP -========== +# Docker PHP **Docker PHP** (for lack of a better name) is a [Docker](http://docker.com/) client written in PHP. This library aim to reach 100% API support of the Docker Engine. @@ -19,8 +14,7 @@ The test suite currently passes against Docker Remote API v1.25 to v1.36. [![Total Downloads](https://img.shields.io/packagist/dt/docker-php/docker-php.svg?style=flat-square)](https://packagist.org/packages/docker-php/docker-php) [![#docker-php on Slack](http://slack.httplug.io/badge.svg)](http://slack.httplug.io) -Installation ------------- +## Installation The recommended way to install Docker PHP is of course to use [Composer](http://getcomposer.org/): @@ -28,23 +22,20 @@ The recommended way to install Docker PHP is of course to use [Composer](http:// composer require docker-php/docker-php ``` -Docker API Version ------------------- +## Docker API Version -By default it will use the last version of docker api available, if you want to fix a version (like 1.25) you can add this +By default it will use the last version of docker api available, if you want to fix a version (like 1.25) you can add this requirement to composer: ```bash composer require "docker-php/docker-php-api:4.1.25.*" ``` -Usage ------ +## Usage See [the documentation](http://docker-php.readthedocs.org/en/latest/). -Unit Tests ----------- +## Unit Tests Setup the test suite using [Composer](http://getcomposer.org/) if not already done: @@ -58,17 +49,16 @@ Run it using [PHPUnit](http://phpunit.de/): $ composer test ``` -Contributing ------------- +## Contributing Please see [CONTRIBUTING](CONTRIBUTING.md) for details. -Credits -------- +## Credits This README heavily inspired by [willdurand/Negotiation](https://github.com/willdurand/Negotiation) by @willdurand. This guy is pretty awesome. -License -------- +This library is a fork of the original [docker-php](https://github.com/docker-php/docker-php), created by [Geoffrey Bachelet](https://github.com/ubermuda) and [Joel Wurtz](https://github.com/joelwurtz). + +## License The MIT License (MIT). Please see [License File](LICENSE) for more information. From c18d7f970283d3564f5735cca2c214567aaa4484 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 15 Dec 2020 17:23:51 -0300 Subject: [PATCH 05/85] Updated Docker client to conform to Jane generated client --- composer.json | 2 +- src/Context/Context.php | 6 +- src/Context/ContextBuilder.php | 4 +- src/Docker.php | 24 +++---- src/DockerClientFactory.php | 45 +++++++------ src/Endpoint/ContainerAttach.php | 22 +++--- src/Endpoint/ContainerAttachWebsocket.php | 41 ++++++------ src/Endpoint/ContainerLogs.php | 21 ++---- src/Endpoint/ExecStart.php | 21 ++---- src/Endpoint/ImageBuild.php | 27 +++----- src/Endpoint/ImageCreate.php | 21 ++---- src/Endpoint/ImagePush.php | 21 ++---- src/Endpoint/SystemEvents.php | 34 +++------- src/Stream/AttachWebsocketStream.php | 2 +- src/Stream/BuildStream.php | 2 +- src/Stream/CallbackStream.php | 2 - src/Stream/CreateImageStream.php | 2 +- src/Stream/DockerRawStream.php | 6 -- src/Stream/EventStream.php | 2 +- src/Stream/PushStream.php | 2 +- src/Stream/TarStream.php | 81 ++++++++++++++++++++++- tests/Context/ContextBuilderTest.php | 80 +++++++++++----------- tests/Context/ContextTest.php | 17 +++-- tests/DockerClientFactoryTest.php | 15 ++--- tests/Resource/ContainerResourceTest.php | 42 +++++++----- tests/Resource/ImageResourceTest.php | 6 +- tests/Stream/MultiJsonStreamTest.php | 12 ++-- 27 files changed, 285 insertions(+), 275 deletions(-) diff --git a/composer.json b/composer.json index 500a8e1bd..7ecf5f447 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "require": { "php": ">=7.1", "beluga-php/docker-php-api": "6.1.*", - "guzzlehttp/psr7": "^1.2", + "nyholm/psr7": "^1.3", "php-http/client-common": "^2.3", "php-http/socket-client": "^2.0", "psr/http-message": "^1.0", diff --git a/src/Context/Context.php b/src/Context/Context.php index 24e8ce0c3..06082510c 100644 --- a/src/Context/Context.php +++ b/src/Context/Context.php @@ -86,7 +86,7 @@ public function setDirectory($directory): void */ public function getDockerfileContent() { - return \file_get_contents($this->directory.DIRECTORY_SEPARATOR.'Dockerfile'); + return \file_get_contents($this->directory.\DIRECTORY_SEPARATOR.'Dockerfile'); } /** @@ -114,7 +114,7 @@ public function read() */ public function toTar() { - $process = new Process('/usr/bin/env tar c .', $this->directory); + $process = new Process(['/usr/bin/env', 'tar', '-c', '.'], $this->directory); $process->run(); if (!$process->isSuccessful()) { @@ -132,7 +132,7 @@ public function toTar() public function toStream() { if (!\is_resource($this->process)) { - $this->process = \proc_open('/usr/bin/env tar c .', [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes, $this->directory); + $this->process = \proc_open('/usr/bin/env tar -c .', [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes, $this->directory); $this->stream = $pipes[1]; } diff --git a/src/Context/ContextBuilder.php b/src/Context/ContextBuilder.php index 74a4308bf..e8b37365b 100644 --- a/src/Context/ContextBuilder.php +++ b/src/Context/ContextBuilder.php @@ -276,7 +276,7 @@ private function write($directory): void { $dockerfile = []; // Insert a FROM instruction if the file does not start with one. - if (empty($this->commands) || $this->commands[0]['type'] !== 'FROM') { + if (empty($this->commands) || 'FROM' !== $this->commands[0]['type']) { $dockerfile[] = 'FROM base'; } foreach ($this->commands as $command) { @@ -325,7 +325,7 @@ private function write($directory): void $dockerfile[] = 'CMD '.$this->command; } - $this->fs->dumpFile($directory.DIRECTORY_SEPARATOR.'Dockerfile', \implode(PHP_EOL, $dockerfile)); + $this->fs->dumpFile($directory.\DIRECTORY_SEPARATOR.'Dockerfile', \implode(PHP_EOL, $dockerfile)); } /** diff --git a/src/Docker.php b/src/Docker.php index 591acb5f0..bdfe028fd 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -5,7 +5,7 @@ namespace Docker; use Docker\API\Client; -use Docker\API\Model\AuthConfig; +use Docker\API\Model\ExecIdStartPostBody; use Docker\Endpoint\ContainerAttach; use Docker\Endpoint\ContainerAttachWebsocket; use Docker\Endpoint\ContainerLogs; @@ -25,7 +25,7 @@ class Docker extends Client */ public function containerAttach(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT) { - return $this->executePsr7Endpoint(new ContainerAttach($id, $queryParameters), $fetch); + return $this->executeEndpoint(new ContainerAttach($id, $queryParameters), $fetch); } /** @@ -33,7 +33,7 @@ public function containerAttach(string $id, array $queryParameters = [], string */ public function containerAttachWebsocket(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT) { - return $this->executePsr7Endpoint(new ContainerAttachWebsocket($id, $queryParameters), $fetch); + return $this->executeEndpoint(new ContainerAttachWebsocket($id, $queryParameters), $fetch); } /** @@ -41,15 +41,15 @@ public function containerAttachWebsocket(string $id, array $queryParameters = [] */ public function containerLogs(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT) { - return $this->executePsr7Endpoint(new ContainerLogs($id, $queryParameters), $fetch); + return $this->executeEndpoint(new ContainerLogs($id, $queryParameters), $fetch); } /** * {@inheritdoc} */ - public function execStart(string $id, \Docker\API\Model\ExecIdStartPostBody $execStartConfig, string $fetch = self::FETCH_OBJECT) + public function execStart(string $id, ExecIdStartPostBody $execStartConfig, string $fetch = self::FETCH_OBJECT) { - return $this->executePsr7Endpoint(new ExecStart($id, $execStartConfig), $fetch); + return $this->executeEndpoint(new ExecStart($id, $execStartConfig), $fetch); } /** @@ -57,7 +57,7 @@ public function execStart(string $id, \Docker\API\Model\ExecIdStartPostBody $exe */ public function imageBuild($inputStream, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) { - return $this->executePsr7Endpoint(new ImageBuild($inputStream, $queryParameters, $headerParameters), $fetch); + return $this->executeEndpoint(new ImageBuild($inputStream, $queryParameters, $headerParameters), $fetch); } /** @@ -65,7 +65,7 @@ public function imageBuild($inputStream, array $queryParameters = [], array $hea */ public function imageCreate(string $inputImage, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) { - return $this->executePsr7Endpoint(new ImageCreate($inputImage, $queryParameters, $headerParameters), $fetch); + return $this->executeEndpoint(new ImageCreate($inputImage, $queryParameters, $headerParameters), $fetch); } /** @@ -77,7 +77,7 @@ public function imagePush(string $name, array $queryParameters = [], array $head $headerParameters['X-Registry-Auth'] = \base64_encode($this->serializer->serialize($headerParameters['X-Registry-Auth'], 'json')); } - return $this->executePsr7Endpoint(new ImagePush($name, $queryParameters, $headerParameters), $fetch); + return $this->executeEndpoint(new ImagePush($name, $queryParameters, $headerParameters), $fetch); } /** @@ -85,15 +85,15 @@ public function imagePush(string $name, array $queryParameters = [], array $head */ public function systemEvents(array $queryParameters = [], string $fetch = self::FETCH_OBJECT) { - return $this->executePsr7Endpoint(new SystemEvents($queryParameters), $fetch); + return $this->executeEndpoint(new SystemEvents($queryParameters), $fetch); } - public static function create($httpClient = null) + public static function create($httpClient = null, array $additionalPlugins = []) { if (null === $httpClient) { $httpClient = DockerClientFactory::createFromEnv(); } - return parent::create($httpClient); + return parent::create($httpClient, $additionalPlugins); } } diff --git a/src/DockerClientFactory.php b/src/DockerClientFactory.php index 918d87240..20a973d59 100644 --- a/src/DockerClientFactory.php +++ b/src/DockerClientFactory.php @@ -4,42 +4,45 @@ namespace Docker; -use GuzzleHttp\Psr7\Uri; use Http\Client\Common\Plugin\AddHostPlugin; +use Http\Client\Common\Plugin\AddPathPlugin; use Http\Client\Common\Plugin\ContentLengthPlugin; use Http\Client\Common\Plugin\DecoderPlugin; use Http\Client\Common\PluginClientFactory; -use Http\Client\HttpClient; -use Http\Client\Socket\Client as SocketHttpClient; -use Http\Message\MessageFactory\GuzzleMessageFactory; +use Http\Client\Socket\Client; +use Http\Discovery\UriFactoryDiscovery; +use Psr\Http\Client\ClientInterface; final class DockerClientFactory { - /** - * ( . - */ - public static function create(array $config = [], PluginClientFactory $pluginClientFactory = null): HttpClient + public static function create(array $config = [], PluginClientFactory $pluginClientFactory = null): ClientInterface { if (!\array_key_exists('remote_socket', $config)) { $config['remote_socket'] = 'unix:///var/run/docker.sock'; } - $messageFactory = new GuzzleMessageFactory(); - $socketClient = new SocketHttpClient($messageFactory, $config); + $socketClient = new Client($config); + + $uriFactory = UriFactoryDiscovery::find(); $host = \preg_match('/unix:\/\//', $config['remote_socket']) ? 'http://localhost' : $config['remote_socket']; $pluginClientFactory = $pluginClientFactory ?? new PluginClientFactory(); - return $pluginClientFactory->createClient($socketClient, [ - new ContentLengthPlugin(), - new DecoderPlugin(), - new AddHostPlugin(new Uri($host)), - ], [ - 'client_name' => 'docker-client', - ]); + return $pluginClientFactory->createClient( + $socketClient, + [ + new ContentLengthPlugin(), + new DecoderPlugin(), + new AddPathPlugin($uriFactory->createUri('/v1.41')), + new AddHostPlugin($uriFactory->createUri($host)), + ], + [ + 'client_name' => 'docker-client', + ] + ); } - public static function createFromEnv(PluginClientFactory $pluginClientFactory = null): HttpClient + public static function createFromEnv(PluginClientFactory $pluginClientFactory = null): ClientInterface { $options = [ 'remote_socket' => \getenv('DOCKER_HOST') ? \getenv('DOCKER_HOST') : 'unix:///var/run/docker.sock', @@ -50,9 +53,9 @@ public static function createFromEnv(PluginClientFactory $pluginClientFactory = throw new \RuntimeException('Connection to docker has been set to use TLS, but no PATH is defined for certificate in DOCKER_CERT_PATH docker environment variable'); } - $cafile = \getenv('DOCKER_CERT_PATH').DIRECTORY_SEPARATOR.'ca.pem'; - $certfile = \getenv('DOCKER_CERT_PATH').DIRECTORY_SEPARATOR.'cert.pem'; - $keyfile = \getenv('DOCKER_CERT_PATH').DIRECTORY_SEPARATOR.'key.pem'; + $cafile = \getenv('DOCKER_CERT_PATH').\DIRECTORY_SEPARATOR.'ca.pem'; + $certfile = \getenv('DOCKER_CERT_PATH').\DIRECTORY_SEPARATOR.'cert.pem'; + $keyfile = \getenv('DOCKER_CERT_PATH').\DIRECTORY_SEPARATOR.'key.pem'; $stream_context = [ 'cafile' => $cafile, diff --git a/src/Endpoint/ContainerAttach.php b/src/Endpoint/ContainerAttach.php index a2d180e93..0676e3830 100644 --- a/src/Endpoint/ContainerAttach.php +++ b/src/Endpoint/ContainerAttach.php @@ -6,27 +6,21 @@ use Docker\API\Endpoint\ContainerAttach as BaseEndpoint; use Docker\Stream\DockerRawStream; -use Jane\OpenApiRuntime\Client\Client; -use Jane\OpenApiRuntime\Client\Exception\InvalidFetchModeException; -use Psr\Http\Message\ResponseInterface; +use Nyholm\Psr7\Stream; use Symfony\Component\Serializer\SerializerInterface; class ContainerAttach extends BaseEndpoint { - public function parsePSR7Response(ResponseInterface $response, SerializerInterface $serializer, string $fetchMode = Client::FETCH_OBJECT) + protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) { - if (Client::FETCH_OBJECT === $fetchMode) { - if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $response->getHeaderLine('Content-Type')) { - return new DockerRawStream($response->getBody()); - } + if (200 === $status && DockerRawStream::HEADER === $contentType) { + $streamFactory = StreamFactoryDiscovery::find(); + $stream = $streamFactory->createStream($jsonStream); + $stream->rewind(); - return $this->transformResponseBody((string) $response->getBody(), $response->getStatusCode(), $serializer); + return new DockerRawStream($stream); } - if (Client::FETCH_RESPONSE === $fetchMode) { - return $response; - } - - throw new InvalidFetchModeException(\sprintf('Fetch mode %s is not supported', $fetchMode)); + return parent::transformResponseBody($body, $status, $serializer, $contentType); } } diff --git a/src/Endpoint/ContainerAttachWebsocket.php b/src/Endpoint/ContainerAttachWebsocket.php index fefb3638a..692599ec8 100644 --- a/src/Endpoint/ContainerAttachWebsocket.php +++ b/src/Endpoint/ContainerAttachWebsocket.php @@ -6,39 +6,36 @@ use Docker\API\Endpoint\ContainerAttachWebsocket as BaseEndpoint; use Docker\Stream\AttachWebsocketStream; -use Jane\OpenApiRuntime\Client\Client; -use Jane\OpenApiRuntime\Client\Exception\InvalidFetchModeException; -use Psr\Http\Message\ResponseInterface; +use Nyholm\Psr7\Stream; use Symfony\Component\Serializer\SerializerInterface; class ContainerAttachWebsocket extends BaseEndpoint { public function getExtraHeaders(): array { - return \array_merge(parent::getExtraHeaders(), [ - 'Host' => 'localhost', - 'Origin' => 'php://docker-php', - 'Upgrade' => 'websocket', - 'Connection' => 'Upgrade', - 'Sec-WebSocket-Version' => '13', - 'Sec-WebSocket-Key' => \base64_encode(\uniqid()), - ]); + return \array_merge( + parent::getExtraHeaders(), + [ + 'Host' => 'localhost', + 'Origin' => 'php://docker-php', + 'Upgrade' => 'websocket', + 'Connection' => 'Upgrade', + 'Sec-WebSocket-Version' => '13', + 'Sec-WebSocket-Key' => \base64_encode(\uniqid()), + ] + ); } - public function parsePSR7Response(ResponseInterface $response, SerializerInterface $serializer, string $fetchMode = Client::FETCH_OBJECT) + protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) { - if (Client::FETCH_OBJECT === $fetchMode) { - if (101 === $response->getStatusCode()) { - return new AttachWebsocketStream($response->getBody()); - } + if (200 === $status && DockerRawStream::HEADER === $contentType) { + $streamFactory = StreamFactoryDiscovery::find(); + $stream = $streamFactory->createStream($jsonStream); + $stream->rewind(); - return $this->transformResponseBody((string) $response->getBody(), $response->getStatusCode(), $serializer); + return new AttachWebsocketStream($stream); } - if (Client::FETCH_RESPONSE === $fetchMode) { - return $response; - } - - throw new InvalidFetchModeException(\sprintf('Fetch mode %s is not supported', $fetchMode)); + return parent::transformResponseBody($body, $status, $serializer, $contentType); } } diff --git a/src/Endpoint/ContainerLogs.php b/src/Endpoint/ContainerLogs.php index 42335752f..22d6c1c0e 100644 --- a/src/Endpoint/ContainerLogs.php +++ b/src/Endpoint/ContainerLogs.php @@ -6,27 +6,20 @@ use Docker\API\Endpoint\ContainerLogs as BaseEndpoint; use Docker\Stream\DockerRawStream; -use Jane\OpenApiRuntime\Client\Client; -use Jane\OpenApiRuntime\Client\Exception\InvalidFetchModeException; -use Psr\Http\Message\ResponseInterface; +use Nyholm\Psr7\Stream; use Symfony\Component\Serializer\SerializerInterface; class ContainerLogs extends BaseEndpoint { - public function parsePSR7Response(ResponseInterface $response, SerializerInterface $serializer, string $fetchMode = Client::FETCH_OBJECT) + protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) { - if (Client::FETCH_OBJECT === $fetchMode) { - if (200 === $response->getStatusCode()) { - return new DockerRawStream($response->getBody()); - } + if (200 === $status && DockerRawStream::HEADER === $contentType) { + $stream = Stream::create($body); + $stream->rewind(); - return $this->transformResponseBody((string) $response->getBody(), $response->getStatusCode(), $serializer); + return new DockerRawStream($stream); } - if (Client::FETCH_RESPONSE === $fetchMode) { - return $response; - } - - throw new InvalidFetchModeException(\sprintf('Fetch mode %s is not supported', $fetchMode)); + return parent::transformResponseBody($body, $status, $serializer, $contentType); } } diff --git a/src/Endpoint/ExecStart.php b/src/Endpoint/ExecStart.php index 48ddd5c8d..c16a83807 100644 --- a/src/Endpoint/ExecStart.php +++ b/src/Endpoint/ExecStart.php @@ -6,27 +6,20 @@ use Docker\API\Endpoint\ExecStart as BaseEndpoint; use Docker\Stream\DockerRawStream; -use Jane\OpenApiRuntime\Client\Client; -use Jane\OpenApiRuntime\Client\Exception\InvalidFetchModeException; -use Psr\Http\Message\ResponseInterface; +use Nyholm\Psr7\Stream; use Symfony\Component\Serializer\SerializerInterface; class ExecStart extends BaseEndpoint { - public function parsePSR7Response(ResponseInterface $response, SerializerInterface $serializer, string $fetchMode = Client::FETCH_OBJECT) + protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) { - if (Client::FETCH_OBJECT === $fetchMode) { - if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $response->getHeaderLine('Content-Type')) { - return new DockerRawStream($response->getBody()); - } + if (200 === $status && DockerRawStream::HEADER === $contentType) { + $stream = Stream::create($body); + $stream->rewind(); - return $this->transformResponseBody((string) $response->getBody(), $response->getStatusCode(), $serializer); + return new DockerRawStream($stream); } - if (Client::FETCH_RESPONSE === $fetchMode) { - return $response; - } - - throw new InvalidFetchModeException(\sprintf('Fetch mode %s is not supported', $fetchMode)); + return parent::transformResponseBody($body, $status, $serializer, $contentType); } } diff --git a/src/Endpoint/ImageBuild.php b/src/Endpoint/ImageBuild.php index 65d3353fc..62af3a9d5 100644 --- a/src/Endpoint/ImageBuild.php +++ b/src/Endpoint/ImageBuild.php @@ -7,38 +7,31 @@ use Docker\API\Endpoint\ImageBuild as BaseEndpoint; use Docker\Stream\BuildStream; use Docker\Stream\TarStream; -use Jane\OpenApiRuntime\Client\Client; -use Jane\OpenApiRuntime\Client\Exception\InvalidFetchModeException; -use Psr\Http\Message\ResponseInterface; +use Nyholm\Psr7\Stream; use Symfony\Component\Serializer\SerializerInterface; class ImageBuild extends BaseEndpoint { - public function getBody(\Symfony\Component\Serializer\SerializerInterface $serializer, \Http\Message\StreamFactory $streamFactory = null): array + public function getBody(SerializerInterface $serializer, $streamFactory = null): array { $body = $this->body; if (\is_resource($body)) { - $body = new TarStream($body); + $body = new TarStream(Stream::create($body)); } - return [[], $body]; + return [['Content-Type' => ['application/octet-stream']], $body]; } - public function parsePSR7Response(ResponseInterface $response, SerializerInterface $serializer, string $fetchMode = Client::FETCH_OBJECT) + protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) { - if (Client::FETCH_OBJECT === $fetchMode) { - if (200 === $response->getStatusCode()) { - return new BuildStream($response->getBody(), $serializer); - } + if (200 === $status) { + $stream = Stream::create($body); + $stream->rewind(); - return $this->transformResponseBody((string) $response->getBody(), $response->getStatusCode(), $serializer); + return new BuildStream($stream, $serializer); } - if (Client::FETCH_RESPONSE === $fetchMode) { - return $response; - } - - throw new InvalidFetchModeException(\sprintf('Fetch mode %s is not supported', $fetchMode)); + return parent::transformResponseBody($body, $status, $serializer, $contentType); } } diff --git a/src/Endpoint/ImageCreate.php b/src/Endpoint/ImageCreate.php index 196ba3e5e..120982bd7 100644 --- a/src/Endpoint/ImageCreate.php +++ b/src/Endpoint/ImageCreate.php @@ -6,27 +6,20 @@ use Docker\API\Endpoint\ImageCreate as BaseEndpoint; use Docker\Stream\CreateImageStream; -use Jane\OpenApiRuntime\Client\Client; -use Jane\OpenApiRuntime\Client\Exception\InvalidFetchModeException; -use Psr\Http\Message\ResponseInterface; +use Nyholm\Psr7\Stream; use Symfony\Component\Serializer\SerializerInterface; class ImageCreate extends BaseEndpoint { - public function parsePSR7Response(ResponseInterface $response, SerializerInterface $serializer, string $fetchMode = Client::FETCH_OBJECT) + protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) { - if (Client::FETCH_OBJECT === $fetchMode) { - if (200 === $response->getStatusCode()) { - return new CreateImageStream($response->getBody(), $serializer); - } + if (200 === $status) { + $stream = Stream::create($body); + $stream->rewind(); - return $this->transformResponseBody((string) $response->getBody(), $response->getStatusCode(), $serializer); + return new CreateImageStream($stream, $serializer); } - if (Client::FETCH_RESPONSE === $fetchMode) { - return $response; - } - - throw new InvalidFetchModeException(\sprintf('Fetch mode %s is not supported', $fetchMode)); + return parent::transformResponseBody($body, $status, $serializer, $contentType); } } diff --git a/src/Endpoint/ImagePush.php b/src/Endpoint/ImagePush.php index 3d2eabcca..ed64493d0 100644 --- a/src/Endpoint/ImagePush.php +++ b/src/Endpoint/ImagePush.php @@ -6,9 +6,7 @@ use Docker\API\Endpoint\ImagePush as BaseEndpoint; use Docker\Stream\PushStream; -use Jane\OpenApiRuntime\Client\Client; -use Jane\OpenApiRuntime\Client\Exception\InvalidFetchModeException; -use Psr\Http\Message\ResponseInterface; +use Nyholm\Psr7\Stream; use Symfony\Component\Serializer\SerializerInterface; class ImagePush extends BaseEndpoint @@ -18,20 +16,15 @@ public function getUri(): string return \str_replace(['{name}'], [\urlencode($this->name)], '/images/{name}/push'); } - public function parsePSR7Response(ResponseInterface $response, SerializerInterface $serializer, string $fetchMode = Client::FETCH_OBJECT) + protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) { - if (Client::FETCH_OBJECT === $fetchMode) { - if (200 === $response->getStatusCode()) { - return new PushStream($response->getBody(), $serializer); - } + if (200 === $status) { + $stream = Stream::create($body); + $stream->rewind(); - return $this->transformResponseBody((string) $response->getBody(), $response->getStatusCode(), $serializer); + return new PushStream($stream, $serializer); } - if (Client::FETCH_RESPONSE === $fetchMode) { - return $response; - } - - throw new InvalidFetchModeException(\sprintf('Fetch mode %s is not supported', $fetchMode)); + return parent::transformResponseBody($body, $status, $serializer, $contentType); } } diff --git a/src/Endpoint/SystemEvents.php b/src/Endpoint/SystemEvents.php index 712e67da5..1526fb817 100644 --- a/src/Endpoint/SystemEvents.php +++ b/src/Endpoint/SystemEvents.php @@ -4,40 +4,22 @@ namespace Docker\Endpoint; -use Amp\Artax\Client as ArtaxClient; use Docker\API\Endpoint\SystemEvents as BaseEndpoint; -use Docker\Client\AmpArtaxStreamEndpoint; -use Docker\Client\AmpArtaxStreamEndpointTrait; -use Docker\Client\ProvideAmpArtaxClientOptions; use Docker\Stream\EventStream; -use Jane\OpenApiRuntime\Client\Client; -use Jane\OpenApiRuntime\Client\Exception\InvalidFetchModeException; -use Psr\Http\Message\ResponseInterface; +use Nyholm\Psr7\Stream; use Symfony\Component\Serializer\SerializerInterface; -class SystemEvents extends BaseEndpoint implements ProvideAmpArtaxClientOptions, AmpArtaxStreamEndpoint +class SystemEvents extends BaseEndpoint { - use AmpArtaxStreamEndpointTrait; - - public function getAmpArtaxClientOptions(): array - { - return [ArtaxClient::OP_TRANSFER_TIMEOUT => 0]; - } - - public function parsePSR7Response(ResponseInterface $response, SerializerInterface $serializer, string $fetchMode = Client::FETCH_OBJECT) + protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) { - if (Client::FETCH_OBJECT === $fetchMode) { - if (200 === $response->getStatusCode()) { - return new EventStream($response->getBody(), $serializer); - } - - return $this->transformResponseBody((string) $response->getBody(), $response->getStatusCode(), $serializer); - } + if (200 === $status) { + $stream = Stream::create($body); + $stream->rewind(); - if (Client::FETCH_RESPONSE === $fetchMode) { - return $response; + return new EventStream($stream, $serializer); } - throw new InvalidFetchModeException(\sprintf('Fetch mode %s is not supported', $fetchMode)); + return parent::transformResponseBody($body, $status, $serializer, $contentType); } } diff --git a/src/Stream/AttachWebsocketStream.php b/src/Stream/AttachWebsocketStream.php index 402e417ca..10a12e546 100644 --- a/src/Stream/AttachWebsocketStream.php +++ b/src/Stream/AttachWebsocketStream.php @@ -87,7 +87,7 @@ public function write($data): void * @param int $waitMicroTime Time to wait in microseconds before return false * @param bool $getFrame Whether to return the frame of websocket or only the data * - * @return null|false|string|array Null for socket not available, false for no message, string for the last message and the frame array if $getFrame is set to true + * @return false|string|array|null Null for socket not available, false for no message, string for the last message and the frame array if $getFrame is set to true */ public function read($waitTime = 0, $waitMicroTime = 200000, $getFrame = false) { diff --git a/src/Stream/BuildStream.php b/src/Stream/BuildStream.php index b6ba9e705..34f32ac41 100644 --- a/src/Stream/BuildStream.php +++ b/src/Stream/BuildStream.php @@ -12,7 +12,7 @@ class BuildStream extends MultiJsonStream { /** - * [@inheritdoc}. + * {@inheritdoc}. */ protected function getDecodeClass() { diff --git a/src/Stream/CallbackStream.php b/src/Stream/CallbackStream.php index 62b746130..459f20ab4 100644 --- a/src/Stream/CallbackStream.php +++ b/src/Stream/CallbackStream.php @@ -19,8 +19,6 @@ public function __construct(StreamInterface $stream) /** * Called when there is a new frame from the stream. - * - * @param callable $onNewFrame */ public function onFrame(callable $onNewFrame): void { diff --git a/src/Stream/CreateImageStream.php b/src/Stream/CreateImageStream.php index f6cb92ca9..8d5aea7c6 100644 --- a/src/Stream/CreateImageStream.php +++ b/src/Stream/CreateImageStream.php @@ -12,7 +12,7 @@ class CreateImageStream extends MultiJsonStream { /** - * [@inheritdoc}. + * {@inheritdoc}. */ protected function getDecodeClass() { diff --git a/src/Stream/DockerRawStream.php b/src/Stream/DockerRawStream.php index 5f71d629c..bd97f817a 100644 --- a/src/Stream/DockerRawStream.php +++ b/src/Stream/DockerRawStream.php @@ -29,8 +29,6 @@ public function __construct(StreamInterface $stream) /** * Add a callable to read stdin. - * - * @param callable $callback */ public function onStdin(callable $callback): void { @@ -39,8 +37,6 @@ public function onStdin(callable $callback): void /** * Add a callable to read stdout. - * - * @param callable $callback */ public function onStdout(callable $callback): void { @@ -49,8 +45,6 @@ public function onStdout(callable $callback): void /** * Add a callable to read stderr. - * - * @param callable $callback */ public function onStderr(callable $callback): void { diff --git a/src/Stream/EventStream.php b/src/Stream/EventStream.php index 0ba9df6f7..90dcf23ed 100644 --- a/src/Stream/EventStream.php +++ b/src/Stream/EventStream.php @@ -12,7 +12,7 @@ class EventStream extends MultiJsonStream { /** - * [@inheritdoc}. + * {@inheritdoc}. */ protected function getDecodeClass() { diff --git a/src/Stream/PushStream.php b/src/Stream/PushStream.php index c40cb6688..4b7242db9 100644 --- a/src/Stream/PushStream.php +++ b/src/Stream/PushStream.php @@ -12,7 +12,7 @@ class PushStream extends MultiJsonStream { /** - * [@inheritdoc}. + * {@inheritdoc}. */ protected function getDecodeClass() { diff --git a/src/Stream/TarStream.php b/src/Stream/TarStream.php index ee0a17519..446da02d1 100644 --- a/src/Stream/TarStream.php +++ b/src/Stream/TarStream.php @@ -4,13 +4,35 @@ namespace Docker\Stream; -use GuzzleHttp\Psr7\Stream; +use Psr\Http\Message\StreamInterface; /** * This class avoid a bug in PHP where fstat return a size of 0 for process stream. */ -class TarStream extends Stream +class TarStream implements StreamInterface { + protected $stream; + + public function __construct(StreamInterface $stream) + { + $this->stream = $stream; + } + + public function __toString() + { + return $this->stream->__toString(); + } + + public function close(): void + { + $this->stream->close(); + } + + public function detach() + { + return $this->stream->detach(); + } + /** * {@inheritdoc} */ @@ -18,4 +40,59 @@ public function getSize() { return null; } + + public function tell(): int + { + return $this->stream->tell(); + } + + public function eof(): bool + { + return $this->stream->eof(); + } + + public function isSeekable(): bool + { + return $this->stream->isSeekable(); + } + + public function seek($offset, $whence = SEEK_SET): void + { + $this->stream->seek($offset, $whence); + } + + public function rewind(): void + { + $this->stream->rewind(); + } + + public function isWritable(): bool + { + return $this->stream->isWritable(); + } + + public function write($string): int + { + return $this->stream->write($string); + } + + public function isReadable(): bool + { + return $this->stream->isReadable(); + } + + public function read($length): string + { + return $this->stream->read($length); + } + + public function getContents(): string + { + return $this->stream->getContents(); + } + + public function getMetadata($key = null) + { + return $this->stream->getMetadata($key); + } } diff --git a/tests/Context/ContextBuilderTest.php b/tests/Context/ContextBuilderTest.php index 828faa63f..f6b72097a 100644 --- a/tests/Context/ContextBuilderTest.php +++ b/tests/Context/ContextBuilderTest.php @@ -62,10 +62,9 @@ public function testWriteTmpFiles(): void $context = $contextBuilder->getContext(); $filename = \preg_replace(<<getDockerfileContent()); + #FROM base + ADD (.+?) /foo# + DOCKERFILE, '$1', $context->getDockerfileContent()); $this->assertStringEqualsFile($context->getDirectory().'/'.$filename, 'random content'); } @@ -80,10 +79,9 @@ public function testWriteTmpFileFromStream(): void $context = $contextBuilder->getContext(); $filename = \preg_replace(<<getDockerfileContent()); + #FROM base + ADD (.+?) /foo# + DOCKERFILE, '$1', $context->getDockerfileContent()); $this->assertStringEqualsFile($context->getDirectory().'/'.$filename, 'test123'); } @@ -97,10 +95,9 @@ public function testWriteTmpFileFromDisk(): void $context = $contextBuilder->getContext(); $filename = \preg_replace(<<getDockerfileContent()); + #FROM base + ADD (.+?) /foo# + DOCKERFILE, '$1', $context->getDockerfileContent()); $this->assertStringEqualsFile($context->getDirectory().'/'.$filename, 'abc'); } @@ -116,10 +113,9 @@ public function testWriteTmpDirFromDisk(): void $context = $contextBuilder->getContext(); $filename = \preg_replace(<<getDockerfileContent()); + #FROM base + ADD (.+?) /foo# + DOCKERFILE, '$1', $context->getDockerfileContent()); $this->assertStringEqualsFile($context->getDirectory().'/'.$filename.'/test', 'abc'); } @@ -130,11 +126,10 @@ public function testWritesAddCommands(): void $context = $contextBuilder->getContext(); - $this->assertRegExp(<<getDockerfileContent() + $this->assertMatchesRegularExpression(<<getDockerfileContent() ); } @@ -146,9 +141,9 @@ public function testWritesRunCommands(): void $context = $contextBuilder->getContext(); $this->assertStringEqualsFile($context->getDirectory().'/Dockerfile', <<getContext(); $this->assertStringEqualsFile($context->getDirectory().'/Dockerfile', <<getContext(); $this->assertStringEqualsFile($context->getDirectory().'/Dockerfile', <<getContext(); $this->assertStringEqualsFile($context->getDirectory().'/Dockerfile', <<getContext(); $this->assertStringEqualsFile($context->getDirectory().'/Dockerfile', <<command('changed'); $content = $contextBuilder->getContext()->getDockerfileContent(); - $this->assertNotContains('CMD test123', $content); + $this->assertStringNotContainsString('CMD test123', $content); $this->assertStringEndsWith("\nCMD changed", $content); } @@ -256,7 +251,7 @@ public function testWritesEntrypointCommand(): void $contextBuilder->entrypoint('changed'); $content = $contextBuilder->getContext()->getDockerfileContent(); - $this->assertNotContains('ENTRYPOINT test123', $content); + $this->assertStringNotContainsString('ENTRYPOINT test123', $content); $this->assertStringEndsWith("\nENTRYPOINT changed", $content); } @@ -266,7 +261,7 @@ public function testTar(): void $contextBuilder->setFormat(Context::FORMAT_TAR); $context = $contextBuilder->getContext(); $content = $context->read(); - $this->assertInternalType('string', $content); + $this->assertIsString($content); $this->assertSame($context->toTar(), $content); } @@ -288,10 +283,9 @@ public function testTraverseSymlinks(): void $context = $contextBuilder->getContext(); $filename = \preg_replace(<<getDockerfileContent()); + #FROM base + ADD (.+?) /foo# + DOCKERFILE, '$1', $context->getDockerfileContent()); \unlink($file); $context->setCleanup(false); $this->assertStringEqualsFile($context->getDirectory().'/'.$filename.'/test-symlink', 'abc'); diff --git a/tests/Context/ContextTest.php b/tests/Context/ContextTest.php index cd2a113f2..9e143cfe4 100644 --- a/tests/Context/ContextTest.php +++ b/tests/Context/ContextTest.php @@ -13,10 +13,10 @@ class ContextTest extends TestCase { public function testReturnsValidTarContent(): void { - $directory = __DIR__.DIRECTORY_SEPARATOR.'context-test'; + $directory = __DIR__.\DIRECTORY_SEPARATOR.'context-test'; $context = new Context($directory); - $process = new Process('/usr/bin/env tar c .', $directory); + $process = new Process(['/usr/bin/env', 'tar', 'c', '.'], $directory); $process->run(); $this->assertSame(\strlen($process->getOutput()), \strlen($context->toTar())); @@ -24,10 +24,10 @@ public function testReturnsValidTarContent(): void public function testReturnsValidTarStream(): void { - $directory = __DIR__.DIRECTORY_SEPARATOR.'context-test'; + $directory = __DIR__.\DIRECTORY_SEPARATOR.'context-test'; $context = new Context($directory); - $this->assertInternalType('resource', $context->toStream()); + $this->assertIsResource($context->toStream()); } public function testDirectorySetter(): void @@ -38,12 +38,11 @@ public function testDirectorySetter(): void $this->assertSame('def', $context->getDirectory()); } - /** - * @expectedException \Symfony\Component\Process\Exception\ProcessFailedException - */ public function testTarFailed(): void { - $directory = __DIR__.DIRECTORY_SEPARATOR.'context-test'; + $this->expectException(\Symfony\Component\Process\Exception\ProcessFailedException::class); + + $directory = __DIR__.\DIRECTORY_SEPARATOR.'context-test'; $path = \getenv('PATH'); \putenv('PATH=/'); $context = new Context($directory); @@ -62,6 +61,6 @@ public function testRemovesFilesOnDestruct(): void unset($context); - $this->assertFileNotExists($file); + $this->assertFileDoesNotExist($file); } } diff --git a/tests/DockerClientFactoryTest.php b/tests/DockerClientFactoryTest.php index 286419d43..e438a4f30 100644 --- a/tests/DockerClientFactoryTest.php +++ b/tests/DockerClientFactoryTest.php @@ -5,7 +5,7 @@ namespace Docker\Tests; use Docker\DockerClientFactory; -use Http\Client\HttpClient; +use Psr\Http\Client\ClientInterface; class DockerClientFactoryTest extends TestCase { @@ -17,15 +17,14 @@ protected function tearDown(): void public function testStaticConstructor(): void { - $this->assertInstanceOf(HttpClient::class, DockerClientFactory::create()); + $this->assertInstanceOf(ClientInterface::class, DockerClientFactory::create()); } - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Connection to docker has been set to use TLS, but no PATH is defined for certificate in DOCKER_CERT_PATH docker environment variable - */ public function testCreateFromEnvWithoutCertPath(): void { + $this->expectException(\RuntimeException::class); + $this->expectExceptionMessage('Connection to docker has been set to use TLS, but no PATH is defined for certificate in DOCKER_CERT_PATH docker environment variable'); + \putenv('DOCKER_TLS_VERIFY=1'); DockerClientFactory::createFromEnv(); } @@ -37,7 +36,7 @@ public function testCreateCustomCa(): void $count = \count(\get_resources('stream-context')); $client = DockerClientFactory::createFromEnv(); - $this->assertInstanceOf(HttpClient::class, $client); + $this->assertInstanceOf(ClientInterface::class, $client); $contexts = \get_resources('stream-context'); $this->assertCount($count + 1, $contexts); @@ -57,7 +56,7 @@ public function testCreateCustomPeerName(): void $count = \count(\get_resources('stream-context')); $client = DockerClientFactory::createFromEnv(); - $this->assertInstanceOf(HttpClient::class, $client); + $this->assertInstanceOf(ClientInterface::class, $client); $contexts = \get_resources('stream-context'); $this->assertCount($count + 1, $contexts); diff --git a/tests/Resource/ContainerResourceTest.php b/tests/Resource/ContainerResourceTest.php index d89f3ada9..3ebb77588 100644 --- a/tests/Resource/ContainerResourceTest.php +++ b/tests/Resource/ContainerResourceTest.php @@ -35,13 +35,16 @@ public function testAttach(): void $containerConfig->setImage('busybox:latest'); $containerConfig->setCmd(['echo', '-n', 'output']); $containerConfig->setAttachStdout(true); - $containerConfig->setLabels(new \ArrayObject(['docker-php-test' => 'true'])); + $containerConfig->setLabels(['docker-php-test' => 'true']); $containerCreateResult = $this->getManager()->containerCreate($containerConfig); - $dockerRawStream = $this->getManager()->containerAttach($containerCreateResult->getId(), [ - 'stream' => true, - 'stdout' => true, - ]); + $dockerRawStream = $this->getManager()->containerAttach( + $containerCreateResult->getId(), + [ + 'stream' => true, + 'stdout' => true, + ] + ); $stdoutFull = ''; $dockerRawStream->onStdout(function ($stdout) use (&$stdoutFull): void { @@ -69,12 +72,15 @@ public function testAttachWebsocket(): void $containerConfig->setLabels(new \ArrayObject(['docker-php-test' => 'true'])); $containerCreateResult = $this->getManager()->containerCreate($containerConfig); - $webSocketStream = $this->getManager()->containerAttachWebsocket($containerCreateResult->getId(), [ - 'stream' => true, - 'stdout' => true, - 'stderr' => true, - 'stdin' => true, - ]); + $webSocketStream = $this->getManager()->containerAttachWebsocket( + $containerCreateResult->getId(), + [ + 'stream' => true, + 'stdout' => true, + 'stderr' => true, + 'stdin' => true, + ] + ); $this->getManager()->containerStart($containerCreateResult->getId()); @@ -106,17 +112,21 @@ public function testLogs(): void $containerConfig->setImage('busybox:latest'); $containerConfig->setCmd(['echo', '-n', 'output']); $containerConfig->setAttachStdout(true); - $containerConfig->setLabels(new \ArrayObject(['docker-php-test' => 'true'])); + $containerConfig->setLabels(['docker-php-test' => 'true']); $containerCreateResult = $this->getManager()->containerCreate($containerConfig); $this->getManager()->containerStart($containerCreateResult->getId()); $this->getManager()->containerWait($containerCreateResult->getId()); - $logsStream = $this->getManager()->containerLogs($containerCreateResult->getId(), [ - 'stdout' => true, - 'stderr' => true, - ], Docker::FETCH_OBJECT); + $logsStream = $this->getManager()->containerLogs( + $containerCreateResult->getId(), + [ + 'stdout' => true, + 'stderr' => true, + ], + Docker::FETCH_OBJECT + ); self::assertInstanceOf(DockerRawStream::class, $logsStream); } diff --git a/tests/Resource/ImageResourceTest.php b/tests/Resource/ImageResourceTest.php index e1c129dd0..8e88982da 100644 --- a/tests/Resource/ImageResourceTest.php +++ b/tests/Resource/ImageResourceTest.php @@ -37,7 +37,7 @@ public function testBuild(): void }); $buildStream->wait(); - $this->assertContains('Successfully', $lastMessage); + $this->assertStringContainsString('Successfully', $lastMessage); } public function testCreate(): void @@ -57,7 +57,7 @@ public function testCreate(): void }); $createImageStream->wait(); - $this->assertContains('Pulling from library/registry', $firstMessage); + $this->assertStringContainsString('Pulling from library/registry', $firstMessage); } public function testPushStream(): void @@ -86,6 +86,6 @@ public function testPushStream(): void }); $pushImageStream->wait(); - $this->assertContains('repository [localhost:5000/test-image]', $firstMessage); + $this->assertStringContainsString('repository [localhost:5000/test-image]', $firstMessage); } } diff --git a/tests/Stream/MultiJsonStreamTest.php b/tests/Stream/MultiJsonStreamTest.php index a999f4929..2fd1d36aa 100644 --- a/tests/Stream/MultiJsonStreamTest.php +++ b/tests/Stream/MultiJsonStreamTest.php @@ -7,7 +7,7 @@ use Docker\API\Model\BuildInfo; use Docker\Stream\MultiJsonStream; use Docker\Tests\TestCase; -use GuzzleHttp\Psr7\BufferStream; +use Nyholm\Psr7\Stream; use Symfony\Component\Serializer\SerializerInterface; class MultiJsonStreamTest extends TestCase @@ -20,7 +20,7 @@ public function jsonStreamDataProvider() ['{}', '{"abc":"def"}'], ], [ - '{"test": "abc\"\""}', + '{"test": "abc\"\""}', ['{"test":"abc\"\""}'], ], [ @@ -37,8 +37,8 @@ public function jsonStreamDataProvider() */ public function testReadJsonEscapedDoubleQuote(string $jsonStream, array $jsonParts): void { - $stream = new BufferStream(); - $stream->write($jsonStream); + $stream = Stream::create($jsonStream); + $stream->rewind(); $serializer = $this->getMockBuilder(SerializerInterface::class) ->getMock(); @@ -46,9 +46,7 @@ public function testReadJsonEscapedDoubleQuote(string $jsonStream, array $jsonPa $serializer ->expects($this->exactly(\count($jsonParts))) ->method('deserialize') - ->withConsecutive(...\array_map(function ($part) { - return [$part, BuildInfo::class, 'json', []]; - }, $jsonParts)) + ->withConsecutive(...\array_map(fn ($part) => [$part, BuildInfo::class, 'json', []], $jsonParts)) ; $stub = $this->getMockForAbstractClass(MultiJsonStream::class, [$stream, $serializer]); From 898328dce5b7ff6aac67a0e749ad8cdc82f24cf4 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Wed, 16 Dec 2020 16:08:40 -0300 Subject: [PATCH 06/85] Fixed ContainerAttach and ContainerAttachWebsocket endpoints --- composer.json | 13 ++++++------- src/Endpoint/ContainerAttach.php | 3 +-- src/Endpoint/ContainerAttachWebsocket.php | 3 +-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index 7ecf5f447..96aaa4f06 100644 --- a/composer.json +++ b/composer.json @@ -30,12 +30,11 @@ "php-http/httplug-bundle": "For integration with Symfony" }, "require-dev": { - "phpunit/phpunit": "^9.5", - "friendsofphp/php-cs-fixer": "^2.17" + "friendsofphp/php-cs-fixer": "^2.17", + "phpunit/phpunit": "^9.5" }, "conflict": { - "amphp/socket": "<0.10.5", - "amphp/artax": "<3.0" + "docker-php/docker-php": "*" }, "scripts": { "test": "vendor/bin/phpunit", @@ -45,9 +44,9 @@ }, "extra": { "branch-alias": { - "dev-master": "2.x-dev" + "dev-master": "3.x-dev" } }, - "prefer-stable": true, - "minimum-stability": "dev" + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/src/Endpoint/ContainerAttach.php b/src/Endpoint/ContainerAttach.php index 0676e3830..e97aee702 100644 --- a/src/Endpoint/ContainerAttach.php +++ b/src/Endpoint/ContainerAttach.php @@ -14,8 +14,7 @@ class ContainerAttach extends BaseEndpoint protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) { if (200 === $status && DockerRawStream::HEADER === $contentType) { - $streamFactory = StreamFactoryDiscovery::find(); - $stream = $streamFactory->createStream($jsonStream); + $stream = Stream::create($body); $stream->rewind(); return new DockerRawStream($stream); diff --git a/src/Endpoint/ContainerAttachWebsocket.php b/src/Endpoint/ContainerAttachWebsocket.php index 692599ec8..13decbe84 100644 --- a/src/Endpoint/ContainerAttachWebsocket.php +++ b/src/Endpoint/ContainerAttachWebsocket.php @@ -29,8 +29,7 @@ public function getExtraHeaders(): array protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) { if (200 === $status && DockerRawStream::HEADER === $contentType) { - $streamFactory = StreamFactoryDiscovery::find(); - $stream = $streamFactory->createStream($jsonStream); + $stream = Stream::create($body); $stream->rewind(); return new AttachWebsocketStream($stream); From ff353fd40d12dd4539950a779b68316b5f36dda0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: Mon, 31 May 2021 09:49:20 -0300 Subject: [PATCH 07/85] Create dependabot.yml --- .github/dependabot.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 000000000..e5fae30f4 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: + # Maintain dependencies for GitHub Actions + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "daily" + # Maintain dependencies for PHP Packages + - package-ecosystem: "composer" + directory: "/" + schedule: + interval: "daily" From b80bd757b663c1d65a73357ab968ac32fb46048d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 31 May 2021 12:49:47 +0000 Subject: [PATCH 08/85] Update friendsofphp/php-cs-fixer requirement from ^2.17 to ^2.17 || ^3.0 Updates the requirements on [friendsofphp/php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to permit the latest version. - [Release notes](https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases) - [Changelog](https://github.com/FriendsOfPHP/PHP-CS-Fixer/blob/3.0/CHANGELOG.md) - [Commits](https://github.com/FriendsOfPHP/PHP-CS-Fixer/compare/v2.17.0...v3.0.0) Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 96aaa4f06..9c47c15ec 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,7 @@ "php-http/httplug-bundle": "For integration with Symfony" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.17", + "friendsofphp/php-cs-fixer": "^2.17 || ^3.0", "phpunit/phpunit": "^9.5" }, "conflict": { From 60eb0263d081f27f1da172bdf9023c4f5263bc63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: Fri, 11 Jun 2021 11:58:46 -0300 Subject: [PATCH 09/85] Create FUNDING.yml --- .github/FUNDING.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 000000000..0d1ec551e --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +patreon: flavioheleno From 3cfd88b4e04b9b39f88d0a04afb251f06956bf97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: Fri, 25 Jun 2021 16:21:27 -0300 Subject: [PATCH 10/85] Update README.md --- README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 933def843..53a450a6c 100644 --- a/README.md +++ b/README.md @@ -6,20 +6,19 @@ This library aim to reach 100% API support of the Docker Engine. The test suite currently passes against Docker Remote API v1.25 to v1.36. [![Documentation Status](https://readthedocs.org/projects/docker-php/badge/?version=latest)](http://docker-php.readthedocs.org/en/latest/) -[![Latest Version](https://img.shields.io/github/release/docker-php/docker-php.svg?style=flat-square)](https://github.com/docker-php/docker-php/releases) +[![Latest Version](https://img.shields.io/github/release/beluga-php/docker-php.svg?style=flat-square)](https://github.com/beluga-php/docker-php/releases) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) -[![Build Status](https://img.shields.io/travis/docker-php/docker-php.svg?branch=master&style=flat-square)](https://travis-ci.org/docker-php/docker-php) -[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/docker-php/docker-php.svg?style=flat-square)](https://scrutinizer-ci.com/g/docker-php/docker-php) -[![Quality Score](https://img.shields.io/scrutinizer/g/docker-php/docker-php.svg?style=flat-square)](https://scrutinizer-ci.com/g/docker-php/docker-php) -[![Total Downloads](https://img.shields.io/packagist/dt/docker-php/docker-php.svg?style=flat-square)](https://packagist.org/packages/docker-php/docker-php) -[![#docker-php on Slack](http://slack.httplug.io/badge.svg)](http://slack.httplug.io) +[![Build Status](https://img.shields.io/travis/beluga-php/docker-php.svg?branch=master&style=flat-square)](https://travis-ci.org/beluga-php/docker-php) +[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/beluga-php/docker-php.svg?style=flat-square)](https://scrutinizer-ci.com/g/beluga-php/docker-php) +[![Quality Score](https://img.shields.io/scrutinizer/g/beluga-php/docker-php.svg?style=flat-square)](https://scrutinizer-ci.com/g/beluga-php/docker-php) +[![Total Downloads](https://img.shields.io/packagist/dt/beluga-php/docker-php.svg?style=flat-square)](https://packagist.org/packages/beluga-php/docker-php) ## Installation The recommended way to install Docker PHP is of course to use [Composer](http://getcomposer.org/): ```bash -composer require docker-php/docker-php +composer require beluga-php/docker-php ``` ## Docker API Version @@ -28,7 +27,7 @@ By default it will use the last version of docker api available, if you want to requirement to composer: ```bash -composer require "docker-php/docker-php-api:4.1.25.*" +composer require "beluga-php/docker-php-api:4.1.25.*" ``` ## Usage From 70f6b1b480b9bc937f3d9ddd8d52fb983263a81a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: Thu, 29 Jul 2021 14:02:18 -0300 Subject: [PATCH 11/85] Create continuous-integration.yml --- .github/workflows/continuous-integration.yml | 78 ++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 .github/workflows/continuous-integration.yml diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml new file mode 100644 index 000000000..57b2432d0 --- /dev/null +++ b/.github/workflows/continuous-integration.yml @@ -0,0 +1,78 @@ +name: "Continuous Integration" + +on: + push: + paths-ignore: + - 'doc/**' + - '.github/**' + pull_request: + paths-ignore: + - 'doc/**' + - '.github/**' + +jobs: + phpunit: + name: PHP ${{ matrix.php-version }} (${{ matrix.dependency-version }}) + + runs-on: ubuntu-latest + continue-on-error: ${{ matrix.experimental }} + + strategy: + fail-fast: false + matrix: + php-version: + - "7.4" + - "8.0" + dependency-version: [prefer-lowest, prefer-stable] + experimental: [false] + include: + - php-version: "8.1" + dependency-version: "prefer-lowest" + experimental: true + - php-version: "8.1" + dependency-version: "prefer-lowest" + experimental: true + + steps: + - uses: actions/checkout@v2.3.4 + + - name: Setup PHP with PECL extension + uses: shivammathur/setup-php@2.12.0 + with: + php-version: ${{ matrix.php-version }} + tools: composer:v2 + coverage: pcov + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache Composer packages + uses: actions/cache@v2.1.6 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}- + + - name: Install dependencies (PHP 7) + if: steps.composer-cache.outputs.cache-hit != 'true' && matrix.php-version < 8 + run: composer update --${{ matrix.dependency-version }} --no-progress --no-interaction + + - name: Install dependencies (PHP 8) + if: steps.composer-cache.outputs.cache-hit != 'true' && matrix.php-version >= 8 + run: composer update --${{ matrix.dependency-version }} --ignore-platform-req=php --no-progress --no-interaction + + - name: Run PHPUnit test suite + run: composer run-script test-ci + + - name: Publish code coverage + uses: paambaati/codeclimate-action@v2.7.5 + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + with: + coverageCommand: composer run-script test-coverage + coverageLocations: | + ${{github.workspace}}/clover.xml:clover From 8b3a1958f408990915a2706473cfbfffc9d3f66b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: Thu, 29 Jul 2021 14:02:57 -0300 Subject: [PATCH 12/85] Create static-analysis.yml --- .github/workflows/static-analysis.yml | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .github/workflows/static-analysis.yml diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 000000000..12c2414fd --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,48 @@ +name: "Static Analysis" + +on: + push: + paths-ignore: + - 'doc/**' + - '.github/**' + pull_request: + paths-ignore: + - 'doc/**' + - '.github/**' + +jobs: + phpstan: + name: PHPStan + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2.3.4 + + - name: Setup PHP with PECL extension + uses: shivammathur/setup-php@2.12.0 + with: + php-version: 8.0 + tools: composer:v2 + coverage: none + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache Composer packages + uses: actions/cache@v2.1.6 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: phpstan-linux-php-8.0-${{ hashFiles('**/composer.lock') }} + restore-keys: phpstan-linux-php-8.0- + + - name: Install dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: composer update --prefer-stable --ignore-platform-req=php --no-progress --no-interaction + + - name: Run PHPStan + run: composer run-script phpstan -- --no-progress From 8e4494bdabd04726b8b9bd04cf5d568b570c5bd6 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Thu, 29 Jul 2021 14:22:11 -0300 Subject: [PATCH 13/85] Remove TravisCI and Scrutinizer --- .scrutinizer.yml | 11 -------- .travis.yml | 68 ------------------------------------------------ README.md | 9 +++---- composer.json | 64 +++++++++++++++++++++++++++++++++++++-------- 4 files changed, 56 insertions(+), 96 deletions(-) delete mode 100644 .scrutinizer.yml delete mode 100644 .travis.yml diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 60d211bf7..000000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,11 +0,0 @@ -filter: - paths: [src/*] -checks: - php: - code_rating: true - duplication: true -tools: - external_code_coverage: true - php_code_sniffer: - config: - standard: "PSR2" diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 41708d6f6..000000000 --- a/.travis.yml +++ /dev/null @@ -1,68 +0,0 @@ -language: php -sudo: required - -services: - - docker - -cache: - directories: - - $HOME/.composer/cache - -php: 7.2 - -env: - global: - - TEST_COMMAND="composer test" - matrix: - - DOCKER_API_VERSION=1.36 DOCKER_VERSION=18.02.0~ce-0~ubuntu - - DOCKER_API_VERSION=1.36 DOCKER_VERSION=18.01.0~ce-0~ubuntu - - DOCKER_API_VERSION=1.35 DOCKER_VERSION=17.12.0~ce-0~ubuntu - - DOCKER_API_VERSION=1.34 DOCKER_VERSION=17.11.0~ce-0~ubuntu - - DOCKER_API_VERSION=1.33 DOCKER_VERSION=17.10.0~ce-0~ubuntu - - DOCKER_API_VERSION=1.32 DOCKER_VERSION=17.09.0~ce-0~ubuntu - - DOCKER_API_VERSION=1.31 DOCKER_VERSION=17.07.0~ce-0~ubuntu - - DOCKER_API_VERSION=1.30 DOCKER_VERSION=17.06.2~ce-0~ubuntu - - DOCKER_API_VERSION=1.29 DOCKER_VERSION=17.05.0~ce-0~ubuntu-trusty - - DOCKER_API_VERSION=1.28 DOCKER_VERSION=17.04.0~ce-0~ubuntu-trusty - - DOCKER_API_VERSION=1.27 DOCKER_VERSION=17.03.2~ce-0~ubuntu-trusty - - DOCKER_API_VERSION=1.26 DOCKER_VERSION=17.03.2~ce-0~ubuntu-trusty - - DOCKER_API_VERSION=1.25 DOCKER_VERSION=17.03.2~ce-0~ubuntu-trusty - -matrix: - allow_failures: - - php: hhvm - fast_finish: true - include: - - php: 7.1 - sudo: required - services: - - docker - env: DOCKER_API_VERSION=1.25 DOCKER_VERSION=17.03.2~ce-0~ubuntu-trusty COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci" - - php: 7.1 - env: DOCKER_API_VERSION=1.36 DOCKER_VERSION=18.02.0~ce-0~ubuntu TEST_COMMAND="composer lint" - - php: 7.2 - sudo: required - services: - - docker - env: DOCKER_API_VERSION=1.36 DOCKER_VERSION=18.02.0~ce-0~ubuntu - -before_install: - - sudo apt-get update - - sudo apt-cache madison docker-ce - - sudo apt-get -o Dpkg::Options::="--force-confnew" install -y --force-yes docker-ce=${DOCKER_VERSION} - - travis_retry composer self-update - -install: - - travis_retry composer install - - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction - - travis_retry composer require docker-php/docker-php-api:4.${DOCKER_API_VERSION}.* - -script: - - $TEST_COMMAND - -after_success: - - if [[ "$COVERAGE" = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi - - if [[ "$COVERAGE" = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi - -after_script: - - sudo cat /var/log/upstart/docker.log diff --git a/README.md b/README.md index 53a450a6c..51495e03b 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,6 @@ The test suite currently passes against Docker Remote API v1.25 to v1.36. [![Documentation Status](https://readthedocs.org/projects/docker-php/badge/?version=latest)](http://docker-php.readthedocs.org/en/latest/) [![Latest Version](https://img.shields.io/github/release/beluga-php/docker-php.svg?style=flat-square)](https://github.com/beluga-php/docker-php/releases) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) -[![Build Status](https://img.shields.io/travis/beluga-php/docker-php.svg?branch=master&style=flat-square)](https://travis-ci.org/beluga-php/docker-php) -[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/beluga-php/docker-php.svg?style=flat-square)](https://scrutinizer-ci.com/g/beluga-php/docker-php) -[![Quality Score](https://img.shields.io/scrutinizer/g/beluga-php/docker-php.svg?style=flat-square)](https://scrutinizer-ci.com/g/beluga-php/docker-php) [![Total Downloads](https://img.shields.io/packagist/dt/beluga-php/docker-php.svg?style=flat-square)](https://packagist.org/packages/beluga-php/docker-php) ## Installation @@ -23,11 +20,11 @@ composer require beluga-php/docker-php ## Docker API Version -By default it will use the last version of docker api available, if you want to fix a version (like 1.25) you can add this +By default it will use the last version of docker api available, if you want to fix a version (like 1.41) you can add this requirement to composer: ```bash -composer require "beluga-php/docker-php-api:4.1.25.*" +composer require "beluga-php/docker-php-api:6.1.41.*" ``` ## Usage @@ -56,7 +53,7 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details. This README heavily inspired by [willdurand/Negotiation](https://github.com/willdurand/Negotiation) by @willdurand. This guy is pretty awesome. -This library is a fork of the original [docker-php](https://github.com/docker-php/docker-php), created by [Geoffrey Bachelet](https://github.com/ubermuda) and [Joel Wurtz](https://github.com/joelwurtz). +This library is a fork of the original [docker-php/docker-php](https://github.com/docker-php/docker-php), created by [Geoffrey Bachelet](https://github.com/ubermuda) and [Joel Wurtz](https://github.com/joelwurtz). ## License diff --git a/composer.json b/composer.json index 9c47c15ec..76c816e45 100644 --- a/composer.json +++ b/composer.json @@ -4,8 +4,12 @@ "type": "library", "description": "A Docker PHP client", "config": { - "sort-packages": true + "optimize-autoloader": true, + "sort-packages": true, + "preferred-install": "dist" }, + "minimum-stability": "dev", + "prefer-stable": true, "autoload": { "psr-4": { "Docker\\": "src/" @@ -16,9 +20,15 @@ "Docker\\Tests\\": "tests/" } }, + "funding": [ + { + "type": "patreon", + "url": "https://www.patreon.com/flavioheleno" + } + ], "require": { "php": ">=7.1", - "beluga-php/docker-php-api": "6.1.*", + "beluga-php/docker-php-api": "6.1.41.0", "nyholm/psr7": "^1.3", "php-http/client-common": "^2.3", "php-http/socket-client": "^2.0", @@ -30,23 +40,55 @@ "php-http/httplug-bundle": "For integration with Symfony" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.17 || ^3.0", - "phpunit/phpunit": "^9.5" + "friendsofphp/php-cs-fixer": "^2.17", + "infection/infection": "^0.21.5", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan": "^0.12.58", + "phpunit/phpunit": "^9.5", + "psy/psysh": "^0.10.5", + "roave/security-advisories": "dev-master", + "squizlabs/php_codesniffer": "^3.5", + "vimeo/psalm": "^4.3" }, "conflict": { "docker-php/docker-php": "*" }, "scripts": { - "test": "vendor/bin/phpunit", - "test-ci": "vendor/bin/phpunit --coverage-clover build/coverage.xml", - "lint": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", - "lint-fix": "vendor/bin/php-cs-fixer fix --verbose" + "php-cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", + "php-cs-fixer-fix": "vendor/bin/php-cs-fixer fix --verbose", + "console": "vendor/bin/psysh", + "infection": "vendor/bin/infection", + "lint": "vendor/bin/parallel-lint --exclude vendor .", + "phpcs": "vendor/bin/phpcs --standard=ruleset.xml src/ tests/", + "phpstan": "vendor/bin/phpstan analyse --level=max --autoload-file=vendor/autoload.php src/", + "phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation", + "psalm": "vendor/bin/psalm --taint-analysis", + "test-ci": "vendor/bin/phpunit ./tests/ --disallow-test-output --process-isolation", + "test-coverage": "vendor/bin/phpunit ./tests/ --whitelist=./src/ --coverage-clover=clover.xml", + "test": [ + "@infection", + "@lint", + "@phpunit", + "@phpstan", + "@psalm", + "@phpcs" + ] + }, + "scripts-descriptions": { + "console": "Runs PsySH Console", + "infection": "Runs mutation test framework", + "lint": "Runs complete codebase lint testing", + "phpcs": "Runs coding style checking", + "phpstan": "Runs complete codebase static analysis", + "phpunit": "Runs library test suite", + "psalm": "Runs complete codebase taint analysis", + "test-ci": "Runs library test suite (for continuous integration)", + "test-coverage": "Runs test-coverage analysis", + "test": "Runs all tests" }, "extra": { "branch-alias": { "dev-master": "3.x-dev" } - }, - "minimum-stability": "dev", - "prefer-stable": true + } } From 66ac8f602338bd964fe8fe65ae51f05b2b44e70f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Jul 2021 09:17:10 +0000 Subject: [PATCH 14/85] Update infection/infection requirement || ^0.24.0 Updates the requirements on [infection/infection](https://github.com/infection/infection) to permit the latest version. - [Release notes](https://github.com/infection/infection/releases) - [Changelog](https://github.com/infection/infection/blob/master/CHANGELOG.md) - [Commits](https://github.com/infection/infection/compare/0.21.5...0.24.0) --- updated-dependencies: - dependency-name: infection/infection dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 76c816e45..851b5c247 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.17", - "infection/infection": "^0.21.5", + "infection/infection": "^0.21.5 || ^0.24.0", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/phpstan": "^0.12.58", "phpunit/phpunit": "^9.5", From fbff34d75c861a00701cb473781d35bf6eb5d932 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 24 Aug 2021 09:11:03 +0000 Subject: [PATCH 15/85] Bump shivammathur/setup-php from 2.12.0 to 2.13.0 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.12.0 to 2.13.0. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.12.0...2.13.0) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 57b2432d0..33eb34eb4 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/checkout@v2.3.4 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.12.0 + uses: shivammathur/setup-php@2.13.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 12c2414fd..57f191617 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v2.3.4 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.12.0 + uses: shivammathur/setup-php@2.13.0 with: php-version: 8.0 tools: composer:v2 From abefbace15bb0d4c9cbbb68f63aabc88c5922e45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 13 Sep 2021 09:12:52 +0000 Subject: [PATCH 16/85] Bump shivammathur/setup-php from 2.13.0 to 2.14.0 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.13.0 to 2.14.0. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.13.0...2.14.0) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 33eb34eb4..f9ffecfb2 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/checkout@v2.3.4 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.13.0 + uses: shivammathur/setup-php@2.14.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 57f191617..bd4b38782 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v2.3.4 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.13.0 + uses: shivammathur/setup-php@2.14.0 with: php-version: 8.0 tools: composer:v2 From 8d520658761052239d0015a8b93143e33266b972 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Oct 2021 09:15:58 +0000 Subject: [PATCH 17/85] Bump actions/checkout from 2.3.4 to 2.3.5 Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.4 to 2.3.5. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2.3.4...v2.3.5) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index f9ffecfb2..ff7237675 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -34,7 +34,7 @@ jobs: experimental: true steps: - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v2.3.5 - name: Setup PHP with PECL extension uses: shivammathur/setup-php@2.14.0 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index bd4b38782..ef53d08b6 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.4 + - uses: actions/checkout@v2.3.5 - name: Setup PHP with PECL extension uses: shivammathur/setup-php@2.14.0 From f755a93e2f6c0ea71e62eec782f19ad3961cafe6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Oct 2021 14:58:42 +0000 Subject: [PATCH 18/85] Bump shivammathur/setup-php from 2.14.0 to 2.15.0 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.14.0 to 2.15.0. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.14.0...2.15.0) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index ff7237675..4ea28cd36 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/checkout@v2.3.5 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.14.0 + uses: shivammathur/setup-php@2.15.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index ef53d08b6..6b2dba782 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v2.3.5 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.14.0 + uses: shivammathur/setup-php@2.15.0 with: php-version: 8.0 tools: composer:v2 From 14563c39ca54632f7206c7fdd8783d72a92aff89 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Nov 2021 09:12:34 +0000 Subject: [PATCH 19/85] Bump actions/cache from 2.1.6 to 2.1.7 Bumps [actions/cache](https://github.com/actions/cache) from 2.1.6 to 2.1.7. - [Release notes](https://github.com/actions/cache/releases) - [Commits](https://github.com/actions/cache/compare/v2.1.6...v2.1.7) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 4ea28cd36..9ea4387b0 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -51,7 +51,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache Composer packages - uses: actions/cache@v2.1.6 + uses: actions/cache@v2.1.7 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 6b2dba782..8f3d2aadf 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -34,7 +34,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache Composer packages - uses: actions/cache@v2.1.6 + uses: actions/cache@v2.1.7 with: path: ${{ steps.composer-cache.outputs.dir }} key: phpstan-linux-php-8.0-${{ hashFiles('**/composer.lock') }} From a1cddc8176cd6bdd29a67060f37675a3ac435ea9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Nov 2021 09:12:25 +0000 Subject: [PATCH 20/85] Bump shivammathur/setup-php from 2.15.0 to 2.16.0 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.15.0 to 2.16.0. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.15.0...2.16.0) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 9ea4387b0..a5f3195d5 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/checkout@v2.3.5 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.15.0 + uses: shivammathur/setup-php@2.16.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 8f3d2aadf..5c643a549 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v2.3.5 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.15.0 + uses: shivammathur/setup-php@2.16.0 with: php-version: 8.0 tools: composer:v2 From fb0b0c1f2ca0316203d17953e318abf4a0c31b62 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 26 Nov 2021 18:30:37 +0000 Subject: [PATCH 21/85] Bump actions/checkout from 2.3.5 to 2.4.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 2.3.5 to 2.4.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2.3.5...v2.4.0) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index a5f3195d5..50ea0f169 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -34,7 +34,7 @@ jobs: experimental: true steps: - - uses: actions/checkout@v2.3.5 + - uses: actions/checkout@v2.4.0 - name: Setup PHP with PECL extension uses: shivammathur/setup-php@2.16.0 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 5c643a549..f4e8df50d 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.5 + - uses: actions/checkout@v2.4.0 - name: Setup PHP with PECL extension uses: shivammathur/setup-php@2.16.0 From d7316073b2b658cc7662f2e6489c06f07a9401fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 9 Feb 2022 09:15:30 +0000 Subject: [PATCH 22/85] Bump shivammathur/setup-php from 2.16.0 to 2.17.0 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.16.0 to 2.17.0. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.16.0...2.17.0) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 50ea0f169..8fd1856ac 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/checkout@v2.4.0 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.16.0 + uses: shivammathur/setup-php@2.17.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index f4e8df50d..f3e436b30 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v2.4.0 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.16.0 + uses: shivammathur/setup-php@2.17.0 with: php-version: 8.0 tools: composer:v2 From bdcb1980f00d594112a563bd724a2650cb5f2a69 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Mar 2022 09:24:36 +0000 Subject: [PATCH 23/85] Bump actions/checkout from 2.4.0 to 3 Bumps [actions/checkout](https://github.com/actions/checkout) from 2.4.0 to 3. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v2.4.0...v3) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 8fd1856ac..fdc00d418 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -34,7 +34,7 @@ jobs: experimental: true steps: - - uses: actions/checkout@v2.4.0 + - uses: actions/checkout@v3 - name: Setup PHP with PECL extension uses: shivammathur/setup-php@2.17.0 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index f3e436b30..64274ef26 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.4.0 + - uses: actions/checkout@v3 - name: Setup PHP with PECL extension uses: shivammathur/setup-php@2.17.0 From 132d9362ca9b40af2a0bb03a3877f51ada3f745a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Mar 2022 09:24:39 +0000 Subject: [PATCH 24/85] Bump shivammathur/setup-php from 2.17.0 to 2.17.1 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.17.0 to 2.17.1. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.17.0...2.17.1) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index fdc00d418..4cb8b02df 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.17.0 + uses: shivammathur/setup-php@2.17.1 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 64274ef26..4ae98ab7d 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.17.0 + uses: shivammathur/setup-php@2.17.1 with: php-version: 8.0 tools: composer:v2 From 20d1609fc74330cd88c291c961b0adda44d91a45 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Mar 2022 09:11:36 +0000 Subject: [PATCH 25/85] Bump actions/cache from 2.1.7 to 3 Bumps [actions/cache](https://github.com/actions/cache) from 2.1.7 to 3. - [Release notes](https://github.com/actions/cache/releases) - [Commits](https://github.com/actions/cache/compare/v2.1.7...v3) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 4cb8b02df..95d4d4228 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -51,7 +51,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache Composer packages - uses: actions/cache@v2.1.7 + uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 4ae98ab7d..aa052b608 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -34,7 +34,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache Composer packages - uses: actions/cache@v2.1.7 + uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} key: phpstan-linux-php-8.0-${{ hashFiles('**/composer.lock') }} From d21f6ac752b81afc1f3ba20361488e709103e019 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 23 Mar 2022 09:27:35 +0000 Subject: [PATCH 26/85] Bump shivammathur/setup-php from 2.17.1 to 2.18.0 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.17.1 to 2.18.0. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.17.1...2.18.0) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 95d4d4228..240a4090a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.17.1 + uses: shivammathur/setup-php@2.18.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index aa052b608..07a00b7ad 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.17.1 + uses: shivammathur/setup-php@2.18.0 with: php-version: 8.0 tools: composer:v2 From 9cf7805a536dd3e07d5e06f59f251e0f79b29d43 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Apr 2022 09:15:29 +0000 Subject: [PATCH 27/85] Bump shivammathur/setup-php from 2.18.0 to 2.18.1 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.18.0 to 2.18.1. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.18.0...2.18.1) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 240a4090a..be1d5950b 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.18.0 + uses: shivammathur/setup-php@2.18.1 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 07a00b7ad..b877901fa 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.18.0 + uses: shivammathur/setup-php@2.18.1 with: php-version: 8.0 tools: composer:v2 From 60039448430d2c106dd41990f639ca4b1740946f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 30 May 2022 09:17:25 +0000 Subject: [PATCH 28/85] Bump shivammathur/setup-php from 2.18.1 to 2.19.0 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.18.1 to 2.19.0. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.18.1...2.19.0) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index be1d5950b..112db1815 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -37,7 +37,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.18.1 + uses: shivammathur/setup-php@2.19.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index b877901fa..30ab526d9 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.18.1 + uses: shivammathur/setup-php@2.19.0 with: php-version: 8.0 tools: composer:v2 From 0eecf2a30491503a1a1d5dad85238ff5b359cb0f Mon Sep 17 00:00:00 2001 From: Rodrigo Aguilera Date: Sun, 5 Jun 2022 08:26:09 +0200 Subject: [PATCH 29/85] Require Symfony 6. --- .github/workflows/continuous-integration.yml | 10 +--------- composer.json | 6 +++--- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 112db1815..261a69e07 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -21,17 +21,9 @@ jobs: fail-fast: false matrix: php-version: - - "7.4" - - "8.0" + - "8.1" dependency-version: [prefer-lowest, prefer-stable] experimental: [false] - include: - - php-version: "8.1" - dependency-version: "prefer-lowest" - experimental: true - - php-version: "8.1" - dependency-version: "prefer-lowest" - experimental: true steps: - uses: actions/checkout@v3 diff --git a/composer.json b/composer.json index 851b5c247..684e8ba24 100644 --- a/composer.json +++ b/composer.json @@ -27,14 +27,14 @@ } ], "require": { - "php": ">=7.1", + "php": ">=8.1", "beluga-php/docker-php-api": "6.1.41.0", "nyholm/psr7": "^1.3", "php-http/client-common": "^2.3", "php-http/socket-client": "^2.0", "psr/http-message": "^1.0", - "symfony/filesystem": "^5.2", - "symfony/process": "^5.2" + "symfony/filesystem": "^6.1", + "symfony/process": "^6.1" }, "suggest": { "php-http/httplug-bundle": "For integration with Symfony" From 70b45b639ce385ddf8e8e1d0333264c436f20dd4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 6 Jun 2022 09:15:52 +0000 Subject: [PATCH 30/85] Bump shivammathur/setup-php from 2.19.0 to 2.19.1 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.19.0 to 2.19.1. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.19.0...2.19.1) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 261a69e07..98a7327c3 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.19.0 + uses: shivammathur/setup-php@2.19.1 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 30ab526d9..59e0ab2ab 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.19.0 + uses: shivammathur/setup-php@2.19.1 with: php-version: 8.0 tools: composer:v2 From e95e8956ce3fd43346a403f67704dbc0796f0eab Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 7 Jun 2022 14:57:16 -0300 Subject: [PATCH 31/85] Updated dev dependencies --- .gitignore | 2 +- .php_cs => .php-cs-fixer.php | 4 ++-- composer.json | 13 ++++++++----- 3 files changed, 11 insertions(+), 8 deletions(-) rename .php_cs => .php-cs-fixer.php (94%) diff --git a/.gitignore b/.gitignore index 228f5459f..64afb0b51 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,4 @@ vendor/ bin/ composer.lock .vagrant -/.php_cs.cache +/.php-cs-fixer.cache diff --git a/.php_cs b/.php-cs-fixer.php similarity index 94% rename from .php_cs rename to .php-cs-fixer.php index 2555e1b84..3bde3b9fc 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -8,11 +8,11 @@ ->notPath('/fixtures/') ; -return \PhpCsFixer\Config::create() +$config = new \PhpCsFixer\Config(); +return $config ->setRules([ '@Symfony' => true, '@Symfony:risky' => true, - '@PHP56Migration' => true, '@PHP56Migration:risky' => true, '@PHP70Migration' => true, '@PHP70Migration:risky' => true, diff --git a/composer.json b/composer.json index 684e8ba24..fea3731ca 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,10 @@ "config": { "optimize-autoloader": true, "sort-packages": true, - "preferred-install": "dist" + "preferred-install": "dist", + "allow-plugins": { + "infection/extension-installer": true + } }, "minimum-stability": "dev", "prefer-stable": true, @@ -40,12 +43,12 @@ "php-http/httplug-bundle": "For integration with Symfony" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.17", - "infection/infection": "^0.21.5 || ^0.24.0", + "friendsofphp/php-cs-fixer": "^3.8", + "infection/infection": "^0.26", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan": "^0.12.58", + "phpstan/phpstan": "^1.0", "phpunit/phpunit": "^9.5", - "psy/psysh": "^0.10.5", + "psy/psysh": "^0.11", "roave/security-advisories": "dev-master", "squizlabs/php_codesniffer": "^3.5", "vimeo/psalm": "^4.3" From 670be31ae64d5f12d497423795737037351ff7ba Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 7 Jun 2022 15:56:29 -0300 Subject: [PATCH 32/85] Add missing 'use' (introduced by c18d7f9) --- src/Endpoint/ContainerAttachWebsocket.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Endpoint/ContainerAttachWebsocket.php b/src/Endpoint/ContainerAttachWebsocket.php index 13decbe84..0d2d1c95f 100644 --- a/src/Endpoint/ContainerAttachWebsocket.php +++ b/src/Endpoint/ContainerAttachWebsocket.php @@ -6,6 +6,7 @@ use Docker\API\Endpoint\ContainerAttachWebsocket as BaseEndpoint; use Docker\Stream\AttachWebsocketStream; +use Docker\Stream\DockerRawStream; use Nyholm\Psr7\Stream; use Symfony\Component\Serializer\SerializerInterface; From 206ebe52932d8ab1bc54575cababd9980bf8bcb7 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 7 Jun 2022 15:57:15 -0300 Subject: [PATCH 33/85] Update method signature in Docker.php --- src/Docker.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Docker.php b/src/Docker.php index bdfe028fd..536cfeb64 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -5,6 +5,7 @@ namespace Docker; use Docker\API\Client; +use Docker\API\Model\AuthConfig; use Docker\API\Model\ExecIdStartPostBody; use Docker\Endpoint\ContainerAttach; use Docker\Endpoint\ContainerAttachWebsocket; @@ -47,7 +48,7 @@ public function containerLogs(string $id, array $queryParameters = [], string $f /** * {@inheritdoc} */ - public function execStart(string $id, ExecIdStartPostBody $execStartConfig, string $fetch = self::FETCH_OBJECT) + public function execStart(string $id, ?ExecIdStartPostBody $execStartConfig = null, string $fetch = self::FETCH_OBJECT) { return $this->executeEndpoint(new ExecStart($id, $execStartConfig), $fetch); } @@ -55,7 +56,7 @@ public function execStart(string $id, ExecIdStartPostBody $execStartConfig, stri /** * {@inheritdoc} */ - public function imageBuild($inputStream, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) + public function imageBuild($inputStream = null, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) { return $this->executeEndpoint(new ImageBuild($inputStream, $queryParameters, $headerParameters), $fetch); } @@ -63,7 +64,7 @@ public function imageBuild($inputStream, array $queryParameters = [], array $hea /** * {@inheritdoc} */ - public function imageCreate(string $inputImage, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) + public function imageCreate(?string $inputImage = null, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) { return $this->executeEndpoint(new ImageCreate($inputImage, $queryParameters, $headerParameters), $fetch); } @@ -88,12 +89,12 @@ public function systemEvents(array $queryParameters = [], string $fetch = self:: return $this->executeEndpoint(new SystemEvents($queryParameters), $fetch); } - public static function create($httpClient = null, array $additionalPlugins = []) + public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) { if (null === $httpClient) { $httpClient = DockerClientFactory::createFromEnv(); } - return parent::create($httpClient, $additionalPlugins); + return parent::create($httpClient, $additionalPlugins, $additionalNormalizers); } } From 92753624021ef0236676eb020b17149cd24b096e Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 7 Jun 2022 15:58:48 -0300 Subject: [PATCH 34/85] Add dependencies based on composer-require-checker output --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index fea3731ca..476e2c480 100644 --- a/composer.json +++ b/composer.json @@ -31,10 +31,11 @@ ], "require": { "php": ">=8.1", - "beluga-php/docker-php-api": "6.1.41.0", + "beluga-php/docker-php-api": "7.1.41.x-dev", "nyholm/psr7": "^1.3", "php-http/client-common": "^2.3", "php-http/socket-client": "^2.0", + "psr/http-client": "^1.0", "psr/http-message": "^1.0", "symfony/filesystem": "^6.1", "symfony/process": "^6.1" @@ -91,7 +92,7 @@ }, "extra": { "branch-alias": { - "dev-master": "3.x-dev" + "dev-master": "4.x-dev" } } } From 1732d9f98d39b976475a3de4fe33fe7de56c7e27 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 7 Jun 2022 16:22:50 -0300 Subject: [PATCH 35/85] Revert 'dev-master' alias to '3.x-dev' --- composer.json | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 476e2c480..45cccea6d 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,10 @@ } }, "funding": [ + { + "type": "github", + "url": "https://github.com/flavioheleno" + }, { "type": "patreon", "url": "https://www.patreon.com/flavioheleno" @@ -92,7 +96,7 @@ }, "extra": { "branch-alias": { - "dev-master": "4.x-dev" + "dev-master": "3.x-dev" } } } From fea8218c2472bd8225fe319ed7288b2fbb3fdbe7 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 7 Jun 2022 16:24:49 -0300 Subject: [PATCH 36/85] Update FUNDING.yml --- .github/FUNDING.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 0d1ec551e..d018c1530 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,5 @@ # These are supported funding model platforms +github: flavioheleno patreon: flavioheleno +custom: "https://www.buymeacoffee.com/flavioheleno" From 5d27f9bf2ac2f5ff23ccd729c88895887696cce8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 6 Jul 2022 09:18:12 +0000 Subject: [PATCH 37/85] Bump shivammathur/setup-php from 2.19.1 to 2.20.0 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.19.1 to 2.20.0. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.19.1...2.20.0) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 98a7327c3..1e0cae6fd 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.19.1 + uses: shivammathur/setup-php@2.20.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 59e0ab2ab..25f362ee7 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.19.1 + uses: shivammathur/setup-php@2.20.0 with: php-version: 8.0 tools: composer:v2 From 8ef7b8e44995d99f05967c8b09da3edc882f0161 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 26 Dec 2022 09:02:47 +0000 Subject: [PATCH 38/85] Bump shivammathur/setup-php from 2.20.0 to 2.23.0 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.20.0 to 2.23.0. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.20.0...2.23.0) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 1e0cae6fd..c65253970 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.20.0 + uses: shivammathur/setup-php@2.23.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 25f362ee7..0f805271e 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.20.0 + uses: shivammathur/setup-php@2.23.0 with: php-version: 8.0 tools: composer:v2 From edfe25aa9815ecb18a7e5ae6a6e4b193be621d18 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 21 Oct 2022 09:20:23 +0000 Subject: [PATCH 39/85] Bump paambaati/codeclimate-action from 2.7.5 to 3.2.0 Bumps [paambaati/codeclimate-action](https://github.com/paambaati/codeclimate-action) from 2.7.5 to 3.2.0. - [Release notes](https://github.com/paambaati/codeclimate-action/releases) - [Changelog](https://github.com/paambaati/codeclimate-action/blob/main/CHANGELOG.md) - [Commits](https://github.com/paambaati/codeclimate-action/compare/v2.7.5...v3.2.0) --- updated-dependencies: - dependency-name: paambaati/codeclimate-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index c65253970..5873b17e9 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -61,7 +61,7 @@ jobs: run: composer run-script test-ci - name: Publish code coverage - uses: paambaati/codeclimate-action@v2.7.5 + uses: paambaati/codeclimate-action@v3.2.0 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: From 78e61b6b9bba163dc625cd45e3a196514cc85845 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 27 Jan 2023 09:02:13 +0000 Subject: [PATCH 40/85] Bump shivammathur/setup-php from 2.23.0 to 2.24.0 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.23.0 to 2.24.0. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.23.0...2.24.0) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 5873b17e9..b4e2c0319 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.23.0 + uses: shivammathur/setup-php@2.24.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 0f805271e..f704b0bc8 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.23.0 + uses: shivammathur/setup-php@2.24.0 with: php-version: 8.0 tools: composer:v2 From 201acb9816fc2990b46a1b2594101c806d0a4ec2 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Mon, 10 Jul 2023 10:31:21 -0300 Subject: [PATCH 41/85] Update method signatures following latest API generated code --- src/Docker.php | 16 ++++++++-------- src/Endpoint/ContainerAttach.php | 13 +++++-------- src/Endpoint/ContainerAttachWebsocket.php | 13 +++++-------- src/Endpoint/ContainerLogs.php | 13 +++++-------- src/Endpoint/ExecStart.php | 13 +++++-------- src/Endpoint/ImageBuild.php | 12 +++++------- src/Endpoint/ImageCreate.php | 13 +++++-------- src/Endpoint/ImagePush.php | 13 +++++-------- src/Endpoint/SystemEvents.php | 13 +++++-------- 9 files changed, 48 insertions(+), 71 deletions(-) diff --git a/src/Docker.php b/src/Docker.php index 536cfeb64..605c21df8 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -24,25 +24,25 @@ class Docker extends Client /** * {@inheritdoc} */ - public function containerAttach(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT) + public function containerAttach(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) { - return $this->executeEndpoint(new ContainerAttach($id, $queryParameters), $fetch); + return $this->executeEndpoint(new ContainerAttach($id, $queryParameters, $accept), $fetch); } /** * {@inheritdoc} */ - public function containerAttachWebsocket(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT) + public function containerAttachWebsocket(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) { - return $this->executeEndpoint(new ContainerAttachWebsocket($id, $queryParameters), $fetch); + return $this->executeEndpoint(new ContainerAttachWebsocket($id, $queryParameters, $accept), $fetch); } /** * {@inheritdoc} */ - public function containerLogs(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT) + public function containerLogs(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) { - return $this->executeEndpoint(new ContainerLogs($id, $queryParameters), $fetch); + return $this->executeEndpoint(new ContainerLogs($id, $queryParameters, $accept), $fetch); } /** @@ -72,13 +72,13 @@ public function imageCreate(?string $inputImage = null, array $queryParameters = /** * {@inheritdoc} */ - public function imagePush(string $name, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) + public function imagePush(string $name, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) { if (isset($headerParameters['X-Registry-Auth']) && $headerParameters['X-Registry-Auth'] instanceof AuthConfig) { $headerParameters['X-Registry-Auth'] = \base64_encode($this->serializer->serialize($headerParameters['X-Registry-Auth'], 'json')); } - return $this->executeEndpoint(new ImagePush($name, $queryParameters, $headerParameters), $fetch); + return $this->executeEndpoint(new ImagePush($name, $queryParameters, $headerParameters, $accept), $fetch); } /** diff --git a/src/Endpoint/ContainerAttach.php b/src/Endpoint/ContainerAttach.php index e97aee702..1c776639e 100644 --- a/src/Endpoint/ContainerAttach.php +++ b/src/Endpoint/ContainerAttach.php @@ -6,20 +6,17 @@ use Docker\API\Endpoint\ContainerAttach as BaseEndpoint; use Docker\Stream\DockerRawStream; -use Nyholm\Psr7\Stream; +use Psr\Http\Message\ResponseInterface; use Symfony\Component\Serializer\SerializerInterface; class ContainerAttach extends BaseEndpoint { - protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { - if (200 === $status && DockerRawStream::HEADER === $contentType) { - $stream = Stream::create($body); - $stream->rewind(); - - return new DockerRawStream($stream); + if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $contentType) { + return new DockerRawStream($response->getBody()); } - return parent::transformResponseBody($body, $status, $serializer, $contentType); + return parent::transformResponseBody($response, $serializer, $contentType); } } diff --git a/src/Endpoint/ContainerAttachWebsocket.php b/src/Endpoint/ContainerAttachWebsocket.php index 0d2d1c95f..0bbe7c309 100644 --- a/src/Endpoint/ContainerAttachWebsocket.php +++ b/src/Endpoint/ContainerAttachWebsocket.php @@ -7,7 +7,7 @@ use Docker\API\Endpoint\ContainerAttachWebsocket as BaseEndpoint; use Docker\Stream\AttachWebsocketStream; use Docker\Stream\DockerRawStream; -use Nyholm\Psr7\Stream; +use Psr\Http\Message\ResponseInterface; use Symfony\Component\Serializer\SerializerInterface; class ContainerAttachWebsocket extends BaseEndpoint @@ -27,15 +27,12 @@ public function getExtraHeaders(): array ); } - protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { - if (200 === $status && DockerRawStream::HEADER === $contentType) { - $stream = Stream::create($body); - $stream->rewind(); - - return new AttachWebsocketStream($stream); + if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $contentType) { + return new AttachWebsocketStream($response->getBody()); } - return parent::transformResponseBody($body, $status, $serializer, $contentType); + return parent::transformResponseBody($response, $serializer, $contentType); } } diff --git a/src/Endpoint/ContainerLogs.php b/src/Endpoint/ContainerLogs.php index 22d6c1c0e..996b09c39 100644 --- a/src/Endpoint/ContainerLogs.php +++ b/src/Endpoint/ContainerLogs.php @@ -6,20 +6,17 @@ use Docker\API\Endpoint\ContainerLogs as BaseEndpoint; use Docker\Stream\DockerRawStream; -use Nyholm\Psr7\Stream; +use Psr\Http\Message\ResponseInterface; use Symfony\Component\Serializer\SerializerInterface; class ContainerLogs extends BaseEndpoint { - protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { - if (200 === $status && DockerRawStream::HEADER === $contentType) { - $stream = Stream::create($body); - $stream->rewind(); - - return new DockerRawStream($stream); + if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $contentType) { + return new DockerRawStream($response->getBody()); } - return parent::transformResponseBody($body, $status, $serializer, $contentType); + return parent::transformResponseBody($response, $serializer, $contentType); } } diff --git a/src/Endpoint/ExecStart.php b/src/Endpoint/ExecStart.php index c16a83807..e2d8985be 100644 --- a/src/Endpoint/ExecStart.php +++ b/src/Endpoint/ExecStart.php @@ -6,20 +6,17 @@ use Docker\API\Endpoint\ExecStart as BaseEndpoint; use Docker\Stream\DockerRawStream; -use Nyholm\Psr7\Stream; +use Psr\Http\Message\ResponseInterface; use Symfony\Component\Serializer\SerializerInterface; class ExecStart extends BaseEndpoint { - protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { - if (200 === $status && DockerRawStream::HEADER === $contentType) { - $stream = Stream::create($body); - $stream->rewind(); - - return new DockerRawStream($stream); + if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $contentType) { + return new DockerRawStream($response->getBody()); } - return parent::transformResponseBody($body, $status, $serializer, $contentType); + return parent::transformResponseBody($response, $serializer, $contentType); } } diff --git a/src/Endpoint/ImageBuild.php b/src/Endpoint/ImageBuild.php index 62af3a9d5..49239c4cf 100644 --- a/src/Endpoint/ImageBuild.php +++ b/src/Endpoint/ImageBuild.php @@ -8,6 +8,7 @@ use Docker\Stream\BuildStream; use Docker\Stream\TarStream; use Nyholm\Psr7\Stream; +use Psr\Http\Message\ResponseInterface; use Symfony\Component\Serializer\SerializerInterface; class ImageBuild extends BaseEndpoint @@ -23,15 +24,12 @@ public function getBody(SerializerInterface $serializer, $streamFactory = null): return [['Content-Type' => ['application/octet-stream']], $body]; } - protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { - if (200 === $status) { - $stream = Stream::create($body); - $stream->rewind(); - - return new BuildStream($stream, $serializer); + if (200 === $response->getStatusCode()) { + return new BuildStream($response->getBody(), $serializer); } - return parent::transformResponseBody($body, $status, $serializer, $contentType); + return parent::transformResponseBody($response, $serializer, $contentType); } } diff --git a/src/Endpoint/ImageCreate.php b/src/Endpoint/ImageCreate.php index 120982bd7..3a50da2e9 100644 --- a/src/Endpoint/ImageCreate.php +++ b/src/Endpoint/ImageCreate.php @@ -6,20 +6,17 @@ use Docker\API\Endpoint\ImageCreate as BaseEndpoint; use Docker\Stream\CreateImageStream; -use Nyholm\Psr7\Stream; +use Psr\Http\Message\ResponseInterface; use Symfony\Component\Serializer\SerializerInterface; class ImageCreate extends BaseEndpoint { - protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { - if (200 === $status) { - $stream = Stream::create($body); - $stream->rewind(); - - return new CreateImageStream($stream, $serializer); + if (200 === $response->getStatusCode()) { + return new CreateImageStream($response->getBody(), $serializer); } - return parent::transformResponseBody($body, $status, $serializer, $contentType); + return parent::transformResponseBody($response, $serializer, $contentType); } } diff --git a/src/Endpoint/ImagePush.php b/src/Endpoint/ImagePush.php index ed64493d0..da7a93f4a 100644 --- a/src/Endpoint/ImagePush.php +++ b/src/Endpoint/ImagePush.php @@ -6,7 +6,7 @@ use Docker\API\Endpoint\ImagePush as BaseEndpoint; use Docker\Stream\PushStream; -use Nyholm\Psr7\Stream; +use Psr\Http\Message\ResponseInterface; use Symfony\Component\Serializer\SerializerInterface; class ImagePush extends BaseEndpoint @@ -16,15 +16,12 @@ public function getUri(): string return \str_replace(['{name}'], [\urlencode($this->name)], '/images/{name}/push'); } - protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { - if (200 === $status) { - $stream = Stream::create($body); - $stream->rewind(); - - return new PushStream($stream, $serializer); + if (200 === $response->getStatusCode()) { + return new PushStream($response->getBody(), $serializer); } - return parent::transformResponseBody($body, $status, $serializer, $contentType); + return parent::transformResponseBody($response, $serializer, $contentType); } } diff --git a/src/Endpoint/SystemEvents.php b/src/Endpoint/SystemEvents.php index 1526fb817..3f57e916c 100644 --- a/src/Endpoint/SystemEvents.php +++ b/src/Endpoint/SystemEvents.php @@ -6,20 +6,17 @@ use Docker\API\Endpoint\SystemEvents as BaseEndpoint; use Docker\Stream\EventStream; -use Nyholm\Psr7\Stream; +use Psr\Http\Message\ResponseInterface; use Symfony\Component\Serializer\SerializerInterface; class SystemEvents extends BaseEndpoint { - protected function transformResponseBody(string $body, int $status, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { - if (200 === $status) { - $stream = Stream::create($body); - $stream->rewind(); - - return new EventStream($stream, $serializer); + if (200 === $response->getStatusCode()) { + return new EventStream($response->getBody(), $serializer); } - return parent::transformResponseBody($body, $status, $serializer, $contentType); + return parent::transformResponseBody($response, $serializer, $contentType); } } From 92b27bd115cf1ccdc02062ca7cb8740a6e207661 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 13 Jun 2023 09:57:27 +0000 Subject: [PATCH 42/85] Bump shivammathur/setup-php from 2.24.0 to 2.25.4 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.24.0 to 2.25.4. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/2.24.0...2.25.4) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index b4e2c0319..68e9a8d8f 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -29,7 +29,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.24.0 + uses: shivammathur/setup-php@2.25.4 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index f704b0bc8..e6477607e 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -20,7 +20,7 @@ jobs: - uses: actions/checkout@v3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.24.0 + uses: shivammathur/setup-php@2.25.4 with: php-version: 8.0 tools: composer:v2 From eb6233de9282265fa88aa4ad231f2342b343e0ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 24 Aug 2023 09:32:15 +0000 Subject: [PATCH 43/85] Update psr/http-message requirement from ^1.0 to ^1.0 || ^2.0 Updates the requirements on [psr/http-message](https://github.com/php-fig/http-message) to permit the latest version. - [Release notes](https://github.com/php-fig/http-message/releases) - [Changelog](https://github.com/php-fig/http-message/blob/master/CHANGELOG.md) - [Commits](https://github.com/php-fig/http-message/compare/1.0...2.0) --- updated-dependencies: - dependency-name: psr/http-message dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 45cccea6d..53739f993 100644 --- a/composer.json +++ b/composer.json @@ -40,7 +40,7 @@ "php-http/client-common": "^2.3", "php-http/socket-client": "^2.0", "psr/http-client": "^1.0", - "psr/http-message": "^1.0", + "psr/http-message": "^1.0 || ^2.0", "symfony/filesystem": "^6.1", "symfony/process": "^6.1" }, From b26d45bf59570544c8eca9addf992153090058bf Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Mon, 9 Oct 2023 10:49:23 -0300 Subject: [PATCH 44/85] Add "Host" Header to DockerClientFactory --- src/DockerClientFactory.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/DockerClientFactory.php b/src/DockerClientFactory.php index 20a973d59..01bbed2d3 100644 --- a/src/DockerClientFactory.php +++ b/src/DockerClientFactory.php @@ -8,6 +8,7 @@ use Http\Client\Common\Plugin\AddPathPlugin; use Http\Client\Common\Plugin\ContentLengthPlugin; use Http\Client\Common\Plugin\DecoderPlugin; +use Http\Client\Common\Plugin\HeaderDefaultsPlugin; use Http\Client\Common\PluginClientFactory; use Http\Client\Socket\Client; use Http\Discovery\UriFactoryDiscovery; @@ -35,6 +36,9 @@ public static function create(array $config = [], PluginClientFactory $pluginCli new DecoderPlugin(), new AddPathPlugin($uriFactory->createUri('/v1.41')), new AddHostPlugin($uriFactory->createUri($host)), + new HeaderDefaultsPlugin([ + 'host' => \parse_url($host, \PHP_URL_HOST), + ]), ], [ 'client_name' => 'docker-client', From c44e04675829abf5863b08182296fcfc0df1c73b Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Mon, 9 Oct 2023 13:43:44 -0300 Subject: [PATCH 45/85] Fix mismatching method signatures --- src/Docker.php | 64 ---------------------------------------- src/Stream/TarStream.php | 2 +- 2 files changed, 1 insertion(+), 65 deletions(-) diff --git a/src/Docker.php b/src/Docker.php index 605c21df8..a1e3ce121 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -6,69 +6,13 @@ use Docker\API\Client; use Docker\API\Model\AuthConfig; -use Docker\API\Model\ExecIdStartPostBody; -use Docker\Endpoint\ContainerAttach; -use Docker\Endpoint\ContainerAttachWebsocket; -use Docker\Endpoint\ContainerLogs; -use Docker\Endpoint\ExecStart; -use Docker\Endpoint\ImageBuild; -use Docker\Endpoint\ImageCreate; use Docker\Endpoint\ImagePush; -use Docker\Endpoint\SystemEvents; /** * Docker\Docker. */ class Docker extends Client { - /** - * {@inheritdoc} - */ - public function containerAttach(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) - { - return $this->executeEndpoint(new ContainerAttach($id, $queryParameters, $accept), $fetch); - } - - /** - * {@inheritdoc} - */ - public function containerAttachWebsocket(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) - { - return $this->executeEndpoint(new ContainerAttachWebsocket($id, $queryParameters, $accept), $fetch); - } - - /** - * {@inheritdoc} - */ - public function containerLogs(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) - { - return $this->executeEndpoint(new ContainerLogs($id, $queryParameters, $accept), $fetch); - } - - /** - * {@inheritdoc} - */ - public function execStart(string $id, ?ExecIdStartPostBody $execStartConfig = null, string $fetch = self::FETCH_OBJECT) - { - return $this->executeEndpoint(new ExecStart($id, $execStartConfig), $fetch); - } - - /** - * {@inheritdoc} - */ - public function imageBuild($inputStream = null, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) - { - return $this->executeEndpoint(new ImageBuild($inputStream, $queryParameters, $headerParameters), $fetch); - } - - /** - * {@inheritdoc} - */ - public function imageCreate(?string $inputImage = null, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) - { - return $this->executeEndpoint(new ImageCreate($inputImage, $queryParameters, $headerParameters), $fetch); - } - /** * {@inheritdoc} */ @@ -81,14 +25,6 @@ public function imagePush(string $name, array $queryParameters = [], array $head return $this->executeEndpoint(new ImagePush($name, $queryParameters, $headerParameters, $accept), $fetch); } - /** - * {@inheritdoc} - */ - public function systemEvents(array $queryParameters = [], string $fetch = self::FETCH_OBJECT) - { - return $this->executeEndpoint(new SystemEvents($queryParameters), $fetch); - } - public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) { if (null === $httpClient) { diff --git a/src/Stream/TarStream.php b/src/Stream/TarStream.php index 446da02d1..8beb42b2f 100644 --- a/src/Stream/TarStream.php +++ b/src/Stream/TarStream.php @@ -36,7 +36,7 @@ public function detach() /** * {@inheritdoc} */ - public function getSize() + public function getSize(): ?int { return null; } From 2ad6306edda962820b0e5af06b998287b04c90d7 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Mon, 9 Oct 2023 13:45:46 -0300 Subject: [PATCH 46/85] Prepare for 1.42.x --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 53739f993..29f96c1c3 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ ], "require": { "php": ">=8.1", - "beluga-php/docker-php-api": "7.1.41.x-dev", + "beluga-php/docker-php-api": "7.1.42.x-dev", "nyholm/psr7": "^1.3", "php-http/client-common": "^2.3", "php-http/socket-client": "^2.0", @@ -96,7 +96,8 @@ }, "extra": { "branch-alias": { - "dev-master": "3.x-dev" + "dev-master": "1.42.x-dev", + "1.41": "1.41.x-dev" } } } From 18b6a1a5ac9e84b0fa00edf66d0a5637507a9a04 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Mon, 9 Oct 2023 13:47:33 -0300 Subject: [PATCH 47/85] Prepare for 1.43.x --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 29f96c1c3..9aa559f0d 100644 --- a/composer.json +++ b/composer.json @@ -35,7 +35,7 @@ ], "require": { "php": ">=8.1", - "beluga-php/docker-php-api": "7.1.42.x-dev", + "beluga-php/docker-php-api": "7.1.43.x-dev", "nyholm/psr7": "^1.3", "php-http/client-common": "^2.3", "php-http/socket-client": "^2.0", @@ -96,7 +96,8 @@ }, "extra": { "branch-alias": { - "dev-master": "1.42.x-dev", + "dev-master": "1.43.x-dev", + "1.42": "1.42.x-dev", "1.41": "1.41.x-dev" } } From 6c0fcd4f0501c277aa412f8047b550da224aa649 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Mon, 16 Oct 2023 12:38:21 -0300 Subject: [PATCH 48/85] Improve PSR standards adherence --- composer.json | 35 +++++++---------------------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/composer.json b/composer.json index 9aa559f0d..c8d48c750 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "sort-packages": true, "preferred-install": "dist", "allow-plugins": { - "infection/extension-installer": true + "php-http/discovery": false } }, "minimum-stability": "dev", @@ -27,36 +27,27 @@ { "type": "github", "url": "https://github.com/flavioheleno" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/flavioheleno" } ], "require": { "php": ">=8.1", "beluga-php/docker-php-api": "7.1.43.x-dev", - "nyholm/psr7": "^1.3", - "php-http/client-common": "^2.3", - "php-http/socket-client": "^2.0", "psr/http-client": "^1.0", - "psr/http-message": "^1.0 || ^2.0", + "psr/http-client-implementation": "*", + "psr/http-message": "^1.1 || ^2.0", + "psr/http-message-implementation": "*", "symfony/filesystem": "^6.1", "symfony/process": "^6.1" }, "suggest": { - "php-http/httplug-bundle": "For integration with Symfony" + "guzzlehttp/guzzle": "PSR-18 compliant HTTP Client to use the API" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.8", - "infection/infection": "^0.26", "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan": "^1.0", "phpunit/phpunit": "^9.5", "psy/psysh": "^0.11", - "roave/security-advisories": "dev-master", - "squizlabs/php_codesniffer": "^3.5", - "vimeo/psalm": "^4.3" + "roave/security-advisories": "dev-latest" }, "conflict": { "docker-php/docker-php": "*" @@ -65,31 +56,19 @@ "php-cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", "php-cs-fixer-fix": "vendor/bin/php-cs-fixer fix --verbose", "console": "vendor/bin/psysh", - "infection": "vendor/bin/infection", "lint": "vendor/bin/parallel-lint --exclude vendor .", - "phpcs": "vendor/bin/phpcs --standard=ruleset.xml src/ tests/", - "phpstan": "vendor/bin/phpstan analyse --level=max --autoload-file=vendor/autoload.php src/", "phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation", - "psalm": "vendor/bin/psalm --taint-analysis", "test-ci": "vendor/bin/phpunit ./tests/ --disallow-test-output --process-isolation", "test-coverage": "vendor/bin/phpunit ./tests/ --whitelist=./src/ --coverage-clover=clover.xml", "test": [ - "@infection", "@lint", - "@phpunit", - "@phpstan", - "@psalm", - "@phpcs" + "@phpunit" ] }, "scripts-descriptions": { "console": "Runs PsySH Console", - "infection": "Runs mutation test framework", "lint": "Runs complete codebase lint testing", - "phpcs": "Runs coding style checking", - "phpstan": "Runs complete codebase static analysis", "phpunit": "Runs library test suite", - "psalm": "Runs complete codebase taint analysis", "test-ci": "Runs library test suite (for continuous integration)", "test-coverage": "Runs test-coverage analysis", "test": "Runs all tests" From c1b4d963995805cd4bd1fcfbc4293736e95ad522 Mon Sep 17 00:00:00 2001 From: Grant Millar Date: Wed, 18 Oct 2023 12:33:41 +0200 Subject: [PATCH 49/85] Revert back to socket-client, add directly used deps, run php-cs-fixer Signed-off-by: Grant Millar --- composer.json | 19 ++-- src/Context/Context.php | 8 +- src/Context/ContextBuilder.php | 24 +++--- src/Docker.php | 5 +- src/DockerClientFactory.php | 32 +++---- src/Endpoint/ContainerAttach.php | 2 +- src/Endpoint/ContainerAttachWebsocket.php | 6 +- src/Endpoint/ContainerLogs.php | 2 +- src/Endpoint/ExecStart.php | 2 +- src/Endpoint/ImageBuild.php | 2 +- src/Endpoint/ImageCreate.php | 2 +- src/Endpoint/ImagePush.php | 4 +- src/Endpoint/SystemEvents.php | 2 +- src/Stream/AttachWebsocketStream.php | 28 +++--- src/Stream/CallbackStream.php | 2 - src/Stream/DockerRawStream.php | 4 +- src/Stream/MultiJsonStream.php | 3 - src/Stream/TarStream.php | 5 +- tests/Context/ContextBuilderTest.php | 100 ++++++++++++---------- tests/Context/ContextTest.php | 6 +- tests/DockerClientFactoryTest.php | 26 +++--- tests/Resource/SystemResourceTest.php | 4 +- tests/Stream/MultiJsonStreamTest.php | 4 +- 23 files changed, 142 insertions(+), 150 deletions(-) diff --git a/composer.json b/composer.json index c8d48c750..5edebfe55 100644 --- a/composer.json +++ b/composer.json @@ -31,16 +31,15 @@ ], "require": { "php": ">=8.1", - "beluga-php/docker-php-api": "7.1.43.x-dev", - "psr/http-client": "^1.0", - "psr/http-client-implementation": "*", - "psr/http-message": "^1.1 || ^2.0", - "psr/http-message-implementation": "*", - "symfony/filesystem": "^6.1", - "symfony/process": "^6.1" - }, - "suggest": { - "guzzlehttp/guzzle": "PSR-18 compliant HTTP Client to use the API" + "beluga-php/docker-php-api": "7.1.43.0", + "nyholm/psr7": "^1.8", + "php-http/client-common": "^2.7", + "php-http/discovery": "^1.19", + "plesk/socket-client": "^2.1", + "psr/http-message": "^2.0", + "symfony/filesystem": "^6.3", + "symfony/process": "^6.3", + "symfony/serializer": "^6.3" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.8", diff --git a/src/Context/Context.php b/src/Context/Context.php index 06082510c..1cc9b1ec9 100644 --- a/src/Context/Context.php +++ b/src/Context/Context.php @@ -86,7 +86,7 @@ public function setDirectory($directory): void */ public function getDockerfileContent() { - return \file_get_contents($this->directory.\DIRECTORY_SEPARATOR.'Dockerfile'); + return file_get_contents($this->directory.\DIRECTORY_SEPARATOR.'Dockerfile'); } /** @@ -132,7 +132,7 @@ public function toTar() public function toStream() { if (!\is_resource($this->process)) { - $this->process = \proc_open('/usr/bin/env tar -c .', [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes, $this->directory); + $this->process = proc_open('/usr/bin/env tar -c .', [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes, $this->directory); $this->stream = $pipes[1]; } @@ -142,11 +142,11 @@ public function toStream() public function __destruct() { if (\is_resource($this->stream)) { - \fclose($this->stream); + fclose($this->stream); } if (\is_resource($this->process)) { - \proc_close($this->process); + proc_close($this->process); } if ($this->cleanup) { diff --git a/src/Context/ContextBuilder.php b/src/Context/ContextBuilder.php index e8b37365b..5e0aa37bc 100644 --- a/src/Context/ContextBuilder.php +++ b/src/Context/ContextBuilder.php @@ -255,7 +255,7 @@ public function volume($volume) */ public function getContext() { - $directory = \sys_get_temp_dir().'/ctb-'.\microtime(); + $directory = sys_get_temp_dir().'/ctb-'.microtime(); $this->fs->mkdir($directory); $this->write($directory); @@ -325,7 +325,7 @@ private function write($directory): void $dockerfile[] = 'CMD '.$this->command; } - $this->fs->dumpFile($directory.\DIRECTORY_SEPARATOR.'Dockerfile', \implode(PHP_EOL, $dockerfile)); + $this->fs->dumpFile($directory.\DIRECTORY_SEPARATOR.'Dockerfile', implode(\PHP_EOL, $dockerfile)); } /** @@ -338,12 +338,12 @@ private function write($directory): void */ private function getFile($directory, $content) { - $hash = \md5($content); + $hash = md5($content); if (!\array_key_exists($hash, $this->files)) { - $file = \tempnam($directory, ''); + $file = tempnam($directory, ''); $this->fs->dumpFile($file, $content); - $this->files[$hash] = \basename($file); + $this->files[$hash] = basename($file); } return $this->files[$hash]; @@ -359,14 +359,14 @@ private function getFile($directory, $content) */ private function getFileFromStream($directory, $stream) { - $file = \tempnam($directory, ''); - $target = \fopen($file, 'w'); - if (0 === \stream_copy_to_stream($stream, $target)) { + $file = tempnam($directory, ''); + $target = fopen($file, 'w'); + if (0 === stream_copy_to_stream($stream, $target)) { throw new \RuntimeException('Failed to write stream to file'); } - \fclose($target); + fclose($target); - return \basename($file); + return basename($file); } /** @@ -379,10 +379,10 @@ private function getFileFromStream($directory, $stream) */ private function getFileFromDisk($directory, $source) { - $hash = 'DISK-'.\md5(\realpath($source)); + $hash = 'DISK-'.md5(realpath($source)); if (!\array_key_exists($hash, $this->files)) { // Check if source is a directory or a file. - if (\is_dir($source)) { + if (is_dir($source)) { $this->fs->mirror($source, $directory.'/'.$hash, null, ['copy_on_windows' => true]); } else { $this->fs->copy($source, $directory.'/'.$hash); diff --git a/src/Docker.php b/src/Docker.php index a1e3ce121..ba4ce786b 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -13,13 +13,10 @@ */ class Docker extends Client { - /** - * {@inheritdoc} - */ public function imagePush(string $name, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) { if (isset($headerParameters['X-Registry-Auth']) && $headerParameters['X-Registry-Auth'] instanceof AuthConfig) { - $headerParameters['X-Registry-Auth'] = \base64_encode($this->serializer->serialize($headerParameters['X-Registry-Auth'], 'json')); + $headerParameters['X-Registry-Auth'] = base64_encode($this->serializer->serialize($headerParameters['X-Registry-Auth'], 'json')); } return $this->executeEndpoint(new ImagePush($name, $queryParameters, $headerParameters, $accept), $fetch); diff --git a/src/DockerClientFactory.php b/src/DockerClientFactory.php index 01bbed2d3..2c050cb1b 100644 --- a/src/DockerClientFactory.php +++ b/src/DockerClientFactory.php @@ -9,14 +9,14 @@ use Http\Client\Common\Plugin\ContentLengthPlugin; use Http\Client\Common\Plugin\DecoderPlugin; use Http\Client\Common\Plugin\HeaderDefaultsPlugin; +use Http\Client\Common\PluginClient; use Http\Client\Common\PluginClientFactory; use Http\Client\Socket\Client; -use Http\Discovery\UriFactoryDiscovery; -use Psr\Http\Client\ClientInterface; +use Http\Discovery\Psr17FactoryDiscovery; final class DockerClientFactory { - public static function create(array $config = [], PluginClientFactory $pluginClientFactory = null): ClientInterface + public static function create(array $config = [], PluginClientFactory $pluginClientFactory = null): PluginClient { if (!\array_key_exists('remote_socket', $config)) { $config['remote_socket'] = 'unix:///var/run/docker.sock'; @@ -24,10 +24,10 @@ public static function create(array $config = [], PluginClientFactory $pluginCli $socketClient = new Client($config); - $uriFactory = UriFactoryDiscovery::find(); - $host = \preg_match('/unix:\/\//', $config['remote_socket']) ? 'http://localhost' : $config['remote_socket']; + $uriFactory = Psr17FactoryDiscovery::findUriFactory(); + $host = preg_match('/unix:\/\//', $config['remote_socket']) ? 'http://localhost' : $config['remote_socket']; - $pluginClientFactory = $pluginClientFactory ?? new PluginClientFactory(); + $pluginClientFactory ??= new PluginClientFactory(); return $pluginClientFactory->createClient( $socketClient, @@ -37,7 +37,7 @@ public static function create(array $config = [], PluginClientFactory $pluginCli new AddPathPlugin($uriFactory->createUri('/v1.41')), new AddHostPlugin($uriFactory->createUri($host)), new HeaderDefaultsPlugin([ - 'host' => \parse_url($host, \PHP_URL_HOST), + 'host' => parse_url($host, \PHP_URL_HOST), ]), ], [ @@ -46,20 +46,20 @@ public static function create(array $config = [], PluginClientFactory $pluginCli ); } - public static function createFromEnv(PluginClientFactory $pluginClientFactory = null): ClientInterface + public static function createFromEnv(PluginClientFactory $pluginClientFactory = null): PluginClient { $options = [ - 'remote_socket' => \getenv('DOCKER_HOST') ? \getenv('DOCKER_HOST') : 'unix:///var/run/docker.sock', + 'remote_socket' => getenv('DOCKER_HOST') ? getenv('DOCKER_HOST') : 'unix:///var/run/docker.sock', ]; - if (\getenv('DOCKER_TLS_VERIFY') && '1' === \getenv('DOCKER_TLS_VERIFY')) { - if (!\getenv('DOCKER_CERT_PATH')) { + if (getenv('DOCKER_TLS_VERIFY') && '1' === getenv('DOCKER_TLS_VERIFY')) { + if (!getenv('DOCKER_CERT_PATH')) { throw new \RuntimeException('Connection to docker has been set to use TLS, but no PATH is defined for certificate in DOCKER_CERT_PATH docker environment variable'); } - $cafile = \getenv('DOCKER_CERT_PATH').\DIRECTORY_SEPARATOR.'ca.pem'; - $certfile = \getenv('DOCKER_CERT_PATH').\DIRECTORY_SEPARATOR.'cert.pem'; - $keyfile = \getenv('DOCKER_CERT_PATH').\DIRECTORY_SEPARATOR.'key.pem'; + $cafile = getenv('DOCKER_CERT_PATH').\DIRECTORY_SEPARATOR.'ca.pem'; + $certfile = getenv('DOCKER_CERT_PATH').\DIRECTORY_SEPARATOR.'cert.pem'; + $keyfile = getenv('DOCKER_CERT_PATH').\DIRECTORY_SEPARATOR.'key.pem'; $stream_context = [ 'cafile' => $cafile, @@ -67,8 +67,8 @@ public static function createFromEnv(PluginClientFactory $pluginClientFactory = 'local_pk' => $keyfile, ]; - if (\getenv('DOCKER_PEER_NAME')) { - $stream_context['peer_name'] = \getenv('DOCKER_PEER_NAME'); + if (getenv('DOCKER_PEER_NAME')) { + $stream_context['peer_name'] = getenv('DOCKER_PEER_NAME'); } $options['ssl'] = true; diff --git a/src/Endpoint/ContainerAttach.php b/src/Endpoint/ContainerAttach.php index 1c776639e..571ec2252 100644 --- a/src/Endpoint/ContainerAttach.php +++ b/src/Endpoint/ContainerAttach.php @@ -11,7 +11,7 @@ class ContainerAttach extends BaseEndpoint { - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) { if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $contentType) { return new DockerRawStream($response->getBody()); diff --git a/src/Endpoint/ContainerAttachWebsocket.php b/src/Endpoint/ContainerAttachWebsocket.php index 0bbe7c309..6009f415a 100644 --- a/src/Endpoint/ContainerAttachWebsocket.php +++ b/src/Endpoint/ContainerAttachWebsocket.php @@ -14,7 +14,7 @@ class ContainerAttachWebsocket extends BaseEndpoint { public function getExtraHeaders(): array { - return \array_merge( + return array_merge( parent::getExtraHeaders(), [ 'Host' => 'localhost', @@ -22,12 +22,12 @@ public function getExtraHeaders(): array 'Upgrade' => 'websocket', 'Connection' => 'Upgrade', 'Sec-WebSocket-Version' => '13', - 'Sec-WebSocket-Key' => \base64_encode(\uniqid()), + 'Sec-WebSocket-Key' => base64_encode(uniqid()), ] ); } - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) { if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $contentType) { return new AttachWebsocketStream($response->getBody()); diff --git a/src/Endpoint/ContainerLogs.php b/src/Endpoint/ContainerLogs.php index 996b09c39..573ae6481 100644 --- a/src/Endpoint/ContainerLogs.php +++ b/src/Endpoint/ContainerLogs.php @@ -11,7 +11,7 @@ class ContainerLogs extends BaseEndpoint { - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) { if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $contentType) { return new DockerRawStream($response->getBody()); diff --git a/src/Endpoint/ExecStart.php b/src/Endpoint/ExecStart.php index e2d8985be..844a49066 100644 --- a/src/Endpoint/ExecStart.php +++ b/src/Endpoint/ExecStart.php @@ -11,7 +11,7 @@ class ExecStart extends BaseEndpoint { - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) { if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $contentType) { return new DockerRawStream($response->getBody()); diff --git a/src/Endpoint/ImageBuild.php b/src/Endpoint/ImageBuild.php index 49239c4cf..c0ceb6459 100644 --- a/src/Endpoint/ImageBuild.php +++ b/src/Endpoint/ImageBuild.php @@ -24,7 +24,7 @@ public function getBody(SerializerInterface $serializer, $streamFactory = null): return [['Content-Type' => ['application/octet-stream']], $body]; } - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) { if (200 === $response->getStatusCode()) { return new BuildStream($response->getBody(), $serializer); diff --git a/src/Endpoint/ImageCreate.php b/src/Endpoint/ImageCreate.php index 3a50da2e9..3ea1aad04 100644 --- a/src/Endpoint/ImageCreate.php +++ b/src/Endpoint/ImageCreate.php @@ -11,7 +11,7 @@ class ImageCreate extends BaseEndpoint { - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) { if (200 === $response->getStatusCode()) { return new CreateImageStream($response->getBody(), $serializer); diff --git a/src/Endpoint/ImagePush.php b/src/Endpoint/ImagePush.php index da7a93f4a..64ea660b3 100644 --- a/src/Endpoint/ImagePush.php +++ b/src/Endpoint/ImagePush.php @@ -13,10 +13,10 @@ class ImagePush extends BaseEndpoint { public function getUri(): string { - return \str_replace(['{name}'], [\urlencode($this->name)], '/images/{name}/push'); + return str_replace(['{name}'], [urlencode($this->name)], '/images/{name}/push'); } - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) { if (200 === $response->getStatusCode()) { return new PushStream($response->getBody(), $serializer); diff --git a/src/Endpoint/SystemEvents.php b/src/Endpoint/SystemEvents.php index 3f57e916c..339a60625 100644 --- a/src/Endpoint/SystemEvents.php +++ b/src/Endpoint/SystemEvents.php @@ -11,7 +11,7 @@ class SystemEvents extends BaseEndpoint { - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) { if (200 === $response->getStatusCode()) { return new EventStream($response->getBody(), $serializer); diff --git a/src/Stream/AttachWebsocketStream.php b/src/Stream/AttachWebsocketStream.php index 10a12e546..0394ac2f8 100644 --- a/src/Stream/AttachWebsocketStream.php +++ b/src/Stream/AttachWebsocketStream.php @@ -30,7 +30,7 @@ public function __construct(StreamInterface $stream) */ public function write($data): void { - $rand = \random_int(0, 28); + $rand = random_int(0, 28); $frame = [ 'fin' => 1, 'rsv1' => 0, @@ -39,7 +39,7 @@ public function write($data): void 'opcode' => 1, // We always send text 'mask' => 1, 'len' => \strlen($data), - 'mask_key' => \substr(\md5(\uniqid()), $rand, 4), + 'mask_key' => substr(md5(uniqid()), $rand, 4), 'data' => $data, ]; @@ -65,12 +65,12 @@ public function write($data): void $this->socketWrite(\chr($secondByte)); if (126 === $len) { - $this->socketWrite(\pack('n', $frame['len'])); + $this->socketWrite(pack('n', $frame['len'])); } elseif (127 === $len) { $higher = $frame['len'] >> 32; $lower = ($frame['len'] << 32) >> 32; - $this->socketWrite(\pack('N', $higher)); - $this->socketWrite(\pack('N', $lower)); + $this->socketWrite(pack('N', $higher)); + $this->socketWrite(pack('N', $lower)); } if (1 === $frame['mask']) { @@ -91,7 +91,7 @@ public function write($data): void */ public function read($waitTime = 0, $waitMicroTime = 200000, $getFrame = false) { - if (!\is_resource($this->socket) || \feof($this->socket)) { + if (!\is_resource($this->socket) || feof($this->socket)) { return null; } @@ -99,7 +99,7 @@ public function read($waitTime = 0, $waitMicroTime = 200000, $getFrame = false) $write = null; $expect = null; - if (0 === \stream_select($read, $write, $expect, $waitTime, $waitMicroTime)) { + if (0 === stream_select($read, $write, $expect, $waitTime, $waitMicroTime)) { return false; } @@ -121,9 +121,9 @@ public function read($waitTime = 0, $waitMicroTime = 200000, $getFrame = false) // Get length of the frame if (126 === $frame['len']) { - $frame['len'] = \unpack('n', $this->socketRead(2))[1]; + $frame['len'] = unpack('n', $this->socketRead(2))[1]; } elseif (127 === $frame['len']) { - list($higher, $lower) = \array_values(\unpack('N2', $this->socketRead(8))); + [$higher, $lower] = array_values(unpack('N2', $this->socketRead(8))); $frame['len'] = ($higher << 32) | $lower; } @@ -151,8 +151,6 @@ public function read($waitTime = 0, $waitMicroTime = 200000, $getFrame = false) /** * Force to have something of the expected size (block). * - * @param $length - * * @return string */ private function socketRead($length) @@ -160,8 +158,8 @@ private function socketRead($length) $read = ''; do { - $read .= \fread($this->socket, $length - \strlen($read)); - } while (\strlen($read) < $length && !\feof($this->socket)); + $read .= fread($this->socket, $length - \strlen($read)); + } while (\strlen($read) < $length && !feof($this->socket)); return $read; } @@ -169,12 +167,10 @@ private function socketRead($length) /** * Write to the socket. * - * @param $data - * * @return int */ private function socketWrite($data) { - return \fwrite($this->socket, $data); + return fwrite($this->socket, $data); } } diff --git a/src/Stream/CallbackStream.php b/src/Stream/CallbackStream.php index 459f20ab4..382c935f4 100644 --- a/src/Stream/CallbackStream.php +++ b/src/Stream/CallbackStream.php @@ -27,8 +27,6 @@ public function onFrame(callable $onNewFrame): void /** * Read a frame in the stream. - * - * @return mixed */ abstract protected function readFrame(); diff --git a/src/Stream/DockerRawStream.php b/src/Stream/DockerRawStream.php index bd97f817a..1ec7ce8b0 100644 --- a/src/Stream/DockerRawStream.php +++ b/src/Stream/DockerRawStream.php @@ -62,7 +62,7 @@ protected function readFrame(): void return; } - $decoded = \unpack('C1type/C3/N1size', $header); + $decoded = unpack('C1type/C3/N1size', $header); $output = $this->forceRead($decoded['size']); $callbackList = []; @@ -86,8 +86,6 @@ protected function readFrame(): void /** * Force to have something of the expected size (block). * - * @param $length - * * @return string */ private function forceRead($length) diff --git a/src/Stream/MultiJsonStream.php b/src/Stream/MultiJsonStream.php index 0973f98a5..536afa171 100644 --- a/src/Stream/MultiJsonStream.php +++ b/src/Stream/MultiJsonStream.php @@ -22,9 +22,6 @@ public function __construct(StreamInterface $stream, SerializerInterface $serial $this->serializer = $serializer; } - /** - * {@inheritdoc} - */ protected function readFrame() { $jsonFrameEnd = false; diff --git a/src/Stream/TarStream.php b/src/Stream/TarStream.php index 8beb42b2f..f14823c89 100644 --- a/src/Stream/TarStream.php +++ b/src/Stream/TarStream.php @@ -33,9 +33,6 @@ public function detach() return $this->stream->detach(); } - /** - * {@inheritdoc} - */ public function getSize(): ?int { return null; @@ -56,7 +53,7 @@ public function isSeekable(): bool return $this->stream->isSeekable(); } - public function seek($offset, $whence = SEEK_SET): void + public function seek($offset, $whence = \SEEK_SET): void { $this->stream->seek($offset, $whence); } diff --git a/tests/Context/ContextBuilderTest.php b/tests/Context/ContextBuilderTest.php index f6b72097a..613964f01 100644 --- a/tests/Context/ContextBuilderTest.php +++ b/tests/Context/ContextBuilderTest.php @@ -61,7 +61,7 @@ public function testWriteTmpFiles(): void $contextBuilder->add('/foo', 'random content'); $context = $contextBuilder->getContext(); - $filename = \preg_replace(<<getDockerfileContent()); @@ -72,13 +72,13 @@ public function testWriteTmpFiles(): void public function testWriteTmpFileFromStream(): void { $contextBuilder = new ContextBuilder(); - $stream = \fopen('php://temp', 'r+'); - $this->assertSame(7, \fwrite($stream, 'test123')); - \rewind($stream); + $stream = fopen('php://temp', 'r+'); + $this->assertSame(7, fwrite($stream, 'test123')); + rewind($stream); $contextBuilder->addStream('/foo', $stream); $context = $contextBuilder->getContext(); - $filename = \preg_replace(<<getDockerfileContent()); @@ -88,13 +88,13 @@ public function testWriteTmpFileFromStream(): void public function testWriteTmpFileFromDisk(): void { $contextBuilder = new ContextBuilder(); - $file = \tempnam('', ''); - \file_put_contents($file, 'abc'); + $file = tempnam('', ''); + file_put_contents($file, 'abc'); $this->assertStringEqualsFile($file, 'abc'); $contextBuilder->addFile('/foo', $file); $context = $contextBuilder->getContext(); - $filename = \preg_replace(<<getDockerfileContent()); @@ -104,15 +104,15 @@ public function testWriteTmpFileFromDisk(): void public function testWriteTmpDirFromDisk(): void { $contextBuilder = new ContextBuilder(); - $dir = \tempnam(\sys_get_temp_dir(), ''); - \unlink($dir); - \mkdir($dir); - \file_put_contents($dir.'/test', 'abc'); + $dir = tempnam(sys_get_temp_dir(), ''); + unlink($dir); + mkdir($dir); + file_put_contents($dir.'/test', 'abc'); $this->assertStringEqualsFile($dir.'/test', 'abc'); $contextBuilder->addFile('/foo', $dir); $context = $contextBuilder->getContext(); - $filename = \preg_replace(<<getDockerfileContent()); @@ -126,10 +126,12 @@ public function testWritesAddCommands(): void $context = $contextBuilder->getContext(); - $this->assertMatchesRegularExpression(<<getDockerfileContent() + $this->assertMatchesRegularExpression( + <<getDockerfileContent() ); } @@ -140,10 +142,12 @@ public function testWritesRunCommands(): void $context = $contextBuilder->getContext(); - $this->assertStringEqualsFile($context->getDirectory().'/Dockerfile', <<assertStringEqualsFile( + $context->getDirectory().'/Dockerfile', + <<getContext(); - $this->assertStringEqualsFile($context->getDirectory().'/Dockerfile', <<assertStringEqualsFile( + $context->getDirectory().'/Dockerfile', + <<getContext(); - $this->assertStringEqualsFile($context->getDirectory().'/Dockerfile', <<assertStringEqualsFile( + $context->getDirectory().'/Dockerfile', + <<getContext(); - $this->assertStringEqualsFile($context->getDirectory().'/Dockerfile', <<assertStringEqualsFile( + $context->getDirectory().'/Dockerfile', + <<getContext(); - $this->assertStringEqualsFile($context->getDirectory().'/Dockerfile', <<assertStringEqualsFile( + $context->getDirectory().'/Dockerfile', + <<addFile('/foo', $dir); $context = $contextBuilder->getContext(); - $filename = \preg_replace(<<getDockerfileContent()); - \unlink($file); + unlink($file); $context->setCleanup(false); $this->assertStringEqualsFile($context->getDirectory().'/'.$filename.'/test-symlink', 'abc'); } diff --git a/tests/Context/ContextTest.php b/tests/Context/ContextTest.php index 9e143cfe4..1038213b7 100644 --- a/tests/Context/ContextTest.php +++ b/tests/Context/ContextTest.php @@ -43,13 +43,13 @@ public function testTarFailed(): void $this->expectException(\Symfony\Component\Process\Exception\ProcessFailedException::class); $directory = __DIR__.\DIRECTORY_SEPARATOR.'context-test'; - $path = \getenv('PATH'); - \putenv('PATH=/'); + $path = getenv('PATH'); + putenv('PATH=/'); $context = new Context($directory); try { $context->toTar(); } finally { - \putenv("PATH=$path"); + putenv("PATH=$path"); } } diff --git a/tests/DockerClientFactoryTest.php b/tests/DockerClientFactoryTest.php index e438a4f30..ed09a955c 100644 --- a/tests/DockerClientFactoryTest.php +++ b/tests/DockerClientFactoryTest.php @@ -12,7 +12,7 @@ class DockerClientFactoryTest extends TestCase protected function tearDown(): void { parent::tearDown(); - \putenv('DOCKER_TLS_VERIFY'); + putenv('DOCKER_TLS_VERIFY'); } public function testStaticConstructor(): void @@ -25,24 +25,24 @@ public function testCreateFromEnvWithoutCertPath(): void $this->expectException(\RuntimeException::class); $this->expectExceptionMessage('Connection to docker has been set to use TLS, but no PATH is defined for certificate in DOCKER_CERT_PATH docker environment variable'); - \putenv('DOCKER_TLS_VERIFY=1'); + putenv('DOCKER_TLS_VERIFY=1'); DockerClientFactory::createFromEnv(); } public function testCreateCustomCa(): void { - \putenv('DOCKER_TLS_VERIFY=1'); - \putenv('DOCKER_CERT_PATH=/tmp'); + putenv('DOCKER_TLS_VERIFY=1'); + putenv('DOCKER_CERT_PATH=/tmp'); - $count = \count(\get_resources('stream-context')); + $count = \count(get_resources('stream-context')); $client = DockerClientFactory::createFromEnv(); $this->assertInstanceOf(ClientInterface::class, $client); - $contexts = \get_resources('stream-context'); + $contexts = get_resources('stream-context'); $this->assertCount($count + 1, $contexts); // Get the last stream context. - $context = \stream_context_get_options(\end($contexts)); + $context = stream_context_get_options(end($contexts)); $this->assertSame('/tmp/ca.pem', $context['ssl']['cafile']); $this->assertSame('/tmp/cert.pem', $context['ssl']['local_cert']); $this->assertSame('/tmp/key.pem', $context['ssl']['local_pk']); @@ -50,19 +50,19 @@ public function testCreateCustomCa(): void public function testCreateCustomPeerName(): void { - \putenv('DOCKER_TLS_VERIFY=1'); - \putenv('DOCKER_CERT_PATH=/abc'); - \putenv('DOCKER_PEER_NAME=test'); + putenv('DOCKER_TLS_VERIFY=1'); + putenv('DOCKER_CERT_PATH=/abc'); + putenv('DOCKER_PEER_NAME=test'); - $count = \count(\get_resources('stream-context')); + $count = \count(get_resources('stream-context')); $client = DockerClientFactory::createFromEnv(); $this->assertInstanceOf(ClientInterface::class, $client); - $contexts = \get_resources('stream-context'); + $contexts = get_resources('stream-context'); $this->assertCount($count + 1, $contexts); // Get the last stream context. - $context = \stream_context_get_options(\end($contexts)); + $context = stream_context_get_options(end($contexts)); $this->assertSame('/abc/ca.pem', $context['ssl']['cafile']); $this->assertSame('/abc/cert.pem', $context['ssl']['local_cert']); $this->assertSame('/abc/key.pem', $context['ssl']['local_pk']); diff --git a/tests/Resource/SystemResourceTest.php b/tests/Resource/SystemResourceTest.php index 474f3506e..b88c4069f 100644 --- a/tests/Resource/SystemResourceTest.php +++ b/tests/Resource/SystemResourceTest.php @@ -20,8 +20,8 @@ private function getManager() public function testGetEvents(): void { $stream = $this->getManager()->systemEvents([ - 'since' => (string) (\time() - 1), - 'until' => (string) (\time() + 4), + 'since' => (string) (time() - 1), + 'until' => (string) (time() + 4), ]); $lastEvent = null; diff --git a/tests/Stream/MultiJsonStreamTest.php b/tests/Stream/MultiJsonStreamTest.php index 2fd1d36aa..29d65739a 100644 --- a/tests/Stream/MultiJsonStreamTest.php +++ b/tests/Stream/MultiJsonStreamTest.php @@ -31,8 +31,6 @@ public function jsonStreamDataProvider() } /** - * @param $jsonStream - * @param $jsonParts * @dataProvider jsonStreamDataProvider */ public function testReadJsonEscapedDoubleQuote(string $jsonStream, array $jsonParts): void @@ -46,7 +44,7 @@ public function testReadJsonEscapedDoubleQuote(string $jsonStream, array $jsonPa $serializer ->expects($this->exactly(\count($jsonParts))) ->method('deserialize') - ->withConsecutive(...\array_map(fn ($part) => [$part, BuildInfo::class, 'json', []], $jsonParts)) + ->withConsecutive(...array_map(fn ($part) => [$part, BuildInfo::class, 'json', []], $jsonParts)) ; $stub = $this->getMockForAbstractClass(MultiJsonStream::class, [$stream, $serializer]); From 4a2b826f2c1e25c50204e73ac39e23fed207a29e Mon Sep 17 00:00:00 2001 From: Grant Millar Date: Wed, 18 Oct 2023 13:02:24 +0200 Subject: [PATCH 50/85] Update endpoint version Signed-off-by: Grant Millar --- src/DockerClientFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DockerClientFactory.php b/src/DockerClientFactory.php index 2c050cb1b..74a43dd8b 100644 --- a/src/DockerClientFactory.php +++ b/src/DockerClientFactory.php @@ -34,7 +34,7 @@ public static function create(array $config = [], PluginClientFactory $pluginCli [ new ContentLengthPlugin(), new DecoderPlugin(), - new AddPathPlugin($uriFactory->createUri('/v1.41')), + new AddPathPlugin($uriFactory->createUri('/v1.43')), new AddHostPlugin($uriFactory->createUri($host)), new HeaderDefaultsPlugin([ 'host' => parse_url($host, \PHP_URL_HOST), From 37c3f53e9f59e101477f4e1e5ae4443c290f418b Mon Sep 17 00:00:00 2001 From: Grant Millar Date: Wed, 18 Oct 2023 16:35:42 +0200 Subject: [PATCH 51/85] Improve error handling when client version not supported, or other API error Signed-off-by: Grant Millar --- src/Docker.php | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Docker.php b/src/Docker.php index ba4ce786b..ddac26942 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -7,6 +7,8 @@ use Docker\API\Client; use Docker\API\Model\AuthConfig; use Docker\Endpoint\ImagePush; +use Docker\API\Runtime\Client\Client as RuntimeClient; +use Docker\API\Exception\BadRequestException; /** * Docker\Docker. @@ -28,6 +30,22 @@ public static function create($httpClient = null, array $additionalPlugins = [], $httpClient = DockerClientFactory::createFromEnv(); } - return parent::create($httpClient, $additionalPlugins, $additionalNormalizers); + $client = parent::create($httpClient, $additionalPlugins, $additionalNormalizers); + $testClient = $client->systemInfo(RuntimeClient::FETCH_RESPONSE)->getBody()->getContents(); + $jsonObj = json_decode($testClient); + + if ($jsonObj !== null) { + if (isset($jsonObj->message)) { + // Check if the client is too new + if (strpos($jsonObj->message, 'client version') !== false && strpos($jsonObj->message, 'is too new') !== false) { + throw new BadRequestException("The client version is not supported by your version of Docker. Message: {$jsonObj->message}"); + } else { + throw new BadRequestException($jsonObj->message); + } + } + } else { + throw new BadRequestException("Failed to decode JSON."); + } + return $client; } } From 10748ae6a18891d2681a2cc9fcff6239e9c9f332 Mon Sep 17 00:00:00 2001 From: Rodrigo Aguilera Date: Wed, 1 Nov 2023 22:18:39 +0100 Subject: [PATCH 52/85] Restore ImageBuild endpoint along with others. --- src/Docker.php | 67 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/src/Docker.php b/src/Docker.php index ddac26942..94ff82e52 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -5,16 +5,71 @@ namespace Docker; use Docker\API\Client; +use Docker\API\Exception\BadRequestException; use Docker\API\Model\AuthConfig; -use Docker\Endpoint\ImagePush; +use Docker\API\Model\ExecIdStartPostBody; use Docker\API\Runtime\Client\Client as RuntimeClient; -use Docker\API\Exception\BadRequestException; +use Docker\Endpoint\ContainerAttach; +use Docker\Endpoint\ContainerAttachWebsocket; +use Docker\Endpoint\ContainerLogs; +use Docker\Endpoint\ExecStart; +use Docker\Endpoint\ImageBuild; +use Docker\Endpoint\ImageCreate; +use Docker\Endpoint\ImagePush; +use Docker\Endpoint\SystemEvents; /** * Docker\Docker. */ class Docker extends Client { + /** + * {@inheritdoc} + */ + public function containerAttach(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) + { + return $this->executeEndpoint(new ContainerAttach($id, $queryParameters, $accept), $fetch); + } + + /** + * {@inheritdoc} + */ + public function containerAttachWebsocket(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) + { + return $this->executeEndpoint(new ContainerAttachWebsocket($id, $queryParameters, $accept), $fetch); + } + + /** + * {@inheritdoc} + */ + public function containerLogs(string $id, array $queryParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) + { + return $this->executeEndpoint(new ContainerLogs($id, $queryParameters, $accept), $fetch); + } + + /** + * {@inheritdoc} + */ + public function execStart(string $id, ?ExecIdStartPostBody $requestBody = null, string $fetch = self::FETCH_OBJECT, array $accept = []) + { + return $this->executeEndpoint(new ExecStart($id, $requestBody, $accept), $fetch); + } + + /** + * {@inheritdoc} + */ + public function imageBuild($requestBody = null, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) + { + return $this->executeEndpoint(new ImageBuild($requestBody, $queryParameters, $headerParameters), $fetch); + } + + /** + * {@inheritdoc} + */ + public function imageCreate(string $requestBody = null, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) + { + return $this->executeEndpoint(new ImageCreate($requestBody, $queryParameters, $headerParameters), $fetch); + } public function imagePush(string $name, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT, array $accept = []) { if (isset($headerParameters['X-Registry-Auth']) && $headerParameters['X-Registry-Auth'] instanceof AuthConfig) { @@ -24,6 +79,14 @@ public function imagePush(string $name, array $queryParameters = [], array $head return $this->executeEndpoint(new ImagePush($name, $queryParameters, $headerParameters, $accept), $fetch); } + /** + * {@inheritdoc} + */ + public function systemEvents(array $queryParameters = [], string $fetch = self::FETCH_OBJECT) + { + return $this->executeEndpoint(new SystemEvents($queryParameters), $fetch); + } + public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) { if (null === $httpClient) { From 0d2de4774d3e6b2499d61be6ae89ded81e44149b Mon Sep 17 00:00:00 2001 From: Rodrigo Aguilera Date: Fri, 16 Feb 2024 21:56:39 +0100 Subject: [PATCH 53/85] Avoid Jane-php deprecations. --- src/Docker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Docker.php b/src/Docker.php index 94ff82e52..6e98c7e2f 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -5,10 +5,10 @@ namespace Docker; use Docker\API\Client; +use Docker\API\Endpoint\SystemInfo; use Docker\API\Exception\BadRequestException; use Docker\API\Model\AuthConfig; use Docker\API\Model\ExecIdStartPostBody; -use Docker\API\Runtime\Client\Client as RuntimeClient; use Docker\Endpoint\ContainerAttach; use Docker\Endpoint\ContainerAttachWebsocket; use Docker\Endpoint\ContainerLogs; @@ -94,7 +94,7 @@ public static function create($httpClient = null, array $additionalPlugins = [], } $client = parent::create($httpClient, $additionalPlugins, $additionalNormalizers); - $testClient = $client->systemInfo(RuntimeClient::FETCH_RESPONSE)->getBody()->getContents(); + $testClient = $client->executeRawEndpoint(new SystemInfo())->getBody()->getContents(); $jsonObj = json_decode($testClient); if ($jsonObj !== null) { From 89cfedcd40218310fe83a1bc8a238ff2aa022ed3 Mon Sep 17 00:00:00 2001 From: Rodrigo Aguilera Date: Sun, 18 Feb 2024 19:48:30 +0100 Subject: [PATCH 54/85] Fix/Skip tests and add php 8.2 and 8.3. --- .github/workflows/continuous-integration.yml | 6 ++---- composer.json | 5 ++++- src/Context/ContextBuilder.php | 2 +- src/Docker.php | 2 +- src/Stream/EventStream.php | 2 +- tests/Resource/ContainerResourceTest.php | 2 ++ tests/Resource/SystemResourceTest.php | 4 ++-- 7 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 68e9a8d8f..d3a243052 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -22,6 +22,8 @@ jobs: matrix: php-version: - "8.1" + - "8.2" + - "8.3" dependency-version: [prefer-lowest, prefer-stable] experimental: [false] @@ -49,10 +51,6 @@ jobs: key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}- - - name: Install dependencies (PHP 7) - if: steps.composer-cache.outputs.cache-hit != 'true' && matrix.php-version < 8 - run: composer update --${{ matrix.dependency-version }} --no-progress --no-interaction - - name: Install dependencies (PHP 8) if: steps.composer-cache.outputs.cache-hit != 'true' && matrix.php-version >= 8 run: composer update --${{ matrix.dependency-version }} --ignore-platform-req=php --no-progress --no-interaction diff --git a/composer.json b/composer.json index 5edebfe55..15a9edf5d 100644 --- a/composer.json +++ b/composer.json @@ -44,12 +44,14 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^3.8", "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9.5", "psy/psysh": "^0.11", "roave/security-advisories": "dev-latest" }, "conflict": { - "docker-php/docker-php": "*" + "docker-php/docker-php": "*", + "php-http/message": "<1.15" }, "scripts": { "php-cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", @@ -57,6 +59,7 @@ "console": "vendor/bin/psysh", "lint": "vendor/bin/parallel-lint --exclude vendor .", "phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation", + "phpstan": "vendor/bin/phpstan analyse --level 2 src", "test-ci": "vendor/bin/phpunit ./tests/ --disallow-test-output --process-isolation", "test-coverage": "vendor/bin/phpunit ./tests/ --whitelist=./src/ --coverage-clover=clover.xml", "test": [ diff --git a/src/Context/ContextBuilder.php b/src/Context/ContextBuilder.php index 5e0aa37bc..6d41d4062 100644 --- a/src/Context/ContextBuilder.php +++ b/src/Context/ContextBuilder.php @@ -39,7 +39,7 @@ class ContextBuilder private $entrypoint; /** - * @param \Symfony\Component\Filesystem\Filesystem + * @param $fs \Symfony\Component\Filesystem\Filesystem */ public function __construct(Filesystem $fs = null) { diff --git a/src/Docker.php b/src/Docker.php index 6e98c7e2f..951a8cd7e 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -87,7 +87,7 @@ public function systemEvents(array $queryParameters = [], string $fetch = self:: return $this->executeEndpoint(new SystemEvents($queryParameters), $fetch); } - public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) + public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) : self { if (null === $httpClient) { $httpClient = DockerClientFactory::createFromEnv(); diff --git a/src/Stream/EventStream.php b/src/Stream/EventStream.php index 90dcf23ed..1c18a8050 100644 --- a/src/Stream/EventStream.php +++ b/src/Stream/EventStream.php @@ -16,6 +16,6 @@ class EventStream extends MultiJsonStream */ protected function getDecodeClass() { - return 'EventsGetResponse200'; + return 'EventMessage'; } } diff --git a/tests/Resource/ContainerResourceTest.php b/tests/Resource/ContainerResourceTest.php index 3ebb77588..eac8e470d 100644 --- a/tests/Resource/ContainerResourceTest.php +++ b/tests/Resource/ContainerResourceTest.php @@ -61,6 +61,7 @@ public function testAttach(): void public function testAttachWebsocket(): void { + $this->markTestSkipped('Since docker API 1.28 Websockets are binary so this test needs work. See https://github.com/xtermjs/xterm.js/issues/883'); $containerConfig = new ContainersCreatePostBody(); $containerConfig->setImage('busybox:latest'); $containerConfig->setCmd(['sh']); @@ -108,6 +109,7 @@ public function testAttachWebsocket(): void public function testLogs(): void { + $this->markTestSkipped('Since at least 1.43 docker API does not return a `application/vnd.docker.raw-stream` but a `application/vnd.docker.multiplexed-stream` so this needs review. See https://github.com/beluga-php/docker-php/issues/19'); $containerConfig = new ContainersCreatePostBody(); $containerConfig->setImage('busybox:latest'); $containerConfig->setCmd(['echo', '-n', 'output']); diff --git a/tests/Resource/SystemResourceTest.php b/tests/Resource/SystemResourceTest.php index b88c4069f..fb1badf30 100644 --- a/tests/Resource/SystemResourceTest.php +++ b/tests/Resource/SystemResourceTest.php @@ -4,7 +4,7 @@ namespace Docker\Tests\Resource; -use Docker\API\Model\EventsGetResponse200; +use Docker\API\Model\EventMessage; use Docker\Tests\TestCase; class SystemResourceTest extends TestCase @@ -36,6 +36,6 @@ public function testGetEvents(): void $stream->wait(); - $this->assertInstanceOf(EventsGetResponse200::class, $lastEvent); + $this->assertInstanceOf(EventMessage::class, $lastEvent); } } From 66e039dba156a02683f60f525fd24ad3617156fd Mon Sep 17 00:00:00 2001 From: Rodrigo Aguilera Date: Sun, 18 Feb 2024 20:10:02 +0100 Subject: [PATCH 55/85] Pull image prior to the tests. --- .github/workflows/continuous-integration.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index d3a243052..0a005cfab 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -55,6 +55,9 @@ jobs: if: steps.composer-cache.outputs.cache-hit != 'true' && matrix.php-version >= 8 run: composer update --${{ matrix.dependency-version }} --ignore-platform-req=php --no-progress --no-interaction + - name: Pull the docker image used by the tests. + run: docker pull busybox:latest + - name: Run PHPUnit test suite run: composer run-script test-ci From 53405bdea39d9ea9ccbdfff6ed53e7d2d549ea7e Mon Sep 17 00:00:00 2001 From: Rodrigo Aguilera Date: Sun, 18 Feb 2024 20:20:51 +0100 Subject: [PATCH 56/85] Skip publish code coverage on PRs. --- .github/workflows/continuous-integration.yml | 1 + src/Docker.php | 6 +++++- tests/Resource/ContainerResourceTest.php | 7 +++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 0a005cfab..e1e32d540 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -69,3 +69,4 @@ jobs: coverageCommand: composer run-script test-coverage coverageLocations: | ${{github.workspace}}/clover.xml:clover + if: github.event_name != 'pull_request' diff --git a/src/Docker.php b/src/Docker.php index 951a8cd7e..b56b2b664 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -87,7 +87,11 @@ public function systemEvents(array $queryParameters = [], string $fetch = self:: return $this->executeEndpoint(new SystemEvents($queryParameters), $fetch); } - public static function create($httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = []) : self + public static function create( + $httpClient = null, + array $additionalPlugins = [], + array $additionalNormalizers = [] + ) : self { if (null === $httpClient) { $httpClient = DockerClientFactory::createFromEnv(); diff --git a/tests/Resource/ContainerResourceTest.php b/tests/Resource/ContainerResourceTest.php index eac8e470d..eb6024a18 100644 --- a/tests/Resource/ContainerResourceTest.php +++ b/tests/Resource/ContainerResourceTest.php @@ -61,7 +61,8 @@ public function testAttach(): void public function testAttachWebsocket(): void { - $this->markTestSkipped('Since docker API 1.28 Websockets are binary so this test needs work. See https://github.com/xtermjs/xterm.js/issues/883'); + $this->markTestSkipped('Since docker API 1.28 Websockets are binary so this test needs work. ' . + 'See https://github.com/xtermjs/xterm.js/issues/883'); $containerConfig = new ContainersCreatePostBody(); $containerConfig->setImage('busybox:latest'); $containerConfig->setCmd(['sh']); @@ -109,7 +110,9 @@ public function testAttachWebsocket(): void public function testLogs(): void { - $this->markTestSkipped('Since at least 1.43 docker API does not return a `application/vnd.docker.raw-stream` but a `application/vnd.docker.multiplexed-stream` so this needs review. See https://github.com/beluga-php/docker-php/issues/19'); + $this->markTestSkipped('Since at least 1.43 docker API does not return a `application/vnd.docker.raw-stream` ' . + 'but a `application/vnd.docker.multiplexed-stream` so this needs review. '. + 'See https://github.com/beluga-php/docker-php/issues/19'); $containerConfig = new ContainersCreatePostBody(); $containerConfig->setImage('busybox:latest'); $containerConfig->setCmd(['echo', '-n', 'output']); From b8c2fedceb90c6c67614d3801d0f6e8ea70efc0f Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Mon, 19 Feb 2024 13:51:48 +0100 Subject: [PATCH 57/85] remove leading space around return type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Flávio Heleno --- src/Docker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Docker.php b/src/Docker.php index b56b2b664..b63c99cdb 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -91,7 +91,7 @@ public static function create( $httpClient = null, array $additionalPlugins = [], array $additionalNormalizers = [] - ) : self + ): self { if (null === $httpClient) { $httpClient = DockerClientFactory::createFromEnv(); From 82e23dc6cde8f2035f4365141ad60b2a98a48005 Mon Sep 17 00:00:00 2001 From: Rodrigo Date: Mon, 19 Feb 2024 13:52:19 +0100 Subject: [PATCH 58/85] Fix param definition in context builder. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Flávio Heleno --- src/Context/ContextBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Context/ContextBuilder.php b/src/Context/ContextBuilder.php index 6d41d4062..0464b15a0 100644 --- a/src/Context/ContextBuilder.php +++ b/src/Context/ContextBuilder.php @@ -39,7 +39,7 @@ class ContextBuilder private $entrypoint; /** - * @param $fs \Symfony\Component\Filesystem\Filesystem + * @param \Symfony\Component\Filesystem\Filesystem $fs */ public function __construct(Filesystem $fs = null) { From e2d4ec378fe0ddd422477163808750b72dc38704 Mon Sep 17 00:00:00 2001 From: Rodrigo Aguilera Date: Tue, 20 Feb 2024 20:02:48 +0100 Subject: [PATCH 59/85] Add conflict with non-compatible versions of nikic/php-parser. Bump psy/psysh to allow for nikic/php-parser v5. --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 15a9edf5d..2431073e8 100644 --- a/composer.json +++ b/composer.json @@ -46,12 +46,13 @@ "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/phpstan": "^1.10", "phpunit/phpunit": "^9.5", - "psy/psysh": "^0.11", + "psy/psysh": "^0.12", "roave/security-advisories": "dev-latest" }, "conflict": { "docker-php/docker-php": "*", - "php-http/message": "<1.15" + "php-http/message": "<1.15", + "nikic/php-parser": "<4.13" }, "scripts": { "php-cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", From 155dcedaac736323b07346295956aef324dcd1b9 Mon Sep 17 00:00:00 2001 From: Lau Ernebjerg Josefsen <44977457+LauJosefsen@users.noreply.github.com> Date: Fri, 15 Mar 2024 15:40:28 +0100 Subject: [PATCH 60/85] Update symfony packages to ^7.0 (#69) --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 2431073e8..c090bd792 100644 --- a/composer.json +++ b/composer.json @@ -37,9 +37,9 @@ "php-http/discovery": "^1.19", "plesk/socket-client": "^2.1", "psr/http-message": "^2.0", - "symfony/filesystem": "^6.3", - "symfony/process": "^6.3", - "symfony/serializer": "^6.3" + "symfony/filesystem": "^7.0|^6.3", + "symfony/process": "^7.0|^6.3", + "symfony/serializer": "^7.0|^6.3" }, "require-dev": { "friendsofphp/php-cs-fixer": "^3.8", From 296d770630bc7e98272059d821e207dbb2caf48a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: Tue, 9 Apr 2024 10:27:51 -0300 Subject: [PATCH 61/85] Add PHP nightly build to test matrix --- .github/workflows/continuous-integration.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index e1e32d540..e5ca65d13 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -21,11 +21,18 @@ jobs: fail-fast: false matrix: php-version: - - "8.1" - - "8.2" - - "8.3" + - '8.1' + - '8.2' + - '8.3' dependency-version: [prefer-lowest, prefer-stable] experimental: [false] + include: + - php-version: '8.4' + dependency-version: prefer-lowest + experimental: true + - php-version: '8.4' + dependency-version: prefer-stable + experimental: true steps: - uses: actions/checkout@v3 @@ -48,8 +55,8 @@ jobs: uses: actions/cache@v3 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}- + key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ matrix.prefer }}-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ matrix.prefer }} - name: Install dependencies (PHP 8) if: steps.composer-cache.outputs.cache-hit != 'true' && matrix.php-version >= 8 From c9c540281fe620a35e729aa7fb2548aae346e578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: Tue, 9 Apr 2024 10:19:28 -0300 Subject: [PATCH 62/85] Update continuous-integration.yml --- .github/workflows/continuous-integration.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index e5ca65d13..4d2df5062 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -35,10 +35,10 @@ jobs: experimental: true steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.25.4 + uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d # v2.29.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 @@ -52,7 +52,7 @@ jobs: run: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache Composer packages - uses: actions/cache@v3 + uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ matrix.prefer }}-${{ hashFiles('**/composer.json') }} @@ -69,7 +69,7 @@ jobs: run: composer run-script test-ci - name: Publish code coverage - uses: paambaati/codeclimate-action@v3.2.0 + uses: paambaati/codeclimate-action@a1831d7162ea1fbc612ffe5fb3b90278b7999d59 # v5.0.0 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: From 96a1e0fac19ed80cda302926877ebba5a0f36c41 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 23 Apr 2024 09:18:04 -0300 Subject: [PATCH 63/85] Add ergebnis/composer-normalize as dev dependency --- composer.json | 84 ++++++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/composer.json b/composer.json index c090bd792..f59275a16 100644 --- a/composer.json +++ b/composer.json @@ -1,28 +1,8 @@ { "name": "beluga-php/docker-php", + "description": "A Docker PHP client", "license": "MIT", "type": "library", - "description": "A Docker PHP client", - "config": { - "optimize-autoloader": true, - "sort-packages": true, - "preferred-install": "dist", - "allow-plugins": { - "php-http/discovery": false - } - }, - "minimum-stability": "dev", - "prefer-stable": true, - "autoload": { - "psr-4": { - "Docker\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Docker\\Tests\\": "tests/" - } - }, "funding": [ { "type": "github", @@ -37,11 +17,12 @@ "php-http/discovery": "^1.19", "plesk/socket-client": "^2.1", "psr/http-message": "^2.0", - "symfony/filesystem": "^7.0|^6.3", - "symfony/process": "^7.0|^6.3", - "symfony/serializer": "^7.0|^6.3" + "symfony/filesystem": "^6.3 || ^7.0", + "symfony/process": "^6.3 || ^7.0", + "symfony/serializer": "^6.3 || ^7.0" }, "require-dev": { + "ergebnis/composer-normalize": "^2.42", "friendsofphp/php-cs-fixer": "^3.8", "php-parallel-lint/php-parallel-lint": "^1.2", "phpstan/phpstan": "^1.10", @@ -51,36 +32,57 @@ }, "conflict": { "docker-php/docker-php": "*", - "php-http/message": "<1.15", - "nikic/php-parser": "<4.13" + "nikic/php-parser": "<4.13", + "php-http/message": "<1.15" + }, + "minimum-stability": "dev", + "prefer-stable": true, + "autoload": { + "psr-4": { + "Docker\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Docker\\Tests\\": "tests/" + } + }, + "config": { + "allow-plugins": { + "ergebnis/composer-normalize": true, + "php-http/discovery": false + }, + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true + }, + "extra": { + "branch-alias": { + "1.41": "1.41.x-dev", + "1.42": "1.42.x-dev", + "dev-master": "1.43.x-dev" + } }, "scripts": { - "php-cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", - "php-cs-fixer-fix": "vendor/bin/php-cs-fixer fix --verbose", "console": "vendor/bin/psysh", "lint": "vendor/bin/parallel-lint --exclude vendor .", - "phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation", + "php-cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", + "php-cs-fixer-fix": "vendor/bin/php-cs-fixer fix --verbose", "phpstan": "vendor/bin/phpstan analyse --level 2 src", - "test-ci": "vendor/bin/phpunit ./tests/ --disallow-test-output --process-isolation", - "test-coverage": "vendor/bin/phpunit ./tests/ --whitelist=./src/ --coverage-clover=clover.xml", + "phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation", "test": [ "@lint", "@phpunit" - ] + ], + "test-ci": "vendor/bin/phpunit ./tests/ --disallow-test-output --process-isolation", + "test-coverage": "vendor/bin/phpunit ./tests/ --whitelist=./src/ --coverage-clover=clover.xml" }, "scripts-descriptions": { "console": "Runs PsySH Console", "lint": "Runs complete codebase lint testing", "phpunit": "Runs library test suite", + "test": "Runs all tests", "test-ci": "Runs library test suite (for continuous integration)", - "test-coverage": "Runs test-coverage analysis", - "test": "Runs all tests" - }, - "extra": { - "branch-alias": { - "dev-master": "1.43.x-dev", - "1.42": "1.42.x-dev", - "1.41": "1.41.x-dev" - } + "test-coverage": "Runs test-coverage analysis" } } From 9cb649532b817247fe063fdf536e3b98d0ab3579 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 23 Apr 2024 09:34:57 -0300 Subject: [PATCH 64/85] Update static analysis workflow dependencies --- .github/workflows/static-analysis.yml | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index e6477607e..54b024140 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -17,32 +17,23 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - name: Repository checkout + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@2.25.4 + uses: shivammathur/setup-php@efffd0e4f2504f936fcfe3b69293d31ce0e2fd7a # v2.30.3 with: - php-version: 8.0 + php-version: 8.1 tools: composer:v2 coverage: none - name: Validate composer.json and composer.lock - run: composer validate - - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache Composer packages - uses: actions/cache@v3 - with: - path: ${{ steps.composer-cache.outputs.dir }} - key: phpstan-linux-php-8.0-${{ hashFiles('**/composer.lock') }} - restore-keys: phpstan-linux-php-8.0- + run: composer validate --strict - name: Install dependencies - if: steps.composer-cache.outputs.cache-hit != 'true' - run: composer update --prefer-stable --ignore-platform-req=php --no-progress --no-interaction + uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # v3.0.0 + with: + dependency-versions: lowest - name: Run PHPStan run: composer run-script phpstan -- --no-progress From 775faf4dcc4e34aa70ac6200a7c06816af7ef984 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Tue, 23 Apr 2024 09:44:48 -0300 Subject: [PATCH 65/85] Update continuous integration workflow dependencies --- .github/workflows/continuous-integration.yml | 32 ++++++++------------ 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 4d2df5062..16a20180c 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -24,43 +24,37 @@ jobs: - '8.1' - '8.2' - '8.3' - dependency-version: [prefer-lowest, prefer-stable] + dependency-versions: [lowest, highest] experimental: [false] include: - php-version: '8.4' - dependency-version: prefer-lowest + dependency-versions: lowest experimental: true + composer-options: --ignore-platform-reqs - php-version: '8.4' - dependency-version: prefer-stable + dependency-versions: highest experimental: true + composer-options: --ignore-platform-reqs steps: - - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + - name: Repository checkout + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@6d7209f44a25a59e904b1ee9f3b0c33ab2cd888d # v2.29.0 + uses: shivammathur/setup-php@efffd0e4f2504f936fcfe3b69293d31ce0e2fd7a # v2.30.3 with: php-version: ${{ matrix.php-version }} tools: composer:v2 coverage: pcov - name: Validate composer.json and composer.lock - run: composer validate + run: composer validate --strict - - name: Get composer cache directory - id: composer-cache - run: echo "::set-output name=dir::$(composer config cache-files-dir)" - - - name: Cache Composer packages - uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4.0.2 + - name: Install dependencies + uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # v3.0.0 with: - path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ matrix.prefer }}-${{ hashFiles('**/composer.json') }} - restore-keys: ${{ runner.os }}-php-${{ matrix.php-version }}-composer-${{ matrix.prefer }} - - - name: Install dependencies (PHP 8) - if: steps.composer-cache.outputs.cache-hit != 'true' && matrix.php-version >= 8 - run: composer update --${{ matrix.dependency-version }} --ignore-platform-req=php --no-progress --no-interaction + dependency-versions: ${{ matrix.dependency-versions }} + composer-options: ${{ matrix.composer-options }} - name: Pull the docker image used by the tests. run: docker pull busybox:latest From 442c689bd9edc78d337f235d544220e33557cb5a Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Mon, 12 Aug 2024 11:20:08 -0300 Subject: [PATCH 66/85] Prepare for 1.44.0 --- composer.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index f59275a16..5e94fc129 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": ">=8.1", - "beluga-php/docker-php-api": "7.1.43.0", + "beluga-php/docker-php-api": "7.1.44.0", "nyholm/psr7": "^1.8", "php-http/client-common": "^2.7", "php-http/discovery": "^1.19", @@ -60,7 +60,9 @@ "branch-alias": { "1.41": "1.41.x-dev", "1.42": "1.42.x-dev", - "dev-master": "1.43.x-dev" + "1.43": "1.43.x-dev", + "1.44": "1.44.x-dev", + "dev-master": "1.45.x-dev" } }, "scripts": { From d9c177140cb5ef068646b51ea097c941bdb7b877 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Mon, 12 Aug 2024 11:22:48 -0300 Subject: [PATCH 67/85] Prepare for v1.45.0 --- composer.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 5e94fc129..231e4a769 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": ">=8.1", - "beluga-php/docker-php-api": "7.1.44.0", + "beluga-php/docker-php-api": "7.1.45.0", "nyholm/psr7": "^1.8", "php-http/client-common": "^2.7", "php-http/discovery": "^1.19", @@ -62,7 +62,8 @@ "1.42": "1.42.x-dev", "1.43": "1.43.x-dev", "1.44": "1.44.x-dev", - "dev-master": "1.45.x-dev" + "1.45": "1.45.x-dev" + "dev-master": "1.46.x-dev" } }, "scripts": { From 8fbdc317ea34f495ec39ad9612c6d901edc06197 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Mon, 12 Aug 2024 11:32:11 -0300 Subject: [PATCH 68/85] Relax beluga-php/docker-php-api constraint --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 231e4a769..de0d725f9 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": ">=8.1", - "beluga-php/docker-php-api": "7.1.45.0", + "beluga-php/docker-php-api": "7.1.45.*", "nyholm/psr7": "^1.8", "php-http/client-common": "^2.7", "php-http/discovery": "^1.19", From 393323a9c0a05e36a172bae0aee282c8518c84f5 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Mon, 12 Aug 2024 11:41:14 -0300 Subject: [PATCH 69/85] Fix composer.json syntax --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index de0d725f9..9e95bdade 100644 --- a/composer.json +++ b/composer.json @@ -62,7 +62,7 @@ "1.42": "1.42.x-dev", "1.43": "1.43.x-dev", "1.44": "1.44.x-dev", - "1.45": "1.45.x-dev" + "1.45": "1.45.x-dev", "dev-master": "1.46.x-dev" } }, From 524a3058efa125cee1c84bb9b3e959f293f567e7 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Fri, 28 Feb 2025 08:31:39 -0300 Subject: [PATCH 70/85] Switch back to php-http/socket-client --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9e95bdade..2e80e384c 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,7 @@ "nyholm/psr7": "^1.8", "php-http/client-common": "^2.7", "php-http/discovery": "^1.19", - "plesk/socket-client": "^2.1", + "php-http/socket-client": "^2.1", "psr/http-message": "^2.0", "symfony/filesystem": "^6.3 || ^7.0", "symfony/process": "^6.3 || ^7.0", From 632e2b5617e2fdf5bec65ee7b792f3bbccbf19f8 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Sun, 25 May 2025 11:28:18 +0200 Subject: [PATCH 71/85] feat: php 8.4 support --- .github/workflows/continuous-integration.yml | 80 +++++++++----------- src/Context/Context.php | 2 +- src/Context/ContextBuilder.php | 2 +- src/Docker.php | 2 +- src/DockerClientFactory.php | 4 +- src/Endpoint/ContainerAttach.php | 2 +- src/Endpoint/ExecStart.php | 2 +- src/Endpoint/ImageBuild.php | 2 +- src/Endpoint/ImageCreate.php | 2 +- src/Endpoint/ImagePush.php | 2 +- src/Endpoint/SystemEvents.php | 2 +- 11 files changed, 47 insertions(+), 55 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 16a20180c..794e609bd 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -3,12 +3,12 @@ name: "Continuous Integration" on: push: paths-ignore: - - 'doc/**' - - '.github/**' + - "doc/**" + - ".github/**" pull_request: paths-ignore: - - 'doc/**' - - '.github/**' + - "doc/**" + - ".github/**" jobs: phpunit: @@ -21,53 +21,45 @@ jobs: fail-fast: false matrix: php-version: - - '8.1' - - '8.2' - - '8.3' + - "8.1" + - "8.2" + - "8.3" + - "8.4" dependency-versions: [lowest, highest] experimental: [false] - include: - - php-version: '8.4' - dependency-versions: lowest - experimental: true - composer-options: --ignore-platform-reqs - - php-version: '8.4' - dependency-versions: highest - experimental: true - composer-options: --ignore-platform-reqs steps: - - name: Repository checkout - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 + - name: Repository checkout + uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 - - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@efffd0e4f2504f936fcfe3b69293d31ce0e2fd7a # v2.30.3 - with: - php-version: ${{ matrix.php-version }} - tools: composer:v2 - coverage: pcov + - name: Setup PHP with PECL extension + uses: shivammathur/setup-php@efffd0e4f2504f936fcfe3b69293d31ce0e2fd7a # v2.30.3 + with: + php-version: ${{ matrix.php-version }} + tools: composer:v2 + coverage: pcov - - name: Validate composer.json and composer.lock - run: composer validate --strict + - name: Validate composer.json and composer.lock + run: composer validate --strict - - name: Install dependencies - uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # v3.0.0 - with: - dependency-versions: ${{ matrix.dependency-versions }} - composer-options: ${{ matrix.composer-options }} + - name: Install dependencies + uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # v3.0.0 + with: + dependency-versions: ${{ matrix.dependency-versions }} + composer-options: ${{ matrix.composer-options }} - - name: Pull the docker image used by the tests. - run: docker pull busybox:latest + - name: Pull the docker image used by the tests. + run: docker pull busybox:latest - - name: Run PHPUnit test suite - run: composer run-script test-ci + - name: Run PHPUnit test suite + run: composer run-script test-ci - - name: Publish code coverage - uses: paambaati/codeclimate-action@a1831d7162ea1fbc612ffe5fb3b90278b7999d59 # v5.0.0 - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - with: - coverageCommand: composer run-script test-coverage - coverageLocations: | - ${{github.workspace}}/clover.xml:clover - if: github.event_name != 'pull_request' + - name: Publish code coverage + uses: paambaati/codeclimate-action@a1831d7162ea1fbc612ffe5fb3b90278b7999d59 # v5.0.0 + env: + CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} + with: + coverageCommand: composer run-script test-coverage + coverageLocations: | + ${{github.workspace}}/clover.xml:clover + if: github.event_name != 'pull_request' diff --git a/src/Context/Context.php b/src/Context/Context.php index 1cc9b1ec9..320f131f4 100644 --- a/src/Context/Context.php +++ b/src/Context/Context.php @@ -52,7 +52,7 @@ class Context implements ContextInterface * @param string $format Format to use when sending the call (stream or tar: string) * @param Filesystem $fs filesystem object for cleaning the context directory on destruction */ - public function __construct($directory, $format = self::FORMAT_STREAM, Filesystem $fs = null) + public function __construct($directory, $format = self::FORMAT_STREAM, ?Filesystem $fs = null) { $this->directory = $directory; $this->format = $format; diff --git a/src/Context/ContextBuilder.php b/src/Context/ContextBuilder.php index 0464b15a0..cda9629f5 100644 --- a/src/Context/ContextBuilder.php +++ b/src/Context/ContextBuilder.php @@ -41,7 +41,7 @@ class ContextBuilder /** * @param \Symfony\Component\Filesystem\Filesystem $fs */ - public function __construct(Filesystem $fs = null) + public function __construct(?Filesystem $fs = null) { $this->fs = $fs ?: new Filesystem(); $this->format = Context::FORMAT_STREAM; diff --git a/src/Docker.php b/src/Docker.php index b63c99cdb..9333e7e3c 100644 --- a/src/Docker.php +++ b/src/Docker.php @@ -66,7 +66,7 @@ public function imageBuild($requestBody = null, array $queryParameters = [], arr /** * {@inheritdoc} */ - public function imageCreate(string $requestBody = null, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) + public function imageCreate(?string $requestBody = null, array $queryParameters = [], array $headerParameters = [], string $fetch = self::FETCH_OBJECT) { return $this->executeEndpoint(new ImageCreate($requestBody, $queryParameters, $headerParameters), $fetch); } diff --git a/src/DockerClientFactory.php b/src/DockerClientFactory.php index 74a43dd8b..0b6fbfb82 100644 --- a/src/DockerClientFactory.php +++ b/src/DockerClientFactory.php @@ -16,7 +16,7 @@ final class DockerClientFactory { - public static function create(array $config = [], PluginClientFactory $pluginClientFactory = null): PluginClient + public static function create(array $config = [], ?PluginClientFactory $pluginClientFactory = null): PluginClient { if (!\array_key_exists('remote_socket', $config)) { $config['remote_socket'] = 'unix:///var/run/docker.sock'; @@ -46,7 +46,7 @@ public static function create(array $config = [], PluginClientFactory $pluginCli ); } - public static function createFromEnv(PluginClientFactory $pluginClientFactory = null): PluginClient + public static function createFromEnv(?PluginClientFactory $pluginClientFactory = null): PluginClient { $options = [ 'remote_socket' => getenv('DOCKER_HOST') ? getenv('DOCKER_HOST') : 'unix:///var/run/docker.sock', diff --git a/src/Endpoint/ContainerAttach.php b/src/Endpoint/ContainerAttach.php index 571ec2252..1c776639e 100644 --- a/src/Endpoint/ContainerAttach.php +++ b/src/Endpoint/ContainerAttach.php @@ -11,7 +11,7 @@ class ContainerAttach extends BaseEndpoint { - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $contentType) { return new DockerRawStream($response->getBody()); diff --git a/src/Endpoint/ExecStart.php b/src/Endpoint/ExecStart.php index 844a49066..e2d8985be 100644 --- a/src/Endpoint/ExecStart.php +++ b/src/Endpoint/ExecStart.php @@ -11,7 +11,7 @@ class ExecStart extends BaseEndpoint { - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $contentType) { return new DockerRawStream($response->getBody()); diff --git a/src/Endpoint/ImageBuild.php b/src/Endpoint/ImageBuild.php index c0ceb6459..49239c4cf 100644 --- a/src/Endpoint/ImageBuild.php +++ b/src/Endpoint/ImageBuild.php @@ -24,7 +24,7 @@ public function getBody(SerializerInterface $serializer, $streamFactory = null): return [['Content-Type' => ['application/octet-stream']], $body]; } - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { if (200 === $response->getStatusCode()) { return new BuildStream($response->getBody(), $serializer); diff --git a/src/Endpoint/ImageCreate.php b/src/Endpoint/ImageCreate.php index 3ea1aad04..3a50da2e9 100644 --- a/src/Endpoint/ImageCreate.php +++ b/src/Endpoint/ImageCreate.php @@ -11,7 +11,7 @@ class ImageCreate extends BaseEndpoint { - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { if (200 === $response->getStatusCode()) { return new CreateImageStream($response->getBody(), $serializer); diff --git a/src/Endpoint/ImagePush.php b/src/Endpoint/ImagePush.php index 64ea660b3..61e165915 100644 --- a/src/Endpoint/ImagePush.php +++ b/src/Endpoint/ImagePush.php @@ -16,7 +16,7 @@ public function getUri(): string return str_replace(['{name}'], [urlencode($this->name)], '/images/{name}/push'); } - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { if (200 === $response->getStatusCode()) { return new PushStream($response->getBody(), $serializer); diff --git a/src/Endpoint/SystemEvents.php b/src/Endpoint/SystemEvents.php index 339a60625..3f57e916c 100644 --- a/src/Endpoint/SystemEvents.php +++ b/src/Endpoint/SystemEvents.php @@ -11,7 +11,7 @@ class SystemEvents extends BaseEndpoint { - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { if (200 === $response->getStatusCode()) { return new EventStream($response->getBody(), $serializer); From a2707610dbb5d41d0dfd963bd560e6fa40529ba5 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Sun, 25 May 2025 11:39:39 +0200 Subject: [PATCH 72/85] fix: update to phpunit 10, to fix pipeline issues --- .gitignore | 1 + composer.json | 174 +++++++++++++-------------- tests/Stream/MultiJsonStreamTest.php | 11 +- 3 files changed, 97 insertions(+), 89 deletions(-) diff --git a/.gitignore b/.gitignore index 64afb0b51..8d49b5514 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ bin/ composer.lock .vagrant /.php-cs-fixer.cache +/.phpunit.result.cache diff --git a/composer.json b/composer.json index 2e80e384c..276633f7f 100644 --- a/composer.json +++ b/composer.json @@ -1,91 +1,91 @@ { - "name": "beluga-php/docker-php", - "description": "A Docker PHP client", - "license": "MIT", - "type": "library", - "funding": [ - { - "type": "github", - "url": "https://github.com/flavioheleno" - } - ], - "require": { - "php": ">=8.1", - "beluga-php/docker-php-api": "7.1.45.*", - "nyholm/psr7": "^1.8", - "php-http/client-common": "^2.7", - "php-http/discovery": "^1.19", - "php-http/socket-client": "^2.1", - "psr/http-message": "^2.0", - "symfony/filesystem": "^6.3 || ^7.0", - "symfony/process": "^6.3 || ^7.0", - "symfony/serializer": "^6.3 || ^7.0" - }, - "require-dev": { - "ergebnis/composer-normalize": "^2.42", - "friendsofphp/php-cs-fixer": "^3.8", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^9.5", - "psy/psysh": "^0.12", - "roave/security-advisories": "dev-latest" - }, - "conflict": { - "docker-php/docker-php": "*", - "nikic/php-parser": "<4.13", - "php-http/message": "<1.15" - }, - "minimum-stability": "dev", - "prefer-stable": true, - "autoload": { - "psr-4": { - "Docker\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Docker\\Tests\\": "tests/" - } - }, - "config": { - "allow-plugins": { - "ergebnis/composer-normalize": true, - "php-http/discovery": false - }, - "optimize-autoloader": true, - "preferred-install": "dist", - "sort-packages": true - }, - "extra": { - "branch-alias": { - "1.41": "1.41.x-dev", - "1.42": "1.42.x-dev", - "1.43": "1.43.x-dev", - "1.44": "1.44.x-dev", - "1.45": "1.45.x-dev", - "dev-master": "1.46.x-dev" - } - }, - "scripts": { - "console": "vendor/bin/psysh", - "lint": "vendor/bin/parallel-lint --exclude vendor .", - "php-cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", - "php-cs-fixer-fix": "vendor/bin/php-cs-fixer fix --verbose", - "phpstan": "vendor/bin/phpstan analyse --level 2 src", - "phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation", - "test": [ - "@lint", - "@phpunit" - ], - "test-ci": "vendor/bin/phpunit ./tests/ --disallow-test-output --process-isolation", - "test-coverage": "vendor/bin/phpunit ./tests/ --whitelist=./src/ --coverage-clover=clover.xml" + "name": "beluga-php/docker-php", + "description": "A Docker PHP client", + "license": "MIT", + "type": "library", + "funding": [ + { + "type": "github", + "url": "https://github.com/flavioheleno" + } + ], + "require": { + "php": ">=8.1", + "beluga-php/docker-php-api": "7.1.45.*", + "nyholm/psr7": "^1.8", + "php-http/client-common": "^2.7", + "php-http/discovery": "^1.19", + "php-http/socket-client": "^2.3", + "psr/http-message": "^2.0", + "symfony/filesystem": "^6.3 || ^7.0", + "symfony/process": "^6.3 || ^7.0", + "symfony/serializer": "^6.3 || ^7.0" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.42", + "friendsofphp/php-cs-fixer": "^3.8", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.5.46", + "psy/psysh": "^0.12.8", + "roave/security-advisories": "dev-latest" + }, + "conflict": { + "docker-php/docker-php": "*", + "nikic/php-parser": "<4.13", + "php-http/message": "<1.15" + }, + "minimum-stability": "dev", + "prefer-stable": true, + "autoload": { + "psr-4": { + "Docker\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Docker\\Tests\\": "tests/" + } + }, + "config": { + "allow-plugins": { + "ergebnis/composer-normalize": true, + "php-http/discovery": false }, - "scripts-descriptions": { - "console": "Runs PsySH Console", - "lint": "Runs complete codebase lint testing", - "phpunit": "Runs library test suite", - "test": "Runs all tests", - "test-ci": "Runs library test suite (for continuous integration)", - "test-coverage": "Runs test-coverage analysis" + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true + }, + "extra": { + "branch-alias": { + "1.41": "1.41.x-dev", + "1.42": "1.42.x-dev", + "1.43": "1.43.x-dev", + "1.44": "1.44.x-dev", + "1.45": "1.45.x-dev", + "dev-master": "1.46.x-dev" } + }, + "scripts": { + "console": "vendor/bin/psysh", + "lint": "vendor/bin/parallel-lint --exclude vendor .", + "php-cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", + "php-cs-fixer-fix": "vendor/bin/php-cs-fixer fix --verbose", + "phpstan": "vendor/bin/phpstan analyse --level 2 src", + "phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation", + "test": [ + "@lint", + "@phpunit" + ], + "test-ci": "vendor/bin/phpunit ./tests/ --disallow-test-output --process-isolation", + "test-coverage": "vendor/bin/phpunit ./tests/ --whitelist=./src/ --coverage-clover=clover.xml" + }, + "scripts-descriptions": { + "console": "Runs PsySH Console", + "lint": "Runs complete codebase lint testing", + "phpunit": "Runs library test suite", + "test": "Runs all tests", + "test-ci": "Runs library test suite (for continuous integration)", + "test-coverage": "Runs test-coverage analysis" + } } diff --git a/tests/Stream/MultiJsonStreamTest.php b/tests/Stream/MultiJsonStreamTest.php index 29d65739a..6d4a46acf 100644 --- a/tests/Stream/MultiJsonStreamTest.php +++ b/tests/Stream/MultiJsonStreamTest.php @@ -41,11 +41,18 @@ public function testReadJsonEscapedDoubleQuote(string $jsonStream, array $jsonPa $serializer = $this->getMockBuilder(SerializerInterface::class) ->getMock(); + $callIndex = 0; $serializer ->expects($this->exactly(\count($jsonParts))) ->method('deserialize') - ->withConsecutive(...array_map(fn ($part) => [$part, BuildInfo::class, 'json', []], $jsonParts)) - ; + ->willReturnCallback(function ($data, $class, $format, $context) use ($jsonParts, &$callIndex) { + $this->assertEquals($jsonParts[$callIndex], $data); + $this->assertEquals(BuildInfo::class, $class); + $this->assertEquals('json', $format); + $this->assertEquals([], $context); + $callIndex++; + return null; + }); $stub = $this->getMockForAbstractClass(MultiJsonStream::class, [$stream, $serializer]); $stub->expects($this->any()) From abe1c9a21d9f03b15355ed0566a6252a28b4a0bb Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Sun, 25 May 2025 11:40:46 +0200 Subject: [PATCH 73/85] ci: publish code climate only on main repo --- .github/workflows/continuous-integration.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 794e609bd..c6d09174a 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -4,15 +4,14 @@ on: push: paths-ignore: - "doc/**" - - ".github/**" pull_request: paths-ignore: - "doc/**" - - ".github/**" + jobs: phpunit: - name: PHP ${{ matrix.php-version }} (${{ matrix.dependency-version }}) + name: PHP ${{ matrix.php-version }} (${{ matrix.dependency-versions }}) runs-on: ubuntu-latest continue-on-error: ${{ matrix.experimental }} @@ -55,6 +54,7 @@ jobs: run: composer run-script test-ci - name: Publish code coverage + if: github.repository == 'beluga-php/docker-php' && github.event_name != 'pull_request' uses: paambaati/codeclimate-action@a1831d7162ea1fbc612ffe5fb3b90278b7999d59 # v5.0.0 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} @@ -62,4 +62,4 @@ jobs: coverageCommand: composer run-script test-coverage coverageLocations: | ${{github.workspace}}/clover.xml:clover - if: github.event_name != 'pull_request' + From c81738c945052b3a80b80c4532ce4f10df459242 Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Sun, 25 May 2025 11:51:51 +0200 Subject: [PATCH 74/85] feat: add editor config --- .editorconfig | 16 +++++ composer.json | 174 +++++++++++++++++++++++++------------------------- 2 files changed, 103 insertions(+), 87 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..d95b72a20 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# EditorConfig is awesome: https://EditorConfig.org + +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 +trim_trailing_whitespace = true + +# JSON files +[*.json] +indent_style = space +indent_size = 4 diff --git a/composer.json b/composer.json index 276633f7f..f680bd44d 100644 --- a/composer.json +++ b/composer.json @@ -1,91 +1,91 @@ { - "name": "beluga-php/docker-php", - "description": "A Docker PHP client", - "license": "MIT", - "type": "library", - "funding": [ - { - "type": "github", - "url": "https://github.com/flavioheleno" - } - ], - "require": { - "php": ">=8.1", - "beluga-php/docker-php-api": "7.1.45.*", - "nyholm/psr7": "^1.8", - "php-http/client-common": "^2.7", - "php-http/discovery": "^1.19", - "php-http/socket-client": "^2.3", - "psr/http-message": "^2.0", - "symfony/filesystem": "^6.3 || ^7.0", - "symfony/process": "^6.3 || ^7.0", - "symfony/serializer": "^6.3 || ^7.0" - }, - "require-dev": { - "ergebnis/composer-normalize": "^2.42", - "friendsofphp/php-cs-fixer": "^3.8", - "php-parallel-lint/php-parallel-lint": "^1.2", - "phpstan/phpstan": "^1.10", - "phpunit/phpunit": "^10.5.46", - "psy/psysh": "^0.12.8", - "roave/security-advisories": "dev-latest" - }, - "conflict": { - "docker-php/docker-php": "*", - "nikic/php-parser": "<4.13", - "php-http/message": "<1.15" - }, - "minimum-stability": "dev", - "prefer-stable": true, - "autoload": { - "psr-4": { - "Docker\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "Docker\\Tests\\": "tests/" - } - }, - "config": { - "allow-plugins": { - "ergebnis/composer-normalize": true, - "php-http/discovery": false + "name": "beluga-php/docker-php", + "description": "A Docker PHP client", + "license": "MIT", + "type": "library", + "funding": [ + { + "type": "github", + "url": "https://github.com/flavioheleno" + } + ], + "require": { + "php": ">=8.1", + "beluga-php/docker-php-api": "7.1.45.*", + "nyholm/psr7": "^1.8", + "php-http/client-common": "^2.7", + "php-http/discovery": "^1.19", + "php-http/socket-client": "^2.3", + "psr/http-message": "^2.0", + "symfony/filesystem": "^6.3 || ^7.0", + "symfony/process": "^6.3 || ^7.0", + "symfony/serializer": "^6.3 || ^7.0" + }, + "require-dev": { + "ergebnis/composer-normalize": "^2.42", + "friendsofphp/php-cs-fixer": "^3.8", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.5.46", + "psy/psysh": "^0.12.8", + "roave/security-advisories": "dev-latest" + }, + "conflict": { + "docker-php/docker-php": "*", + "nikic/php-parser": "<4.13", + "php-http/message": "<1.15" }, - "optimize-autoloader": true, - "preferred-install": "dist", - "sort-packages": true - }, - "extra": { - "branch-alias": { - "1.41": "1.41.x-dev", - "1.42": "1.42.x-dev", - "1.43": "1.43.x-dev", - "1.44": "1.44.x-dev", - "1.45": "1.45.x-dev", - "dev-master": "1.46.x-dev" + "minimum-stability": "dev", + "prefer-stable": true, + "autoload": { + "psr-4": { + "Docker\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Docker\\Tests\\": "tests/" + } + }, + "config": { + "allow-plugins": { + "ergebnis/composer-normalize": true, + "php-http/discovery": false + }, + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true + }, + "extra": { + "branch-alias": { + "1.41": "1.41.x-dev", + "1.42": "1.42.x-dev", + "1.43": "1.43.x-dev", + "1.44": "1.44.x-dev", + "1.45": "1.45.x-dev", + "dev-master": "1.46.x-dev" + } + }, + "scripts": { + "console": "vendor/bin/psysh", + "lint": "vendor/bin/parallel-lint --exclude vendor .", + "php-cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", + "php-cs-fixer-fix": "vendor/bin/php-cs-fixer fix --verbose", + "phpstan": "vendor/bin/phpstan analyse --level 2 src", + "phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation", + "test": [ + "@lint", + "@phpunit" + ], + "test-ci": "vendor/bin/phpunit ./tests/ --disallow-test-output --process-isolation", + "test-coverage": "vendor/bin/phpunit ./tests/ --whitelist=./src/ --coverage-clover=clover.xml" + }, + "scripts-descriptions": { + "console": "Runs PsySH Console", + "lint": "Runs complete codebase lint testing", + "phpunit": "Runs library test suite", + "test": "Runs all tests", + "test-ci": "Runs library test suite (for continuous integration)", + "test-coverage": "Runs test-coverage analysis" } - }, - "scripts": { - "console": "vendor/bin/psysh", - "lint": "vendor/bin/parallel-lint --exclude vendor .", - "php-cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", - "php-cs-fixer-fix": "vendor/bin/php-cs-fixer fix --verbose", - "phpstan": "vendor/bin/phpstan analyse --level 2 src", - "phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation", - "test": [ - "@lint", - "@phpunit" - ], - "test-ci": "vendor/bin/phpunit ./tests/ --disallow-test-output --process-isolation", - "test-coverage": "vendor/bin/phpunit ./tests/ --whitelist=./src/ --coverage-clover=clover.xml" - }, - "scripts-descriptions": { - "console": "Runs PsySH Console", - "lint": "Runs complete codebase lint testing", - "phpunit": "Runs library test suite", - "test": "Runs all tests", - "test-ci": "Runs library test suite (for continuous integration)", - "test-coverage": "Runs test-coverage analysis" - } } From 51909c28fc0a6b8209ef3ef1371abbe6c946456d Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Sun, 25 May 2025 12:36:14 -0300 Subject: [PATCH 75/85] Fix PHPUnit deprecations --- composer.json | 2 +- phpunit.xml.dist | 32 +++++++++++++--------------- tests/Stream/MultiJsonStreamTest.php | 2 +- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/composer.json b/composer.json index f680bd44d..118d66ff4 100644 --- a/composer.json +++ b/composer.json @@ -72,7 +72,7 @@ "php-cs-fixer": "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", "php-cs-fixer-fix": "vendor/bin/php-cs-fixer fix --verbose", "phpstan": "vendor/bin/phpstan analyse --level 2 src", - "phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --whitelist=./src/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation", + "phpunit": "vendor/bin/phpunit ./tests/ --coverage-html=./report/coverage/ --testdox-html=./report/testdox.html --disallow-test-output --process-isolation", "test": [ "@lint", "@phpunit" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d1446e798..cbc386105 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,25 +1,23 @@ - - - - src - - + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" + backupGlobals="false" + colors="true" + processIsolation="false" + stopOnFailure="false" + bootstrap="vendor/autoload.php" + cacheDirectory=".phpunit.cache" + backupStaticProperties="false"> + tests/ + + + src + + diff --git a/tests/Stream/MultiJsonStreamTest.php b/tests/Stream/MultiJsonStreamTest.php index 6d4a46acf..e3683e5c3 100644 --- a/tests/Stream/MultiJsonStreamTest.php +++ b/tests/Stream/MultiJsonStreamTest.php @@ -12,7 +12,7 @@ class MultiJsonStreamTest extends TestCase { - public function jsonStreamDataProvider() + public static function jsonStreamDataProvider() { return [ [ From c86f3e6bd567a6bd2b4434f55e16f9df2e8525be Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 25 May 2025 15:39:26 +0000 Subject: [PATCH 76/85] Bump shivammathur/setup-php from 2.30.3 to 2.31.0 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.30.3 to 2.31.0. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/efffd0e4f2504f936fcfe3b69293d31ce0e2fd7a...2e947f1f6932d141d076ca441d0e1e881775e95b) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index c6d09174a..d0586282b 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -32,7 +32,7 @@ jobs: uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@efffd0e4f2504f936fcfe3b69293d31ce0e2fd7a # v2.30.3 + uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 54b024140..44a1d56db 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@efffd0e4f2504f936fcfe3b69293d31ce0e2fd7a # v2.30.3 + uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0 with: php-version: 8.1 tools: composer:v2 From d0cb03cb3e14278213afc46e52807e95adc1b0e9 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Fri, 14 Nov 2025 21:36:41 -0300 Subject: [PATCH 77/85] Fix composer branch alias --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 118d66ff4..b5d9dd4f2 100644 --- a/composer.json +++ b/composer.json @@ -62,8 +62,7 @@ "1.42": "1.42.x-dev", "1.43": "1.43.x-dev", "1.44": "1.44.x-dev", - "1.45": "1.45.x-dev", - "dev-master": "1.46.x-dev" + "dev-master": "1.45.x-dev" } }, "scripts": { From 00fac8e12f5460c78a5c79ee75d8792b444b6a62 Mon Sep 17 00:00:00 2001 From: Flavio Heleno Date: Fri, 14 Nov 2025 21:36:57 -0300 Subject: [PATCH 78/85] Fix base url in DockerClientFactory --- src/DockerClientFactory.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DockerClientFactory.php b/src/DockerClientFactory.php index 0b6fbfb82..39b07e890 100644 --- a/src/DockerClientFactory.php +++ b/src/DockerClientFactory.php @@ -34,7 +34,7 @@ public static function create(array $config = [], ?PluginClientFactory $pluginCl [ new ContentLengthPlugin(), new DecoderPlugin(), - new AddPathPlugin($uriFactory->createUri('/v1.43')), + new AddPathPlugin($uriFactory->createUri('/v1.45')), new AddHostPlugin($uriFactory->createUri($host)), new HeaderDefaultsPlugin([ 'host' => parse_url($host, \PHP_URL_HOST), From 4f72d61ac26480cacfe6b59cd2caaea9abc091de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fl=C3=A1vio=20Heleno?= Date: Wed, 11 Jun 2025 22:50:47 -0300 Subject: [PATCH 79/85] Drop CodeClimate integration from CI Workflow --- .github/workflows/continuous-integration.yml | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index d0586282b..4e6431d79 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -8,7 +8,6 @@ on: paths-ignore: - "doc/**" - jobs: phpunit: name: PHP ${{ matrix.php-version }} (${{ matrix.dependency-versions }}) @@ -52,14 +51,3 @@ jobs: - name: Run PHPUnit test suite run: composer run-script test-ci - - - name: Publish code coverage - if: github.repository == 'beluga-php/docker-php' && github.event_name != 'pull_request' - uses: paambaati/codeclimate-action@a1831d7162ea1fbc612ffe5fb3b90278b7999d59 # v5.0.0 - env: - CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} - with: - coverageCommand: composer run-script test-coverage - coverageLocations: | - ${{github.workspace}}/clover.xml:clover - From 40dcaac47f33c4aabc868ebdadbb224d2d907834 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 15 Nov 2025 00:43:35 +0000 Subject: [PATCH 80/85] Bump shivammathur/setup-php from 2.33.0 to 2.35.5 Bumps [shivammathur/setup-php](https://github.com/shivammathur/setup-php) from 2.33.0 to 2.35.5. - [Release notes](https://github.com/shivammathur/setup-php/releases) - [Commits](https://github.com/shivammathur/setup-php/compare/cf4cade2721270509d5b1c766ab3549210a39a2a...bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f) --- updated-dependencies: - dependency-name: shivammathur/setup-php dependency-version: 2.35.5 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 4e6431d79..abc3cc549 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -31,7 +31,7 @@ jobs: uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0 + uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2.35.5 with: php-version: ${{ matrix.php-version }} tools: composer:v2 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 44a1d56db..875822ceb 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -21,7 +21,7 @@ jobs: uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 - name: Setup PHP with PECL extension - uses: shivammathur/setup-php@cf4cade2721270509d5b1c766ab3549210a39a2a # v2.33.0 + uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2.35.5 with: php-version: 8.1 tools: composer:v2 From f77e92bac763cbbe770f4710170d195d2e077b79 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 15 Nov 2025 00:45:31 +0000 Subject: [PATCH 81/85] Bump actions/checkout from 4.1.3 to 5.0.0 Bumps [actions/checkout](https://github.com/actions/checkout) from 4.1.3 to 5.0.0. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/1d96c772d19495a3b5c517cd2bc0cb401ea0529f...08c6903cd8c0fde910a37f88322edcfb5dd907a8) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: 5.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index abc3cc549..4c69d1f5b 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -28,7 +28,7 @@ jobs: steps: - name: Repository checkout - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Setup PHP with PECL extension uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2.35.5 diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index 875822ceb..c5fcdba98 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -18,7 +18,7 @@ jobs: steps: - name: Repository checkout - uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3 + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 - name: Setup PHP with PECL extension uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # v2.35.5 From c2d1af1a8be7818f8ea300cb021b9c4ba8701b30 Mon Sep 17 00:00:00 2001 From: Adam Spychala Date: Wed, 4 Jun 2025 19:01:30 +0200 Subject: [PATCH 82/85] set explicit nullable parameters for PHP 8.4 --- src/Endpoint/ContainerAttachWebsocket.php | 3 ++- src/Endpoint/ContainerLogs.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Endpoint/ContainerAttachWebsocket.php b/src/Endpoint/ContainerAttachWebsocket.php index 6009f415a..ee6fe0237 100644 --- a/src/Endpoint/ContainerAttachWebsocket.php +++ b/src/Endpoint/ContainerAttachWebsocket.php @@ -27,7 +27,8 @@ public function getExtraHeaders(): array ); } - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string + $contentType = null) { if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $contentType) { return new AttachWebsocketStream($response->getBody()); diff --git a/src/Endpoint/ContainerLogs.php b/src/Endpoint/ContainerLogs.php index 573ae6481..996b09c39 100644 --- a/src/Endpoint/ContainerLogs.php +++ b/src/Endpoint/ContainerLogs.php @@ -11,7 +11,7 @@ class ContainerLogs extends BaseEndpoint { - protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, string $contentType = null) + protected function transformResponseBody(ResponseInterface $response, SerializerInterface $serializer, ?string $contentType = null) { if (200 === $response->getStatusCode() && DockerRawStream::HEADER === $contentType) { return new DockerRawStream($response->getBody()); From fa9022df8a8c2a0d00433c9f23f7c94b8778dfa7 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Tue, 23 Dec 2025 17:58:27 +0100 Subject: [PATCH 83/85] ci: updated symfony dependencies --- composer.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index b5d9dd4f2..eca91be79 100644 --- a/composer.json +++ b/composer.json @@ -17,9 +17,9 @@ "php-http/discovery": "^1.19", "php-http/socket-client": "^2.3", "psr/http-message": "^2.0", - "symfony/filesystem": "^6.3 || ^7.0", - "symfony/process": "^6.3 || ^7.0", - "symfony/serializer": "^6.3 || ^7.0" + "symfony/filesystem": "^6.3 || ^7.0 || ^8.0", + "symfony/process": "^6.3 || ^7.0 || ^8.0", + "symfony/serializer": "^6.3 || ^7.0 || ^8.0" }, "require-dev": { "ergebnis/composer-normalize": "^2.42", From f6b8d499a62f730dd541bc70253bf65e1dd8cad1 Mon Sep 17 00:00:00 2001 From: Jorg Sowa Date: Wed, 10 Dec 2025 17:51:05 +0100 Subject: [PATCH 84/85] ci: support PHP 8.5 in CI --- .github/workflows/continuous-integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 4c69d1f5b..89f832c3e 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -23,6 +23,7 @@ jobs: - "8.2" - "8.3" - "8.4" + - "8.5" dependency-versions: [lowest, highest] experimental: [false] From 19857d2a2cb84b42e7d35868bc78c9ceda67a08f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 27 Dec 2025 21:40:13 +0000 Subject: [PATCH 85/85] Bump ramsey/composer-install from 3.0.0 to 3.1.1 Bumps [ramsey/composer-install](https://github.com/ramsey/composer-install) from 3.0.0 to 3.1.1. - [Release notes](https://github.com/ramsey/composer-install/releases) - [Commits](https://github.com/ramsey/composer-install/compare/57532f8be5bda426838819c5ee9afb8af389d51a...3cf229dc2919194e9e36783941438d17239e8520) --- updated-dependencies: - dependency-name: ramsey/composer-install dependency-version: 3.1.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .github/workflows/continuous-integration.yml | 2 +- .github/workflows/static-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 89f832c3e..854f94f74 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -42,7 +42,7 @@ jobs: run: composer validate --strict - name: Install dependencies - uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # v3.0.0 + uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3.1.1 with: dependency-versions: ${{ matrix.dependency-versions }} composer-options: ${{ matrix.composer-options }} diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml index c5fcdba98..43f70ce66 100644 --- a/.github/workflows/static-analysis.yml +++ b/.github/workflows/static-analysis.yml @@ -31,7 +31,7 @@ jobs: run: composer validate --strict - name: Install dependencies - uses: ramsey/composer-install@57532f8be5bda426838819c5ee9afb8af389d51a # v3.0.0 + uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3.1.1 with: dependency-versions: lowest