Skip to content

Commit

Permalink
Bump to PHP 8.1 (#30)
Browse files Browse the repository at this point in the history
* Move to PHP 8.1

* Add getAllValueDetails()
  • Loading branch information
z4kn4fein authored Mar 15, 2023
1 parent a60c323 commit 146a236
Show file tree
Hide file tree
Showing 42 changed files with 297 additions and 384 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/php-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: [ '7.1', '7.2', '7.3', '7.4', '8.0', '8.1' ]
php-versions: [ '8.1', '8.2' ]
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.1'
extensions: xdebug

- name: Validate composer.json and composer.lock
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
php-version: '8.1'

- name: Validate composer.json and composer.lock
run: composer validate --strict
Expand Down
1 change: 1 addition & 0 deletions .phpunit.result.cache
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":1,"defects":{"ConfigCat\\Tests\\ConfigCatClientTest::testConstructLoggerOption":6,"ConfigCat\\Tests\\ConfigCatClientTest::testConstructCacheOption":6,"ConfigCat\\Tests\\ConfigCatClientTest::testConstructCacheRefreshIntervalOption":6,"ConfigCat\\Tests\\ConfigCatClientTest::testGetValueFailedFetch":4,"ConfigCat\\Tests\\ConfigCatClientTest::testGetAllKeysFailedFetch":4,"ConfigCat\\Tests\\ConfigCatClientTest::testForceRefresh":4,"ConfigCat\\Tests\\ConfigCatClientTest::testKeyNotExist":4,"ConfigCat\\Tests\\ConfigCatClientTest::testGetVariationId":4,"ConfigCat\\Tests\\ConfigCatClientTest::testGetVariationIdDefault":4,"ConfigCat\\Tests\\ConfigCatClientTest::testGetAllVariationIds":4,"ConfigCat\\Tests\\ConfigCatClientTest::testGetAllVariationIdsEmpty":4,"ConfigCat\\Tests\\ConfigCatClientTest::testGetKeyAndValue":4,"ConfigCat\\Tests\\ConfigCatClientTest::testGetKeyAndValueNull":4,"ConfigCat\\Tests\\ConfigCatClientTest::testGetAllValues":4,"ConfigCat\\Tests\\ConfigCatClientTest::testDefaultUser":4,"ConfigCat\\Tests\\ConfigCatClientTest::testInitDefaultUser":4,"ConfigCat\\Tests\\ConfigCatClientTest::testDefaultUserVariationId":4,"ConfigCat\\Tests\\ConfigCatClientTest::testOfflineOnline":4,"ConfigCat\\Tests\\ConfigCatClientTest::testInitOfflineOnline":4,"ConfigCat\\Tests\\ConfigCatClientTest::testHooks":4,"ConfigCat\\Tests\\ConfigCatClientTest::testEvalDetails":4,"ConfigCat\\Tests\\ConfigCatClientTest::testEvalDetailsHook":4,"ConfigCat\\Tests\\ConfigCatClientTest::testTimeout":4,"ConfigCat\\Tests\\ConfigCatClientTest::testHttpException":4,"ConfigCat\\Tests\\ConfigCatClientTest::testGeneralException":4,"ConfigCat\\Tests\\DataGovernanceTest::testShouldStayOnServer":6,"ConfigCat\\Tests\\DataGovernanceTest::testShouldStayOnSameUrlWithRedirect":6,"ConfigCat\\Tests\\DataGovernanceTest::testShouldStayOnSameUrlEvenWhenForced":6,"ConfigCat\\Tests\\DataGovernanceTest::testShouldRedirectToAnotherServer":6,"ConfigCat\\Tests\\DataGovernanceTest::testShouldRedirectToAnotherServerWhenForced":6,"ConfigCat\\Tests\\DataGovernanceTest::testShouldRedirectToAnotherServerWhenWrongIsCached":6,"ConfigCat\\Tests\\DataGovernanceTest::testShouldBreakRedirectLoop":6,"ConfigCat\\Tests\\DataGovernanceTest::testShouldBreakRedirectLoopWhenForced":6,"ConfigCat\\Tests\\DataGovernanceTest::testShouldRespectCustomUrlWhenNotForced":6,"ConfigCat\\Tests\\DataGovernanceTest::testShouldNotRespectCustomUrlWhenForced":6,"ConfigCat\\Tests\\LocalSourceTest::testWithFile":4,"ConfigCat\\Tests\\LocalSourceTest::testWithFile_Rules":4,"ConfigCat\\Tests\\LocalSourceTest::testWithSimpleFile":4,"ConfigCat\\Tests\\LocalSourceTest::testWithArraySource":4,"ConfigCat\\Tests\\LocalSourceTest::testLocalOverRemote":4,"ConfigCat\\Tests\\LocalSourceTest::testRemoteOverLocal":4,"ConfigCat\\Tests\\LocalSourceTest::testLocalOnlyIgnoresFetched":4,"ConfigCat\\Tests\\LoggerTest::testClientNoLog":4,"ConfigCat\\Tests\\RolloutIntegrationsTest::testRolloutIntegration with data set #0":4,"ConfigCat\\Tests\\RolloutIntegrationsTest::testRolloutIntegration with data set #1":4,"ConfigCat\\Tests\\RolloutIntegrationsTest::testRolloutIntegration with data set #2":4,"ConfigCat\\Tests\\RolloutIntegrationsTest::testRolloutIntegration with data set #3":4,"ConfigCat\\Tests\\RolloutIntegrationsTest::testRolloutIntegration with data set #4":4,"ConfigCat\\Tests\\RolloutIntegrationsTest::testRolloutIntegration with data set #5":4},"times":{"ConfigCat\\Tests\\ConfigCatClientTest::testConstructEmptySdkKey":0.003,"ConfigCat\\Tests\\ConfigCatClientTest::testConstructDefaults":0.009,"ConfigCat\\Tests\\ConfigCatClientTest::testConstructLoggerOption":0.001,"ConfigCat\\Tests\\ConfigCatClientTest::testConstructCacheOption":0,"ConfigCat\\Tests\\ConfigCatClientTest::testConstructCacheRefreshIntervalOption":0,"ConfigCat\\Tests\\ConfigCatClientTest::testGetValueFailedFetch":0.006,"ConfigCat\\Tests\\ConfigCatClientTest::testGetAllKeysFailedFetch":0.001,"ConfigCat\\Tests\\ConfigCatClientTest::testForceRefresh":0.097,"ConfigCat\\Tests\\ConfigCatClientTest::testKeyNotExist":0.08,"ConfigCat\\Tests\\ConfigCatClientTest::testGetVariationId":0.001,"ConfigCat\\Tests\\ConfigCatClientTest::testGetVariationIdDefault":0,"ConfigCat\\Tests\\ConfigCatClientTest::testGetAllVariationIds":0,"ConfigCat\\Tests\\ConfigCatClientTest::testGetAllVariationIdsEmpty":0,"ConfigCat\\Tests\\ConfigCatClientTest::testGetKeyAndValue":0.001,"ConfigCat\\Tests\\ConfigCatClientTest::testGetKeyAndValueNull":0,"ConfigCat\\Tests\\ConfigCatClientTest::testGetAllValues":0,"ConfigCat\\Tests\\ConfigCatClientTest::testDefaultUser":0.001,"ConfigCat\\Tests\\ConfigCatClientTest::testInitDefaultUser":0,"ConfigCat\\Tests\\ConfigCatClientTest::testDefaultUserVariationId":0,"ConfigCat\\Tests\\ConfigCatClientTest::testOfflineOnline":0.001,"ConfigCat\\Tests\\ConfigCatClientTest::testInitOfflineOnline":0,"ConfigCat\\Tests\\ConfigCatClientTest::testHooks":0.001,"ConfigCat\\Tests\\ConfigCatClientTest::testEvalDetails":0,"ConfigCat\\Tests\\ConfigCatClientTest::testEvalDetailsHook":0,"ConfigCat\\Tests\\ConfigCatClientTest::testTimeout":0.001,"ConfigCat\\Tests\\ConfigCatClientTest::testHttpException":0.001,"ConfigCat\\Tests\\ConfigCatClientTest::testGeneralException":0,"ConfigCat\\Tests\\ConfigFetcherTest::testFetchOk":0,"ConfigCat\\Tests\\ConfigFetcherTest::testFetchNotModified":0,"ConfigCat\\Tests\\ConfigFetcherTest::testFetchFailed":0.001,"ConfigCat\\Tests\\ConfigFetcherTest::testFetchInvalidJson":0,"ConfigCat\\Tests\\ConfigFetcherTest::testConstructEmptySdkKey":0,"ConfigCat\\Tests\\ConfigFetcherTest::testConstructDefaults":0,"ConfigCat\\Tests\\ConfigFetcherTest::testConstructConnectTimeoutOption":0,"ConfigCat\\Tests\\ConfigFetcherTest::testConstructRequestTimeoutOption":0,"ConfigCat\\Tests\\ConfigFetcherTest::testTimeoutException":0,"ConfigCat\\Tests\\ConfigFetcherTest::testIntegration":0.108,"ConfigCat\\Tests\\DataGovernanceTest::testShouldStayOnServer":0.001,"ConfigCat\\Tests\\DataGovernanceTest::testShouldStayOnSameUrlWithRedirect":0,"ConfigCat\\Tests\\DataGovernanceTest::testShouldStayOnSameUrlEvenWhenForced":0,"ConfigCat\\Tests\\DataGovernanceTest::testShouldRedirectToAnotherServer":0.001,"ConfigCat\\Tests\\DataGovernanceTest::testShouldRedirectToAnotherServerWhenForced":0.001,"ConfigCat\\Tests\\DataGovernanceTest::testShouldRedirectToAnotherServerWhenWrongIsCached":0.001,"ConfigCat\\Tests\\DataGovernanceTest::testShouldBreakRedirectLoop":0.001,"ConfigCat\\Tests\\DataGovernanceTest::testShouldBreakRedirectLoopWhenForced":0.001,"ConfigCat\\Tests\\DataGovernanceTest::testShouldRespectCustomUrlWhenNotForced":0,"ConfigCat\\Tests\\DataGovernanceTest::testShouldNotRespectCustomUrlWhenForced":0.001,"ConfigCat\\Tests\\LocalSourceTest::testWithNonExistingFile":0.001,"ConfigCat\\Tests\\LocalSourceTest::testWithInvalidBehavior":0,"ConfigCat\\Tests\\LocalSourceTest::testWithFile":0,"ConfigCat\\Tests\\LocalSourceTest::testWithFile_Rules":0,"ConfigCat\\Tests\\LocalSourceTest::testWithSimpleFile":0,"ConfigCat\\Tests\\LocalSourceTest::testWithArraySource":0,"ConfigCat\\Tests\\LocalSourceTest::testLocalOverRemote":0,"ConfigCat\\Tests\\LocalSourceTest::testRemoteOverLocal":0,"ConfigCat\\Tests\\LocalSourceTest::testLocalOnlyIgnoresFetched":0,"ConfigCat\\Tests\\LoggerTest::testLoggerBypassesInternalLogicWhenGlobalLevelIsZero":0.001,"ConfigCat\\Tests\\LoggerTest::testLoggerLogOnlyHigherLevelThanDebug":0.001,"ConfigCat\\Tests\\LoggerTest::testLoggerLogOnlyHigherLevelThanInfo":0.001,"ConfigCat\\Tests\\LoggerTest::testLoggerLogOnlyHigherLevelThanNotice":0,"ConfigCat\\Tests\\LoggerTest::testLoggerLogOnlyHigherLevelThanWarning":0,"ConfigCat\\Tests\\LoggerTest::testLoggerLogOnlyHigherLevelThanError":0,"ConfigCat\\Tests\\LoggerTest::testLoggerLogOnlyHigherLevelThanCritical":0,"ConfigCat\\Tests\\LoggerTest::testLoggerLogOnlyHigherLevelThanAlert":0,"ConfigCat\\Tests\\LoggerTest::testLoggerNoLog":0,"ConfigCat\\Tests\\LoggerTest::testClientNoLog":0.064,"ConfigCat\\Tests\\LoggerTest::testLoggerBypassesLogWhenExceptionIsIgnored":0.001,"ConfigCat\\Tests\\RolloutIntegrationsTest::testRolloutIntegration with data set #0":0.722,"ConfigCat\\Tests\\RolloutIntegrationsTest::testRolloutIntegration with data set #1":0.112,"ConfigCat\\Tests\\RolloutIntegrationsTest::testRolloutIntegration with data set #2":0.078,"ConfigCat\\Tests\\RolloutIntegrationsTest::testRolloutIntegration with data set #3":0.172,"ConfigCat\\Tests\\RolloutIntegrationsTest::testRolloutIntegration with data set #4":0.074,"ConfigCat\\Tests\\RolloutIntegrationsTest::testRolloutIntegration with data set #5":0.075,"ConfigCat\\Tests\\UserTest::testConstructEmptyIdentifier":0,"ConfigCat\\Tests\\UserTest::testGetAttributeEmptyKey":0}}
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ ConfigCat is a <a href="https://configcat.com" target="_blank">hosted feature fl
[![Total Downloads](https://poser.pugx.org/configcat/configcat-client/downloads)](https://packagist.org/packages/configcat/configcat-client)
[![Latest Unstable Version](https://poser.pugx.org/configcat/configcat-client/v/unstable)](https://packagist.org/packages/configcat/configcat-client)

## Requirements
- PHP >= 8.1

ConfigCat SDK for PHP >= 7.1 is available [here](https://github.com/configcat/php7-sdk).

## Getting started

### 1. Install the package with [Composer](https://getcomposer.org/)
Expand Down
17 changes: 11 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
}
],
"require": {
"php": ">=7.1",
"php": ">=8.1",
"guzzlehttp/guzzle": "^6.3|^7.0",
"psr/log": "^1.1",
"psr/log": "^2.0|^3.0",
"ext-json": "*",
"monolog/monolog": "^1.6|^2.0",
"monolog/monolog": "2.0|^3.0",
"z4kn4fein/php-semver": "^2.0"
},
"require-dev": {
"phpunit/phpunit": "~7.0|^8",
"illuminate/cache": "^5.0",
"psr/simple-cache": "^1.0",
"illuminate/cache": "^9.0",
"psr/simple-cache": "^3.0",
"psr/cache": "^1.0",
"squizlabs/php_codesniffer": "3.5.1"
"squizlabs/php_codesniffer": "^3.7"
},
"autoload": {
"psr-4": {
Expand All @@ -41,5 +41,10 @@
"psr/cache": "When using any PSR6 Cache implementation, a pre-built cache adapter \\ConfigCat\\Psr6Cache can be used as the main cache of the library.",
"psr/simple-cache": "When using any PSR16 SimpleCache implementation, a pre-built cache adapter \\ConfigCat\\Psr16Cache can be used as the main cache of the library.",
"laravel/framework": "When using laravel, a pre-built cache adapter \\ConfigCat\\LaravelCache can be used as the main cache of the library."
},
"config": {
"allow-plugins": {
"kylekatarnls/update-helper": false
}
}
}
4 changes: 2 additions & 2 deletions src/Attributes/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
*/
class Config
{
const PREFERENCES = "p";
const ENTRIES = "f";
public const PREFERENCES = "p";
public const ENTRIES = "f";
}
6 changes: 3 additions & 3 deletions src/Attributes/PercentageAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
class PercentageAttributes
{
const VALUE = "v";
const PERCENTAGE = "p";
const VARIATION_ID = "i";
public const VALUE = "v";
public const PERCENTAGE = "p";
public const VARIATION_ID = "i";
}
4 changes: 2 additions & 2 deletions src/Attributes/Preferences.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
*/
class Preferences
{
const BASE_URL = "u";
const REDIRECT = "r";
public const BASE_URL = "u";
public const REDIRECT = "r";
}
10 changes: 5 additions & 5 deletions src/Attributes/RolloutAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/
class RolloutAttributes
{
const VALUE = "v";
const COMPARISON_ATTRIBUTE = "a";
const COMPARATOR = "t";
const COMPARISON_VALUE = "c";
const VARIATION_ID = "i";
public const VALUE = "v";
public const COMPARISON_ATTRIBUTE = "a";
public const COMPARATOR = "t";
public const COMPARISON_VALUE = "c";
public const VARIATION_ID = "i";
}
10 changes: 5 additions & 5 deletions src/Attributes/SettingAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/
class SettingAttributes
{
const VALUE = "v";
const TYPE = "t";
const ROLLOUT_PERCENTAGE_ITEMS = "p";
const ROLLOUT_RULES = "r";
const VARIATION_ID = "i";
public const VALUE = "v";
public const TYPE = "t";
public const ROLLOUT_PERCENTAGE_ITEMS = "p";
public const ROLLOUT_RULES = "r";
public const VARIATION_ID = "i";
}
7 changes: 3 additions & 4 deletions src/Cache/ArrayCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
*/
final class ArrayCache extends ConfigCache
{
/** @var array */
private static $arrayCache = [];
private static array $arrayCache = [];

/**
* Reads the value identified by the given $key from the underlying cache.
*
* @param string $key Identifier for the cached value.
* @return string|null Cached value for the given key, or null if it's missing.
* @return ?string Cached value for the given key, or null if it's missing.
*/
protected function get(string $key): ?string
{
return array_key_exists($key, self::$arrayCache) ? self::$arrayCache[$key] : null;
return self::$arrayCache[$key] ?? null;
}

/**
Expand Down
16 changes: 8 additions & 8 deletions src/Cache/CacheItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
*/
class CacheItem
{
/** @var int The time the cached entry refreshed. */
public $lastRefreshed = 0;
/** @var string The ETag. */
public $etag;
/** @var array The cached JSON configuration. */
public $config;
/** @var string The url pointing to the proper cdn server. */
public $url;
/** The time the cached entry refreshed. */
public int $lastRefreshed = 0;
/** The ETag. */
public ?string $etag = null;
/** The cached JSON configuration. */
public array $config;
/** The url pointing to the proper cdn server. */
public ?string $url = null;
}
5 changes: 2 additions & 3 deletions src/Cache/ConfigCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
*/
abstract class ConfigCache implements LoggerAwareInterface
{
/** @var LoggerInterface */
private $logger;
private LoggerInterface $logger;

/**
* Reads the value identified by the given $key from the underlying cache.
Expand Down Expand Up @@ -58,7 +57,7 @@ public function store(string $key, CacheItem $value): void
* Reads the value identified by the given $key from the underlying cache.
*
* @param string $key Identifier for the cached value.
* @return CacheItem|null Cached value for the given key, or null if it's missing.
* @return ?CacheItem Cached value for the given key, or null if it's missing.
*
* @throws InvalidArgumentException
* If the $key is not a legal value.
Expand Down
8 changes: 2 additions & 6 deletions src/Cache/LaravelCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@

class LaravelCache extends ConfigCache
{
/** @var Repository */
private $cache;

public function __construct(Repository $cache)
public function __construct(private readonly Repository $cache)
{
$this->cache = $cache;
}

/**
* Reads the value identified by the given $key from the underlying cache.
*
* @param string $key Identifier for the cached value.
* @return string|null Cached value for the given key, or null if it's missing.
* @return ?string Cached value for the given key, or null if it's missing.
*
* @throws InvalidArgumentException If the $key is not a legal value.
*/
Expand Down
8 changes: 2 additions & 6 deletions src/Cache/Psr16Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@

class Psr16Cache extends ConfigCache
{
/** @var CacheInterface */
private $cache;

public function __construct(CacheInterface $cache)
public function __construct(private readonly CacheInterface $cache)
{
$this->cache = $cache;
}

/**
* Reads the value identified by the given $key from the underlying cache.
*
* @param string $key Identifier for the cached value.
* @return string|null Cached value for the given key, or null if it's missing.
* @return ?string Cached value for the given key, or null if it's missing.
*
* @throws InvalidArgumentException If the $key is not a legal value.
*/
Expand Down
7 changes: 2 additions & 5 deletions src/Cache/Psr6Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@

class Psr6Cache extends ConfigCache
{
/** @var CacheItemPoolInterface */
private $cachePool;

public function __construct(CacheItemPoolInterface $cachePool)
public function __construct(private readonly CacheItemPoolInterface $cachePool)
{
$this->cachePool = $cachePool;
}

/**
* Reads the value identified by the given $key from the underlying cache.
*
* @param string $key Identifier for the cached value.
* @return string|null Cached value for the given key, or null if it's missing.
* @return ?string Cached value for the given key, or null if it's missing.
*
* @throws InvalidArgumentException If the $key is not a legal value.
*/
Expand Down
Loading

0 comments on commit 146a236

Please sign in to comment.