Skip to content

Commit 1e862f8

Browse files
authored
PHP 8.0 support (#1)
1 parent 606eae9 commit 1e862f8

11 files changed

Lines changed: 38 additions & 17 deletions

File tree

.github/workflows/phpunit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ jobs:
1313
os: >-
1414
['ubuntu-latest']
1515
php: >-
16-
['8.1', '8.2']
16+
['8.0', '8.1', '8.2']
1717
stability: >-
1818
['prefer-lowest', 'prefer-stable']

.github/workflows/security.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
php: ['8.1']
17+
php: ['8.2']
1818
os: [ubuntu-latest]
1919

2020
steps:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
Make sure that your server is configured with following PHP version and extensions:
1414

15-
- PHP 8.1+
15+
- PHP 8.0+
1616

1717
## Installation
1818

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"homepage": "https://github.com/roadrunner-php/version-checker",
1010
"license": "MIT",
1111
"require": {
12-
"php": "^8.1",
12+
"php": "^8.0",
1313
"symfony/process": "^5.4 || ^6.0",
1414
"composer-runtime-api": "^2.0",
1515
"composer/semver": "^3.3"

src/Exception/UnsupportedVersionException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ final class UnsupportedVersionException extends VersionCheckerException
1313
*/
1414
public function __construct(
1515
string $message,
16-
private readonly string $installed,
17-
private readonly string $requested
16+
private string $installed,
17+
private string $requested
1818
) {
1919
parent::__construct($message);
2020
}

src/Version/Installed.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,19 @@ final class Installed implements InstalledInterface
2020
*/
2121
private static ?string $cachedVersion = null;
2222

23+
private ProcessInterface $process;
24+
private EnvironmentInterface $environment;
25+
2326
/**
2427
* @param non-empty-string $executablePath
2528
*/
2629
public function __construct(
27-
private readonly ProcessInterface $process = new Process(),
28-
private readonly EnvironmentInterface $environment = new Native(),
29-
private readonly string $executablePath = './rr'
30+
ProcessInterface $process = null,
31+
EnvironmentInterface $environment = null,
32+
private string $executablePath = './rr'
3033
) {
34+
$this->process = $process ?? new Process();
35+
$this->environment = $environment ?? new Native();
3136
}
3237

3338
/**

src/Version/Required.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ final class Required implements RequiredInterface
1717
*/
1818
private static ?string $cachedVersion = null;
1919

20-
public function __construct(
21-
private readonly PackageInterface $package = new Package()
22-
) {
20+
private PackageInterface $package;
21+
22+
public function __construct(PackageInterface $package = null)
23+
{
24+
$this->package = $package ?? new Package();
2325
}
2426

2527
/**

src/VersionChecker.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@
1616

1717
final class VersionChecker
1818
{
19+
private InstalledInterface $installedVersion;
20+
private RequiredInterface $requiredVersion;
21+
private ComparatorInterface $comparator;
22+
1923
public function __construct(
20-
private readonly InstalledInterface $installedVersion = new Installed(),
21-
private readonly RequiredInterface $requiredVersion = new Required(),
22-
private readonly ComparatorInterface $comparator = new Comparator()
24+
InstalledInterface $installedVersion = null,
25+
RequiredInterface $requiredVersion = null,
26+
ComparatorInterface $comparator = null
2327
) {
28+
$this->installedVersion = $installedVersion ?? new Installed();
29+
$this->requiredVersion = $requiredVersion ?? new Required();
30+
$this->comparator = $comparator ?? new Comparator();
2431
}
2532

2633
/**

tests/src/Unit/Composer/PackageTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public function testIsSupportedVersion(string $version, bool $expected): void
1616
{
1717
$package = new Package();
1818
$ref = new \ReflectionMethod($package, 'isSupportedVersion');
19+
$ref->setAccessible(true);
1920

2021
$this->assertSame($expected, $ref->invoke($package, $version));
2122
}
@@ -27,6 +28,7 @@ public function testGetMinVersion(string $version, string $expected): void
2728
{
2829
$package = new Package();
2930
$ref = new \ReflectionMethod($package, 'getMinVersion');
31+
$ref->setAccessible(true);
3032

3133
$this->assertSame($expected, $ref->invoke($package, $version));
3234
}

tests/src/Unit/Version/InstalledTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ final class InstalledTest extends TestCase
1616
protected function tearDown(): void
1717
{
1818
// clean the cache
19-
(new \ReflectionProperty(Installed::class, 'cachedVersion'))->setValue(null);
19+
$ref = new \ReflectionProperty(Installed::class, 'cachedVersion');
20+
$ref->setAccessible(true);
21+
$ref->setValue(null);
2022
}
2123

2224
/**

0 commit comments

Comments
 (0)