sdc-build-wp 4.1.0 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/composer.json +2 -3
  2. package/composer.lock +3 -313
  3. package/index.js +38 -21
  4. package/lib/blocks.js +8 -6
  5. package/lib/style.js +17 -0
  6. package/package.json +1 -1
  7. package/vendor/composer/autoload_classmap.php +0 -37
  8. package/vendor/composer/autoload_psr4.php +0 -1
  9. package/vendor/composer/autoload_real.php +2 -0
  10. package/vendor/composer/autoload_static.php +0 -53
  11. package/vendor/composer/installed.json +1 -329
  12. package/vendor/composer/installed.php +3 -39
  13. package/vendor/composer/platform_check.php +26 -0
  14. package/lib/bustCache.js +0 -14
  15. package/vendor/dealerdirect/phpcodesniffer-composer-installer/LICENSE.md +0 -22
  16. package/vendor/dealerdirect/phpcodesniffer-composer-installer/README.md +0 -285
  17. package/vendor/dealerdirect/phpcodesniffer-composer-installer/composer.json +0 -71
  18. package/vendor/dealerdirect/phpcodesniffer-composer-installer/src/Plugin.php +0 -637
  19. package/vendor/phpcsstandards/phpcsextra/CHANGELOG.md +0 -590
  20. package/vendor/phpcsstandards/phpcsextra/LICENSE +0 -165
  21. package/vendor/phpcsstandards/phpcsextra/Modernize/Docs/FunctionCalls/DirnameStandard.xml +0 -40
  22. package/vendor/phpcsstandards/phpcsextra/Modernize/Sniffs/FunctionCalls/DirnameSniff.php +0 -382
  23. package/vendor/phpcsstandards/phpcsextra/Modernize/ruleset.xml +0 -5
  24. package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/Docs/Arrays/ArrayBraceSpacingStandard.xml +0 -94
  25. package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/Docs/Arrays/CommaAfterLastStandard.xml +0 -43
  26. package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/Sniffs/Arrays/ArrayBraceSpacingSniff.php +0 -305
  27. package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/Sniffs/Arrays/CommaAfterLastSniff.php +0 -226
  28. package/vendor/phpcsstandards/phpcsextra/NormalizedArrays/ruleset.xml +0 -5
  29. package/vendor/phpcsstandards/phpcsextra/README.md +0 -573
  30. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Arrays/DisallowShortArraySyntaxStandard.xml +0 -27
  31. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Arrays/DuplicateArrayKeyStandard.xml +0 -44
  32. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Arrays/MixedArrayKeyTypesStandard.xml +0 -40
  33. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Arrays/MixedKeyedUnkeyedArrayStandard.xml +0 -31
  34. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/DisallowAnonClassParenthesesStandard.xml +0 -24
  35. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/DisallowFinalClassStandard.xml +0 -25
  36. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/ModifierKeywordOrderStandard.xml +0 -27
  37. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/RequireAnonClassParenthesesStandard.xml +0 -23
  38. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Classes/RequireFinalClassStandard.xml +0 -25
  39. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/ConstructorDestructorReturnStandard.xml +0 -64
  40. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/ForeachUniqueAssignmentStandard.xml +0 -26
  41. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/NoDoubleNegativeStandard.xml +0 -27
  42. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/NoEchoSprintfStandard.xml +0 -25
  43. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/CodeAnalysis/StaticInFinalClassStandard.xml +0 -43
  44. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Constants/LowercaseClassResolutionKeywordStandard.xml +0 -23
  45. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Constants/ModifierKeywordOrderStandard.xml +0 -30
  46. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Constants/UppercaseMagicConstantsStandard.xml +0 -25
  47. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/ControlStructures/DisallowAlternativeSyntaxStandard.xml +0 -35
  48. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/ControlStructures/DisallowLonelyIfStandard.xml +0 -49
  49. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/ControlStructures/IfElseDeclarationStandard.xml +0 -37
  50. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Files/SeparateFunctionsFromOOStandard.xml +0 -45
  51. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/NoLongClosuresStandard.xml +0 -42
  52. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/FunctionDeclarations/RequireFinalMethodsInTraitsStandard.xml +0 -33
  53. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Lists/DisallowLongListSyntaxStandard.xml +0 -23
  54. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Lists/DisallowShortListSyntaxStandard.xml +0 -23
  55. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Namespaces/DisallowCurlyBraceSyntaxStandard.xml +0 -27
  56. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Namespaces/DisallowDeclarationWithoutNameStandard.xml +0 -25
  57. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Namespaces/EnforceCurlyBraceSyntaxStandard.xml +0 -27
  58. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Namespaces/OneDeclarationPerFileStandard.xml +0 -27
  59. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/NamingConventions/NoReservedKeywordParameterNamesStandard.xml +0 -23
  60. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/OOStructures/AlphabeticExtendsImplementsStandard.xml +0 -27
  61. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/ConcatPositionStandard.xml +0 -31
  62. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/DisallowLogicalAndOrStandard.xml +0 -30
  63. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/DisallowShortTernaryStandard.xml +0 -26
  64. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/DisallowStandalonePostIncrementDecrementStandard.xml +0 -44
  65. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/StrictComparisonsStandard.xml +0 -29
  66. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/Operators/TypeSeparatorSpacingStandard.xml +0 -33
  67. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/PHP/LowercasePHPTagStandard.xml +0 -25
  68. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/PHP/OneStatementInShortEchoTagStandard.xml +0 -41
  69. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowMixedGroupUseStandard.xml +0 -39
  70. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowUseClassStandard.xml +0 -25
  71. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowUseConstStandard.xml +0 -25
  72. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/DisallowUseFunctionStandard.xml +0 -25
  73. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/KeywordSpacingStandard.xml +0 -29
  74. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/LowercaseFunctionConstStandard.xml +0 -25
  75. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/NoLeadingBackslashStandard.xml +0 -23
  76. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/UseStatements/NoUselessAliasesStandard.xml +0 -30
  77. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/AnonClassKeywordSpacingStandard.xml +0 -31
  78. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/CommaSpacingStandard.xml +0 -94
  79. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/DisallowInlineTabsStandard.xml +0 -25
  80. package/vendor/phpcsstandards/phpcsextra/Universal/Docs/WhiteSpace/PrecisionAlignmentStandard.xml +0 -29
  81. package/vendor/phpcsstandards/phpcsextra/Universal/Helpers/DummyTokenizer.php +0 -60
  82. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php +0 -89
  83. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/DuplicateArrayKeySniff.php +0 -297
  84. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/MixedArrayKeyTypesSniff.php +0 -174
  85. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Arrays/MixedKeyedUnkeyedArraySniff.php +0 -134
  86. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/DisallowAnonClassParenthesesSniff.php +0 -112
  87. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/DisallowFinalClassSniff.php +0 -116
  88. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/ModifierKeywordOrderSniff.php +0 -188
  89. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/RequireAnonClassParenthesesSniff.php +0 -81
  90. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Classes/RequireFinalClassSniff.php +0 -102
  91. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/ConstructorDestructorReturnSniff.php +0 -211
  92. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/ForeachUniqueAssignmentSniff.php +0 -153
  93. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/NoDoubleNegativeSniff.php +0 -269
  94. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/NoEchoSprintfSniff.php +0 -131
  95. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/CodeAnalysis/StaticInFinalClassSniff.php +0 -216
  96. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Constants/LowercaseClassResolutionKeywordSniff.php +0 -106
  97. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Constants/ModifierKeywordOrderSniff.php +0 -199
  98. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Constants/UppercaseMagicConstantsSniff.php +0 -89
  99. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/ControlStructures/DisallowAlternativeSyntaxSniff.php +0 -216
  100. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/ControlStructures/DisallowLonelyIfSniff.php +0 -348
  101. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/ControlStructures/IfElseDeclarationSniff.php +0 -164
  102. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Files/SeparateFunctionsFromOOSniff.php +0 -190
  103. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/NoLongClosuresSniff.php +0 -233
  104. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/FunctionDeclarations/RequireFinalMethodsInTraitsSniff.php +0 -120
  105. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Lists/DisallowLongListSyntaxSniff.php +0 -71
  106. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Lists/DisallowShortListSyntaxSniff.php +0 -86
  107. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Namespaces/DisallowCurlyBraceSyntaxSniff.php +0 -81
  108. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Namespaces/DisallowDeclarationWithoutNameSniff.php +0 -80
  109. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Namespaces/EnforceCurlyBraceSyntaxSniff.php +0 -81
  110. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Namespaces/OneDeclarationPerFileSniff.php +0 -96
  111. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/NamingConventions/NoReservedKeywordParameterNamesSniff.php +0 -190
  112. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/OOStructures/AlphabeticExtendsImplementsSniff.php +0 -275
  113. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/ConcatPositionSniff.php +0 -204
  114. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/DisallowLogicalAndOrSniff.php +0 -112
  115. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/DisallowShortTernarySniff.php +0 -76
  116. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/DisallowStandalonePostIncrementDecrementSniff.php +0 -197
  117. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/StrictComparisonsSniff.php +0 -116
  118. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/Operators/TypeSeparatorSpacingSniff.php +0 -85
  119. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/PHP/LowercasePHPTagSniff.php +0 -87
  120. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/PHP/OneStatementInShortEchoTagSniff.php +0 -101
  121. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowMixedGroupUseSniff.php +0 -248
  122. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowUseClassSniff.php +0 -211
  123. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowUseConstSniff.php +0 -211
  124. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/DisallowUseFunctionSniff.php +0 -211
  125. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/KeywordSpacingSniff.php +0 -207
  126. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/LowercaseFunctionConstSniff.php +0 -156
  127. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/NoLeadingBackslashSniff.php +0 -170
  128. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/UseStatements/NoUselessAliasesSniff.php +0 -155
  129. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/AnonClassKeywordSpacingSniff.php +0 -79
  130. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/CommaSpacingSniff.php +0 -408
  131. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/DisallowInlineTabsSniff.php +0 -173
  132. package/vendor/phpcsstandards/phpcsextra/Universal/Sniffs/WhiteSpace/PrecisionAlignmentSniff.php +0 -445
  133. package/vendor/phpcsstandards/phpcsextra/Universal/ruleset.xml +0 -5
  134. package/vendor/phpcsstandards/phpcsextra/composer.json +0 -69
  135. package/vendor/phpcsstandards/phpcsutils/.phpdoc.xml.dist +0 -36
  136. package/vendor/phpcsstandards/phpcsutils/CHANGELOG.md +0 -1106
  137. package/vendor/phpcsstandards/phpcsutils/LICENSE +0 -165
  138. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/AbstractSniffs/AbstractArrayDeclarationSniff.php +0 -551
  139. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCFile.php +0 -781
  140. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/BCTokens.php +0 -123
  141. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/BackCompat/Helper.php +0 -202
  142. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Exceptions/InvalidTokenArray.php +0 -44
  143. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Exceptions/TestFileNotFound.php +0 -47
  144. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Exceptions/TestMarkerNotFound.php +0 -43
  145. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Exceptions/TestTargetNotFound.php +0 -50
  146. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Fixers/SpacesFixer.php +0 -246
  147. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/Cache.php +0 -218
  148. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrList.php +0 -687
  149. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/IsShortArrayOrListWithCache.php +0 -269
  150. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/NoFileCache.php +0 -164
  151. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Internal/StableCollections.php +0 -75
  152. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/TestUtils/UtilityMethodTestCase.php +0 -459
  153. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/Collections.php +0 -837
  154. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Tokens/TokenHelper.php +0 -55
  155. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Arrays.php +0 -227
  156. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Conditions.php +0 -156
  157. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Context.php +0 -232
  158. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ControlStructures.php +0 -276
  159. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/FunctionDeclarations.php +0 -828
  160. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/GetTokensAsString.php +0 -262
  161. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Lists.php +0 -359
  162. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/MessageHelper.php +0 -145
  163. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Namespaces.php +0 -389
  164. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/NamingConventions.php +0 -116
  165. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Numbers.php +0 -322
  166. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/ObjectDeclarations.php +0 -359
  167. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Operators.php +0 -252
  168. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Orthography.php +0 -120
  169. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Parentheses.php +0 -419
  170. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/PassedParameters.php +0 -510
  171. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Scopes.php +0 -143
  172. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/TextStrings.php +0 -331
  173. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/UseStatements.php +0 -432
  174. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/Utils/Variables.php +0 -333
  175. package/vendor/phpcsstandards/phpcsutils/PHPCSUtils/ruleset.xml +0 -4
  176. package/vendor/phpcsstandards/phpcsutils/README.md +0 -297
  177. package/vendor/phpcsstandards/phpcsutils/composer.json +0 -92
  178. package/vendor/phpcsstandards/phpcsutils/phpcsutils-autoload.php +0 -68
  179. package/vendor/wp-coding-standards/wpcs/CHANGELOG.md +0 -1654
  180. package/vendor/wp-coding-standards/wpcs/LICENSE +0 -21
  181. package/vendor/wp-coding-standards/wpcs/README.md +0 -261
  182. package/vendor/wp-coding-standards/wpcs/WordPress/AbstractArrayAssignmentRestrictionsSniff.php +0 -261
  183. package/vendor/wp-coding-standards/wpcs/WordPress/AbstractClassRestrictionsSniff.php +0 -257
  184. package/vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionParameterSniff.php +0 -111
  185. package/vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionRestrictionsSniff.php +0 -358
  186. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/Arrays/ArrayIndentationStandard.xml +0 -116
  187. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/Arrays/ArrayKeySpacingRestrictionsStandard.xml +0 -31
  188. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/Arrays/MultipleStatementAlignmentStandard.xml +0 -50
  189. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/CodeAnalysis/EscapedNotTranslatedStandard.xml +0 -24
  190. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/DateTime/CurrentTimeTimestampStandard.xml +0 -35
  191. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/DateTime/RestrictedFunctionsStandard.xml +0 -54
  192. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/NamingConventions/PrefixAllGlobalsStandard.xml +0 -119
  193. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/NamingConventions/ValidHookNameStandard.xml +0 -35
  194. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/NamingConventions/ValidPostTypeSlugStandard.xml +0 -121
  195. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/PHP/IniSetStandard.xml +0 -40
  196. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/PHP/StrictInArrayStandard.xml +0 -53
  197. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/PHP/YodaConditionsStandard.xml +0 -27
  198. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/Security/SafeRedirectStandard.xml +0 -23
  199. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/CapabilitiesStandard.xml +0 -69
  200. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/CapitalPDangitStandard.xml +0 -43
  201. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/ClassNameCaseStandard.xml +0 -23
  202. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/CronIntervalStandard.xml +0 -45
  203. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/DeprecatedClassesStandard.xml +0 -23
  204. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/DeprecatedFunctionsStandard.xml +0 -23
  205. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/DeprecatedParameterValuesStandard.xml +0 -23
  206. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/DeprecatedParametersStandard.xml +0 -40
  207. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/EnqueuedResourceParametersStandard.xml +0 -92
  208. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/EnqueuedResourcesStandard.xml +0 -57
  209. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WP/PostsPerPageStandard.xml +0 -73
  210. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WhiteSpace/CastStructureSpacingStandard.xml +0 -27
  211. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WhiteSpace/ControlStructureSpacingStandard.xml +0 -150
  212. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WhiteSpace/ObjectOperatorSpacingStandard.xml +0 -19
  213. package/vendor/wp-coding-standards/wpcs/WordPress/Docs/WhiteSpace/OperatorSpacingStandard.xml +0 -61
  214. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ArrayWalkingFunctionsHelper.php +0 -108
  215. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ConstantsHelper.php +0 -135
  216. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ContextHelper.php +0 -394
  217. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/DeprecationHelper.php +0 -84
  218. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/EscapingFunctionsTrait.php +0 -256
  219. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/FormattingFunctionsHelper.php +0 -60
  220. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/IsUnitTestTrait.php +0 -238
  221. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ListHelper.php +0 -101
  222. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/MinimumWPVersionTrait.php +0 -159
  223. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/PrintingFunctionsTrait.php +0 -122
  224. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/RulesetPropertyHelper.php +0 -73
  225. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/SanitizationHelperTrait.php +0 -418
  226. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/SnakeCaseHelper.php +0 -60
  227. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/UnslashingFunctionsHelper.php +0 -59
  228. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/ValidationHelper.php +0 -349
  229. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/VariableHelper.php +0 -262
  230. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/WPDBTrait.php +0 -115
  231. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/WPGlobalVariablesHelper.php +0 -312
  232. package/vendor/wp-coding-standards/wpcs/WordPress/Helpers/WPHookHelper.php +0 -113
  233. package/vendor/wp-coding-standards/wpcs/WordPress/Sniff.php +0 -72
  234. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php +0 -252
  235. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php +0 -550
  236. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php +0 -174
  237. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php +0 -583
  238. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CodeAnalysis/AssignmentInTernaryConditionSniff.php +0 -173
  239. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CodeAnalysis/EscapedNotTranslatedSniff.php +0 -89
  240. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/DirectDatabaseQuerySniff.php +0 -301
  241. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php +0 -761
  242. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/PreparedSQLSniff.php +0 -242
  243. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedClassesSniff.php +0 -57
  244. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedFunctionsSniff.php +0 -63
  245. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/SlowDBQuerySniff.php +0 -58
  246. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DateTime/CurrentTimeTimestampSniff.php +0 -168
  247. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DateTime/RestrictedFunctionsSniff.php +0 -59
  248. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Files/FileNameSniff.php +0 -313
  249. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/PrefixAllGlobalsSniff.php +0 -1297
  250. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidFunctionNameSniff.php +0 -188
  251. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidHookNameSniff.php +0 -277
  252. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidPostTypeSlugSniff.php +0 -230
  253. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php +0 -289
  254. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DevelopmentFunctionsSniff.php +0 -63
  255. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DiscouragedPHPFunctionsSniff.php +0 -100
  256. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/DontExtractSniff.php +0 -52
  257. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/IniSetSniff.php +0 -193
  258. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/NoSilencedErrorsSniff.php +0 -245
  259. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/POSIXFunctionsSniff.php +0 -73
  260. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/PregQuoteDelimiterSniff.php +0 -70
  261. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/RestrictedPHPFunctionsSniff.php +0 -45
  262. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/StrictInArraySniff.php +0 -122
  263. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/TypeCastsSniff.php +0 -90
  264. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/PHP/YodaConditionsSniff.php +0 -124
  265. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/EscapeOutputSniff.php +0 -903
  266. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/NonceVerificationSniff.php +0 -422
  267. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/PluginMenuSlugSniff.php +0 -126
  268. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/SafeRedirectSniff.php +0 -45
  269. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Security/ValidatedSanitizedInputSniff.php +0 -244
  270. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Utils/I18nTextDomainFixerSniff.php +0 -862
  271. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/AlternativeFunctionsSniff.php +0 -371
  272. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/CapabilitiesSniff.php +0 -478
  273. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/CapitalPDangitSniff.php +0 -315
  274. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/ClassNameCaseSniff.php +0 -897
  275. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/CronIntervalSniff.php +0 -321
  276. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedClassesSniff.php +0 -152
  277. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedFunctionsSniff.php +0 -1708
  278. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedParameterValuesSniff.php +0 -291
  279. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DeprecatedParametersSniff.php +0 -509
  280. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DiscouragedConstantsSniff.php +0 -160
  281. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/DiscouragedFunctionsSniff.php +0 -54
  282. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/EnqueuedResourceParametersSniff.php +0 -241
  283. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/EnqueuedResourcesSniff.php +0 -108
  284. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/GlobalVariablesOverrideSniff.php +0 -436
  285. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/I18nSniff.php +0 -977
  286. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WP/PostsPerPageSniff.php +0 -102
  287. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/CastStructureSpacingSniff.php +0 -59
  288. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +0 -486
  289. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php +0 -63
  290. package/vendor/wp-coding-standards/wpcs/WordPress/Sniffs/WhiteSpace/OperatorSpacingSniff.php +0 -60
  291. package/vendor/wp-coding-standards/wpcs/WordPress/ruleset.xml +0 -13
  292. package/vendor/wp-coding-standards/wpcs/WordPress-Core/ruleset.xml +0 -948
  293. package/vendor/wp-coding-standards/wpcs/WordPress-Docs/ruleset.xml +0 -109
  294. package/vendor/wp-coding-standards/wpcs/WordPress-Extra/ruleset.xml +0 -199
  295. package/vendor/wp-coding-standards/wpcs/composer.json +0 -88
  296. package/vendor/wp-coding-standards/wpcs/phpcs.xml.dist.sample +0 -153
