Skip to content
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

Feat: Support PHP 7.2 #48

Merged
merged 4 commits into from
Feb 10, 2022
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
3 changes: 3 additions & 0 deletions .github/bootstrap-72.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

const JSON_THROW_ON_ERROR = 4194304;
14 changes: 13 additions & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.3', '7.4', '8.0']
version: ['7.2', '7.3', '7.4', '8.0']
steps:
- name: Extract Version Name
id: extract_name
Expand All @@ -57,8 +57,20 @@ jobs:
run: composer install
- 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: Add polyfill
if: matrix.version == '7.2'
run: composer require symfony/polyfill-php73
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.1"/"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'
- name: Copy Bootstrap
if: matrix.version == '7.2'
run: cp .github/bootstrap-72.php src
- name: Load Bootstrap
if: matrix.version == '7.2'
run: 'cat composer.json | jq --argjson files ''["src/bootstrap-72.php"]'' ''.autoload += {files: $files}'' > tmp.json && mv tmp.json composer.json'
- name: Commit PHP ${{ matrix.version }} version
run: |
git config user.email noreply@github.com && \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests-7.x.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.3', '7.4']
version: ['7.2', '7.3', '7.4']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
14 changes: 13 additions & 1 deletion .github/workflows/transpile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
version: ['7.3', '7.4', '8.0']
version: ['7.2', '7.3', '7.4', '8.0']
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -23,8 +23,20 @@ jobs:
run: composer install
- 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: Add polyfill
if: matrix.version == '7.2'
run: composer require symfony/polyfill-php73
- name: Update composer.json version
run: 'sed -i -e ''s/"php": "\^8.1"/"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'
- name: Copy Bootstrap
if: matrix.version == '7.2'
run: cp .github/bootstrap-72.php src
- name: Load Bootstrap
if: matrix.version == '7.2'
run: 'cat composer.json | jq --argjson files ''["src/bootstrap-72.php"]'' ''.autoload += {files: $files}'' > tmp.json && mv tmp.json composer.json'
- name: Update README
run: sed -i '1s/^/# This branch is auto generated\n/' README.md
- name: Commit PHP ${{ matrix.version }} version
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This implementation conforms to the official Unleash standards and implements al

`composer require unleash/client`

Requires PHP 7.3 or newer.
Requires PHP 7.2 or newer.

> You will also need some implementation of [PSR-18](https://packagist.org/providers/psr/http-client-implementation)
> and [PSR-17](https://packagist.org/providers/psr/http-factory-implementation), for example
Expand Down
11 changes: 11 additions & 0 deletions rector.72.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

use Rector\Set\ValueObject\DowngradeSetList;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(DowngradeSetList::PHP_81);
$containerConfigurator->import(DowngradeSetList::PHP_80);
$containerConfigurator->import(DowngradeSetList::PHP_74);
$containerConfigurator->import(DowngradeSetList::PHP_73);
};
2 changes: 1 addition & 1 deletion tests/DefaultUnleashTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public function findFeature(string $featureName): ?Feature
$this->cache[$featureName] = new DefaultFeature(
$featureName,
true,
new LimitIterator(new ArrayIterator([new DefaultStrategy('default')])),
new LimitIterator(new ArrayIterator([new DefaultStrategy('default')]))
);
}

Expand Down
12 changes: 6 additions & 6 deletions tests/Strategy/GradualRolloutStrategyHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ public function testIsEnabled()

self::assertFalse($this->instance->isEnabled(
$this->createStrategy(100, Stickiness::USER_ID),
new UnleashContext(),
new UnleashContext()
));

self::assertFalse($this->instance->isEnabled(
$this->createStrategy(100, Stickiness::USER_ID),
new UnleashContext(null, null, 'test'),
new UnleashContext(null, null, 'test')
));

self::assertFalse(
Expand All @@ -104,12 +104,12 @@ public function testIsEnabled()

self::assertFalse($this->instance->isEnabled(
$this->createStrategy(100, Stickiness::SESSION_ID),
new UnleashContext(),
new UnleashContext()
));

self::assertFalse($this->instance->isEnabled(
$this->createStrategy(100, Stickiness::SESSION_ID),
new UnleashContext('test'),
new UnleashContext('test')
));

self::assertFalse(
Expand All @@ -133,7 +133,7 @@ public function testIsEnabled()
self::assertFalse($this->instance->isEnabled($strategy, new UnleashContext()));
self::assertTrue($this->instance->isEnabled(
$strategy,
(new UnleashContext())->setCustomProperty('something', 'test'),
(new UnleashContext())->setCustomProperty('something', 'test')
));

$strategy = $this->createStrategy(100, Stickiness::DEFAULT, [
Expand All @@ -142,7 +142,7 @@ public function testIsEnabled()
self::assertTrue($this->instance->isEnabled($strategy, new UnleashContext()));
self::assertFalse($this->instance->isEnabled(
$strategy,
(new UnleashContext())->setCustomProperty('something', 'test'),
(new UnleashContext())->setCustomProperty('something', 'test')
));
}

Expand Down