diff --git a/.github/workflows/coding-standards.yml b/.github/workflows/coding-standards.yml index f8e48b8..26ae868 100644 --- a/.github/workflows/coding-standards.yml +++ b/.github/workflows/coding-standards.yml @@ -5,6 +5,11 @@ on: - main paths-ignore: - '**.md' + pull_request: + branches: + - main + paths-ignore: + - '**.md' workflow_dispatch: inputs: coverage_report: @@ -24,11 +29,10 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4'] + php-version: ['7.4', '8.0', '8.1', '8.2', '8.3', '8.4', '8.5'] name: Coding standards test runs-on: ubuntu-latest - if: ${{ !contains(github.event.head_commit.message, 'chore(') }} env: EXTENSION_PATH: "my-code/common" @@ -59,7 +63,7 @@ jobs: ddev exec php -v - name: Clone sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: path: ${{env.EXTENSION_PATH}} diff --git a/.github/workflows/keepalive.yml b/.github/workflows/keepalive.yml deleted file mode 100644 index 81d3824..0000000 --- a/.github/workflows/keepalive.yml +++ /dev/null @@ -1,26 +0,0 @@ -name: Keep Alive -on: - - schedule: - - cron: '0 3 * * 4' - -permissions: - actions: write - -jobs: - keep-alive: - - name: Keep Alive - runs-on: ubuntu-latest - - steps: - - - name: Clone project files - uses: actions/checkout@v4 - - # keepalive-workflow keeps GitHub from turning off tests after 60 days - - uses: gautamkrishnar/keepalive-workflow@v2 - with: - time_elapsed: 45 - workflow_files: "unit-tests.yml" - diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 08a5874..78171ef 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,7 +35,7 @@ jobs: echo "version_number=$(echo ${{ env.TAG_NAME }} | sed 's/v//g' )" >> $GITHUB_OUTPUT - name: Clone sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Check version consistency in files # Check src/Constants.php and CHANGELOG.md diff --git a/.github/workflows/sdk-chain-tests.yml b/.github/workflows/sdk-chain-tests.yml index 26c64e6..e8bfa59 100644 --- a/.github/workflows/sdk-chain-tests.yml +++ b/.github/workflows/sdk-chain-tests.yml @@ -3,6 +3,11 @@ on: push: paths-ignore: - "**.md" + pull_request: + branches: + - main + paths-ignore: + - "**.md" permissions: contents: read @@ -14,10 +19,9 @@ env: jobs: test-standalone-bouncer: name: Run Standalone Bouncer tests - if: ${{ !contains(github.event.head_commit.message, 'chore(') }} - uses: crowdsecurity/cs-standalone-php-bouncer/.github/workflows/php-sdk-development-tests.yml@22b9a34f4623d3380e970b4c7569fe4d9397f1eb + uses: crowdsecurity/cs-standalone-php-bouncer/.github/workflows/php-sdk-development-tests.yml@main with: - php_common_json: '["${{ github.ref_name }}"]' + php_common_json: '["${{ github.head_ref || github.ref_name }}"]' lapi_client_json: '["main"]' capi_client_json: '["main"]' remediation_engine_json: '["main"]' @@ -25,20 +29,18 @@ jobs: test-bouncer-lib: name: Run Bouncer lib tests - if: ${{ !contains(github.event.head_commit.message, 'chore(') }} - uses: crowdsecurity/php-cs-bouncer/.github/workflows/php-sdk-development-tests.yml@c15ac30dfb66f51c0794cb02f4449056116c85bf + uses: crowdsecurity/php-cs-bouncer/.github/workflows/php-sdk-development-tests.yml@main with: - php_common_json: '["${{ github.ref_name }}"]' + php_common_json: '["${{ github.head_ref || github.ref_name }}"]' lapi_client_json: '["main"]' capi_client_json: '["main"]' remediation_engine_json: '["main"]' test-remediation-engine: name: Run Remediation Engine tests - if: ${{ !contains(github.event.head_commit.message, 'chore(') }} uses: crowdsecurity/php-remediation-engine/.github/workflows/php-sdk-development-tests.yml@main with: - php_common_json: '["${{ github.ref_name }}"]' + php_common_json: '["${{ github.head_ref || github.ref_name }}"]' lapi_client_json: '["main"]' capi_client_json: '["main"]' secrets: @@ -47,17 +49,15 @@ jobs: test-lapi-client: name: Run Lapi client tests - if: ${{ !contains(github.event.head_commit.message, 'chore(') }} uses: crowdsecurity/php-lapi-client/.github/workflows/php-sdk-development-tests.yml@main with: - php_common_json: '["${{ github.ref_name }}"]' + php_common_json: '["${{ github.head_ref || github.ref_name }}"]' test-capi-client: name: Run Capi client tests - if: ${{ !contains(github.event.head_commit.message, 'chore(') }} uses: crowdsecurity/php-capi-client/.github/workflows/php-sdk-development-tests.yml@main with: - php_common_json: '["${{ github.ref_name }}"]' + php_common_json: '["${{ github.head_ref || github.ref_name }}"]' secrets: TEST_MACHINE_ID: ${{ secrets.TEST_MACHINE_ID }} TEST_MACHINE_PWD: ${{ secrets.TEST_MACHINE_PWD }} @@ -65,10 +65,9 @@ jobs: test-magento-engine: name: Run Magento 2 Engine module tests - if: ${{ !contains(github.event.head_commit.message, 'chore(') }} uses: crowdsecurity/magento-cs-extension/.github/workflows/php-sdk-development-tests.yml@main with: - php_common_json: '["${{ github.ref_name }}"]' + php_common_json: '["${{ github.head_ref || github.ref_name }}"]' lapi_client_json: '["main"]' capi_client_json: '["main"]' remediation_engine_json: '["main"]' diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index c14c3b4..386dba9 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -5,6 +5,11 @@ on: - main paths-ignore: - '**.md' + pull_request: + branches: + - main + paths-ignore: + - '**.md' workflow_dispatch: schedule: @@ -22,11 +27,10 @@ jobs: strategy: fail-fast: false matrix: - php-version: ['7.2','7.3','7.4','8.0','8.1', '8.2', '8.3', '8.4'] + php-version: ['7.2','7.3','7.4','8.0','8.1', '8.2', '8.3', '8.4', '8.5'] name: Unit tests runs-on: ubuntu-latest - if: ${{ !contains(github.event.head_commit.message, 'chore(') }} env: EXTENSION_PATH: "my-code/common" @@ -61,7 +65,7 @@ jobs: ddev exec php -v - name: Clone sources - uses: actions/checkout@v4 + uses: actions/checkout@v5 with: path: ${{env.EXTENSION_PATH}} diff --git a/CHANGELOG.md b/CHANGELOG.md index 38c0efe..3740d85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,16 @@ the `src` folder. 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. +--- + +## [3.0.1](https://github.com/crowdsecurity/php-common/releases/tag/v3.0.1) - 2025-??-?? +[_Compare with previous release_](https://github.com/crowdsecurity/php-common/compare/v3.0.0...v3.0.1) + +### Fixed + +- Fix `curl_close` deprecation warning in PHP 8.5 + + --- ## [3.0.0](https://github.com/crowdsecurity/php-common/releases/tag/v3.0.0) - 2025-01-31 diff --git a/docs/DEVELOPER.md b/docs/DEVELOPER.md index 210d56d..a509fac 100644 --- a/docs/DEVELOPER.md +++ b/docs/DEVELOPER.md @@ -29,7 +29,7 @@ There are many ways to install this library on a local PHP environment. -We are using [DDEV](https://ddev.readthedocs.io/en/stable/) because it is quite simple to use and customize. +We are using [DDEV](https://docs.ddev.com/en/stable/) because it is quite simple to use and customize. Of course, you may use your own local stack, but we provide here some useful tools that depends on DDEV. @@ -41,7 +41,7 @@ For a quick start, follow the below steps. #### DDEV installation -For the DDEV installation, please follow the [official instructions](https://ddev.readthedocs.io/en/stable/users/install/ddev-installation/). +For the DDEV installation, please follow the [official instructions](https://docs.ddev.com/en/stable/users/install/ddev-installation/). #### Prepare DDEV PHP environment @@ -80,7 +80,7 @@ ddev config --project-type=php --php-version=8.2 --project-name=crowdsec-php-com - Add some DDEV add-ons: ```bash -ddev get julienloizelet/ddev-tools +ddev add-on get julienloizelet/ddev-tools ``` - Clone this repo sources in a `my-code/common` folder: diff --git a/src/Client/RequestHandler/Curl.php b/src/Client/RequestHandler/Curl.php index 3a9267b..51b315c 100644 --- a/src/Client/RequestHandler/Curl.php +++ b/src/Client/RequestHandler/Curl.php @@ -50,7 +50,9 @@ public function handle(Request $request): Response throw new ClientException('Unexpected empty response http code'); } - curl_close($handle); + if (PHP_VERSION_ID < 80000) { + curl_close($handle); + } return new Response((string) $response, $statusCode); } diff --git a/src/Constants.php b/src/Constants.php index 7d17a2e..bd0aefa 100644 --- a/src/Constants.php +++ b/src/Constants.php @@ -131,7 +131,7 @@ class Constants /** * @var string The current version of this library */ - public const VERSION = 'v3.0.0'; + public const VERSION = 'v3.0.1'; /** * @var string The version regex */ diff --git a/tests/PHPUnitUtil.php b/tests/PHPUnitUtil.php index 3b19c9d..674781f 100644 --- a/tests/PHPUnitUtil.php +++ b/tests/PHPUnitUtil.php @@ -31,7 +31,9 @@ public static function callMethod($obj, $name, array $args) { $class = new \ReflectionClass($obj); $method = $class->getMethod($name); - $method->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $method->setAccessible(true); + } return $method->invokeArgs($obj, $args); } @@ -56,7 +58,9 @@ public static function setProtectedProperty($object, $property, $value) { $reflection = new \ReflectionClass($object); $reflection_property = $reflection->getProperty($property); - $reflection_property->setAccessible(true); + if (PHP_VERSION_ID < 80100) { + $reflection_property->setAccessible(true); + } $reflection_property->setValue($object, $value); } } diff --git a/tools/coding-standards/composer.json b/tools/coding-standards/composer.json index 8bfe80d..cf02421 100644 --- a/tools/coding-standards/composer.json +++ b/tools/coding-standards/composer.json @@ -4,7 +4,7 @@ "friendsofphp/php-cs-fixer": "^v3.8.0", "phpstan/phpstan": "^1.8.0", "phpmd/phpmd": "^2.12.0", - "squizlabs/php_codesniffer": "3.7.1", + "squizlabs/php_codesniffer": "3.7.1 || ^4.0.1", "vimeo/psalm": "^4.24.0 || ^5.26", "phpunit/phpunit": "^9.3", "phpunit/php-code-coverage": "^9.2.15",