From e75e3a836c427e7c8223bcea612678655709c906 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Mon, 31 Aug 2026 14:05:21 +0000 Subject: [PATCH 1/8] Update dependency guzzlehttp/guzzle to v8 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 30196e2..4d70de4 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require": { "php": ">=8.1", "ext-json": "*", - "guzzlehttp/guzzle": "^6 || ^7" + "guzzlehttp/guzzle": "^6 || ^7 || ^8" }, "autoload": { "psr-4": { From 67ba7934f5a32ca6f55eea7abab393d5c1783724 Mon Sep 17 00:00:00 2001 From: K Widholm <279278+apotek@users.noreply.github.com> Date: Mon, 31 Aug 2026 11:53:53 -0400 Subject: [PATCH 2/8] Update to latest php rector style. --- src/Factory.php | 5 ++--- src/Http/Client.php | 15 +++++++-------- src/Http/Response.php | 5 ++--- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/Factory.php b/src/Factory.php index 8de7842..26884fb 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -39,9 +39,8 @@ class Factory */ public function __construct(array $config = [], ?Client $client = null, array $clientOptions = []) { - if (is_null($client)) { - $client = new Client($config, null, $clientOptions); - } + // Null coalesce assignment of new instance if necessary. + $client ??= new Client($config, null, $clientOptions); $this->client = $client; } diff --git a/src/Http/Client.php b/src/Http/Client.php index 261d559..0739c49 100644 --- a/src/Http/Client.php +++ b/src/Http/Client.php @@ -77,14 +77,13 @@ public function __construct(array $config = [], ?GuzzleClient $httpClient = null throw new OrangeDamException('You must provide Orange DAM API Base path.'); } - // Creates a new instance - if (is_null($httpClient)) { - $httpClient = new GuzzleClient([ - 'cookies' => true, - 'timeout' => self::REQUEST_TIMEOUT, - 'base_uri' => $config['base_path'], - ]); - } + // Null coalesce assignment of new instance. + $httpClient ??= new GuzzleClient([ + 'cookies' => true, + 'timeout' => self::REQUEST_TIMEOUT, + 'base_uri' => $config['base_path'], + ]); + $this->httpClient = $httpClient; } diff --git a/src/Http/Response.php b/src/Http/Response.php index b102cae..1409806 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -59,9 +59,8 @@ public function __get($name) */ public function getData() { - if (is_null($this->data)) { - $this->data = $this->getDataFromResponse($this->response); - } + // Null coalesce assignment of new data if data is null. + $this->data ??= $this->getDataFromResponse($this->response); return $this->data; } From 0bc9ac8695030e6757bfe97754ca3054e4f4559b Mon Sep 17 00:00:00 2001 From: K Widholm <279278+apotek@users.noreply.github.com> Date: Mon, 31 Aug 2026 12:28:07 -0400 Subject: [PATCH 3/8] Handle Guzzle RequestException constructor change in version 8 --- tests/Exceptions/OrangeDamExceptionTest.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/Exceptions/OrangeDamExceptionTest.php b/tests/Exceptions/OrangeDamExceptionTest.php index 7ca30d0..e34e60c 100644 --- a/tests/Exceptions/OrangeDamExceptionTest.php +++ b/tests/Exceptions/OrangeDamExceptionTest.php @@ -2,6 +2,7 @@ namespace Chromatic\OrangeDam\Exceptions; +use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; @@ -23,10 +24,17 @@ public function testClassConstructor(): void */ public function testSanitizeResponse(): void { + // Handle Guzzle RequestException constructor change in version 8. + if (defined('ClientInterface::MAJOR_VERSION') && ClientInterface::MAJOR_VERSION > 7) { + $response = 200; + } + else { + $response = new Response(200); + } $e = new RequestException( 'token=12345 Test response message.', new Request('GET', '/'), - new Response(200) + $response, ); $orangeException = OrangeDamException::create($e); $this->assertSame($orangeException->getMessage(), 'token=*** Test response message.'); @@ -37,10 +45,17 @@ public function testSanitizeResponse(): void */ public function testGetResponse(): void { + // Handle Guzzle RequestException constructor change in version 8. + if (defined('ClientInterface::MAJOR_VERSION') && ClientInterface::MAJOR_VERSION > 7) { + $response = 200; + } + else { + $response = new Response(200); + } $e = new RequestException( '', new Request('GET', '/'), - new Response(200) + $response, ); $orangeException = OrangeDamException::create($e); $this->assertInstanceOf(Response::class, $orangeException->getResponse()); From 533b688a4975d6404873986018cc40adbebecd89 Mon Sep 17 00:00:00 2001 From: K Widholm <279278+apotek@users.noreply.github.com> Date: Mon, 31 Aug 2026 12:38:41 -0400 Subject: [PATCH 4/8] Conform tests to psr4 --- composer.json | 5 +++++ tests/{ => Chromatic/OrangeDam}/Endpoints/AssetLinkTest.php | 0 .../OrangeDam}/Exceptions/OrangeDamExceptionTest.php | 0 tests/{ => Chromatic/OrangeDam}/FactoryTest.php | 0 tests/{ => Chromatic/OrangeDam}/Http/ClientTest.php | 0 tests/{ => Chromatic/OrangeDam}/Http/ResponseTest.php | 0 6 files changed, 5 insertions(+) rename tests/{ => Chromatic/OrangeDam}/Endpoints/AssetLinkTest.php (100%) rename tests/{ => Chromatic/OrangeDam}/Exceptions/OrangeDamExceptionTest.php (100%) rename tests/{ => Chromatic/OrangeDam}/FactoryTest.php (100%) rename tests/{ => Chromatic/OrangeDam}/Http/ClientTest.php (100%) rename tests/{ => Chromatic/OrangeDam}/Http/ResponseTest.php (100%) diff --git a/composer.json b/composer.json index 4d70de4..33caa6b 100644 --- a/composer.json +++ b/composer.json @@ -18,6 +18,11 @@ "name": "Adam Zimmermann", "email": "adam@chromatichq.com", "homepage": "https://www.drupal.org/u/adamzimmermann" + }, + { + "name": "Kristofer Widholm", + "email": "kristofer@chromatichq.com", + "homepage": "https://www.drupal.org/u/apotek" } ], "require": { diff --git a/tests/Endpoints/AssetLinkTest.php b/tests/Chromatic/OrangeDam/Endpoints/AssetLinkTest.php similarity index 100% rename from tests/Endpoints/AssetLinkTest.php rename to tests/Chromatic/OrangeDam/Endpoints/AssetLinkTest.php diff --git a/tests/Exceptions/OrangeDamExceptionTest.php b/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php similarity index 100% rename from tests/Exceptions/OrangeDamExceptionTest.php rename to tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php diff --git a/tests/FactoryTest.php b/tests/Chromatic/OrangeDam/FactoryTest.php similarity index 100% rename from tests/FactoryTest.php rename to tests/Chromatic/OrangeDam/FactoryTest.php diff --git a/tests/Http/ClientTest.php b/tests/Chromatic/OrangeDam/Http/ClientTest.php similarity index 100% rename from tests/Http/ClientTest.php rename to tests/Chromatic/OrangeDam/Http/ClientTest.php diff --git a/tests/Http/ResponseTest.php b/tests/Chromatic/OrangeDam/Http/ResponseTest.php similarity index 100% rename from tests/Http/ResponseTest.php rename to tests/Chromatic/OrangeDam/Http/ResponseTest.php From 3ce27b0548621115959bac8394a588d8ed98c9f7 Mon Sep 17 00:00:00 2001 From: K Widholm <279278+apotek@users.noreply.github.com> Date: Mon, 31 Aug 2026 12:40:49 -0400 Subject: [PATCH 5/8] phpcs fixes --- .../OrangeDam/Exceptions/OrangeDamExceptionTest.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php b/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php index e34e60c..2bacf0c 100644 --- a/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php +++ b/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php @@ -27,8 +27,7 @@ public function testSanitizeResponse(): void // Handle Guzzle RequestException constructor change in version 8. if (defined('ClientInterface::MAJOR_VERSION') && ClientInterface::MAJOR_VERSION > 7) { $response = 200; - } - else { + } else { $response = new Response(200); } $e = new RequestException( @@ -48,8 +47,7 @@ public function testGetResponse(): void // Handle Guzzle RequestException constructor change in version 8. if (defined('ClientInterface::MAJOR_VERSION') && ClientInterface::MAJOR_VERSION > 7) { $response = 200; - } - else { + } else { $response = new Response(200); } $e = new RequestException( From e359664b68a1d64042c607bf6650dcdfa7b261db Mon Sep 17 00:00:00 2001 From: K Widholm <279278+apotek@users.noreply.github.com> Date: Mon, 31 Aug 2026 12:54:02 -0400 Subject: [PATCH 6/8] Try to detect correct client version --- .../OrangeDam/Exceptions/OrangeDamExceptionTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php b/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php index 2bacf0c..9477443 100644 --- a/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php +++ b/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php @@ -25,7 +25,8 @@ public function testClassConstructor(): void public function testSanitizeResponse(): void { // Handle Guzzle RequestException constructor change in version 8. - if (defined('ClientInterface::MAJOR_VERSION') && ClientInterface::MAJOR_VERSION > 7) { + $client_class = ClientInterface::class; + if (defined("$client_class::MAJOR_VERSION") && ClientInterface::MAJOR_VERSION > 7) { $response = 200; } else { $response = new Response(200); @@ -45,7 +46,7 @@ public function testSanitizeResponse(): void public function testGetResponse(): void { // Handle Guzzle RequestException constructor change in version 8. - if (defined('ClientInterface::MAJOR_VERSION') && ClientInterface::MAJOR_VERSION > 7) { + if (ClientInterface::MAJOR_VERSION > 7) { $response = 200; } else { $response = new Response(200); From 09ecebb949c753fb287f6c493b9f6e79e69f0929 Mon Sep 17 00:00:00 2001 From: K Widholm <279278+apotek@users.noreply.github.com> Date: Tue, 1 Sep 2026 23:48:30 -0400 Subject: [PATCH 7/8] Attempt to allow tests to work in 7 and 8 --- src/Exceptions/OrangeDamException.php | 1 - .../Exceptions/OrangeDamExceptionTest.php | 37 +++++++++++-------- tests/Chromatic/OrangeDam/Http/ClientTest.php | 2 +- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/Exceptions/OrangeDamException.php b/src/Exceptions/OrangeDamException.php index 2a09b6b..dc76d8f 100644 --- a/src/Exceptions/OrangeDamException.php +++ b/src/Exceptions/OrangeDamException.php @@ -44,7 +44,6 @@ public static function create(RequestException $guzzleException): self $guzzleException->getCode(), $guzzleException ); - $e->response = $guzzleException->getResponse(); return $e; diff --git a/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php b/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php index 9477443..dcc9179 100644 --- a/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php +++ b/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php @@ -27,15 +27,18 @@ public function testSanitizeResponse(): void // Handle Guzzle RequestException constructor change in version 8. $client_class = ClientInterface::class; if (defined("$client_class::MAJOR_VERSION") && ClientInterface::MAJOR_VERSION > 7) { - $response = 200; + $e = new \GuzzleHttp\Exception\ResponseException( + 'token=12345 Test response message.', + new Request('GET', '/'), + new Response(200), + ); } else { - $response = new Response(200); + $e = new RequestException( + 'token=12345 Test response message.', + new Request('GET', '/'), + new Response(200), + ); } - $e = new RequestException( - 'token=12345 Test response message.', - new Request('GET', '/'), - $response, - ); $orangeException = OrangeDamException::create($e); $this->assertSame($orangeException->getMessage(), 'token=*** Test response message.'); } @@ -46,16 +49,20 @@ public function testSanitizeResponse(): void public function testGetResponse(): void { // Handle Guzzle RequestException constructor change in version 8. - if (ClientInterface::MAJOR_VERSION > 7) { - $response = 200; + $client_class = ClientInterface::class; + if (defined("$client_class::MAJOR_VERSION") && ClientInterface::MAJOR_VERSION > 7) { + $e = new ResponseException( + '', + new Request('GET', '/'), + new Response(200), + ); } else { - $response = new Response(200); + $e = new RequestException( + '', + new Request('GET', '/'), + new Response(200), + ); } - $e = new RequestException( - '', - new Request('GET', '/'), - $response, - ); $orangeException = OrangeDamException::create($e); $this->assertInstanceOf(Response::class, $orangeException->getResponse()); } diff --git a/tests/Chromatic/OrangeDam/Http/ClientTest.php b/tests/Chromatic/OrangeDam/Http/ClientTest.php index 87a9a41..b3faff5 100644 --- a/tests/Chromatic/OrangeDam/Http/ClientTest.php +++ b/tests/Chromatic/OrangeDam/Http/ClientTest.php @@ -69,7 +69,7 @@ public function testRequestUrlHasNoTrailingQuestionMark(): void $guzzle = new GuzzleClient(['handler' => $handlerStack, 'base_uri' => 'https://test.com']); $client = new Client(['base_path' => 'https://test.com'], $guzzle); $client->token = 'test-token'; - $client->request('get', '/some/endpoint'); + $client->request('GET', '/some/endpoint'); $uri = (string) $container[0]['request']->getUri(); $this->assertStringNotContainsString('?', $uri); From 983f432d8be8a908aebd6e6b06d88e4dae369f5f Mon Sep 17 00:00:00 2001 From: K Widholm <279278+apotek@users.noreply.github.com> Date: Tue, 1 Sep 2026 23:51:54 -0400 Subject: [PATCH 8/8] Add full path for ResponseException --- tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php b/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php index dcc9179..aa0be3a 100644 --- a/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php +++ b/tests/Chromatic/OrangeDam/Exceptions/OrangeDamExceptionTest.php @@ -51,7 +51,7 @@ public function testGetResponse(): void // Handle Guzzle RequestException constructor change in version 8. $client_class = ClientInterface::class; if (defined("$client_class::MAJOR_VERSION") && ClientInterface::MAJOR_VERSION > 7) { - $e = new ResponseException( + $e = new \GuzzleHttp\Exception\ResponseException( '', new Request('GET', '/'), new Response(200),