@@ -1,1297 +0,0 @@
1
- <?php
2
- /**
3
- * WordPress Coding Standard.
4
- *
5
- * @package WPCS\WordPressCodingStandards
6
- * @link https://github.com/WordPress/WordPress-Coding-Standards
7
- * @license https://opensource.org/licenses/MIT MIT
8
- */
9
-
10
- namespace WordPressCS\WordPress\Sniffs\NamingConventions;
11
-
12
- use PHP_CodeSniffer\Util\Tokens;
13
- use PHPCSUtils\BackCompat\Helper;
14
- use PHPCSUtils\Tokens\Collections;
15
- use PHPCSUtils\Utils\Conditions;
16
- use PHPCSUtils\Utils\Context;
17
- use PHPCSUtils\Utils\FunctionDeclarations;
18
- use PHPCSUtils\Utils\Lists;
19
- use PHPCSUtils\Utils\MessageHelper;
20
- use PHPCSUtils\Utils\Namespaces;
21
- use PHPCSUtils\Utils\ObjectDeclarations;
22
- use PHPCSUtils\Utils\Parentheses;
23
- use PHPCSUtils\Utils\PassedParameters;
24
- use PHPCSUtils\Utils\Scopes;
25
- use PHPCSUtils\Utils\TextStrings;
26
- use PHPCSUtils\Utils\Variables;
27
- use WordPressCS\WordPress\AbstractFunctionParameterSniff;
28
- use WordPressCS\WordPress\Helpers\DeprecationHelper;
29
- use WordPressCS\WordPress\Helpers\IsUnitTestTrait;
30
- use WordPressCS\WordPress\Helpers\ListHelper;
31
- use WordPressCS\WordPress\Helpers\RulesetPropertyHelper;
32
- use WordPressCS\WordPress\Helpers\VariableHelper;
33
- use WordPressCS\WordPress\Helpers\WPGlobalVariablesHelper;
34
- use WordPressCS\WordPress\Helpers\WPHookHelper;
35
-
36
- /**
37
- * Verify that everything defined in the global namespace is prefixed with a theme/plugin specific prefix.
38
- *
39
- * @since 0.12.0
40
- * @since 0.13.0 Class name changed: this class is now namespaced.
41
- * @since 1.2.0 Now also checks whether namespaces are prefixed.
42
- * @since 2.2.0 - Now also checks variables assigned via the list() construct.
43
- * - Now also ignores global functions which are marked as @deprecated.
44
- *
45
- * @uses \WordPressCS\WordPress\Helpers\IsUnitTestTrait::$custom_test_classes
46
- */
47
- final class PrefixAllGlobalsSniff extends AbstractFunctionParameterSniff {
48
-
49
- use IsUnitTestTrait;
50
-
51
- /**
52
- * Error message template.
53
- *
54
- * @var string
55
- */
56
- const ERROR_MSG = '%s by a theme/plugin should start with the theme/plugin prefix. Found: "%s".';
57
-
58
- /**
59
- * Minimal number of characters the prefix needs in order to be valid.
60
- *
61
- * @since 2.2.0
62
- *
63
- * @link https://github.com/WordPress/WordPress-Coding-Standards/issues/1733 Issue 1733.
64
- *
65
- * @var int
66
- */
67
- const MIN_PREFIX_LENGTH = 3;
68
-
69
- /**
70
- * Target prefixes.
71
- *
72
- * @since 0.12.0
73
- *
74
- * @var string[]
75
- */
76
- public $prefixes = array();
77
-
78
- /**
79
- * Prefix blocklist.
80
- *
81
- * @since 0.12.0
82
- * @since 3.0.0 Renamed from `$prefix_blacklist` to `$prefix_blocklist`.
83
- *
84
- * @var array<string, true> Key is prefix, value irrelevant.
85
- */
86
- protected $prefix_blocklist = array(
87
- 'wordpress' => true,
88
- 'wp' => true,
89
- '_' => true,
90
- 'php' => true, // See #1728, the 'php' prefix is reserved by PHP itself.
91
- );
92
-
93
- /**
94
- * Target prefixes after validation.
95
- *
96
- * All prefixes are lowercased for case-insensitive compare.
97
- *
98
- * @since 0.12.0
99
- *
100
- * @var array<string, string>
101
- */
102
- private $validated_prefixes = array();
103
-
104
- /**
105
- * Target namespace prefixes after validation with regex indicator.
106
- *
107
- * All prefixes are lowercased for case-insensitive compare.
108
- * If the prefix doesn't already contain a namespace separator, but does contain
109
- * non-word characters, these will have been replaced with regex syntax to allow
110
- * for namespace separators and the `is_regex` indicator will have been set to `true`.
111
- *
112
- * @since 1.2.0
113
- *
114
- * @var array<string, array<string, mixed>>
115
- */
116
- private $validated_namespace_prefixes = array();
117
-
118
- /**
119
- * Cache of previously set prefixes.
120
- *
121
- * Prevents having to do the same prefix validation over and over again.
122
- *
123
- * @since 0.12.0
124
- *
125
- * @var string[]
126
- */
127
- private $previous_prefixes = array();
128
-
129
- /**
130
- * A list of core hooks that are allowed to be called by plugins and themes.
131
- *
132
- * @since 0.14.0
133
- * @since 3.0.0 Renamed from `$whitelisted_core_hooks` to `$allowed_core_hooks`.
134
- *
135
- * @var array<string, true> Key is hook name, value irrelevant.
136
- */
137
- protected $allowed_core_hooks = array(
138
- 'widget_title' => true,
139
- 'add_meta_boxes' => true,
140
- );
141
-
142
- /**
143
- * A list of core constants that are allowed to be defined by plugins and themes.
144
- *
145
- * Source: {@link https://core.trac.wordpress.org/browser/trunk/src/wp-includes/default-constants.php#L0}
146
- * The constants are listed in alphabetic order.
147
- * Only overrulable constants are listed, i.e. those defined within core within
148
- * a `if ( ! defined() ) {}` wrapper.
149
- *
150
- * {@internal To be updated after every major release. Last updated for WordPress 6.5-RC3.}
151
- *
152
- * @since 1.0.0
153
- * @since 3.0.0 Renamed from `$whitelisted_core_constants` to `$allowed_core_constants`.
154
- *
155
- * @var array<string, true> Key is constant name, value irrelevant.
156
- */
157
- protected $allowed_core_constants = array(
158
- 'ADMIN_COOKIE_PATH' => true,
159
- 'AUTH_COOKIE' => true,
160
- 'AUTOSAVE_INTERVAL' => true,
161
- 'COOKIEHASH' => true,
162
- 'COOKIEPATH' => true,
163
- 'COOKIE_DOMAIN' => true,
164
- 'EMPTY_TRASH_DAYS' => true,
165
- 'FORCE_SSL_ADMIN' => true,
166
- 'FORCE_SSL_LOGIN' => true, // Deprecated.
167
- 'LOGGED_IN_COOKIE' => true,
168
- 'MEDIA_TRASH' => true,
169
- 'MUPLUGINDIR' => true, // Deprecated.
170
- 'PASS_COOKIE' => true,
171
- 'PLUGINDIR' => true, // Deprecated.
172
- 'PLUGINS_COOKIE_PATH' => true,
173
- 'RECOVERY_MODE_COOKIE' => true,
174
- 'SCRIPT_DEBUG' => true,
175
- 'SECURE_AUTH_COOKIE' => true,
176
- 'SHORTINIT' => true,
177
- 'SITECOOKIEPATH' => true,
178
- 'TEST_COOKIE' => true,
179
- 'USER_COOKIE' => true,
180
- 'WPMU_PLUGIN_DIR' => true,
181
- 'WPMU_PLUGIN_URL' => true,
182
- 'WP_CACHE' => true,
183
- 'WP_CONTENT_DIR' => true,
184
- 'WP_CONTENT_URL' => true,
185
- 'WP_CRON_LOCK_TIMEOUT' => true,
186
- 'WP_DEBUG' => true,
187
- 'WP_DEBUG_DISPLAY' => true,
188
- 'WP_DEBUG_LOG' => true,
189
- 'WP_DEFAULT_THEME' => true,
190
- 'WP_DEVELOPMENT_MODE' => true,
191
- 'WP_MAX_MEMORY_LIMIT' => true,
192
- 'WP_MEMORY_LIMIT' => true,
193
- 'WP_PLUGIN_DIR' => true,
194
- 'WP_PLUGIN_URL' => true,
195
- 'WP_POST_REVISIONS' => true,
196
- 'WP_START_TIMESTAMP' => true,
197
- );
198
-
199
- /**
200
- * A list of functions declared in WP core as "Pluggable", i.e. overloadable from a plugin.
201
- *
202
- * Note: deprecated functions should still be included in this list as plugins may support older WP versions.
203
- *
204
- * {@internal To be updated after every major release. Last updated for WordPress 6.5-RC3.}
205
- *
206
- * @since 3.0.0.
207
- *
208
- * @var array<string, true> Key is function name, value irrelevant.
209
- */
210
- protected $pluggable_functions = array(
211
- 'auth_redirect' => true,
212
- 'cache_users' => true,
213
- 'check_admin_referer' => true,
214
- 'check_ajax_referer' => true,
215
- 'get_avatar' => true,
216
- 'get_currentuserinfo' => true, // Deprecated.
217
- 'get_user_by' => true,
218
- 'get_user_by_email' => true, // Deprecated.
219
- 'get_userdata' => true,
220
- 'get_userdatabylogin' => true, // Deprecated.
221
- 'graceful_fail' => true,
222
- 'install_global_terms' => true,
223
- 'install_network' => true,
224
- 'is_user_logged_in' => true,
225
- // 'lowercase_octets' => true, => unclear if this function is meant to be publicly pluggable.
226
- 'maybe_add_column' => true,
227
- 'maybe_create_table' => true,
228
- 'set_current_user' => true, // Deprecated.
229
- 'twenty_twenty_one_entry_meta_footer' => true,
230
- 'twenty_twenty_one_post_thumbnail' => true,
231
- 'twenty_twenty_one_post_title' => true,
232
- 'twenty_twenty_one_posted_by' => true,
233
- 'twenty_twenty_one_posted_on' => true,
234
- 'twenty_twenty_one_setup' => true,
235
- 'twenty_twenty_one_the_posts_navigation' => true,
236
- 'twentyeleven_admin_header_image' => true,
237
- 'twentyeleven_admin_header_style' => true,
238
- 'twentyeleven_comment' => true,
239
- 'twentyeleven_content_nav' => true,
240
- 'twentyeleven_continue_reading_link' => true,
241
- 'twentyeleven_header_image' => true,
242
- 'twentyeleven_header_style' => true,
243
- 'twentyeleven_posted_on' => true,
244
- 'twentyeleven_setup' => true,
245
- 'twentyfifteen_comment_nav' => true,
246
- 'twentyfifteen_entry_meta' => true,
247
- 'twentyfifteen_excerpt_more' => true,
248
- 'twentyfifteen_fonts_url' => true,
249
- 'twentyfifteen_get_color_scheme' => true,
250
- 'twentyfifteen_get_color_scheme_choices' => true,
251
- 'twentyfifteen_get_link_url' => true,
252
- 'twentyfifteen_header_style' => true,
253
- 'twentyfifteen_post_thumbnail' => true,
254
- 'twentyfifteen_sanitize_color_scheme' => true,
255
- 'twentyfifteen_setup' => true,
256
- 'twentyfifteen_the_custom_logo' => true,
257
- 'twentyfourteen_admin_header_image' => true,
258
- 'twentyfourteen_admin_header_style' => true,
259
- 'twentyfourteen_excerpt_more' => true,
260
- 'twentyfourteen_font_url' => true,
261
- 'twentyfourteen_header_image' => true,
262
- 'twentyfourteen_header_style' => true,
263
- 'twentyfourteen_list_authors' => true,
264
- 'twentyfourteen_paging_nav' => true,
265
- 'twentyfourteen_post_nav' => true,
266
- 'twentyfourteen_post_thumbnail' => true,
267
- 'twentyfourteen_posted_on' => true,
268
- 'twentyfourteen_setup' => true,
269
- 'twentyfourteen_the_attached_image' => true,
270
- 'twentynineteen_comment_count' => true,
271
- 'twentynineteen_comment_form' => true,
272
- 'twentynineteen_discussion_avatars_list' => true,
273
- 'twentynineteen_entry_footer' => true,
274
- 'twentynineteen_get_user_avatar_markup' => true,
275
- 'twentynineteen_post_thumbnail' => true,
276
- 'twentynineteen_posted_by' => true,
277
- 'twentynineteen_posted_on' => true,
278
- 'twentynineteen_setup' => true,
279
- 'twentynineteen_the_posts_navigation' => true,
280
- 'twentyseventeen_edit_link' => true,
281
- 'twentyseventeen_entry_footer' => true,
282
- 'twentyseventeen_fonts_url' => true,
283
- 'twentyseventeen_header_style' => true,
284
- 'twentyseventeen_posted_on' => true,
285
- 'twentyseventeen_time_link' => true,
286
- 'twentysixteen_categorized_blog' => true,
287
- 'twentysixteen_entry_date' => true,
288
- 'twentysixteen_entry_meta' => true,
289
- 'twentysixteen_entry_taxonomies' => true,
290
- 'twentysixteen_excerpt' => true,
291
- 'twentysixteen_excerpt_more' => true,
292
- 'twentysixteen_fonts_url' => true,
293
- 'twentysixteen_get_color_scheme' => true,
294
- 'twentysixteen_get_color_scheme_choices' => true,
295
- 'twentysixteen_header_style' => true,
296
- 'twentysixteen_post_thumbnail' => true,
297
- 'twentysixteen_sanitize_color_scheme' => true,
298
- 'twentysixteen_setup' => true,
299
- 'twentysixteen_the_custom_logo' => true,
300
- 'twentyten_admin_header_style' => true,
301
- 'twentyten_comment' => true,
302
- 'twentyten_continue_reading_link' => true,
303
- 'twentyten_header_image' => true,
304
- 'twentyten_posted_in' => true,
305
- 'twentyten_posted_on' => true,
306
- 'twentyten_setup' => true,
307
- 'twentythirteen_entry_date' => true,
308
- 'twentythirteen_entry_meta' => true,
309
- 'twentythirteen_excerpt_more' => true,
310
- 'twentythirteen_fonts_url' => true,
311
- 'twentythirteen_paging_nav' => true,
312
- 'twentythirteen_post_nav' => true,
313
- 'twentythirteen_the_attached_image' => true,
314
- 'twentytwelve_comment' => true,
315
- 'twentytwelve_content_nav' => true,
316
- 'twentytwelve_entry_meta' => true,
317
- 'twentytwelve_get_font_url' => true,
318
- 'twentytwenty_customize_partial_blogdescription' => true,
319
- 'twentytwenty_customize_partial_blogname' => true,
320
- 'twentytwenty_customize_partial_site_logo' => true,
321
- 'twentytwenty_generate_css' => true,
322
- 'twentytwenty_get_customizer_css' => true,
323
- 'twentytwenty_get_theme_svg' => true,
324
- 'twentytwenty_the_theme_svg' => true,
325
- 'twentytwentyfour_block_styles' => true,
326
- 'twentytwentyfour_block_stylesheets' => true,
327
- 'twentytwentyfour_pattern_categories' => true,
328
- 'twentytwentytwo_styles' => true,
329
- 'twentytwentytwo_support' => true,
330
- 'wp_authenticate' => true,
331
- 'wp_cache_add_multiple' => true,
332
- 'wp_cache_delete_multiple' => true,
333
- 'wp_cache_flush_group' => true,
334
- 'wp_cache_flush_runtime' => true,
335
- 'wp_cache_get_multiple' => true,
336
- 'wp_cache_set_multiple' => true,
337
- 'wp_cache_supports' => true,
338
- 'wp_check_password' => true,
339
- 'wp_clear_auth_cookie' => true,
340
- 'wp_clearcookie' => true, // Deprecated.
341
- 'wp_create_nonce' => true,
342
- 'wp_generate_auth_cookie' => true,
343
- 'wp_generate_password' => true,
344
- 'wp_get_cookie_login' => true, // Deprecated.
345
- 'wp_get_current_user' => true,
346
- // 'wp_handle_upload_error' => true, => unclear if this function is meant to be publicly pluggable.
347
- 'wp_hash' => true,
348
- 'wp_hash_password' => true,
349
- 'wp_install' => true,
350
- 'wp_install_defaults' => true,
351
- 'wp_login' => true, // Deprecated.
352
- 'wp_logout' => true,
353
- 'wp_mail' => true,
354
- 'wp_new_blog_notification' => true,
355
- 'wp_new_user_notification' => true,
356
- 'wp_nonce_tick' => true,
357
- 'wp_notify_moderator' => true,
358
- 'wp_notify_postauthor' => true,
359
- 'wp_parse_auth_cookie' => true,
360
- 'wp_password_change_notification' => true,
361
- 'wp_rand' => true,
362
- 'wp_redirect' => true,
363
- 'wp_safe_redirect' => true,
364
- 'wp_salt' => true,
365
- 'wp_sanitize_redirect' => true,
366
- 'wp_set_auth_cookie' => true,
367
- 'wp_set_current_user' => true,
368
- 'wp_set_password' => true,
369
- 'wp_setcookie' => true, // Deprecated.
370
- 'wp_text_diff' => true,
371
- 'wp_upgrade' => true,
372
- 'wp_validate_auth_cookie' => true,
373
- 'wp_validate_redirect' => true,
374
- 'wp_verify_nonce' => true,
375
- );
376
-
377
- /**
378
- * A list of classes declared in WP core as "Pluggable", i.e. overloadable from a plugin.
379
- *
380
- * Source: {@link https://core.trac.wordpress.org/browser/trunk/src/wp-includes/pluggable.php}
381
- * and {@link https://core.trac.wordpress.org/browser/trunk/src/wp-includes/pluggable-deprecated.php}
382
- *
383
- * Note: deprecated classes should still be included in this list as plugins may support older WP versions.
384
- *
385
- * {@internal To be updated after every major release. Last updated for WordPress 6.5-RC3.}
386
- *
387
- * @since 3.0.0.
388
- *
389
- * @var array<string, true> Key is class name, value irrelevant.
390
- */
391
- protected $pluggable_classes = array(
392
- 'TwentyTwenty_Customize' => true,
393
- 'TwentyTwenty_Non_Latin_Languages' => true,
394
- 'TwentyTwenty_SVG_Icons' => true,
395
- 'TwentyTwenty_Script_Loader' => true,
396
- 'TwentyTwenty_Separator_Control' => true,
397
- 'TwentyTwenty_Walker_Comment' => true,
398
- 'TwentyTwenty_Walker_Page' => true,
399
- 'Twenty_Twenty_One_Customize' => true,
400
- 'WP_User_Search' => true,
401
- 'wp_atom_server' => true, // Deprecated.
402
- );
403
-
404
- /**
405
- * List of all PHP native functions.
406
- *
407
- * Using this list rather than a call to `function_exists()` prevents
408
- * false negatives from user-defined functions when those would be
409
- * autoloaded via a Composer autoload files directives.
410
- *
411
- * @var array<string, int>
412
- */
413
- private $built_in_functions;
414
-
415
-
416
- /**
417
- * Returns an array of tokens this test wants to listen for.
418
- *
419
- * @since 0.12.0
420
- *
421
- * @return array
422
- */
423
- public function register() {
424
- // Get a list of all PHP native functions.
425
- $all_functions = get_defined_functions();
426
- $this->built_in_functions = array_flip( $all_functions['internal'] );
427
- $this->built_in_functions = array_change_key_case( $this->built_in_functions, \CASE_LOWER );
428
-
429
- // Make sure the pluggable functions and classes list can be easily compared.
430
- $this->pluggable_functions = array_change_key_case( $this->pluggable_functions, \CASE_LOWER );
431
- $this->pluggable_classes = array_change_key_case( $this->pluggable_classes, \CASE_LOWER );
432
-
433
- // Set the sniff targets.
434
- $targets = array(
435
- \T_NAMESPACE => \T_NAMESPACE,
436
- \T_FUNCTION => \T_FUNCTION,
437
- \T_CONST => \T_CONST,
438
- \T_VARIABLE => \T_VARIABLE,
439
- \T_DOLLAR => \T_DOLLAR, // Variable variables.
440
- \T_FN_ARROW => \T_FN_ARROW, // T_FN_ARROW is only used for skipping over (for now).
441
- );
442
- $targets += Tokens::$ooScopeTokens; // T_ANON_CLASS is only used for skipping over test classes.
443
- $targets += Collections::listOpenTokensBC();
444
-
445
- // Add function call target for hook names and constants defined using define().
446
- $parent = parent::register();
447
- if ( ! empty( $parent ) ) {
448
- $targets[] = \T_STRING;
449
- }
450
-
451
- return $targets;
452
- }
453
-
454
- /**
455
- * Groups of functions to restrict.
456
- *
457
- * @since 0.12.0
458
- *
459
- * @return array
460
- */
461
- public function getGroups() {
462
- // Only retrieve functions which are not used for deprecated hooks.
463
- $this->target_functions = WPHookHelper::get_functions( false );
464
- $this->target_functions['define'] = true;
465
-
466
- return parent::getGroups();
467
- }
468
-
469
- /**
470
- * Processes this test, when one of its tokens is encountered.
471
- *
472
- * @since 0.12.0
473
- *
474
- * @param int $stackPtr The position of the current token in the stack.
475
- *
476
- * @return int|void Integer stack pointer to skip forward or void to continue
477
- * normal file processing.
478
- */
479
- public function process_token( $stackPtr ) {
480
-
481
- // Allow overruling the prefixes set in a ruleset via the command line.
482
- $cl_prefixes = Helper::getConfigData( 'prefixes' );
483
- if ( ! empty( $cl_prefixes ) ) {
484
- $cl_prefixes = trim( $cl_prefixes );
485
- if ( '' !== $cl_prefixes ) {
486
- $this->prefixes = array_filter( array_map( 'trim', explode( ',', $cl_prefixes ) ) );
487
- }
488
- }
489
-
490
- $this->prefixes = RulesetPropertyHelper::merge_custom_array( $this->prefixes, array(), false );
491
- if ( empty( $this->prefixes ) ) {
492
- // No prefixes passed, nothing to do.
493
- return;
494
- }
495
-
496
- $this->validate_prefixes();
497
- if ( empty( $this->validated_prefixes ) ) {
498
- // No _valid_ prefixes passed, nothing to do.
499
- return;
500
- }
501
-
502
- // Ignore test classes.
503
- if ( isset( Tokens::$ooScopeTokens[ $this->tokens[ $stackPtr ]['code'] ] )
504
- && true === $this->is_test_class( $this->phpcsFile, $stackPtr )
505
- ) {
506
- if ( $this->tokens[ $stackPtr ]['scope_condition'] === $stackPtr && isset( $this->tokens[ $stackPtr ]['scope_closer'] ) ) {
507
- // Skip forward to end of test class.
508
- return $this->tokens[ $stackPtr ]['scope_closer'];
509
- }
510
- return;
511
- }
512
-
513
- if ( \T_ANON_CLASS === $this->tokens[ $stackPtr ]['code'] ) {
514
- // Token was only registered to allow skipping over test classes.
515
- return;
516
- }
517
-
518
- /*
519
- * Ignore the contents of arrow functions which do not declare closures.
520
- *
521
- * - Parameters declared by arrow functions do not need to be prefixed (handled elsewhere).
522
- * - New variables declared within an arrow function are local to the arrow function, so can be ignored.
523
- * - A `global` statement is not allowed within an arrow function.
524
- *
525
- * Note: this does mean some convoluted code may get ignored (false negatives), but this is currently
526
- * not reliably solvable as PHPCS does not add arrow functions to the 'conditions' array.
527
- */
528
- if ( \T_FN_ARROW === $this->tokens[ $stackPtr ]['code']
529
- && isset( $this->tokens[ $stackPtr ]['scope_closer'] )
530
- ) {
531
- $has_closure = $this->phpcsFile->findNext( \T_CLOSURE, ( $stackPtr + 1 ), $this->tokens[ $stackPtr ]['scope_closer'] );
532
- if ( false !== $has_closure ) {
533
- // Skip to the start of the closure.
534
- return $has_closure;
535
- }
536
-
537
- // Skip the arrow function completely.
538
- return $this->tokens[ $stackPtr ]['scope_closer'];
539
- }
540
-
541
- if ( \T_STRING === $this->tokens[ $stackPtr ]['code'] ) {
542
- // Disallow excluding function groups for this sniff.
543
- $this->exclude = array();
544
-
545
- return parent::process_token( $stackPtr );
546
-
547
- } elseif ( \T_DOLLAR === $this->tokens[ $stackPtr ]['code'] ) {
548
-
549
- return $this->process_variable_variable( $stackPtr );
550
-
551
- } elseif ( \T_VARIABLE === $this->tokens[ $stackPtr ]['code'] ) {
552
-
553
- return $this->process_variable_assignment( $stackPtr );
554
-
555
- } elseif ( isset( Collections::listOpenTokensBC()[ $this->tokens[ $stackPtr ]['code'] ] ) ) {
556
- return $this->process_list_assignment( $stackPtr );
557
-
558
- } elseif ( \T_NAMESPACE === $this->tokens[ $stackPtr ]['code'] ) {
559
- $namespace_name = Namespaces::getDeclaredName( $this->phpcsFile, $stackPtr );
560
-
561
- if ( false === $namespace_name || '' === $namespace_name || '\\' === $namespace_name ) {
562
- return;
563
- }
564
-
565
- foreach ( $this->validated_namespace_prefixes as $key => $prefix_info ) {
566
- if ( false === $prefix_info['is_regex'] ) {
567
- if ( stripos( $namespace_name, $prefix_info['prefix'] ) === 0 ) {
568
- $this->phpcsFile->recordMetric( $stackPtr, 'Prefix all globals: allowed prefixes', $key );
569
- return;
570
- }
571
- } else {
572
- // Ok, so this prefix should be used as a regex.
573
- $regex = '`^' . $prefix_info['prefix'] . '`i';
574
- if ( preg_match( $regex, $namespace_name ) > 0 ) {
575
- $this->phpcsFile->recordMetric( $stackPtr, 'Prefix all globals: allowed prefixes', $key );
576
- return;
577
- }
578
- }
579
- }
580
-
581
- // Still here ? In that case, we have a non-prefixed namespace name.
582
- $recorded = $this->phpcsFile->addError(
583
- self::ERROR_MSG,
584
- $stackPtr,
585
- 'NonPrefixedNamespaceFound',
586
- array(
587
- 'Namespaces declared',
588
- $namespace_name,
589
- )
590
- );
591
-
592
- if ( true === $recorded ) {
593
- $this->record_potential_prefix_metric( $stackPtr, $namespace_name );
594
- }
595
-
596
- return;
597
-
598
- } else {
599
-
600
- // Namespaced methods, classes and constants do not need to be prefixed.
601
- $namespace = Namespaces::determineNamespace( $this->phpcsFile, $stackPtr );
602
- if ( '' !== $namespace && '\\' !== $namespace ) {
603
- return;
604
- }
605
-
606
- $item_name = '';
607
- $error_text = 'Unknown syntax used';
608
- $error_code = 'NonPrefixedSyntaxFound';
609
-
610
- switch ( $this->tokens[ $stackPtr ]['code'] ) {
611
- case \T_FUNCTION:
612
- // Methods in a class do not need to be prefixed.
613
- if ( Scopes::isOOMethod( $this->phpcsFile, $stackPtr ) === true ) {
614
- return;
615
- }
616
-
617
- if ( DeprecationHelper::is_function_deprecated( $this->phpcsFile, $stackPtr ) === true ) {
618
- /*
619
- * Deprecated functions don't have to comply with the naming conventions,
620
- * otherwise functions deprecated in favour of a function with a compliant
621
- * name would still trigger an error.
622
- */
623
- return;
624
- }
625
-
626
- $item_name = FunctionDeclarations::getName( $this->phpcsFile, $stackPtr );
627
- $item_lc = strtolower( $item_name );
628
- if ( isset( $this->built_in_functions[ $item_lc ] ) ) {
629
- // Backfill for PHP native function.
630
- return;
631
- }
632
-
633
- if ( isset( $this->pluggable_functions[ $item_lc ] ) ) {
634
- // Pluggable function should not be prefixed.
635
- return;
636
- }
637
-
638
- $error_text = 'Functions declared in the global namespace';
639
- $error_code = 'NonPrefixedFunctionFound';
640
- break;
641
-
642
- case \T_CLASS:
643
- case \T_INTERFACE:
644
- case \T_TRAIT:
645
- case \T_ENUM:
646
- $item_name = ObjectDeclarations::getName( $this->phpcsFile, $stackPtr );
647
- $error_text = 'Classes declared';
648
- $error_code = 'NonPrefixedClassFound';
649
-
650
- switch ( $this->tokens[ $stackPtr ]['code'] ) {
651
- case \T_CLASS:
652
- if ( isset( $this->pluggable_classes[ strtolower( $item_name ) ] ) ) {
653
- // Pluggable class should not be prefixed.
654
- return;
655
- }
656
-
657
- if ( class_exists( '\\' . $item_name, false ) ) {
658
- // Backfill for PHP native class.
659
- return;
660
- }
661
- break;
662
-
663
- case \T_INTERFACE:
664
- if ( interface_exists( '\\' . $item_name, false ) ) {
665
- // Backfill for PHP native interface.
666
- return;
667
- }
668
-
669
- $error_text = 'Interfaces declared';
670
- $error_code = 'NonPrefixedInterfaceFound';
671
- break;
672
-
673
- case \T_TRAIT:
674
- // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.trait_existsFound
675
- if ( function_exists( '\trait_exists' ) && trait_exists( '\\' . $item_name, false ) ) {
676
- // Backfill for PHP native trait.
677
- return;
678
- }
679
-
680
- $error_text = 'Traits declared';
681
- $error_code = 'NonPrefixedTraitFound';
682
- break;
683
-
684
- case \T_ENUM:
685
- // phpcs:ignore PHPCompatibility.FunctionUse.NewFunctions.enum_existsFound
686
- if ( function_exists( '\enum_exists' ) && enum_exists( '\\' . $item_name, false ) ) {
687
- // Backfill for PHP native enum.
688
- return;
689
- }
690
-
691
- $error_text = 'Enums declared';
692
- $error_code = 'NonPrefixedEnumFound';
693
- break;
694
- }
695
-
696
- break;
697
-
698
- case \T_CONST:
699
- // Constants in an OO construct do not need to be prefixed.
700
- if ( true === Scopes::isOOConstant( $this->phpcsFile, $stackPtr ) ) {
701
- return;
702
- }
703
-
704
- $constant_name_ptr = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
705
- if ( false === $constant_name_ptr ) {
706
- // Live coding.
707
- return;
708
- }
709
-
710
- $item_name = $this->tokens[ $constant_name_ptr ]['content'];
711
- if ( \defined( '\\' . $item_name ) ) {
712
- // Backfill for PHP native constant.
713
- return;
714
- }
715
-
716
- if ( isset( $this->allowed_core_constants[ $item_name ] ) ) {
717
- // Defining a WP Core constant intended for overruling.
718
- return;
719
- }
720
-
721
- $error_text = 'Global constants defined';
722
- $error_code = 'NonPrefixedConstantFound';
723
- break;
724
-
725
- default:
726
- // Left empty on purpose.
727
- break;
728
-
729
- }
730
-
731
- if ( empty( $item_name ) || $this->is_prefixed( $stackPtr, $item_name ) === true ) {
732
- return;
733
- }
734
-
735
- $recorded = $this->phpcsFile->addError(
736
- self::ERROR_MSG,
737
- $stackPtr,
738
- $error_code,
739
- array(
740
- $error_text,
741
- $item_name,
742
- )
743
- );
744
-
745
- if ( true === $recorded ) {
746
- $this->record_potential_prefix_metric( $stackPtr, $item_name );
747
- }
748
- }
749
- }
750
-
751
- /**
752
- * Handle variable variables defined in the global namespace.
753
- *
754
- * @since 0.12.0
755
- *
756
- * @param int $stackPtr The position of the current token in the stack.
757
- *
758
- * @return int|void Integer stack pointer to skip forward or void to continue
759
- * normal file processing.
760
- */
761
- protected function process_variable_variable( $stackPtr ) {
762
- static $indicators = array(
763
- \T_OPEN_CURLY_BRACKET => true,
764
- \T_VARIABLE => true,
765
- );
766
-
767
- // Is this a variable variable ?
768
- // Not concerned with nested ones as those will be recognized on their own token.
769
- $next_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
770
- if ( false === $next_non_empty || ! isset( $indicators[ $this->tokens[ $next_non_empty ]['code'] ] ) ) {
771
- return;
772
- }
773
-
774
- if ( \T_OPEN_CURLY_BRACKET === $this->tokens[ $next_non_empty ]['code']
775
- && isset( $this->tokens[ $next_non_empty ]['bracket_closer'] )
776
- ) {
777
- // Skip over the variable part.
778
- $next_non_empty = $this->tokens[ $next_non_empty ]['bracket_closer'];
779
- }
780
-
781
- $maybe_assignment = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $next_non_empty + 1 ), null, true, null, true );
782
-
783
- while ( false !== $maybe_assignment
784
- && \T_OPEN_SQUARE_BRACKET === $this->tokens[ $maybe_assignment ]['code']
785
- && isset( $this->tokens[ $maybe_assignment ]['bracket_closer'] )
786
- ) {
787
- $maybe_assignment = $this->phpcsFile->findNext(
788
- Tokens::$emptyTokens,
789
- ( $this->tokens[ $maybe_assignment ]['bracket_closer'] + 1 ),
790
- null,
791
- true,
792
- null,
793
- true
794
- );
795
- }
796
-
797
- if ( false === $maybe_assignment ) {
798
- return;
799
- }
800
-
801
- if ( ! isset( Tokens::$assignmentTokens[ $this->tokens[ $maybe_assignment ]['code'] ] ) ) {
802
- // Not an assignment.
803
- return;
804
- }
805
-
806
- $error = self::ERROR_MSG;
807
-
808
- /*
809
- * Local variable variables in a function do not need to be prefixed.
810
- * But a variable variable could evaluate to the name of an imported global
811
- * variable.
812
- * Not concerned with imported variable variables (global.. ) as that has been
813
- * forbidden since PHP 7.0. Presuming cross-version code and if not, that
814
- * is for the PHPCompatibility standard to detect.
815
- */
816
- $functionPtr = Conditions::getLastCondition( $this->phpcsFile, $stackPtr, Collections::functionDeclarationTokens() );
817
- if ( false !== $functionPtr ) {
818
- $has_global = $this->phpcsFile->findPrevious( \T_GLOBAL, ( $stackPtr - 1 ), $this->tokens[ $functionPtr ]['scope_opener'] );
819
- if ( false === $has_global ) {
820
- // No variable import happening.
821
- return;
822
- }
823
-
824
- $error = 'Variable variable which could potentially override an imported global variable detected. ' . $error;
825
- }
826
-
827
- $variable_name = $this->phpcsFile->getTokensAsString( $stackPtr, ( ( $next_non_empty - $stackPtr ) + 1 ) );
828
-
829
- // Still here ? In that case, the variable name should be prefixed.
830
- $recorded = $this->phpcsFile->addWarning(
831
- $error,
832
- $stackPtr,
833
- 'NonPrefixedVariableFound',
834
- array(
835
- 'Global variables defined',
836
- $variable_name,
837
- )
838
- );
839
-
840
- if ( true === $recorded ) {
841
- $this->record_potential_prefix_metric( $stackPtr, $variable_name );
842
- }
843
-
844
- // Skip over the variable part of the variable.
845
- return ( $next_non_empty + 1 );
846
- }
847
-
848
- /**
849
- * Check that defined global variables are prefixed.
850
- *
851
- * @since 0.12.0
852
- * @since 2.2.0 Added $in_list parameter.
853
- *
854
- * @param int $stackPtr The position of the current token in the stack.
855
- * @param bool $in_list Whether or not this is a variable in a list assignment.
856
- * Defaults to false.
857
- *
858
- * @return int|void Integer stack pointer to skip forward or void to continue
859
- * normal file processing.
860
- */
861
- protected function process_variable_assignment( $stackPtr, $in_list = false ) {
862
- /*
863
- * We're only concerned with variables which are being defined.
864
- * `is_assigment()` will not recognize property assignments, which is good in this case.
865
- * However it will also not recognize $b in `foreach( $a as $b )` as an assignment, so
866
- * we need a separate check for that.
867
- */
868
- if ( false === $in_list
869
- && false === VariableHelper::is_assignment( $this->phpcsFile, $stackPtr )
870
- && Context::inForeachCondition( $this->phpcsFile, $stackPtr ) !== 'afterAs'
871
- ) {
872
- return;
873
- }
874
-
875
- $is_error = true;
876
- $variable_name = substr( $this->tokens[ $stackPtr ]['content'], 1 ); // Strip the dollar sign.
877
-
878
- // Bow out early if we know for certain no prefix is needed.
879
- if ( 'GLOBALS' !== $variable_name
880
- && $this->variable_prefixed_or_allowed( $stackPtr, $variable_name ) === true
881
- ) {
882
- return;
883
- }
884
-
885
- if ( 'GLOBALS' === $variable_name ) {
886
- $array_open = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
887
- if ( false === $array_open || \T_OPEN_SQUARE_BRACKET !== $this->tokens[ $array_open ]['code'] ) {
888
- // Live coding or something very silly.
889
- return;
890
- }
891
-
892
- $array_key = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $array_open + 1 ), null, true, null, true );
893
- if ( false === $array_key ) {
894
- // No key found, nothing to do.
895
- return;
896
- }
897
-
898
- $stackPtr = $array_key;
899
- $variable_name = TextStrings::stripQuotes( $this->tokens[ $array_key ]['content'] );
900
-
901
- // Check whether a prefix is needed.
902
- if ( isset( Tokens::$stringTokens[ $this->tokens[ $array_key ]['code'] ] )
903
- && $this->variable_prefixed_or_allowed( $stackPtr, $variable_name ) === true
904
- ) {
905
- return;
906
- }
907
-
908
- if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $array_key ]['code'] ) {
909
- // If the array key is a double quoted string, try again with only
910
- // the part before the first variable (if any).
911
- $exploded = explode( '$', $variable_name );
912
- $first = rtrim( $exploded[0], '{' );
913
- if ( '' !== $first ) {
914
- if ( $this->variable_prefixed_or_allowed( $array_key, $first ) === true ) {
915
- return;
916
- }
917
- } else {
918
- // If the first part was dynamic, throw a warning.
919
- $is_error = false;
920
- }
921
- } elseif ( ! isset( Tokens::$stringTokens[ $this->tokens[ $array_key ]['code'] ] ) ) {
922
- // Dynamic array key, throw a warning.
923
- $is_error = false;
924
- }
925
- } else {
926
- // Function parameters do not need to be prefixed.
927
- if ( false === $in_list ) {
928
- $functionPtr = Parentheses::getLastOwner( $this->phpcsFile, $stackPtr, Collections::functionDeclarationTokens() );
929
- if ( false !== $functionPtr ) {
930
- return;
931
- }
932
- unset( $functionPtr );
933
- }
934
-
935
- // Properties in a class do not need to be prefixed.
936
- if ( false === $in_list && true === Scopes::isOOProperty( $this->phpcsFile, $stackPtr ) ) {
937
- return;
938
- }
939
-
940
- // Local variables in a function do not need to be prefixed unless they are being imported.
941
- $functionPtr = Conditions::getLastCondition( $this->phpcsFile, $stackPtr, Collections::functionDeclarationTokens() );
942
- if ( false !== $functionPtr ) {
943
- $has_global = $this->phpcsFile->findPrevious( \T_GLOBAL, ( $stackPtr - 1 ), $this->tokens[ $functionPtr ]['scope_opener'] );
944
- if ( false === $has_global
945
- || Conditions::getLastCondition( $this->phpcsFile, $has_global, Collections::functionDeclarationTokens() ) !== $functionPtr
946
- ) {
947
- // No variable import happening in the current scope.
948
- return;
949
- }
950
-
951
- // Ok, this may be an imported global variable.
952
- $end_of_statement = $this->phpcsFile->findNext( array( \T_SEMICOLON, \T_CLOSE_TAG ), ( $has_global + 1 ) );
953
- if ( false === $end_of_statement ) {
954
- // No semi-colon - live coding.
955
- return;
956
- }
957
-
958
- for ( $ptr = ( $has_global + 1 ); $ptr <= $end_of_statement; $ptr++ ) {
959
- // Move the stack pointer to the next variable.
960
- $ptr = $this->phpcsFile->findNext( \T_VARIABLE, $ptr, $end_of_statement, false, null, true );
961
-
962
- if ( false === $ptr ) {
963
- // Reached the end of the global statement without finding the variable,
964
- // so this must be a local variable.
965
- return;
966
- }
967
-
968
- if ( substr( $this->tokens[ $ptr ]['content'], 1 ) === $variable_name ) {
969
- break;
970
- }
971
- }
972
-
973
- unset( $has_global, $end_of_statement, $ptr );
974
- }
975
- }
976
-
977
- // Still here ? In that case, the variable name should be prefixed.
978
- $recorded = MessageHelper::addMessage(
979
- $this->phpcsFile,
980
- self::ERROR_MSG,
981
- $stackPtr,
982
- $is_error,
983
- 'NonPrefixedVariableFound',
984
- array(
985
- 'Global variables defined',
986
- '$' . $variable_name,
987
- )
988
- );
989
-
990
- if ( true === $recorded ) {
991
- $this->record_potential_prefix_metric( $stackPtr, $variable_name );
992
- }
993
- }
994
-
995
- /**
996
- * Check that global variables declared via a list construct are prefixed.
997
- *
998
- * {@internal No need to take special measures for nested lists. Nested or not,
999
- * each list part can only contain one variable being written to.}
1000
- *
1001
- * @since 2.2.0
1002
- *
1003
- * @param int $stackPtr The position of the current token in the stack.
1004
- *
1005
- * @return int|void Integer stack pointer to skip forward or void to continue
1006
- * normal file processing.
1007
- */
1008
- protected function process_list_assignment( $stackPtr ) {
1009
- $list_open_close = Lists::getOpenClose( $this->phpcsFile, $stackPtr );
1010
- if ( false === $list_open_close ) {
1011
- // Short array, not short list.
1012
- return;
1013
- }
1014
-
1015
- $var_pointers = ListHelper::get_list_variables( $this->phpcsFile, $stackPtr );
1016
- foreach ( $var_pointers as $ptr ) {
1017
- $this->process_variable_assignment( $ptr, true );
1018
- }
1019
-
1020
- // No need to re-examine these variables.
1021
- return $list_open_close['closer'];
1022
- }
1023
-
1024
- /**
1025
- * Process the parameters of a matched function.
1026
- *
1027
- * @since 0.12.0
1028
- *
1029
- * @param int $stackPtr The position of the current token in the stack.
1030
- * @param string $group_name The name of the group which was matched.
1031
- * @param string $matched_content The token content (function name) which was matched
1032
- * in lowercase.
1033
- * @param array $parameters Array with information about the parameters.
1034
- *
1035
- * @return void
1036
- */
1037
- public function process_parameters( $stackPtr, $group_name, $matched_content, $parameters ) {
1038
- if ( 'define' === $matched_content ) {
1039
- $target_param = PassedParameters::getParameterFromStack( $parameters, 1, 'constant_name' );
1040
-
1041
- } else {
1042
- $target_param = WPHookHelper::get_hook_name_param( $matched_content, $parameters );
1043
- }
1044
-
1045
- if ( false === $target_param ) {
1046
- return;
1047
- }
1048
-
1049
- $is_error = true;
1050
- $clean_content = TextStrings::stripQuotes( $target_param['clean'] );
1051
-
1052
- if ( ( 'define' !== $matched_content
1053
- && isset( $this->allowed_core_hooks[ $clean_content ] ) )
1054
- || ( 'define' === $matched_content
1055
- && isset( $this->allowed_core_constants[ $clean_content ] ) )
1056
- ) {
1057
- return;
1058
- }
1059
-
1060
- if ( $this->is_prefixed( $target_param['start'], $clean_content ) === true ) {
1061
- return;
1062
- } else {
1063
- // This may be a dynamic hook/constant name.
1064
- $first_non_empty = $this->phpcsFile->findNext(
1065
- Tokens::$emptyTokens,
1066
- $target_param['start'],
1067
- ( $target_param['end'] + 1 ),
1068
- true
1069
- );
1070
-
1071
- if ( false === $first_non_empty ) {
1072
- return;
1073
- }
1074
-
1075
- $first_non_empty_content = TextStrings::stripQuotes( $this->tokens[ $first_non_empty ]['content'] );
1076
-
1077
- // Try again with just the first token if it's a text string.
1078
- if ( isset( Tokens::$stringTokens[ $this->tokens[ $first_non_empty ]['code'] ] )
1079
- && $this->is_prefixed( $target_param['start'], $first_non_empty_content ) === true
1080
- ) {
1081
- return;
1082
- }
1083
-
1084
- if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $first_non_empty ]['code'] ) {
1085
- // If the first part of the parameter is a double quoted string, try again with only
1086
- // the part before the first variable (if any).
1087
- $exploded = explode( '$', $first_non_empty_content );
1088
- $first = rtrim( $exploded[0], '{' );
1089
- if ( '' !== $first ) {
1090
- if ( $this->is_prefixed( $target_param['start'], $first ) === true ) {
1091
- return;
1092
- }
1093
- } else {
1094
- // Start of hook/constant name is dynamic, throw a warning.
1095
- $is_error = false;
1096
- }
1097
- } elseif ( ! isset( Tokens::$stringTokens[ $this->tokens[ $first_non_empty ]['code'] ] ) ) {
1098
- // Dynamic hook/constant name, throw a warning.
1099
- $is_error = false;
1100
- }
1101
- }
1102
-
1103
- if ( 'define' === $matched_content ) {
1104
- if ( \defined( '\\' . $clean_content ) ) {
1105
- // Backfill for PHP native constant.
1106
- return;
1107
- }
1108
-
1109
- if ( strpos( $clean_content, '\\' ) !== false ) {
1110
- // Namespaced or unreachable constant.
1111
- return;
1112
- }
1113
-
1114
- $data = array( 'Global constants defined' );
1115
- $error_code = 'NonPrefixedConstantFound';
1116
- if ( false === $is_error ) {
1117
- $error_code = 'VariableConstantNameFound';
1118
- }
1119
- } else {
1120
- $data = array( 'Hook names invoked' );
1121
- $error_code = 'NonPrefixedHooknameFound';
1122
- if ( false === $is_error ) {
1123
- $error_code = 'DynamicHooknameFound';
1124
- }
1125
- }
1126
-
1127
- $data[] = $clean_content;
1128
-
1129
- $recorded = MessageHelper::addMessage( $this->phpcsFile, self::ERROR_MSG, $first_non_empty, $is_error, $error_code, $data );
1130
-
1131
- if ( true === $recorded ) {
1132
- $this->record_potential_prefix_metric( $stackPtr, $clean_content );
1133
- }
1134
- }
1135
-
1136
- /**
1137
- * Check if a function/class/constant/variable name is prefixed with one of the expected prefixes.
1138
- *
1139
- * @since 0.12.0
1140
- * @since 0.14.0 Allows for other non-word characters as well as underscores to better support hook names.
1141
- * @since 1.0.0 Does not require a word seperator anymore after a prefix.
1142
- * This allows for improved code style independent checking,
1143
- * i.e. allows for camelCase naming and the likes.
1144
- * @since 1.0.1 - Added $stackPtr parameter.
1145
- * - The function now also records metrics about the prefixes encountered.
1146
- *
1147
- * @param int $stackPtr The position of the token to record the metric against.
1148
- * @param string $name Name to check for a prefix.
1149
- *
1150
- * @return bool True when the name is one of the prefixes or starts with an allowed prefix.
1151
- * False otherwise.
1152
- */
1153
- private function is_prefixed( $stackPtr, $name ) {
1154
- foreach ( $this->validated_prefixes as $prefix ) {
1155
- if ( stripos( $name, $prefix ) === 0 ) {
1156
- $this->phpcsFile->recordMetric( $stackPtr, 'Prefix all globals: allowed prefixes', $prefix );
1157
- return true;
1158
- }
1159
- }
1160
-
1161
- return false;
1162
- }
1163
-
1164
- /**
1165
- * Check if a variable name might need a prefix.
1166
- *
1167
- * Prefix is not needed for:
1168
- * - superglobals,
1169
- * - WP native globals,
1170
- * - variables which are already prefixed.
1171
- *
1172
- * @since 0.12.0
1173
- * @since 1.0.1 Added $stackPtr parameter.
1174
- * @since 3.0.0 Renamed from `variable_prefixed_or_whitelisted()` to `variable_prefixed_or_allowed()`.
1175
- *
1176
- * @param int $stackPtr The position of the token to record the metric against.
1177
- * @param string $name Variable name without the dollar sign.
1178
- *
1179
- * @return bool True if the variable name is allowed or already prefixed.
1180
- * False otherwise.
1181
- */
1182
- private function variable_prefixed_or_allowed( $stackPtr, $name ) {
1183
- // Ignore superglobals and WP global variables.
1184
- if ( Variables::isSuperglobalName( $name ) || WPGlobalVariablesHelper::is_wp_global( $name ) ) {
1185
- return true;
1186
- }
1187
-
1188
- return $this->is_prefixed( $stackPtr, $name );
1189
- }
1190
-
1191
- /**
1192
- * Validate an array of prefixes as passed through a custom property or via the command line.
1193
- *
1194
- * Checks that the prefix:
1195
- * - is not one of the blocked ones.
1196
- * - complies with the PHP rules for valid function, class, variable, constant names.
1197
- *
1198
- * @since 0.12.0
1199
- *
1200
- * @return void
1201
- */
1202
- private function validate_prefixes() {
1203
- if ( $this->previous_prefixes === $this->prefixes ) {
1204
- return;
1205
- }
1206
-
1207
- // Set the cache *before* validation so as to not break the above compare.
1208
- $this->previous_prefixes = $this->prefixes;
1209
-
1210
- // Validate the passed prefix(es).
1211
- $prefixes = array();
1212
- $ns_prefixes = array();
1213
- foreach ( $this->prefixes as $key => $prefix ) {
1214
- $prefixLC = strtolower( $prefix );
1215
-
1216
- if ( isset( $this->prefix_blocklist[ $prefixLC ] ) ) {
1217
- $this->phpcsFile->addError(
1218
- 'The "%s" prefix is not allowed.',
1219
- 0,
1220
- 'ForbiddenPrefixPassed',
1221
- array( $prefix )
1222
- );
1223
- continue;
1224
- }
1225
-
1226
- $prefix_length = strlen( $prefix );
1227
- if ( function_exists( 'iconv_strlen' ) ) {
1228
- $prefix_length = iconv_strlen( $prefix, Helper::getEncoding( $this->phpcsFile ) );
1229
- }
1230
-
1231
- if ( $prefix_length < self::MIN_PREFIX_LENGTH ) {
1232
- $this->phpcsFile->addError(
1233
- 'The "%s" prefix is too short. Short prefixes are not unique enough and may cause name collisions with other code.',
1234
- 0,
1235
- 'ShortPrefixPassed',
1236
- array( $prefix )
1237
- );
1238
- continue;
1239
- }
1240
-
1241
- /*
1242
- * Validate the prefix against characters allowed for function, class, constant names etc.
1243
- * Note: this does not use the PHPCSUtils `NamingConventions::isValidIdentifierName()` method
1244
- * as we want to allow namespace separators in the prefixes.
1245
- */
1246
- if ( preg_match( '`^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff\\\\]*$`', $prefix ) !== 1 ) {
1247
-
1248
- $this->phpcsFile->addWarning(
1249
- 'The "%s" prefix is not a valid namespace/function/class/variable/constant prefix in PHP.',
1250
- 0,
1251
- 'InvalidPrefixPassed',
1252
- array( $prefix )
1253
- );
1254
- }
1255
-
1256
- // Lowercase the prefix to allow for direct compare.
1257
- $prefixes[ $key ] = $prefixLC;
1258
-
1259
- /*
1260
- * Replace non-word characters in the prefix with a regex snippet, but only if the
1261
- * string doesn't already contain namespace separators.
1262
- */
1263
- $is_regex = false;
1264
- if ( strpos( $prefix, '\\' ) === false && preg_match( '`[_\W]`', $prefix ) > 0 ) {
1265
- $prefix = preg_replace( '`([_\W])`', '[\\\\\\\\$1]', $prefixLC );
1266
- $is_regex = true;
1267
- }
1268
-
1269
- $ns_prefixes[ $prefixLC ] = array(
1270
- 'prefix' => $prefix,
1271
- 'is_regex' => $is_regex,
1272
- );
1273
- }
1274
-
1275
- // Set the validated prefixes caches.
1276
- $this->validated_prefixes = $prefixes;
1277
- $this->validated_namespace_prefixes = $ns_prefixes;
1278
- }
1279
-
1280
- /**
1281
- * Record the "potential prefix" metric.
1282
- *
1283
- * @since 1.0.1
1284
- *
1285
- * @param int $stackPtr The position of the token to record the metric against.
1286
- * @param string $construct_name Name of the global construct to try and distill a potential prefix from.
1287
- *
1288
- * @return void
1289
- */
1290
- private function record_potential_prefix_metric( $stackPtr, $construct_name ) {
1291
- if ( preg_match( '`^([A-Z]*[a-z0-9]*+)`', ltrim( $construct_name, '\$_' ), $matches ) > 0
1292
- && isset( $matches[1] ) && '' !== $matches[1]
1293
- ) {
1294
- $this->phpcsFile->recordMetric( $stackPtr, 'Prefix all globals: potential prefixes - start of non-prefixed construct', strtolower( $matches[1] ) );
1295
- }
1296
- }
1297
- }