From b94cb0bdddf317c29436e670228fe7c32f64e9be Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 23 Aug 2023 18:48:27 +0200 Subject: [PATCH 1/3] Docs: improve test `@return` tags ... and use consistent spacing (blank line between param and return tags). --- .../Tests/Classes/DeclarationCompatibilityUnitTest.php | 4 ++-- .../Tests/Classes/RestrictedExtendClassesUnitTest.php | 4 ++-- .../Tests/Constants/ConstantStringUnitTest.php | 4 ++-- .../Tests/Constants/RestrictedConstantsUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/Files/IncludingFileUnitTest.php | 4 ++-- .../Tests/Files/IncludingNonPHPFileUnitTest.php | 4 ++-- .../Tests/Functions/CheckReturnValueUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/Functions/DynamicCallsUnitTest.php | 4 ++-- .../Tests/Functions/RestrictedFunctionsUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/Functions/StripTagsUnitTest.php | 4 ++-- .../Tests/Hooks/AlwaysReturnInFilterUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/Hooks/PreGetPostsUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/Hooks/RestrictedHooksUnitTest.php | 4 ++-- .../Tests/JS/DangerouslySetInnerHTMLUnitTest.php | 4 ++-- .../Tests/JS/HTMLExecutingFunctionsUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/JS/InnerHTMLUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/JS/StringConcatUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/JS/StrippingTagsUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/JS/WindowUnitTest.php | 4 ++-- .../Tests/Performance/CacheValueOverrideUnitTest.php | 4 ++-- .../Tests/Performance/FetchingRemoteDataUnitTest.php | 4 ++-- .../Tests/Performance/LowExpiryCacheTimeUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/Performance/NoPagingUnitTest.php | 4 ++-- .../Tests/Performance/OrderByRandUnitTest.php | 4 ++-- .../Tests/Performance/RegexpCompareUnitTest.php | 4 ++-- .../Tests/Performance/RemoteRequestTimeoutUnitTest.php | 4 ++-- .../Tests/Performance/TaxonomyMetaInOptionsUnitTest.php | 4 ++-- .../Tests/Performance/WPQueryParamsUnitTest.php | 4 ++-- .../Tests/Security/EscapingVoidReturnFunctionsUnitTest.php | 4 ++-- .../Tests/Security/ExitAfterRedirectUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/Security/MustacheUnitTest.php | 4 ++-- .../Tests/Security/PHPFilterFunctionsUnitTest.php | 4 ++-- .../Tests/Security/ProperEscapingFunctionUnitTest.php | 4 ++-- .../Tests/Security/StaticStrreplaceUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/Security/TwigUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/Security/UnderscorejsUnitTest.php | 4 ++-- WordPressVIPMinimum/Tests/Security/VuejsUnitTest.php | 4 ++-- .../Tests/UserExperience/AdminBarRemovalUnitTest.php | 5 +++-- .../Tests/Variables/RestrictedVariablesUnitTest.php | 4 ++-- .../Tests/Variables/ServerVariablesUnitTest.php | 4 ++-- 40 files changed, 81 insertions(+), 80 deletions(-) diff --git a/WordPressVIPMinimum/Tests/Classes/DeclarationCompatibilityUnitTest.php b/WordPressVIPMinimum/Tests/Classes/DeclarationCompatibilityUnitTest.php index 65500c20..1fb8cb67 100644 --- a/WordPressVIPMinimum/Tests/Classes/DeclarationCompatibilityUnitTest.php +++ b/WordPressVIPMinimum/Tests/Classes/DeclarationCompatibilityUnitTest.php @@ -21,7 +21,7 @@ class DeclarationCompatibilityUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -55,7 +55,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Classes/RestrictedExtendClassesUnitTest.php b/WordPressVIPMinimum/Tests/Classes/RestrictedExtendClassesUnitTest.php index 7a6f4d1d..7f4912c5 100644 --- a/WordPressVIPMinimum/Tests/Classes/RestrictedExtendClassesUnitTest.php +++ b/WordPressVIPMinimum/Tests/Classes/RestrictedExtendClassesUnitTest.php @@ -21,7 +21,7 @@ class RestrictedExtendClassesUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -30,7 +30,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Constants/ConstantStringUnitTest.php b/WordPressVIPMinimum/Tests/Constants/ConstantStringUnitTest.php index 47915762..f65342fc 100644 --- a/WordPressVIPMinimum/Tests/Constants/ConstantStringUnitTest.php +++ b/WordPressVIPMinimum/Tests/Constants/ConstantStringUnitTest.php @@ -21,7 +21,7 @@ class ConstantStringUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -33,7 +33,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Constants/RestrictedConstantsUnitTest.php b/WordPressVIPMinimum/Tests/Constants/RestrictedConstantsUnitTest.php index ea01991c..33d59549 100644 --- a/WordPressVIPMinimum/Tests/Constants/RestrictedConstantsUnitTest.php +++ b/WordPressVIPMinimum/Tests/Constants/RestrictedConstantsUnitTest.php @@ -21,7 +21,7 @@ class RestrictedConstantsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -34,7 +34,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Files/IncludingFileUnitTest.php b/WordPressVIPMinimum/Tests/Files/IncludingFileUnitTest.php index 4d1678e0..68017835 100644 --- a/WordPressVIPMinimum/Tests/Files/IncludingFileUnitTest.php +++ b/WordPressVIPMinimum/Tests/Files/IncludingFileUnitTest.php @@ -20,7 +20,7 @@ class IncludingFileUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -36,7 +36,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Files/IncludingNonPHPFileUnitTest.php b/WordPressVIPMinimum/Tests/Files/IncludingNonPHPFileUnitTest.php index 118a3960..0822ad88 100644 --- a/WordPressVIPMinimum/Tests/Files/IncludingNonPHPFileUnitTest.php +++ b/WordPressVIPMinimum/Tests/Files/IncludingNonPHPFileUnitTest.php @@ -21,7 +21,7 @@ class IncludingNonPHPFileUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -54,7 +54,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Functions/CheckReturnValueUnitTest.php b/WordPressVIPMinimum/Tests/Functions/CheckReturnValueUnitTest.php index a7558dfd..d86bea52 100644 --- a/WordPressVIPMinimum/Tests/Functions/CheckReturnValueUnitTest.php +++ b/WordPressVIPMinimum/Tests/Functions/CheckReturnValueUnitTest.php @@ -21,7 +21,7 @@ class CheckReturnValueUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -36,7 +36,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Functions/DynamicCallsUnitTest.php b/WordPressVIPMinimum/Tests/Functions/DynamicCallsUnitTest.php index 98ceb4ee..c98cc6e7 100644 --- a/WordPressVIPMinimum/Tests/Functions/DynamicCallsUnitTest.php +++ b/WordPressVIPMinimum/Tests/Functions/DynamicCallsUnitTest.php @@ -21,7 +21,7 @@ class DynamicCallsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -34,7 +34,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php b/WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php index 66479acd..35170b9b 100644 --- a/WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php +++ b/WordPressVIPMinimum/Tests/Functions/RestrictedFunctionsUnitTest.php @@ -21,7 +21,7 @@ class RestrictedFunctionsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -107,7 +107,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Functions/StripTagsUnitTest.php b/WordPressVIPMinimum/Tests/Functions/StripTagsUnitTest.php index 26cd2597..40cdb485 100644 --- a/WordPressVIPMinimum/Tests/Functions/StripTagsUnitTest.php +++ b/WordPressVIPMinimum/Tests/Functions/StripTagsUnitTest.php @@ -21,7 +21,7 @@ class StripTagsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -30,7 +30,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Hooks/AlwaysReturnInFilterUnitTest.php b/WordPressVIPMinimum/Tests/Hooks/AlwaysReturnInFilterUnitTest.php index 323d2640..fdd7d05e 100644 --- a/WordPressVIPMinimum/Tests/Hooks/AlwaysReturnInFilterUnitTest.php +++ b/WordPressVIPMinimum/Tests/Hooks/AlwaysReturnInFilterUnitTest.php @@ -22,7 +22,7 @@ class AlwaysReturnInFilterUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -40,7 +40,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Hooks/PreGetPostsUnitTest.php b/WordPressVIPMinimum/Tests/Hooks/PreGetPostsUnitTest.php index 90b429dc..2ed915a6 100644 --- a/WordPressVIPMinimum/Tests/Hooks/PreGetPostsUnitTest.php +++ b/WordPressVIPMinimum/Tests/Hooks/PreGetPostsUnitTest.php @@ -21,7 +21,7 @@ class PreGetPostsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -30,7 +30,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Hooks/RestrictedHooksUnitTest.php b/WordPressVIPMinimum/Tests/Hooks/RestrictedHooksUnitTest.php index 4b84e342..9f3553c5 100644 --- a/WordPressVIPMinimum/Tests/Hooks/RestrictedHooksUnitTest.php +++ b/WordPressVIPMinimum/Tests/Hooks/RestrictedHooksUnitTest.php @@ -22,7 +22,7 @@ class RestrictedHooksUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -31,7 +31,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/JS/DangerouslySetInnerHTMLUnitTest.php b/WordPressVIPMinimum/Tests/JS/DangerouslySetInnerHTMLUnitTest.php index eb2c0321..4a568119 100644 --- a/WordPressVIPMinimum/Tests/JS/DangerouslySetInnerHTMLUnitTest.php +++ b/WordPressVIPMinimum/Tests/JS/DangerouslySetInnerHTMLUnitTest.php @@ -21,7 +21,7 @@ class DangerouslySetInnerHTMLUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -32,7 +32,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/JS/HTMLExecutingFunctionsUnitTest.php b/WordPressVIPMinimum/Tests/JS/HTMLExecutingFunctionsUnitTest.php index 97f841d4..aa1836a3 100644 --- a/WordPressVIPMinimum/Tests/JS/HTMLExecutingFunctionsUnitTest.php +++ b/WordPressVIPMinimum/Tests/JS/HTMLExecutingFunctionsUnitTest.php @@ -21,7 +21,7 @@ class HTMLExecutingFunctionsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -30,7 +30,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/JS/InnerHTMLUnitTest.php b/WordPressVIPMinimum/Tests/JS/InnerHTMLUnitTest.php index 4c287ec6..6fd4871c 100644 --- a/WordPressVIPMinimum/Tests/JS/InnerHTMLUnitTest.php +++ b/WordPressVIPMinimum/Tests/JS/InnerHTMLUnitTest.php @@ -21,7 +21,7 @@ class InnerHTMLUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -30,7 +30,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/JS/StringConcatUnitTest.php b/WordPressVIPMinimum/Tests/JS/StringConcatUnitTest.php index d5c74039..94ab2535 100644 --- a/WordPressVIPMinimum/Tests/JS/StringConcatUnitTest.php +++ b/WordPressVIPMinimum/Tests/JS/StringConcatUnitTest.php @@ -21,7 +21,7 @@ class StringConcatUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -32,7 +32,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/JS/StrippingTagsUnitTest.php b/WordPressVIPMinimum/Tests/JS/StrippingTagsUnitTest.php index 1ee43a79..45c73a1f 100644 --- a/WordPressVIPMinimum/Tests/JS/StrippingTagsUnitTest.php +++ b/WordPressVIPMinimum/Tests/JS/StrippingTagsUnitTest.php @@ -21,7 +21,7 @@ class StrippingTagsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -32,7 +32,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/JS/WindowUnitTest.php b/WordPressVIPMinimum/Tests/JS/WindowUnitTest.php index 8deaae65..283af2c5 100644 --- a/WordPressVIPMinimum/Tests/JS/WindowUnitTest.php +++ b/WordPressVIPMinimum/Tests/JS/WindowUnitTest.php @@ -21,7 +21,7 @@ class WindowUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -49,7 +49,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Performance/CacheValueOverrideUnitTest.php b/WordPressVIPMinimum/Tests/Performance/CacheValueOverrideUnitTest.php index 524e8f1c..e8eb7555 100644 --- a/WordPressVIPMinimum/Tests/Performance/CacheValueOverrideUnitTest.php +++ b/WordPressVIPMinimum/Tests/Performance/CacheValueOverrideUnitTest.php @@ -21,7 +21,7 @@ class CacheValueOverrideUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -32,7 +32,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Performance/FetchingRemoteDataUnitTest.php b/WordPressVIPMinimum/Tests/Performance/FetchingRemoteDataUnitTest.php index 363a1e1d..922d8d9c 100644 --- a/WordPressVIPMinimum/Tests/Performance/FetchingRemoteDataUnitTest.php +++ b/WordPressVIPMinimum/Tests/Performance/FetchingRemoteDataUnitTest.php @@ -21,7 +21,7 @@ class FetchingRemoteDataUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -30,7 +30,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Performance/LowExpiryCacheTimeUnitTest.php b/WordPressVIPMinimum/Tests/Performance/LowExpiryCacheTimeUnitTest.php index f3f6928d..fa706edd 100644 --- a/WordPressVIPMinimum/Tests/Performance/LowExpiryCacheTimeUnitTest.php +++ b/WordPressVIPMinimum/Tests/Performance/LowExpiryCacheTimeUnitTest.php @@ -21,7 +21,7 @@ class LowExpiryCacheTimeUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -30,7 +30,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Performance/NoPagingUnitTest.php b/WordPressVIPMinimum/Tests/Performance/NoPagingUnitTest.php index d1bf5b8e..66885a22 100644 --- a/WordPressVIPMinimum/Tests/Performance/NoPagingUnitTest.php +++ b/WordPressVIPMinimum/Tests/Performance/NoPagingUnitTest.php @@ -23,7 +23,7 @@ class NoPagingUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -35,7 +35,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Performance/OrderByRandUnitTest.php b/WordPressVIPMinimum/Tests/Performance/OrderByRandUnitTest.php index a7e28a75..e49bbcb6 100644 --- a/WordPressVIPMinimum/Tests/Performance/OrderByRandUnitTest.php +++ b/WordPressVIPMinimum/Tests/Performance/OrderByRandUnitTest.php @@ -23,7 +23,7 @@ class OrderByRandUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -39,7 +39,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Performance/RegexpCompareUnitTest.php b/WordPressVIPMinimum/Tests/Performance/RegexpCompareUnitTest.php index 480abd70..a0b714d8 100644 --- a/WordPressVIPMinimum/Tests/Performance/RegexpCompareUnitTest.php +++ b/WordPressVIPMinimum/Tests/Performance/RegexpCompareUnitTest.php @@ -21,7 +21,7 @@ class RegexpCompareUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -35,7 +35,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Performance/RemoteRequestTimeoutUnitTest.php b/WordPressVIPMinimum/Tests/Performance/RemoteRequestTimeoutUnitTest.php index 756beb96..b25e072d 100644 --- a/WordPressVIPMinimum/Tests/Performance/RemoteRequestTimeoutUnitTest.php +++ b/WordPressVIPMinimum/Tests/Performance/RemoteRequestTimeoutUnitTest.php @@ -21,7 +21,7 @@ class RemoteRequestTimeoutUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -32,7 +32,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Performance/TaxonomyMetaInOptionsUnitTest.php b/WordPressVIPMinimum/Tests/Performance/TaxonomyMetaInOptionsUnitTest.php index 6849a3b1..5c64334f 100644 --- a/WordPressVIPMinimum/Tests/Performance/TaxonomyMetaInOptionsUnitTest.php +++ b/WordPressVIPMinimum/Tests/Performance/TaxonomyMetaInOptionsUnitTest.php @@ -21,7 +21,7 @@ class TaxonomyMetaInOptionsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -30,7 +30,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Performance/WPQueryParamsUnitTest.php b/WordPressVIPMinimum/Tests/Performance/WPQueryParamsUnitTest.php index fd1bae70..d1a2b4e7 100644 --- a/WordPressVIPMinimum/Tests/Performance/WPQueryParamsUnitTest.php +++ b/WordPressVIPMinimum/Tests/Performance/WPQueryParamsUnitTest.php @@ -21,7 +21,7 @@ class WPQueryParamsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -33,7 +33,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Security/EscapingVoidReturnFunctionsUnitTest.php b/WordPressVIPMinimum/Tests/Security/EscapingVoidReturnFunctionsUnitTest.php index 3737e264..5e039b73 100644 --- a/WordPressVIPMinimum/Tests/Security/EscapingVoidReturnFunctionsUnitTest.php +++ b/WordPressVIPMinimum/Tests/Security/EscapingVoidReturnFunctionsUnitTest.php @@ -21,7 +21,7 @@ class EscapingVoidReturnFunctionsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -32,7 +32,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Security/ExitAfterRedirectUnitTest.php b/WordPressVIPMinimum/Tests/Security/ExitAfterRedirectUnitTest.php index 2670312f..1549c076 100644 --- a/WordPressVIPMinimum/Tests/Security/ExitAfterRedirectUnitTest.php +++ b/WordPressVIPMinimum/Tests/Security/ExitAfterRedirectUnitTest.php @@ -21,7 +21,7 @@ class ExitAfterRedirectUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -33,7 +33,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Security/MustacheUnitTest.php b/WordPressVIPMinimum/Tests/Security/MustacheUnitTest.php index f2667b00..001c88cf 100644 --- a/WordPressVIPMinimum/Tests/Security/MustacheUnitTest.php +++ b/WordPressVIPMinimum/Tests/Security/MustacheUnitTest.php @@ -21,7 +21,7 @@ class MustacheUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -30,7 +30,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Security/PHPFilterFunctionsUnitTest.php b/WordPressVIPMinimum/Tests/Security/PHPFilterFunctionsUnitTest.php index 3ab33db8..edc3333f 100644 --- a/WordPressVIPMinimum/Tests/Security/PHPFilterFunctionsUnitTest.php +++ b/WordPressVIPMinimum/Tests/Security/PHPFilterFunctionsUnitTest.php @@ -21,7 +21,7 @@ class PHPFilterFunctionsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -30,7 +30,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Security/ProperEscapingFunctionUnitTest.php b/WordPressVIPMinimum/Tests/Security/ProperEscapingFunctionUnitTest.php index c01b9356..70af9cda 100644 --- a/WordPressVIPMinimum/Tests/Security/ProperEscapingFunctionUnitTest.php +++ b/WordPressVIPMinimum/Tests/Security/ProperEscapingFunctionUnitTest.php @@ -23,7 +23,7 @@ class ProperEscapingFunctionUnitTest extends AbstractSniffUnitTest { * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList( $testFile = '' ) { switch ( $testFile ) { @@ -71,7 +71,7 @@ public function getErrorList( $testFile = '' ) { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Security/StaticStrreplaceUnitTest.php b/WordPressVIPMinimum/Tests/Security/StaticStrreplaceUnitTest.php index bd4dd0cd..2209a462 100644 --- a/WordPressVIPMinimum/Tests/Security/StaticStrreplaceUnitTest.php +++ b/WordPressVIPMinimum/Tests/Security/StaticStrreplaceUnitTest.php @@ -21,7 +21,7 @@ class StaticStrreplaceUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -33,7 +33,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; diff --git a/WordPressVIPMinimum/Tests/Security/TwigUnitTest.php b/WordPressVIPMinimum/Tests/Security/TwigUnitTest.php index 6ff23524..7d6c54c4 100644 --- a/WordPressVIPMinimum/Tests/Security/TwigUnitTest.php +++ b/WordPressVIPMinimum/Tests/Security/TwigUnitTest.php @@ -21,7 +21,7 @@ class TwigUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -30,7 +30,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Security/UnderscorejsUnitTest.php b/WordPressVIPMinimum/Tests/Security/UnderscorejsUnitTest.php index 35540b6d..b70cc8fe 100644 --- a/WordPressVIPMinimum/Tests/Security/UnderscorejsUnitTest.php +++ b/WordPressVIPMinimum/Tests/Security/UnderscorejsUnitTest.php @@ -36,7 +36,7 @@ protected function getTestFiles( $testFileBase ) { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -47,7 +47,7 @@ public function getErrorList() { * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList( $testFile = '' ) { switch ( $testFile ) { diff --git a/WordPressVIPMinimum/Tests/Security/VuejsUnitTest.php b/WordPressVIPMinimum/Tests/Security/VuejsUnitTest.php index 28695106..d539d831 100644 --- a/WordPressVIPMinimum/Tests/Security/VuejsUnitTest.php +++ b/WordPressVIPMinimum/Tests/Security/VuejsUnitTest.php @@ -21,7 +21,7 @@ class VuejsUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return []; @@ -30,7 +30,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/UserExperience/AdminBarRemovalUnitTest.php b/WordPressVIPMinimum/Tests/UserExperience/AdminBarRemovalUnitTest.php index 7eefb77f..1c19641c 100644 --- a/WordPressVIPMinimum/Tests/UserExperience/AdminBarRemovalUnitTest.php +++ b/WordPressVIPMinimum/Tests/UserExperience/AdminBarRemovalUnitTest.php @@ -25,7 +25,7 @@ class AdminBarRemovalUnitTest extends AbstractSniffUnitTest { * * @param string $testFile The name of the file being tested. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList( $testFile = '' ) { @@ -85,7 +85,8 @@ public function getErrorList( $testFile = '' ) { * Returns the lines where warnings should occur. * * @param string $testFile The name of the file being tested. - * @return array => + * + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList( $testFile = '' ) { switch ( $testFile ) { diff --git a/WordPressVIPMinimum/Tests/Variables/RestrictedVariablesUnitTest.php b/WordPressVIPMinimum/Tests/Variables/RestrictedVariablesUnitTest.php index a1f32740..5feb1d8a 100644 --- a/WordPressVIPMinimum/Tests/Variables/RestrictedVariablesUnitTest.php +++ b/WordPressVIPMinimum/Tests/Variables/RestrictedVariablesUnitTest.php @@ -24,7 +24,7 @@ class RestrictedVariablesUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -39,7 +39,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return [ diff --git a/WordPressVIPMinimum/Tests/Variables/ServerVariablesUnitTest.php b/WordPressVIPMinimum/Tests/Variables/ServerVariablesUnitTest.php index 9e4d135d..39678f40 100644 --- a/WordPressVIPMinimum/Tests/Variables/ServerVariablesUnitTest.php +++ b/WordPressVIPMinimum/Tests/Variables/ServerVariablesUnitTest.php @@ -21,7 +21,7 @@ class ServerVariablesUnitTest extends AbstractSniffUnitTest { /** * Returns the lines where errors should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected errors. */ public function getErrorList() { return [ @@ -35,7 +35,7 @@ public function getErrorList() { /** * Returns the lines where warnings should occur. * - * @return array => + * @return array Key is the line number, value is the number of expected warnings. */ public function getWarningList() { return []; From b544e32baac4e7bb16b3c42a83629bec1260af61 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 23 Aug 2023 20:26:57 +0200 Subject: [PATCH 2/3] Docs: various `@var`/`@param`/`@return` tag improvements Definitely not claiming completeness. This is just another iteration step in improving the documented types. --- .../Sniffs/Classes/DeclarationCompatibilitySniff.php | 4 ++-- .../Sniffs/Classes/RestrictedExtendClassesSniff.php | 5 +++-- .../Sniffs/Functions/CheckReturnValueSniff.php | 6 +++--- WordPressVIPMinimum/Sniffs/Functions/StripTagsSniff.php | 6 ++++-- WordPressVIPMinimum/Sniffs/Hooks/PreGetPostsSniff.php | 4 ++-- WordPressVIPMinimum/Sniffs/Hooks/RestrictedHooksSniff.php | 7 +++++-- .../Sniffs/Performance/CacheValueOverrideSniff.php | 2 +- .../Sniffs/Performance/LowExpiryCacheTimeSniff.php | 6 ++++-- .../Sniffs/Security/PHPFilterFunctionsSniff.php | 6 ++++-- .../Sniffs/UserExperience/AdminBarRemovalSniff.php | 5 +++-- tests/RulesetTest.php | 1 + 11 files changed, 32 insertions(+), 20 deletions(-) diff --git a/WordPressVIPMinimum/Sniffs/Classes/DeclarationCompatibilitySniff.php b/WordPressVIPMinimum/Sniffs/Classes/DeclarationCompatibilitySniff.php index dea566e2..334c1674 100644 --- a/WordPressVIPMinimum/Sniffs/Classes/DeclarationCompatibilitySniff.php +++ b/WordPressVIPMinimum/Sniffs/Classes/DeclarationCompatibilitySniff.php @@ -34,7 +34,7 @@ class DeclarationCompatibilitySniff extends AbstractScopeSniff { /** * A list of classes and methods to check. * - * @var string[] + * @var array>> */ public $checkClasses = [ 'WP_Widget' => [ @@ -176,7 +176,7 @@ class DeclarationCompatibilitySniff extends AbstractScopeSniff { /** * List of grouped classes with same methods (as they extend the same parent class) * - * @var string[] + * @var array */ public $checkClassesGroups = [ 'Walker' => [ diff --git a/WordPressVIPMinimum/Sniffs/Classes/RestrictedExtendClassesSniff.php b/WordPressVIPMinimum/Sniffs/Classes/RestrictedExtendClassesSniff.php index b92ffbd8..d57f9d57 100644 --- a/WordPressVIPMinimum/Sniffs/Classes/RestrictedExtendClassesSniff.php +++ b/WordPressVIPMinimum/Sniffs/Classes/RestrictedExtendClassesSniff.php @@ -39,8 +39,9 @@ public function getGroups() { * Process a matched token. * * @param int $stackPtr The position of the current token in the stack. - * @param array $group_name The name of the group which was matched. - * @param string $matched_content The token content (class name) which was matched. + * @param string $group_name The name of the group which was matched. + * @param string $matched_content The token content (class name) which was matched + * in lowercase. * * @return void */ diff --git a/WordPressVIPMinimum/Sniffs/Functions/CheckReturnValueSniff.php b/WordPressVIPMinimum/Sniffs/Functions/CheckReturnValueSniff.php index 02cb436d..1940ab6a 100644 --- a/WordPressVIPMinimum/Sniffs/Functions/CheckReturnValueSniff.php +++ b/WordPressVIPMinimum/Sniffs/Functions/CheckReturnValueSniff.php @@ -112,7 +112,7 @@ private function isFunctionCall( $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack passed in $tokens. * - * @return bool + * @return int|false */ private function isVariableAssignment( $stackPtr ) { @@ -290,8 +290,8 @@ public function findNonCheckedVariables( $stackPtr ) { /** * Function used as as callback for the array_reduce call. * - * @param string $carry The final string. - * @param array $item Processed item. + * @param string|null $carry The final string. + * @param mixed $item Processed item. * * @return string */ diff --git a/WordPressVIPMinimum/Sniffs/Functions/StripTagsSniff.php b/WordPressVIPMinimum/Sniffs/Functions/StripTagsSniff.php index 5434427d..3e0280cc 100644 --- a/WordPressVIPMinimum/Sniffs/Functions/StripTagsSniff.php +++ b/WordPressVIPMinimum/Sniffs/Functions/StripTagsSniff.php @@ -41,9 +41,11 @@ class StripTagsSniff extends AbstractFunctionParameterSniff { * Process the parameters of a matched function. * * @param int $stackPtr The position of the current token in the stack. - * @param array $group_name The name of the group which was matched. - * @param string $matched_content The token content (function name) which was matched. + * @param string $group_name The name of the group which was matched. + * @param string $matched_content The token content (function name) which was matched + * in lowercase. * @param array $parameters Array with information about the parameters. + * * @return int|void Integer stack pointer to skip forward or void to continue * normal file processing. */ diff --git a/WordPressVIPMinimum/Sniffs/Hooks/PreGetPostsSniff.php b/WordPressVIPMinimum/Sniffs/Hooks/PreGetPostsSniff.php index 75b54729..7ec5576a 100644 --- a/WordPressVIPMinimum/Sniffs/Hooks/PreGetPostsSniff.php +++ b/WordPressVIPMinimum/Sniffs/Hooks/PreGetPostsSniff.php @@ -362,8 +362,8 @@ private function isEarlyMainQueryCheck( $stackPtr ) { /** * Is the current code a WP_Query call? * - * @param int $stackPtr The position in the stack where the token was found. - * @param null $method Method. + * @param int $stackPtr The position in the stack where the token was found. + * @param string|null $method Method. * * @return bool */ diff --git a/WordPressVIPMinimum/Sniffs/Hooks/RestrictedHooksSniff.php b/WordPressVIPMinimum/Sniffs/Hooks/RestrictedHooksSniff.php index 43054c2b..90c2c68f 100644 --- a/WordPressVIPMinimum/Sniffs/Hooks/RestrictedHooksSniff.php +++ b/WordPressVIPMinimum/Sniffs/Hooks/RestrictedHooksSniff.php @@ -76,9 +76,11 @@ class RestrictedHooksSniff extends AbstractFunctionParameterSniff { * Process the parameters of a matched function. * * @param int $stackPtr The position of the current token in the stack. - * @param array $group_name The name of the group which was matched. - * @param string $matched_content The token content (function name) which was matched. + * @param string $group_name The name of the group which was matched. + * @param string $matched_content The token content (function name) which was matched + * in lowercase. * @param array $parameters Array with information about the parameters. + * * @return int|void Integer stack pointer to skip forward or void to continue * normal file processing. */ @@ -97,6 +99,7 @@ public function process_parameters( $stackPtr, $group_name, $matched_content, $p * Normalize hook name parameter. * * @param array $parameter Array with information about a parameter. + * * @return string Normalized hook name. */ private function normalize_hook_name_from_parameter( $parameter ) { diff --git a/WordPressVIPMinimum/Sniffs/Performance/CacheValueOverrideSniff.php b/WordPressVIPMinimum/Sniffs/Performance/CacheValueOverrideSniff.php index 26102291..90881a65 100644 --- a/WordPressVIPMinimum/Sniffs/Performance/CacheValueOverrideSniff.php +++ b/WordPressVIPMinimum/Sniffs/Performance/CacheValueOverrideSniff.php @@ -119,7 +119,7 @@ private function isFunctionCall( $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack. * - * @return bool + * @return int|false */ private function isVariableAssignment( $stackPtr ) { diff --git a/WordPressVIPMinimum/Sniffs/Performance/LowExpiryCacheTimeSniff.php b/WordPressVIPMinimum/Sniffs/Performance/LowExpiryCacheTimeSniff.php index 23639560..7bc8ca32 100644 --- a/WordPressVIPMinimum/Sniffs/Performance/LowExpiryCacheTimeSniff.php +++ b/WordPressVIPMinimum/Sniffs/Performance/LowExpiryCacheTimeSniff.php @@ -60,9 +60,11 @@ class LowExpiryCacheTimeSniff extends AbstractFunctionParameterSniff { * Process the parameters of a matched function. * * @param int $stackPtr The position of the current token in the stack. - * @param array $group_name The name of the group which was matched. - * @param string $matched_content The token content (function name) which was matched. + * @param string $group_name The name of the group which was matched. + * @param string $matched_content The token content (function name) which was matched + * in lowercase. * @param array $parameters Array with information about the parameters. + * * @return int|void Integer stack pointer to skip forward or void to continue * normal file processing. */ diff --git a/WordPressVIPMinimum/Sniffs/Security/PHPFilterFunctionsSniff.php b/WordPressVIPMinimum/Sniffs/Security/PHPFilterFunctionsSniff.php index 84278541..d8198118 100644 --- a/WordPressVIPMinimum/Sniffs/Security/PHPFilterFunctionsSniff.php +++ b/WordPressVIPMinimum/Sniffs/Security/PHPFilterFunctionsSniff.php @@ -54,9 +54,11 @@ class PHPFilterFunctionsSniff extends AbstractFunctionParameterSniff { * Process the parameters of a matched function. * * @param int $stackPtr The position of the current token in the stack. - * @param array $group_name The name of the group which was matched. - * @param string $matched_content The token content (function name) which was matched. + * @param string $group_name The name of the group which was matched. + * @param string $matched_content The token content (function name) which was matched + * in lowercase. * @param array $parameters Array with information about the parameters. + * * @return int|void Integer stack pointer to skip forward or void to continue * normal file processing. */ diff --git a/WordPressVIPMinimum/Sniffs/UserExperience/AdminBarRemovalSniff.php b/WordPressVIPMinimum/Sniffs/UserExperience/AdminBarRemovalSniff.php index a029134b..099119e8 100644 --- a/WordPressVIPMinimum/Sniffs/UserExperience/AdminBarRemovalSniff.php +++ b/WordPressVIPMinimum/Sniffs/UserExperience/AdminBarRemovalSniff.php @@ -190,8 +190,9 @@ public function process_token( $stackPtr ) { * Process the parameters of a matched function. * * @param int $stackPtr The position of the current token in the stack. - * @param array $group_name The name of the group which was matched. - * @param string $matched_content The token content (function name) which was matched. + * @param string $group_name The name of the group which was matched. + * @param string $matched_content The token content (function name) which was matched + * in lowercase. * @param array $parameters Array with information about the parameters. * * @return void diff --git a/tests/RulesetTest.php b/tests/RulesetTest.php index ca9b15d0..72432cba 100644 --- a/tests/RulesetTest.php +++ b/tests/RulesetTest.php @@ -199,6 +199,7 @@ private function process_violation( $violation ) { * Check if violation is an error. * * @param \stdClass $violation Violation data. + * * @return bool True if string matches error type. */ private function violation_type_is_error( $violation ) { From 6af9e134765c982950a091a1b7426792c65e6b6f Mon Sep 17 00:00:00 2001 From: jrfnl Date: Wed, 23 Aug 2023 21:09:37 +0200 Subject: [PATCH 3/3] Docs: add missing `@return` tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While WP tends to omit `@return void` statements, this is not WP and documenting the function return type is a good thing™. --- .../Functions/CheckReturnValueSniff.php | 4 ++++ .../Hooks/AlwaysReturnInFilterSniff.php | 8 ++++++++ .../Sniffs/Hooks/PreGetPostsSniff.php | 12 +++++++++++ .../Sniffs/JS/StringConcatSniff.php | 2 ++ .../UserExperience/AdminBarRemovalSniff.php | 2 ++ tests/RulesetTest.php | 20 +++++++++++++++++++ 6 files changed, 48 insertions(+) diff --git a/WordPressVIPMinimum/Sniffs/Functions/CheckReturnValueSniff.php b/WordPressVIPMinimum/Sniffs/Functions/CheckReturnValueSniff.php index 1940ab6a..20f4bfeb 100644 --- a/WordPressVIPMinimum/Sniffs/Functions/CheckReturnValueSniff.php +++ b/WordPressVIPMinimum/Sniffs/Functions/CheckReturnValueSniff.php @@ -140,6 +140,8 @@ private function isVariableAssignment( $stackPtr ) { * Find instances in which a function call is directly passed to another one w/o checking the return type * * @param int $stackPtr The position of the current token in the stack passed in $tokens. + * + * @return void */ public function findDirectFunctionCalls( $stackPtr ) { @@ -305,6 +307,8 @@ public function reduce_array( $carry, $item ) { * @param int $stackPtr The position in the stack where the token was found. * @param string $variableName Variable name. * @param string $callee Function name. + * + * @return void */ private function addNonCheckedVariableError( $stackPtr, $variableName, $callee ) { $message = 'Type of `%s` must be checked before calling `%s()` using that variable.'; diff --git a/WordPressVIPMinimum/Sniffs/Hooks/AlwaysReturnInFilterSniff.php b/WordPressVIPMinimum/Sniffs/Hooks/AlwaysReturnInFilterSniff.php index 907ab5df..03cc8a78 100644 --- a/WordPressVIPMinimum/Sniffs/Hooks/AlwaysReturnInFilterSniff.php +++ b/WordPressVIPMinimum/Sniffs/Hooks/AlwaysReturnInFilterSniff.php @@ -91,6 +91,8 @@ public function process_token( $stackPtr ) { * Process array. * * @param int $stackPtr The position in the stack where the token was found. + * + * @return void */ private function processArray( $stackPtr ) { @@ -124,6 +126,8 @@ private function processArray( $stackPtr ) { * @param int $stackPtr The position in the stack where the token was found. * @param int $start The start of the token. * @param int $end The end of the token. + * + * @return void */ private function processString( $stackPtr, $start = 0, $end = null ) { @@ -151,6 +155,8 @@ private function processString( $stackPtr, $start = 0, $end = null ) { * @param int $stackPtr The position in the stack where the token was found. * @param int $start The start of the token. * @param int $end The end of the token. + * + * @return void */ private function processFunction( $stackPtr, $start = 0, $end = null ) { @@ -172,6 +178,8 @@ private function processFunction( $stackPtr, $start = 0, $end = null ) { * Process function's body * * @param int $stackPtr The position in the stack where the token was found. + * + * @return void */ private function processFunctionBody( $stackPtr ) { diff --git a/WordPressVIPMinimum/Sniffs/Hooks/PreGetPostsSniff.php b/WordPressVIPMinimum/Sniffs/Hooks/PreGetPostsSniff.php index 7ec5576a..ddcf4fac 100644 --- a/WordPressVIPMinimum/Sniffs/Hooks/PreGetPostsSniff.php +++ b/WordPressVIPMinimum/Sniffs/Hooks/PreGetPostsSniff.php @@ -92,6 +92,8 @@ public function process_token( $stackPtr ) { * Process array. * * @param int $stackPtr The position in the stack where the token was found. + * + * @return void */ private function processArray( $stackPtr ) { @@ -114,6 +116,8 @@ private function processArray( $stackPtr ) { * Process string. * * @param int $stackPtr The position in the stack where the token was found. + * + * @return void */ private function processString( $stackPtr ) { @@ -139,6 +143,8 @@ private function processString( $stackPtr ) { * Process function. * * @param int $stackPtr The position in the stack where the token was found. + * + * @return void */ private function processFunction( $stackPtr ) { @@ -172,6 +178,8 @@ private function processFunction( $stackPtr ) { * Process closure. * * @param int $stackPtr The position in the stack where the token was found. + * + * @return void */ private function processClosure( $stackPtr ) { @@ -197,6 +205,8 @@ private function processClosure( $stackPtr ) { * * @param int $stackPtr The position in the stack where the token was found. * @param string $variableName Variable name. + * + * @return void */ private function processFunctionBody( $stackPtr, $variableName ) { @@ -236,6 +246,8 @@ private function processFunctionBody( $stackPtr, $variableName ) { * Consolidated violation. * * @param int $stackPtr The position in the stack where the token was found. + * + * @return void */ private function addPreGetPostsWarning( $stackPtr ) { $message = 'Main WP_Query is being modified without `$query->is_main_query()` check. Needs manual inspection.'; diff --git a/WordPressVIPMinimum/Sniffs/JS/StringConcatSniff.php b/WordPressVIPMinimum/Sniffs/JS/StringConcatSniff.php index 9c217366..4266921b 100644 --- a/WordPressVIPMinimum/Sniffs/JS/StringConcatSniff.php +++ b/WordPressVIPMinimum/Sniffs/JS/StringConcatSniff.php @@ -67,6 +67,8 @@ public function process_token( $stackPtr ) { * * @param int $stackPtr The position of the current token in the stack passed in $tokens. * @param array $data Replacements for the error message. + * + * @return void */ private function addFoundError( $stackPtr, array $data ) { $message = 'HTML string concatenation detected, this is a security risk, use DOM node construction or a templating language instead: %s.'; diff --git a/WordPressVIPMinimum/Sniffs/UserExperience/AdminBarRemovalSniff.php b/WordPressVIPMinimum/Sniffs/UserExperience/AdminBarRemovalSniff.php index 099119e8..6d95cb34 100644 --- a/WordPressVIPMinimum/Sniffs/UserExperience/AdminBarRemovalSniff.php +++ b/WordPressVIPMinimum/Sniffs/UserExperience/AdminBarRemovalSniff.php @@ -372,6 +372,8 @@ protected function process_css_style( $stackPtr ) { * Consolidated violation. * * @param int $stackPtr The position of the current token in the stack passed in $tokens. + * + * @return void */ private function addHidingDetectedError( $stackPtr ) { $message = 'Hiding of the admin bar is not allowed.'; diff --git a/tests/RulesetTest.php b/tests/RulesetTest.php index 72432cba..dde1f0f8 100644 --- a/tests/RulesetTest.php +++ b/tests/RulesetTest.php @@ -124,6 +124,8 @@ public function passes() { /** * Run all the tests. + * + * @return void */ private function run() { // Check for missing expected values. @@ -162,6 +164,8 @@ private function collect_phpcs_result() { * Process the Decoded JSON output from PHP_CodeSniffer. * * @param \stdClass $output Decoded JSON output from PHP_CodeSniffer. + * + * @return void */ private function process_output( $output ) { foreach ( $output->files as $file ) { @@ -173,6 +177,8 @@ private function process_output( $output ) { * Process single file of within PHP_CodeSniffer results. * * @param \stdClass $file File output. + * + * @return void */ private function process_file( $file ) { foreach ( $file->messages as $violation ) { @@ -184,6 +190,8 @@ private function process_file( $file ) { * Process single violation within PHP_CodeSniffer results. * * @param \stdClass $violation Violation data. + * + * @return void */ private function process_violation( $violation ) { if ( $this->violation_type_is_error( $violation ) ) { @@ -210,6 +218,8 @@ private function violation_type_is_error( $violation ) { * Add 1 to the number of errors for the given line. * * @param int $line Line number. + * + * @return void */ private function add_error_for_line( $line ) { $this->errors[ $line ] = isset( $this->errors[ $line ] ) ? ++$this->errors[ $line ] : 1; @@ -219,6 +229,8 @@ private function add_error_for_line( $line ) { * Add 1 to the number of errors for the given line. * * @param int $line Line number. + * + * @return void */ private function add_warning_for_line( $line ) { $this->warnings[ $line ] = isset( $this->warnings[ $line ] ) ? ++$this->warnings[ $line ] : 1; @@ -229,6 +241,8 @@ private function add_warning_for_line( $line ) { * * @param int $line Line number. * @param string $message Message. + * + * @return void */ private function add_message_for_line( $line, $message ) { $this->messages[ $line ] = ( ! isset( $this->messages[ $line ] ) || ! is_array( $this->messages[ $line ] ) ) ? [ $message ] : array_merge( $this->messages[ $line ], [ $message ] ); @@ -236,6 +250,8 @@ private function add_message_for_line( $line, $message ) { /** * Check whether all expected numbers of errors and warnings are present in the output. + * + * @return void */ private function check_missing_expected_values() { foreach ( $this->expected as $type => $lines ) { @@ -261,6 +277,8 @@ private function check_missing_expected_values() { /** * Check whether there are no unexpected numbers of errors and warnings. + * + * @return void */ private function check_unexpected_values() { foreach ( [ 'errors', 'warnings' ] as $type ) { @@ -317,6 +335,8 @@ private function check_messages() { * @param string $type The type of the issue. * @param int $number Real number of issues. * @param int $line Line number. + * + * @return void */ private function error_warning_message( $expected, $type, $number, $line ) { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped