Skip to content

Chore: Update codebase to php 8.2 #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 58 additions & 42 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ on:
workflow_dispatch:

jobs:
build:
release_latest:
name: Release latest PHP version
runs-on: ubuntu-latest
steps:
- name: Extract Version Name
Expand All @@ -20,69 +21,84 @@ jobs:
return context.payload.ref.replace(/refs\/tags\/release-/, '');
- name: Checkout Code
uses: actions/checkout@v2
- name: Create PHP 8 release tag
- name: Check if version is updated in SDK
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: git tag v${VERSION}80
- name: Push PHP 8 release tag
run: php tests/check-version.php $VERSION
- name: Create latest release tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: git push origin v${VERSION}80

- name: Install Dependencies
run: composer install
- name: Transpile 7.3
run: php vendor/bin/rector process --no-diffs --no-progress-bar --config rector.73.php src
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.0"/"php": "\^7.3"/'' composer.json'
- name: Commit PHP 7.3 version
run: |
git config --global --add safe.directory /github/workspace && \
git config user.email noreply@github.com && \
git config user.name "GitHub Actions" && \
git checkout -b tmp-php-7.3-release && \
git add . -v && \
git commit -m "Transpile to PHP 7.3" && \
git push origin tmp-php-7.3-release
- name: Create PHP 7.3 release tag
run: git tag v${VERSION}82
- name: Push latest release tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: git tag v${VERSION}73
- name: Push PHP 7.3 release tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: git push origin v${VERSION}73
- name: Delete temporary branch
run: git push origin --delete tmp-php-7.3-release

run: git push origin v${VERSION}82
release_older:
name: Release older PHP version
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.3', '7.4', '8.0', '8.1']
steps:
- name: Extract Version Name
id: extract_name
uses: actions/github-script@v4
with:
result-encoding: string
script: |
return context.payload.ref.replace(/refs\/tags\/release-/, '');
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.2
- name: Checkout Code
uses: actions/checkout@v2
- name: Install Dependencies
run: composer install
- name: Transpile 7.4
run: php vendor/bin/rector process --no-diffs --no-progress-bar --config rector.74.php src
- name: Check if version is updated in SDK
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: php tests/check-version.php $VERSION
- name: Transpile ${{ matrix.version }}
run: php vendor/bin/rector process --no-diffs --no-progress-bar --config rector.$(echo ${{ matrix.version }} | sed -e 's/\.//').php src
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.0"/"php": "\^7.4"/'' composer.json'
- name: Commit PHP 7.4 version
run: 'sed -i -e ''s/"php": "\^8.2"/"php": "\^${{ matrix.version }}"/'' composer.json'
- name: Commit PHP ${{ matrix.version }} version
run: |
git config --global --add safe.directory /github/workspace && \
git config user.email noreply@github.com && \
git config user.name "GitHub Actions" && \
git checkout -b tmp-php-7.4-release && \
git checkout -b tmp-php-${{ matrix.version }}-release && \
git add . -v && \
git commit -m "Transpile to PHP 7.4" && \
git push origin tmp-php-7.4-release
- name: Create PHP 7.4 release tag
git commit -m "Transpile to PHP ${{ matrix.version }}" && \
git push origin tmp-php-${{ matrix.version }}-release
- name: Create PHP ${{ matrix.version }} release tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: git tag v${VERSION}74
- name: Push PHP 7.4 release tag
run: git tag v${VERSION}$(echo ${{ matrix.version }} | sed -e 's/\.//')
- name: Push PHP ${{ matrix.version }} release tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
run: git push origin v${VERSION}74
run: git push origin v${VERSION}$(echo ${{ matrix.version }} | sed -e 's/\.//')
- name: Delete temporary branch
run: git push origin --delete tmp-php-7.4-release
run: git push origin --delete tmp-php-${{ matrix.version }}-release

delete_tag:
name: Delete original tag
runs-on: ubuntu-latest
needs:
- release_latest
- release_older
steps:
- name: Extract Version Name
id: extract_name
uses: actions/github-script@v4
with:
result-encoding: string
script: |
return context.payload.ref.replace(/refs\/tags\/release-/, '');
- name: Checkout Code
uses: actions/checkout@v2
- name: Delete original tag
env:
VERSION: ${{ steps.extract_name.outputs.result }}
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/tests-8.x.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Tests (8.x)
on:
repository_dispatch:
types:
- trigger-8x-tests

jobs:
tests:
name: Tests
runs-on: ubuntu-latest
strategy:
matrix:
version: ['8.0', '8.1']
steps:
- name: TBD
run: echo 'To be done'
# - name: Setup PHP
# uses: shivammathur/setup-php@v2
# with:
# php-version: ${{ matrix.version }}
# - name: Checkout Code
# uses: actions/checkout@v2
# with:
# ref: php-${{ matrix.version }}
# submodules: true
# - name: Install Dependencies
# run: composer install
# - name: Run tests
# run: composer phpunit
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['8.0']
version: ['8.2']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -29,7 +29,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['8.0']
version: ['8.2']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
68 changes: 21 additions & 47 deletions .github/workflows/transpile.yaml
Original file line number Diff line number Diff line change
@@ -1,79 +1,53 @@
name: Transpile to 7.x
name: Transpile to older versions
on:
push:
branches:
- main
workflow_dispatch:

jobs:
transpile_73:
name: Transpile to PHP 7.3
transpile:
name: Transpile to older versions of PHP
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.3', '7.4', '8.0', '8.1']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.2
- name: Checkout Code
uses: actions/checkout@v2
with:
ref: main
- name: Install Dependencies
run: composer install
- name: Transpile to 7.3
run: php vendor/bin/rector process --no-diffs --no-progress-bar --config rector.73.php src
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.0"/"php": "\^7.3"/'' composer.json'
- name: Update README
run: sed -i '1s/^/# This branch is auto generated\n/' README.md
- name: Commit PHP 7.3 version
uses: actions-x/commit@v6
with:
files: .
branch: php-7.3
name: GitHub Actions
email: noreply@github.com
message: Transpiled to PHP 7.3
force: true
transpile_74:
name: Transpile to PHP 7.4
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
- name: Checkout Code
uses: actions/checkout@v2
with:
ref: main
- name: Install Dependencies
run: composer install
- name: Transpile to 7.4
run: php vendor/bin/rector process --no-diffs --no-progress-bar --config rector.74.php src
- name: Transpile to ${{ matrix.version }}
run: php vendor/bin/rector process --no-diffs --no-progress-bar --config rector.$(echo ${{ matrix.version }} | sed -e 's/\.//').php src
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.0"/"php": "\^7.4"/'' composer.json'
run: 'sed -i -e ''s/"php": "\^8.2"/"php": "\^${{ matrix.version }}"/'' composer.json'
- name: Update README
run: sed -i '1s/^/# This branch is auto generated\n/' README.md
- name: Commit PHP 7.4 version
- name: Commit PHP ${{ matrix.version }} version
uses: actions-x/commit@v6
with:
files: .
branch: php-7.4
branch: php-${{ matrix.version }}
name: GitHub Actions
email: noreply@github.com
message: Transpiled to PHP 7.4
message: Transpiled to PHP ${{ matrix.version }}
force: true
trigger_7x_tests:
name: Trigger 7.x tests
trigger_tests:
name: Trigger tests
runs-on: ubuntu-latest
needs:
- transpile_73
- transpile_74
- transpile
strategy:
matrix:
version: [7x, 8x]
steps:
- name: Trigger 7.x tests
- name: Trigger ${{ matrix.version }} tests
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_TOKEN }}
event-type: trigger-7x-tests
event-type: trigger-${{ matrix.version }}-tests
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"symfony/cache": "^5.0 | ^6.0",
"nyholm/psr7": "^1.0",
"unleash/client": "^1.6",
"php": "^8.0"
"php": "^8.2"
},
"autoload": {
"psr-4": {
Expand All @@ -22,7 +22,8 @@
"jetbrains/phpstorm-attributes": "^1.0",
"symfony/security-core": "^5.0 | ^6.0",
"symfony/expression-language": "^5.0 | ^6.0",
"twig/twig": "^3.3"
"twig/twig": "^3.3",
"symfony/yaml": "^6.3"
},
"suggest": {
"symfony/security-bundle": "For integration of Symfony users into Unleash context",
Expand Down
Empty file modified rector.73.php
100644 → 100755
Empty file.
Empty file modified rector.74.php
100644 → 100755
Empty file.
10 changes: 10 additions & 0 deletions rector.80.php
Original file line number Diff line number Diff line change
@@ -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_80,
]);
};
10 changes: 10 additions & 0 deletions rector.81.php
Original file line number Diff line number Diff line change
@@ -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_81,
]);
};
3 changes: 3 additions & 0 deletions src/Attribute/ControllerAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
use JetBrains\PhpStorm\ExpectedValues;
use Symfony\Component\HttpFoundation\Response;

