Skip to content

Commit 97d83d5

Browse files
committed
Docs: improve specificity
Miscellaneous other doc specificity fixes. Note: this doesn't fix everything throughout the codebase, but is an iteration to improve things nonetheless.
1 parent b95dde7 commit 97d83d5

19 files changed

+38
-38
lines changed

Diff for: WordPressVIPMinimum/Sniffs/Classes/DeclarationCompatibilitySniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ private function addError( $parentClassName, $methodName, $currentMethodSignatur
315315
*
316316
* @param array $methodSignature Signature of a method.
317317
*
318-
* @return array
318+
* @return array<string>
319319
*/
320320
private function generateParamList( $methodSignature ) {
321321
$paramList = [];

Diff for: WordPressVIPMinimum/Sniffs/Classes/RestrictedExtendClassesSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class RestrictedExtendClassesSniff extends AbstractClassRestrictionsSniff {
1919
/**
2020
* Groups of classes to restrict.
2121
*
22-
* @return array
22+
* @return array<string, array<string, string|array<string>>>
2323
*/
2424
public function getGroups() {
2525
return [

Diff for: WordPressVIPMinimum/Sniffs/Constants/RestrictedConstantsSniff.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class RestrictedConstantsSniff extends Sniff {
1919
/**
2020
* List of restricted constant names.
2121
*
22-
* @var array
22+
* @var array<string>
2323
*/
2424
public $restrictedConstantNames = [
2525
'A8C_PROXIED_REQUEST',
@@ -28,7 +28,7 @@ class RestrictedConstantsSniff extends Sniff {
2828
/**
2929
* List of restricted constant declarations.
3030
*
31-
* @var array
31+
* @var array<string>
3232
*/
3333
public $restrictedConstantDeclaration = [
3434
'JETPACK_DEV_DEBUG',

Diff for: WordPressVIPMinimum/Sniffs/Files/IncludingFileSniff.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
2020
/**
2121
* List of function used for getting paths.
2222
*
23-
* @var array
23+
* @var array<string>
2424
*/
2525
public $getPathFunctions = [
2626
'dirname',
@@ -55,7 +55,7 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
5555
/**
5656
* List of restricted constants.
5757
*
58-
* @var array
58+
* @var array<string, string>
5959
*/
6060
public $restrictedConstants = [
6161
'TEMPLATEPATH' => 'get_template_directory',
@@ -65,7 +65,7 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
6565
/**
6666
* List of allowed constants.
6767
*
68-
* @var array
68+
* @var array<string>
6969
*/
7070
public $allowedConstants = [
7171
'ABSPATH',
@@ -77,7 +77,7 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
7777
* List of keywords allowed for use in custom constants.
7878
* Note: Customizing this property will overwrite current default values.
7979
*
80-
* @var array
80+
* @var array<string>
8181
*/
8282
public $allowedKeywords = [
8383
'PATH',
@@ -87,7 +87,7 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
8787
/**
8888
* Functions used for modify slashes.
8989
*
90-
* @var array
90+
* @var array<string>
9191
*/
9292
public $slashingFunctions = [
9393
'trailingslashit',

Diff for: WordPressVIPMinimum/Sniffs/Files/IncludingNonPHPFileSniff.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class IncludingNonPHPFileSniff extends Sniff {
2323
*
2424
* Files with these extensions are allowed to be `include`d.
2525
*
26-
* @var array Key is the extension, value is irrelevant.
26+
* @var array<string, bool> Key is the extension, value is irrelevant.
2727
*/
2828
private $php_extensions = [
2929
'php' => true,
@@ -34,7 +34,7 @@ class IncludingNonPHPFileSniff extends Sniff {
3434
/**
3535
* File extensions used for SVG and CSS files.
3636
*
37-
* @var array Key is the extension, value is irrelevant.
37+
* @var array<string, bool> Key is the extension, value is irrelevant.
3838
*/
3939
private $svg_css_extensions = [
4040
'css' => true,

Diff for: WordPressVIPMinimum/Sniffs/Functions/CheckReturnValueSniff.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CheckReturnValueSniff extends Sniff {
2424
/**
2525
* Pairs we are about to check.
2626
*
27-
* @var array
27+
* @var array<string, array<string>>
2828
*/
2929
public $catch = [
3030
'esc_url' => [
@@ -48,7 +48,7 @@ class CheckReturnValueSniff extends Sniff {
4848
/**
4949
* Tokens we are about to examine, which are not functions.
5050
*
51-
* @var array
51+
* @var array<string, int|string>
5252
*/
5353
public $notFunctions = [
5454
'foreach' => T_FOREACH,
@@ -293,7 +293,7 @@ public function findNonCheckedVariables( $stackPtr ) {
293293
* Function used as as callback for the array_reduce call.
294294
*
295295
* @param string|null $carry The final string.
296-
* @param mixed $item Processed item.
296+
* @param array $item Processed item.
297297
*
298298
* @return string
299299
*/

Diff for: WordPressVIPMinimum/Sniffs/Functions/DynamicCallsSniff.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class DynamicCallsSniff extends Sniff {
2929
/**
3030
* Functions that should not be called dynamically.
3131
*
32-
* @var array
32+
* @var array<string, bool>
3333
*/
3434
private $disallowed_functions = [
3535
'assert' => true,
@@ -48,7 +48,7 @@ class DynamicCallsSniff extends Sniff {
4848
*
4949
* Populated at run-time.
5050
*
51-
* @var array The key is the name of the variable, the value, its assigned value.
51+
* @var array<string, string> The key is the name of the variable, the value, its assigned value.
5252
*/
5353
private $variables_arr = [];
5454

Diff for: WordPressVIPMinimum/Sniffs/Functions/RestrictedFunctionsSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class RestrictedFunctionsSniff extends AbstractFunctionRestrictionsSniff {
1818
/**
1919
* Groups of functions to restrict.
2020
*
21-
* @return array
21+
* @return array<string, array<string, string|array<string>|array<string, bool>>>
2222
*/
2323
public function getGroups() {
2424

Diff for: WordPressVIPMinimum/Sniffs/Hooks/RestrictedHooksSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class RestrictedHooksSniff extends AbstractFunctionParameterSniff {
3636
/**
3737
* List of restricted filters by groups.
3838
*
39-
* @var array
39+
* @var array<string, array<string, string|array<string>>>
4040
*/
4141
private $restricted_hook_groups = [
4242
'upload_mimes' => [

Diff for: WordPressVIPMinimum/Sniffs/JS/HTMLExecutingFunctionsSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class HTMLExecutingFunctionsSniff extends Sniff {
2424
* Value indicates whether the function's arg is the content to be inserted, or the target where the inserted
2525
* content is to be inserted before/after/replaced. For the latter, the content is in the preceding method's arg.
2626
*
27-
* @var array
27+
* @var array<string, string>
2828
*/
2929
public $HTMLExecutingFunctions = [
3030
'after' => 'content', // jQuery.

Diff for: WordPressVIPMinimum/Sniffs/JS/StringConcatSniff.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ public function process_token( $stackPtr ) {
6363
/**
6464
* Consolidated violation.
6565
*
66-
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
67-
* @param array $data Replacements for the error message.
66+
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
67+
* @param array<string> $data Replacements for the error message.
6868
*
6969
* @return void
7070
*/

Diff for: WordPressVIPMinimum/Sniffs/JS/WindowSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function register() {
3838
/**
3939
* List of window properties that need to be flagged.
4040
*
41-
* @var array
41+
* @var array<string, bool|array<string, bool>>
4242
*/
4343
private $windowProperties = [
4444
'location' => [

Diff for: WordPressVIPMinimum/Sniffs/Performance/LowExpiryCacheTimeSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class LowExpiryCacheTimeSniff extends AbstractFunctionParameterSniff {
4141
/**
4242
* List of WP time constants, see https://codex.wordpress.org/Easier_Expression_of_Time_Constants.
4343
*
44-
* @var array
44+
* @var array<string, int>
4545
*/
4646
protected $wp_time_constants = [
4747
'MINUTE_IN_SECONDS' => 60,

Diff for: WordPressVIPMinimum/Sniffs/Performance/TaxonomyMetaInOptionsSniff.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class TaxonomyMetaInOptionsSniff extends Sniff {
1919
/**
2020
* List of options_ functions
2121
*
22-
* @var array
22+
* @var array<string>
2323
*/
2424
public $option_functions = [
2525
'get_option',
@@ -31,7 +31,7 @@ class TaxonomyMetaInOptionsSniff extends Sniff {
3131
/**
3232
* List of possible variable names holding term ID.
3333
*
34-
* @var array
34+
* @var array<string>
3535
*/
3636
public $taxonomy_term_patterns = [
3737
'category_id',

Diff for: WordPressVIPMinimum/Sniffs/Security/PHPFilterFunctionsSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class PHPFilterFunctionsSniff extends AbstractFunctionParameterSniff {
3838
/**
3939
* List of restricted filter names.
4040
*
41-
* @var array
41+
* @var array<string, bool>
4242
*/
4343
private $restricted_filters = [
4444
'FILTER_DEFAULT' => true,

Diff for: WordPressVIPMinimum/Sniffs/Security/ProperEscapingFunctionSniff.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class ProperEscapingFunctionSniff extends Sniff {
2828
/**
2929
* List of escaping functions which are being tested.
3030
*
31-
* @var array
31+
* @var array<string, string>
3232
*/
3333
protected $escaping_functions = [
3434
'esc_url' => 'url',
@@ -45,7 +45,7 @@ class ProperEscapingFunctionSniff extends Sniff {
4545
/**
4646
* List of tokens we can skip.
4747
*
48-
* @var array
48+
* @var array<int|string, int|string>
4949
*/
5050
private $echo_or_concat_tokens =
5151
[
@@ -63,7 +63,7 @@ class ProperEscapingFunctionSniff extends Sniff {
6363
* for public methods which extending sniffs may be
6464
* relying on.
6565
*
66-
* @var array
66+
* @var array<string>
6767
*/
6868
private $url_attrs = [
6969
'href',
@@ -79,7 +79,7 @@ class ProperEscapingFunctionSniff extends Sniff {
7979
* for public methods which extending sniffs may be
8080
* relying on.
8181
*
82-
* @var array
82+
* @var array<string>
8383
*/
8484
private $attr_endings = [
8585
'=',

Diff for: WordPressVIPMinimum/Sniffs/UserExperience/AdminBarRemovalSniff.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff {
2626
/**
2727
* A list of tokenizers this sniff supports.
2828
*
29-
* @var array
29+
* @var array<string>
3030
*/
3131
public $supportedTokenizers = [
3232
'PHP',
@@ -58,7 +58,7 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff {
5858
/**
5959
* CSS properties this sniff is looking for.
6060
*
61-
* @var array
61+
* @var array<string, array<string, string|float>>
6262
*/
6363
protected $target_css_properties = [
6464
'visibility' => [
@@ -78,7 +78,7 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff {
7878
/**
7979
* CSS selectors this sniff is looking for.
8080
*
81-
* @var array
81+
* @var array<string>
8282
*/
8383
protected $target_css_selectors = [
8484
'.show-admin-bar',
@@ -90,7 +90,7 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff {
9090
*
9191
* Set from the register() method.
9292
*
93-
* @var array
93+
* @var array<int|string>
9494
*/
9595
private $string_tokens = [];
9696

Diff for: WordPressVIPMinimum/Sniffs/Variables/ServerVariablesSniff.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class ServerVariablesSniff extends Sniff {
1818
/**
1919
* List of restricted constant names.
2020
*
21-
* @var array
21+
* @var array<string, array<string, bool>>
2222
*/
2323
public $restrictedVariables = [
2424
'authVariables' => [

Diff for: tests/RulesetTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class RulesetTest {
2828
*
2929
* This is the giant array in the ruleset-test.php files.
3030
*
31-
* @var array
31+
* @var array<string, array<int, int|array<string>>>
3232
*/
3333
public $expected = [];
3434

@@ -82,8 +82,8 @@ class RulesetTest {
8282
/**
8383
* Init the object by processing the test file.
8484
*
85-
* @param string $ruleset Name of the ruleset e.g. WordPressVIPMinimum or WordPress-VIP-Go.
86-
* @param array $expected The array of expected errors, warnings and messages.
85+
* @param string $ruleset Name of the ruleset e.g. WordPressVIPMinimum or WordPress-VIP-Go.
86+
* @param array<string, array<int, int|array<string>>> $expected The array of expected errors, warnings and messages.
8787
*/
8888
public function __construct( $ruleset, $expected = [] ) {
8989
$this->ruleset = $ruleset;

0 commit comments

Comments
 (0)