Skip to content

Commit 2619541

Browse files
authored
Add support for Guzzle 6.3 (#93)
1 parent 9c1f2e6 commit 2619541

File tree

3 files changed

+30
-19
lines changed

3 files changed

+30
-19
lines changed

.circleci/config.yml

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@ orbs:
66
workflows:
77
workflow:
88
jobs:
9-
- test-with-preinstalled-php:
10-
name: PHP 7.3
11-
docker-image: cimg/php:7.3
12-
- test-with-preinstalled-php:
13-
name: PHP 7.4
14-
docker-image: cimg/php:7.4
15-
- test-with-preinstalled-php:
16-
name: PHP 8.0
17-
docker-image: cimg/php:8.0
9+
- test-on-linux:
10+
matrix:
11+
parameters:
12+
php-version: ["7.3", "7.4", "8.0"]
13+
composer-dependencies: ["lowest", "highest"]
1814
- test-on-windows
1915

2016
jobs:
@@ -48,38 +44,50 @@ jobs:
4844
name: run tests
4945
command: .\vendor\bin\phpunit
5046

51-
test-with-preinstalled-php:
47+
test-on-linux:
5248
parameters:
53-
docker-image:
49+
php-version:
50+
type: string
51+
composer-dependencies:
5452
type: string
5553

5654
environment:
5755
LD_INCLUDE_INTEGRATION_TESTS: 1
5856

5957
docker:
60-
- image: <<parameters.docker-image>>
58+
- image: cimg/php:<<parameters.php-version>>
6159
- image: wiremock/wiremock
6260

6361
steps:
6462
- setup_remote_docker
6563
- checkout
64+
6665
- run:
6766
name: validate composer.json
6867
command: composer validate
6968
- run:
7069
name: install dependencies
7170
command: composer install --no-progress
71+
- when:
72+
condition:
73+
equal: [ <<parameters.composer-dependencies>>, "lowest" ]
74+
steps:
75+
- run:
76+
name: downgrade to lowest versions
77+
command: composer update --prefer-lowest --prefer-stable
78+
7279
- run:
7380
name: psalm linting
7481
command: ./vendor/bin/psalm --no-cache
7582
- run:
7683
name: php-cs-fixer check
7784
command: composer cs-check
7885
- run:
79-
name: run tests with highest compatible dependency versions
86+
name: run tests
8087
command: php -d xdebug.mode=coverage vendor/bin/phpunit
8188
enviroment:
8289
XDEBUG_MODE: coverage
90+
8391
- store_test_results:
8492
path: build/phpunit
8593
- store_artifacts:

composer.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@
1919
"psr/log": "^1.0|^2.0|^3.0"
2020
},
2121
"require-dev": {
22-
"friendsofphp/php-cs-fixer": ">=2.2.19 <3.0",
23-
"guzzlehttp/guzzle": "^7",
22+
"friendsofphp/php-cs-fixer": ">=2.18.0 <3.0",
23+
"guzzlehttp/guzzle": "^6.3 | ^7",
2424
"kevinrob/guzzle-cache-middleware": "^3",
2525
"phpunit/php-code-coverage": "^9",
2626
"phpunit/phpunit": "^9",
27-
"vimeo/psalm": "^4.0"
27+
"vimeo/psalm": "^4.4"
2828
},
2929
"suggest": {
30-
"guzzlehttp/guzzle": "(^7) Required when using GuzzleEventPublisher or the default FeatureRequester",
30+
"guzzlehttp/guzzle": "(^6.3 | ^7) Required when using GuzzleEventPublisher or the default FeatureRequester",
3131
"kevinrob/guzzle-cache-middleware": "(^3) Recommended for performance when using the default FeatureRequester"
3232
},
3333
"autoload": {
@@ -44,7 +44,7 @@
4444
"sort-packages": true
4545
},
4646
"scripts": {
47-
"cs-check": "vendor/bin/php-cs-fixer fix --diff --dry-run --verbose",
48-
"cs-fix": "vendor/bin/php-cs-fixer fix --diff --verbose"
47+
"cs-check": "vendor/bin/php-cs-fixer fix --diff --dry-run --verbose --config=.php-cs-fixer.php",
48+
"cs-fix": "vendor/bin/php-cs-fixer fix --diff --verbose --config=.php-cs-fixer.php"
4949
}
5050
}

src/LaunchDarkly/Impl/Integrations/GuzzleFeatureRequester.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public function getFeature(string $key): ?FeatureFlag
7575
$body = $response->getBody();
7676
return FeatureFlag::decode(json_decode($body->getContents(), true));
7777
} catch (BadResponseException $e) {
78+
/** @psalm-suppress PossiblyNullReference (resolved in guzzle 7) */
7879
$code = $e->getResponse()->getStatusCode();
7980
if ($code == 404) {
8081
$this->_logger->warning("GuzzleFeatureRequester::get returned 404. Feature flag does not exist for key: " . $key);
@@ -98,6 +99,7 @@ public function getSegment(string $key): ?Segment
9899
$body = $response->getBody();
99100
return Segment::decode(json_decode($body->getContents(), true));
100101
} catch (BadResponseException $e) {
102+
/** @psalm-suppress PossiblyNullReference (resolved in guzzle 7) */
101103
$code = $e->getResponse()->getStatusCode();
102104
if ($code == 404) {
103105
$this->_logger->warning("GuzzleFeatureRequester::get returned 404. Segment does not exist for key: " . $key);
@@ -120,6 +122,7 @@ public function getAllFeatures(): ?array
120122
$body = $response->getBody();
121123
return array_map(FeatureFlag::getDecoder(), json_decode($body->getContents(), true));
122124
} catch (BadResponseException $e) {
125+
/** @psalm-suppress PossiblyNullReference (resolved in guzzle 7) */
123126
$this->handleUnexpectedStatus($e->getResponse()->getStatusCode(), "GuzzleFeatureRequester::getAll");
124127
return null;
125128
}

0 commit comments

Comments
 (0)