woocommerce / woocommerce-gateway-payfast

South African payment gateway supporting subscriptions, deposits & pre-orders
https://wordpress.org/plugins/woocommerce-payfast-gateway/
41 stars 15 forks source link

WooCommerce PHPCS sniff throws an error when using @since x.x.x on hooks #235

Closed vikrampm1 closed 1 month ago

vikrampm1 commented 2 months ago

Describe the Bug

We use the woocommerce/woocommerce-sniffs package for our PHPCS sniffs. There is one sniff here (WooCommerce.Commenting.CommentHooks.MissingSinceVersionComment) that will throw an error if a @since statement is added to a hook doc but doesn't contain a valid value. Can see a failure here: https://github.com/woocommerce/woocommerce-deposits/actions/runs/9649327093/job/26612562501

Since we aren't always sure when opening a PR what the final released version will be, we always use x.x.x for those statements, which is fine for function, method or parameter statements but will get flagged when using it for hooks. We always update these x.x.x statements before a release so I think we can just ignore these particular sniff by adding the following to our phpcs.xml.dist file:

<rule ref="WooCommerce.Commenting">
    <!-- It wants @since to contain defined version and does not allow just x.x.x -->
    <exclude name="WooCommerce.Commenting.CommentHooks.MissingSinceVersionComment"/>
</rule>

To Reproduce

See the following PHPCS error on the #615 PR: https://github.com/woocommerce/woocommerce-deposits/actions/runs/9649327093/job/26612562501

Can also check out this branch locally (fix/586) and run PHPCS locally to see the failure:

./vendor/bin/phpcs-changed -s --git --git-base origin/trunk includes/api/class-wc-deposits-store-api.php