Skip to content

Commit 3ef330d

Browse files
feat(*): Add PHP 8.5 compatibility (#20)
* ci(test): Add PHP 8.5 in matrix * ci(test): Upgrade phpcs for php 8.5 * feat(*): Handle deprecated warning for PHP 8.5 * chore(*): Prepare release 3.0.1 * ci(test): Add pull_request as trigger * docs(developer): Fix 302 links
1 parent 3ebd0c5 commit 3ef330d

File tree

11 files changed

+52
-55
lines changed

11 files changed

+52
-55
lines changed

.github/workflows/coding-standards.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
- main
66
paths-ignore:
77
- '**.md'
8+
pull_request:
9+
branches:
10+
- main
11+
paths-ignore:
12+
- '**.md'
813
workflow_dispatch:
914
inputs:
1015
coverage_report:
@@ -24,11 +29,10 @@ jobs:
2429
strategy:
2530
fail-fast: false
2631
matrix:
27-
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
32+
php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5']
2833

2934
name: Coding standards test
3035
runs-on: ubuntu-latest
31-
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
3236
env:
3337
EXTENSION_PATH: "my-code/common"
3438

@@ -59,7 +63,7 @@ jobs:
5963
ddev exec php -v
6064
6165
- name: Clone sources
62-
uses: actions/checkout@v4
66+
uses: actions/checkout@v5
6367
with:
6468
path: ${{env.EXTENSION_PATH}}
6569

.github/workflows/keepalive.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
echo "version_number=$(echo ${{ env.TAG_NAME }} | sed 's/v//g' )" >> $GITHUB_OUTPUT
3636
3737
- name: Clone sources
38-
uses: actions/checkout@v4
38+
uses: actions/checkout@v5
3939

4040
- name: Check version consistency in files
4141
# Check src/Constants.php and CHANGELOG.md

.github/workflows/sdk-chain-tests.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ on:
33
push:
44
paths-ignore:
55
- "**.md"
6+
pull_request:
7+
branches:
8+
- main
9+
paths-ignore:
10+
- "**.md"
611

712
permissions:
813
contents: read
@@ -14,31 +19,28 @@ env:
1419
jobs:
1520
test-standalone-bouncer:
1621
name: Run Standalone Bouncer tests
17-
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
18-
uses: crowdsecurity/cs-standalone-php-bouncer/.github/workflows/php-sdk-development-tests.yml@22b9a34f4623d3380e970b4c7569fe4d9397f1eb
22+
uses: crowdsecurity/cs-standalone-php-bouncer/.github/workflows/php-sdk-development-tests.yml@main
1923
with:
20-
php_common_json: '["${{ github.ref_name }}"]'
24+
php_common_json: '["${{ github.head_ref || github.ref_name }}"]'
2125
lapi_client_json: '["main"]'
2226
capi_client_json: '["main"]'
2327
remediation_engine_json: '["main"]'
2428
bouncer_lib_json: '["main"]'
2529

2630
test-bouncer-lib:
2731
name: Run Bouncer lib tests
28-
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
29-
uses: crowdsecurity/php-cs-bouncer/.github/workflows/php-sdk-development-tests.yml@c15ac30dfb66f51c0794cb02f4449056116c85bf
32+
uses: crowdsecurity/php-cs-bouncer/.github/workflows/php-sdk-development-tests.yml@main
3033
with:
31-
php_common_json: '["${{ github.ref_name }}"]'
34+
php_common_json: '["${{ github.head_ref || github.ref_name }}"]'
3235
lapi_client_json: '["main"]'
3336
capi_client_json: '["main"]'
3437
remediation_engine_json: '["main"]'
3538

3639
test-remediation-engine:
3740
name: Run Remediation Engine tests
38-
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
3941
uses: crowdsecurity/php-remediation-engine/.github/workflows/php-sdk-development-tests.yml@main
4042
with:
41-
php_common_json: '["${{ github.ref_name }}"]'
43+
php_common_json: '["${{ github.head_ref || github.ref_name }}"]'
4244
lapi_client_json: '["main"]'
4345
capi_client_json: '["main"]'
4446
secrets:
@@ -47,28 +49,25 @@ jobs:
4749

4850
test-lapi-client:
4951
name: Run Lapi client tests
50-
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
5152
uses: crowdsecurity/php-lapi-client/.github/workflows/php-sdk-development-tests.yml@main
5253
with:
53-
php_common_json: '["${{ github.ref_name }}"]'
54+
php_common_json: '["${{ github.head_ref || github.ref_name }}"]'
5455

5556
test-capi-client:
5657
name: Run Capi client tests
57-
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
5858
uses: crowdsecurity/php-capi-client/.github/workflows/php-sdk-development-tests.yml@main
5959
with:
60-
php_common_json: '["${{ github.ref_name }}"]'
60+
php_common_json: '["${{ github.head_ref || github.ref_name }}"]'
6161
secrets:
6262
TEST_MACHINE_ID: ${{ secrets.TEST_MACHINE_ID }}
6363
TEST_MACHINE_PWD: ${{ secrets.TEST_MACHINE_PWD }}
6464
ENROLLMENT_KEY: ${{ secrets.TEST_ENROLLMENT_KEY }}
6565

6666
test-magento-engine:
6767
name: Run Magento 2 Engine module tests
68-
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
6968
uses: crowdsecurity/magento-cs-extension/.github/workflows/php-sdk-development-tests.yml@main
7069
with:
71-
php_common_json: '["${{ github.ref_name }}"]'
70+
php_common_json: '["${{ github.head_ref || github.ref_name }}"]'
7271
lapi_client_json: '["main"]'
7372
capi_client_json: '["main"]'
7473
remediation_engine_json: '["main"]'

.github/workflows/unit-tests.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
- main
66
paths-ignore:
77
- '**.md'
8+
pull_request:
9+
branches:
10+
- main
11+
paths-ignore:
12+
- '**.md'
813
workflow_dispatch:
914

1015
schedule:
@@ -22,11 +27,10 @@ jobs:
2227
strategy:
2328
fail-fast: false
2429
matrix:
25-
php-version: ['7.2','7.3','7.4','8.0','8.1', '8.2', '8.3', '8.4']
30+
php-version: ['7.2','7.3','7.4','8.0','8.1', '8.2', '8.3', '8.4', '8.5']
2631

2732
name: Unit tests
2833
runs-on: ubuntu-latest
29-
if: ${{ !contains(github.event.head_commit.message, 'chore(') }}
3034
env:
3135
EXTENSION_PATH: "my-code/common"
3236

@@ -61,7 +65,7 @@ jobs:
6165
ddev exec php -v
6266
6367
- name: Clone sources
64-
uses: actions/checkout@v4
68+
uses: actions/checkout@v5
6569
with:
6670
path: ${{env.EXTENSION_PATH}}
6771

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ the `src` folder.
1212

1313
As far as possible, we try to adhere to [Symfony guidelines](https://symfony.com/doc/current/contributing/code/bc.html#working-on-symfony-code) when deciding whether a change is a breaking change or not.
1414

15+
---
16+
17+
## [3.0.1](https://github.com/crowdsecurity/php-common/releases/tag/v3.0.1) - 2025-??-??
18+
[_Compare with previous release_](https://github.com/crowdsecurity/php-common/compare/v3.0.0...v3.0.1)
19+
20+
### Fixed
21+
22+
- Fix `curl_close` deprecation warning in PHP 8.5
23+
24+
1525
---
1626

1727
## [3.0.0](https://github.com/crowdsecurity/php-common/releases/tag/v3.0.0) - 2025-01-31

docs/DEVELOPER.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
There are many ways to install this library on a local PHP environment.
3131

32-
We are using [DDEV](https://ddev.readthedocs.io/en/stable/) because it is quite simple to use and customize.
32+
We are using [DDEV](https://docs.ddev.com/en/stable/) because it is quite simple to use and customize.
3333

3434
Of course, you may use your own local stack, but we provide here some useful tools that depends on DDEV.
3535

@@ -41,7 +41,7 @@ For a quick start, follow the below steps.
4141

4242
#### DDEV installation
4343

44-
For the DDEV installation, please follow the [official instructions](https://ddev.readthedocs.io/en/stable/users/install/ddev-installation/).
44+
For the DDEV installation, please follow the [official instructions](https://docs.ddev.com/en/stable/users/install/ddev-installation/).
4545

4646

4747
#### Prepare DDEV PHP environment
@@ -80,7 +80,7 @@ ddev config --project-type=php --php-version=8.2 --project-name=crowdsec-php-com
8080
- Add some DDEV add-ons:
8181

8282
```bash
83-
ddev get julienloizelet/ddev-tools
83+
ddev add-on get julienloizelet/ddev-tools
8484
```
8585

8686
- Clone this repo sources in a `my-code/common` folder:

src/Client/RequestHandler/Curl.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ public function handle(Request $request): Response
5050
throw new ClientException('Unexpected empty response http code');
5151
}
5252

53-
curl_close($handle);
53+
if (PHP_VERSION_ID < 80000) {
54+
curl_close($handle);
55+
}
5456

5557
return new Response((string) $response, $statusCode);
5658
}

src/Constants.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class Constants
131131
/**
132132
* @var string The current version of this library
133133
*/
134-
public const VERSION = 'v3.0.0';
134+
public const VERSION = 'v3.0.1';
135135
/**
136136
* @var string The version regex
137137
*/

tests/PHPUnitUtil.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ public static function callMethod($obj, $name, array $args)
3131
{
3232
$class = new \ReflectionClass($obj);
3333
$method = $class->getMethod($name);
34-
$method->setAccessible(true);
34+
if (PHP_VERSION_ID < 80100) {
35+
$method->setAccessible(true);
36+
}
3537

3638
return $method->invokeArgs($obj, $args);
3739
}
@@ -56,7 +58,9 @@ public static function setProtectedProperty($object, $property, $value)
5658
{
5759
$reflection = new \ReflectionClass($object);
5860
$reflection_property = $reflection->getProperty($property);
59-
$reflection_property->setAccessible(true);
61+
if (PHP_VERSION_ID < 80100) {
62+
$reflection_property->setAccessible(true);
63+
}
6064
$reflection_property->setValue($object, $value);
6165
}
6266
}

0 commit comments

Comments
 (0)