Skip to content

Commit

Permalink
Move the exclude pattern statements to the phpcs.xml.dist file to a…
Browse files Browse the repository at this point in the history
…void cluttering the code with `phpcs:ignore` statements.
  • Loading branch information
anton-vlasenko authored and Anton Vlasenko committed Jan 30, 2024
1 parent 0c8ef69 commit 255e3ed
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 0 additions & 2 deletions packages/block-library/src/form-input/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ function render_block_core_form_input( $attributes, $content ) {
* Registers the `core/form-input` block on server.
*/
function register_block_core_form_input() {
// Refactoring required: this function must be guarded as it is available only in Gutenberg, and not in Core.
// phpcs:ignore Gutenberg.CodeAnalysis.ForbiddenFunctionsAndClasses.ForbiddenFunctionCall
if ( ! gutenberg_is_experiment_enabled( 'gutenberg-form-blocks' ) ) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ function render_block_core_form_submission_notification( $attributes, $content )
* Registers the `core/form-submission-notification` block on server.
*/
function register_block_core_form_submission_notification() {
// Refactoring required: this function must be guarded as it is available only in Gutenberg, and not in Core.
// phpcs:ignore Gutenberg.CodeAnalysis.ForbiddenFunctionsAndClasses.ForbiddenFunctionCall
if ( ! gutenberg_is_experiment_enabled( 'gutenberg-form-blocks' ) ) {
return;
}
Expand Down
4 changes: 0 additions & 4 deletions packages/block-library/src/form/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ function render_block_core_form( $attributes, $content ) {
* Additional data to add to the view.js script for this block.
*/
function block_core_form_view_script() {
// Refactoring required: this function must be guarded as it is available only in Gutenberg, and not in Core.
// phpcs:ignore Gutenberg.CodeAnalysis.ForbiddenFunctionsAndClasses.ForbiddenFunctionCall
if ( ! gutenberg_is_experiment_enabled( 'gutenberg-form-blocks' ) ) {
return;
}
Expand Down Expand Up @@ -203,8 +201,6 @@ function block_core_form_privacy_form() {
* Registers the `core/form` block on server.
*/
function register_block_core_form() {
// Refactoring required: this function must be guarded as it is available only in Gutenberg, and not in Core.
// phpcs:ignore Gutenberg.CodeAnalysis.ForbiddenFunctionsAndClasses.ForbiddenFunctionCall
if ( ! gutenberg_is_experiment_enabled( 'gutenberg-form-blocks' ) ) {
return;
}
Expand Down
8 changes: 8 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,14 @@
</rule>
<rule ref="Gutenberg.CodeAnalysis.ForbiddenFunctionsAndClasses">
<include-pattern>./packages/block-library/src/*/*.php</include-pattern>
<!--
Refactoring required: the functions and classes prefixed with 'Gutenberg_' in the files that are being excluded
through the 'exclude-pattern' statements below must be guarded, as they are available only in the Gutenberg context,
not in Core.
-->
<exclude-pattern>./packages/block-library/src/form-input/index.php</exclude-pattern>
<exclude-pattern>./packages/block-library/src/form-submission-notification/index.php</exclude-pattern>
<exclude-pattern>./packages/block-library/src/form/index.php</exclude-pattern>
<properties>
<property name="forbidden_functions" type="array">
<element value="[Gg]utenberg.*"/>
Expand Down

0 comments on commit 255e3ed

Please sign in to comment.