/**
* @todo Make internal in next major
*/
interface ControllerAttribute
{
public function getFeatureName(): string;
Expand Down
3 changes: 3 additions & 0 deletions src/Attribute/IsEnabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use JetBrains\PhpStorm\ExpectedValues;
use Symfony\Component\HttpFoundation\Response;

/**
* @todo Make readonly in next major
*/
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD | Attribute::TARGET_CLASS)]
final class IsEnabled implements ControllerAttribute
{
Expand Down
3 changes: 3 additions & 0 deletions src/Attribute/IsNotEnabled.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
use JetBrains\PhpStorm\ExpectedValues;
use Symfony\Component\HttpFoundation\Response;

/**
* @todo Make readonly in next major
*/
#[Attribute(Attribute::IS_REPEATABLE | Attribute::TARGET_METHOD | Attribute::TARGET_CLASS)]
final class IsNotEnabled implements ControllerAttribute
{
Expand Down
2 changes: 1 addition & 1 deletion src/Context/SymfonyContextProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Unleash\Client\Configuration\Context;
use Unleash\Client\ContextProvider\UnleashContextProvider;

final class SymfonyContextProvider implements UnleashContextProvider
final readonly class SymfonyContextProvider implements UnleashContextProvider
{
public function __construct(
private SymfonyUnleashContext $context
Expand Down
10 changes: 5 additions & 5 deletions src/Context/SymfonyUnleashContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ final class SymfonyUnleashContext implements Context
* @param array<string,string> $customProperties
*/
public function __construct(
private ?TokenStorageInterface $userTokenStorage,
private ?string $userIdField,
private readonly ?TokenStorageInterface $userTokenStorage,
private readonly ?string $userIdField,
private array $customProperties,
private ?RequestStack $requestStack,
private ?ExpressionLanguage $expressionLanguage,
private ?EventDispatcherInterface $eventDispatcher,
private readonly ?RequestStack $requestStack,
private readonly ?ExpressionLanguage $expressionLanguage,
private readonly ?EventDispatcherInterface $eventDispatcher,
private ?string $environment = null,
) {
}
Expand Down
5 changes: 4 additions & 1 deletion src/DependencyInjection/Compiler/BootstrapResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
use Symfony\Component\DependencyInjection\Definition;
use Unleash\Client\Bootstrap\FileBootstrapProvider;

final class BootstrapResolver implements CompilerPassInterface
/**
* @todo Make internal in next major
*/
final readonly class BootstrapResolver implements CompilerPassInterface
{
private const TAG = 'unleash.client.bootstrap_provider';

Expand Down
Loading