diff --git a/.circleci/config.yml b/.circleci/config.yml index 75cd954e..4badb855 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -6,15 +6,11 @@ orbs: workflows: workflow: jobs: - - test-with-preinstalled-php: - name: PHP 7.3 - docker-image: cimg/php:7.3 - - test-with-preinstalled-php: - name: PHP 7.4 - docker-image: cimg/php:7.4 - - test-with-preinstalled-php: - name: PHP 8.0 - docker-image: cimg/php:8.0 + - test-on-linux: + matrix: + parameters: + php-version: ["7.3", "7.4", "8.0"] + composer-dependencies: ["lowest", "highest"] - test-on-windows jobs: @@ -48,27 +44,38 @@ jobs: name: run tests command: .\vendor\bin\phpunit - test-with-preinstalled-php: + test-on-linux: parameters: - docker-image: + php-version: + type: string + composer-dependencies: type: string environment: LD_INCLUDE_INTEGRATION_TESTS: 1 docker: - - image: <> + - image: cimg/php:<> - image: wiremock/wiremock steps: - setup_remote_docker - checkout + - run: name: validate composer.json command: composer validate - run: name: install dependencies command: composer install --no-progress + - when: + condition: + equal: [ <>, "lowest" ] + steps: + - run: + name: downgrade to lowest versions + command: composer update --prefer-lowest --prefer-stable + - run: name: psalm linting command: ./vendor/bin/psalm --no-cache @@ -76,10 +83,11 @@ jobs: name: php-cs-fixer check command: composer cs-check - run: - name: run tests with highest compatible dependency versions + name: run tests command: php -d xdebug.mode=coverage vendor/bin/phpunit enviroment: XDEBUG_MODE: coverage + - store_test_results: path: build/phpunit - store_artifacts: diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 19806760..fc89ce0f 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -1,7 +1,7 @@ **Requirements** - [ ] I have added test coverage for new or changed functionality -- [ ] I have followed the repository's [pull request submission guidelines](../blob/master/CONTRIBUTING.md#submitting-pull-requests) +- [ ] I have followed the repository's [pull request submission guidelines](../blob/main/CONTRIBUTING.md#submitting-pull-requests) - [ ] I have validated my changes against all supported platform versions **Related issues** diff --git a/composer.json b/composer.json index a21d934c..4da99fc7 100644 --- a/composer.json +++ b/composer.json @@ -19,15 +19,15 @@ "psr/log": "^1.0|^2.0|^3.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": ">=2.2.19 <3.0", - "guzzlehttp/guzzle": "^7", + "friendsofphp/php-cs-fixer": ">=2.18.0 <3.0", + "guzzlehttp/guzzle": "^6.3 | ^7", "kevinrob/guzzle-cache-middleware": "^3", "phpunit/php-code-coverage": "^9", "phpunit/phpunit": "^9", - "vimeo/psalm": "^4.0" + "vimeo/psalm": "^4.4" }, "suggest": { - "guzzlehttp/guzzle": "(^7) Required when using GuzzleEventPublisher or the default FeatureRequester", + "guzzlehttp/guzzle": "(^6.3 | ^7) Required when using GuzzleEventPublisher or the default FeatureRequester", "kevinrob/guzzle-cache-middleware": "(^3) Recommended for performance when using the default FeatureRequester" }, "autoload": { @@ -44,7 +44,7 @@ "sort-packages": true }, "scripts": { - "cs-check": "vendor/bin/php-cs-fixer fix --diff --dry-run --verbose", - "cs-fix": "vendor/bin/php-cs-fixer fix --diff --verbose" + "cs-check": "vendor/bin/php-cs-fixer fix --diff --dry-run --verbose --config=.php-cs-fixer.php", + "cs-fix": "vendor/bin/php-cs-fixer fix --diff --verbose --config=.php-cs-fixer.php" } } diff --git a/src/LaunchDarkly/Impl/Integrations/GuzzleFeatureRequester.php b/src/LaunchDarkly/Impl/Integrations/GuzzleFeatureRequester.php index 98e3ca17..ed94f719 100644 --- a/src/LaunchDarkly/Impl/Integrations/GuzzleFeatureRequester.php +++ b/src/LaunchDarkly/Impl/Integrations/GuzzleFeatureRequester.php @@ -75,6 +75,7 @@ public function getFeature(string $key): ?FeatureFlag $body = $response->getBody(); return FeatureFlag::decode(json_decode($body->getContents(), true)); } catch (BadResponseException $e) { + /** @psalm-suppress PossiblyNullReference (resolved in guzzle 7) */ $code = $e->getResponse()->getStatusCode(); if ($code == 404) { $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 $body = $response->getBody(); return Segment::decode(json_decode($body->getContents(), true)); } catch (BadResponseException $e) { + /** @psalm-suppress PossiblyNullReference (resolved in guzzle 7) */ $code = $e->getResponse()->getStatusCode(); if ($code == 404) { $this->_logger->warning("GuzzleFeatureRequester::get returned 404. Segment does not exist for key: " . $key); @@ -120,6 +122,7 @@ public function getAllFeatures(): ?array $body = $response->getBody(); return array_map(FeatureFlag::getDecoder(), json_decode($body->getContents(), true)); } catch (BadResponseException $e) { + /** @psalm-suppress PossiblyNullReference (resolved in guzzle 7) */ $this->handleUnexpectedStatus($e->getResponse()->getStatusCode(), "GuzzleFeatureRequester::getAll"); return null; } diff --git a/src/LaunchDarkly/LDClient.php b/src/LaunchDarkly/LDClient.php index 55e5c5b7..d5ac099b 100644 --- a/src/LaunchDarkly/LDClient.php +++ b/src/LaunchDarkly/LDClient.php @@ -59,7 +59,7 @@ class LDClient * @param string $sdkKey The SDK key for your account * @param array $options Client configuration settings * - `base_uri`: Base URI of the LaunchDarkly service. Change this if you are connecting to a Relay Proxy instance instead of - * directly to LaunchDarkly. + * directly to LaunchDarkly. To learn more, read [The Relay Proxy](https://docs.launchdarkly.com/home/relay-proxy). * - `events_uri`: Base URI for sending events to LaunchDarkly. Change this if you are forwarding events through a Relay Proxy instance. * - `timeout`: The maximum length of an HTTP request in seconds. Defaults to 3. * - `connect_timeout`: The maximum number of seconds to wait while trying to connect to a server. Defaults to 3.