Skip to content

Commit 462e590

Browse files
authored
Release version 0.2.1
Release version 0.2.1
2 parents 1141d45 + 9244d3e commit 462e590

35 files changed

+216
-191
lines changed

.phpcs.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
<exclude name="WordPress.NamingConventions.ValidVariableName"/>
1818
<exclude name="WordPress.CodeAnalysis.AssignmentInCondition.FoundInWhileCondition"/>
1919
<exclude name="WordPress.WP.AlternativeFunctions"/>
20+
<exclude name="Generic.Arrays.DisallowShortArraySyntax"/>
2021
</rule>
2122

2223
<rule ref="WordPress-Docs"/>
@@ -30,6 +31,9 @@
3031
</properties>
3132
</rule>
3233

34+
<!-- Enforce array short syntax. -->
35+
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
36+
3337
<rule ref="PSR2.Methods.FunctionClosingBrace"/>
3438

3539
<!-- Check code for cross-version PHP compatibility. -->

.travis.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ php:
2222

2323
env:
2424
# Highest supported PHPCS + WPCS versions.
25-
- PHPCS_BRANCH="dev-master" WPCS_BRANCH="dev-master" LINT=1
25+
- PHPCS_BRANCH="dev-master" WPCS_BRANCH="dev-develop" LINT=1
2626
# Lowest supported PHPCS + WPCS versions.
2727
- PHPCS_BRANCH="3.3.1" WPCS_BRANCH="2.1.0"
2828

@@ -56,7 +56,7 @@ jobs:
5656
php: 7.2
5757
env: PHPCS_BRANCH="dev-master" WPCS_BRANCH="2.1.0" LINT=1
5858
- php: 7.2
59-
env: PHPCS_BRANCH="3.3.1" WPCS_BRANCH="dev-master"
59+
env: PHPCS_BRANCH="3.3.1" WPCS_BRANCH="dev-develop"
6060

6161
allow_failures:
6262
# Allow failures for unstable builds.
@@ -65,6 +65,14 @@ jobs:
6565
before_install:
6666
# Speed up build time by disabling Xdebug.
6767
- phpenv config-rm xdebug.ini || echo 'No xdebug config.'
68+
69+
# On stable PHPCS versions, allow for PHP deprecation notices.
70+
# Unit tests don't need to fail on those for stable releases where those issues won't get fixed anymore.
71+
- |
72+
if [[ "$TRAVIS_BUILD_STAGE_NAME" != "Sniff" && $PHPCS_BRANCH != "dev-master" && $WPCS_BRANCH != "dev-develop" ]]; then
73+
echo 'error_reporting = E_ALL & ~E_DEPRECATED' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
74+
fi
75+
6876
- export XMLLINT_INDENT=" "
6977
- composer require squizlabs/php_codesniffer:${PHPCS_BRANCH} wp-coding-standards/wpcs:${WPCS_BRANCH} --no-update --no-suggest --no-scripts
7078
- |

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a
88

99
_No documentation available about unreleased changes as of yet._
1010

11+
## [0.2.1] - 2019-11-17
12+
13+
### Changed
14+
15+
- Added new `$in_list` parameter to the `PrefixAllGlobalsSniff::process_variable_assignment()` method, so that the method is compatible with the upstream WPCS method (changed in WPCS 2.2.0).
16+
- Updated the minimum version requirement for the WordPress Coding Standards dependency to version 2.2.0.
17+
- Replaced the deprecated `WordPress.WP.TimezoneChange` with `WordPress.DateTime.RestrictedFunctions.timezone_change_date_default_timezone_set`
18+
- Enforce the array short syntax when writing sniffs.
19+
- Travis: Minor build script tweaks.
20+
1121
## [0.2.0] - 2019-07-17
1222

1323
### Added
@@ -99,5 +109,6 @@ _No documentation available about unreleased changes as of yet._
99109
- `WordPress.WP.TimezoneChange`: themes should never touch the timezone.
100110

