Skip to content

Commit

Permalink
Chore: Make php 8.3 the main version (#203)
Browse files Browse the repository at this point in the history
  • Loading branch information
RikudouSage committed May 3, 2024
1 parent 783f84b commit 477bb2f
Show file tree
Hide file tree
Showing 19 changed files with 83 additions and 64 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/code-coverage.yml
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3
- name: Checkout Code
uses: actions/checkout@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Expand Up @@ -38,7 +38,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.2', '7.3', '7.4', '8.0', '8.1']
version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
steps:
- name: Extract Version Name
id: extract_name
Expand All @@ -50,7 +50,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3
- name: Checkout Code
uses: actions/checkout@v4
- name: Install Dependencies
Expand All @@ -65,7 +65,7 @@ jobs:
if: matrix.version == '7.2'
run: composer require symfony/polyfill-php73:^1.0
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.2"/"php": "\^${{ matrix.version }}"/'' composer.json'
run: 'sed -i -e ''s/"php": "\^8.3"/"php": "\^${{ matrix.version }}"/'' composer.json'
- name: Downgrade phpunit
if: matrix.version == '7.2'
run: 'sed -i -e ''s/"phpunit\/phpunit": "\^9.5"/"phpunit\/phpunit": "\^8.5"/'' composer.json'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-8.x.yaml
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['8.0', '8.1']
version: ['8.0', '8.1', '8.2']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/tests.yaml
@@ -1,4 +1,4 @@
name: Tests (8.2)
name: Tests (8.3)
on:
push:
branches:
Expand All @@ -14,7 +14,7 @@ jobs:
PHP_CS_FIXER_IGNORE_ENV: 1
strategy:
matrix:
version: ['8.2']
version: ['8.3']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -31,7 +31,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['8.2']
version: ['8.3']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -48,7 +48,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['8.2']
version: ['8.3']
optional-deps: ['', 'cache/filesystem-adapter:^1.1']
steps:
- name: Setup PHP
Expand All @@ -73,12 +73,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.2', '7.3', '7.4', '8.0', '8.1']
version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
steps:
- name: Setup Build PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3
- name: Checkout Code
uses: actions/checkout@v4
with:
Expand All @@ -91,7 +91,7 @@ jobs:
if: matrix.version == '7.2'
run: composer require symfony/polyfill-php73:^1.0
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.2"/"php": "\^${{ matrix.version }}"/'' composer.json'
run: 'sed -i -e ''s/"php": "\^8.3"/"php": "\^${{ matrix.version }}"/'' composer.json'
- name: Downgrade phpunit
if: matrix.version == '7.2'
run: 'sed -i -e ''s/"phpunit\/phpunit": "\^9.5"/"phpunit\/phpunit": "\^8.5"/'' composer.json'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/transpile.yaml
Expand Up @@ -11,12 +11,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.2', '7.3', '7.4', '8.0', '8.1']
version: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
php-version: 8.3
- name: Checkout Code
uses: actions/checkout@v4
- name: Install Dependencies
Expand All @@ -27,7 +27,7 @@ jobs:
if: matrix.version == '7.2'
run: composer require symfony/polyfill-php73:^1.0
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.2"/"php": "\^${{ matrix.version }}"/'' composer.json'
run: 'sed -i -e ''s/"php": "\^8.3"/"php": "\^${{ matrix.version }}"/'' composer.json'
- name: Downgrade phpunit
if: matrix.version == '7.2'
run: 'sed -i -e ''s/"phpunit\/phpunit": "\^9.5"/"phpunit\/phpunit": "\^8.5"/'' composer.json'
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Expand Up @@ -10,7 +10,7 @@
],
"minimum-stability": "stable",
"require": {
"php": "^8.2",
"php": "^8.3",
"ext-json": "*",
"psr/http-client": "^1.0",
"psr/http-client-implementation": "^1.0",
Expand All @@ -34,7 +34,7 @@
"friendsofphp/php-cs-fixer": "^3.0",
"phpstan/phpstan": "^1.2",
"jetbrains/phpstorm-attributes": "^1.0",
"rector/rector": "^0.14.8",
"rector/rector": "^1.0",
"phpunit/phpunit": "^9.5",
"symfony/http-client": "^5.0 | ^6.0 | ^7.0",
"nyholm/psr7": "^1.0",
Expand Down
10 changes: 10 additions & 0 deletions rector.82.php
@@ -0,0 +1,10 @@
<?php

use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\DowngradeLevelSetList;

return static function (RectorConfig $config): void {
$config->sets([
DowngradeLevelSetList::DOWN_TO_PHP_82,
]);
};
Expand Up @@ -9,7 +9,7 @@
*/
abstract class AbstractVersionOperatorValidator extends AbstractOperatorValidator
{
private const REGEX = '@^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$@';
private const string REGEX = '@^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$@';

protected function acceptsValues(array|string $values): bool
{
Expand Down
8 changes: 4 additions & 4 deletions src/Enum/CacheKey.php
Expand Up @@ -7,11 +7,11 @@
*/
final class CacheKey
{
public const METRICS_BUCKET = 'unleash.client.metrics.bucket';
public const string METRICS_BUCKET = 'unleash.client.metrics.bucket';

public const FEATURES = 'unleash.client.feature.list';
public const string FEATURES = 'unleash.client.feature.list';

public const REGISTRATION = 'unleash.client.metrics.registration';
public const string REGISTRATION = 'unleash.client.metrics.registration';

public const FEATURES_RESPONSE = 'unleash.client.feature.response';
public const string FEATURES_RESPONSE = 'unleash.client.feature.response';
}
34 changes: 17 additions & 17 deletions src/Enum/ConstraintOperator.php
Expand Up @@ -8,43 +8,43 @@ final class ConstraintOperator
{
// legacy
#[Deprecated('Please use IN_LIST constant')]
public const IN = self::IN_LIST;
public const string IN = self::IN_LIST;

#[Deprecated('Please use NOT_IN_LIST constant')]
public const NOT_IN = self::NOT_IN_LIST;
public const string NOT_IN = self::NOT_IN_LIST;

// list
public const IN_LIST = 'IN';
public const string IN_LIST = 'IN';

public const NOT_IN_LIST = 'NOT_IN';
public const string NOT_IN_LIST = 'NOT_IN';

// string
public const STRING_STARTS_WITH = 'STR_STARTS_WITH';
public const string STRING_STARTS_WITH = 'STR_STARTS_WITH';

public const STRING_ENDS_WITH = 'STR_ENDS_WITH';
public const string STRING_ENDS_WITH = 'STR_ENDS_WITH';

public const STRING_CONTAINS = 'STR_CONTAINS';
public const string STRING_CONTAINS = 'STR_CONTAINS';

// number
public const NUMBER_EQUALS = 'NUM_EQ';
public const string NUMBER_EQUALS = 'NUM_EQ';

public const NUMBER_GREATER_THAN = 'NUM_GT';
public const string NUMBER_GREATER_THAN = 'NUM_GT';

public const NUMBER_GREATER_THAN_OR_EQUALS = 'NUM_GTE';
public const string NUMBER_GREATER_THAN_OR_EQUALS = 'NUM_GTE';

public const NUMBER_LOWER_THAN = 'NUM_LT';
public const string NUMBER_LOWER_THAN = 'NUM_LT';

public const NUMBER_LOWER_THAN_OR_EQUALS = 'NUM_LTE';
public const string NUMBER_LOWER_THAN_OR_EQUALS = 'NUM_LTE';

// date
public const DATE_AFTER = 'DATE_AFTER';
public const string DATE_AFTER = 'DATE_AFTER';

public const DATE_BEFORE = 'DATE_BEFORE';
public const string DATE_BEFORE = 'DATE_BEFORE';

// versions
public const VERSION_EQUALS = 'SEMVER_EQ';
public const string VERSION_EQUALS = 'SEMVER_EQ';

public const VERSION_GREATER_THAN = 'SEMVER_GT';
public const string VERSION_GREATER_THAN = 'SEMVER_GT';

public const VERSION_LOWER_THAN = 'SEMVER_LT';
public const string VERSION_LOWER_THAN = 'SEMVER_LT';
}
14 changes: 7 additions & 7 deletions src/Enum/ContextField.php
Expand Up @@ -4,17 +4,17 @@

final class ContextField
{
public const USER_ID = 'userId';
public const string USER_ID = 'userId';

public const SESSION_ID = 'sessionId';
public const string SESSION_ID = 'sessionId';

public const IP_ADDRESS = 'remoteAddress';
public const string IP_ADDRESS = 'remoteAddress';

public const ENVIRONMENT = 'environment';
public const string ENVIRONMENT = 'environment';

public const REMOTE_ADDRESS = self::IP_ADDRESS;
public const string REMOTE_ADDRESS = self::IP_ADDRESS;

public const HOSTNAME = 'hostname';
public const string HOSTNAME = 'hostname';

public const CURRENT_TIME = 'currentTime';
public const string CURRENT_TIME = 'currentTime';
}
4 changes: 2 additions & 2 deletions src/Enum/ImpressionDataEventType.php
Expand Up @@ -4,7 +4,7 @@

final class ImpressionDataEventType
{
public const IS_ENABLED = 'isEnabled';
public const string IS_ENABLED = 'isEnabled';

public const GET_VARIANT = 'getVariant';
public const string GET_VARIANT = 'getVariant';
}
8 changes: 4 additions & 4 deletions src/Enum/Stickiness.php
Expand Up @@ -4,11 +4,11 @@

final class Stickiness
{
public const USER_ID = 'userid';
public const string USER_ID = 'userid';

public const SESSION_ID = 'sessionid';
public const string SESSION_ID = 'sessionid';

public const RANDOM = 'random';
public const string RANDOM = 'random';

public const DEFAULT = 'default';
public const string DEFAULT = 'default';
}
6 changes: 3 additions & 3 deletions src/Enum/VariantPayloadType.php
Expand Up @@ -4,9 +4,9 @@

final class VariantPayloadType
{
public const STRING = 'string';
public const string STRING = 'string';

public const JSON = 'json';
public const string JSON = 'json';

public const CSV = 'csv';
public const string CSV = 'csv';
}
10 changes: 5 additions & 5 deletions src/Event/UnleashEvents.php
Expand Up @@ -9,33 +9,33 @@ final class UnleashEvents
*
* @Event("Unleash\Client\Event\FeatureToggleNotFoundEvent")
*/
public const FEATURE_TOGGLE_NOT_FOUND = 'unleash.event.toggle.not_found';
public const string FEATURE_TOGGLE_NOT_FOUND = 'unleash.event.toggle.not_found';

/**
* Triggered when a feature toggle is disabled.
*
* @Event("Unleash\Client\Event\FeatureToggleDisabledEvent")
*/
public const FEATURE_TOGGLE_DISABLED = 'unleash.event.toggle.disabled';
public const string FEATURE_TOGGLE_DISABLED = 'unleash.event.toggle.disabled';

/**
* Triggered when no strategy handler has been found for the feature.
*
* @Event("Unleash\Client\Event\FeatureToggleMissingStrategyHandlerEvent")
*/
public const FEATURE_TOGGLE_MISSING_STRATEGY_HANDLER = 'unleash.event.toggle.missing_strategy_handler';
public const string FEATURE_TOGGLE_MISSING_STRATEGY_HANDLER = 'unleash.event.toggle.missing_strategy_handler';

/**
* Triggered when fetching features from server fails.
*
* @Event("Unleash\Client\Event\FetchingDataFailedEvent")
*/
public const FETCHING_DATA_FAILED = 'unleash.event.server.fetching_failed';
public const string FETCHING_DATA_FAILED = 'unleash.event.server.fetching_failed';

/**
* Triggered when feature has impression data enabled.
*
* @Event("Unleash\Client\Event\ImpressionDataEvent")
*/
public const IMPRESSION_DATA = 'unleash.events.impression_data';
public const string IMPRESSION_DATA = 'unleash.events.impression_data';
}
4 changes: 4 additions & 0 deletions src/Helper/StringStream.php
Expand Up @@ -83,9 +83,13 @@ public function tell(): int
throw new StreamException('The stream is detached');
}
$tell = ftell($this->stream);

// this doesn't happen anymore in php 8.3, but is kept here for older versions
// @codeCoverageIgnoreStart
if ($tell === false) {
throw new StreamException('Could not retrieve stream position. Is the stream after EOF?');
}
// @codeCoverageIgnoreEnd

return $tell;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Unleash.php
Expand Up @@ -7,7 +7,7 @@

interface Unleash
{
public const SDK_VERSION = '2.4.0';
public const string SDK_VERSION = '2.4.0';

public function isEnabled(string $featureName, ?Context $context = null, bool $default = false): bool;

Expand Down
2 changes: 1 addition & 1 deletion src/Variant/DefaultVariantHandler.php
Expand Up @@ -11,7 +11,7 @@

final readonly class DefaultVariantHandler implements VariantHandler
{
private const VARIANT_HASH_SEED = 86028157;
private const int VARIANT_HASH_SEED = 86028157;

public function __construct(
private StickinessCalculator $stickinessCalculator,
Expand Down
9 changes: 7 additions & 2 deletions tests/Helper/StringStreamTest.php
Expand Up @@ -36,8 +36,13 @@ public function testTell()
$this->instance->seek(11);
self::assertEquals(11, $this->instance->tell());
$this->instance->seek(12);
$this->expectException(StreamException::class);
$this->instance->tell();

if (PHP_VERSION_ID < 80300) {
$this->expectException(StreamException::class);
$this->instance->tell();
} else {
self::assertSame(12, $this->instance->tell());
}
}

public function testClose()
Expand Down

0 comments on commit 477bb2f

Please sign in to comment.