Skip to content

Commit cb604c6

Browse files
Add support for PHP 8.5
1 parent ba193fc commit cb604c6

File tree

4 files changed

+54
-16
lines changed

4 files changed

+54
-16
lines changed

.github/workflows/run-tests.yml

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,23 @@ jobs:
1717

1818
name: "PHP${{ matrix.php }} ${{ matrix.os-title }} ${{ matrix.dependency-prefer-title }}"
1919
runs-on: "${{ matrix.os }}"
20+
permissions:
21+
contents: "read"
2022
strategy:
2123
fail-fast: true
2224
matrix:
2325
os: [ "ubuntu-latest", "macos-latest", "windows-latest" ]
24-
php: [ "8.4", "8.3", "8.2", "8.1", "8.0" ]
26+
php: [ "8.5", "8.4", "8.3", "8.2", "8.1", "8.0" ]
2527
dependency-prefer: [ "prefer-stable", "prefer-lowest" ]
2628
include:
29+
- php: "8.5"
30+
phpunit: "^11.0 | ^12.0"
31+
phpunit-config-file: "phpunit.github-actions.xml.dist"
2732
- php: "8.4"
28-
phpunit: "^11.0"
33+
phpunit: "^11.0 | ^12.0"
2934
phpunit-config-file: "phpunit.github-actions.xml.dist"
3035
- php: "8.3"
31-
phpunit: "^11.0"
36+
phpunit: "^11.0 | ^12.0"
3237
phpunit-config-file: "phpunit.github-actions.xml.dist"
3338
- php: "8.2"
3439
phpunit: "^11.0"
@@ -54,7 +59,7 @@ jobs:
5459

5560
steps:
5661
- name: "Checkout code"
57-
uses: "actions/checkout@v4"
62+
uses: "actions/checkout@v6"
5863

5964
- name: "Setup PHP"
6065
uses: "shivammathur/setup-php@v2"
@@ -75,11 +80,23 @@ jobs:
7580
run: |
7681
echo "composer_cache_dir=$(composer config cache-files-dir)">> "$GITHUB_OUTPUT"
7782
83+
- name: "Compute composer.json hash"
84+
id: "composer-hash"
85+
shell: "bash" # make sure this step works on Windows - bash syntax is used
86+
run: |
87+
# GitHub's hashFiles() tool has regression bug on MacOS - https://github.com/actions/runner-images/issues/13341
88+
# if replacing, fix the "$" and the "{ {" - the GitHub running picks it up and runs it before the step is run
89+
#COMPOSER_HASH="${ { hashFiles('composer.json') }}"
90+
# Use md5_file() instead
91+
COMPOSER_HASH="$(php -r 'echo md5_file("composer.json");')"
92+
echo "value=$COMPOSER_HASH" >> "$GITHUB_OUTPUT"
93+
7894
- name: "Cache composer's cache directory"
7995
uses: "actions/cache@v4"
8096
with:
8197
path: "${{ steps.composer-cache.outputs.composer_cache_dir }}"
82-
key: "[${{ matrix.os }}][php-${{ matrix.php }}][${{ matrix.dependency-prefer }}][composer.json-${{ hashFiles('composer.json') }}]"
98+
# key: "[${{ matrix.os }}][php-${{ matrix.php }}][${{ matrix.dependency-prefer }}][composer.json-${{ hashFiles('composer.json') }}]"
99+
key: "[${{ matrix.os }}][php-${{ matrix.php }}][${{ matrix.dependency-prefer }}][composer.json-${{ steps.composer-hash.outputs.value }}]"
83100

