Skip to content

Commit b454dd6

Browse files
committed
Some PHPCS Updates
1 parent 224e21c commit b454dd6

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

.phpcs.xml

+12-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0"?>
2-
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Example Project" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
2+
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Viget Blocks Toolkit" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/PHPCSStandards/PHP_CodeSniffer/master/phpcs.xsd">
33

44
<description>A custom set of rules to check for a WPized WordPress project</description>
55

@@ -42,24 +42,15 @@
4242
#############################################################################
4343
-->
4444

45+
<rule ref="WordPress">
46+
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
47+
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
48+
</rule>
49+
4550
<!-- Include the WordPress-Extra standard. -->
4651
<rule ref="WordPress-Extra">
47-
<!--
48-
We may want a middle ground though. The best way to do this is add the
49-
entire ruleset, then rule by rule, remove ones that don't suit a project.
50-
We can do this by running `phpcs` with the '-s' flag, which allows us to
51-
see the names of the sniffs reporting errors.
52-
Once we know the sniff names, we can opt to exclude sniffs which don't
53-
suit our project like so.
54-
55-
The below two examples just show how you can exclude rules/error codes.
56-
They are not intended as advice about which sniffs to exclude.
57-
-->
58-
59-
<!--
60-
<exclude name="WordPress.WhiteSpace.ControlStructureSpacing"/>
61-
<exclude name="Modernize.FunctionCalls.Dirname.Nested"/>
62-
-->
52+
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
53+
<exclude name="Universal.Arrays.DisallowShortArraySyntax"/>
6354
</rule>
6455

6556
<!-- Let's also check that everything is properly documented. -->
@@ -105,16 +96,17 @@
10596
<rule ref="WordPress.WP.I18n">
10697
<properties>
10798
<property name="text_domain" type="array">
108-
<element value="wp-starter"/>
109-
<element value="library-wp-starter"/>
99+
<element value="viget-blocks-toolkit"/>
110100
</property>
111101
</properties>
112102
</rule>
113103

114104
<rule ref="WordPress.NamingConventions.PrefixAllGlobals">
115105
<properties>
116106
<property name="prefixes" type="array">
117-
<element value="wpstarter_"/>
107+
<element value="VGTBT_"/>
108+
<element value="vgtbt_"/>
109+
<element value="VigetBlocksToolkit"/>
118110
</property>
119111
</properties>
120112
</rule>

includes/parts-kit.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Viget\VigetBlocksToolkit\Block_Registration;
99

1010
add_filter(
11-
'viget_parts_kit_block_%',
11+
'vgtpk_parts_kit_block_%',
1212
function ( string $output, string $block_name ): string {
1313
$block = Block_Registration::get_block( $block_name );
1414

@@ -19,7 +19,7 @@ function ( string $output, string $block_name ): string {
1919
if ( ! empty( $block['path'] ) ) {
2020
$include = $block['path'] . '/block.php';
2121

22-
// Autoload block.php within block directory
22+
// Autoload block.php within block directory.
2323
if ( file_exists( $include ) ) {
2424
require_once $include;
2525
}
@@ -39,12 +39,12 @@ function ( string $output, string $block_name ): string {
3939
* @return string
4040
*/
4141
function vgtbt_parse_inner_blocks( string $output ): string {
42-
// Check if InnerBlocks tag has a template attribute with regular expression
42+
// Check if InnerBlocks tag has a template attribute with regular expression.
4343
if ( ! preg_match( '/<InnerBlocks[^>]*template="([^"]*)"[^>]*>/i', $output, $matches ) ) {
4444
return $output;
4545
}
4646

47-
// Get the template attribute value
47+
// Get the template attribute value.
4848
$template = $matches[1];
4949
$template = htmlspecialchars_decode( $template );
5050
$template = json_decode( $template, true );

0 commit comments

Comments
 (0)