Skip to content

Commit

Permalink
Docs: improve specificity
Browse files Browse the repository at this point in the history
Miscellaneous other doc specificity fixes.

Note: this doesn't fix everything throughout the codebase, but is an iteration to improve things nonetheless.
  • Loading branch information
jrfnl committed Nov 8, 2024
1 parent b95dde7 commit 97d83d5
Show file tree
Hide file tree
Showing 19 changed files with 38 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ private function addError( $parentClassName, $methodName, $currentMethodSignatur
*
* @param array $methodSignature Signature of a method.
*
* @return array
* @return array<string>
*/
private function generateParamList( $methodSignature ) {
$paramList = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RestrictedExtendClassesSniff extends AbstractClassRestrictionsSniff {
/**
* Groups of classes to restrict.
*
* @return array
* @return array<string, array<string, string|array<string>>>
*/
public function getGroups() {
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class RestrictedConstantsSniff extends Sniff {
/**
* List of restricted constant names.
*
* @var array
* @var array<string>
*/
public $restrictedConstantNames = [
'A8C_PROXIED_REQUEST',
Expand All @@ -28,7 +28,7 @@ class RestrictedConstantsSniff extends Sniff {
/**
* List of restricted constant declarations.
*
* @var array
* @var array<string>
*/
public $restrictedConstantDeclaration = [
'JETPACK_DEV_DEBUG',
Expand Down
10 changes: 5 additions & 5 deletions WordPressVIPMinimum/Sniffs/Files/IncludingFileSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
/**
* List of function used for getting paths.
*
* @var array
* @var array<string>
*/
public $getPathFunctions = [
'dirname',
Expand Down Expand Up @@ -55,7 +55,7 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
/**
* List of restricted constants.
*
* @var array
* @var array<string, string>
*/
public $restrictedConstants = [
'TEMPLATEPATH' => 'get_template_directory',
Expand All @@ -65,7 +65,7 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
/**
* List of allowed constants.
*
* @var array
* @var array<string>
*/
public $allowedConstants = [
'ABSPATH',
Expand All @@ -77,7 +77,7 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
* List of keywords allowed for use in custom constants.
* Note: Customizing this property will overwrite current default values.
*
* @var array
* @var array<string>
*/
public $allowedKeywords = [
'PATH',
Expand All @@ -87,7 +87,7 @@ class IncludingFileSniff extends AbstractFunctionRestrictionsSniff {
/**
* Functions used for modify slashes.
*
* @var array
* @var array<string>
*/
public $slashingFunctions = [
'trailingslashit',
Expand Down
4 changes: 2 additions & 2 deletions WordPressVIPMinimum/Sniffs/Files/IncludingNonPHPFileSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class IncludingNonPHPFileSniff extends Sniff {
*
* Files with these extensions are allowed to be `include`d.
*
* @var array Key is the extension, value is irrelevant.
* @var array<string, bool> Key is the extension, value is irrelevant.
*/
private $php_extensions = [
'php' => true,
Expand All @@ -34,7 +34,7 @@ class IncludingNonPHPFileSniff extends Sniff {
/**
* File extensions used for SVG and CSS files.
*
* @var array Key is the extension, value is irrelevant.
* @var array<string, bool> Key is the extension, value is irrelevant.
*/
private $svg_css_extensions = [
'css' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class CheckReturnValueSniff extends Sniff {
/**
* Pairs we are about to check.
*
* @var array
* @var array<string, array<string>>
*/
public $catch = [
'esc_url' => [
Expand All @@ -48,7 +48,7 @@ class CheckReturnValueSniff extends Sniff {
/**
* Tokens we are about to examine, which are not functions.
*
* @var array
* @var array<string, int|string>
*/
public $notFunctions = [
'foreach' => T_FOREACH,
Expand Down Expand Up @@ -293,7 +293,7 @@ public function findNonCheckedVariables( $stackPtr ) {
* Function used as as callback for the array_reduce call.
*
* @param string|null $carry The final string.
* @param mixed $item Processed item.
* @param array $item Processed item.
*
* @return string
*/
Expand Down
4 changes: 2 additions & 2 deletions WordPressVIPMinimum/Sniffs/Functions/DynamicCallsSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class DynamicCallsSniff extends Sniff {
/**
* Functions that should not be called dynamically.
*
* @var array
* @var array<string, bool>
*/
private $disallowed_functions = [
'assert' => true,
Expand All @@ -48,7 +48,7 @@ class DynamicCallsSniff extends Sniff {
*
* Populated at run-time.
*
* @var array The key is the name of the variable, the value, its assigned value.
* @var array<string, string> The key is the name of the variable, the value, its assigned value.
*/
private $variables_arr = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RestrictedFunctionsSniff extends AbstractFunctionRestrictionsSniff {
/**
* Groups of functions to restrict.
*
* @return array
* @return array<string, array<string, string|array<string>|array<string, bool>>>
*/
public function getGroups() {

Expand Down
2 changes: 1 addition & 1 deletion WordPressVIPMinimum/Sniffs/Hooks/RestrictedHooksSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class RestrictedHooksSniff extends AbstractFunctionParameterSniff {
/**
* List of restricted filters by groups.
*
* @var array
* @var array<string, array<string, string|array<string>>>
*/
private $restricted_hook_groups = [
'upload_mimes' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class HTMLExecutingFunctionsSniff extends Sniff {
* Value indicates whether the function's arg is the content to be inserted, or the target where the inserted
* content is to be inserted before/after/replaced. For the latter, the content is in the preceding method's arg.
*
* @var array
* @var array<string, string>
*/
public $HTMLExecutingFunctions = [
'after' => 'content', // jQuery.
Expand Down
4 changes: 2 additions & 2 deletions WordPressVIPMinimum/Sniffs/JS/StringConcatSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ public function process_token( $stackPtr ) {
/**
* Consolidated violation.
*
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
* @param array $data Replacements for the error message.
* @param int $stackPtr The position of the current token in the stack passed in $tokens.
* @param array<string> $data Replacements for the error message.
*
* @return void
*/
Expand Down
2 changes: 1 addition & 1 deletion WordPressVIPMinimum/Sniffs/JS/WindowSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function register() {
/**
* List of window properties that need to be flagged.
*
* @var array
* @var array<string, bool|array<string, bool>>
*/
private $windowProperties = [
'location' => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class LowExpiryCacheTimeSniff extends AbstractFunctionParameterSniff {
/**
* List of WP time constants, see https://codex.wordpress.org/Easier_Expression_of_Time_Constants.
*
* @var array
* @var array<string, int>
*/
protected $wp_time_constants = [
'MINUTE_IN_SECONDS' => 60,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TaxonomyMetaInOptionsSniff extends Sniff {
/**
* List of options_ functions
*
* @var array
* @var array<string>
*/
public $option_functions = [
'get_option',
Expand All @@ -31,7 +31,7 @@ class TaxonomyMetaInOptionsSniff extends Sniff {
/**
* List of possible variable names holding term ID.
*
* @var array
* @var array<string>
*/
public $taxonomy_term_patterns = [
'category_id',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class PHPFilterFunctionsSniff extends AbstractFunctionParameterSniff {
/**
* List of restricted filter names.
*
* @var array
* @var array<string, bool>
*/
private $restricted_filters = [
'FILTER_DEFAULT' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ProperEscapingFunctionSniff extends Sniff {
/**
* List of escaping functions which are being tested.
*
* @var array
* @var array<string, string>
*/
protected $escaping_functions = [
'esc_url' => 'url',
Expand All @@ -45,7 +45,7 @@ class ProperEscapingFunctionSniff extends Sniff {
/**
* List of tokens we can skip.
*
* @var array
* @var array<int|string, int|string>
*/
private $echo_or_concat_tokens =
[
Expand All @@ -63,7 +63,7 @@ class ProperEscapingFunctionSniff extends Sniff {
* for public methods which extending sniffs may be
* relying on.
*
* @var array
* @var array<string>
*/
private $url_attrs = [
'href',
Expand All @@ -79,7 +79,7 @@ class ProperEscapingFunctionSniff extends Sniff {
* for public methods which extending sniffs may be
* relying on.
*
* @var array
* @var array<string>
*/
private $attr_endings = [
'=',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff {
/**
* A list of tokenizers this sniff supports.
*
* @var array
* @var array<string>
*/
public $supportedTokenizers = [
'PHP',
Expand Down Expand Up @@ -58,7 +58,7 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff {
/**
* CSS properties this sniff is looking for.
*
* @var array
* @var array<string, array<string, string|float>>
*/
protected $target_css_properties = [
'visibility' => [
Expand All @@ -78,7 +78,7 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff {
/**
* CSS selectors this sniff is looking for.
*
* @var array
* @var array<string>
*/
protected $target_css_selectors = [
'.show-admin-bar',
Expand All @@ -90,7 +90,7 @@ class AdminBarRemovalSniff extends AbstractFunctionParameterSniff {
*
* Set from the register() method.
*
* @var array
* @var array<int|string>
*/
private $string_tokens = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ServerVariablesSniff extends Sniff {
/**
* List of restricted constant names.
*
* @var array
* @var array<string, array<string, bool>>
*/
public $restrictedVariables = [
'authVariables' => [
Expand Down
6 changes: 3 additions & 3 deletions tests/RulesetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class RulesetTest {
*
* This is the giant array in the ruleset-test.php files.
*
* @var array
* @var array<string, array<int, int|array<string>>>
*/
public $expected = [];

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

0 comments on commit 97d83d5

Please sign in to comment.