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,903 +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\Security;
11
-
12
- use PHP_CodeSniffer\Util\Tokens;
13
- use PHPCSUtils\BackCompat\BCFile;
14
- use PHPCSUtils\Tokens\Collections;
15
- use PHPCSUtils\Utils\Arrays;
16
- use PHPCSUtils\Utils\Conditions;
17
- use PHPCSUtils\Utils\Operators;
18
- use PHPCSUtils\Utils\PassedParameters;
19
- use PHPCSUtils\Utils\TextStrings;
20
- use WordPressCS\WordPress\AbstractFunctionRestrictionsSniff;
21
- use WordPressCS\WordPress\Helpers\ArrayWalkingFunctionsHelper;
22
- use WordPressCS\WordPress\Helpers\ConstantsHelper;
23
- use WordPressCS\WordPress\Helpers\ContextHelper;
24
- use WordPressCS\WordPress\Helpers\EscapingFunctionsTrait;
25
- use WordPressCS\WordPress\Helpers\FormattingFunctionsHelper;
26
- use WordPressCS\WordPress\Helpers\PrintingFunctionsTrait;
27
- use WordPressCS\WordPress\Helpers\VariableHelper;
28
-
29
- /**
30
- * Verifies that all outputted strings are escaped.
31
- *
32
- * @link https://developer.wordpress.org/apis/security/data-validation/ WordPress Developer Docs on Data Validation.
33
- *
34
- * @since 2013-06-11
35
- * @since 0.4.0 This class now extends the WordPressCS native `Sniff` class.
36
- * @since 0.5.0 The various function list properties which used to be contained in this class
37
- * have been moved to the WordPressCS native `Sniff` parent class.
38
- * @since 0.12.0 This sniff will now also check for output escaping when using shorthand
39
- * echo tags `<?=`.
40
- * @since 0.13.0 Class name changed: this class is now namespaced.
41
- * @since 1.0.0 This sniff has been moved from the `XSS` category to the `Security` category.
42
- * @since 3.0.0 This class now extends the WordPressCS native
43
- * `AbstractFunctionRestrictionsSniff` class.
44
- * The parent `exclude` property is disabled.
45
- *
46
- * @uses \WordPressCS\WordPress\Helpers\EscapingFunctionsTrait::$customEscapingFunctions
47
- * @uses \WordPressCS\WordPress\Helpers\EscapingFunctionsTrait::$customAutoEscapedFunctions
48
- * @uses \WordPressCS\WordPress\Helpers\PrintingFunctionsTrait::$customPrintingFunctions
49
- */
50
- class EscapeOutputSniff extends AbstractFunctionRestrictionsSniff {
51
-
52
- use EscapingFunctionsTrait;
53
- use PrintingFunctionsTrait;
54
-
55
- /**
56
- * Printing functions that incorporate unsafe values.
57
- *
58
- * @since 0.4.0
59
- * @since 0.11.0 Changed from public static to protected non-static.
60
- * @since 3.0.0 The format of the array values has changed from plain string to array.
61
- *
62
- * @var array<string, array>
63
- */
64
- protected $unsafePrintingFunctions = array(
65
- '_e' => array(
66
- 'alternative' => 'esc_html_e() or esc_attr_e()',
67
- 'params' => array(
68
- 1 => 'text',
69
- ),
70
- ),
71
- '_ex' => array(
72
- 'alternative' => 'echo esc_html_x() or echo esc_attr_x()',
73
- 'params' => array(
74
- 1 => 'text',
75
- ),
76
- ),
77
- );
78
-
79
- /**
80
- * List of names of the native PHP constants which can be considered safe.
81
- *
82
- * @since 1.0.0
83
- *
84
- * @var array<string, bool>
85
- */
86
- private $safe_php_constants = array(
87
- 'PHP_EOL' => true, // String.
88
- 'PHP_VERSION' => true, // Integer.
89
- 'PHP_MAJOR_VERSION' => true, // Integer.
90
- 'PHP_MINOR_VERSION' => true, // Integer.
91
- 'PHP_RELEASE_VERSION' => true, // Integer.
92
- 'PHP_VERSION_ID' => true, // Integer.
93
- 'PHP_EXTRA_VERSION' => true, // String.
94
- 'PHP_DEBUG' => true, // Integer.
95
- );
96
-
97
- /**
98
- * List of tokens which can be considered as safe when directly part of the output.
99
- *
100
- * This list is enhanced with additional tokens in the `register()` method.
101
- *
102
- * @since 0.12.0
103
- *
104
- * @var array<string|int, string|int>
105
- */
106
- private $safe_components = array(
107
- \T_LNUMBER => \T_LNUMBER,
108
- \T_DNUMBER => \T_DNUMBER,
109
- \T_TRUE => \T_TRUE,
110
- \T_FALSE => \T_FALSE,
111
- \T_NULL => \T_NULL,
112
- \T_CONSTANT_ENCAPSED_STRING => \T_CONSTANT_ENCAPSED_STRING,
113
- \T_START_NOWDOC => \T_START_NOWDOC,
114
- \T_NOWDOC => \T_NOWDOC,
115
- \T_END_NOWDOC => \T_END_NOWDOC,
116
- \T_BOOLEAN_NOT => \T_BOOLEAN_NOT,
117
- );
118
-
119
- /**
120
- * List of keyword tokens this sniff listens for, which can also be used as an inline expression.
121
- *
122
- * @since 3.0.0
123
- *
124
- * @var array<string|int, string|int>
125
- */
126
- private $target_keywords = array(
127
- \T_EXIT => \T_EXIT,
128
- \T_PRINT => \T_PRINT,
129
- \T_THROW => \T_THROW,
130
- );
131
-
132
- /**
133
- * Returns an array of tokens this test wants to listen for.
134
- *
135
- * @return string|int[]
136
- */
137
- public function register() {
138
- // Enrich the list of "safe components" tokens.
139
- $this->safe_components += Tokens::$comparisonTokens;
140
- $this->safe_components += Tokens::$operators;
141
- $this->safe_components += Tokens::$booleanOperators;
142
- $this->safe_components += Collections::incrementDecrementOperators();
143
-
144
- // Set up the tokens the sniff should listen to.
145
- $targets = array_merge( parent::register(), $this->target_keywords );
146
- $targets[] = \T_ECHO;
147
- $targets[] = \T_OPEN_TAG_WITH_ECHO;
148
-
149
- return $targets;
150
- }
151
-
152
- /**
153
- * Groups of functions this sniff is looking for.
154
- *
155
- * @since 3.0.0
156
- *
157
- * @return array
158
- */
159
- public function getGroups() {
160
- // Make sure all array keys are lowercase (could contain user-provided function names).
161
- $printing_functions = array_change_key_case( $this->get_printing_functions(), \CASE_LOWER );
162
-
163
- // Remove the unsafe printing functions to prevent duplicate notices.
164
- $printing_functions = array_diff_key( $printing_functions, $this->unsafePrintingFunctions );
165
-
166
- return array(
167
- 'unsafe_printing_functions' => array(
168
- 'functions' => array_keys( $this->unsafePrintingFunctions ),
169
- ),
170
- 'printing_functions' => array(
171
- 'functions' => array_keys( $printing_functions ),
172
- ),
173
- );
174
- }
175
-
176
- /**
177
- * Processes this test, when one of its tokens is encountered.
178
- *
179
- * @since 3.0.0 This method has been split up.
180
- *
181
- * @param int $stackPtr The position of the current token in the stack.
182
- *
183
- * @return int|void Integer stack pointer to skip forward or void to continue
184
- * normal file processing.
185
- */
186
- public function process_token( $stackPtr ) {
187
- $start = ( $stackPtr + 1 );
188
- $end = $start;
189
-
190
- switch ( $this->tokens[ $stackPtr ]['code'] ) {
191
- case \T_STRING:
192
- // Prevent exclusion of any of the function groups.
193
- $this->exclude = array();
194
-
195
- // In the tests, custom printing functions may be added/removed on the fly.
196
- if ( defined( 'PHP_CODESNIFFER_IN_TESTS' ) ) {
197
- $this->setup_groups( 'functions' );
198
- }
199
-
200
- // Let the abstract parent class handle the initial function call check.
201
- return parent::process_token( $stackPtr );
202
-
203
- case \T_EXIT:
204
- $next_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
205
- if ( false === $next_non_empty
206
- || \T_OPEN_PARENTHESIS !== $this->tokens[ $next_non_empty ]['code']
207
- || isset( $this->tokens[ $next_non_empty ]['parenthesis_closer'] ) === false
208
- ) {
209
- // Live coding/parse error or an exit/die which doesn't pass a status code. Ignore.
210
- return;
211
- }
212
-
213
- // $end is not examined, so make sure the parentheses are balanced.
214
- $start = $next_non_empty;
215
- $end = ( $this->tokens[ $next_non_empty ]['parenthesis_closer'] + 1 );
216
- break;
217
-
218
- case \T_THROW:
219
- // Find the open parentheses, while stepping over the exception creation tokens.
220
- $ignore = Tokens::$emptyTokens;
221
- $ignore += Collections::namespacedNameTokens();
222
- $ignore += Collections::functionCallTokens();
223
- $ignore += Collections::objectOperators();
224
-
225
- $next_relevant = $this->phpcsFile->findNext( $ignore, ( $stackPtr + 1 ), null, true );
226
- if ( false === $next_relevant ) {
227
- return;
228
- }
229
-
230
- if ( \T_NEW === $this->tokens[ $next_relevant ]['code'] ) {
231
- $next_relevant = $this->phpcsFile->findNext( $ignore, ( $next_relevant + 1 ), null, true );
232
- if ( false === $next_relevant ) {
233
- return;
234
- }
235
- }
236
-
237
- if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $next_relevant ]['code']
238
- || isset( $this->tokens[ $next_relevant ]['parenthesis_closer'] ) === false
239
- ) {
240
- // Live coding/parse error or a pre-created exception. Nothing to do for us.
241
- return;
242
- }
243
-
244
- $end = $this->tokens[ $next_relevant ]['parenthesis_closer'];
245
-
246
- // Check if the throw is within a `try-catch`.
247
- // Doing this here (instead of earlier) to allow skipping to the end of the statement.
248
- $search_for = Collections::closedScopes();
249
- $search_for[ \T_TRY ] = \T_TRY;
250
-
251
- $last_condition = Conditions::getLastCondition( $this->phpcsFile, $stackPtr, $search_for );
252
- if ( false !== $last_condition && \T_TRY === $this->tokens[ $last_condition ]['code'] ) {
253
- // This exception will (probably) be caught, so ignore it.
254
- return $end;
255
- }
256
-
257
- $call_token = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $next_relevant - 1 ), null, true );
258
- $params = PassedParameters::getParameters( $this->phpcsFile, $call_token );
259
- if ( empty( $params ) ) {
260
- // No parameters passed, nothing to do.
261
- return $end;
262
- }
263
-
264
- // Examine each parameter individually.
265
- foreach ( $params as $param ) {
266
- $this->check_code_is_escaped( $param['start'], ( $param['end'] + 1 ), 'ExceptionNotEscaped' );
267
- }
268
-
269
- return $end;
270
-
271
- case \T_PRINT:
272
- $end = BCFile::findEndOfStatement( $this->phpcsFile, $stackPtr );
273
- if ( \T_COMMA !== $this->tokens[ $end ]['code']
274
- && \T_SEMICOLON !== $this->tokens[ $end ]['code']
275
- && \T_COLON !== $this->tokens[ $end ]['code']
276
- && \T_DOUBLE_ARROW !== $this->tokens[ $end ]['code']
277
- && isset( $this->tokens[ ( $end + 1 ) ] )
278
- ) {
279
- /*
280
- * FindEndOfStatement includes a comma/(semi-)colon/double arrow if that's the end of
281
- * the statement, but for everything else, it returns the last non-empty token _before_
282
- * the end, which would mean the last non-empty token in the statement would not
283
- * be examined. Let's fix that.
284
- */
285
- ++$end;
286
- }
287
-
288
- // Note: no need to check for close tag as close tag will have the token before the tag as the $end.
289
- if ( $end >= ( $this->phpcsFile->numTokens - 1 ) ) {
290
- $last_non_empty = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, $end, null, true );
291
- if ( \T_SEMICOLON !== $this->tokens[ $last_non_empty ]['code'] ) {
292
- // Live coding/parse error at end of file. Ignore.
293
- return;
294
- }
295
- }
296
-
297
- // Special case for a print statement *within* a ternary, where we need to find the "inline else" as the end token.
298
- $prev_non_empty = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
299
- if ( \T_INLINE_THEN === $this->tokens[ $prev_non_empty ]['code'] ) {
300
- $target_nesting_level = 0;
301
- if ( empty( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) === false ) {
302
- $target_nesting_level = \count( $this->tokens[ $stackPtr ]['nested_parenthesis'] );
303
- }
304
-
305
- $inline_else = false;
306
- for ( $i = ( $stackPtr + 1 ); $i < $end; $i++ ) {
307
- if ( \T_INLINE_ELSE !== $this->tokens[ $i ]['code'] ) {
308
- continue;
309
- }
310
-
311
- if ( empty( $this->tokens[ $i ]['nested_parenthesis'] )
312
- && 0 === $target_nesting_level
313
- ) {
314
- $inline_else = $i;
315
- break;
316
- }
317
-
318
- if ( empty( $this->tokens[ $i ]['nested_parenthesis'] ) === false
319
- && \count( $this->tokens[ $i ]['nested_parenthesis'] ) === $target_nesting_level
320
- ) {
321
- $inline_else = $i;
322
- break;
323
- }
324
- }
325
-
326
- if ( false === $inline_else ) {
327
- // Live coding/parse error. Bow out.
328
- return;
329
- }
330
-
331
- $end = $inline_else;
332
- }
333
-
334
- break;
335
-
336
- // Echo, open tag with echo.
337
- default:
338
- $end = $this->phpcsFile->findNext( array( \T_SEMICOLON, \T_CLOSE_TAG ), $stackPtr );
339
- if ( false === $end ) {
340
- // Live coding/parse error. Bow out.
341
- return;
342
- }
343
-
344
- break;
345
- }
346
-
347
- return $this->check_code_is_escaped( $start, $end );
348
- }
349
-
350
- /**
351
- * Process a matched function call token.
352
- *
353
- * @since 3.0.0 Split off from the process_token() method.
354
- *
355
- * @param int $stackPtr The position of the current token in the stack.
356
- * @param string $group_name The name of the group which was matched.
357
- * @param string $matched_content The token content (function name) which was matched
358
- * in lowercase.
359
- *
360
- * @return int|void Integer stack pointer to skip forward or void to continue
361
- * normal file processing.
362
- */
363
- public function process_matched_token( $stackPtr, $group_name, $matched_content ) {
364
- // Make sure we only deal with actual function calls, not function import use statements.
365
- $next_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
366
- if ( false === $next_non_empty
367
- || \T_OPEN_PARENTHESIS !== $this->tokens[ $next_non_empty ]['code']
368
- || isset( $this->tokens[ $next_non_empty ]['parenthesis_closer'] ) === false
369
- ) {
370
- // Live coding, parse error or not a function _call_.
371
- return;
372
- }
373
-
374
- $end = $this->tokens[ $next_non_empty ]['parenthesis_closer'];
375
-
376
- if ( 'unsafe_printing_functions' === $group_name ) {
377
- $error = $this->phpcsFile->addError(
378
- "All output should be run through an escaping function (like %s), found '%s'.",
379
- $stackPtr,
380
- 'UnsafePrintingFunction',
381
- array( $this->unsafePrintingFunctions[ $matched_content ]['alternative'], $matched_content )
382
- );
383
-
384
- // If the error was reported, don't bother checking the function's arguments.
385
- if ( $error || empty( $this->unsafePrintingFunctions[ $matched_content ]['params'] ) ) {
386
- return $end;
387
- }
388
-
389
- // If the function was not reported for being unsafe, examine the relevant parameters.
390
- $params = PassedParameters::getParameters( $this->phpcsFile, $stackPtr );
391
- foreach ( $this->unsafePrintingFunctions[ $matched_content ]['params'] as $position => $name ) {
392
- $param = PassedParameters::getParameterFromStack( $params, $position, $name );
393
- if ( false === $param ) {
394
- // Parameter doesn't exist. Nothing to do.
395
- continue;
396
- }
397
-
398
- $this->check_code_is_escaped( $param['start'], ( $param['end'] + 1 ) );
399
- }
400
-
401
- return $end;
402
- }
403
-
404
- $params = PassedParameters::getParameters( $this->phpcsFile, $stackPtr );
405
-
406
- /*
407
- * These functions only need to have their first argument - `$message` - escaped.
408
- * Note: user_error() is an alias for trigger_error(), so the param names are the same.
409
- */
410
- if ( 'trigger_error' === $matched_content || 'user_error' === $matched_content ) {
411
- $message_param = PassedParameters::getParameterFromStack( $params, 1, 'message' );
412
- if ( false === $message_param ) {
413
- // Message parameter doesn't exist. Nothing to do.
414
- return $end;
415
- }
416
-
417
- return $this->check_code_is_escaped( $message_param['start'], ( $message_param['end'] + 1 ) );
418
- }
419
-
420
- /*
421
- * If the first param to `_deprecated_file()` - `$file` - follows the typical `basename( __FILE__ )`
422
- * pattern, it doesn't need to be escaped.
423
- */
424
- if ( '_deprecated_file' === $matched_content ) {
425
- $file_param = PassedParameters::getParameterFromStack( $params, 1, 'file' );
426
-
427
- if ( false !== $file_param ) {
428
- // Check for a particular code pattern which can safely be ignored.
429
- if ( preg_match( '`^[\\\\]?basename\s*\(\s*__FILE__\s*\)$`', $file_param['clean'] ) === 1 ) {
430
- unset( $params[1], $params['file'] ); // Remove the param, whether passed positionally or named.
431
- }
432
- }
433
- unset( $file_param );
434
- }
435
-
436
- // Examine each parameter individually.
437
- foreach ( $params as $param ) {
438
- $this->check_code_is_escaped( $param['start'], ( $param['end'] + 1 ) );
439
- }
440
-
441
- return $end;
442
- }
443
-
444
- /**
445
- * Check whether each relevant part of an arbitrary group of token is output escaped.
446
- *
447
- * @since 3.0.0 Split off from the process_token() method.
448
- *
449
- * @param int $start The position to start checking from.
450
- * @param int $end The position to stop the check at.
451
- * @param string $code Code to use for the PHPCS error.
452
- *
453
- * @return int Integer stack pointer to skip forward.
454
- */
455
- protected function check_code_is_escaped( $start, $end, $code = 'OutputNotEscaped' ) {
456
- /*
457
- * Check for a ternary operator.
458
- * We only need to do this here if this statement is lacking parenthesis.
459
- * Otherwise it will be handled in the below loop.
460
- */
461
- $ternary = false;
462
- $next_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $start + 1 ), null, true );
463
- $last_non_empty = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $end - 1 ), null, true );
464
-
465
- if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $next_non_empty ]['code']
466
- || \T_CLOSE_PARENTHESIS !== $this->tokens[ $last_non_empty ]['code']
467
- || ( \T_OPEN_PARENTHESIS === $this->tokens[ $next_non_empty ]['code']
468
- && \T_CLOSE_PARENTHESIS === $this->tokens[ $last_non_empty ]['code']
469
- && isset( $this->tokens[ $next_non_empty ]['parenthesis_closer'] )
470
- && $this->tokens[ $next_non_empty ]['parenthesis_closer'] !== $last_non_empty
471
- )
472
- ) {
473
- // If there is a (long) ternary, skip over the part before the ?.
474
- $ternary = $this->find_long_ternary( $start, $end );
475
- if ( false !== $ternary ) {
476
- $start = ( $ternary + 1 );
477
- }
478
- }
479
-
480
- $in_cast = false;
481
- $watch = true;
482
-
483
- // Looping through echo'd components.
484
- for ( $i = $start; $i < $end; $i++ ) {
485
- // Ignore whitespaces and comments.
486
- if ( isset( Tokens::$emptyTokens[ $this->tokens[ $i ]['code'] ] ) ) {
487
- continue;
488
- }
489
-
490
- // Skip over irrelevant tokens.
491
- if ( isset( Tokens::$magicConstants[ $this->tokens[ $i ]['code'] ] ) // Magic constants for debug functions.
492
- || \T_NS_SEPARATOR === $this->tokens[ $i ]['code']
493
- || \T_DOUBLE_ARROW === $this->tokens[ $i ]['code']
494
- || \T_CLOSE_PARENTHESIS === $this->tokens[ $i ]['code']
495
- ) {
496
- continue;
497
- }
498
-
499
- if ( \T_OPEN_PARENTHESIS === $this->tokens[ $i ]['code'] ) {
500
- if ( ! isset( $this->tokens[ $i ]['parenthesis_closer'] ) ) {
501
- // Live coding or parse error.
502
- break;
503
- }
504
-
505
- if ( $in_cast ) {
506
- // Skip to the end of a function call if it has been cast to a safe value.
507
- $i = $this->tokens[ $i ]['parenthesis_closer'];
508
- $in_cast = false;
509
-
510
- } else {
511
- // Skip over the condition part of a (long) ternary (i.e., to after the ?).
512
- $ternary = $this->find_long_ternary( ( $i + 1 ), $this->tokens[ $i ]['parenthesis_closer'] );
513
- if ( false !== $ternary ) {
514
- $i = $ternary;
515
- }
516
- }
517
-
518
- continue;
519
- }
520
-
521
- /*
522
- * If a keyword is encountered in an inline expression and the keyword is one
523
- * this sniff listens to, recurse into the sniff, handle the expression
524
- * based on the keyword and skip over the code examined.
525
- */
526
- if ( isset( $this->target_keywords[ $this->tokens[ $i ]['code'] ] ) ) {
527
- $return_value = $this->process_token( $i );
528
- if ( isset( $return_value ) ) {
529
- $i = $return_value;
530
- }
531
- continue;
532
- }
533
-
534
- // Handle PHP 8.0+ match expressions.
535
- if ( \T_MATCH === $this->tokens[ $i ]['code'] ) {
536
- $match_valid = $this->walk_match_expression( $i, $code );
537
- if ( false === $match_valid ) {
538
- // Live coding or parse error. Shouldn't be possible as PHP[CS] will tokenize the keyword as `T_STRING` in that case.
539
- break; // @codeCoverageIgnore
540
- }
541
-
542
- $i = $match_valid;
543
- continue;
544
- }
545
-
546
- // Examine the items in an array individually for array parameters.
547
- if ( isset( Collections::arrayOpenTokensBC()[ $this->tokens[ $i ]['code'] ] ) ) {
548
- $array_open_close = Arrays::getOpenClose( $this->phpcsFile, $i );
549
- if ( false === $array_open_close ) {
550
- // Short list or misidentified short array token.
551
- continue;
552
- }
553
-
554
- $array_items = PassedParameters::getParameters( $this->phpcsFile, $i, 0, true );
555
- if ( ! empty( $array_items ) ) {
556
- foreach ( $array_items as $array_item ) {
557
- $this->check_code_is_escaped( $array_item['start'], ( $array_item['end'] + 1 ), $code );
558
- }
559
- }
560
-
561
- $i = $array_open_close['closer'];
562
- continue;
563
- }
564
-
565
- // Ignore safe PHP native constants.
566
- if ( \T_STRING === $this->tokens[ $i ]['code']
567
- && isset( $this->safe_php_constants[ $this->tokens[ $i ]['content'] ] )
568
- && ConstantsHelper::is_use_of_global_constant( $this->phpcsFile, $i )
569
- ) {
570
- continue;
571
- }
572
-
573
- // Wake up on concatenation characters, another part to check.
574
- if ( \T_STRING_CONCAT === $this->tokens[ $i ]['code'] ) {
575
- $watch = true;
576
- continue;
577
- }
578
-
579
- // Wake up after a ternary else (:).
580
- if ( false !== $ternary && \T_INLINE_ELSE === $this->tokens[ $i ]['code'] ) {
581
- $watch = true;
582
- continue;
583
- }
584
-
585
- // Wake up for commas.
586
- if ( \T_COMMA === $this->tokens[ $i ]['code'] ) {
587
- $in_cast = false;
588
- $watch = true;
589
- continue;
590
- }
591
-
592
- if ( false === $watch ) {
593
- continue;
594
- }
595
-
596
- // Allow T_CONSTANT_ENCAPSED_STRING eg: echo 'Some String';
597
- // Also T_LNUMBER, e.g.: echo 45; exit -1; and booleans.
598
- if ( isset( $this->safe_components[ $this->tokens[ $i ]['code'] ] ) ) {
599
- continue;
600
- }
601
-
602
- // Check for use of *::class.
603
- if ( \T_STRING === $this->tokens[ $i ]['code']
604
- || \T_VARIABLE === $this->tokens[ $i ]['code']
605
- || isset( Collections::ooHierarchyKeywords()[ $this->tokens[ $i ]['code'] ] )
606
- ) {
607
- $double_colon = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), $end, true );
608
- if ( false !== $double_colon
609
- && \T_DOUBLE_COLON === $this->tokens[ $double_colon ]['code']
610
- ) {
611
- $class_keyword = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $double_colon + 1 ), $end, true );
612
- if ( false !== $class_keyword
613
- && \T_STRING === $this->tokens[ $class_keyword ]['code']
614
- && 'class' === strtolower( $this->tokens[ $class_keyword ]['content'] )
615
- ) {
616
- $i = $class_keyword;
617
- continue;
618
- }
619
- }
620
- }
621
-
622
- $watch = false;
623
-
624
- // Allow int/double/bool casted variables.
625
- if ( isset( ContextHelper::get_safe_cast_tokens()[ $this->tokens[ $i ]['code'] ] ) ) {
626
- /*
627
- * If the next thing is a match expression, skip over it as whatever is
628
- * being returned will be safely cast.
629
- * Do not set `$in_cast` to `true`.
630
- */
631
- $next_non_empty = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), $end, true );
632
- if ( false !== $next_non_empty
633
- && \T_MATCH === $this->tokens[ $next_non_empty ]['code']
634
- && isset( $this->tokens[ $next_non_empty ]['scope_closer'] )
635
- ) {
636
- $i = $this->tokens[ $next_non_empty ]['scope_closer'];
637
- continue;
638
- }
639
-
640
- $in_cast = true;
641
- continue;
642
- }
643
-
644
- // Handle heredocs separately as they only need escaping when interpolation is used.
645
- if ( \T_START_HEREDOC === $this->tokens[ $i ]['code'] ) {
646
- $current = ( $i + 1 );
647
- while ( isset( $this->tokens[ $current ] ) && \T_HEREDOC === $this->tokens[ $current ]['code'] ) {
648
- $embeds = TextStrings::getEmbeds( $this->tokens[ $current ]['content'] );
649
- if ( ! empty( $embeds ) ) {
650
- $this->phpcsFile->addError(
651
- 'All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found interpolation in unescaped heredoc.',
652
- $current,
653
- 'HeredocOutputNotEscaped'
654
- );
655
- }
656
- ++$current;
657
- }
658
-
659
- $i = $current;
660
- continue;
661
- }
662
-
663
- // Now check that the next token is a function call.
664
- if ( \T_STRING === $this->tokens[ $i ]['code'] ) {
665
- $ptr = $i;
666
- $functionName = $this->tokens[ $i ]['content'];
667
- $function_opener = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
668
- $is_formatting_function = FormattingFunctionsHelper::is_formatting_function( $functionName );
669
-
670
- if ( false !== $function_opener
671
- && \T_OPEN_PARENTHESIS === $this->tokens[ $function_opener ]['code']
672
- ) {
673
- if ( ArrayWalkingFunctionsHelper::is_array_walking_function( $functionName ) ) {
674
- // Get the callback parameter.
675
- $callback = ArrayWalkingFunctionsHelper::get_callback_parameter( $this->phpcsFile, $ptr );
676
-
677
- if ( ! empty( $callback ) ) {
678
- /*
679
- * If this is a function callback (not a method callback array) and we're able
680
- * to resolve the function name, do so.
681
- */
682
- $mapped_function = $this->phpcsFile->findNext(
683
- Tokens::$emptyTokens,
684
- $callback['start'],
685
- ( $callback['end'] + 1 ),
686
- true
687
- );
688
-
689
- if ( false !== $mapped_function
690
- && \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $mapped_function ]['code']
691
- ) {
692
- $functionName = TextStrings::stripQuotes( $this->tokens[ $mapped_function ]['content'] );
693
- $ptr = $mapped_function;
694
- }
695
- }
696
- }
697
-
698
- // If this is a formatting function, we examine the parameters individually.
699
- if ( $is_formatting_function ) {
700
- $formatting_params = PassedParameters::getParameters( $this->phpcsFile, $i );
701
- if ( ! empty( $formatting_params ) ) {
702
- foreach ( $formatting_params as $format_param ) {
703
- $this->check_code_is_escaped( $format_param['start'], ( $format_param['end'] + 1 ), $code );
704
- }
705
- }
706
-
707
- $watch = true;
708
- }
709
-
710
- // Skip pointer to after the function.
711
- if ( isset( $this->tokens[ $function_opener ]['parenthesis_closer'] ) ) {
712
- $i = $this->tokens[ $function_opener ]['parenthesis_closer'];
713
- } else {
714
- // Live coding or parse error.
715
- break;
716
- }
717
- }
718
-
719
- // If this is a safe function, we don't flag it.
720
- if ( $is_formatting_function
721
- || $this->is_escaping_function( $functionName )
722
- || $this->is_auto_escaped_function( $functionName )
723
- ) {
724
- // Special case get_search_query() which is unsafe if $escaped = false.
725
- if ( 'get_search_query' === strtolower( $functionName ) ) {
726
- $escaped_param = PassedParameters::getParameter( $this->phpcsFile, $ptr, 1, 'escaped' );
727
- if ( false !== $escaped_param && 'true' !== $escaped_param['clean'] ) {
728
- $this->phpcsFile->addError(
729
- 'Output from get_search_query() is unsafe due to $escaped parameter being set to "false".',
730
- $ptr,
731
- 'UnsafeSearchQuery'
732
- );
733
- }
734
- }
735
-
736
- continue;
737
- }
738
-
739
- $content = $functionName;
740
-
741
- } else {
742
- $content = $this->tokens[ $i ]['content'];
743
- $ptr = $i;
744
- }
745
-
746
- // Make the error message a little more informative for array access variables.
747
- if ( \T_VARIABLE === $this->tokens[ $ptr ]['code'] ) {
748
- $array_keys = VariableHelper::get_array_access_keys( $this->phpcsFile, $ptr );
749
-
750
- if ( ! empty( $array_keys ) ) {
751
- $content .= '[' . implode( '][', $array_keys ) . ']';
752
- }
753
- }
754
-
755
- $this->phpcsFile->addError(
756
- "All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '%s'.",
757
- $ptr,
758
- $code,
759
- array( $content )
760
- );
761
- }
762
-
763
- return $end;
764
- }
765
-
766
- /**
767
- * Check whether there is a ternary token at the right nesting level in an arbitrary set of tokens.
768
- *
769
- * @since 3.0.0 Split off from the process_token() method.
770
- *
771
- * @param int $start The position to start checking from.
772
- * @param int $end The position to stop the check at.
773
- *
774
- * @return int|false Stack pointer to the ternary or FALSE if no ternary was found or
775
- * if this is a short ternary.
776
- */
777
- private function find_long_ternary( $start, $end ) {
778
- for ( $i = $start; $i < $end; $i++ ) {
779
- // Ignore anything within square brackets.
780
- if ( isset( $this->tokens[ $i ]['bracket_opener'], $this->tokens[ $i ]['bracket_closer'] )
781
- && $i === $this->tokens[ $i ]['bracket_opener']
782
- ) {
783
- $i = $this->tokens[ $i ]['bracket_closer'];
784
- continue;
785
- }
786
-
787
- // Skip past nested arrays, function calls and arbitrary groupings.
788
- if ( \T_OPEN_PARENTHESIS === $this->tokens[ $i ]['code']
789
- && isset( $this->tokens[ $i ]['parenthesis_closer'] )
790
- ) {
791
- $i = $this->tokens[ $i ]['parenthesis_closer'];
792
- continue;
793
- }
794
-
795
- // Skip past closures, anonymous classes and anything else scope related.
796
- if ( isset( $this->tokens[ $i ]['scope_condition'], $this->tokens[ $i ]['scope_closer'] )
797
- && $this->tokens[ $i ]['scope_condition'] === $i
798
- ) {
799
- $i = $this->tokens[ $i ]['scope_closer'];
800
- continue;
801
- }
802
-
803
- if ( \T_INLINE_THEN !== $this->tokens[ $i ]['code'] ) {
804
- continue;
805
- }
806
-
807
- /*
808
- * Okay, we found a ternary and it should be at the correct nesting level.
809
- * If this is a short ternary, it shouldn't be ignored though.
810
- */
811
- if ( Operators::isShortTernary( $this->phpcsFile, $i ) === true ) {
812
- return false;
813
- }
814
-
815
- return $i;
816
- }
817
-
818
- return false;
819
- }
820
-
821
- /**
822
- * Examine a match expression and only check for escaping in the "returned" parts of the match expression.
823
- *
824
- * {@internal PHPCSUtils will likely contain a utility for parsing match expressions in the future.
825
- * Ref: https://github.com/PHPCSStandards/PHPCSUtils/issues/497}
826
- *
827
- * @since 3.0.0
828
- *
829
- * @param int $stackPtr Pointer to a T_MATCH token.
830
- * @param string $code Code to use for the PHPCS error.
831
- *
832
- * @return int|false Stack pointer to skip to or FALSE if the match expression contained a parse error.
833
- */
834
- private function walk_match_expression( $stackPtr, $code ) {
835
- if ( ! isset( $this->tokens[ $stackPtr ]['scope_opener'], $this->tokens[ $stackPtr ]['scope_closer'] ) ) {
836
- // Parse error/live coding. Shouldn't be possible as PHP[CS] will tokenize the keyword as `T_STRING` in that case.
837
- return false; // @codeCoverageIgnore
838
- }
839
-
840
- $current = $this->tokens[ $stackPtr ]['scope_opener'];
841
- $end = $this->tokens[ $stackPtr ]['scope_closer'];
842
- do {
843
- $current = $this->phpcsFile->findNext( \T_MATCH_ARROW, ( $current + 1 ), $end );
844
- if ( false === $current ) {
845
- // We must have reached the last match item (or there is a parse error).
846
- break;
847
- }
848
-
849
- $item_start = ( $current + 1 );
850
- $item_end = false;
851
-
852
- // Find the first comma at the same level.
853
- for ( $i = $item_start; $i <= $end; $i++ ) {
854
- // Ignore anything within square brackets.
855
- if ( isset( $this->tokens[ $i ]['bracket_opener'], $this->tokens[ $i ]['bracket_closer'] )
856
- && $i === $this->tokens[ $i ]['bracket_opener']
857
- ) {
858
- $i = $this->tokens[ $i ]['bracket_closer'];
859
- continue;
860
- }
861
-
862
- // Skip past nested arrays, function calls and arbitrary groupings.
863
- if ( \T_OPEN_PARENTHESIS === $this->tokens[ $i ]['code']
864
- && isset( $this->tokens[ $i ]['parenthesis_closer'] )
865
- ) {
866
- $i = $this->tokens[ $i ]['parenthesis_closer'];
867
- continue;
868
- }
869
-
870
- // Skip past closures, anonymous classes and anything else scope related.
871
- if ( isset( $this->tokens[ $i ]['scope_condition'], $this->tokens[ $i ]['scope_closer'] )
872
- && $this->tokens[ $i ]['scope_condition'] === $i
873
- ) {
874
- $i = $this->tokens[ $i ]['scope_closer'];
875
- continue;
876
- }
877
-
878
- if ( \T_COMMA !== $this->tokens[ $i ]['code']
879
- && $i !== $end
880
- ) {
881
- continue;
882
- }
883
-
884
- $item_end = $i;
885
- break;
886
- }
887
-
888
- if ( false === $item_end ) {
889
- // Parse error/live coding. Shouldn't be possible.
890
- return false; // @codeCoverageIgnore
891
- }
892
-
893
- // Now check that the value returned by this match "leaf" is correctly escaped.
894
- $this->check_code_is_escaped( $item_start, $item_end, $code );
895
-
896
- // Independently of whether or not the check was successful or ran into (parse error) problems,
897
- // always skip to the identified end of the item.
898
- $current = $item_end;
899
- } while ( $current < $end );
900
-
901
- return $end;
902
- }
903
- }