Skip to content

Commit 492da5a

Browse files
authored
Workflows
1 parent c5c4aef commit 492da5a

File tree

2 files changed

+33
-30
lines changed

2 files changed

+33
-30
lines changed

.github/workflows/php-code-quality.yml

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
# Set up PHPCompatibility standards properly with absolute paths
9494
ABSOLUTE_PHPCOMP_PATH=$(composer config vendor-dir)/phpcompatibility/php-compatibility
9595
ABSOLUTE_WPCS_PATH=$(composer config vendor-dir)/wp-coding-standards/wpcs
96-
vendor/bin/phpcs --config-set installed_paths $ABSOLUTE_PHPCOMP_PATH,$ABSOLUTE_WPCS_PATH
96+
vendor/bin/phpcs --config-set installed_paths ${ABSOLUTE_PHPCOMP_PATH},${ABSOLUTE_WPCS_PATH}
9797
9898
# Verify configured standards
9999
echo "Available coding standards:"
@@ -111,19 +111,22 @@ jobs:
111111
cp phpcs.xml phpcs.xml.bak
112112
113113
# Create a simple phpcs configuration file that directly references PHPCompatibility
114-
echo '<?xml version="1.0"?>' > phpcs-compat.xml
115-
echo '<ruleset name="PHP Compatibility Check">' >> phpcs-compat.xml
116-
echo ' <description>Check PHP compatibility for WordPress plugin</description>' >> phpcs-compat.xml
117-
echo ' <config name="installed_paths" value="'$(composer config vendor-dir)'/phpcompatibility/php-compatibility"/>' >> phpcs-compat.xml
118-
echo ' <rule ref="PHPCompatibility"/>' >> phpcs-compat.xml
119-
echo ' <config name="testVersion" value="7.4-8.4"/>' >> phpcs-compat.xml
120-
echo ' <arg name="extensions" value="php"/>' >> phpcs-compat.xml
121-
echo ' <file>.</file>' >> phpcs-compat.xml
122-
echo ' <exclude-pattern>/vendor/*</exclude-pattern>' >> phpcs-compat.xml
123-
echo ' <exclude-pattern>/node_modules/*</exclude-pattern>' >> phpcs-compat.xml
124-
echo '</ruleset>' >> phpcs-compat.xml
114+
cat > phpcs-compat.xml << 'EOF'
115+
<?xml version="1.0"?>
116+
<ruleset name="PHP Compatibility Check">
117+
<description>Check PHP compatibility for WordPress plugin</description>
118+
<config name="installed_paths" value="./vendor/phpcompatibility/php-compatibility"/>
119+
<rule ref="PHPCompatibility"/>
120+
<config name="testVersion" value="7.4-8.4"/>
121+
<arg name="extensions" value="php"/>
122+
<file>.</file>
123+
<exclude-pattern>/vendor/*</exclude-pattern>
124+
<exclude-pattern>/node_modules/*</exclude-pattern>
125+
</ruleset>
126+
EOF
125127

126-
# Try with the temporary configuration
128+
# Try with the temporary configuration and ensure installed_paths is set correctly
129+
vendor/bin/phpcs --config-set installed_paths ${ABSOLUTE_PHPCOMP_PATH},${ABSOLUTE_WPCS_PATH}
127130
vendor/bin/phpcs --standard=phpcs-compat.xml --extensions=php --ignore=vendor/,node_modules/ .
128131
}
129132

.github/workflows/wordpress-tests.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ jobs:
289289
# Create or copy required class-basic-object.php file if missing
290290
if [ ! -f "/tmp/wordpress-tests-lib/includes/class-basic-object.php" ]; then
291291
echo "Creating missing class-basic-object.php file in /tmp/wordpress-tests-lib..."
292-
cat > "/tmp/wordpress-tests-lib/includes/class-basic-object.php" << 'EOF'
292+
cat > /tmp/wordpress-tests-lib/includes/class-basic-object.php << 'EOF'
293293
<?php
294294
/**
295295
* Basic object, which other objects in WordPress extend.
@@ -300,16 +300,16 @@ class Basic_Object {
300300
/**
301301
* Retrieve a value from an array with support for a default value.
302302
*
303-
* @param array $args Arguments.
304-
* @param string $key Key to retrieve.
305-
* @param mixed $default Default value.
303+
* @param array \$args Arguments.
304+
* @param string \$key Key to retrieve.
305+
* @param mixed \$default Default value.
306306
* @return mixed Value if set, default if not.
307307
*/
308-
protected function get_from_array( $args, $key, $default = null ) {
309-
if ( isset( $args[ $key ] ) ) {
310-
return $args[ $key ];
308+
protected function get_from_array( \$args, \$key, \$default = null ) {
309+
if ( isset( \$args[ \$key ] ) ) {
310+
return \$args[ \$key ];
311311
}
312-
return $default;
312+
return \$default;
313313
}
314314
}
315315
EOF
@@ -322,27 +322,27 @@ EOF
322322
sudo cp -f /tmp/wordpress-tests-lib/includes/class-basic-object.php /wordpress-tests-lib/includes/ || echo "::warning::Failed to copy class-basic-object.php"
323323
else
324324
echo "Creating missing class-basic-object.php file in /wordpress-tests-lib..."
325-
sudo bash -c 'cat > "/wordpress-tests-lib/includes/class-basic-object.php" << "EOF"
325+
sudo bash -c 'cat > /wordpress-tests-lib/includes/class-basic-object.php << '\''EOF'\''
326326
<?php
327327
/**
328328
* Basic object, which other objects in WordPress extend.
329-
*
329+
*
330330
* This is a simplified version for tests to fix the missing class issue.
331331
*/
332332
class Basic_Object {
333333
/**
334334
* Retrieve a value from an array with support for a default value.
335335
*
336-
* @param array $args Arguments.
337-
* @param string $key Key to retrieve.
338-
* @param mixed $default Default value.
336+
* @param array \$args Arguments.
337+
* @param string \$key Key to retrieve.
338+
* @param mixed \$default Default value.
339339
* @return mixed Value if set, default if not.
340340
*/
341-
protected function get_from_array( $args, $key, $default = null ) {
342-
if ( isset( $args[ $key ] ) ) {
343-
return $args[ $key ];
341+
protected function get_from_array( \$args, \$key, \$default = null ) {
342+
if ( isset( \$args[ \$key ] ) ) {
343+
return \$args[ \$key ];
344344
}
345-
return $default;
345+
return \$default;
346346
}
347347
}
348348
EOF'

0 commit comments

Comments
 (0)