Skip to content

Commit 8aa7060

Browse files
committed
Fix PHPCompatibility dependency conflict
- Remove PHPCompatibility packages from composer.json (conflicts with WPCS 3.x) - Remove PHPCompatibilityWP rules from phpcs.xml.dist - Add dedicated phpcompat.yml workflow for PHP 7.4-8.5 compatibility checks - PHP compatibility now runs in isolated environment with PHPCS 4.x - Resolves composer dependency conflict between WPCS 3.x (requires PHPCS 3.x) and PHPCompatibility 10.x (requires PHPCS 4.x)
1 parent 29d98f6 commit 8aa7060

File tree

3 files changed

+59
-5
lines changed

3 files changed

+59
-5
lines changed

.github/workflows/phpcompat.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: PHP Compatibility
2+
3+
on:
4+
push:
5+
paths-ignore:
6+
- '**.md'
7+
- '**.txt'
8+
pull_request:
9+
paths-ignore:
10+
- '**.md'
11+
- '**.txt'
12+
workflow_dispatch: {}
13+
14+
jobs:
15+
phpcompat:
16+
name: 'PHP Compatibility Check'
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
23+
- name: Install PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: '8.0'
27+
coverage: none
28+
29+
# Create isolated environment for PHPCompatibility with PHPCS 4.x
30+
- name: Setup PHPCompatibility
31+
run: |
32+
mkdir phpcompat-tools
33+
cd phpcompat-tools
34+
composer init --name="temp/phpcompat" --type=project --no-interaction
35+
composer config allow-plugins.dealerdirect/phpcodesniffer-composer-installer true
36+
composer require --dev \
37+
squizlabs/php_codesniffer:"^4.0" \
38+
phpcompatibility/php-compatibility:"dev-develop" \
39+
dealerdirect/phpcodesniffer-composer-installer:"^1.0" \
40+
--no-interaction
41+
42+
# Check PHP 7.4 through 8.5 compatibility
43+
- name: Check PHP Compatibility (7.4-8.5)
44+
run: |
45+
cd phpcompat-tools
46+
./vendor/bin/phpcs -p \
47+
--standard=PHPCompatibility \
48+
--runtime-set testVersion 7.4-8.5 \
49+
--extensions=php \
50+
--ignore=*/vendor/*,*/node_modules/*,*/tests/*,*/phpunit/*,*/freemius/* \
51+
../ || exit_code=$?
52+
53+
# Exit with the phpcs exit code (if set)
54+
exit ${exit_code:-0}

composer.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
"php-stubs/wordpress-stubs": "^6",
3030
"wp-coding-standards/wpcs": "^3",
3131
"dealerdirect/phpcodesniffer-composer-installer": "^1",
32-
"phpcompatibility/phpcompatibility-wp": "*",
33-
"phpcompatibility/php-compatibility": "dev-develop as 9.99.99",
3432
"yoast/phpunit-polyfills": "^3",
3533
"phpunit/phpunit": "^9 || ^10 || ^11 || ^12"
3634
},

phpcs.xml.dist

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@
3737
<rule ref="Generic.Commenting.Todo"/>
3838
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed"/>
3939

40-
<!-- Check for PHP 7.4+ compatibility. -->
41-
<config name="testVersion" value="7.4-"/>
42-
<rule ref="PHPCompatibilityWP"/>
40+
41+
42+
<!-- Note: PHP Compatibility checks are run in a separate GitHub Actions workflow
43+
(.github/workflows/phpcompat.yml) due to dependency conflicts between
44+
WPCS 3.x (requires PHPCS 3.x) and PHPCompatibility 10.x (requires PHPCS 4.x) -->
4345

4446
</ruleset>

0 commit comments

Comments
 (0)