Skip to content

Commit 486539c

Browse files
committed
Updated code quality to check min PHP version from the composer.json file.
1 parent f37f125 commit 486539c

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

.github/workflows/code-quality.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ jobs:
2424
outputs:
2525
plugins: ${{ steps.detect.outputs.plugins }}
2626
has-plugins: ${{ steps.detect.outputs.has-plugins }}
27+
php-version: ${{ steps.detect-php-version.outputs.php-version }}
2728
steps:
2829
- name: Checkout
2930
uses: actions/checkout@v4
@@ -40,7 +41,7 @@ jobs:
4041
fi
4142
4243
- name: Detect changed plugins with quality config
43-
id: detect
44+
id: detect-plugin-slug
4445
run: |
4546
if [ -z "${{ steps.plugin.outputs.slug }}" ]; then
4647
echo "No plugin slug detected"
@@ -60,6 +61,23 @@ jobs:
6061
echo "has-plugins=false" >> $GITHUB_OUTPUT
6162
echo "ℹ️ No phpcs.xml found for plugin: $PLUGIN, skipping quality checks"
6263
fi
64+
- name: Detect changed plugins with quality config
65+
id: detect-php-version
66+
run: |
67+
PLUGIN="${{ steps.plugin.outputs.slug }}"
68+
PHP_VERSION="7.4"
69+
if [ -f "plugins/$PLUGIN/composer.json" ]; then
70+
DETECTED_VERSION=$(jq -r '.require["php"] // empty' plugins/$PLUGIN/composer.json | grep -oE '[0-9]+\.[0-9]+' | head -1)
71+
if [ -n "$DETECTED_VERSION" ]; then
72+
PHP_VERSION="$DETECTED_VERSION"
73+
echo "Detected PHP version $PHP_VERSION from composer.json"
74+
else
75+
echo "No PHP version found in composer.json, using default $PHP_VERSION"
76+
fi
77+
else
78+
echo "No composer.json found, using default PHP version $PHP_VERSION"
79+
fi
80+
echo "php-version=$PHP_VERSION" >> $GITHUB_OUTPUT
6381
quality-checks:
6482
needs: detect-plugins
6583
if: needs.detect-plugins.outputs.has-plugins == 'true'
@@ -77,3 +95,5 @@ jobs:
7795
uses: ./.github/actions/code-quality
7896
with:
7997
working-directory: plugins/${{ matrix.plugin }}
98+
php-version: ${{ needs.detect-plugins.outputs.php-version }}
99+
composer-options: '--no-progress --no-suggest'

plugins/wpgraphql-logging/phpcs.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,6 @@
210210
<element value="Iterator"/>
211211
<element value="Generator"/>
212212
</property>
213-
<!-- PHP 7.4 specific settings -->
214-
<property name="enableMixedTypeHint" value="false"/>
215-
<property name="enableUnionTypeHint" value="false"/>
216-
<property name="enableIntersectionTypeHint" value="false"/>
217213
</properties>
218214
</rule>
219215
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHintSpacing">

0 commit comments

Comments
 (0)