84101
- name: "Install dependencies"
85102
uses: "nick-fields/retry@v3"

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
}
2424
],
2525
"require": {
26-
"php": "8.0.* | 8.1.* | 8.2.* | 8.3.* | 8.4.*",
26+
"php": "8.0.* | 8.1.* | 8.2.* | 8.3.* | 8.4.* | 8.5.*",
2727
"code-distortion/di-caller": "^0.2.1 | ^0.3.0"
2828
},
2929
"require-dev": {
30-
"infection/infection": "^0.10 | ^0.11 | ^0.12 | ^0.13 | ^0.14 | ^0.15 | ^0.16 | ^0.17 | ^0.18 | ^0.19 | ^0.20 | ^0.21 | ^0.22 | ^0.23 | ^0.24 | ^0.25 | ^0.26 | ^0.27 | ^0.28 | ^0.29",
30+
"infection/infection": "^0.10 | ^0.11 | ^0.12 | ^0.13 | ^0.14 | ^0.15 | ^0.16 | ^0.17 | ^0.18 | ^0.19 | ^0.20 | ^0.21 | ^0.22 | ^0.23 | ^0.24 | ^0.25 | ^0.26 | ^0.27 | ^0.28 | ^0.29 | ^0.30 | ^0.31",
3131
"phpstan/phpstan": "^2.0",
3232
"phpstan/phpstan-strict-rules": "^2.0",
33-
"phpunit/phpunit": "~4.8 | ^5.0 | ^6.0 | ^7.0 | ^8.4 | ^9.0 | ^10.0 | ^11.0",
34-
"squizlabs/php_codesniffer": "^3.11.2"
33+
"phpunit/phpunit": "~4.8 | ^5.0 | ^6.0 | ^7.0 | ^8.4 | ^9.0 | ^10.0 | ^11.0 | ^12.0",
34+
"squizlabs/php_codesniffer": "^3.11.2 | ^4.0"
3535
},
3636
"autoload": {
3737
"psr-4": {

src/Support/Support.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,19 @@ public static function randFloat(int|float $min, int|float $max, int $decPl = 10
2727
}
2828

2929
$multiplier = pow(10, $decPl);
30-
$minInt = intval($min * $multiplier);
31-
$maxInt = intval($max * $multiplier);
30+
31+
// check if values would exceed PHP_INT_MAX before casting
32+
$maxScaled = $max * $multiplier;
33+
$minScaled = $min * $multiplier;
34+
35+
// if values are too large, clamp them to PHP_INT_MAX
36+
if ($maxScaled > PHP_INT_MAX || $minScaled > PHP_INT_MAX) {
37+
$maxInt = PHP_INT_MAX;
38+
$minInt = (int) min($minScaled, PHP_INT_MAX);
39+
} else {
40+
$minInt = intval($minScaled);
41+
$maxInt = intval($maxScaled);
42+
}
3243

3344
// safety net just in case this number gets too large
3445
// @infection-ignore-all LessThanNegotiation (timeout, mutant didn't escape)

tests/Unit/Support/TestSupport.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public static function callPrivateMethod(object $instance, string $method, array
3737
{
3838
$reflection = new ReflectionClass($instance);
3939
$method = $reflection->getMethod($method);
40-
$method->setAccessible(true);
40+
if (PHP_VERSION_ID < 80500) {
41+
$method->setAccessible(true);
42+
}
4143

4244
return $method->invoke($instance, ...$args);
4345
}
@@ -54,7 +56,9 @@ public static function getPrivateProperty(object $instance, string $property): m
5456
{
5557
$reflection = new ReflectionClass($instance);
5658
$property = $reflection->getProperty($property);
57-
$property->setAccessible(true);
59+
if (PHP_VERSION_ID < 80500) {
60+
$property->setAccessible(true);
61+
}
5862

5963
return $property->getValue($instance);
6064
}
@@ -72,7 +76,9 @@ public static function setPrivateProperty(object $instance, string $property, mi
7276
{
7377
$reflection = new ReflectionClass($instance);
7478
$property = $reflection->getProperty($property);
75-
$property->setAccessible(true);
79+
if (PHP_VERSION_ID < 80500) {
80+
$property->setAccessible(true);
81+
}
7682

7783
$property->setValue($instance, $value);
7884
}
@@ -89,7 +95,9 @@ public static function getPrivateStaticProperty(string $class, string $property)
8995
{
9096
$reflection = new ReflectionClass($class);
9197
$property = $reflection->getProperty($property);
92-
$property->setAccessible(true);
98+
if (PHP_VERSION_ID < 80500) {
99+
$property->setAccessible(true);
100+
}
93101

94102
return $property->getValue();
95103
}
@@ -107,7 +115,9 @@ public static function setPrivateStaticProperty(string $class, string $property,
107115
{
108116
$reflection = new ReflectionClass($class);
109117
$property = $reflection->getProperty($property);
110-
$property->setAccessible(true);
118+
if (PHP_VERSION_ID < 80500) {
119+
$property->setAccessible(true);
120+
}
111121

112122
$property->setValue($reflection, $value);
113123
}

0 commit comments

Comments
 (0)