101111
[Unreleased]: https://github.com/WPTRT/WPThemeReview/compare/master...HEAD
112+
[0.2.1]: https://github.com/WPTRT/WPThemeReview/compare/0.2.0...0.2.1
102113
[0.2.0]: https://github.com/WPTRT/WPThemeReview/compare/0.1.0...0.2.0
103114
[0.1.0]: https://github.com/WPTRT/WPThemeReview/compare/1dabb9876caf78209849a01381c0b863ce583d07...0.1.0

WPThemeReview/Sniffs/CoreFunctionality/FileIncludeSniff.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ class FileIncludeSniff implements Sniff {
2727
*
2828
* @var array
2929
*/
30-
protected $file_whitelist = array(
30+
protected $file_whitelist = [
3131
'functions.php' => true,
32-
);
32+
];
3333

3434
/**
3535
* Returns an array of tokens this test wants to listen for.
@@ -61,7 +61,7 @@ public function process( File $phpcsFile, $stackPtr ) {
6161
'Check that %s is not being used to load template files. "get_template_part()" should be used to load template files.',
6262
$stackPtr,
6363
'FileIncludeFound',
64-
array( $token['content'] )
64+
[ $token['content'] ]
6565
);
6666
}
6767
}

WPThemeReview/Sniffs/CoreFunctionality/NoDeregisterCoreScriptSniff.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ class NoDeregisterCoreScriptSniff extends AbstractFunctionParameterSniff {
4242
*
4343
* @var array
4444
*/
45-
protected $target_functions = array(
46-
'wp_deregister_script' => array(
45+
protected $target_functions = [
46+
'wp_deregister_script' => [
4747
'jcrop' => true,
4848
'swfobject' => true,
4949
'swfupload' => true,
@@ -140,8 +140,8 @@ class NoDeregisterCoreScriptSniff extends AbstractFunctionParameterSniff {
140140
'underscore' => true,
141141
'backbone' => true,
142142
'imagesloaded' => true,
143-
),
144-
);
143+
],
144+
];
145145

146146
/**
147147
* Process the parameters of a matched function.
@@ -170,7 +170,7 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p
170170
);
171171

172172
if ( isset( $this->target_functions[ $matched_content ][ $matched_parameter ] ) ) {
173-
$this->throw_prohibited_error( $first_param_token, array( $matched_parameter ) );
173+
$this->throw_prohibited_error( $first_param_token, [ $matched_parameter ] );
174174
return;
175175
}
176176

@@ -193,12 +193,12 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p
193193
}
194194

195195
if ( isset( $this->target_functions[ $matched_content ][ $text ] ) ) {
196-
$this->throw_prohibited_error( $first_param_token, array( $text ) );
196+
$this->throw_prohibited_error( $first_param_token, [ $text ] );
197197
return;
198198
}
199199

200200
if ( true === $found_variable_token ) {
201-
$this->throw_variable_handle_warning( $first_param_token, array( $matched_content, $matched_parameter ) );
201+
$this->throw_variable_handle_warning( $first_param_token, [ $matched_content, $matched_parameter ] );
202202
}
203203
}
204204

@@ -208,7 +208,7 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p
208208
* @param int $stackPtr The position of the first non-empty parameter token in the stack.
209209
* @param array $data Optional input for the data replacements.
210210
*/
211-
public function throw_prohibited_error( $stackPtr, $data = array() ) {
211+
public function throw_prohibited_error( $stackPtr, $data = [] ) {
212212
$this->phpcsFile->addError(
213213
'Deregistering core script "%s" is prohibited.',
214214
$stackPtr,
@@ -223,7 +223,7 @@ public function throw_prohibited_error( $stackPtr, $data = array() ) {
223223
* @param int $stackPtr The position of the first non-empty parameter token in the stack.
224224
* @param array $data Optional input for the data replacements.
225225
*/
226-
public function throw_variable_handle_warning( $stackPtr, $data = array() ) {
226+
public function throw_variable_handle_warning( $stackPtr, $data = [] ) {
227227
$this->phpcsFile->addWarning(
228228
'Deregistering core scripts is prohibited. A variable script handle was found. Inspection of the %s() call needed. Found: %s',
229229
$stackPtr,

WPThemeReview/Sniffs/CoreFunctionality/NoFaviconSniff.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,23 @@ class NoFaviconSniff implements Sniff {
4545
*
4646
* @var array
4747
*/
48-
protected $attribute_blacklist = array(
49-
'rel' => array(
48+
protected $attribute_blacklist = [
49+
'rel' => [
5050
'icon',
5151
'shortcut icon',
5252
'bookmark icon',
5353
'apple-touch-icon',
5454
'apple-touch-icon-precomposed',
55-
),
56-
'name' => array(
55+
],
56+
'name' => [
5757
'msapplication-config',
5858
'msapplication-TileImage',
5959
'msapplication-square70x70logo',
6060
'msapplication-square150x150logo',
6161
'msapplication-wide310x150logo',
6262
'msapplication-square310x310logo',
63-
),
64-
);
63+
],
64+
];
6565

6666
/**
6767
* The regex to catch the blacklisted attributes.
@@ -77,7 +77,7 @@ class NoFaviconSniff implements Sniff {
7777
*/
7878
public function register() {
7979
// Build the regex to be used only once.
80-
$regex_parts = array();
80+
$regex_parts = [];
8181

8282
foreach ( $this->attribute_blacklist as $key => $values ) {
8383
$values = array_map( 'preg_quote', $values, array_fill( 0, count( $values ), '`' ) );

WPThemeReview/Sniffs/CoreFunctionality/PrefixAllGlobalsSniff.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,16 @@ class PrefixAllGlobalsSniff extends WPCSPrefixAllGlobalsSniff {
130130
* local to that function.
131131
*
132132
* @since 0.2.0
133+
* @since 0.2.1 Added $in_list parameter as introduced in WPCS 2.2.0.
133134
*
134-
* @param int $stackPtr The position of the current token in the stack.
135+
* @param int $stackPtr The position of the current token in the stack.
136+
* @param bool $in_list Whether or not this is a variable in a list assignment.
137+
* Defaults to false.
135138
*
136139
* @return int|void Integer stack pointer to skip forward or void to continue
137140
* normal file processing.
138141
*/
139-
protected function process_variable_assignment( $stackPtr ) {
142+
protected function process_variable_assignment( $stackPtr, $in_list = false ) {
140143

141144
// Usage of `strip_quotes` is to ensure `stdin_path` passed by IDEs does not include quotes.
142145
$file = $this->strip_quotes( $this->phpcsFile->getFileName() );
@@ -161,7 +164,7 @@ protected function process_variable_assignment( $stackPtr ) {
161164
}
162165

163166
// Not a typical template file name, defer to the prefix checking in the parent sniff.
164-
return parent::process_variable_assignment( $stackPtr );
167+
return parent::process_variable_assignment( $stackPtr, $in_list );
165168
}
166169

167170
/**

WPThemeReview/Sniffs/PluginTerritory/AdminBarRemovalSniff.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff {
3535
*
3636
* @var array
3737
*/
38-
public $supportedTokenizers = array( 'PHP', 'CSS' );
38+
public $supportedTokenizers = [ 'PHP', 'CSS' ];
3939

4040
/**
4141
* Whether or not the sniff only checks for removal of the admin bar
@@ -58,10 +58,10 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff {
5858
*
5959
* @var array
6060
*/
61-
protected $target_functions = array(
61+
protected $target_functions = [
6262
'show_admin_bar' => true,
6363
'add_filter' => true,
64-
);
64+
];
6565

6666
/**
6767
* CSS properties this sniff is looking for.
@@ -70,20 +70,20 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff {
7070
*
7171
* @var array
7272
*/
73-
protected $target_css_properties = array(
74-
'visibility' => array(
73+
protected $target_css_properties = [
74+
'visibility' => [
7575
'type' => '!=',
7676
'value' => 'hidden',
77-
),
78-
'display' => array(
77+
],
78+
'display' => [
7979
'type' => '!=',
8080
'value' => 'none',
81-
),
82-
'opacity' => array(
81+
],
82+
'opacity' => [
8383
'type' => '>',
8484
'value' => 0.3,
85-
),
86-
);
85+
],
86+
];
8787

8888
/**
8989
* CSS selectors this sniff is looking for.
@@ -92,10 +92,10 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff {
9292
*
9393
* @var array
9494
*/
95-
protected $target_css_selectors = array(
95+
protected $target_css_selectors = [
9696
'.show-admin-bar',
9797
'#wpadminbar',
98-
);
98+
];
9999

100100
/**
101101
* Regex template for use with the CSS selectors in combination with PHP text strings.
@@ -369,7 +369,7 @@ protected function process_css_style( $stackPtr ) {
369369

370370
if ( true === $this->remove_only ) {
371371
// Check the value of the CSS property.
372-
$valuePtr = $this->phpcsFile->findNext( array( \T_COLON, \T_WHITESPACE ), ( $stackPtr + 1 ), null, true );
372+
$valuePtr = $this->phpcsFile->findNext( [ \T_COLON, \T_WHITESPACE ], ( $stackPtr + 1 ), null, true );
373373
$value = $this->tokens[ $valuePtr ]['content'];
374374
$valid = $this->validate_css_property_value( $value, $css_property['type'], $css_property['value'] );
375375
if ( true === $valid ) {

WPThemeReview/Sniffs/PluginTerritory/ForbiddenFunctionsSniff.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,51 +25,51 @@ class ForbiddenFunctionsSniff extends AbstractFunctionRestrictionsSniff {
2525
/**
2626
* Groups of functions to restrict.
2727
*
28-
* Example: groups => array(
29-
* 'lambda' => array(
28+
* Example: groups => [
29+
* 'lambda' => [
3030
* 'type' => 'error' | 'warning',
3131
* 'message' => 'Use anonymous functions instead please!',
32-
* 'functions' => array( 'file_get_contents', 'create_function' ),
33-
* )
34-
* )
32+
* 'functions' => [ 'file_get_contents', 'create_function' ],
33+
* ]
34+
* ]
3535
*
3636
* @return array
3737
*/
3838
public function getGroups() {
39-
return array(
40-
'plugin-territory' => array(
39+
return [
40+
'plugin-territory' => [
4141
'type' => 'error',
4242
'message' => 'Function %s() is not allowed because it is plugin territory.',
43-
'functions' => array(
43+
'functions' => [
4444
'register_post_type',
4545
'register_taxonomy',
4646
'add_shortcode',
4747
'register_taxonomy_for_object_type',
4848
'flush_rewrite_rules',
49-
),
50-
),
49+
],
50+
],
5151

52-
'editor-blocks' => array(
52+
'editor-blocks' => [
5353
'type' => 'error',
5454
'message' => 'Registering and deregistering editor blocks should be done in a plugin, not in a theme. Found %s().',
55-
'functions' => array(
55+
'functions' => [
5656
'register_block_*',
5757
'unregister_block_*',
58-
),
59-
),
58+
],
59+
],
6060

61-
'cron-functionality' => array(
61+
'cron-functionality' => [
6262
'type' => 'error',
6363
'message' => 'Themes should not be running regular (Cron) tasks. Found %s().',
64-
'functions' => array(
64+
'functions' => [
6565
'wp_clear_scheduled_hook',
6666
'wp_cron',
6767
'wp_reschedule_event',
6868
'wp_schedule_*',
6969
'wp_unschedule_*',
70-
),
71-
),
72-
);
70+
],
71+
],
72+
];
7373
}
7474

7575
}

0 commit comments

Comments
 (0)