PHPCS updates.

This commit is contained in:
Peter Fabian 2018-09-21 20:51:41 +02:00
parent f2cb1e6a85
commit e956afdeb7
3 changed files with 99 additions and 24 deletions

View File

@ -2,10 +2,9 @@
if [[ ${RUN_PHPCS} == 1 ]]; then
CHANGED_FILES=`git diff --name-only --diff-filter=ACMR $TRAVIS_COMMIT_RANGE | grep \\\\.php | awk '{print}' ORS=' '`
IGNORE="tests/cli/,apigen/,includes/gateways/simplify-commerce/includes/,includes/libraries/,includes/api/legacy/"
if [ "$CHANGED_FILES" != "" ]; then
echo "Running Code Sniffer."
./vendor/bin/phpcs --ignore=$IGNORE --encoding=utf-8 -n -p $CHANGED_FILES
./vendor/bin/phpcs --encoding=utf-8 -n -p $CHANGED_FILES
fi
fi

View File

@ -106,18 +106,18 @@ class WC_Admin_Api_Init {
public static function filter_rest_endpoints( $endpoints ) {
// Override GET /wc/v3/system_status/tools.
if ( isset( $endpoints['/wc/v3/system_status/tools'] )
&& isset( $endpoints['/wc/v3/system_status/tools'][1] )
&& isset( $endpoints['/wc/v3/system_status/tools'][0] )
&& $endpoints['/wc/v3/system_status/tools'][1]['callback'][0] instanceof WC_Admin_REST_System_Status_Tools_Controller
&& isset( $endpoints['/wc/v3/system_status/tools'][1] )
&& isset( $endpoints['/wc/v3/system_status/tools'][0] )
&& $endpoints['/wc/v3/system_status/tools'][1]['callback'][0] instanceof WC_Admin_REST_System_Status_Tools_Controller
) {
$endpoints['/wc/v3/system_status/tools'][0] = $endpoints['/wc/v3/system_status/tools'][1];
}
// // Override GET & PUT for /wc/v3/system_status/tools.
if ( isset( $endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'] )
&& isset( $endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'][3] )
&& isset( $endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'][2] )
&& $endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'][2]['callback'][0] instanceof WC_Admin_REST_System_Status_Tools_Controller
&& $endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'][3]['callback'][0] instanceof WC_Admin_REST_System_Status_Tools_Controller
&& isset( $endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'][3] )
&& isset( $endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'][2] )
&& $endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'][2]['callback'][0] instanceof WC_Admin_REST_System_Status_Tools_Controller
&& $endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'][3]['callback'][0] instanceof WC_Admin_REST_System_Status_Tools_Controller
) {
$endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'][0] = $endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'][2];
$endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'][1] = $endpoints['/wc/v3/system_status/tools/(?P<id>[\w-]+)'][3];
@ -125,9 +125,9 @@ class WC_Admin_Api_Init {
// Override GET /wc/v3/reports.
if ( isset( $endpoints['/wc/v3/reports'] )
&& isset( $endpoints['/wc/v3/reports'][1] )
&& isset( $endpoints['/wc/v3/reports'][0] )
&& $endpoints['/wc/v3/reports'][1]['callback'][0] instanceof WC_Admin_REST_Reports_Controller
&& isset( $endpoints['/wc/v3/reports'][1] )
&& isset( $endpoints['/wc/v3/reports'][0] )
&& $endpoints['/wc/v3/reports'][1]['callback'][0] instanceof WC_Admin_REST_Reports_Controller
) {
$endpoints['/wc/v3/reports'][0] = $endpoints['/wc/v3/reports'][1];
}
@ -176,8 +176,8 @@ class WC_Admin_Api_Init {
* @param WC_Background_Updater|null $updater Updater instance.
* @return bool
*/
// TODO: this needs to be updated a bit, as it no longer runs as a part of WC_Install, there is no bg updater.
public static function order_product_lookup_store_init( $updater = null ) {
// TODO: this needs to be updated a bit, as it no longer runs as a part of WC_Install, there is no bg updater.
global $wpdb;
$orders = get_transient( 'wc_update_350_all_orders' );

View File

@ -1,17 +1,93 @@
<?xml version="1.0"?>
<ruleset name="WordPress Coding Standards for Plugins">
<description>Generally-applicable sniffs for WordPress plugins</description>
<ruleset name="WordPress Coding Standards">
<!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml -->
<!-- See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/WordPress-Core/ruleset.xml -->
<rule ref="WordPress-Core" />
<rule ref="WordPress-Docs" />
<!-- Check all PHP files in directory tree by default. -->
<arg name="extensions" value="php"/>
<file>.</file>
<!-- Show progress and sniff codes in all reports -->
<arg value="ps"/>
<description>WooCommerce dev PHP_CodeSniffer ruleset.</description>
<!-- Exclude paths -->
<exclude-pattern>tests/cli/</exclude-pattern>
<exclude-pattern>apigen/</exclude-pattern>
<exclude-pattern>includes/gateways/simplify-commerce</exclude-pattern>
<exclude-pattern>includes/libraries/</exclude-pattern>
<exclude-pattern>includes/legacy/</exclude-pattern>
<exclude-pattern>includes/api/legacy/</exclude-pattern>
<exclude-pattern>includes/api/v1/</exclude-pattern>
<exclude-pattern>includes/class-wc-geo-ip.php</exclude-pattern>
<exclude-pattern>includes/wc-deprecated-functions.php</exclude-pattern>
<exclude-pattern>*/node_modules/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<!-- Configs -->
<config name="minimum_supported_wp_version" value="4.7" />
<config name="testVersion" value="5.2-"/>
<!-- Rules -->
<rule ref="WooCommerce-Core" />
<rule ref="PHPCompatibility">
<exclude name="PHPCompatibility.PHP.NewFunctions.hash_equalsFound" />
<exclude name="PHPCompatibility.PHP.NewInterfaces.jsonserializableFound" />
<exclude name="PHPCompatibility.PHP.NewKeywords.t_namespaceFound" />
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="WordPress">
<exclude name="WordPress.VIP.DirectDatabaseQuery.NoCaching" />
<exclude name="WordPress.VIP.DirectDatabaseQuery.DirectQuery" />
<exclude name="WordPress.VIP.DirectDatabaseQuery.SchemaChange" />
<exclude name="WordPress.VIP.FileSystemWritesDisallow.file_ops_fwrite" />
<exclude name="WordPress.VIP.OrderByRand" />
<exclude name="WordPress.VIP.RestrictedFunctions" />
<exclude name="WordPress.VIP.RestrictedVariables.user_meta__wpdb__usermeta" />
<exclude name="WordPress.VIP.PostsPerPage.posts_per_page_posts_per_page" />
<exclude name="WordPress.VIP.RestrictedVariables.cache_constraints___COOKIE" />
<exclude name="WordPress.VIP.RestrictedVariables.cache_constraints___SERVER__REMOTE_ADDR__" />
</rule>
<rule ref="WordPress.VIP.ValidatedSanitizedInput">
<properties>
<property name="customSanitizingFunctions" type="array" value="wc_clean,wc_sanitize_tooltip,wc_format_decimal,wc_stock_amount,wc_sanitize_permalink,wc_sanitize_textarea" />
</properties>
</rule>
<rule ref="WordPress.XSS.EscapeOutput">
<properties>
<property name="customEscapingFunctions" type="array" value="wc_help_tip,wc_sanitize_tooltip,wc_selected,wc_kses_notice" />
</properties>
</rule>
<rule ref="WordPress.WP.I18n">
<properties>
<property name="text_domain" type="array" value="woocommerce" />
</properties>
</rule>
<rule ref="WordPress.Files.FileName.InvalidClassFileName">
<exclude-pattern>includes/**/abstract-*.php</exclude-pattern>
<exclude-pattern>tests/*</exclude-pattern>
</rule>
<rule ref="Generic.Commenting">
<exclude-pattern>tests/</exclude-pattern>
</rule>
<rule ref="Squiz.Commenting">
<exclude-pattern>tests/</exclude-pattern>
<exclude name="Squiz.Commenting.LongConditionClosingComment" />
<exclude name="Squiz.Commenting.PostStatementComment" />
</rule>
<rule ref="PEAR.Functions.FunctionCallSignature.EmptyLine">
<exclude-pattern>tests/e2e-tests/</exclude-pattern>
</rule>
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>i18n/</exclude-pattern>
</rule>
<!-- CLI commands require PHP >= 5.5 instead of 5.2 -->
<rule ref="PHPCompatibility.PHP.NewLanguageConstructs.t_ns_separatorFound">
<exclude-pattern>includes/cli/</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.PHP.NewFunctions.array_columnFound">
<exclude-pattern>includes/cli/</exclude-pattern>
</rule>
<rule ref="PHPCompatibility.PHP.NewClosure.Found">
<exclude-pattern>includes/cli/</exclude-pattern>
</rule>
<rule ref="WordPress.Files.FileName.NotHyphenatedLowercase">
<exclude-pattern>i18n/</exclude-pattern>
</rule>
</ruleset>