Instant Articles for WP - Version 4.2.0

Version Description

Download this release

Release Info

Developer diegoquinteiro
Plugin Icon 128x128 Instant Articles for WP
Version 4.2.0
Comparing to
See all releases

Code changes from version 4.1.1 to 4.2.0

Files changed (426) hide show
  1. CHANGELOG.md +3 -0
  2. class-instant-articles-post.php +0 -13
  3. facebook-instant-articles.php +3 -39
  4. readme.txt +4 -1
  5. vendor/autoload.php +1 -1
  6. vendor/composer/ClassLoader.php +2 -2
  7. vendor/composer/autoload_classmap.php +0 -79
  8. vendor/composer/autoload_psr4.php +1 -1
  9. vendor/composer/autoload_real.php +7 -7
  10. vendor/composer/autoload_static.php +5 -88
  11. vendor/composer/installed.json +36 -65
  12. vendor/facebook/facebook-instant-articles-sdk-php/composer.json +2 -2
  13. vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/Image.php +10 -45
  14. vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/InstantArticle.php +1 -1
  15. vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/Video.php +10 -45
  16. vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Parser/instant-articles-rules.json +0 -20
  17. vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Getters/ConstantGetter.php +4 -1
  18. vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Getters/ElementGetter.php +1 -1
  19. vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/ConfigurationSelectorRule.php +1 -1
  20. vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/VideoRule.php +1 -1
  21. vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Settings/AnalyticsSettings.php +5 -4
  22. vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Transformer.php +79 -7
  23. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Elements/ImageTest.php +4 -4
  24. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Elements/SlideshowTest.php +3 -3
  25. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Elements/VideoTest.php +3 -3
  26. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Parser/instant-article-example-no-timezone.html +4 -4
  27. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Parser/instant-article-example-nyc-timezone.html +4 -4
  28. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Parser/instant-article-example-standard-timezone.html +4 -4
  29. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Parser/instant-article-example.html +4 -4
  30. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/SimpleTransformerTest.php +44 -0
  31. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/invalid-rule-class.json +15 -0
  32. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/invalid-rules-syntax.json +21 -0
  33. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/invalid-rules-unexpected-character.json +21 -0
  34. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/simple-ia.html +1 -2
  35. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/instant-article-example-multibyte.html +4 -4
  36. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/instant-article-example-nonutf8.html +4 -4
  37. vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/instant-article-example.html +4 -4
  38. vendor/facebook/graph-sdk/src/Facebook/Facebook.php +1 -1
  39. vendor/facebook/graph-sdk/src/Facebook/FacebookBatchRequest.php +1 -1
  40. vendor/squizlabs/php_codesniffer/README.md +34 -4
  41. vendor/squizlabs/php_codesniffer/autoload.php +12 -0
  42. vendor/squizlabs/php_codesniffer/phpcs.xml.dist +23 -0
  43. vendor/squizlabs/php_codesniffer/phpcs.xsd +9 -1
  44. vendor/squizlabs/php_codesniffer/scripts/build-phar.php +4 -4
  45. vendor/squizlabs/php_codesniffer/src/Config.php +98 -74
  46. vendor/squizlabs/php_codesniffer/src/Files/File.php +180 -47
  47. vendor/squizlabs/php_codesniffer/src/Files/FileList.php +6 -6
  48. vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php +2 -2
  49. vendor/squizlabs/php_codesniffer/src/Filters/Filter.php +3 -2
  50. vendor/squizlabs/php_codesniffer/src/Generators/Generator.php +0 -1
  51. vendor/squizlabs/php_codesniffer/src/Reporter.php +26 -4
  52. vendor/squizlabs/php_codesniffer/src/Reports/Diff.php +0 -1
  53. vendor/squizlabs/php_codesniffer/src/Reports/Full.php +27 -14
  54. vendor/squizlabs/php_codesniffer/src/Reports/Info.php +49 -20
  55. vendor/squizlabs/php_codesniffer/src/Reports/Json.php +10 -15
  56. vendor/squizlabs/php_codesniffer/src/Reports/Junit.php +2 -1
  57. vendor/squizlabs/php_codesniffer/src/Reports/Source.php +8 -9
  58. vendor/squizlabs/php_codesniffer/src/Reports/Summary.php +21 -0
  59. vendor/squizlabs/php_codesniffer/src/Ruleset.php +55 -10
  60. vendor/squizlabs/php_codesniffer/src/Runner.php +1 -1
  61. vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractArraySniff.php +1 -3
  62. vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php +0 -1
  63. vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractScopeSniff.php +21 -5
  64. vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractVariableSniff.php +48 -11
  65. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/Commenting/FixmeStandard.xml +1 -1
  66. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/PHP/LowerCaseConstantStandard.xml +1 -1
  67. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/PHP/LowerCaseTypeStandard.xml +38 -0
  68. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/PHP/UpperCaseConstantStandard.xml +1 -1
  69. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/WhiteSpace/ArbitraryParenthesesSpacingStandard.xml +26 -0
  70. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php +0 -1
  71. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php +6 -1
  72. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php +65 -62
  73. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +45 -19
  74. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +65 -21
  75. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php +0 -1
  76. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php +12 -3
  77. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php +46 -8
  78. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +15 -5
  79. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php +0 -2
  80. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php +1 -1
  81. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php +1 -2
  82. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php +6 -4
  83. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php +162 -0
  84. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php +14 -4
  85. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php +3 -16
  86. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php +238 -0
  87. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php +137 -0
  88. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +139 -57
  89. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc +6 -0
  90. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed +6 -0
  91. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php +4 -4
  92. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc +3 -3
  93. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc.fixed +3 -3
  94. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.2.inc +1 -1
  95. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.2.inc.fixed +1 -1
  96. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php +0 -22
  97. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.inc +3 -3
  98. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.inc.fixed +3 -3
  99. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.inc +17 -12
  100. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php +3 -2
  101. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc +3 -3
  102. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc +20 -0
  103. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js +20 -0
  104. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php +9 -4
  105. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc +21 -0
  106. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc.fixed +26 -0
  107. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php +8 -0
  108. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php +0 -5
  109. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php +1 -10
  110. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineLengthUnitTest.4.inc +1 -1
  111. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php +0 -12
  112. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc +146 -8
  113. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc.fixed +146 -8
  114. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php +29 -0
  115. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.inc +2 -2
  116. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.inc.fixed +2 -2
  117. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc +10 -0
  118. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc.fixed +10 -0
  119. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php +5 -0
  120. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc +44 -4
  121. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc.fixed +68 -19
  122. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php +7 -0
  123. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc +39 -6
  124. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc.fixed +37 -6
  125. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php +4 -0
  126. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.inc +20 -20
  127. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php +0 -1
  128. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc +1 -1
  129. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php +0 -12
  130. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php +1 -20
  131. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.inc +1 -1
  132. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc +11 -11
  133. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc.fixed +11 -11
  134. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php +0 -1
  135. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc +44 -0
  136. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed +44 -0
  137. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php +67 -0
  138. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php +0 -21
  139. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc +1 -1
  140. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc.fixed +1 -1
  141. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.inc +2 -2
  142. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.inc +161 -0
  143. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.inc.fixed +149 -0
  144. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php +82 -0
  145. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.1.inc +4 -4
  146. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.1.inc.fixed +4 -4
  147. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.2.inc +4 -4
  148. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.2.inc.fixed +4 -4
  149. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.inc +4 -4
  150. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.inc.fixed +4 -4
  151. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc +76 -0
  152. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc.fixed +70 -0
  153. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php +75 -0
  154. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc +56 -13
  155. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed +56 -13
  156. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc +56 -13
  157. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed +56 -13
  158. vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php +31 -5
  159. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php +0 -2
  160. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php +8 -1
  161. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php +0 -1
  162. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php +1 -0
  163. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php +8 -14
  164. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc +10 -10
  165. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc.fixed +10 -10
  166. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.inc +2 -2
  167. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.inc +1 -1
  168. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc +6 -6
  169. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed +6 -6
  170. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc +6 -6
  171. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed +7 -7
  172. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.js.fixed +2 -2
  173. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc +3 -3
  174. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.inc +45 -69
  175. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php +36 -55
  176. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.inc +6 -6
  177. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc +23 -0
  178. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc.fixed +73 -0
  179. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php +3 -0
  180. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc +1 -1
  181. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc.fixed +1 -1
  182. vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc +1 -1
  183. vendor/squizlabs/php_codesniffer/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php +32 -2
  184. vendor/squizlabs/php_codesniffer/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php +4 -8
  185. vendor/squizlabs/php_codesniffer/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.1.inc +2 -0
  186. vendor/squizlabs/php_codesniffer/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.12.inc +8 -0
  187. vendor/squizlabs/php_codesniffer/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php +18 -0
  188. vendor/squizlabs/php_codesniffer/src/Standards/PSR1/ruleset.xml +1 -0
  189. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Docs/Classes/ClassInstantiationStandard.xml +19 -0
  190. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Docs/Keywords/ShortFormTypeKeywordsStandard.xml +19 -0
  191. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Docs/Namespaces/CompoundNamespaceDepthStandard.xml +28 -0
  192. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Docs/Operators/OperatorSpacingStandard.xml +27 -0
  193. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php +100 -0
  194. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php +68 -0
  195. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php +80 -0
  196. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php +114 -0
  197. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc +34 -0
  198. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc.fixed +34 -0
  199. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php +64 -0
  200. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.inc +8 -0
  201. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.inc.fixed +8 -0
  202. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php +52 -0
  203. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.inc +31 -0
  204. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php +52 -0
  205. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.inc +48 -0
  206. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.inc.fixed +48 -0
  207. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php +69 -0
  208. vendor/squizlabs/php_codesniffer/src/Standards/PSR12/ruleset.xml +282 -0
  209. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php +3 -2
  210. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php +101 -37
  211. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php +0 -5
  212. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.inc +8 -0
  213. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.inc.fixed +10 -0
  214. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php +4 -2
  215. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.15.inc +10 -0
  216. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.16.inc +11 -0
  217. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.16.inc.fixed +9 -0
  218. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.17.inc +3 -0
  219. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.2.inc +2 -0
  220. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.2.inc.fixed +4 -0
  221. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.5.inc +26 -2
  222. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.5.inc.fixed +26 -2
  223. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php +15 -1
  224. vendor/squizlabs/php_codesniffer/src/Standards/PSR2/ruleset.xml +9 -1
  225. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php +0 -1
  226. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php +76 -79
  227. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php +3 -3
  228. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php +8 -1
  229. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php +4 -4
  230. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php +85 -40
  231. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php +0 -2
  232. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +8 -4
  233. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php +22 -1
  234. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php +27 -5
  235. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php +21 -9
  236. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php +1 -1
  237. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php +28 -27
  238. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php +60 -69
  239. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php +1 -1
  240. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php +2 -32
  241. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php +24 -9
  242. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php +55 -19
  243. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php +2 -1
  244. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php +50 -58
  245. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php +8 -16
  246. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php +1 -2
  247. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php +1 -2
  248. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php +117 -24
  249. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php +2 -3
  250. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php +38 -10
  251. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php +122 -87
  252. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php +39 -7
  253. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php +22 -18
  254. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc +54 -1
  255. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc.fixed +58 -1
  256. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc +53 -1
  257. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed +59 -1
  258. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php +42 -12
  259. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc +11 -0
  260. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc.fixed +11 -0
  261. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php +5 -4
  262. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.inc +3 -0
  263. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc +22 -0
  264. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc.fixed +26 -6
  265. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php +5 -2
  266. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php +0 -6
  267. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc +10 -0
  268. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed +10 -0
  269. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php +12 -10
  270. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc +10 -0
  271. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc.fixed +10 -0
  272. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc +6 -0
  273. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed +6 -0
  274. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php +3 -2
  275. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc +37 -0
  276. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed +36 -0
  277. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php +8 -1
  278. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php +5 -1
  279. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php +5 -1
  280. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc +2 -0
  281. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc.fixed +2 -0
  282. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js +2 -0
  283. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js.fixed +2 -0
  284. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php +1 -0
  285. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc +3 -0
  286. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc.fixed +3 -0
  287. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php +1 -0
  288. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc +16 -0
  289. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc.fixed +17 -1
  290. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.js.fixed +2 -2
  291. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc +16 -0
  292. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php +5 -1
  293. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc +3 -0
  294. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php +1 -0
  295. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.inc +24 -0
  296. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php +2 -0
  297. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc +3 -0
  298. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.inc +21 -1
  299. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php +1 -0
  300. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.inc +16 -0
  301. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php +3 -1
  302. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.inc +107 -1
  303. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.inc.fixed +122 -1
  304. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php +16 -3
  305. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc +58 -0
  306. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc.fixed +55 -0
  307. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php +7 -0
  308. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc +21 -0
  309. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed +21 -0
  310. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php +2 -0
  311. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc +38 -1
  312. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc.fixed +36 -1
  313. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php +3 -0
  314. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.inc +56 -0
  315. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.inc.fixed +51 -0
  316. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.inc +9 -0
  317. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.inc.fixed +7 -0
  318. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.inc +14 -0
  319. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.inc.fixed +5 -0
  320. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.4.inc +4 -0
  321. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.4.inc.fixed +4 -0
  322. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.5.inc +5 -0
  323. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.5.inc.fixed +4 -0
  324. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php +20 -1
  325. vendor/squizlabs/php_codesniffer/src/Standards/Squiz/ruleset.xml +119 -80
  326. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php +1 -1
  327. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php +12 -2
  328. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php +2 -32
  329. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php +5 -1
  330. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.1.inc.fixed +12 -0
  331. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.2.inc +1 -1
  332. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.3.inc +1 -0
  333. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.3.inc.fixed +1 -0
  334. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.4.inc +1 -0
  335. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.4.inc.fixed +1 -0
  336. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.5.inc +1 -0
  337. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.5.inc.fixed +1 -0
  338. vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php +11 -3
  339. vendor/squizlabs/php_codesniffer/src/Tokenizers/CSS.php +2 -2
  340. vendor/squizlabs/php_codesniffer/src/Tokenizers/JS.php +1 -0
  341. vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php +156 -153
  342. vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php +127 -34
  343. vendor/squizlabs/php_codesniffer/src/Util/Cache.php +13 -5
  344. vendor/squizlabs/php_codesniffer/src/Util/Common.php +0 -3
  345. vendor/squizlabs/php_codesniffer/src/Util/Standards.php +4 -0
  346. vendor/squizlabs/php_codesniffer/src/Util/Tokens.php +39 -39
  347. vendor/squizlabs/php_codesniffer/tests/AllTests.php +0 -1
  348. vendor/squizlabs/php_codesniffer/tests/Core/AllTests.php +8 -2
  349. vendor/squizlabs/php_codesniffer/tests/Core/ErrorSuppressionTest.php +84 -0
  350. vendor/squizlabs/php_codesniffer/tests/Core/File/FindEndOfStatementTest.inc +29 -0
  351. vendor/squizlabs/php_codesniffer/tests/Core/File/FindEndOfStatementTest.php +203 -0
  352. vendor/squizlabs/php_codesniffer/tests/Core/File/FindExtendedClassNameTest.inc +15 -1
  353. vendor/squizlabs/php_codesniffer/tests/Core/File/FindExtendedClassNameTest.php +61 -109
  354. vendor/squizlabs/php_codesniffer/tests/Core/File/FindImplementedInterfaceNamesTest.inc +6 -1
  355. vendor/squizlabs/php_codesniffer/tests/Core/File/FindImplementedInterfaceNamesTest.php +57 -87
  356. vendor/squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.inc +119 -0
  357. vendor/squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.php +382 -0
  358. vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodParametersTest.inc +1 -1
  359. vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodParametersTest.php +12 -0
  360. vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.inc +57 -0
  361. vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.php +524 -0
  362. vendor/squizlabs/php_codesniffer/tests/Core/File/IsReferenceTest.inc +1 -1
  363. vendor/squizlabs/php_codesniffer/tests/Standards/AbstractSniffUnitTest.php +1 -1
  364. vendor/squizlabs/php_codesniffer/tests/Standards/AllSniffs.php +14 -2
  365. vendor/symfony/css-selector/CssSelector.php +1 -1
  366. vendor/symfony/css-selector/Node/AbstractNode.php +1 -1
  367. vendor/symfony/css-selector/Node/ElementNode.php +2 -2
  368. vendor/symfony/css-selector/Node/SelectorNode.php +2 -2
  369. vendor/symfony/css-selector/Parser/Handler/HashHandler.php +2 -2
  370. vendor/symfony/css-selector/Parser/Handler/IdentifierHandler.php +2 -2
  371. vendor/symfony/css-selector/Parser/Handler/NumberHandler.php +2 -2
  372. vendor/symfony/css-selector/Parser/Handler/StringHandler.php +5 -5
  373. vendor/symfony/css-selector/Parser/Handler/WhitespaceHandler.php +1 -1
  374. vendor/symfony/css-selector/Parser/Parser.php +3 -3
  375. vendor/symfony/css-selector/Parser/Reader.php +1 -1
  376. vendor/symfony/css-selector/Parser/Token.php +1 -1
  377. vendor/symfony/css-selector/Parser/TokenStream.php +1 -1
  378. vendor/symfony/css-selector/Parser/Tokenizer/TokenizerEscaping.php +3 -3
  379. vendor/symfony/css-selector/Parser/Tokenizer/TokenizerPatterns.php +1 -1
  380. vendor/symfony/css-selector/Tests/Node/HashNodeTest.php +1 -1
  381. vendor/symfony/css-selector/Tests/Node/NegationNodeTest.php +1 -1
  382. vendor/symfony/css-selector/Tests/Parser/Handler/AbstractHandlerTest.php +1 -1
  383. vendor/symfony/css-selector/Tests/Parser/Handler/HashHandlerTest.php +1 -1
  384. vendor/symfony/css-selector/Tests/Parser/Handler/IdentifierHandlerTest.php +1 -1
  385. vendor/symfony/css-selector/Tests/Parser/Handler/StringHandlerTest.php +1 -1
  386. vendor/symfony/css-selector/Tests/Parser/ParserTest.php +1 -0
  387. vendor/symfony/css-selector/Tests/XPath/TranslatorTest.php +4 -4
  388. vendor/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php +1 -1
  389. vendor/symfony/css-selector/XPath/Extension/FunctionExtension.php +2 -8
  390. vendor/symfony/css-selector/XPath/Extension/HtmlExtension.php +1 -4
  391. vendor/symfony/css-selector/XPath/Translator.php +6 -6
  392. vendor/symfony/css-selector/phpunit.xml.dist +1 -1
  393. vendor/wp-coding-standards/wpcs/.gitattributes +1 -0
  394. vendor/wp-coding-standards/wpcs/.gitignore +2 -3
  395. vendor/wp-coding-standards/wpcs/CHANGELOG.md +289 -6
  396. vendor/wp-coding-standards/wpcs/README.md +96 -83
  397. vendor/wp-coding-standards/wpcs/WordPress-Core/ruleset.xml +88 -49
  398. vendor/wp-coding-standards/wpcs/WordPress-Docs/ruleset.xml +0 -7
  399. vendor/wp-coding-standards/wpcs/WordPress-Extra/ruleset.xml +46 -9
  400. vendor/wp-coding-standards/wpcs/WordPress-VIP/ruleset.xml +182 -36
  401. vendor/wp-coding-standards/wpcs/WordPress/AbstractArrayAssignmentRestrictionsSniff.php +24 -22
  402. vendor/wp-coding-standards/wpcs/WordPress/AbstractClassRestrictionsSniff.php +18 -21
  403. vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionParameterSniff.php +1 -1
  404. vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionRestrictionsSniff.php +23 -20
  405. vendor/wp-coding-standards/wpcs/WordPress/AbstractVariableRestrictionsSniff.php +28 -25
  406. vendor/wp-coding-standards/wpcs/WordPress/PHPCSAliases.php +16 -14
  407. vendor/wp-coding-standards/wpcs/WordPress/PHPCSHelper.php +1 -1
  408. vendor/wp-coding-standards/wpcs/WordPress/Sniff.php +389 -126
  409. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayAssignmentRestrictionsSniff.php +1 -1
  410. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php +1 -1
  411. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php +22 -20
  412. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php +40 -30
  413. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php +7 -9
  414. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php +17 -12
  415. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php +14 -14
  416. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CSRF/NonceVerificationSniff.php +29 -157
  417. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Classes/ClassInstantiationSniff.php +23 -23
  418. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php +42 -27
  419. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CodeAnalysis/EmptyStatementSniff.php +29 -13
  420. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/DirectDatabaseQuerySniff.php +264 -0
  421. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php +17 -17
  422. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/PreparedSQLSniff.php +209 -0
  423. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedClassesSniff.php +1 -1
  424. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedFunctionsSniff.php +1 -2
  425. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/SlowDBQuerySniff.php +100 -0
  426. vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Files/FileNameSniff.php +31 -3
CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
  ## Change Log
2
 
 
 
 
3
  ### 4.1.1 (2018/07/17 15:45 +00:00)
4
  - [#962](https://github.com/automattic/facebook-instant-articles-wp/pull/962) Updating description for the plugin on website (@Blakomen)
5
  - [#1](https://github.com/automattic/facebook-instant-articles-wp/pull/1) Merging into local (@diegoquinteiro, @everton-rosario, @algmelo)
1
  ## Change Log
2
 
3
+ ### 4.2.0 (2018/11/29 20:47 +00:00)
4
+ - [#997](https://github.com/automattic/facebook-instant-articles-wp/pull/997) Removed fields from deprecated feature to enable comments/likes/share from media content (@everton-rosario)
5
+
6
  ### 4.1.1 (2018/07/17 15:45 +00:00)
7
  - [#962](https://github.com/automattic/facebook-instant-articles-wp/pull/962) Updating description for the plugin on website (@Blakomen)
8
  - [#1](https://github.com/automattic/facebook-instant-articles-wp/pull/1) Merging into local (@diegoquinteiro, @everton-rosario, @algmelo)
class-instant-articles-post.php CHANGED
@@ -681,19 +681,6 @@ class Instant_Articles_Post {
681
 
682
  $this->set_appearance_from_settings();
683
 
684
- // This block sets as default likes and/or comments based on the configuration setup,
685
- // and call $transformer->transform will consider the defaults before building the Elements
686
- //
687
- // Warning: if you are using pthreads or any other multithreaded engine, consider replicating this to all processes.
688
- if ( isset( $settings_publishing[ 'likes_on_media' ] ) ) {
689
- Image::setDefaultLikeEnabled( $settings_publishing[ 'likes_on_media' ] );
690
- Video::setDefaultLikeEnabled( $settings_publishing[ 'likes_on_media' ] );
691
- }
692
- if ( isset( $settings_publishing[ 'comments_on_media' ] ) ) {
693
- Image::setDefaultCommentEnabled( $settings_publishing[ 'comments_on_media' ] );
694
- Video::setDefaultCommentEnabled( $settings_publishing[ 'comments_on_media' ] );
695
- }
696
-
697
  $the_content = $this->get_the_content();
698
  if (!Type::isTextEmpty($the_content)) {
699
  $transformer->transformString( $this->instant_article, $the_content, get_option( 'blog_charset' ) );
681
 
682
  $this->set_appearance_from_settings();
683
 
 
 
 
 
 
 
 
 
 
 
 
 
 
684
  $the_content = $this->get_the_content();
685
  if (!Type::isTextEmpty($the_content)) {
686
  $transformer->transformString( $this->instant_article, $the_content, get_option( 'blog_charset' ) );
facebook-instant-articles.php CHANGED
@@ -4,7 +4,7 @@
4
  * Description: Add support for Instant Articles for Facebook to your WordPress site.
5
  * Author: Automattic, Dekode, Facebook
6
  * Author URI: https://vip.wordpress.com/plugins/instant-articles/
7
- * Version: 4.1.1
8
  * Text Domain: instant-articles
9
  * License: GPLv2
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -33,42 +33,9 @@ if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
33
  $autoloader->add( 'Facebook\\', __DIR__ . '/vendor/facebook/facebook-instant-articles-sdk-php/src' );
34
  $autoloader->add( 'Facebook\\', __DIR__ . '/vendor/facebook/facebook-instant-articles-sdk-extensions-in-php/src' );
35
 
36
- // Configures log to go through console.
37
- \Logger::configure(
38
- array(
39
- 'rootLogger' => array(
40
- 'appenders' => array( 'facebook-instantarticles-transformer' ),
41
- ),
42
- 'appenders' => array(
43
- 'facebook-instantarticles-transformer' => array(
44
- 'class' => 'LoggerAppenderConsole',
45
- 'threshold' => 'INFO',
46
- 'layout' => array(
47
- 'class' => 'LoggerLayoutSimple',
48
- ),
49
- ),
50
- 'facebook-instantarticles-client' => array(
51
- 'class' => 'LoggerAppenderConsole',
52
- 'threshold' => 'INFO',
53
- 'layout' => array(
54
- 'class' => 'LoggerLayoutSimple',
55
- ),
56
- ),
57
- 'instantarticles-wp-plugin' => array(
58
- 'class' => 'LoggerAppenderConsole',
59
- 'threshold' => 'INFO',
60
- 'layout' => array(
61
- 'class' => 'LoggerLayoutSimple',
62
- ),
63
- ),
64
- ),
65
- )
66
- );
67
-
68
-
69
  defined( 'ABSPATH' ) || die( 'Shame on you' );
70
 
71
- define( 'IA_PLUGIN_VERSION', '4.1.1' );
72
  define( 'IA_PLUGIN_PATH_FULL', __FILE__ );
73
  define( 'IA_PLUGIN_PATH', plugin_basename( __FILE__ ) );
74
  define( 'IA_PLUGIN_FILE_BASENAME', pathinfo( __FILE__, PATHINFO_FILENAME ) );
@@ -610,10 +577,7 @@ if ( version_compare( PHP_VERSION, '5.4', '<' ) ) {
610
  }
611
  }
612
  } catch ( Exception $e ) {
613
- Logger::getLogger( 'instantarticles-wp-plugin' )->error(
614
- 'Unable to submit article.',
615
- $e->getTraceAsString()
616
- );
617
  }
618
  }
619
  }
4
  * Description: Add support for Instant Articles for Facebook to your WordPress site.
5
  * Author: Automattic, Dekode, Facebook
6
  * Author URI: https://vip.wordpress.com/plugins/instant-articles/
7
+ * Version: 4.2.0
8
  * Text Domain: instant-articles
9
  * License: GPLv2
10
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
33
  $autoloader->add( 'Facebook\\', __DIR__ . '/vendor/facebook/facebook-instant-articles-sdk-php/src' );
34
  $autoloader->add( 'Facebook\\', __DIR__ . '/vendor/facebook/facebook-instant-articles-sdk-extensions-in-php/src' );
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  defined( 'ABSPATH' ) || die( 'Shame on you' );
37
 
38
+ define( 'IA_PLUGIN_VERSION', '4.2.0' );
39
  define( 'IA_PLUGIN_PATH_FULL', __FILE__ );
40
  define( 'IA_PLUGIN_PATH', plugin_basename( __FILE__ ) );
41
  define( 'IA_PLUGIN_FILE_BASENAME', pathinfo( __FILE__, PATHINFO_FILENAME ) );
577
  }
578
  }
579
  } catch ( Exception $e ) {
580
+ error_log( 'Unable to submit article.'.$e->getTraceAsString() );
 
 
 
581
  }
582
  }
583
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: trrine, olethomas, bjornjohansen, dekode, automattic, facebook
3
  Tags: instant articles, facebook, mobile
4
  Requires at least: 4.3
5
  Tested up to: 4.8
6
- Stable tag: 4.1.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -90,6 +90,9 @@ Usually simply visiting the permalinks settings page in the WordPress dashboard
90
  == Changelog ==
91
  ## Change Log
92
 
 
 
 
93
  ### 4.1.1 (2018/07/17 15:45 +00:00)
94
  - [#962](https://github.com/automattic/facebook-instant-articles-wp/pull/962) Updating description for the plugin on website (@Blakomen)
95
  - [#1](https://github.com/automattic/facebook-instant-articles-wp/pull/1) Merging into local (@diegoquinteiro, @everton-rosario, @algmelo)
3
  Tags: instant articles, facebook, mobile
4
  Requires at least: 4.3
5
  Tested up to: 4.8
6
+ Stable tag: 4.2.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
90
  == Changelog ==
91
  ## Change Log
92
 
93
+ ### 4.2.0 (2018/11/29 20:47 +00:00)
94
+ - [#997](https://github.com/automattic/facebook-instant-articles-wp/pull/997) Removed fields from deprecated feature to enable comments/likes/share from media content (@everton-rosario)
95
+
96
  ### 4.1.1 (2018/07/17 15:45 +00:00)
97
  - [#962](https://github.com/automattic/facebook-instant-articles-wp/pull/962) Updating description for the plugin on website (@Blakomen)
98
  - [#1](https://github.com/automattic/facebook-instant-articles-wp/pull/1) Merging into local (@diegoquinteiro, @everton-rosario, @algmelo)
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInitf357817e391b286c997f3abb9d725c67::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit8b1e91281cd41e15c5fb1bef205d265f::getLoader();
vendor/composer/ClassLoader.php CHANGED
@@ -279,7 +279,7 @@ class ClassLoader
279
  */
280
  public function setApcuPrefix($apcuPrefix)
281
  {
282
- $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
283
  }
284
 
285
  /**
@@ -377,7 +377,7 @@ class ClassLoader
377
  $subPath = $class;
378
  while (false !== $lastPos = strrpos($subPath, '\\')) {
379
  $subPath = substr($subPath, 0, $lastPos);
380
- $search = $subPath.'\\';
381
  if (isset($this->prefixDirsPsr4[$search])) {
382
  $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383
  foreach ($this->prefixDirsPsr4[$search] as $dir) {
279
  */
280
  public function setApcuPrefix($apcuPrefix)
281
  {
282
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
283
  }
284
 
285
  /**
377
  $subPath = $class;
378
  while (false !== $lastPos = strrpos($subPath, '\\')) {
379
  $subPath = substr($subPath, 0, $lastPos);
380
+ $search = $subPath . '\\';
381
  if (isset($this->prefixDirsPsr4[$search])) {
382
  $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383
  foreach ($this->prefixDirsPsr4[$search] as $dir) {
vendor/composer/autoload_classmap.php CHANGED
@@ -6,83 +6,4 @@ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
- 'Logger' => $vendorDir . '/apache/log4php/src/main/php/Logger.php',
10
- 'LoggerAppender' => $vendorDir . '/apache/log4php/src/main/php/LoggerAppender.php',
11
- 'LoggerAppenderConsole' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderConsole.php',
12
- 'LoggerAppenderDailyFile' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderDailyFile.php',
13
- 'LoggerAppenderEcho' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderEcho.php',
14
- 'LoggerAppenderFile' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderFile.php',
15
- 'LoggerAppenderFirePHP' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderFirePHP.php',
16
- 'LoggerAppenderMail' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderMail.php',
17
- 'LoggerAppenderMailEvent' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderMailEvent.php',
18
- 'LoggerAppenderMongoDB' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderMongoDB.php',
19
- 'LoggerAppenderNull' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderNull.php',
20
- 'LoggerAppenderPDO' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderPDO.php',
21
- 'LoggerAppenderPhp' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderPhp.php',
22
- 'LoggerAppenderPool' => $vendorDir . '/apache/log4php/src/main/php/LoggerAppenderPool.php',
23
- 'LoggerAppenderRollingFile' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderRollingFile.php',
24
- 'LoggerAppenderSocket' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderSocket.php',
25
- 'LoggerAppenderSyslog' => $vendorDir . '/apache/log4php/src/main/php/appenders/LoggerAppenderSyslog.php',
26
- 'LoggerAutoloader' => $vendorDir . '/apache/log4php/src/main/php/LoggerAutoloader.php',
27
- 'LoggerConfigurable' => $vendorDir . '/apache/log4php/src/main/php/LoggerConfigurable.php',
28
- 'LoggerConfigurationAdapter' => $vendorDir . '/apache/log4php/src/main/php/configurators/LoggerConfigurationAdapter.php',
29
- 'LoggerConfigurationAdapterINI' => $vendorDir . '/apache/log4php/src/main/php/configurators/LoggerConfigurationAdapterINI.php',
30
- 'LoggerConfigurationAdapterPHP' => $vendorDir . '/apache/log4php/src/main/php/configurators/LoggerConfigurationAdapterPHP.php',
31
- 'LoggerConfigurationAdapterXML' => $vendorDir . '/apache/log4php/src/main/php/configurators/LoggerConfigurationAdapterXML.php',
32
- 'LoggerConfigurator' => $vendorDir . '/apache/log4php/src/main/php/LoggerConfigurator.php',
33
- 'LoggerConfiguratorDefault' => $vendorDir . '/apache/log4php/src/main/php/configurators/LoggerConfiguratorDefault.php',
34
- 'LoggerException' => $vendorDir . '/apache/log4php/src/main/php/LoggerException.php',
35
- 'LoggerFilter' => $vendorDir . '/apache/log4php/src/main/php/LoggerFilter.php',
36
- 'LoggerFilterDenyAll' => $vendorDir . '/apache/log4php/src/main/php/filters/LoggerFilterDenyAll.php',
37
- 'LoggerFilterLevelMatch' => $vendorDir . '/apache/log4php/src/main/php/filters/LoggerFilterLevelMatch.php',
38
- 'LoggerFilterLevelRange' => $vendorDir . '/apache/log4php/src/main/php/filters/LoggerFilterLevelRange.php',
39
- 'LoggerFilterStringMatch' => $vendorDir . '/apache/log4php/src/main/php/filters/LoggerFilterStringMatch.php',
40
- 'LoggerFormattingInfo' => $vendorDir . '/apache/log4php/src/main/php/helpers/LoggerFormattingInfo.php',
41
- 'LoggerHierarchy' => $vendorDir . '/apache/log4php/src/main/php/LoggerHierarchy.php',
42
- 'LoggerLayout' => $vendorDir . '/apache/log4php/src/main/php/LoggerLayout.php',
43
- 'LoggerLayoutHtml' => $vendorDir . '/apache/log4php/src/main/php/layouts/LoggerLayoutHtml.php',
44
- 'LoggerLayoutPattern' => $vendorDir . '/apache/log4php/src/main/php/layouts/LoggerLayoutPattern.php',
45
- 'LoggerLayoutSerialized' => $vendorDir . '/apache/log4php/src/main/php/layouts/LoggerLayoutSerialized.php',
46
- 'LoggerLayoutSimple' => $vendorDir . '/apache/log4php/src/main/php/layouts/LoggerLayoutSimple.php',
47
- 'LoggerLayoutTTCC' => $vendorDir . '/apache/log4php/src/main/php/layouts/LoggerLayoutTTCC.php',
48
- 'LoggerLayoutXml' => $vendorDir . '/apache/log4php/src/main/php/layouts/LoggerLayoutXml.php',
49
- 'LoggerLevel' => $vendorDir . '/apache/log4php/src/main/php/LoggerLevel.php',
50
- 'LoggerLocationInfo' => $vendorDir . '/apache/log4php/src/main/php/LoggerLocationInfo.php',
51
- 'LoggerLoggingEvent' => $vendorDir . '/apache/log4php/src/main/php/LoggerLoggingEvent.php',
52
- 'LoggerMDC' => $vendorDir . '/apache/log4php/src/main/php/LoggerMDC.php',
53
- 'LoggerNDC' => $vendorDir . '/apache/log4php/src/main/php/LoggerNDC.php',
54
- 'LoggerOptionConverter' => $vendorDir . '/apache/log4php/src/main/php/helpers/LoggerOptionConverter.php',
55
- 'LoggerPatternConverter' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverter.php',
56
- 'LoggerPatternConverterClass' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterClass.php',
57
- 'LoggerPatternConverterCookie' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterCookie.php',
58
- 'LoggerPatternConverterDate' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterDate.php',
59
- 'LoggerPatternConverterEnvironment' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterEnvironment.php',
60
- 'LoggerPatternConverterFile' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterFile.php',
61
- 'LoggerPatternConverterLevel' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterLevel.php',
62
- 'LoggerPatternConverterLine' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterLine.php',
63
- 'LoggerPatternConverterLiteral' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterLiteral.php',
64
- 'LoggerPatternConverterLocation' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterLocation.php',
65
- 'LoggerPatternConverterLogger' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterLogger.php',
66
- 'LoggerPatternConverterMDC' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterMDC.php',
67
- 'LoggerPatternConverterMessage' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterMessage.php',
68
- 'LoggerPatternConverterMethod' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterMethod.php',
69
- 'LoggerPatternConverterNDC' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterNDC.php',
70
- 'LoggerPatternConverterNewLine' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterNewLine.php',
71
- 'LoggerPatternConverterProcess' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterProcess.php',
72
- 'LoggerPatternConverterRelative' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterRelative.php',
73
- 'LoggerPatternConverterRequest' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterRequest.php',
74
- 'LoggerPatternConverterServer' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterServer.php',
75
- 'LoggerPatternConverterSession' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterSession.php',
76
- 'LoggerPatternConverterSessionID' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterSessionID.php',
77
- 'LoggerPatternConverterSuperglobal' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterSuperglobal.php',
78
- 'LoggerPatternConverterThrowable' => $vendorDir . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterThrowable.php',
79
- 'LoggerPatternParser' => $vendorDir . '/apache/log4php/src/main/php/helpers/LoggerPatternParser.php',
80
- 'LoggerReflectionUtils' => $vendorDir . '/apache/log4php/src/main/php/LoggerReflectionUtils.php',
81
- 'LoggerRenderer' => $vendorDir . '/apache/log4php/src/main/php/renderers/LoggerRenderer.php',
82
- 'LoggerRendererDefault' => $vendorDir . '/apache/log4php/src/main/php/renderers/LoggerRendererDefault.php',
83
- 'LoggerRendererException' => $vendorDir . '/apache/log4php/src/main/php/renderers/LoggerRendererException.php',
84
- 'LoggerRendererMap' => $vendorDir . '/apache/log4php/src/main/php/renderers/LoggerRendererMap.php',
85
- 'LoggerRoot' => $vendorDir . '/apache/log4php/src/main/php/LoggerRoot.php',
86
- 'LoggerThrowableInformation' => $vendorDir . '/apache/log4php/src/main/php/LoggerThrowableInformation.php',
87
- 'LoggerUtils' => $vendorDir . '/apache/log4php/src/main/php/helpers/LoggerUtils.php',
88
  );
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  );
vendor/composer/autoload_psr4.php CHANGED
@@ -7,6 +7,6 @@ $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
  'Symfony\\Component\\CssSelector\\' => array($vendorDir . '/symfony/css-selector'),
10
- 'Facebook\\InstantArticles\\' => array($vendorDir . '/facebook/facebook-instant-articles-sdk-extensions-in-php/src/Facebook/InstantArticles', $vendorDir . '/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles'),
11
  'Facebook\\' => array($vendorDir . '/facebook/graph-sdk/src/Facebook'),
12
  );
7
 
8
  return array(
9
  'Symfony\\Component\\CssSelector\\' => array($vendorDir . '/symfony/css-selector'),
10
+ 'Facebook\\InstantArticles\\' => array($vendorDir . '/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles', $vendorDir . '/facebook/facebook-instant-articles-sdk-extensions-in-php/src/Facebook/InstantArticles'),
11
  'Facebook\\' => array($vendorDir . '/facebook/graph-sdk/src/Facebook'),
12
  );
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInitf357817e391b286c997f3abb9d725c67
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInitf357817e391b286c997f3abb9d725c67
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInitf357817e391b286c997f3abb9d725c67', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInitf357817e391b286c997f3abb9d725c67', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
- call_user_func(\Composer\Autoload\ComposerStaticInitf357817e391b286c997f3abb9d725c67::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInitf357817e391b286c997f3abb9d725c67
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInitf357817e391b286c997f3abb9d725c67::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequiref357817e391b286c997f3abb9d725c67($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
- function composerRequiref357817e391b286c997f3abb9d725c67($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit8b1e91281cd41e15c5fb1bef205d265f
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit8b1e91281cd41e15c5fb1bef205d265f', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit8b1e91281cd41e15c5fb1bef205d265f', 'loadClassLoader'));
25
 
26
  $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
  if ($useStaticLoader) {
28
  require_once __DIR__ . '/autoload_static.php';
29
 
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit8b1e91281cd41e15c5fb1bef205d265f::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInit8b1e91281cd41e15c5fb1bef205d265f::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequire8b1e91281cd41e15c5fb1bef205d265f($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
+ function composerRequire8b1e91281cd41e15c5fb1bef205d265f($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
vendor/composer/autoload_static.php CHANGED
@@ -4,7 +4,7 @@
4
 
5
  namespace Composer\Autoload;
6
 
7
- class ComposerStaticInitf357817e391b286c997f3abb9d725c67
8
  {
9
  public static $files = array (
10
  'c65d09b6820da036953a371c8c73a9b1' => __DIR__ . '/..' . '/facebook/graph-sdk/src/Facebook/polyfills.php',
@@ -29,8 +29,8 @@ class ComposerStaticInitf357817e391b286c997f3abb9d725c67
29
  ),
30
  'Facebook\\InstantArticles\\' =>
31
  array (
32
- 0 => __DIR__ . '/..' . '/facebook/facebook-instant-articles-sdk-extensions-in-php/src/Facebook/InstantArticles',
33
- 1 => __DIR__ . '/..' . '/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles',
34
  ),
35
  'Facebook\\' =>
36
  array (
@@ -38,94 +38,11 @@ class ComposerStaticInitf357817e391b286c997f3abb9d725c67
38
  ),
39
  );
40
 
41
- public static $classMap = array (
42
- 'Logger' => __DIR__ . '/..' . '/apache/log4php/src/main/php/Logger.php',
43
- 'LoggerAppender' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerAppender.php',
44
- 'LoggerAppenderConsole' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderConsole.php',
45
- 'LoggerAppenderDailyFile' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderDailyFile.php',
46
- 'LoggerAppenderEcho' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderEcho.php',
47
- 'LoggerAppenderFile' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderFile.php',
48
- 'LoggerAppenderFirePHP' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderFirePHP.php',
49
- 'LoggerAppenderMail' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderMail.php',
50
- 'LoggerAppenderMailEvent' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderMailEvent.php',
51
- 'LoggerAppenderMongoDB' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderMongoDB.php',
52
- 'LoggerAppenderNull' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderNull.php',
53
- 'LoggerAppenderPDO' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderPDO.php',
54
- 'LoggerAppenderPhp' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderPhp.php',
55
- 'LoggerAppenderPool' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerAppenderPool.php',
56
- 'LoggerAppenderRollingFile' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderRollingFile.php',
57
- 'LoggerAppenderSocket' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderSocket.php',
58
- 'LoggerAppenderSyslog' => __DIR__ . '/..' . '/apache/log4php/src/main/php/appenders/LoggerAppenderSyslog.php',
59
- 'LoggerAutoloader' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerAutoloader.php',
60
- 'LoggerConfigurable' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerConfigurable.php',
61
- 'LoggerConfigurationAdapter' => __DIR__ . '/..' . '/apache/log4php/src/main/php/configurators/LoggerConfigurationAdapter.php',
62
- 'LoggerConfigurationAdapterINI' => __DIR__ . '/..' . '/apache/log4php/src/main/php/configurators/LoggerConfigurationAdapterINI.php',
63
- 'LoggerConfigurationAdapterPHP' => __DIR__ . '/..' . '/apache/log4php/src/main/php/configurators/LoggerConfigurationAdapterPHP.php',
64
- 'LoggerConfigurationAdapterXML' => __DIR__ . '/..' . '/apache/log4php/src/main/php/configurators/LoggerConfigurationAdapterXML.php',
65
- 'LoggerConfigurator' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerConfigurator.php',
66
- 'LoggerConfiguratorDefault' => __DIR__ . '/..' . '/apache/log4php/src/main/php/configurators/LoggerConfiguratorDefault.php',
67
- 'LoggerException' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerException.php',
68
- 'LoggerFilter' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerFilter.php',
69
- 'LoggerFilterDenyAll' => __DIR__ . '/..' . '/apache/log4php/src/main/php/filters/LoggerFilterDenyAll.php',
70
- 'LoggerFilterLevelMatch' => __DIR__ . '/..' . '/apache/log4php/src/main/php/filters/LoggerFilterLevelMatch.php',
71
- 'LoggerFilterLevelRange' => __DIR__ . '/..' . '/apache/log4php/src/main/php/filters/LoggerFilterLevelRange.php',
72
- 'LoggerFilterStringMatch' => __DIR__ . '/..' . '/apache/log4php/src/main/php/filters/LoggerFilterStringMatch.php',
73
- 'LoggerFormattingInfo' => __DIR__ . '/..' . '/apache/log4php/src/main/php/helpers/LoggerFormattingInfo.php',
74
- 'LoggerHierarchy' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerHierarchy.php',
75
- 'LoggerLayout' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerLayout.php',
76
- 'LoggerLayoutHtml' => __DIR__ . '/..' . '/apache/log4php/src/main/php/layouts/LoggerLayoutHtml.php',
77
- 'LoggerLayoutPattern' => __DIR__ . '/..' . '/apache/log4php/src/main/php/layouts/LoggerLayoutPattern.php',
78
- 'LoggerLayoutSerialized' => __DIR__ . '/..' . '/apache/log4php/src/main/php/layouts/LoggerLayoutSerialized.php',
79
- 'LoggerLayoutSimple' => __DIR__ . '/..' . '/apache/log4php/src/main/php/layouts/LoggerLayoutSimple.php',
80
- 'LoggerLayoutTTCC' => __DIR__ . '/..' . '/apache/log4php/src/main/php/layouts/LoggerLayoutTTCC.php',
81
- 'LoggerLayoutXml' => __DIR__ . '/..' . '/apache/log4php/src/main/php/layouts/LoggerLayoutXml.php',
82
- 'LoggerLevel' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerLevel.php',
83
- 'LoggerLocationInfo' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerLocationInfo.php',
84
- 'LoggerLoggingEvent' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerLoggingEvent.php',
85
- 'LoggerMDC' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerMDC.php',
86
- 'LoggerNDC' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerNDC.php',
87
- 'LoggerOptionConverter' => __DIR__ . '/..' . '/apache/log4php/src/main/php/helpers/LoggerOptionConverter.php',
88
- 'LoggerPatternConverter' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverter.php',
89
- 'LoggerPatternConverterClass' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterClass.php',
90
- 'LoggerPatternConverterCookie' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterCookie.php',
91
- 'LoggerPatternConverterDate' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterDate.php',
92
- 'LoggerPatternConverterEnvironment' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterEnvironment.php',
93
- 'LoggerPatternConverterFile' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterFile.php',
94
- 'LoggerPatternConverterLevel' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterLevel.php',
95
- 'LoggerPatternConverterLine' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterLine.php',
96
- 'LoggerPatternConverterLiteral' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterLiteral.php',
97
- 'LoggerPatternConverterLocation' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterLocation.php',
98
- 'LoggerPatternConverterLogger' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterLogger.php',
99
- 'LoggerPatternConverterMDC' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterMDC.php',
100
- 'LoggerPatternConverterMessage' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterMessage.php',
101
- 'LoggerPatternConverterMethod' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterMethod.php',
102
- 'LoggerPatternConverterNDC' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterNDC.php',
103
- 'LoggerPatternConverterNewLine' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterNewLine.php',
104
- 'LoggerPatternConverterProcess' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterProcess.php',
105
- 'LoggerPatternConverterRelative' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterRelative.php',
106
- 'LoggerPatternConverterRequest' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterRequest.php',
107
- 'LoggerPatternConverterServer' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterServer.php',
108
- 'LoggerPatternConverterSession' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterSession.php',
109
- 'LoggerPatternConverterSessionID' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterSessionID.php',
110
- 'LoggerPatternConverterSuperglobal' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterSuperglobal.php',
111
- 'LoggerPatternConverterThrowable' => __DIR__ . '/..' . '/apache/log4php/src/main/php/pattern/LoggerPatternConverterThrowable.php',
112
- 'LoggerPatternParser' => __DIR__ . '/..' . '/apache/log4php/src/main/php/helpers/LoggerPatternParser.php',
113
- 'LoggerReflectionUtils' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerReflectionUtils.php',
114
- 'LoggerRenderer' => __DIR__ . '/..' . '/apache/log4php/src/main/php/renderers/LoggerRenderer.php',
115
- 'LoggerRendererDefault' => __DIR__ . '/..' . '/apache/log4php/src/main/php/renderers/LoggerRendererDefault.php',
116
- 'LoggerRendererException' => __DIR__ . '/..' . '/apache/log4php/src/main/php/renderers/LoggerRendererException.php',
117
- 'LoggerRendererMap' => __DIR__ . '/..' . '/apache/log4php/src/main/php/renderers/LoggerRendererMap.php',
118
- 'LoggerRoot' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerRoot.php',
119
- 'LoggerThrowableInformation' => __DIR__ . '/..' . '/apache/log4php/src/main/php/LoggerThrowableInformation.php',
120
- 'LoggerUtils' => __DIR__ . '/..' . '/apache/log4php/src/main/php/helpers/LoggerUtils.php',
121
- );
122
-
123
  public static function getInitializer(ClassLoader $loader)
124
  {
125
  return \Closure::bind(function () use ($loader) {
126
- $loader->prefixLengthsPsr4 = ComposerStaticInitf357817e391b286c997f3abb9d725c67::$prefixLengthsPsr4;
127
- $loader->prefixDirsPsr4 = ComposerStaticInitf357817e391b286c997f3abb9d725c67::$prefixDirsPsr4;
128
- $loader->classMap = ComposerStaticInitf357817e391b286c997f3abb9d725c67::$classMap;
129
 
130
  }, null, ClassLoader::class);
131
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit8b1e91281cd41e15c5fb1bef205d265f
8
  {
9
  public static $files = array (
10
  'c65d09b6820da036953a371c8c73a9b1' => __DIR__ . '/..' . '/facebook/graph-sdk/src/Facebook/polyfills.php',
29
  ),
30
  'Facebook\\InstantArticles\\' =>
31
  array (
32
+ 0 => __DIR__ . '/..' . '/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles',
33
+ 1 => __DIR__ . '/..' . '/facebook/facebook-instant-articles-sdk-extensions-in-php/src/Facebook/InstantArticles',
34
  ),
35
  'Facebook\\' =>
36
  array (
38
  ),
39
  );
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  public static function getInitializer(ClassLoader $loader)
42
  {
43
  return \Closure::bind(function () use ($loader) {
44
+ $loader->prefixLengthsPsr4 = ComposerStaticInit8b1e91281cd41e15c5fb1bef205d265f::$prefixLengthsPsr4;
45
+ $loader->prefixDirsPsr4 = ComposerStaticInit8b1e91281cd41e15c5fb1bef205d265f::$prefixDirsPsr4;
 
46
 
47
  }, null, ClassLoader::class);
48
  }
vendor/composer/installed.json CHANGED
@@ -1,36 +1,4 @@
1
  [
2
- {
3
- "name": "apache/log4php",
4
- "version": "2.3.0",
5
- "version_normalized": "2.3.0.0",
6
- "source": {
7
- "type": "git",
8
- "url": "https://git-wip-us.apache.org/repos/asf/logging-log4php.git",
9
- "reference": "cac428b6f67d2035af39784da1d1a299ef42fcf2"
10
- },
11
- "require": {
12
- "php": ">=5.2.7"
13
- },
14
- "time": "2012-10-26T09:13:25+00:00",
15
- "type": "library",
16
- "installation-source": "source",
17
- "autoload": {
18
- "classmap": [
19
- "src/main/php/"
20
- ]
21
- },
22
- "notification-url": "https://packagist.org/downloads/",
23
- "license": [
24
- "Apache-2.0"
25
- ],
26
- "description": "A versatile logging framework for PHP",
27
- "homepage": "http://logging.apache.org/log4php/",
28
- "keywords": [
29
- "log",
30
- "logging",
31
- "php"
32
- ]
33
- },
34
  {
35
  "name": "facebook/facebook-instant-articles-sdk-extensions-in-php",
36
  "version": "v0.1.1",
@@ -85,23 +53,23 @@
85
  },
86
  {
87
  "name": "facebook/facebook-instant-articles-sdk-php",
88
- "version": "v1.9.2",
89
- "version_normalized": "1.9.2.0",
90
  "source": {
91
  "type": "git",
92
  "url": "https://github.com/facebook/facebook-instant-articles-sdk-php.git",
93
- "reference": "d2ccefa4da393ea33b9c095a7ebce7b352e31480"
94
  },
95
  "dist": {
96
  "type": "zip",
97
- "url": "https://api.github.com/repos/facebook/facebook-instant-articles-sdk-php/zipball/d2ccefa4da393ea33b9c095a7ebce7b352e31480",
98
- "reference": "d2ccefa4da393ea33b9c095a7ebce7b352e31480",
99
  "shasum": ""
100
  },
101
  "require": {
102
  "facebook/graph-sdk": "~5.0",
103
- "php": "^5.4 || ^7.0",
104
- "symfony/css-selector": "^2.8 || ^3.0"
105
  },
106
  "require-dev": {
107
  "fzaninotto/faker": "^1.6.0",
@@ -110,7 +78,7 @@
110
  "squizlabs/php_codesniffer": "^2.6.0",
111
  "symfony/yaml": "2.1.*"
112
  },
113
- "time": "2018-03-16T19:42:33+00:00",
114
  "type": "library",
115
  "installation-source": "dist",
116
  "autoload": {
@@ -139,17 +107,17 @@
139
  },
140
  {
141
  "name": "facebook/graph-sdk",
142
- "version": "5.6.2",
143
- "version_normalized": "5.6.2.0",
144
  "source": {
145
  "type": "git",
146
  "url": "https://github.com/facebook/php-graph-sdk.git",
147
- "reference": "030f8c5b9b1a6c09e71719fd638b66ea4daa2f10"
148
  },
149
  "dist": {
150
  "type": "zip",
151
- "url": "https://api.github.com/repos/facebook/php-graph-sdk/zipball/030f8c5b9b1a6c09e71719fd638b66ea4daa2f10",
152
- "reference": "030f8c5b9b1a6c09e71719fd638b66ea4daa2f10",
153
  "shasum": ""
154
  },
155
  "require": {
@@ -164,7 +132,7 @@
164
  "guzzlehttp/guzzle": "Allows for implementation of the Guzzle HTTP client",
165
  "paragonie/random_compat": "Provides a better CSPRNG option in PHP 5"
166
  },
167
- "time": "2018-02-14T23:24:51+00:00",
168
  "type": "library",
169
  "extra": {
170
  "branch-alias": {
@@ -199,17 +167,17 @@
199
  },
200
  {
201
  "name": "squizlabs/php_codesniffer",
202
- "version": "3.2.3",
203
- "version_normalized": "3.2.3.0",
204
  "source": {
205
  "type": "git",
206
  "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
207
- "reference": "4842476c434e375f9d3182ff7b89059583aa8b27"
208
  },
209
  "dist": {
210
  "type": "zip",
211
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4842476c434e375f9d3182ff7b89059583aa8b27",
212
- "reference": "4842476c434e375f9d3182ff7b89059583aa8b27",
213
  "shasum": ""
214
  },
215
  "require": {
@@ -221,7 +189,7 @@
221
  "require-dev": {
222
  "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
223
  },
224
- "time": "2018-02-20T21:35:23+00:00",
225
  "bin": [
226
  "bin/phpcs",
227
  "bin/phpcbf"
@@ -252,23 +220,23 @@
252
  },
253
  {
254
  "name": "symfony/css-selector",
255
- "version": "v2.8.36",
256
- "version_normalized": "2.8.36.0",
257
  "source": {
258
  "type": "git",
259
  "url": "https://github.com/symfony/css-selector.git",
260
- "reference": "99a4b2c2f1757d62d081b5f9f14128f23504897d"
261
  },
262
  "dist": {
263
  "type": "zip",
264
- "url": "https://api.github.com/repos/symfony/css-selector/zipball/99a4b2c2f1757d62d081b5f9f14128f23504897d",
265
- "reference": "99a4b2c2f1757d62d081b5f9f14128f23504897d",
266
  "shasum": ""
267
  },
268
  "require": {
269
  "php": ">=5.3.9"
270
  },
271
- "time": "2018-02-03T14:55:47+00:00",
272
  "type": "library",
273
  "extra": {
274
  "branch-alias": {
@@ -307,27 +275,30 @@
307
  },
308
  {
309
  "name": "wp-coding-standards/wpcs",
310
- "version": "0.14.1",
311
- "version_normalized": "0.14.1.0",
312
  "source": {
313
  "type": "git",
314
  "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
315
- "reference": "cf6b310caad735816caef7573295f8a534374706"
316
  },
317
  "dist": {
318
  "type": "zip",
319
- "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/cf6b310caad735816caef7573295f8a534374706",
320
- "reference": "cf6b310caad735816caef7573295f8a534374706",
321
  "shasum": ""
322
  },
323
  "require": {
324
  "php": ">=5.3",
325
  "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2"
326
  },
 
 
 
327
  "suggest": {
328
- "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3"
329
  },
330
- "time": "2018-02-16T01:57:48+00:00",
331
  "type": "phpcodesniffer-standard",
332
  "installation-source": "dist",
333
  "notification-url": "https://packagist.org/downloads/",
1
  [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  {
3
  "name": "facebook/facebook-instant-articles-sdk-extensions-in-php",
4
  "version": "v0.1.1",
53
  },
54
  {
55
  "name": "facebook/facebook-instant-articles-sdk-php",
56
+ "version": "v1.10.0",
57
+ "version_normalized": "1.10.0.0",
58
  "source": {
59
  "type": "git",
60
  "url": "https://github.com/facebook/facebook-instant-articles-sdk-php.git",
61
+ "reference": "ddd592500bd377af1965602fc008e6f593e63532"
62
  },
63
  "dist": {
64
  "type": "zip",
65
+ "url": "https://api.github.com/repos/facebook/facebook-instant-articles-sdk-php/zipball/ddd592500bd377af1965602fc008e6f593e63532",
66
+ "reference": "ddd592500bd377af1965602fc008e6f593e63532",
67
  "shasum": ""
68
  },
69
  "require": {
70
  "facebook/graph-sdk": "~5.0",
71
+ "php": "^5.4 || ^5.6 || ^7",
72
+ "symfony/css-selector": "^2.8 || ^3.1 || ^4.1"
73
  },
74
  "require-dev": {
75
  "fzaninotto/faker": "^1.6.0",
78
  "squizlabs/php_codesniffer": "^2.6.0",
79
  "symfony/yaml": "2.1.*"
80
  },
81
+ "time": "2018-11-29T14:50:41+00:00",
82
  "type": "library",
83
  "installation-source": "dist",
84
  "autoload": {
107
  },
108
  {
109
  "name": "facebook/graph-sdk",
110
+ "version": "5.6.3",
111
+ "version_normalized": "5.6.3.0",
112
  "source": {
113
  "type": "git",
114
  "url": "https://github.com/facebook/php-graph-sdk.git",
115
+ "reference": "90e92bd1816fe718e55184ab85910dfcf488432c"
116
  },
117
  "dist": {
118
  "type": "zip",
119
+ "url": "https://api.github.com/repos/facebook/php-graph-sdk/zipball/90e92bd1816fe718e55184ab85910dfcf488432c",
120
+ "reference": "90e92bd1816fe718e55184ab85910dfcf488432c",
121
  "shasum": ""
122
  },
123
  "require": {
132
  "guzzlehttp/guzzle": "Allows for implementation of the Guzzle HTTP client",
133
  "paragonie/random_compat": "Provides a better CSPRNG option in PHP 5"
134
  },
135
+ "time": "2018-07-03T02:25:00+00:00",
136
  "type": "library",
137
  "extra": {
138
  "branch-alias": {
167
  },
168
  {
169
  "name": "squizlabs/php_codesniffer",
170
+ "version": "3.3.2",
171
+ "version_normalized": "3.3.2.0",
172
  "source": {
173
  "type": "git",
174
  "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
175
+ "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e"
176
  },
177
  "dist": {
178
  "type": "zip",
179
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6ad28354c04b364c3c71a34e4a18b629cc3b231e",
180
+ "reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e",
181
  "shasum": ""
182
  },
183
  "require": {
189
  "require-dev": {
190
  "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0"
191
  },
192
+ "time": "2018-09-23T23:08:17+00:00",
193
  "bin": [
194
  "bin/phpcs",
195
  "bin/phpcbf"
220
  },
221
  {
222
  "name": "symfony/css-selector",
223
+ "version": "v2.8.48",
224
+ "version_normalized": "2.8.48.0",
225
  "source": {
226
  "type": "git",
227
  "url": "https://github.com/symfony/css-selector.git",
228
+ "reference": "7b1692e418d7ccac24c373528453bc90e42797de"
229
  },
230
  "dist": {
231
  "type": "zip",
232
+ "url": "https://api.github.com/repos/symfony/css-selector/zipball/7b1692e418d7ccac24c373528453bc90e42797de",
233
+ "reference": "7b1692e418d7ccac24c373528453bc90e42797de",
234
  "shasum": ""
235
  },
236
  "require": {
237
  "php": ">=5.3.9"
238
  },
239
+ "time": "2018-11-11T11:18:13+00:00",
240
  "type": "library",
241
  "extra": {
242
  "branch-alias": {
275
  },
276
  {
277
  "name": "wp-coding-standards/wpcs",
278
+ "version": "1.2.0",
279
+ "version_normalized": "1.2.0.0",
280
  "source": {
281
  "type": "git",
282
  "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
283
+ "reference": "7aa217ab38156c5cb4eae0f04ae376027c407a9b"
284
  },
285
  "dist": {
286
  "type": "zip",
287
+ "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/7aa217ab38156c5cb4eae0f04ae376027c407a9b",
288
+ "reference": "7aa217ab38156c5cb4eae0f04ae376027c407a9b",
289
  "shasum": ""
290
  },
291
  "require": {
292
  "php": ">=5.3",
293
  "squizlabs/php_codesniffer": "^2.9.0 || ^3.0.2"
294
  },
295
+ "require-dev": {
296
+ "phpcompatibility/php-compatibility": "^9.0"
297
+ },
298
  "suggest": {
299
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.4.3 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically."
300
  },
301
+ "time": "2018-11-12T10:13:12+00:00",
302
  "type": "phpcodesniffer-standard",
303
  "installation-source": "dist",
304
  "notification-url": "https://packagist.org/downloads/",
vendor/facebook/facebook-instant-articles-sdk-php/composer.json CHANGED
@@ -10,8 +10,8 @@
10
  "homepage": "https://github.com/facebook/facebook-instant-articles-sdk-php/contributors"
11
  }],
12
  "require": {
13
- "php": "^5.4 || ^7.0",
14
- "symfony/css-selector": "^2.8 || ^3.0",
15
  "facebook/graph-sdk": "~5.0"
16
  },
17
  "require-dev": {
10
  "homepage": "https://github.com/facebook/facebook-instant-articles-sdk-php/contributors"
11
  }],
12
  "require": {
13
+ "php": "^5.4 || ^5.6 || ^7",
14
+ "symfony/css-selector": "^2.8 || ^3.1 || ^4.1",
15
  "facebook/graph-sdk": "~5.0"
16
  },
17
  "require-dev": {
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/Image.php CHANGED
@@ -40,16 +40,6 @@ class Image extends Audible
40
  const FULLSCREEN = 'fullscreen';
41
  const NON_INTERACTIVE = 'non-interactive';
42
 
43
- /**
44
- * @var boolean marks if any created image will have likes enabled by default
45
- */
46
- public static $defaultLikeEnabled = false;
47
-
48
- /**
49
- * @var boolean marks if any created image will have comments enabled by default
50
- */
51
- public static $defaultCommentEnabled = false;
52
-
53
  /**
54
  * @var Caption The caption for Image
55
  */
@@ -61,16 +51,6 @@ class Image extends Audible
61
  */
62
  private $url;
63
 
64
- /**
65
- * @var bool Tells if like is enabled. Default: false
66
- */
67
- private $isLikeEnabled;
68
-
69
- /**
70
- * @var bool Tells if comments are enabled. Default: false
71
- */
72
- private $isCommentsEnabled;
73
-
74
  /**
75
  * @var string The picture size for the video.
76
  * @see Image::ASPECT_FIT
@@ -96,8 +76,6 @@ class Image extends Audible
96
  */
97
  private function __construct()
98
  {
99
- $this->isLikeEnabled = self::$defaultLikeEnabled;
100
- $this->isCommentsEnabled = self::$defaultCommentEnabled;
101
  }
102
 
103
  /**
@@ -169,41 +147,37 @@ class Image extends Audible
169
 
170
  /**
171
  * Makes like enabled for this image.
 
172
  */
173
  public function enableLike()
174
  {
175
- $this->isLikeEnabled = true;
176
-
177
  return $this;
178
  }
179
 
180
  /**
181
  * Makes like disabled for this image.
 
182
  */
183
  public function disableLike()
184
  {
185
- $this->isLikeEnabled = false;
186
-
187
  return $this;
188
  }
189
 
190
  /**
191
  * Makes comments enabled for this image.
 
192
  */
193
  public function enableComments()
194
  {
195
- $this->isCommentsEnabled = true;
196
-
197
  return $this;
198
  }
199
 
200
  /**
201
  * Makes comments disabled for this image.
 
202
  */
203
  public function disableComments()
204
  {
205
- $this->isCommentsEnabled = false;
206
-
207
  return $this;
208
  }
209
 
@@ -257,18 +231,20 @@ class Image extends Audible
257
 
258
  /**
259
  * @return boolean tells if the like button is enabled
 
260
  */
261
  public function isLikeEnabled()
262
  {
263
- return $this->isLikeEnabled;
264
  }
265
 
266
  /**
267
  * @return boolean tells if the comments widget is enabled
 
268
  */
269
  public function isCommentsEnabled()
270
  {
271
- return $this->isCommentsEnabled;
272
  }
273
 
274
  /**
@@ -314,17 +290,6 @@ class Image extends Audible
314
 
315
  $element = $document->createElement('figure');
316
 
317
- // Like/comments markup optional
318
- if ($this->isLikeEnabled || $this->isCommentsEnabled) {
319
- if ($this->isLikeEnabled && $this->isCommentsEnabled) {
320
- $element->setAttribute('data-feedback', 'fb:likes,fb:comments');
321
- } elseif ($this->isLikeEnabled) {
322
- $element->setAttribute('data-feedback', 'fb:likes');
323
- } else {
324
- $element->setAttribute('data-feedback', 'fb:comments');
325
- }
326
- }
327
-
328
  // Presentation
329
  if ($this->presentation) {
330
  $element->setAttribute('data-mode', $this->presentation);
@@ -393,10 +358,10 @@ class Image extends Audible
393
  * WARNING this is not Thread-safe, so if you are using pthreads or any other multithreaded engine,
394
  * this might not work as expected. (you will need to set this in all working threads manually)
395
  * @param boolean $enabled inform true to enable likes on images per default or false to disable like on images.
 
396
  */
397
  public static function setDefaultLikeEnabled($enabled)
398
  {
399
- self::$defaultLikeEnabled = $enabled;
400
  }
401
 
402
  /**
@@ -405,9 +370,9 @@ class Image extends Audible
405
  * WARNING this is not Thread-safe, so if you are using pthreads or any other multithreaded engine,
406
  * this might not work as expected. (you will need to set this in all working threads manually)
407
  * @param boolean $enabled inform true to enable comments on images per default or false to disable commenting on images.
 
408
  */
409
  public static function setDefaultCommentEnabled($enabled)
410
  {
411
- self::$defaultCommentEnabled = $enabled;
412
  }
413
  }
40
  const FULLSCREEN = 'fullscreen';
41
  const NON_INTERACTIVE = 'non-interactive';
42
 
 
 
 
 
 
 
 
 
 
 
43
  /**
44
  * @var Caption The caption for Image
45
  */
51
  */
52
  private $url;
53
 
 
 
 
 
 
 
 
 
 
 
54
  /**
55
  * @var string The picture size for the video.
56
  * @see Image::ASPECT_FIT
76
  */
77
  private function __construct()
78
  {
 
 
79
  }
80
 
81
  /**
147
 
148
  /**
149
  * Makes like enabled for this image.
150
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
151
  */
152
  public function enableLike()
153
  {
 
 
154
  return $this;
155
  }
156
 
157
  /**
158
  * Makes like disabled for this image.
159
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
160
  */
161
  public function disableLike()
162
  {
 
 
163
  return $this;
164
  }
165
 
166
  /**
167
  * Makes comments enabled for this image.
168
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
169
  */
170
  public function enableComments()
171
  {
 
 
172
  return $this;
173
  }
174
 
175
  /**
176
  * Makes comments disabled for this image.
177
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
178
  */
179
  public function disableComments()
180
  {
 
 
181
  return $this;
182
  }
183
 
231
 
232
  /**
233
  * @return boolean tells if the like button is enabled
234
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
235
  */
236
  public function isLikeEnabled()
237
  {
238
+ return false;
239
  }
240
 
241
  /**
242
  * @return boolean tells if the comments widget is enabled
243
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
244
  */
245
  public function isCommentsEnabled()
246
  {
247
+ return false;
248
  }
249
 
250
  /**
290
 
291
  $element = $document->createElement('figure');
292
 
 
 
 
 
 
 
 
 
 
 
 
293
  // Presentation
294
  if ($this->presentation) {
295
  $element->setAttribute('data-mode', $this->presentation);
358
  * WARNING this is not Thread-safe, so if you are using pthreads or any other multithreaded engine,
359
  * this might not work as expected. (you will need to set this in all working threads manually)
360
  * @param boolean $enabled inform true to enable likes on images per default or false to disable like on images.
361
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
362
  */
363
  public static function setDefaultLikeEnabled($enabled)
364
  {
 
365
  }
366
 
367
  /**
370
  * WARNING this is not Thread-safe, so if you are using pthreads or any other multithreaded engine,
371
  * this might not work as expected. (you will need to set this in all working threads manually)
372
  * @param boolean $enabled inform true to enable comments on images per default or false to disable commenting on images.
373
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
374
  */
375
  public static function setDefaultCommentEnabled($enabled)
376
  {
 
377
  }
378
  }
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/InstantArticle.php CHANGED
@@ -34,7 +34,7 @@ use Facebook\InstantArticles\Validators\Type;
34
 
35
  class InstantArticle extends Element implements ChildrenContainer, InstantArticleInterface
36
  {
37
- const CURRENT_VERSION = '1.9.2';
38
 
39
  /**
40
  * The meta properties that are used on <head>
34
 
35
  class InstantArticle extends Element implements ChildrenContainer, InstantArticleInterface
36
  {
37
+ const CURRENT_VERSION = '1.10.0';
38
 
39
  /**
40
  * The meta properties that are used on <head>
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Elements/Video.php CHANGED
@@ -44,16 +44,6 @@ class Video extends Element implements ChildrenContainer
44
  const LOOP = 'loop';
45
  const DATA_FADE = 'data-fade';
46
 
47
- /**
48
- * @var boolean marks if any created image will have likes enabled by default
49
- */
50
- private static $defaultLikeEnabled = false;
51
-
52
- /**
53
- * @var boolean marks if any created image will have comments enabled by default
54
- */
55
- private static $defaultCommentEnabled = false;
56
-
57
  /**
58
  * @var Caption The caption for Video
59
  */
@@ -70,16 +60,6 @@ class Video extends Element implements ChildrenContainer
70
  */
71
  private $contentType;
72
 
73
- /**
74
- * @var boolean Tells if like is enabled. Default: false
75
- */
76
- private $isLikeEnabled;
77
-
78
- /**
79
- * @var boolean Tells if comments are enabled. Default: false
80
- */
81
- private $isCommentsEnabled;
82
-
83
  /**
84
  * @var boolean Makes the video the cover on news feed.
85
  *
@@ -124,8 +104,6 @@ class Video extends Element implements ChildrenContainer
124
 
125
  private function __construct()
126
  {
127
- $this->isLikeEnabled = self::$defaultLikeEnabled;
128
- $this->isCommentsEnabled = self::$defaultCommentEnabled;
129
  }
130
 
131
  /**
@@ -201,11 +179,10 @@ class Video extends Element implements ChildrenContainer
201
  * Makes like enabled for this video.
202
  *
203
  * @return $this
 
204
  */
205
  public function enableLike()
206
  {
207
- $this->isLikeEnabled = true;
208
-
209
  return $this;
210
  }
211
 
@@ -213,11 +190,10 @@ class Video extends Element implements ChildrenContainer
213
  * Makes like disabled for this video.
214
  *
215
  * @return $this
 
216
  */
217
  public function disableLike()
218
  {
219
- $this->isLikeEnabled = false;
220
-
221
  return $this;
222
  }
223
 
@@ -225,11 +201,10 @@ class Video extends Element implements ChildrenContainer
225
  * Makes comments enabled for this video.
226
  *
227
  * @return $this
 
228
  */
229
  public function enableComments()
230
  {
231
- $this->isCommentsEnabled = true;
232
-
233
  return $this;
234
  }
235
 
@@ -237,11 +212,10 @@ class Video extends Element implements ChildrenContainer
237
  * Makes comments disabled for this video.
238
  *
239
  * @return $this
 
240
  */
241
  public function disableComments()
242
  {
243
- $this->isCommentsEnabled = false;
244
-
245
  return $this;
246
  }
247
 
@@ -394,10 +368,11 @@ class Video extends Element implements ChildrenContainer
394
 
395
  /**
396
  * @return boolean tells if the like button is enabled
 
397
  */
398
  public function isLikeEnabled()
399
  {
400
- return $this->isLikeEnabled;
401
  }
402
 
403
  /**
@@ -410,10 +385,11 @@ class Video extends Element implements ChildrenContainer
410
 
411
  /**
412
  * @return boolean tells if the comments widget is enabled
 
413
  */
414
  public function isCommentsEnabled()
415
  {
416
- return $this->isCommentsEnabled;
417
  }
418
 
419
  /**
@@ -451,10 +427,10 @@ class Video extends Element implements ChildrenContainer
451
  * WARNING this is not Thread-safe, so if you are using pthreads or any other multithreaded engine,
452
  * this might not work as expected. (you will need to set this in all working threads manually)
453
  * @param boolean $enabled inform true to enable likes on videos per default or false to disable like on videos.
 
454
  */
455
  public static function setDefaultLikeEnabled($enabled)
456
  {
457
- self::$defaultLikeEnabled = $enabled;
458
  }
459
 
460
  /**
@@ -463,10 +439,10 @@ class Video extends Element implements ChildrenContainer
463
  * WARNING this is not Thread-safe, so if you are using pthreads or any other multithreaded engine,
464
  * this might not work as expected. (you will need to set this in all working threads manually)
465
  * @param boolean $enabled inform true to enable comments on videos per default or false to disable commenting on videos.
 
466
  */
467
  public static function setDefaultCommentEnabled($enabled)
468
  {
469
- self::$defaultCommentEnabled = $enabled;
470
  }
471
 
472
 
@@ -501,17 +477,6 @@ class Video extends Element implements ChildrenContainer
501
  $element->setAttribute('class', 'fb-feed-cover');
502
  }
503
 
504
- // Like/comments markup optional
505
- if ($this->isLikeEnabled || $this->isCommentsEnabled) {
506
- if ($this->isLikeEnabled && $this->isCommentsEnabled) {
507
- $element->setAttribute('data-feedback', 'fb:likes,fb:comments');
508
- } elseif ($this->isLikeEnabled) {
509
- $element->setAttribute('data-feedback', 'fb:likes');
510
- } else {
511
- $element->setAttribute('data-feedback', 'fb:comments');
512
- }
513
- }
514
-
515
  // URL markup required
516
  if ($this->url) {
517
  $videoElement = $document->createElement('video');
44
  const LOOP = 'loop';
45
  const DATA_FADE = 'data-fade';
46
 
 
 
 
 
 
 
 
 
 
 
47
  /**
48
  * @var Caption The caption for Video
49
  */
60
  */
61
  private $contentType;
62
 
 
 
 
 
 
 
 
 
 
 
63
  /**
64
  * @var boolean Makes the video the cover on news feed.
65
  *
104
 
105
  private function __construct()
106
  {
 
 
107
  }
108
 
109
  /**
179
  * Makes like enabled for this video.
180
  *
181
  * @return $this
182
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
183
  */
184
  public function enableLike()
185
  {
 
 
186
  return $this;
187
  }
188
 
190
  * Makes like disabled for this video.
191
  *
192
  * @return $this
193
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
194
  */
195
  public function disableLike()
196
  {
 
 
197
  return $this;
198
  }
199
 
201
  * Makes comments enabled for this video.
202
  *
203
  * @return $this
204
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
205
  */
206
  public function enableComments()
207
  {
 
 
208
  return $this;
209
  }
210
 
212
  * Makes comments disabled for this video.
213
  *
214
  * @return $this
215
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
216
  */
217
  public function disableComments()
218
  {
 
 
219
  return $this;
220
  }
221
 
368
 
369
  /**
370
  * @return boolean tells if the like button is enabled
371
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
372
  */
373
  public function isLikeEnabled()
374
  {
375
+ return false;
376
  }
377
 
378
  /**
385
 
386
  /**
387
  * @return boolean tells if the comments widget is enabled
388
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
389
  */
390
  public function isCommentsEnabled()
391
  {
392
+ return false;
393
  }
394
 
395
  /**
427
  * WARNING this is not Thread-safe, so if you are using pthreads or any other multithreaded engine,
428
  * this might not work as expected. (you will need to set this in all working threads manually)
429
  * @param boolean $enabled inform true to enable likes on videos per default or false to disable like on videos.
430
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
431
  */
432
  public static function setDefaultLikeEnabled($enabled)
433
  {
 
434
  }
435
 
436
  /**
439
  * WARNING this is not Thread-safe, so if you are using pthreads or any other multithreaded engine,
440
  * this might not work as expected. (you will need to set this in all working threads manually)
441
  * @param boolean $enabled inform true to enable comments on videos per default or false to disable commenting on videos.
442
+ * @deprecated This feature has been deprecated as InstantArticles doesn't support likes, comments and shares to individual media content.
443
  */
444
  public static function setDefaultCommentEnabled($enabled)
445
  {
 
446
  }
447
 
448
 
477
  $element->setAttribute('class', 'fb-feed-cover');
478
  }
479
 
 
 
 
 
 
 
 
 
 
 
 
480
  // URL markup required
481
  if ($this->url) {
482
  $videoElement = $document->createElement('video');
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Parser/instant-articles-rules.json CHANGED
@@ -465,11 +465,6 @@
465
  "selector" : "img",
466
  "attribute": "src"
467
  },
468
- "image.like" : {
469
- "type" : "exists",
470
- "selector" : "figure[data-feedback*='fb:likes']",
471
- "attribute": "data-feedback"
472
- },
473
  "aspect-fit": {
474
  "type": "exists",
475
  "selector" : "figure[data-mode=aspect-fit]"
@@ -485,11 +480,6 @@
485
  "non-interactive": {
486
  "type": "exists",
487
  "selector" : "figure[data-mode=non-interactive]"
488
- },
489
- "image.comments" : {
490
- "type" : "exists",
491
- "selector" : "figure[data-feedback*='fb:comments']",
492
- "attribute": "data-feedback"
493
  }
494
  }
495
  },
@@ -533,16 +523,6 @@
533
  "type": "exists",
534
  "selector" : "video",
535
  "attribute": "data-fb-disable-autoplay"
536
- },
537
- "video.like" : {
538
- "type" : "exists",
539
- "selector" : "figure[data-feedback*='fb:likes']",
540
- "attribute": "data-feedback"
541
- },
542
- "video.comments" : {
543
- "type" : "exists",
544
- "selector" : "figure[data-feedback*='fb:comments']",
545
- "attribute": "data-feedback"
546
  }
547
  }
548
  },
465
  "selector" : "img",
466
  "attribute": "src"
467
  },
 
 
 
 
 
468
  "aspect-fit": {
469
  "type": "exists",
470
  "selector" : "figure[data-mode=aspect-fit]"
480
  "non-interactive": {
481
  "type": "exists",
482
  "selector" : "figure[data-mode=non-interactive]"
 
 
 
 
 
483
  }
484
  }
485
  },
523
  "type": "exists",
524
  "selector" : "video",
525
  "attribute": "data-fb-disable-autoplay"
 
 
 
 
 
 
 
 
 
 
526
  }
527
  }
528
  },
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Getters/ConstantGetter.php CHANGED
@@ -29,7 +29,10 @@ class ConstantGetter extends AbstractGetter
29
  */
30
  public function withValue($value)
31
  {
32
- Type::enforce($value, Type::STRING);
 
 
 
33
  $this->value = $value;
34
 
35
  return $this;
29
  */
30
  public function withValue($value)
31
  {
32
+ Type::enforce($value, [
33
+ Type::STRING,
34
+ Type::INTEGER,
35
+ ]);
36
  $this->value = $value;
37
 
38
  return $this;
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Getters/ElementGetter.php CHANGED
@@ -33,7 +33,7 @@ class ElementGetter extends AbstractGetter
33
  {
34
  $domXPath = new \DOMXPath($node->ownerDocument);
35
  $converter = new CssSelectorConverter();
36
- $xpath = $converter->toXPath($selector);
37
  return $domXPath->query($xpath, $node);
38
  }
39
 
33
  {
34
  $domXPath = new \DOMXPath($node->ownerDocument);
35
  $converter = new CssSelectorConverter();
36
+ $xpath = $converter->toXPath($selector === null ? "" : $selector);
37
  return $domXPath->query($xpath, $node);
38
  }
39
 
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/ConfigurationSelectorRule.php CHANGED
@@ -118,7 +118,7 @@ abstract class ConfigurationSelectorRule extends Rule
118
  $xpath = $this->selector;
119
  } else {
120
  $converter = new CssSelectorConverter();
121
- $xpath = $converter->toXPath($this->selector);
122
  }
123
 
124
  $results = $domXPath->query($xpath);
118
  $xpath = $this->selector;
119
  } else {
120
  $converter = new CssSelectorConverter();
121
+ $xpath = $converter->toXPath($this->selector === null ? "" : $this->selector);
122
  }
123
 
124
  $results = $domXPath->query($xpath);
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Rules/VideoRule.php CHANGED
@@ -53,7 +53,7 @@ class VideoRule extends ConfigurationSelectorRule
53
  foreach ($node->childNodes as $child) {
54
  $domXPath = new \DOMXPath($child->ownerDocument);
55
  $converter = new CssSelectorConverter();
56
- $xpath = $converter->toXPath($this->childSelector);
57
  $results = $domXPath->query($xpath, $node);
58
  foreach ($results as $result) {
59
  if ($result === $child) {
53
  foreach ($node->childNodes as $child) {
54
  $domXPath = new \DOMXPath($child->ownerDocument);
55
  $converter = new CssSelectorConverter();
56
+ $xpath = $converter->toXPath($this->childSelector === null ? "" : $this->childSelector);
57
  $results = $domXPath->query($xpath, $node);
58
  foreach ($results as $result) {
59
  if ($result === $child) {
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Settings/AnalyticsSettings.php CHANGED
@@ -68,10 +68,11 @@ class AnalyticsSettings
68
  "'https://connect.facebook.net/en_US/fbevents.js'); ".
69
  "fbq('init', '$this->fbPixelId'); ".
70
  "fbq('track', 'PageView'); ".
71
- "</script> ".
72
- "<noscript><img height=\"1\" width=\"1\" style=\"display:none\" ".
73
- "src=\"https://www.facebook.com/tr?ev=PageView&noscript=1&id=$this->fbPixelId\" ".
74
- "/></noscript> ".
 
75
  "<!-- End Facebook Pixel Code -->";
76
  }
77
 
68
  "'https://connect.facebook.net/en_US/fbevents.js'); ".
69
  "fbq('init', '$this->fbPixelId'); ".
70
  "fbq('track', 'PageView'); ".
71
+ "fbq('track', 'ViewContent', {".
72
+ "title: ia_document.title, ".
73
+ "platform: 'InstantArticles'".
74
+ "});".
75
+ "</script>".
76
  "<!-- End Facebook Pixel Code -->";
77
  }
78
 
vendor/facebook/facebook-instant-articles-sdk-php/src/Facebook/InstantArticles/Transformer/Transformer.php CHANGED
@@ -380,25 +380,97 @@ class Transformer
380
 
381
  /**
382
  * @param string $json_file
 
 
383
  */
384
- public function loadRules($json_file)
385
  {
386
  $configuration = json_decode($json_file, true);
387
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
  // Treats the Rules configuration
389
  if ($configuration && isset($configuration['rules'])) {
390
  foreach ($configuration['rules'] as $configuration_rule) {
391
  $class = $configuration_rule['class'];
392
  try {
393
  $factory_method = new \ReflectionMethod($class, 'createFrom');
 
394
  } catch (\ReflectionException $e) {
395
- $factory_method =
396
- new \ReflectionMethod(
397
- 'Facebook\\InstantArticles\\Transformer\\Rules\\'.$class,
398
  'createFrom'
399
  );
 
 
 
 
 
 
 
 
400
  }
401
- $this->addRule($factory_method->invoke(null, $configuration_rule));
402
  }
403
  }
404
 
@@ -545,8 +617,8 @@ class Transformer
545
  public function loadAnalyicsConfiguration($analyticsSettings)
546
  {
547
  $this->analyticsSettings = new AnalyticsSettings(
548
- $analyticsSettings['fb_pixel_id'],
549
- $analyticsSettings['raw_html']
550
  );
551
  }
552
  }
380
 
381
  /**
382
  * @param string $json_file
383
+ *
384
+ * @return configuration
385
  */
386
+ public function validateJSON($json_file)
387
  {
388
  $configuration = json_decode($json_file, true);
389
 
390
+ switch (json_last_error()) {
391
+ case JSON_ERROR_NONE:
392
+ break;
393
+ case JSON_ERROR_DEPTH:
394
+ $this->addWarning('Invalid JSON Rules: Maximum stack depth exceeded');
395
+ $this->addLog(
396
+ TransformerLog::ERROR,
397
+ "Invalid JSON Rules: Maximum stack depth exceeded"
398
+ );
399
+ $configuration = '';
400
+ break;
401
+ case JSON_ERROR_STATE_MISMATCH:
402
+ $this->addWarning('Invalid JSON Rules: Underflow or the modes mismatch');
403
+ $this->addLog(
404
+ TransformerLog::ERROR,
405
+ "Invalid JSON Rules: Underflow or the modes mismatch"
406
+ );
407
+ $configuration = '';
408
+ break;
409
+ case JSON_ERROR_CTRL_CHAR:
410
+ $this->addWarning('Invalid JSON Rules: Unexpected control character found');
411
+ $this->addLog(
412
+ TransformerLog::ERROR,
413
+ "Invalid JSON Rules: Unexpected control character found"
414
+ );
415
+ $configuration = '';
416
+ break;
417
+ case JSON_ERROR_SYNTAX:
418
+ $this->addWarning('Invalid JSON Rules: Syntax error, malformed JSON');
419
+ $this->addLog(
420
+ TransformerLog::ERROR,
421
+ "Invalid JSON Rules: Syntax error, malformed JSON"
422
+ );
423
+ $configuration = '';
424
+ break;
425
+ case JSON_ERROR_UTF8:
426
+ $this->addWarning('Invalid JSON Rules: Malformed UTF-8 characters, possibly incorrectly encoded');
427
+ $this->addLog(
428
+ TransformerLog::ERROR,
429
+ "Invalid JSON Rules: Malformed UTF-8 characters, possibly incorrectly encoded"
430
+ );
431
+ $configuration = '';
432
+ break;
433
+ default:
434
+ $this->addWarning('Invalid JSON Rules');
435
+ $this->addLog(
436
+ TransformerLog::ERROR,
437
+ "Invalid JSON Rules"
438
+ );
439
+ $configuration = '';
440
+ break;
441
+ }
442
+ return $configuration;
443
+ }
444
+
445
+ /**
446
+ * @param string $json_file
447
+ */
448
+ public function loadRules($json_file)
449
+ {
450
+ $configuration = $this->validateJSON($json_file);
451
+
452
  // Treats the Rules configuration
453
  if ($configuration && isset($configuration['rules'])) {
454
  foreach ($configuration['rules'] as $configuration_rule) {
455
  $class = $configuration_rule['class'];
456
  try {
457
  $factory_method = new \ReflectionMethod($class, 'createFrom');
458
+ $this->addRule($factory_method->invoke(null, $configuration_rule));
459
  } catch (\ReflectionException $e) {
460
+ try {
461
+ $factory_method = new \ReflectionMethod(
462
+ 'Facebook\\InstantArticles\\Transformer\\Rules\\' . $class,
463
  'createFrom'
464
  );
465
+ $this->addRule($factory_method->invoke(null, $configuration_rule));
466
+ } catch (\ReflectionException $e) {
467
+ $this->addWarning("$class was not found");
468
+ $this->addLog(
469
+ TransformerLog::ERROR,
470
+ "$class was not found"
471
+ );
472
+ }
473
  }
 
474
  }
475
  }
476
 
617
  public function loadAnalyicsConfiguration($analyticsSettings)
618
  {
619
  $this->analyticsSettings = new AnalyticsSettings(
620
+ isset($analyticsSettings['fb_pixel_id']) ? $analyticsSettings['fb_pixel_id'] : '',
621
+ isset($analyticsSettings['raw_html']) ? $analyticsSettings['raw_html'] : ''
622
  );
623
  }
624
  }
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Elements/ImageTest.php CHANGED
@@ -94,7 +94,7 @@ class ImageTest extends BaseHTMLTestCase
94
  ->enableLike();
95
 
96
  $expected =
97
- '<figure data-feedback="fb:likes">'.
98
  '<img src="https://jpeg.org/images/jpegls-home.jpg"/>'.
99
  '<figcaption>Some caption to the image</figcaption>'.
100
  '</figure>';
@@ -115,7 +115,7 @@ class ImageTest extends BaseHTMLTestCase
115
  ->enableComments();
116
 
117
  $expected =
118
- '<figure data-feedback="fb:comments">'.
119
  '<img src="https://jpeg.org/images/jpegls-home.jpg"/>'.
120
  '<figcaption>Some caption to the image</figcaption>'.
121
  '</figure>';
@@ -137,7 +137,7 @@ class ImageTest extends BaseHTMLTestCase
137
  ->enableComments();
138
 
139
  $expected =
140
- '<figure data-feedback="fb:likes,fb:comments">'.
141
  '<img src="https://jpeg.org/images/jpegls-home.jpg"/>'.
142
  '<figcaption>Some caption to the image</figcaption>'.
143
  '</figure>';
@@ -159,7 +159,7 @@ class ImageTest extends BaseHTMLTestCase
159
  ->enableComments();
160
 
161
  $expected =
162
- '<figure data-feedback="fb:likes,fb:comments">'.
163
  '<img src="https://jpeg.org/images/jpegls-home.jpg?width=100&height=200"/>'.
164
  '<figcaption>Some caption to the image</figcaption>'.
165
  '</figure>';
94
  ->enableLike();
95
 
96
  $expected =
97
+ '<figure>'.
98
  '<img src="https://jpeg.org/images/jpegls-home.jpg"/>'.
99
  '<figcaption>Some caption to the image</figcaption>'.
100
  '</figure>';
115
  ->enableComments();
116
 
117
  $expected =
118
+ '<figure>'.
119
  '<img src="https://jpeg.org/images/jpegls-home.jpg"/>'.
120
  '<figcaption>Some caption to the image</figcaption>'.
121
  '</figure>';
137
  ->enableComments();
138
 
139
  $expected =
140
+ '<figure>'.
141
  '<img src="https://jpeg.org/images/jpegls-home.jpg"/>'.
142
  '<figcaption>Some caption to the image</figcaption>'.
143
  '</figure>';
159
  ->enableComments();
160
 
161
  $expected =
162
+ '<figure>'.
163
  '<img src="https://jpeg.org/images/jpegls-home.jpg?width=100&height=200"/>'.
164
  '<figcaption>Some caption to the image</figcaption>'.
165
  '</figure>';
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Elements/SlideshowTest.php CHANGED
@@ -70,13 +70,13 @@ class SlideshowTest extends BaseHTMLTestCase
70
 
71
  $expected =
72
  '<figure class="op-slideshow">'.
73
- '<figure data-feedback="fb:likes">'.
74
  '<img src="https://jpeg.org/images/jpegls-home.jpg"/>'.
75
  '</figure>'.
76
- '<figure data-feedback="fb:comments">'.
77
  '<img src="https://jpeg.org/images/jpegls-home2.jpg"/>'.
78
  '</figure>'.
79
- '<figure data-feedback="fb:likes,fb:comments">'.
80
  '<img src="https://jpeg.org/images/jpegls-home3.jpg"/>'.
81
  '</figure>'.
82
  '</figure>';
70
 
71
  $expected =
72
  '<figure class="op-slideshow">'.
73
+ '<figure>'.
74
  '<img src="https://jpeg.org/images/jpegls-home.jpg"/>'.
75
  '</figure>'.
76
+ '<figure>'.
77
  '<img src="https://jpeg.org/images/jpegls-home2.jpg"/>'.
78
  '</figure>'.
79
+ '<figure>'.
80
  '<img src="https://jpeg.org/images/jpegls-home3.jpg"/>'.
81
  '</figure>'.
82
  '</figure>';
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Elements/VideoTest.php CHANGED
@@ -148,7 +148,7 @@ class VideoTest extends BaseHTMLTestCase
148
  ->enableLike();
149
 
150
  $expected =
151
- '<figure data-feedback="fb:likes">'.
152
  '<video>'.
153
  '<source src="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4"/>'.
154
  '</video>'.
@@ -171,7 +171,7 @@ class VideoTest extends BaseHTMLTestCase
171
  ->enableComments();
172
 
173
  $expected =
174
- '<figure data-feedback="fb:comments">'.
175
  '<video>'.
176
  '<source src="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4"/>'.
177
  '</video>'.
@@ -195,7 +195,7 @@ class VideoTest extends BaseHTMLTestCase
195
  ->enableComments();
196
 
197
  $expected =
198
- '<figure data-feedback="fb:likes,fb:comments">'.
199
  '<video>'.
200
  '<source src="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4"/>'.
201
  '</video>'.
148
  ->enableLike();
149
 
150
  $expected =
151
+ '<figure>'.
152
  '<video>'.
153
  '<source src="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4"/>'.
154
  '</video>'.
171
  ->enableComments();
172
 
173
  $expected =
174
+ '<figure>'.
175
  '<video>'.
176
  '<source src="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4"/>'.
177
  '</video>'.
195
  ->enableComments();
196
 
197
  $expected =
198
+ '<figure>'.
199
  '<video>'.
200
  '<source src="http://www.sample-videos.com/video/mp4/720/big_buck_bunny_720p_1mb.mp4"/>'.
201
  '</video>'.
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Parser/instant-article-example-no-timezone.html CHANGED
@@ -31,13 +31,13 @@
31
  <h3 class="op-kicker">Some kicker of this article</h3>
32
  </header>
33
  <p>Some text to be within a paragraph for testing.</p>
34
- <figure data-feedback="fb:likes">
35
  <img src="http://mydomain.com/path/to/img.jpg"/>
36
  <audio title="audio title" autoplay="autoplay" muted="muted">
37
  <source src="http://foo.com/mp3"/>
38
  </audio>
39
  </figure>
40
- <figure data-feedback="fb:comments">
41
  <img src="http://mydomain.com/path/to/img.jpg"/>
42
  <script type="application/json" class="op-geotag">
43
  {
@@ -58,7 +58,7 @@
58
  <source src="http://foo.com/mp3"/>
59
  </audio>
60
  </figure>
61
- <figure data-feedback="fb:likes,fb:comments">
62
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
63
  <figcaption><h1>Image Name</h1>Some text on text node<cite>Some caption to the image</cite></figcaption>
64
  </figure>
@@ -143,7 +143,7 @@
143
  <h1>Custom code for your social embed</h1>
144
  <script>alert("test & more test");</script></iframe>
145
  </figure>
146
- <figure data-mode="fullscreen" data-feedback="fb:likes,fb:comments">
147
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
148
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
149
  </video>
31
  <h3 class="op-kicker">Some kicker of this article</h3>
32
  </header>
33
  <p>Some text to be within a paragraph for testing.</p>
34
+ <figure>
35
  <img src="http://mydomain.com/path/to/img.jpg"/>
36
  <audio title="audio title" autoplay="autoplay" muted="muted">
37
  <source src="http://foo.com/mp3"/>
38
  </audio>
39
  </figure>
40
+ <figure>
41
  <img src="http://mydomain.com/path/to/img.jpg"/>
42
  <script type="application/json" class="op-geotag">
43
  {
58
  <source src="http://foo.com/mp3"/>
59
  </audio>
60
  </figure>
61
+ <figure>
62
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
63
  <figcaption><h1>Image Name</h1>Some text on text node<cite>Some caption to the image</cite></figcaption>
64
  </figure>
143
  <h1>Custom code for your social embed</h1>
144
  <script>alert("test & more test");</script></iframe>
145
  </figure>
146
+ <figure data-mode="fullscreen">
147
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
148
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
149
  </video>
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Parser/instant-article-example-nyc-timezone.html CHANGED
@@ -31,13 +31,13 @@
31
  <h3 class="op-kicker">Some kicker of this article</h3>
32
  </header>
33
  <p>Some text to be within a paragraph for testing.</p>
34
- <figure data-feedback="fb:likes">
35
  <img src="http://mydomain.com/path/to/img.jpg"/>
36
  <audio title="audio title" autoplay="autoplay" muted="muted">
37
  <source src="http://foo.com/mp3"/>
38
  </audio>
39
  </figure>
40
- <figure data-feedback="fb:comments">
41
  <img src="http://mydomain.com/path/to/img.jpg"/>
42
  <script type="application/json" class="op-geotag">
43
  {
@@ -58,7 +58,7 @@
58
  <source src="http://foo.com/mp3"/>
59
  </audio>
60
  </figure>
61
- <figure data-feedback="fb:likes,fb:comments">
62
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
63
  <figcaption><h1>Image Name</h1>Some text on text node<cite>Some caption to the image</cite></figcaption>
64
  </figure>
@@ -143,7 +143,7 @@
143
  <h1>Custom code for your social embed</h1>
144
  <script>alert("test & more test");</script></iframe>
145
  </figure>
146
- <figure data-mode="fullscreen" data-feedback="fb:likes,fb:comments">
147
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
148
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
149
  </video>
31
  <h3 class="op-kicker">Some kicker of this article</h3>
32
  </header>
33
  <p>Some text to be within a paragraph for testing.</p>
34
+ <figure>
35
  <img src="http://mydomain.com/path/to/img.jpg"/>
36
  <audio title="audio title" autoplay="autoplay" muted="muted">
37
  <source src="http://foo.com/mp3"/>
38
  </audio>
39
  </figure>
40
+ <figure>
41
  <img src="http://mydomain.com/path/to/img.jpg"/>
42
  <script type="application/json" class="op-geotag">
43
  {
58
  <source src="http://foo.com/mp3"/>
59
  </audio>
60
  </figure>
61
+ <figure>
62
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
63
  <figcaption><h1>Image Name</h1>Some text on text node<cite>Some caption to the image</cite></figcaption>
64
  </figure>
143
  <h1>Custom code for your social embed</h1>
144
  <script>alert("test & more test");</script></iframe>
145
  </figure>
146
+ <figure data-mode="fullscreen">
147
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
148
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
149
  </video>
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Parser/instant-article-example-standard-timezone.html CHANGED
@@ -31,13 +31,13 @@
31
  <h3 class="op-kicker">Some kicker of this article</h3>
32
  </header>
33
  <p>Some text to be within a paragraph for testing.</p>
34
- <figure data-feedback="fb:likes">
35
  <img src="http://mydomain.com/path/to/img.jpg"/>
36
  <audio title="audio title" autoplay="autoplay" muted="muted">
37
  <source src="http://foo.com/mp3"/>
38
  </audio>
39
  </figure>
40
- <figure data-feedback="fb:comments">
41
  <img src="http://mydomain.com/path/to/img.jpg"/>
42
  <script type="application/json" class="op-geotag">
43
  {
@@ -58,7 +58,7 @@
58
  <source src="http://foo.com/mp3"/>
59
  </audio>
60
  </figure>
61
- <figure data-feedback="fb:likes,fb:comments">
62
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
63
  <figcaption><h1>Image Name</h1>Some text on text node<cite>Some caption to the image</cite></figcaption>
64
  </figure>
@@ -143,7 +143,7 @@
143
  <h1>Custom code for your social embed</h1>
144
  <script>alert("test & more test");</script></iframe>
145
  </figure>
146
- <figure data-mode="fullscreen" data-feedback="fb:likes,fb:comments">
147
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
148
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
149
  </video>
31
  <h3 class="op-kicker">Some kicker of this article</h3>
32
  </header>
33
  <p>Some text to be within a paragraph for testing.</p>
34
+ <figure>
35
  <img src="http://mydomain.com/path/to/img.jpg"/>
36
  <audio title="audio title" autoplay="autoplay" muted="muted">
37
  <source src="http://foo.com/mp3"/>
38
  </audio>
39
  </figure>
40
+ <figure>
41
  <img src="http://mydomain.com/path/to/img.jpg"/>
42
  <script type="application/json" class="op-geotag">
43
  {
58
  <source src="http://foo.com/mp3"/>
59
  </audio>
60
  </figure>
61
+ <figure>
62
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
63
  <figcaption><h1>Image Name</h1>Some text on text node<cite>Some caption to the image</cite></figcaption>
64
  </figure>
143
  <h1>Custom code for your social embed</h1>
144
  <script>alert("test & more test");</script></iframe>
145
  </figure>
146
+ <figure data-mode="fullscreen">
147
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
148
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
149
  </video>
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Parser/instant-article-example.html CHANGED
@@ -32,13 +32,13 @@
32
  <h3 class="op-kicker">Some kicker of this article</h3>
33
  </header>
34
  <p>Some text to be within a paragraph for testing.</p>
35
- <figure data-feedback="fb:likes">
36
  <img src="http://mydomain.com/path/to/img.jpg"/>
37
  <audio title="audio title" autoplay="autoplay" muted="muted">
38
  <source src="http://foo.com/mp3"/>
39
  </audio>
40
  </figure>
41
- <figure data-feedback="fb:comments">
42
  <img src="http://mydomain.com/path/to/img.jpg"/>
43
  <script type="application/json" class="op-geotag">
44
  {
@@ -59,7 +59,7 @@
59
  <source src="http://foo.com/mp3"/>
60
  </audio>
61
  </figure>
62
- <figure data-feedback="fb:likes,fb:comments">
63
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
64
  <figcaption><h1>Image Name</h1>Some text on text node<cite>Some caption to the image</cite></figcaption>
65
  </figure>
@@ -144,7 +144,7 @@
144
  <h1>Custom code for your social embed</h1>
145
  <script>alert("test & more test");</script></iframe>
146
  </figure>
147
- <figure data-mode="fullscreen" data-feedback="fb:likes,fb:comments">
148
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
149
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
150
  </video>
32
  <h3 class="op-kicker">Some kicker of this article</h3>
33
  </header>
34
  <p>Some text to be within a paragraph for testing.</p>
35
+ <figure>
36
  <img src="http://mydomain.com/path/to/img.jpg"/>
37
  <audio title="audio title" autoplay="autoplay" muted="muted">
38
  <source src="http://foo.com/mp3"/>
39
  </audio>
40
  </figure>
41
+ <figure>
42
  <img src="http://mydomain.com/path/to/img.jpg"/>
43
  <script type="application/json" class="op-geotag">
44
  {
59
  <source src="http://foo.com/mp3"/>
60
  </audio>
61
  </figure>
62
+ <figure>
63
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
64
  <figcaption><h1>Image Name</h1>Some text on text node<cite>Some caption to the image</cite></figcaption>
65
  </figure>
144
  <h1>Custom code for your social embed</h1>
145
  <script>alert("test & more test");</script></iframe>
146
  </figure>
147
+ <figure data-mode="fullscreen">
148
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
149
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
150
  </video>
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/SimpleTransformerTest.php CHANGED
@@ -77,4 +77,48 @@ class SimpleTransformerTest extends BaseHTMLTestCase
77
 
78
  $this->assertEqualsHtml($expected, $result);
79
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  }
77
 
78
  $this->assertEqualsHtml($expected, $result);
79
  }
80
+
81
+ public function testTransformerInvalidSyntaxRules()
82
+ {
83
+ $expected_error = new TransformerLog(TransformerLog::ERROR, 'Invalid JSON Rules: Syntax error, malformed JSON');
84
+ $json_file = file_get_contents(__DIR__ . '/invalid-rules-syntax.json');
85
+
86
+ $transformer = new Transformer();
87
+ $transformer->loadRules($json_file);
88
+
89
+ TransformerLog::setLevel(TransformerLog::DEBUG);
90
+ $result = $transformer->getLogs()[1];
91
+
92
+ $this->assertEquals($expected_error, $result);
93
+ }
94
+
95
+ public function testTransformerUnexpectedControlCharacterRules()
96
+ {
97
+ // For PHP < 7
98
+ $expected_error1 = new TransformerLog(TransformerLog::ERROR, 'Invalid JSON Rules: Syntax error, malformed JSON');
99
+
100
+ // For PHP >= 7
101
+ $expected_error2 = new TransformerLog(TransformerLog::ERROR, 'Invalid JSON Rules: Unexpected control character found');
102
+
103
+ $json_file = file_get_contents(__DIR__ . '/invalid-rules-unexpected-character.json');
104
+
105
+ $transformer = new Transformer();
106
+ $transformer->loadRules($json_file);
107
+
108
+ TransformerLog::setLevel(TransformerLog::DEBUG);
109
+ $result = $transformer->getLogs()[1];
110
+
111
+ $this->assertEquals($expected_error1 == $result || $expected_error2 == $result, true);
112
+ }
113
+
114
+ public function testTransformerInvalidRuleClassName()
115
+ {
116
+ $expected_error = new TransformerLog(TransformerLog::ERROR, 'TextNodeRul was not found');
117
+ $json_file = file_get_contents(__DIR__ . '/invalid-rule-class.json');
118
+ $transformer = new Transformer();
119
+ $transformer->loadRules($json_file);
120
+ TransformerLog::setLevel(TransformerLog::DEBUG);
121
+ $result = $transformer->getLogs()[1];
122
+ $this->assertEquals($expected_error, $result);
123
+ }
124
  }
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/invalid-rule-class.json ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "style_name": "mydefaultstyle",
3
+ "ads": {
4
+ "audience_network_placement_id": "1234"
5
+ },
6
+ "analytics": {
7
+ "fb_pixel_id": "4321",
8
+ "raw_html": "<script>alert('hello world!');</script><div class='block'></div>"
9
+ },
10
+ "rules": [
11
+ {
12
+ "class": "TextNodeRul"
13
+ }
14
+ ]
15
+ }
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/invalid-rules-syntax.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "style_name" : "mydefaultstyle",
3
+ "ads" : {
4
+ "audience_network_placement_id": "1234",
5
+ "raw_html": "<script>alert('hello world!');</script><div class='block'></div>"
6
+ },
7
+ "analytics" : {
8
+ "fb_pixel_id": "4321",
9
+ "raw_html": "<script>alert('hello world!');</script><div class='block'></div>"
10
+ }
11
+ "rules" :
12
+ [
13
+ {
14
+ "class": "TextNodeRule"
15
+ },
16
+ {
17
+ "class": "PassThroughRule",
18
+ "selector" : "html, head, script, body"
19
+ }
20
+ ]
21
+ }
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/invalid-rules-unexpected-character.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "style_name" : "mydefaultstyle",
3
+ "ads" : {
4
+ "audience_network_placement_id": "1234",
5
+ "raw_html": "<script>alert('hello world!');</script><div class='block'></div>"
6
+ },
7
+ "analytics" : {
8
+ "fb_pixel_id": "4321",
9
+ "raw_html": "<script>alert('hello world!');</script><div class='block'></div>"
10
+ },
11
+ "rules :
12
+ [
13
+ {
14
+ "class": "TextNodeRule"
15
+ },
16
+ {
17
+ "class": "PassThroughRule",
18
+ "selector" : "html, head, script, body"
19
+ }
20
+ ]
21
+ }
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/Example/simple-ia.html CHANGED
@@ -29,8 +29,7 @@
29
  <!-- Facebook Pixel Code -->
30
  <script>
31
  !function(f,b,e,v,n,t,s)
32
- {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '4321'); fbq('track', 'PageView'); </script>
33
- <noscript><img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?ev=PageView&noscript=1&id=4321" /></noscript>
34
  <!-- End Facebook Pixel Code -->
35
  <script>alert('hello world!');</script>
36
  <div class='block'></div></iframe></figure>
29
  <!-- Facebook Pixel Code -->
30
  <script>
31
  !function(f,b,e,v,n,t,s)
32
+ {if(f.fbq)return;n=f.fbq=function(){n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments)}; if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0'; n.queue=[];t=b.createElement(e);t.async=!0; t.src=v;s=b.getElementsByTagName(e)[0]; s.parentNode.insertBefore(t,s)}(window, document,'script', 'https://connect.facebook.net/en_US/fbevents.js'); fbq('init', '4321'); fbq('track', 'PageView'); fbq('track', 'ViewContent', {title: ia_document.title, platform: 'InstantArticles'});</script>
 
33
  <!-- End Facebook Pixel Code -->
34
  <script>alert('hello world!');</script>
35
  <div class='block'></div></iframe></figure>
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/instant-article-example-multibyte.html CHANGED
@@ -36,13 +36,13 @@
36
  </ul>
37
  </header>
38
  <p>パラグラフ内のテキストのテストです。</p>
39
- <figure data-feedback="fb:likes">
40
  <img src="http://mydomain.com/path/to/img.jpg"/>
41
  <audio title="&#x30AA;&#x30FC;&#x30C7;&#x30A3;&#x30AA;&#x30BF;&#x30A4;&#x30C8;&#x30EB;" autoplay="autoplay" muted="muted">
42
  <source src="http://foo.com/mp3"/>
43
  </audio>
44
  </figure>
45
- <figure data-feedback="fb:comments">
46
  <img src="http://mydomain.com/path/to/img.jpg"/>
47
  <script type="application/json" class="op-geotag">
48
  {
@@ -63,7 +63,7 @@
63
  <source src="http://foo.com/mp3"/>
64
  </audio>
65
  </figure>
66
- <figure data-feedback="fb:likes,fb:comments">
67
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
68
  <figcaption><h1>イメージ名</h1>テキストノード<cite>イメージキャプション</cite></figcaption>
69
  </figure>
@@ -148,7 +148,7 @@
148
  <h1>ソーシャル埋め込み用カスタムコード</h1>
149
  <script>alert("テスト");</script></iframe>
150
  </figure>
151
- <figure data-mode="fullscreen" data-feedback="fb:likes,fb:comments">
152
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
153
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
154
  </video>
36
  </ul>
37
  </header>
38
  <p>パラグラフ内のテキストのテストです。</p>
39
+ <figure>
40
  <img src="http://mydomain.com/path/to/img.jpg"/>
41
  <audio title="&#x30AA;&#x30FC;&#x30C7;&#x30A3;&#x30AA;&#x30BF;&#x30A4;&#x30C8;&#x30EB;" autoplay="autoplay" muted="muted">
42
  <source src="http://foo.com/mp3"/>
43
  </audio>
44
  </figure>
45
+ <figure>
46
  <img src="http://mydomain.com/path/to/img.jpg"/>
47
  <script type="application/json" class="op-geotag">
48
  {
63
  <source src="http://foo.com/mp3"/>
64
  </audio>
65
  </figure>
66
+ <figure>
67
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
68
  <figcaption><h1>イメージ名</h1>テキストノード<cite>イメージキャプション</cite></figcaption>
69
  </figure>
148
  <h1>ソーシャル埋め込み用カスタムコード</h1>
149
  <script>alert("テスト");</script></iframe>
150
  </figure>
151
+ <figure data-mode="fullscreen">
152
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
153
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
154
  </video>
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/instant-article-example-nonutf8.html CHANGED
@@ -36,13 +36,13 @@
36
  </ul>
37
  </header>
38
  <p>�ѥ饰�����Υƥ����ȤΥƥ��ȤǤ���</p>
39
- <figure data-feedback="fb:likes">
40
  <img src="http://mydomain.com/path/to/img.jpg"/>
41
  <audio title="&#x30AA;&#x30FC;&#x30C7;&#x30A3;&#x30AA;&#x30BF;&#x30A4;&#x30C8;&#x30EB;" autoplay="autoplay" muted="muted">
42
  <source src="http://foo.com/mp3"/>
43
  </audio>
44
  </figure>
45
- <figure data-feedback="fb:comments">
46
  <img src="http://mydomain.com/path/to/img.jpg"/>
47
  <script type="application/json" class="op-geotag">
48
  {
@@ -63,7 +63,7 @@
63
  <source src="http://foo.com/mp3"/>
64
  </audio>
65
  </figure>
66
- <figure data-feedback="fb:likes,fb:comments">
67
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
68
  <figcaption><h1>���᡼��̾</h1>�ƥ����ȥΡ���<cite>���᡼������ץ����</cite></figcaption>
69
  </figure>
@@ -148,7 +148,7 @@
148
  <h1>����������������ѥ������ॳ����</h1>
149
  <script>alert("�ƥ���");</script></iframe>
150
  </figure>
151
- <figure data-mode="fullscreen" data-feedback="fb:likes,fb:comments">
152
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
153
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
154
  </video>
36
  </ul>
37
  </header>
38
  <p>�ѥ饰�����Υƥ����ȤΥƥ��ȤǤ���</p>
39
+ <figure>
40
  <img src="http://mydomain.com/path/to/img.jpg"/>
41
  <audio title="&#x30AA;&#x30FC;&#x30C7;&#x30A3;&#x30AA;&#x30BF;&#x30A4;&#x30C8;&#x30EB;" autoplay="autoplay" muted="muted">
42
  <source src="http://foo.com/mp3"/>
43
  </audio>
44
  </figure>
45
+ <figure>
46
  <img src="http://mydomain.com/path/to/img.jpg"/>
47
  <script type="application/json" class="op-geotag">
48
  {
63
  <source src="http://foo.com/mp3"/>
64
  </audio>
65
  </figure>
66
+ <figure>
67
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
68
  <figcaption><h1>���᡼��̾</h1>�ƥ����ȥΡ���<cite>���᡼������ץ����</cite></figcaption>
69
  </figure>
148
  <h1>����������������ѥ������ॳ����</h1>
149
  <script>alert("�ƥ���");</script></iframe>
150
  </figure>
151
+ <figure data-mode="fullscreen">
152
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
153
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
154
  </video>
vendor/facebook/facebook-instant-articles-sdk-php/tests/Facebook/InstantArticles/Transformer/instant-article-example.html CHANGED
@@ -36,13 +36,13 @@
36
  </ul>
37
  </header>
38
  <p>Some text to be within a paragraph for testing.</p>
39
- <figure data-feedback="fb:likes">
40
  <img src="http://mydomain.com/path/to/img.jpg"/>
41
  <audio title="audio title" autoplay="autoplay" muted="muted">
42
  <source src="http://foo.com/mp3"/>
43
  </audio>
44
  </figure>
45
- <figure data-feedback="fb:comments">
46
  <img src="http://mydomain.com/path/to/img.jpg"/>
47
  <script type="application/json" class="op-geotag">
48
  {
@@ -63,7 +63,7 @@
63
  <source src="http://foo.com/mp3"/>
64
  </audio>
65
  </figure>
66
- <figure data-feedback="fb:likes,fb:comments">
67
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
68
  <figcaption><h1>Image Name</h1>Some text on text node<cite>Some caption to the image</cite></figcaption>
69
  </figure>
@@ -148,7 +148,7 @@
148
  <h1>Custom code for your social embed</h1>
149
  <script>alert("test & more test");</script></iframe>
150
  </figure>
151
- <figure data-mode="fullscreen" data-feedback="fb:likes,fb:comments">
152
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
153
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
154
  </video>
36
  </ul>
37
  </header>
38
  <p>Some text to be within a paragraph for testing.</p>
39
+ <figure>
40
  <img src="http://mydomain.com/path/to/img.jpg"/>
41
  <audio title="audio title" autoplay="autoplay" muted="muted">
42
  <source src="http://foo.com/mp3"/>
43
  </audio>
44
  </figure>
45
+ <figure>
46
  <img src="http://mydomain.com/path/to/img.jpg"/>
47
  <script type="application/json" class="op-geotag">
48
  {
63
  <source src="http://foo.com/mp3"/>
64
  </audio>
65
  </figure>
66
+ <figure>
67
  <img src="https://jpeg.org/images/jpegls-home.jpg"/>
68
  <figcaption><h1>Image Name</h1>Some text on text node<cite>Some caption to the image</cite></figcaption>
69
  </figure>
148
  <h1>Custom code for your social embed</h1>
149
  <script>alert("test & more test");</script></iframe>
150
  </figure>
151
+ <figure data-mode="fullscreen">
152
  <video data-fb-disable-autoplay="data-fb-disable-autoplay" controls="controls">
153
  <source src="http://mydomain.com/path/to/video.mp4" type="video/mp4"/>
154
  </video>
vendor/facebook/graph-sdk/src/Facebook/Facebook.php CHANGED
@@ -53,7 +53,7 @@ class Facebook
53
  /**
54
  * @const string Version number of the Facebook PHP SDK.
55
  */
56
- const VERSION = '5.6.2';
57
 
58
  /**
59
  * @const string Default Graph API version for requests.
53
  /**
54
  * @const string Version number of the Facebook PHP SDK.
55
  */
56
+ const VERSION = '5.6.3';
57
 
58
  /**
59
  * @const string Default Graph API version for requests.
vendor/facebook/graph-sdk/src/Facebook/FacebookBatchRequest.php CHANGED
@@ -39,7 +39,7 @@ class FacebookBatchRequest extends FacebookRequest implements IteratorAggregate,
39
  /**
40
  * @var array An array of FacebookRequest entities to send.
41
  */
42
- protected $requests;
43
 
44
  /**
45
  * @var array An array of files to upload.
39
  /**
40
  * @var array An array of FacebookRequest entities to send.
41
  */
42
+ protected $requests = [];
43
 
44
  /**
45
  * @var array An array of files to upload.
vendor/squizlabs/php_codesniffer/README.md CHANGED
@@ -11,12 +11,19 @@ PHP\_CodeSniffer requires PHP version 5.4.0 or greater, although individual snif
11
  ## Installation
12
 
13
  The easiest way to get started with PHP\_CodeSniffer is to download the Phar files for each of the commands:
 
 
 
 
14
 
15
- curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
16
- php phpcs.phar -h
 
17
 
18
- curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
19
- php phpcbf.phar -h
 
 
20
 
21
  ### Composer
22
  If you use Composer, you can install PHP_CodeSniffer system-wide with the following command:
@@ -75,3 +82,26 @@ Bug reports and feature requests can be submitted on the [Github Issue Tracker](
75
  ## Contributing
76
 
77
  See [CONTRIBUTING.md](CONTRIBUTING.md) for information.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  ## Installation
12
 
13
  The easiest way to get started with PHP\_CodeSniffer is to download the Phar files for each of the commands:
14
+ ```
15
+ # Download using curl
16
+ curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
17
+ curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
18
 
19
+ # Or download using wget
20
+ wget https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
21
+ wget https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar
22
 
23
+ # Then test the downloaded PHARs
24
+ php phpcs.phar -h
25
+ php phpcbf.phar -h
26
+ ```
27
 
28
  ### Composer
29
  If you use Composer, you can install PHP_CodeSniffer system-wide with the following command:
82
  ## Contributing
83
 
84
  See [CONTRIBUTING.md](CONTRIBUTING.md) for information.
85
+
86
+ ## Versioning
87
+
88
+ PHP_CodeSniffer uses a `MAJOR.MINOR.PATCH` version number format.
89
+
90
+ The `MAJOR` version is incremented when:
91
+ - backwards-incompatible changes are made to how the `phpcs` or `phpcbf` commands are used, or
92
+ - backwards-incompatible changes are made to the `ruleset.xml` format, or
93
+ - backwards-incompatible changes are made to the API used by sniff developers, or
94
+ - custom PHP_CodeSniffer token types are removed
95
+
96
+ The `MINOR` version is incremented when:
97
+ - new backwards-compatible features are added to the `phpcs` and `phpcbf` commands, or
98
+ - backwards-compatible changes are made to the `ruleset.xml` format, or
99
+ - backwards-compatible changes are made to the API used by sniff developers, or
100
+ - new sniffs are added to an included standard
101
+
102
+ > NOTE: Backwards-compatible changes to the API used by sniff develpers will allow an existing sniff to continue running without producing fatal errors but may not result in the sniff reporting the same errors as it did previously without changes being required.
103
+
104
+ The `PATCH` version is incremented when:
105
+ - backwards-compatible bug fixes are made
106
+
107
+ > NOTE: As PHP_CodeSniffer exists to report and fix issues, most bugs are the result of coding standard errors being incorrectly reported or coding standard errors not being reported when they should be. This means that the messages produced by PHP_CodeSniffer, and the fixes it makes, are likely to be different between PATCH versions.
vendor/squizlabs/php_codesniffer/autoload.php CHANGED
@@ -217,6 +217,18 @@ if (class_exists('PHP_CodeSniffer\Autoload', false) === false) {
217
  }//end addSearchPath()
218
 
219
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  /**
221
  * Gets the class name for the given file path.
222
  *
217
  }//end addSearchPath()
218
 
219
 
220
+ /**
221
+ * Retrieve the namespaces and paths registered by external standards.
222
+ *
223
+ * @return array
224
+ */
225
+ public static function getSearchPaths()
226
+ {
227
+ return self::$searchPaths;
228
+
229
+ }//end getSearchPaths()
230
+
231
+
232
  /**
233
  * Gets the class name for the given file path.
234
  *
vendor/squizlabs/php_codesniffer/phpcs.xml.dist CHANGED
@@ -4,6 +4,7 @@
4
 
5
  <file>autoload.php</file>
6
  <file>bin</file>
 
7
  <file>src</file>
8
  <file>tests</file>
9
 
@@ -28,6 +29,7 @@
28
  <exclude name="PEAR.Commenting.FileComment.MissingPackageTag" />
29
  <exclude name="PEAR.Commenting.FileComment.MissingLinkTag" />
30
  <exclude name="PEAR.Commenting.FileComment.MissingVersion" />
 
31
  </rule>
32
 
33
  <!-- Include some sniffs from other standards that don't conflict with PEAR -->
@@ -47,6 +49,7 @@
47
  <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing" />
48
  <rule ref="Squiz.Operators.ComparisonOperatorUsage" />
49
  <rule ref="Squiz.PHP.DisallowInlineIf" />
 
50
  <rule ref="Squiz.Strings.ConcatenationSpacing" />
51
  <rule ref="Squiz.WhiteSpace.ControlStructureSpacing" />
52
  <rule ref="Squiz.WhiteSpace.FunctionClosingBraceSpace" />
@@ -67,6 +70,13 @@
67
  <rule ref="PSR2.Files.EndFileNewline"/>
68
  <rule ref="Zend.Files.ClosingTag"/>
69
 
 
 
 
 
 
 
 
70
  <!-- We use custom indent rules for arrays -->
71
  <rule ref="Generic.Arrays.ArrayIndent"/>
72
  <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
@@ -103,6 +113,19 @@
103
  </properties>
104
  </rule>
105
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  <!-- Private methods MUST not be prefixed with an underscore -->
107
  <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
108
  <type>error</type>
4
 
5
  <file>autoload.php</file>
6
  <file>bin</file>
7
+ <file>scripts</file>
8
  <file>src</file>
9
  <file>tests</file>
10
 
29
  <exclude name="PEAR.Commenting.FileComment.MissingPackageTag" />
30
  <exclude name="PEAR.Commenting.FileComment.MissingLinkTag" />
31
  <exclude name="PEAR.Commenting.FileComment.MissingVersion" />
32
+ <exclude name="PEAR.Commenting.InlineComment" />
33
  </rule>
34
 
35
  <!-- Include some sniffs from other standards that don't conflict with PEAR -->
49
  <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing" />
50
  <rule ref="Squiz.Operators.ComparisonOperatorUsage" />
51
  <rule ref="Squiz.PHP.DisallowInlineIf" />
52
+ <rule ref="Squiz.Scope.MethodScope" />
53
  <rule ref="Squiz.Strings.ConcatenationSpacing" />
54
  <rule ref="Squiz.WhiteSpace.ControlStructureSpacing" />
55
  <rule ref="Squiz.WhiteSpace.FunctionClosingBraceSpace" />
70
  <rule ref="PSR2.Files.EndFileNewline"/>
71
  <rule ref="Zend.Files.ClosingTag"/>
72
 
73
+ <!-- PEAR uses warnings for inline control structures, so switch back to errors -->
74
+ <rule ref="Generic.ControlStructures.InlineControlStructure">
75
+ <properties>
76
+ <property name="error" value="true"/>
77
+ </properties>
78
+ </rule>
79
+
80
  <!-- We use custom indent rules for arrays -->
81
  <rule ref="Generic.Arrays.ArrayIndent"/>
82
  <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
113
  </properties>
114
  </rule>
115
 
116
+ <!-- Ban some functions -->
117
+ <rule ref="Generic.PHP.ForbiddenFunctions">
118
+ <properties>
119
+ <property name="forbiddenFunctions" type="array">
120
+ <element key="sizeof" value="count"/>
121
+ <element key="delete" value="unset"/>
122
+ <element key="print" value="echo"/>
123
+ <element key="is_null" value="null"/>
124
+ <element key="create_function" value="null"/>
125
+ </property>
126
+ </properties>
127
+ </rule>
128
+
129
  <!-- Private methods MUST not be prefixed with an underscore -->
130
  <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
131
  <type>error</type>
vendor/squizlabs/php_codesniffer/phpcs.xsd CHANGED
@@ -75,6 +75,14 @@
75
  <xs:sequence>
76
  <xs:element name="property" maxOccurs="unbounded" minOccurs="1">
77
  <xs:complexType>
 
 
 
 
 
 
 
 
78
  <xs:attribute name="type">
79
  <xs:simpleType>
80
  <xs:restriction base="xs:string">
@@ -83,7 +91,7 @@
83
  </xs:simpleType>
84
  </xs:attribute>
85
  <xs:attribute name="name" type="xs:string" use="required"></xs:attribute>
86
- <xs:attribute name="value" type="xs:string" use="required"></xs:attribute>
87
  </xs:complexType>
88
  </xs:element>
89
  </xs:sequence>
75
  <xs:sequence>
76
  <xs:element name="property" maxOccurs="unbounded" minOccurs="1">
77
  <xs:complexType>
78
+ <xs:sequence>
79
+ <xs:element name="element" maxOccurs="unbounded" minOccurs="0">
80
+ <xs:complexType>
81
+ <xs:attribute name="key" type="xs:string"></xs:attribute>
82
+ <xs:attribute name="value" type="xs:string" use="required"></xs:attribute>
83
+ </xs:complexType>
84
+ </xs:element>
85
+ </xs:sequence>
86
  <xs:attribute name="type">
87
  <xs:simpleType>
88
  <xs:restriction base="xs:string">
91
  </xs:simpleType>
92
  </xs:attribute>
93
  <xs:attribute name="name" type="xs:string" use="required"></xs:attribute>
94
+ <xs:attribute name="value" type="xs:string"></xs:attribute>
95
  </xs:complexType>
96
  </xs:element>
97
  </xs:sequence>
vendor/squizlabs/php_codesniffer/scripts/build-phar.php CHANGED
@@ -21,10 +21,10 @@ if (ini_get('phar.readonly') === '1') {
21
  exit(1);
22
  }
23
 
24
- $scripts = array(
25
- 'phpcs',
26
- 'phpcbf',
27
- );
28
 
29
  foreach ($scripts as $script) {
30
  echo "Building $script phar".PHP_EOL;
21
  exit(1);
22
  }
23
 
24
+ $scripts = [
25
+ 'phpcs',
26
+ 'phpcbf',
27
+ ];
28
 
29
  foreach ($scripts as $script) {
30
  echo "Building $script phar".PHP_EOL;
vendor/squizlabs/php_codesniffer/src/Config.php CHANGED
@@ -23,7 +23,7 @@ class Config
23
  *
24
  * @var string
25
  */
26
- const VERSION = '3.2.3';
27
 
28
  /**
29
  * Package stability; either stable, beta or alpha.
@@ -158,7 +158,7 @@ class Config
158
  *
159
  * @var array<string, TRUE>
160
  */
161
- private $overriddenDefaults = [];
162
 
163
  /**
164
  * Config file data that has been loaded for the run.
@@ -334,7 +334,7 @@ class Config
334
  $this->restoreDefaults();
335
  $this->setCommandLineValues($cliArgs);
336
 
337
- if (isset($this->overriddenDefaults['standards']) === false) {
338
  // They did not supply a standard to use.
339
  // Look for a default ruleset in the current directory or higher.
340
  $currentDir = getcwd();
@@ -389,8 +389,8 @@ class Config
389
  if (trim($fileContents) !== '') {
390
  $this->stdin = true;
391
  $this->stdinContent = $fileContents;
392
- $this->overriddenDefaults['stdin'] = true;
393
- $this->overriddenDefaults['stdinContent'] = true;
394
  }
395
  }//end if
396
 
@@ -421,7 +421,7 @@ class Config
421
  if ($arg === '-') {
422
  // Asking to read from STDIN.
423
  $this->stdin = true;
424
- $this->overriddenDefaults['stdin'] = true;
425
  continue;
426
  }
427
 
@@ -608,23 +608,23 @@ class Config
608
  }
609
 
610
  $this->verbosity++;
611
- $this->overriddenDefaults['verbosity'] = true;
612
  break;
613
  case 'l' :
614
  $this->local = true;
615
- $this->overriddenDefaults['local'] = true;
616
  break;
617
  case 's' :
618
  $this->showSources = true;
619
- $this->overriddenDefaults['showSources'] = true;
620
  break;
621
  case 'a' :
622
  $this->interactive = true;
623
- $this->overriddenDefaults['interactive'] = true;
624
  break;
625
  case 'e':
626
  $this->explain = true;
627
- $this->overriddenDefaults['explain'] = true;
628
  break;
629
  case 'p' :
630
  if ($this->quiet === true) {
@@ -633,7 +633,7 @@ class Config
633
  }
634
 
635
  $this->showProgress = true;
636
- $this->overriddenDefaults['showProgress'] = true;
637
  break;
638
  case 'q' :
639
  // Quiet mode disables a few other settings as well.
@@ -641,11 +641,11 @@ class Config
641
  $this->showProgress = false;
642
  $this->verbosity = 0;
643
 
644
- $this->overriddenDefaults['quiet'] = true;
645
  break;
646
  case 'm' :
647
  $this->recordErrors = false;
648
- $this->overriddenDefaults['recordErrors'] = true;
649
  break;
650
  case 'd' :
651
  $ini = explode('=', $this->cliArgs[($pos + 1)]);
@@ -657,15 +657,15 @@ class Config
657
  }
658
  break;
659
  case 'n' :
660
- if (isset($this->overriddenDefaults['warningSeverity']) === false) {
661
  $this->warningSeverity = 0;
662
- $this->overriddenDefaults['warningSeverity'] = true;
663
  }
664
  break;
665
  case 'w' :
666
- if (isset($this->overriddenDefaults['warningSeverity']) === false) {
667
  $this->warningSeverity = $this->errorSeverity;
668
- $this->overriddenDefaults['warningSeverity'] = true;
669
  }
670
  break;
671
  default:
@@ -703,46 +703,46 @@ class Config
703
  $output .= 'by Squiz (http://www.squiz.net)'.PHP_EOL;
704
  throw new DeepExitException($output, 0);
705
  case 'colors':
706
- if (isset($this->overriddenDefaults['colors']) === true) {
707
  break;
708
  }
709
 
710
  $this->colors = true;
711
- $this->overriddenDefaults['colors'] = true;
712
  break;
713
  case 'no-colors':
714
- if (isset($this->overriddenDefaults['colors']) === true) {
715
  break;
716
  }
717
 
718
  $this->colors = false;
719
- $this->overriddenDefaults['colors'] = true;
720
  break;
721
  case 'cache':
722
- if (isset($this->overriddenDefaults['cache']) === true) {
723
  break;
724
  }
725
 
726
  if (defined('PHP_CODESNIFFER_IN_TESTS') === false) {
727
  $this->cache = true;
728
- $this->overriddenDefaults['cache'] = true;
729
  }
730
  break;
731
  case 'no-cache':
732
- if (isset($this->overriddenDefaults['cache']) === true) {
733
  break;
734
  }
735
 
736
  $this->cache = false;
737
- $this->overriddenDefaults['cache'] = true;
738
  break;
739
  case 'ignore-annotations':
740
- if (isset($this->overriddenDefaults['annotations']) === true) {
741
  break;
742
  }
743
 
744
  $this->annotations = false;
745
- $this->overriddenDefaults['annotations'] = true;
746
  break;
747
  case 'config-set':
748
  if (isset($this->cliArgs[($pos + 1)]) === false
@@ -816,10 +816,15 @@ class Config
816
  $this->cliArgs[($pos + 1)] = '';
817
  $this->cliArgs[($pos + 2)] = '';
818
  self::setConfigData($key, $value, true);
 
 
 
 
 
819
  break;
820
  default:
821
  if (substr($arg, 0, 7) === 'sniffs=') {
822
- if (isset($this->overriddenDefaults['sniffs']) === true) {
823
  break;
824
  }
825
 
@@ -833,9 +838,9 @@ class Config
833
  }
834
 
835
  $this->sniffs = $sniffs;
836
- $this->overriddenDefaults['sniffs'] = true;
837
  } else if (substr($arg, 0, 8) === 'exclude=') {
838
- if (isset($this->overriddenDefaults['exclude']) === true) {
839
  break;
840
  }
841
 
@@ -849,20 +854,20 @@ class Config
849
  }
850
 
851
  $this->exclude = $sniffs;
852
- $this->overriddenDefaults['exclude'] = true;
853
  } else if (defined('PHP_CODESNIFFER_IN_TESTS') === false
854
  && substr($arg, 0, 6) === 'cache='
855
  ) {
856
- if ((isset($this->overriddenDefaults['cache']) === true
857
  && $this->cache === false)
858
- || isset($this->overriddenDefaults['cacheFile']) === true
859
  ) {
860
  break;
861
  }
862
 
863
  // Turn caching on.
864
  $this->cache = true;
865
- $this->overriddenDefaults['cache'] = true;
866
 
867
  $this->cacheFile = Util\Common::realpath(substr($arg, 6));
868
 
@@ -895,7 +900,7 @@ class Config
895
  }
896
  }//end if
897
 
898
- $this->overriddenDefaults['cacheFile'] = true;
899
 
900
  if (is_dir($this->cacheFile) === true) {
901
  $error = 'ERROR: The specified cache file path "'.$this->cacheFile.'" is a directory'.PHP_EOL.PHP_EOL;
@@ -917,7 +922,7 @@ class Config
917
  }
918
 
919
  $this->bootstrap = array_merge($this->bootstrap, $bootstrap);
920
- $this->overriddenDefaults['bootstrap'] = true;
921
  } else if (substr($arg, 0, 10) === 'file-list=') {
922
  $fileList = substr($arg, 10);
923
  $path = Util\Common::realpath($fileList);
@@ -939,7 +944,7 @@ class Config
939
  $this->processFilePath($inputFile);
940
  }
941
  } else if (substr($arg, 0, 11) === 'stdin-path=') {
942
- if (isset($this->overriddenDefaults['stdinPath']) === true) {
943
  break;
944
  }
945
 
@@ -950,9 +955,9 @@ class Config
950
  $this->stdinPath = trim(substr($arg, 11));
951
  }
952
 
953
- $this->overriddenDefaults['stdinPath'] = true;
954
  } else if (PHP_CODESNIFFER_CBF === false && substr($arg, 0, 12) === 'report-file=') {
955
- if (isset($this->overriddenDefaults['reportFile']) === true) {
956
  break;
957
  }
958
 
@@ -987,7 +992,7 @@ class Config
987
  }
988
  }//end if
989
 
990
- $this->overriddenDefaults['reportFile'] = true;
991
 
992
  if (is_dir($this->reportFile) === true) {
993
  $error = 'ERROR: The specified report file path "'.$this->reportFile.'" is a directory'.PHP_EOL.PHP_EOL;
@@ -995,18 +1000,18 @@ class Config
995
  throw new DeepExitException($error, 3);
996
  }
997
  } else if (substr($arg, 0, 13) === 'report-width=') {
998
- if (isset($this->overriddenDefaults['reportWidth']) === true) {
999
  break;
1000
  }
1001
 
1002
  $this->reportWidth = substr($arg, 13);
1003
- $this->overriddenDefaults['reportWidth'] = true;
1004
  } else if (substr($arg, 0, 9) === 'basepath=') {
1005
- if (isset($this->overriddenDefaults['basepath']) === true) {
1006
  break;
1007
  }
1008
 
1009
- $this->overriddenDefaults['basepath'] = true;
1010
 
1011
  if (substr($arg, 9) === '') {
1012
  $this->basepath = null;
@@ -1041,6 +1046,12 @@ class Config
1041
  $output = null;
1042
  } else {
1043
  $dir = dirname($output);
 
 
 
 
 
 
1044
  if ($dir === '.') {
1045
  // Passed report file is a filename in the current directory.
1046
  $output = getcwd().'/'.basename($output);
@@ -1063,7 +1074,7 @@ class Config
1063
  $reports[$report] = $output;
1064
  } else {
1065
  // This is a single report.
1066
- if (isset($this->overriddenDefaults['reports']) === true) {
1067
  break;
1068
  }
1069
 
@@ -1074,29 +1085,29 @@ class Config
1074
  }//end if
1075
 
1076
  // Remove the default value so the CLI value overrides it.
1077
- if (isset($this->overriddenDefaults['reports']) === false) {
1078
  $this->reports = $reports;
1079
  } else {
1080
  $this->reports = array_merge($this->reports, $reports);
1081
  }
1082
 
1083
- $this->overriddenDefaults['reports'] = true;
1084
  } else if (substr($arg, 0, 7) === 'filter=') {
1085
- if (isset($this->overriddenDefaults['filter']) === true) {
1086
  break;
1087
  }
1088
 
1089
  $this->filter = substr($arg, 7);
1090
- $this->overriddenDefaults['filter'] = true;
1091
  } else if (substr($arg, 0, 9) === 'standard=') {
1092
  $standards = trim(substr($arg, 9));
1093
  if ($standards !== '') {
1094
  $this->standards = explode(',', $standards);
1095
  }
1096
 
1097
- $this->overriddenDefaults['standards'] = true;
1098
  } else if (substr($arg, 0, 11) === 'extensions=') {
1099
- if (isset($this->overriddenDefaults['extensions']) === true) {
1100
  break;
1101
  }
1102
 
@@ -1119,47 +1130,47 @@ class Config
1119
  }
1120
 
1121
  $this->extensions = $newExtensions;
1122
- $this->overriddenDefaults['extensions'] = true;
1123
  } else if (substr($arg, 0, 7) === 'suffix=') {
1124
- if (isset($this->overriddenDefaults['suffix']) === true) {
1125
  break;
1126
  }
1127
 
1128
  $this->suffix = substr($arg, 7);
1129
- $this->overriddenDefaults['suffix'] = true;
1130
  } else if (substr($arg, 0, 9) === 'parallel=') {
1131
- if (isset($this->overriddenDefaults['parallel']) === true) {
1132
  break;
1133
  }
1134
 
1135
  $this->parallel = max((int) substr($arg, 9), 1);
1136
- $this->overriddenDefaults['parallel'] = true;
1137
  } else if (substr($arg, 0, 9) === 'severity=') {
1138
  $this->errorSeverity = (int) substr($arg, 9);
1139
  $this->warningSeverity = $this->errorSeverity;
1140
- if (isset($this->overriddenDefaults['errorSeverity']) === false) {
1141
- $this->overriddenDefaults['errorSeverity'] = true;
1142
  }
1143
 
1144
- if (isset($this->overriddenDefaults['warningSeverity']) === false) {
1145
- $this->overriddenDefaults['warningSeverity'] = true;
1146
  }
1147
  } else if (substr($arg, 0, 15) === 'error-severity=') {
1148
- if (isset($this->overriddenDefaults['errorSeverity']) === true) {
1149
  break;
1150
  }
1151
 
1152
  $this->errorSeverity = (int) substr($arg, 15);
1153
- $this->overriddenDefaults['errorSeverity'] = true;
1154
  } else if (substr($arg, 0, 17) === 'warning-severity=') {
1155
- if (isset($this->overriddenDefaults['warningSeverity']) === true) {
1156
  break;
1157
  }
1158
 
1159
  $this->warningSeverity = (int) substr($arg, 17);
1160
- $this->overriddenDefaults['warningSeverity'] = true;
1161
  } else if (substr($arg, 0, 7) === 'ignore=') {
1162
- if (isset($this->overriddenDefaults['ignored']) === true) {
1163
  break;
1164
  }
1165
 
@@ -1181,30 +1192,30 @@ class Config
1181
  }
1182
 
1183
  $this->ignored = $ignored;
1184
- $this->overriddenDefaults['ignored'] = true;
1185
  } else if (substr($arg, 0, 10) === 'generator='
1186
  && PHP_CODESNIFFER_CBF === false
1187
  ) {
1188
- if (isset($this->overriddenDefaults['generator']) === true) {
1189
  break;
1190
  }
1191
 
1192
  $this->generator = substr($arg, 10);
1193
- $this->overriddenDefaults['generator'] = true;
1194
  } else if (substr($arg, 0, 9) === 'encoding=') {
1195
- if (isset($this->overriddenDefaults['encoding']) === true) {
1196
  break;
1197
  }
1198
 
1199
  $this->encoding = strtolower(substr($arg, 9));
1200
- $this->overriddenDefaults['encoding'] = true;
1201
  } else if (substr($arg, 0, 10) === 'tab-width=') {
1202
- if (isset($this->overriddenDefaults['tabWidth']) === true) {
1203
  break;
1204
  }
1205
 
1206
  $this->tabWidth = (int) substr($arg, 10);
1207
- $this->overriddenDefaults['tabWidth'] = true;
1208
  } else {
1209
  if ($this->dieOnUnknownArg === false) {
1210
  $eqPos = strpos($arg, '=');
@@ -1281,10 +1292,12 @@ class Config
1281
  $error .= $this->printShortUsage(true);
1282
  throw new DeepExitException($error, 3);
1283
  } else {
 
 
1284
  $files = $this->files;
1285
  $files[] = $file;
1286
  $this->files = $files;
1287
- $this->overriddenDefaults['files'] = true;
1288
  }
1289
 
1290
  }//end processFilePath()
@@ -1503,6 +1516,11 @@ class Config
1503
  return $data;
1504
  }
1505
 
 
 
 
 
 
1506
  if (array_key_exists($name, self::$executablePaths) === true) {
1507
  return self::$executablePaths[$name];
1508
  }
@@ -1541,6 +1559,12 @@ class Config
1541
  */
1542
  public static function setConfigData($key, $value, $temp=false)
1543
  {
 
 
 
 
 
 
1544
  if ($temp === false) {
1545
  $path = '';
1546
  if (is_callable('\Phar::running') === true) {
23
  *
24
  * @var string
25
  */
26
+ const VERSION = '3.3.2';
27
 
28
  /**
29
  * Package stability; either stable, beta or alpha.
158
  *
159
  * @var array<string, TRUE>
160
  */
161
+ private static $overriddenDefaults = [];
162
 
163
  /**
164
  * Config file data that has been loaded for the run.
334
  $this->restoreDefaults();
335
  $this->setCommandLineValues($cliArgs);
336
 
337
+ if (isset(self::$overriddenDefaults['standards']) === false) {
338
  // They did not supply a standard to use.
339
  // Look for a default ruleset in the current directory or higher.
340
  $currentDir = getcwd();
389
  if (trim($fileContents) !== '') {
390
  $this->stdin = true;
391
  $this->stdinContent = $fileContents;
392
+ self::$overriddenDefaults['stdin'] = true;
393
+ self::$overriddenDefaults['stdinContent'] = true;
394
  }
395
  }//end if
396
 
421
  if ($arg === '-') {
422
  // Asking to read from STDIN.
423
  $this->stdin = true;
424
+ self::$overriddenDefaults['stdin'] = true;
425
  continue;
426
  }
427
 
608
  }
609
 
610
  $this->verbosity++;
611
+ self::$overriddenDefaults['verbosity'] = true;
612
  break;
613
  case 'l' :
614
  $this->local = true;
615
+ self::$overriddenDefaults['local'] = true;
616
  break;
617
  case 's' :
618
  $this->showSources = true;
619
+ self::$overriddenDefaults['showSources'] = true;
620
  break;
621
  case 'a' :
622
  $this->interactive = true;
623
+ self::$overriddenDefaults['interactive'] = true;
624
  break;
625
  case 'e':
626
  $this->explain = true;
627
+ self::$overriddenDefaults['explain'] = true;
628
  break;
629
  case 'p' :
630
  if ($this->quiet === true) {
633
  }
634
 
635
  $this->showProgress = true;
636
+ self::$overriddenDefaults['showProgress'] = true;
637
  break;
638
  case 'q' :
639
  // Quiet mode disables a few other settings as well.
641
  $this->showProgress = false;
642
  $this->verbosity = 0;
643
 
644
+ self::$overriddenDefaults['quiet'] = true;
645
  break;
646
  case 'm' :
647
  $this->recordErrors = false;
648
+ self::$overriddenDefaults['recordErrors'] = true;
649
  break;
650
  case 'd' :
651
  $ini = explode('=', $this->cliArgs[($pos + 1)]);
657
  }
658
  break;
659
  case 'n' :
660
+ if (isset(self::$overriddenDefaults['warningSeverity']) === false) {
661
  $this->warningSeverity = 0;
662
+ self::$overriddenDefaults['warningSeverity'] = true;
663
  }
664
  break;
665
  case 'w' :
666
+ if (isset(self::$overriddenDefaults['warningSeverity']) === false) {
667
  $this->warningSeverity = $this->errorSeverity;
668
+ self::$overriddenDefaults['warningSeverity'] = true;
669
  }
670
  break;
671
  default:
703
  $output .= 'by Squiz (http://www.squiz.net)'.PHP_EOL;
704
  throw new DeepExitException($output, 0);
705
  case 'colors':
706
+ if (isset(self::$overriddenDefaults['colors']) === true) {
707
  break;
708
  }
709
 
710
  $this->colors = true;
711
+ self::$overriddenDefaults['colors'] = true;
712
  break;
713
  case 'no-colors':
714
+ if (isset(self::$overriddenDefaults['colors']) === true) {
715
  break;
716
  }
717
 
718
  $this->colors = false;
719
+ self::$overriddenDefaults['colors'] = true;
720
  break;
721
  case 'cache':
722
+ if (isset(self::$overriddenDefaults['cache']) === true) {
723
  break;
724
  }
725
 
726
  if (defined('PHP_CODESNIFFER_IN_TESTS') === false) {
727
  $this->cache = true;
728
+ self::$overriddenDefaults['cache'] = true;
729
  }
730
  break;
731
  case 'no-cache':
732
+ if (isset(self::$overriddenDefaults['cache']) === true) {
733
  break;
734
  }
735
 
736
  $this->cache = false;
737
+ self::$overriddenDefaults['cache'] = true;
738
  break;
739
  case 'ignore-annotations':
740
+ if (isset(self::$overriddenDefaults['annotations']) === true) {
741
  break;
742
  }
743
 
744
  $this->annotations = false;
745
+ self::$overriddenDefaults['annotations'] = true;
746
  break;
747
  case 'config-set':
748
  if (isset($this->cliArgs[($pos + 1)]) === false
816
  $this->cliArgs[($pos + 1)] = '';
817
  $this->cliArgs[($pos + 2)] = '';
818
  self::setConfigData($key, $value, true);
819
+ if (isset(self::$overriddenDefaults['runtime-set']) === false) {
820
+ self::$overriddenDefaults['runtime-set'] = [];
821
+ }
822
+
823
+ self::$overriddenDefaults['runtime-set'][$key] = true;
824
  break;
825
  default:
826
  if (substr($arg, 0, 7) === 'sniffs=') {
827
+ if (isset(self::$overriddenDefaults['sniffs']) === true) {
828
  break;
829
  }
830
 
838
  }
839
 
840
  $this->sniffs = $sniffs;
841
+ self::$overriddenDefaults['sniffs'] = true;
842
  } else if (substr($arg, 0, 8) === 'exclude=') {
843
+ if (isset(self::$overriddenDefaults['exclude']) === true) {
844
  break;
845
  }
846
 
854
  }
855
 
856
  $this->exclude = $sniffs;
857
+ self::$overriddenDefaults['exclude'] = true;
858
  } else if (defined('PHP_CODESNIFFER_IN_TESTS') === false
859
  && substr($arg, 0, 6) === 'cache='
860
  ) {
861
+ if ((isset(self::$overriddenDefaults['cache']) === true
862
  && $this->cache === false)
863
+ || isset(self::$overriddenDefaults['cacheFile']) === true
864
  ) {
865
  break;
866
  }
867
 
868
  // Turn caching on.
869
  $this->cache = true;
870
+ self::$overriddenDefaults['cache'] = true;
871
 
872
  $this->cacheFile = Util\Common::realpath(substr($arg, 6));
873
 
900
  }
901
  }//end if
902
 
903
+ self::$overriddenDefaults['cacheFile'] = true;
904
 
905
  if (is_dir($this->cacheFile) === true) {
906
  $error = 'ERROR: The specified cache file path "'.$this->cacheFile.'" is a directory'.PHP_EOL.PHP_EOL;
922
  }
923
 
924
  $this->bootstrap = array_merge($this->bootstrap, $bootstrap);
925
+ self::$overriddenDefaults['bootstrap'] = true;
926
  } else if (substr($arg, 0, 10) === 'file-list=') {
927
  $fileList = substr($arg, 10);
928
  $path = Util\Common::realpath($fileList);
944
  $this->processFilePath($inputFile);
945
  }
946
  } else if (substr($arg, 0, 11) === 'stdin-path=') {
947
+ if (isset(self::$overriddenDefaults['stdinPath']) === true) {
948
  break;
949
  }
950
 
955
  $this->stdinPath = trim(substr($arg, 11));
956
  }
957
 
958
+ self::$overriddenDefaults['stdinPath'] = true;
959
  } else if (PHP_CODESNIFFER_CBF === false && substr($arg, 0, 12) === 'report-file=') {
960
+ if (isset(self::$overriddenDefaults['reportFile']) === true) {
961
  break;
962
  }
963
 
992
  }
993
  }//end if
994
 
995
+ self::$overriddenDefaults['reportFile'] = true;
996
 
997
  if (is_dir($this->reportFile) === true) {
998
  $error = 'ERROR: The specified report file path "'.$this->reportFile.'" is a directory'.PHP_EOL.PHP_EOL;
1000
  throw new DeepExitException($error, 3);
1001
  }
1002
  } else if (substr($arg, 0, 13) === 'report-width=') {
1003
+ if (isset(self::$overriddenDefaults['reportWidth']) === true) {
1004
  break;
1005
  }
1006
 
1007
  $this->reportWidth = substr($arg, 13);
1008
+ self::$overriddenDefaults['reportWidth'] = true;
1009
  } else if (substr($arg, 0, 9) === 'basepath=') {
1010
+ if (isset(self::$overriddenDefaults['basepath']) === true) {
1011
  break;
1012
  }
1013
 
1014
+ self::$overriddenDefaults['basepath'] = true;
1015
 
1016
  if (substr($arg, 9) === '') {
1017
  $this->basepath = null;
1046
  $output = null;
1047
  } else {
1048
  $dir = dirname($output);
1049
+ if (is_dir($dir) === false) {
1050
+ $error = 'ERROR: The specified '.$report.' report file path "'.$output.'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
1051
+ $error .= $this->printShortUsage(true);
1052
+ throw new DeepExitException($error, 3);
1053
+ }
1054
+
1055
  if ($dir === '.') {
1056
  // Passed report file is a filename in the current directory.
1057
  $output = getcwd().'/'.basename($output);
1074
  $reports[$report] = $output;
1075
  } else {
1076
  // This is a single report.
1077
+ if (isset(self::$overriddenDefaults['reports']) === true) {
1078
  break;
1079
  }
1080
 
1085
  }//end if
1086
 
1087
  // Remove the default value so the CLI value overrides it.
1088
+ if (isset(self::$overriddenDefaults['reports']) === false) {
1089
  $this->reports = $reports;
1090
  } else {
1091
  $this->reports = array_merge($this->reports, $reports);
1092
  }
1093
 
1094
+ self::$overriddenDefaults['reports'] = true;
1095
  } else if (substr($arg, 0, 7) === 'filter=') {
1096
+ if (isset(self::$overriddenDefaults['filter']) === true) {
1097
  break;
1098
  }
1099
 
1100
  $this->filter = substr($arg, 7);
1101
+ self::$overriddenDefaults['filter'] = true;
1102
  } else if (substr($arg, 0, 9) === 'standard=') {
1103
  $standards = trim(substr($arg, 9));
1104
  if ($standards !== '') {
1105
  $this->standards = explode(',', $standards);
1106
  }
1107
 
1108
+ self::$overriddenDefaults['standards'] = true;
1109
  } else if (substr($arg, 0, 11) === 'extensions=') {
1110
+ if (isset(self::$overriddenDefaults['extensions']) === true) {
1111
  break;
1112
  }
1113
 
1130
  }
1131
 
1132
  $this->extensions = $newExtensions;
1133
+ self::$overriddenDefaults['extensions'] = true;
1134
  } else if (substr($arg, 0, 7) === 'suffix=') {
1135
+ if (isset(self::$overriddenDefaults['suffix']) === true) {
1136
  break;
1137
  }
1138
 
1139
  $this->suffix = substr($arg, 7);
1140
+ self::$overriddenDefaults['suffix'] = true;
1141
  } else if (substr($arg, 0, 9) === 'parallel=') {
1142
+ if (isset(self::$overriddenDefaults['parallel']) === true) {
1143
  break;
1144
  }
1145
 
1146
  $this->parallel = max((int) substr($arg, 9), 1);
1147
+ self::$overriddenDefaults['parallel'] = true;
1148
  } else if (substr($arg, 0, 9) === 'severity=') {
1149
  $this->errorSeverity = (int) substr($arg, 9);
1150
  $this->warningSeverity = $this->errorSeverity;
1151
+ if (isset(self::$overriddenDefaults['errorSeverity']) === false) {
1152
+ self::$overriddenDefaults['errorSeverity'] = true;
1153
  }
1154
 
1155
+ if (isset(self::$overriddenDefaults['warningSeverity']) === false) {
1156
+ self::$overriddenDefaults['warningSeverity'] = true;
1157
  }
1158
  } else if (substr($arg, 0, 15) === 'error-severity=') {
1159
+ if (isset(self::$overriddenDefaults['errorSeverity']) === true) {
1160
  break;
1161
  }
1162
 
1163
  $this->errorSeverity = (int) substr($arg, 15);
1164
+ self::$overriddenDefaults['errorSeverity'] = true;
1165
  } else if (substr($arg, 0, 17) === 'warning-severity=') {
1166
+ if (isset(self::$overriddenDefaults['warningSeverity']) === true) {
1167
  break;
1168
  }
1169
 
1170
  $this->warningSeverity = (int) substr($arg, 17);
1171
+ self::$overriddenDefaults['warningSeverity'] = true;
1172
  } else if (substr($arg, 0, 7) === 'ignore=') {
1173
+ if (isset(self::$overriddenDefaults['ignored']) === true) {
1174
  break;
1175
  }
1176
 
1192
  }
1193
 
1194
  $this->ignored = $ignored;
1195
+ self::$overriddenDefaults['ignored'] = true;
1196
  } else if (substr($arg, 0, 10) === 'generator='
1197
  && PHP_CODESNIFFER_CBF === false
1198
  ) {
1199
+ if (isset(self::$overriddenDefaults['generator']) === true) {
1200
  break;
1201
  }
1202
 
1203
  $this->generator = substr($arg, 10);
1204
+ self::$overriddenDefaults['generator'] = true;
1205
  } else if (substr($arg, 0, 9) === 'encoding=') {
1206
+ if (isset(self::$overriddenDefaults['encoding']) === true) {
1207
  break;
1208
  }
1209
 
1210
  $this->encoding = strtolower(substr($arg, 9));
1211
+ self::$overriddenDefaults['encoding'] = true;
1212
  } else if (substr($arg, 0, 10) === 'tab-width=') {
1213
+ if (isset(self::$overriddenDefaults['tabWidth']) === true) {
1214
  break;
1215
  }
1216
 
1217
  $this->tabWidth = (int) substr($arg, 10);
1218
+ self::$overriddenDefaults['tabWidth'] = true;
1219
  } else {
1220
  if ($this->dieOnUnknownArg === false) {
1221
  $eqPos = strpos($arg, '=');
1292
  $error .= $this->printShortUsage(true);
1293
  throw new DeepExitException($error, 3);
1294
  } else {
1295
+ // Can't modify the files array directly because it's not a real
1296
+ // class member, so need to use this little get/modify/set trick.
1297
  $files = $this->files;
1298
  $files[] = $file;
1299
  $this->files = $files;
1300
+ self::$overriddenDefaults['files'] = true;
1301
  }
1302
 
1303
  }//end processFilePath()
1516
  return $data;
1517
  }
1518
 
1519
+ if ($name === "php") {
1520
+ // For php, we know the executable path. There's no need to look it up.
1521
+ return PHP_BINARY;
1522
+ }
1523
+
1524
  if (array_key_exists($name, self::$executablePaths) === true) {
1525
  return self::$executablePaths[$name];
1526
  }
1559
  */
1560
  public static function setConfigData($key, $value, $temp=false)
1561
  {
1562
+ if (isset(self::$overriddenDefaults['runtime-set']) === true
1563
+ && isset(self::$overriddenDefaults['runtime-set'][$key]) === true
1564
+ ) {
1565
+ return false;
1566
+ }
1567
+
1568
  if ($temp === false) {
1569
  $path = '';
1570
  if (is_callable('\Phar::running') === true) {
vendor/squizlabs/php_codesniffer/src/Files/File.php CHANGED
@@ -50,7 +50,7 @@ class File
50
  /**
51
  * If TRUE, the entire file is being ignored.
52
  *
53
- * @var string
54
  */
55
  public $ignored = false;
56
 
@@ -75,6 +75,13 @@ class File
75
  */
76
  public $tokenizer = null;
77
 
 
 
 
 
 
 
 
78
  /**
79
  * Was the file loaded from cache?
80
  *
@@ -239,7 +246,8 @@ class File
239
  $this->configCache['errorSeverity'] = $this->config->errorSeverity;
240
  $this->configCache['warningSeverity'] = $this->config->warningSeverity;
241
  $this->configCache['recordErrors'] = $this->config->recordErrors;
242
- $this->configCache['ignorePatterns'] = $this->ruleset->getIgnorePatterns();
 
243
 
244
  }//end __construct()
245
 
@@ -351,9 +359,9 @@ class File
351
  $start = strpos($commentText, '@codingStandardsChangeSetting');
352
  $comment = substr($commentText, ($start + 30));
353
  $parts = explode(' ', $comment);
354
- if ($parts >= 3) {
355
  $sniffParts = explode('.', $parts[0]);
356
- if ($sniffParts >= 3) {
357
  // If the sniff code is not known to us, it has not been registered in this run.
358
  // But don't throw an error as it could be there for a different standard to use.
359
  if (isset($this->ruleset->sniffCodes[$parts[0]]) === true) {
@@ -380,16 +388,16 @@ class File
380
  || substr($commentTextLower, 0, 10) === '@phpcs:set'
381
  ) {
382
  // If the @phpcs: syntax is being used, strip the @ to make
383
- // comparisions easier.
384
  if ($commentText[0] === '@') {
385
  $commentText = substr($commentText, 1);
386
  }
387
 
388
  // Need to maintain case here, to get the correct sniff code.
389
  $parts = explode(' ', substr($commentText, 10));
390
- if ($parts >= 3) {
391
  $sniffParts = explode('.', $parts[0]);
392
- if ($sniffParts >= 3) {
393
  // If the sniff code is not known to us, it has not been registered in this run.
394
  // But don't throw an error as it could be there for a different standard to use.
395
  if (isset($this->ruleset->sniffCodes[$parts[0]]) === true) {
@@ -826,7 +834,7 @@ class File
826
  protected function addMessage($error, $message, $line, $column, $code, $data, $severity, $fixable)
827
  {
828
  // Check if this line is ignoring all message codes.
829
- if (isset($this->tokenizer->ignoredLines[$line]['all']) === true) {
830
  return false;
831
  }
832
 
@@ -856,12 +864,32 @@ class File
856
  ];
857
  }//end if
858
 
859
- // Check if this line is ignoring this specific message.
860
- foreach ($checkCodes as $checkCode) {
861
- if (isset($this->tokenizer->ignoredLines[$line][$checkCode]) === true) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862
  return false;
863
  }
864
- }
865
 
866
  $includeAll = true;
867
  if ($this->configCache['cache'] === false
@@ -937,11 +965,21 @@ class File
937
 
938
  // Make sure we are not ignoring this file.
939
  foreach ($checkCodes as $checkCode) {
940
- if (isset($this->configCache['ignorePatterns'][$checkCode]) === false) {
 
 
 
 
 
 
 
 
 
 
941
  continue;
942
  }
943
 
944
- foreach ($this->configCache['ignorePatterns'][$checkCode] as $pattern => $type) {
945
  // While there is support for a type of each pattern
946
  // (absolute or relative) we don't actually support it here.
947
  $replacements = [
@@ -957,7 +995,11 @@ class File
957
  }
958
 
959
  $pattern = '`'.strtr($pattern, $replacements).'`i';
960
- if (preg_match($pattern, $this->path) === 1) {
 
 
 
 
961
  $this->ignoredCodes[$checkCode] = true;
962
  return false;
963
  }
@@ -1224,6 +1266,8 @@ class File
1224
  * 'pass_by_reference' => boolean, // Is the variable passed by reference?
1225
  * 'variable_length' => boolean, // Is the param of variable length through use of `...` ?
1226
  * 'type_hint' => string, // The type hint for the variable.
 
 
1227
  * 'nullable_type' => boolean, // Is the variable using a nullable type?
1228
  * )
1229
  * </code>
@@ -1257,6 +1301,7 @@ class File
1257
  $passByReference = false;
1258
  $variableLength = false;
1259
  $typeHint = '';
 
1260
  $nullableType = false;
1261
 
1262
  for ($i = $paramStart; $i <= $closer; $i++) {
@@ -1290,8 +1335,11 @@ class File
1290
  case T_ELLIPSIS:
1291
  $variableLength = true;
1292
  break;
1293
- case T_ARRAY_HINT:
1294
  case T_CALLABLE:
 
 
 
 
1295
  $typeHint .= $this->tokens[$i]['content'];
1296
  break;
1297
  case T_SELF:
@@ -1299,6 +1347,10 @@ class File
1299
  case T_STATIC:
1300
  // Self is valid, the others invalid, but were probably intended as type hints.
1301
  if (isset($defaultStart) === false) {
 
 
 
 
1302
  $typeHint .= $this->tokens[$i]['content'];
1303
  }
1304
  break;
@@ -1328,12 +1380,20 @@ class File
1328
  }
1329
 
1330
  if ($defaultStart === null) {
 
 
 
 
1331
  $typeHint .= $this->tokens[$i]['content'];
1332
  }
1333
  break;
1334
  case T_NS_SEPARATOR:
1335
  // Part of a type hint or default value.
1336
  if ($defaultStart === null) {
 
 
 
 
1337
  $typeHint .= $this->tokens[$i]['content'];
1338
  }
1339
  break;
@@ -1348,7 +1408,7 @@ class File
1348
  // If it's null, then there must be no parameters for this
1349
  // method.
1350
  if ($currVar === null) {
1351
- continue;
1352
  }
1353
 
1354
  $vars[$paramCount] = [];
@@ -1363,6 +1423,7 @@ class File
1363
  $vars[$paramCount]['pass_by_reference'] = $passByReference;
1364
  $vars[$paramCount]['variable_length'] = $variableLength;
1365
  $vars[$paramCount]['type_hint'] = $typeHint;
 
1366
  $vars[$paramCount]['nullable_type'] = $nullableType;
1367
 
1368
  // Reset the vars, as we are about to process the next parameter.
@@ -1371,6 +1432,7 @@ class File
1371
  $passByReference = false;
1372
  $variableLength = false;
1373
  $typeHint = '';
 
1374
  $nullableType = false;
1375
 
1376
  $paramCount++;
@@ -1392,11 +1454,15 @@ class File
1392
  * The format of the array is:
1393
  * <code>
1394
  * array(
1395
- * 'scope' => 'public', // public protected or protected
1396
- * 'scope_specified' => true, // true is scope keyword was found.
1397
- * 'is_abstract' => false, // true if the abstract keyword was found.
1398
- * 'is_final' => false, // true if the final keyword was found.
1399
- * 'is_static' => false, // true if the static keyword was found.
 
 
 
 
1400
  * );
1401
  * </code>
1402
  *
@@ -1472,12 +1538,59 @@ class File
1472
  }//end switch
1473
  }//end for
1474
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1475
  return [
1476
- 'scope' => $scope,
1477
- 'scope_specified' => $scopeSpecified,
1478
- 'is_abstract' => $isAbstract,
1479
- 'is_final' => $isFinal,
1480
- 'is_static' => $isStatic,
 
 
 
1481
  ];
1482
 
1483
  }//end getMethodProperties()
@@ -1491,8 +1604,9 @@ class File
1491
  *
1492
  * <code>
1493
  * array(
1494
- * 'scope' => 'public', // public protected or protected
1495
- * 'is_static' => false, // true if the static keyword was found.
 
1496
  * );
1497
  * </code>
1498
  *
@@ -1537,22 +1651,29 @@ class File
1537
  }
1538
 
1539
  $valid = [
1540
- T_PUBLIC => T_PUBLIC,
1541
- T_PRIVATE => T_PRIVATE,
1542
- T_PROTECTED => T_PROTECTED,
1543
- T_STATIC => T_STATIC,
1544
- T_WHITESPACE => T_WHITESPACE,
1545
- T_COMMENT => T_COMMENT,
1546
- T_DOC_COMMENT => T_DOC_COMMENT,
1547
- T_VARIABLE => T_VARIABLE,
1548
- T_COMMA => T_COMMA,
1549
  ];
1550
 
 
 
1551
  $scope = 'public';
1552
  $scopeSpecified = false;
1553
  $isStatic = false;
1554
 
1555
- for ($i = ($stackPtr - 1); $i > 0; $i--) {
 
 
 
 
 
 
 
 
 
1556
  if (isset($valid[$this->tokens[$i]['code']]) === false) {
1557
  break;
1558
  }
@@ -1781,12 +1902,14 @@ class File
1781
  * Returns the content of the tokens from the specified start position in
1782
  * the token stack for the specified length.
1783
  *
1784
- * @param int $start The position to start from in the token stack.
1785
- * @param int $length The length of tokens to traverse from the start pos.
 
 
1786
  *
1787
  * @return string The token contents.
1788
  */
1789
- public function getTokensAsString($start, $length)
1790
  {
1791
  $str = '';
1792
  $end = ($start + $length);
@@ -1795,7 +1918,13 @@ class File
1795
  }
1796
 
1797
  for ($i = $start; $i < $end; $i++) {
1798
- $str .= $this->tokens[$i]['content'];
 
 
 
 
 
 
1799
  }
1800
 
1801
  return $str;
@@ -2071,6 +2200,10 @@ class File
2071
  && ($i === $this->tokens[$i]['scope_opener']
2072
  || $i === $this->tokens[$i]['scope_condition'])
2073
  ) {
 
 
 
 
2074
  $i = $this->tokens[$i]['scope_closer'];
2075
  } else if (isset($this->tokens[$i]['bracket_closer']) === true
2076
  && $i === $this->tokens[$i]['bracket_opener']
@@ -2244,12 +2377,12 @@ class File
2244
  return false;
2245
  }
2246
 
2247
- if (isset($this->tokens[$stackPtr]['scope_closer']) === false) {
2248
  return false;
2249
  }
2250
 
2251
- $classCloserIndex = $this->tokens[$stackPtr]['scope_closer'];
2252
- $extendsIndex = $this->findNext(T_EXTENDS, $stackPtr, $classCloserIndex);
2253
  if (false === $extendsIndex) {
2254
  return false;
2255
  }
@@ -2260,7 +2393,7 @@ class File
2260
  T_WHITESPACE,
2261
  ];
2262
 
2263
- $end = $this->findNext($find, ($extendsIndex + 1), $classCloserIndex, true);
2264
  $name = $this->getTokensAsString(($extendsIndex + 1), ($end - $extendsIndex - 1));
2265
  $name = trim($name);
2266
 
50
  /**
51
  * If TRUE, the entire file is being ignored.
52
  *
53
+ * @var boolean
54
  */
55
  public $ignored = false;
56
 
75
  */
76
  public $tokenizer = null;
77
 
78
+ /**
79
+ * The name of the tokenizer being used for this file.
80
+ *
81
+ * @var string
82
+ */
83
+ public $tokenizerType = 'PHP';
84
+
85
  /**
86
  * Was the file loaded from cache?
87
  *
246
  $this->configCache['errorSeverity'] = $this->config->errorSeverity;
247
  $this->configCache['warningSeverity'] = $this->config->warningSeverity;
248
  $this->configCache['recordErrors'] = $this->config->recordErrors;
249
+ $this->configCache['ignorePatterns'] = $this->ruleset->ignorePatterns;
250
+ $this->configCache['includePatterns'] = $this->ruleset->includePatterns;
251
 
252
  }//end __construct()
253
 
359
  $start = strpos($commentText, '@codingStandardsChangeSetting');
360
  $comment = substr($commentText, ($start + 30));
361
  $parts = explode(' ', $comment);
362
+ if (count($parts) >= 2) {
363
  $sniffParts = explode('.', $parts[0]);
364
+ if (count($sniffParts) >= 3) {
365
  // If the sniff code is not known to us, it has not been registered in this run.
366
  // But don't throw an error as it could be there for a different standard to use.
367
  if (isset($this->ruleset->sniffCodes[$parts[0]]) === true) {
388
  || substr($commentTextLower, 0, 10) === '@phpcs:set'
389
  ) {
390
  // If the @phpcs: syntax is being used, strip the @ to make
391
+ // comparisons easier.
392
  if ($commentText[0] === '@') {
393
  $commentText = substr($commentText, 1);
394
  }
395
 
396
  // Need to maintain case here, to get the correct sniff code.
397
  $parts = explode(' ', substr($commentText, 10));
398
+ if (count($parts) >= 2) {
399
  $sniffParts = explode('.', $parts[0]);
400
+ if (count($sniffParts) >= 3) {
401
  // If the sniff code is not known to us, it has not been registered in this run.
402
  // But don't throw an error as it could be there for a different standard to use.
403
  if (isset($this->ruleset->sniffCodes[$parts[0]]) === true) {
834
  protected function addMessage($error, $message, $line, $column, $code, $data, $severity, $fixable)
835
  {
836
  // Check if this line is ignoring all message codes.
837
+ if (isset($this->tokenizer->ignoredLines[$line]['.all']) === true) {
838
  return false;
839
  }
840
 
864
  ];
865
  }//end if
866
 
867
+ if (isset($this->tokenizer->ignoredLines[$line]) === true) {
868
+ // Check if this line is ignoring this specific message.
869
+ $ignored = false;
870
+ foreach ($checkCodes as $checkCode) {
871
+ if (isset($this->tokenizer->ignoredLines[$line][$checkCode]) === true) {
872
+ $ignored = true;
873
+ break;
874
+ }
875
+ }
876
+
877
+ // If it is ignored, make sure it's not whitelisted.
878
+ if ($ignored === true
879
+ && isset($this->tokenizer->ignoredLines[$line]['.except']) === true
880
+ ) {
881
+ foreach ($checkCodes as $checkCode) {
882
+ if (isset($this->tokenizer->ignoredLines[$line]['.except'][$checkCode]) === true) {
883
+ $ignored = false;
884
+ break;
885
+ }
886
+ }
887
+ }
888
+
889
+ if ($ignored === true) {
890
  return false;
891
  }
892
+ }//end if
893
 
894
  $includeAll = true;
895
  if ($this->configCache['cache'] === false
965
 
966
  // Make sure we are not ignoring this file.
967
  foreach ($checkCodes as $checkCode) {
968
+ $patterns = null;
969
+
970
+ if (isset($this->configCache['includePatterns'][$checkCode]) === true) {
971
+ $patterns = $this->configCache['includePatterns'][$checkCode];
972
+ $excluding = false;
973
+ } else if (isset($this->configCache['ignorePatterns'][$checkCode]) === true) {
974
+ $patterns = $this->configCache['ignorePatterns'][$checkCode];
975
+ $excluding = true;
976
+ }
977
+
978
+ if ($patterns === null) {
979
  continue;
980
  }
981
 
982
+ foreach ($patterns as $pattern => $type) {
983
  // While there is support for a type of each pattern
984
  // (absolute or relative) we don't actually support it here.
985
  $replacements = [
995
  }
996
 
997
  $pattern = '`'.strtr($pattern, $replacements).'`i';
998
+ $matched = preg_match($pattern, $this->path);
999
+ if (($matched === 1 && $excluding === true)
1000
+ || ($matched === 0 && $excluding === false)
1001
+ ) {
1002
+ // This file path is being excluded, or not included.
1003
  $this->ignoredCodes[$checkCode] = true;
1004
  return false;
1005
  }
1266
  * 'pass_by_reference' => boolean, // Is the variable passed by reference?
1267
  * 'variable_length' => boolean, // Is the param of variable length through use of `...` ?
1268
  * 'type_hint' => string, // The type hint for the variable.
1269
+ * 'type_hint_token' => integer, // The stack pointer to the type hint
1270
+ * // or false if there is no type hint.
1271
  * 'nullable_type' => boolean, // Is the variable using a nullable type?
1272
  * )
1273
  * </code>
1301
  $passByReference = false;
1302
  $variableLength = false;
1303
  $typeHint = '';
1304
+ $typeHintToken = false;
1305
  $nullableType = false;
1306
 
1307
  for ($i = $paramStart; $i <= $closer; $i++) {
1335
  case T_ELLIPSIS:
1336
  $variableLength = true;
1337
  break;
 
1338
  case T_CALLABLE:
1339
+ if ($typeHintToken === false) {
1340
+ $typeHintToken = $i;
1341
+ }
1342
+
1343
  $typeHint .= $this->tokens[$i]['content'];
1344
  break;
1345
  case T_SELF:
1347
  case T_STATIC:
1348
  // Self is valid, the others invalid, but were probably intended as type hints.
1349
  if (isset($defaultStart) === false) {
1350
+ if ($typeHintToken === false) {
1351
+ $typeHintToken = $i;
1352
+ }
1353
+
1354
  $typeHint .= $this->tokens[$i]['content'];
1355
  }
1356
  break;
1380
  }
1381
 
1382
  if ($defaultStart === null) {
1383
+ if ($typeHintToken === false) {
1384
+ $typeHintToken = $i;
1385
+ }
1386
+
1387
  $typeHint .= $this->tokens[$i]['content'];
1388
  }
1389
  break;
1390
  case T_NS_SEPARATOR:
1391
  // Part of a type hint or default value.
1392
  if ($defaultStart === null) {
1393
+ if ($typeHintToken === false) {
1394
+ $typeHintToken = $i;
1395
+ }
1396
+
1397
  $typeHint .= $this->tokens[$i]['content'];
1398
  }
1399
  break;
1408
  // If it's null, then there must be no parameters for this
1409
  // method.
1410
  if ($currVar === null) {
1411
+ continue 2;
1412
  }
1413
 
1414
  $vars[$paramCount] = [];
1423
  $vars[$paramCount]['pass_by_reference'] = $passByReference;
1424
  $vars[$paramCount]['variable_length'] = $variableLength;
1425
  $vars[$paramCount]['type_hint'] = $typeHint;
1426
+ $vars[$paramCount]['type_hint_token'] = $typeHintToken;
1427
  $vars[$paramCount]['nullable_type'] = $nullableType;
1428
 
1429
  // Reset the vars, as we are about to process the next parameter.
1432
  $passByReference = false;
1433
  $variableLength = false;
1434
  $typeHint = '';
1435
+ $typeHintToken = false;
1436
  $nullableType = false;
1437
 
1438
  $paramCount++;
1454
  * The format of the array is:
1455
  * <code>
1456
  * array(
1457
+ * 'scope' => 'public', // public protected or protected
1458
+ * 'scope_specified' => true, // true is scope keyword was found.
1459
+ * 'return_type' => '', // the return type of the method.
1460
+ * 'return_type_token' => integer, // The stack pointer to the start of the return type
1461
+ * // or false if there is no return type.
1462
+ * 'nullable_return_type' => false, // true if the return type is nullable.
1463
+ * 'is_abstract' => false, // true if the abstract keyword was found.
1464
+ * 'is_final' => false, // true if the final keyword was found.
1465
+ * 'is_static' => false, // true if the static keyword was found.
1466
  * );
1467
  * </code>
1468
  *
1538
  }//end switch
1539
  }//end for
1540
 
1541
+ $returnType = '';
1542
+ $returnTypeToken = false;
1543
+ $nullableReturnType = false;
1544
+
1545
+ if (isset($this->tokens[$stackPtr]['parenthesis_closer']) === true) {
1546
+ $scopeOpener = null;
1547
+ if (isset($this->tokens[$stackPtr]['scope_opener']) === true) {
1548
+ $scopeOpener = $this->tokens[$stackPtr]['scope_opener'];
1549
+ }
1550
+
1551
+ $valid = [
1552
+ T_STRING => T_STRING,
1553
+ T_CALLABLE => T_CALLABLE,
1554
+ T_SELF => T_SELF,
1555
+ T_PARENT => T_PARENT,
1556
+ T_NS_SEPARATOR => T_NS_SEPARATOR,
1557
+ ];
1558
+
1559
+ for ($i = $this->tokens[$stackPtr]['parenthesis_closer']; $i < $this->numTokens; $i++) {
1560
+ if (($scopeOpener === null && $this->tokens[$i]['code'] === T_SEMICOLON)
1561
+ || ($scopeOpener !== null && $i === $scopeOpener)
1562
+ ) {
1563
+ // End of function definition.
1564
+ break;
1565
+ }
1566
+
1567
+ if ($this->tokens[$i]['code'] === T_NULLABLE) {
1568
+ $nullableReturnType = true;
1569
+ }
1570
+
1571
+ if (isset($valid[$this->tokens[$i]['code']]) === true) {
1572
+ if ($returnTypeToken === false) {
1573
+ $returnTypeToken = $i;
1574
+ }
1575
+
1576
+ $returnType .= $this->tokens[$i]['content'];
1577
+ }
1578
+ }
1579
+ }//end if
1580
+
1581
+ if ($returnType !== '' && $nullableReturnType === true) {
1582
+ $returnType = '?'.$returnType;
1583
+ }
1584
+
1585
  return [
1586
+ 'scope' => $scope,
1587
+ 'scope_specified' => $scopeSpecified,
1588
+ 'return_type' => $returnType,
1589
+ 'return_type_token' => $returnTypeToken,
1590
+ 'nullable_return_type' => $nullableReturnType,
1591
+ 'is_abstract' => $isAbstract,
1592
+ 'is_final' => $isFinal,
1593
+ 'is_static' => $isStatic,
1594
  ];
1595
 
1596
  }//end getMethodProperties()
1604
  *
1605
  * <code>
1606
  * array(
1607
+ * 'scope' => 'public', // public protected or protected.
1608
+ * 'scope_specified' => false, // true if the scope was explicitly specified.
1609
+ * 'is_static' => false, // true if the static keyword was found.
1610
  * );
1611
  * </code>
1612
  *
1651
  }
1652
 
1653
  $valid = [
1654
+ T_PUBLIC => T_PUBLIC,
1655
+ T_PRIVATE => T_PRIVATE,
1656
+ T_PROTECTED => T_PROTECTED,
1657
+ T_STATIC => T_STATIC,
1658
+ T_VAR => T_VAR,
 
 
 
 
1659
  ];
1660
 
1661
+ $valid += Util\Tokens::$emptyTokens;
1662
+
1663
  $scope = 'public';
1664
  $scopeSpecified = false;
1665
  $isStatic = false;
1666
 
1667
+ $startOfStatement = $this->findPrevious(
1668
+ [
1669
+ T_SEMICOLON,
1670
+ T_OPEN_CURLY_BRACKET,
1671
+ T_CLOSE_CURLY_BRACKET,
1672
+ ],
1673
+ ($stackPtr - 1)
1674
+ );
1675
+
1676
+ for ($i = ($startOfStatement + 1); $i < $stackPtr; $i++) {
1677
  if (isset($valid[$this->tokens[$i]['code']]) === false) {
1678
  break;
1679
  }
1902
  * Returns the content of the tokens from the specified start position in
1903
  * the token stack for the specified length.
1904
  *
1905
+ * @param int $start The position to start from in the token stack.
1906
+ * @param int $length The length of tokens to traverse from the start pos.
1907
+ * @param int $origContent Whether the original content or the tab replaced
1908
+ * content should be used.
1909
  *
1910
  * @return string The token contents.
1911
  */
1912
+ public function getTokensAsString($start, $length, $origContent=false)
1913
  {
1914
  $str = '';
1915
  $end = ($start + $length);
1918
  }
1919
 
1920
  for ($i = $start; $i < $end; $i++) {
1921
+ // If tabs are being converted to spaces by the tokeniser, the
1922
+ // original content should be used instead of the converted content.
1923
+ if ($origContent === true && isset($this->tokens[$i]['orig_content']) === true) {
1924
+ $str .= $this->tokens[$i]['orig_content'];
1925
+ } else {
1926
+ $str .= $this->tokens[$i]['content'];
1927
+ }
1928
  }
1929
 
1930
  return $str;
2200
  && ($i === $this->tokens[$i]['scope_opener']
2201
  || $i === $this->tokens[$i]['scope_condition'])
2202
  ) {
2203
+ if ($i === $start && isset(Util\Tokens::$scopeOpeners[$this->tokens[$i]['code']]) === true) {
2204
+ return $this->tokens[$i]['scope_closer'];
2205
+ }
2206
+
2207
  $i = $this->tokens[$i]['scope_closer'];
2208
  } else if (isset($this->tokens[$i]['bracket_closer']) === true
2209
  && $i === $this->tokens[$i]['bracket_opener']
2377
  return false;
2378
  }
2379
 
2380
+ if (isset($this->tokens[$stackPtr]['scope_opener']) === false) {
2381
  return false;
2382
  }
2383
 
2384
+ $classOpenerIndex = $this->tokens[$stackPtr]['scope_opener'];
2385
+ $extendsIndex = $this->findNext(T_EXTENDS, $stackPtr, $classOpenerIndex);
2386
  if (false === $extendsIndex) {
2387
  return false;
2388
  }
2393
  T_WHITESPACE,
2394
  ];
2395
 
2396
+ $end = $this->findNext($find, ($extendsIndex + 1), ($classOpenerIndex + 1), true);
2397
  $name = $this->getTokensAsString(($extendsIndex + 1), ($end - $extendsIndex - 1));
2398
  $name = trim($name);
2399
 
vendor/squizlabs/php_codesniffer/src/Files/FileList.php CHANGED
@@ -167,7 +167,7 @@ class FileList implements \Iterator, \Countable
167
  *
168
  * @return void
169
  */
170
- function rewind()
171
  {
172
  reset($this->files);
173
 
@@ -179,7 +179,7 @@ class FileList implements \Iterator, \Countable
179
  *
180
  * @return \PHP_CodeSniffer\Files\File
181
  */
182
- function current()
183
  {
184
  $path = key($this->files);
185
  if ($this->files[$path] === null) {
@@ -196,7 +196,7 @@ class FileList implements \Iterator, \Countable
196
  *
197
  * @return void
198
  */
199
- function key()
200
  {
201
  return key($this->files);
202
 
@@ -208,7 +208,7 @@ class FileList implements \Iterator, \Countable
208
  *
209
  * @return void
210
  */
211
- function next()
212
  {
213
  next($this->files);
214
 
@@ -220,7 +220,7 @@ class FileList implements \Iterator, \Countable
220
  *
221
  * @return boolean
222
  */
223
- function valid()
224
  {
225
  if (current($this->files) === false) {
226
  return false;
@@ -236,7 +236,7 @@ class FileList implements \Iterator, \Countable
236
  *
237
  * @return integer
238
  */
239
- function count()
240
  {
241
  return $this->numFiles;
242
 
167
  *
168
  * @return void
169
  */
170
+ public function rewind()
171
  {
172
  reset($this->files);
173
 
179
  *
180
  * @return \PHP_CodeSniffer\Files\File
181
  */
182
+ public function current()
183
  {
184
  $path = key($this->files);
185
  if ($this->files[$path] === null) {
196
  *
197
  * @return void
198
  */
199
+ public function key()
200
  {
201
  return key($this->files);
202
 
208
  *
209
  * @return void
210
  */
211
+ public function next()
212
  {
213
  next($this->files);
214
 
220
  *
221
  * @return boolean
222
  */
223
+ public function valid()
224
  {
225
  if (current($this->files) === false) {
226
  return false;
236
  *
237
  * @return integer
238
  */
239
+ public function count()
240
  {
241
  return $this->numFiles;
242
 
vendor/squizlabs/php_codesniffer/src/Files/LocalFile.php CHANGED
@@ -48,7 +48,7 @@ class LocalFile extends File
48
  fclose($handle);
49
 
50
  if (strpos($firstContent, '@codingStandardsIgnoreFile') !== false
51
- || strpos(strtolower($firstContent), 'phpcs:ignorefile') !== false
52
  ) {
53
  // We are ignoring the whole file.
54
  $this->ignored = true;
@@ -69,7 +69,7 @@ class LocalFile extends File
69
  *
70
  * @return void
71
  */
72
- function reloadContent()
73
  {
74
  $this->setContent(file_get_contents($this->path));
75
 
48
  fclose($handle);
49
 
50
  if (strpos($firstContent, '@codingStandardsIgnoreFile') !== false
51
+ || stripos($firstContent, 'phpcs:ignorefile') !== false
52
  ) {
53
  // We are ignoring the whole file.
54
  $this->ignored = true;
69
  *
70
  * @return void
71
  */
72
+ public function reloadContent()
73
  {
74
  $this->setContent(file_get_contents($this->path));
75
 
vendor/squizlabs/php_codesniffer/src/Filters/Filter.php CHANGED
@@ -204,9 +204,10 @@ class Filter extends \RecursiveFilterIterator
204
  // If the ignore pattern ends with /* then it is ignoring an entire directory.
205
  if (substr($pattern, -2) === '/*') {
206
  // Need to check this pattern for dirs as well as individual file paths.
207
- $pattern = substr($pattern, 0, -2);
208
- $this->ignoreDirPatterns[$pattern] = $type;
209
  $this->ignoreFilePatterns[$pattern] = $type;
 
 
 
210
  } else {
211
  // This is a file-specific pattern, so only need to check this
212
  // for individual file paths.
204
  // If the ignore pattern ends with /* then it is ignoring an entire directory.
205
  if (substr($pattern, -2) === '/*') {
206
  // Need to check this pattern for dirs as well as individual file paths.
 
 
207
  $this->ignoreFilePatterns[$pattern] = $type;
208
+
209
+ $pattern = substr($pattern, 0, -2);
210
+ $this->ignoreDirPatterns[$pattern] = $type;
211
  } else {
212
  // This is a file-specific pattern, so only need to check this
213
  // for individual file paths.
vendor/squizlabs/php_codesniffer/src/Generators/Generator.php CHANGED
@@ -14,7 +14,6 @@ namespace PHP_CodeSniffer\Generators;
14
 
15
  use PHP_CodeSniffer\Ruleset;
16
  use PHP_CodeSniffer\Autoload;
17
- use PHP_CodeSniffer\Util\Common;
18
 
19
  abstract class Generator
20
  {
14
 
15
  use PHP_CodeSniffer\Ruleset;
16
  use PHP_CodeSniffer\Autoload;
 
17
 
18
  abstract class Generator
19
  {
vendor/squizlabs/php_codesniffer/src/Reporter.php CHANGED
@@ -99,12 +99,11 @@ class Reporter
99
  $this->config = $config;
100
 
101
  foreach ($config->reports as $type => $output) {
102
- $type = ucfirst($type);
103
-
104
  if ($output === null) {
105
  $output = $config->reportFile;
106
  }
107
 
 
108
  if (strpos($type, '.') !== false) {
109
  // This is a path to a custom report class.
110
  $filename = realpath($type);
@@ -114,8 +113,32 @@ class Reporter
114
  }
115
 
116
  $reportClassName = Autoload::loadFile($filename);
 
 
 
 
 
 
117
  } else {
118
- $reportClassName = 'PHP_CodeSniffer\Reports\\'.$type;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  }
120
 
121
  $reportClass = new $reportClassName();
@@ -175,7 +198,6 @@ class Reporter
175
  */
176
  public function printReport($report)
177
  {
178
- $report = ucfirst($report);
179
  $reportClass = $this->reports[$report]['class'];
180
  $reportFile = $this->reports[$report]['output'];
181
 
99
  $this->config = $config;
100
 
101
  foreach ($config->reports as $type => $output) {
 
 
102
  if ($output === null) {
103
  $output = $config->reportFile;
104
  }
105
 
106
+ $reportClassName = '';
107
  if (strpos($type, '.') !== false) {
108
  // This is a path to a custom report class.
109
  $filename = realpath($type);
113
  }
114
 
115
  $reportClassName = Autoload::loadFile($filename);
116
+ } else if (class_exists('PHP_CodeSniffer\Reports\\'.ucfirst($type)) === true) {
117
+ // PHPCS native report.
118
+ $reportClassName = 'PHP_CodeSniffer\Reports\\'.ucfirst($type);
119
+ } else if (class_exists($type) === true) {
120
+ // FQN of a custom report.
121
+ $reportClassName = $type;
122
  } else {
123
+ // OK, so not a FQN, try and find the report using the registered namespaces.
124
+ $registeredNamespaces = Autoload::getSearchPaths();
125
+ $trimmedType = ltrim($type, '\\');
126
+
127
+ foreach ($registeredNamespaces as $nsPrefix) {
128
+ if ($nsPrefix === '') {
129
+ continue;
130
+ }
131
+
132
+ if (class_exists($nsPrefix.'\\'.$trimmedType) === true) {
133
+ $reportClassName = $nsPrefix.'\\'.$trimmedType;
134
+ break;
135
+ }
136
+ }
137
+ }//end if
138
+
139
+ if ($reportClassName === '') {
140
+ $error = "ERROR: Class file for report \"$type\" not found".PHP_EOL;
141
+ throw new DeepExitException($error, 3);
142
  }
143
 
144
  $reportClass = new $reportClassName();
198
  */
199
  public function printReport($report)
200
  {
 
201
  $reportClass = $this->reports[$report]['class'];
202
  $reportFile = $this->reports[$report]['output'];
203
 
vendor/squizlabs/php_codesniffer/src/Reports/Diff.php CHANGED
@@ -10,7 +10,6 @@
10
  namespace PHP_CodeSniffer\Reports;
11
 
12
  use PHP_CodeSniffer\Files\File;
13
- use PHP_CodeSniffer\Util;
14
 
15
  class Diff implements Report
16
  {
10
  namespace PHP_CodeSniffer\Reports;
11
 
12
  use PHP_CodeSniffer\Files\File;
 
13
 
14
  class Diff implements Report
15
  {
vendor/squizlabs/php_codesniffer/src/Reports/Full.php CHANGED
@@ -114,27 +114,40 @@ class Full implements Report
114
 
115
  // The maximum amount of space an error message can use.
116
  $maxErrorSpace = ($width - $paddingLength - 1);
117
- if ($showSources === true) {
118
- // Account for the chars used to print colors.
119
- $maxErrorSpace += 8;
120
- }
121
 
122
  foreach ($report['messages'] as $line => $lineErrors) {
123
  foreach ($lineErrors as $column => $colErrors) {
124
  foreach ($colErrors as $error) {
125
- $message = $error['message'];
126
- $message = str_replace("\n", "\n".$paddingLine2, $message);
127
- if ($showSources === true) {
128
- $message = "\033[1m".$message."\033[0m".' ('.$error['source'].')';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  }
130
 
131
  // The padding that goes on the front of the line.
132
- $padding = ($maxLineNumLength - strlen($line));
133
- $errorMsg = wordwrap(
134
- $message,
135
- $maxErrorSpace,
136
- PHP_EOL.$paddingLine2
137
- );
138
 
139
  echo ' '.str_repeat(' ', $padding).$line.' | ';
140
  if ($error['type'] === 'ERROR') {
114
 
115
  // The maximum amount of space an error message can use.
116
  $maxErrorSpace = ($width - $paddingLength - 1);
 
 
 
 
117
 
118
  foreach ($report['messages'] as $line => $lineErrors) {
119
  foreach ($lineErrors as $column => $colErrors) {
120
  foreach ($colErrors as $error) {
121
+ $message = $error['message'];
122
+ $msgLines = [$message];
123
+ if (strpos($message, "\n") !== false) {
124
+ $msgLines = explode("\n", $message);
125
+ }
126
+
127
+ $errorMsg = '';
128
+ $lastLine = (count($msgLines) - 1);
129
+ foreach ($msgLines as $k => $msgLine) {
130
+ if ($k === 0) {
131
+ if ($showSources === true) {
132
+ $errorMsg .= "\033[1m";
133
+ }
134
+ } else {
135
+ $errorMsg .= PHP_EOL.$paddingLine2;
136
+ }
137
+
138
+ if ($k === $lastLine && $showSources === true) {
139
+ $msgLine .= "\033[0m".' ('.$error['source'].')';
140
+ }
141
+
142
+ $errorMsg .= wordwrap(
143
+ $msgLine,
144
+ $maxErrorSpace,
145
+ PHP_EOL.$paddingLine2
146
+ );
147
  }
148
 
149
  // The padding that goes on the front of the line.
150
+ $padding = ($maxLineNumLength - strlen($line));
 
 
 
 
 
151
 
152
  echo ' '.str_repeat(' ', $padding).$line.' | ';
153
  if ($error['type'] === 'ERROR') {
vendor/squizlabs/php_codesniffer/src/Reports/Info.php CHANGED
@@ -101,30 +101,59 @@ class Info implements Report
101
  echo str_repeat('-', 70).PHP_EOL;
102
 
103
  foreach ($metrics as $metric => $values) {
104
- $winner = '';
105
- $winnerCount = 0;
106
- $totalCount = 0;
107
- foreach ($values as $value => $count) {
108
- $totalCount += $count;
109
- if ($count > $winnerCount) {
110
- $winner = $value;
111
- $winnerCount = $count;
112
- }
113
- }
114
 
115
- $winPercent = round(($winnerCount / $totalCount * 100), 2);
116
- echo "$metric: \033[4m$winner\033[0m [$winnerCount/$totalCount, $winPercent%]".PHP_EOL;
 
 
 
 
 
 
117
 
118
- asort($values);
119
- $values = array_reverse($values, true);
120
- foreach ($values as $value => $count) {
121
- if ($value === $winner) {
122
- continue;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  }
124
 
125
- $percent = round(($count / $totalCount * 100), 2);
126
- echo "\t$value => $count ($percent%)".PHP_EOL;
127
- }
 
 
 
 
128
 
129
  echo PHP_EOL;
130
  }//end foreach
101
  echo str_repeat('-', 70).PHP_EOL;
102
 
103
  foreach ($metrics as $metric => $values) {
104
+ if (count($values) === 1) {
105
+ $count = reset($values);
106
+ $value = key($values);
 
 
 
 
 
 
 
107
 
108
+ echo "$metric: \033[4m$value\033[0m [$count/$count, 100%]".PHP_EOL;
109
+ } else {
110
+ $totalCount = 0;
111
+ $valueWidth = 0;
112
+ foreach ($values as $value => $count) {
113
+ $totalCount += $count;
114
+ $valueWidth = max($valueWidth, strlen($value));
115
+ }
116
 
117
+ $countWidth = strlen($totalCount);
118
+ $nrOfThousandSeps = floor($countWidth / 3);
119
+ $countWidth += $nrOfThousandSeps;
120
+
121
+ // Account for 'total' line.
122
+ $valueWidth = max(5, $valueWidth);
123
+
124
+ echo "$metric:".PHP_EOL;
125
+
126
+ ksort($values, SORT_NATURAL);
127
+ arsort($values);
128
+
129
+ $percentPrefixWidth = 0;
130
+ $percentWidth = 6;
131
+ foreach ($values as $value => $count) {
132
+ $percent = round(($count / $totalCount * 100), 2);
133
+ $percentPrefix = '';
134
+ if ($percent === 0.00) {
135
+ $percent = 0.01;
136
+ $percentPrefix = '<';
137
+ $percentPrefixWidth = 2;
138
+ $percentWidth = 4;
139
+ }
140
+
141
+ printf(
142
+ "\t%-{$valueWidth}s => %{$countWidth}s (%{$percentPrefixWidth}s%{$percentWidth}.2f%%)".PHP_EOL,
143
+ $value,
144
+ number_format($count),
145
+ $percentPrefix,
146
+ $percent
147
+ );
148
  }
149
 
150
+ echo "\t".str_repeat('-', ($valueWidth + $countWidth + 15)).PHP_EOL;
151
+ printf(
152
+ "\t%-{$valueWidth}s => %{$countWidth}s (100.00%%)".PHP_EOL,
153
+ 'total',
154
+ number_format($totalCount)
155
+ );
156
+ }//end if
157
 
158
  echo PHP_EOL;
159
  }//end foreach
vendor/squizlabs/php_codesniffer/src/Reports/Json.php CHANGED
@@ -42,28 +42,23 @@ class Json implements Report
42
  foreach ($report['messages'] as $line => $lineErrors) {
43
  foreach ($lineErrors as $column => $colErrors) {
44
  foreach ($colErrors as $error) {
45
- $error['message'] = str_replace('\\', '\\\\', $error['message']);
46
- $error['message'] = str_replace('"', '\"', $error['message']);
47
- $error['message'] = str_replace('/', '\/', $error['message']);
48
  $error['message'] = str_replace("\n", '\n', $error['message']);
49
  $error['message'] = str_replace("\r", '\r', $error['message']);
50
  $error['message'] = str_replace("\t", '\t', $error['message']);
51
 
52
- $fixable = 'false';
53
  if ($error['fixable'] === true) {
54
- $fixable = 'true';
55
  }
56
 
57
- $messages .= '{"message":"'.$error['message'].'",';
58
- $messages .= '"source":"'.$error['source'].'",';
59
- $messages .= '"severity":'.$error['severity'].',';
60
- $messages .= '"type":"'.$error['type'].'",';
61
- $messages .= '"line":'.$line.',';
62
- $messages .= '"column":'.$column.',';
63
- $messages .= '"fixable":'.$fixable;
64
- $messages .= '},';
65
- }//end foreach
66
- }//end foreach
67
  }//end foreach
68
 
69
  echo rtrim($messages, ',');
42
  foreach ($report['messages'] as $line => $lineErrors) {
43
  foreach ($lineErrors as $column => $colErrors) {
44
  foreach ($colErrors as $error) {
 
 
 
45
  $error['message'] = str_replace("\n", '\n', $error['message']);
46
  $error['message'] = str_replace("\r", '\r', $error['message']);
47
  $error['message'] = str_replace("\t", '\t', $error['message']);
48
 
49
+ $fixable = false;
50
  if ($error['fixable'] === true) {
51
+ $fixable = true;
52
  }
53
 
54
+ $messagesObject = (object) $error;
55
+ $messagesObject->line = $line;
56
+ $messagesObject->column = $column;
57
+ $messagesObject->fixable = $fixable;
58
+
59
+ $messages .= json_encode($messagesObject).",";
60
+ }
61
+ }
 
 
62
  }//end foreach
63
 
64
  echo rtrim($messages, ',');
vendor/squizlabs/php_codesniffer/src/Reports/Junit.php CHANGED
@@ -39,6 +39,7 @@ class Junit implements Report
39
 
40
  $out->startElement('testsuite');
41
  $out->writeAttribute('name', $report['filename']);
 
42
 
43
  if (count($report['messages']) === 0) {
44
  $out->writeAttribute('tests', 1);
@@ -120,7 +121,7 @@ class Junit implements Report
120
 
121
  $failures = ($totalErrors + $totalWarnings);
122
  echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
123
- echo '<testsuites name="PHP_CodeSniffer '.Config::VERSION.'" tests="'.$tests.'" failures="'.$failures.'">'.PHP_EOL;
124
  echo $cachedData;
125
  echo '</testsuites>'.PHP_EOL;
126
 
39
 
40
  $out->startElement('testsuite');
41
  $out->writeAttribute('name', $report['filename']);
42
+ $out->writeAttribute('errors', 0);
43
 
44
  if (count($report['messages']) === 0) {
45
  $out->writeAttribute('tests', 1);
121
 
122
  $failures = ($totalErrors + $totalWarnings);
123
  echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
124
+ echo '<testsuites name="PHP_CodeSniffer '.Config::VERSION.'" errors="0" tests="'.$tests.'" failures="'.$failures.'">'.PHP_EOL;
125
  echo $cachedData;
126
  echo '</testsuites>'.PHP_EOL;
127
 
vendor/squizlabs/php_codesniffer/src/Reports/Source.php CHANGED
@@ -141,13 +141,6 @@ class Source implements Report
141
  } else {
142
  $sources[$source]['count'] += $count;
143
  }//end if
144
-
145
- $fileLen = strlen($parts[0]);
146
- $reportFiles[$parts[0]] = [
147
- 'errors' => $parts[1],
148
- 'warnings' => $parts[2],
149
- 'strlen' => $fileLen,
150
- ];
151
  }//end foreach
152
 
153
  if ($showSources === true) {
@@ -158,8 +151,14 @@ class Source implements Report
158
 
159
  $width = max($width, 70);
160
 
161
- asort($sources);
162
- $sources = array_reverse($sources);
 
 
 
 
 
 
163
 
164
  echo PHP_EOL."\033[1mPHP CODE SNIFFER VIOLATION SOURCE SUMMARY\033[0m".PHP_EOL;
165
  echo str_repeat('-', $width).PHP_EOL."\033[1m";
141
  } else {
142
  $sources[$source]['count'] += $count;
143
  }//end if
 
 
 
 
 
 
 
144
  }//end foreach
145
 
146
  if ($showSources === true) {
151
 
152
  $width = max($width, 70);
153
 
154
+ // Sort the data based on counts and source code.
155
+ $sourceCodes = array_keys($sources);
156
+ $counts = [];
157
+ foreach ($sources as $source => $data) {
158
+ $counts[$source] = $data['count'];
159
+ }
160
+
161
+ array_multisort($counts, SORT_DESC, $sourceCodes, SORT_ASC, SORT_NATURAL, $sources);
162
 
163
  echo PHP_EOL."\033[1mPHP CODE SNIFFER VIOLATION SOURCE SUMMARY\033[0m".PHP_EOL;
164
  echo str_repeat('-', $width).PHP_EOL."\033[1m";
vendor/squizlabs/php_codesniffer/src/Reports/Summary.php CHANGED
@@ -95,6 +95,27 @@ class Summary implements Report
95
  $maxLength = max($maxLength, $fileLen);
96
  }
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  $width = min($width, ($maxLength + 21));
99
  $width = max($width, 70);
100
 
95
  $maxLength = max($maxLength, $fileLen);
96
  }
97
 
98
+ uksort(
99
+ $reportFiles,
100
+ function ($keyA, $keyB) {
101
+ $pathPartsA = explode(DIRECTORY_SEPARATOR, $keyA);
102
+ $pathPartsB = explode(DIRECTORY_SEPARATOR, $keyB);
103
+
104
+ do {
105
+ $partA = array_shift($pathPartsA);
106
+ $partB = array_shift($pathPartsB);
107
+ } while ($partA === $partB && empty($pathPartsA) === false && empty($pathPartsB) === false);
108
+
109
+ if (empty($pathPartsA) === false && empty($pathPartsB) === true) {
110
+ return 1;
111
+ } else if (empty($pathPartsA) === true && empty($pathPartsB) === false) {
112
+ return -1;
113
+ } else {
114
+ return strcasecmp($partA, $partB);
115
+ }
116
+ }
117
+ );
118
+
119
  $width = min($width, ($maxLength + 21));
120
  $width = max($width, 70);
121
 
vendor/squizlabs/php_codesniffer/src/Ruleset.php CHANGED
@@ -390,7 +390,11 @@ class Ruleset
390
  $includedSniffs = array_merge($includedSniffs, $expandedSniffs);
391
 
392
  $parts = explode('.', $rule['ref']);
393
- if (count($parts) === 4) {
 
 
 
 
394
  $sniffCode = $parts[0].'.'.$parts[1].'.'.$parts[2];
395
  if (isset($this->ruleset[$sniffCode]['severity']) === true
396
  && $this->ruleset[$sniffCode]['severity'] === 0
@@ -945,21 +949,43 @@ class Ruleset
945
  if (isset($prop['type']) === true
946
  && (string) $prop['type'] === 'array'
947
  ) {
948
- $value = (string) $prop['value'];
949
  $values = [];
950
- foreach (explode(',', $value) as $val) {
951
- list($k, $v) = explode('=>', $val.'=>');
952
- if ($v !== '') {
953
- $values[trim($k)] = trim($v);
954
- } else {
955
- $values[] = trim($k);
 
 
 
 
 
 
 
 
 
 
956
  }
957
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
958
 
959
  $this->ruleset[$code]['properties'][$name] = $values;
960
  if (PHP_CODESNIFFER_VERBOSITY > 1) {
961
  echo str_repeat("\t", $depth);
962
- echo "\t\t=> array property \"$name\" set to \"$value\"";
963
  if ($code !== $ref) {
964
  echo " for $code";
965
  }
@@ -1241,11 +1267,30 @@ class Ruleset
1241
  $value = trim($value);
1242
  }
1243
 
 
 
 
 
1244
  // Special case for booleans.
1245
  if ($value === 'true') {
1246
  $value = true;
1247
  } else if ($value === 'false') {
1248
  $value = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1249
  }
1250
 
1251
  $this->sniffs[$sniffClass]->$name = $value;
390
  $includedSniffs = array_merge($includedSniffs, $expandedSniffs);
391
 
392
  $parts = explode('.', $rule['ref']);
393
+ if (count($parts) === 4
394
+ && $parts[0] !== ''
395
+ && $parts[1] !== ''
396
+ && $parts[2] !== ''
397
+ ) {
398
  $sniffCode = $parts[0].'.'.$parts[1].'.'.$parts[2];
399
  if (isset($this->ruleset[$sniffCode]['severity']) === true
400
  && $this->ruleset[$sniffCode]['severity'] === 0
949
  if (isset($prop['type']) === true
950
  && (string) $prop['type'] === 'array'
951
  ) {
 
952
  $values = [];
953
+ if (isset($prop->element) === true) {
954
+ $printValue = '';
955
+ foreach ($prop->element as $element) {
956
+ if ($this->shouldProcessElement($element) === false) {
957
+ continue;
958
+ }
959
+
960
+ $value = (string) $element['value'];
961
+ if (isset($element['key']) === true) {
962
+ $key = (string) $element['key'];
963
+ $values[$key] = $value;
964
+ $printValue .= $key.'=>'.$value.',';
965
+ } else {
966
+ $values[] = $value;
967
+ $printValue .= $value.',';
968
+ }
969
  }
970
+
971
+ $printValue = rtrim($printValue, ',');
972
+ } else {
973
+ $value = (string) $prop['value'];
974
+ $printValue = $value;
975
+ foreach (explode(',', $value) as $val) {
976
+ list($k, $v) = explode('=>', $val.'=>');
977
+ if ($v !== '') {
978
+ $values[trim($k)] = trim($v);
979
+ } else {
980
+ $values[] = trim($k);
981
+ }
982
+ }
983
+ }//end if
984
 
985
  $this->ruleset[$code]['properties'][$name] = $values;
986
  if (PHP_CODESNIFFER_VERBOSITY > 1) {
987
  echo str_repeat("\t", $depth);
988
+ echo "\t\t=> array property \"$name\" set to \"$printValue\"";
989
  if ($code !== $ref) {
990
  echo " for $code";
991
  }
1267
  $value = trim($value);
1268
  }
1269
 
1270
+ if ($value === '') {
1271
+ $value = null;
1272
+ }
1273
+
1274
  // Special case for booleans.
1275
  if ($value === 'true') {
1276
  $value = true;
1277
  } else if ($value === 'false') {
1278
  $value = false;
1279
+ } else if (substr($name, -2) === '[]') {
1280
+ $name = substr($name, 0, -2);
1281
+ $values = [];
1282
+ if ($value !== null) {
1283
+ foreach (explode(',', $value) as $val) {
1284
+ list($k, $v) = explode('=>', $val.'=>');
1285
+ if ($v !== '') {
1286
+ $values[trim($k)] = trim($v);
1287
+ } else {
1288
+ $values[] = trim($k);
1289
+ }
1290
+ }
1291
+ }
1292
+
1293
+ $value = $values;
1294
  }
1295
 
1296
  $this->sniffs[$sniffClass]->$name = $value;
vendor/squizlabs/php_codesniffer/src/Runner.php CHANGED
@@ -726,7 +726,7 @@ class Runner
726
  *
727
  * @return void
728
  */
729
- function printProgress($file, $numFiles, $numProcessed)
730
  {
731
  if (PHP_CODESNIFFER_VERBOSITY > 0
732
  || $this->config->showProgress === false
726
  *
727
  * @return void
728
  */
729
+ public function printProgress($file, $numFiles, $numProcessed)
730
  {
731
  if (PHP_CODESNIFFER_VERBOSITY > 0
732
  || $this->config->showProgress === false
vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractArraySniff.php CHANGED
@@ -9,7 +9,6 @@
9
 
10
  namespace PHP_CodeSniffer\Sniffs;
11
 
12
- use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
14
  use PHP_CodeSniffer\Util\Tokens;
15
 
@@ -110,10 +109,9 @@ abstract class AbstractArraySniff implements Sniff
110
  }
111
 
112
  $checkToken = $phpcsFile->findNext(T_WHITESPACE, ($checkToken + 1), null, true);
 
113
  if ($tokens[$checkToken]['code'] !== T_COMMA) {
114
  $checkToken--;
115
- } else {
116
- $lastToken = $checkToken;
117
  }
118
 
119
  continue;
9
 
10
  namespace PHP_CodeSniffer\Sniffs;
11
 
 
12
  use PHP_CodeSniffer\Files\File;
13
  use PHP_CodeSniffer\Util\Tokens;
14
 
109
  }
110
 
111
  $checkToken = $phpcsFile->findNext(T_WHITESPACE, ($checkToken + 1), null, true);
112
+ $lastToken = $checkToken;
113
  if ($tokens[$checkToken]['code'] !== T_COMMA) {
114
  $checkToken--;
 
 
115
  }
116
 
117
  continue;
vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractPatternSniff.php CHANGED
@@ -10,7 +10,6 @@
10
  namespace PHP_CodeSniffer\Sniffs;
11
 
12
  use PHP_CodeSniffer\Files\File;
13
- use PHP_CodeSniffer\Config;
14
  use PHP_CodeSniffer\Util\Tokens;
15
  use PHP_CodeSniffer\Tokenizers\PHP;
16
  use PHP_CodeSniffer\Exceptions\RuntimeException;
10
  namespace PHP_CodeSniffer\Sniffs;
11
 
12
  use PHP_CodeSniffer\Files\File;
 
13
  use PHP_CodeSniffer\Util\Tokens;
14
  use PHP_CodeSniffer\Tokenizers\PHP;
15
  use PHP_CodeSniffer\Exceptions\RuntimeException;
vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractScopeSniff.php CHANGED
@@ -121,7 +121,10 @@ abstract class AbstractScopeSniff implements Sniff
121
  * @param int $stackPtr The position in the stack where this
122
  * token was found.
123
  *
124
- * @return void
 
 
 
125
  * @see processTokenWithinScope()
126
  */
127
  final public function process(File $phpcsFile, $stackPtr)
@@ -129,17 +132,24 @@ abstract class AbstractScopeSniff implements Sniff
129
  $tokens = $phpcsFile->getTokens();
130
 
131
  $foundScope = false;
 
132
  foreach ($tokens[$stackPtr]['conditions'] as $scope => $code) {
133
  if (isset($this->scopeTokens[$code]) === true) {
134
- $this->processTokenWithinScope($phpcsFile, $stackPtr, $scope);
135
  $foundScope = true;
136
  }
137
  }
138
 
139
  if ($this->listenOutside === true && $foundScope === false) {
140
- $this->processTokenOutsideScope($phpcsFile, $stackPtr);
141
  }
142
 
 
 
 
 
 
 
143
  }//end process()
144
 
145
 
@@ -154,7 +164,10 @@ abstract class AbstractScopeSniff implements Sniff
154
  * opened the scope that this test is
155
  * listening for.
156
  *
157
- * @return void
 
 
 
158
  */
159
  abstract protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope);
160
 
@@ -167,7 +180,10 @@ abstract class AbstractScopeSniff implements Sniff
167
  * @param int $stackPtr The position in the stack where this
168
  * token was found.
169
  *
170
- * @return void
 
 
 
171
  */
172
  abstract protected function processTokenOutsideScope(File $phpcsFile, $stackPtr);
173
 
121
  * @param int $stackPtr The position in the stack where this
122
  * token was found.
123
  *
124
+ * @return void|int Optionally returns a stack pointer. The sniff will not be
125
+ * called again on the current file until the returned stack
126
+ * pointer is reached. Return (count($tokens) + 1) to skip
127
+ * the rest of the file.
128
  * @see processTokenWithinScope()
129
  */
130
  final public function process(File $phpcsFile, $stackPtr)
132
  $tokens = $phpcsFile->getTokens();
133
 
134
  $foundScope = false;
135
+ $skipPtrs = [];
136
  foreach ($tokens[$stackPtr]['conditions'] as $scope => $code) {
137
  if (isset($this->scopeTokens[$code]) === true) {
138
+ $skipPtrs[] = $this->processTokenWithinScope($phpcsFile, $stackPtr, $scope);
139
  $foundScope = true;
140
  }
141
  }
142
 
143
  if ($this->listenOutside === true && $foundScope === false) {
144
+ $skipPtrs[] = $this->processTokenOutsideScope($phpcsFile, $stackPtr);
145
  }
146
 
147
+ if (empty($skipPtrs) === false) {
148
+ return min($skipPtrs);
149
+ }
150
+
151
+ return;
152
+
153
  }//end process()
154
 
155
 
164
  * opened the scope that this test is
165
  * listening for.
166
  *
167
+ * @return void|int Optionally returns a stack pointer. The sniff will not be
168
+ * called again on the current file until the returned stack
169
+ * pointer is reached. Return (count($tokens) + 1) to skip
170
+ * the rest of the file.
171
  */
172
  abstract protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope);
173
 
180
  * @param int $stackPtr The position in the stack where this
181
  * token was found.
182
  *
183
+ * @return void|int Optionally returns a stack pointer. The sniff will not be
184
+ * called again on the current file until the returned stack
185
+ * pointer is reached. Return (count($tokens) + 1) to skip
186
+ * the rest of the file.
187
  */
188
  abstract protected function processTokenOutsideScope(File $phpcsFile, $stackPtr);
189
 
vendor/squizlabs/php_codesniffer/src/Sniffs/AbstractVariableSniff.php CHANGED
@@ -17,12 +17,34 @@ namespace PHP_CodeSniffer\Sniffs;
17
 
18
  use PHP_CodeSniffer\Files\File;
19
  use PHP_CodeSniffer\Util\Tokens;
20
- use PHP_CodeSniffer\Exceptions\RuntimeException;
21
 
22
  abstract class AbstractVariableSniff extends AbstractScopeSniff
23
  {
24
 
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  /**
27
  * Constructs an AbstractVariableTest.
28
  */
@@ -49,7 +71,10 @@ abstract class AbstractVariableSniff extends AbstractScopeSniff
49
  * @param int $stackPtr The position where the token was found.
50
  * @param int $currScope The current scope opener token.
51
  *
52
- * @return void
 
 
 
53
  */
54
  final protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope)
55
  {
@@ -61,7 +86,7 @@ abstract class AbstractVariableSniff extends AbstractScopeSniff
61
  // Check to see if this string has a variable in it.
62
  $pattern = '|(?<!\\\\)(?:\\\\{2})*\${?[a-zA-Z0-9_]+}?|';
63
  if (preg_match($pattern, $tokens[$stackPtr]['content']) !== 0) {
64
- $this->processVariableInString($phpcsFile, $stackPtr);
65
  }
66
 
67
  return;
@@ -115,9 +140,9 @@ abstract class AbstractVariableSniff extends AbstractScopeSniff
115
  }//end if
116
 
117
  if ($inFunction === true) {
118
- $this->processVariable($phpcsFile, $stackPtr);
119
  } else {
120
- $this->processMemberVar($phpcsFile, $stackPtr);
121
  }
122
 
123
  }//end processTokenWithinScope()
@@ -130,21 +155,24 @@ abstract class AbstractVariableSniff extends AbstractScopeSniff
130
  * token was found.
131
  * @param int $stackPtr The position where the token was found.
132
  *
133
- * @return void
 
 
 
134
  */
135
  final protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
136
  {
137
  $tokens = $phpcsFile->getTokens();
138
  // These variables are not member vars.
139
  if ($tokens[$stackPtr]['code'] === T_VARIABLE) {
140
- $this->processVariable($phpcsFile, $stackPtr);
141
  } else if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING
142
  || $tokens[$stackPtr]['code'] === T_HEREDOC
143
  ) {
144
  // Check to see if this string has a variable in it.
145
  $pattern = '|(?<!\\\\)(?:\\\\{2})*\${?[a-zA-Z0-9_]+}?|';
146
  if (preg_match($pattern, $tokens[$stackPtr]['content']) !== 0) {
147
- $this->processVariableInString($phpcsFile, $stackPtr);
148
  }
149
  }
150
 
@@ -158,7 +186,10 @@ abstract class AbstractVariableSniff extends AbstractScopeSniff
158
  * token was found.
159
  * @param int $stackPtr The position where the token was found.
160
  *
161
- * @return void
 
 
 
162
  */
163
  abstract protected function processMemberVar(File $phpcsFile, $stackPtr);
164
 
@@ -170,7 +201,10 @@ abstract class AbstractVariableSniff extends AbstractScopeSniff
170
  * token was found.
171
  * @param int $stackPtr The position where the token was found.
172
  *
173
- * @return void
 
 
 
174
  */
175
  abstract protected function processVariable(File $phpcsFile, $stackPtr);
176
 
@@ -186,7 +220,10 @@ abstract class AbstractVariableSniff extends AbstractScopeSniff
186
  * @param int $stackPtr The position where the double quoted
187
  * string was found.
188
  *
189
- * @return void
 
 
 
190
  */
191
  abstract protected function processVariableInString(File $phpcsFile, $stackPtr);
192
 
17
 
18
  use PHP_CodeSniffer\Files\File;
19
  use PHP_CodeSniffer\Util\Tokens;
 
20
 
21
  abstract class AbstractVariableSniff extends AbstractScopeSniff
22
  {
23
 
24
 
25
+ /**
26
+ * List of PHP Reserved variables.
27
+ *
28
+ * Used by various naming convention sniffs.
29
+ *
30
+ * @var array
31
+ */
32
+ protected $phpReservedVars = [
33
+ '_SERVER' => true,
34
+ '_GET' => true,
35
+ '_POST' => true,
36
+ '_REQUEST' => true,
37
+ '_SESSION' => true,
38
+ '_ENV' => true,
39
+ '_COOKIE' => true,
40
+ '_FILES' => true,
41
+ 'GLOBALS' => true,
42
+ 'http_response_header' => true,
43
+ 'HTTP_RAW_POST_DATA' => true,
44
+ 'php_errormsg' => true,
45
+ ];
46
+
47
+
48
  /**
49
  * Constructs an AbstractVariableTest.
50
  */
71
  * @param int $stackPtr The position where the token was found.
72
  * @param int $currScope The current scope opener token.
73
  *
74
+ * @return void|int Optionally returns a stack pointer. The sniff will not be
75
+ * called again on the current file until the returned stack
76
+ * pointer is reached. Return (count($tokens) + 1) to skip
77
+ * the rest of the file.
78
  */
79
  final protected function processTokenWithinScope(File $phpcsFile, $stackPtr, $currScope)
80
  {
86
  // Check to see if this string has a variable in it.
87
  $pattern = '|(?<!\\\\)(?:\\\\{2})*\${?[a-zA-Z0-9_]+}?|';
88
  if (preg_match($pattern, $tokens[$stackPtr]['content']) !== 0) {
89
+ return $this->processVariableInString($phpcsFile, $stackPtr);
90
  }
91
 
92
  return;
140
  }//end if
141
 
142
  if ($inFunction === true) {
143
+ return $this->processVariable($phpcsFile, $stackPtr);
144
  } else {
145
+ return $this->processMemberVar($phpcsFile, $stackPtr);
146
  }
147
 
148
  }//end processTokenWithinScope()
155
  * token was found.
156
  * @param int $stackPtr The position where the token was found.
157
  *
158
+ * @return void|int Optionally returns a stack pointer. The sniff will not be
159
+ * called again on the current file until the returned stack
160
+ * pointer is reached. Return (count($tokens) + 1) to skip
161
+ * the rest of the file.
162
  */
163
  final protected function processTokenOutsideScope(File $phpcsFile, $stackPtr)
164
  {
165
  $tokens = $phpcsFile->getTokens();
166
  // These variables are not member vars.
167
  if ($tokens[$stackPtr]['code'] === T_VARIABLE) {
168
+ return $this->processVariable($phpcsFile, $stackPtr);
169
  } else if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING
170
  || $tokens[$stackPtr]['code'] === T_HEREDOC
171
  ) {
172
  // Check to see if this string has a variable in it.
173
  $pattern = '|(?<!\\\\)(?:\\\\{2})*\${?[a-zA-Z0-9_]+}?|';
174
  if (preg_match($pattern, $tokens[$stackPtr]['content']) !== 0) {
175
+ return $this->processVariableInString($phpcsFile, $stackPtr);
176
  }
177
  }
178
 
186
  * token was found.
187
  * @param int $stackPtr The position where the token was found.
188
  *
189
+ * @return void|int Optionally returns a stack pointer. The sniff will not be
190
+ * called again on the current file until the returned stack
191
+ * pointer is reached. Return (count($tokens) + 1) to skip
192
+ * the rest of the file.
193
  */
194
  abstract protected function processMemberVar(File $phpcsFile, $stackPtr);
195
 
201
  * token was found.
202
  * @param int $stackPtr The position where the token was found.
203
  *
204
+ * @return void|int Optionally returns a stack pointer. The sniff will not be
205
+ * called again on the current file until the returned stack
206
+ * pointer is reached. Return (count($tokens) + 1) to skip
207
+ * the rest of the file.
208
  */
209
  abstract protected function processVariable(File $phpcsFile, $stackPtr);
210
 
220
  * @param int $stackPtr The position where the double quoted
221
  * string was found.
222
  *
223
+ * @return void|int Optionally returns a stack pointer. The sniff will not be
224
+ * called again on the current file until the returned stack
225
+ * pointer is reached. Return (count($tokens) + 1) to skip
226
+ * the rest of the file.
227
  */
228
  abstract protected function processVariableInString(File $phpcsFile, $stackPtr);
229
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/Commenting/FixmeStandard.xml CHANGED
@@ -1,4 +1,4 @@
1
- <documentation title="Todo Comments">
2
  <standard>
3
  <![CDATA[
4
  FIXME Statements should be taken care of.
1
+ <documentation title="Fixme Comments">
2
  <standard>
3
  <![CDATA[
4
  FIXME Statements should be taken care of.
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/PHP/LowerCaseConstantStandard.xml CHANGED
@@ -1,4 +1,4 @@
1
- <documentation title="PHP Constants">
2
  <standard>
3
  <![CDATA[
4
  The <em>true</em>, <em>false</em> and <em>null</em> constants must always be lowercase.
1
+ <documentation title="Lowercase PHP Constants">
2
  <standard>
3
  <![CDATA[
4
  The <em>true</em>, <em>false</em> and <em>null</em> constants must always be lowercase.
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/PHP/LowerCaseTypeStandard.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Lowercase PHP Types">
2
+ <standard>
3
+ <![CDATA[
4
+ All PHP types used for parameter type and return type declarations should be lowercase.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Lowercase type declarations used.">
9
+ <![CDATA[
10
+ function myFunction(int $foo) : string {
11
+ }
12
+ ]]>
13
+ </code>
14
+ <code title="Invalid: Non-lowercase type declarations used.">
15
+ <![CDATA[
16
+ function myFunction(<em>Int</em> $foo) : <em>STRING</em> {
17
+ }
18
+ ]]>
19
+ </code>
20
+ </code_comparison>
21
+ <standard>
22
+ <![CDATA[
23
+ All PHP types used for type casting should be lowercase.
24
+ ]]>
25
+ </standard>
26
+ <code_comparison>
27
+ <code title="Valid: Lowercase type used.">
28
+ <![CDATA[
29
+ $foo = (bool) $isValid;
30
+ ]]>
31
+ </code>
32
+ <code title="Invalid: Non-lowercase type used.">
33
+ <![CDATA[
34
+ $foo = <em>(BOOL)</em> $isValid;
35
+ ]]>
36
+ </code>
37
+ </code_comparison>
38
+ </documentation>
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/PHP/UpperCaseConstantStandard.xml CHANGED
@@ -1,4 +1,4 @@
1
- <documentation title="PHP Constants">
2
  <standard>
3
  <![CDATA[
4
  The <em>true</em>, <em>false</em> and <em>null</em> constants must always be uppercase.
1
+ <documentation title="Uppercase PHP Constants">
2
  <standard>
3
  <![CDATA[
4
  The <em>true</em>, <em>false</em> and <em>null</em> constants must always be uppercase.
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Docs/WhiteSpace/ArbitraryParenthesesSpacingStandard.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Arbitrary Parentheses Spacing">
2
+ <standard>
3
+ <![CDATA[
4
+ Arbitrary sets of parentheses should have no spaces inside.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: no spaces on the inside of a set of arbitrary parentheses.">
9
+ <![CDATA[
10
+ $a = (null !== $extra);
11
+ ]]>
12
+ </code>
13
+ <code title="Invalid: spaces on the inside of a set of arbitrary parentheses.">
14
+ <![CDATA[
15
+ $a = ( null !== $extra );
16
+ ]]>
17
+ </code>
18
+ <code title="Invalid: new lines on the inside of a set of arbitrary parentheses.">
19
+ <![CDATA[
20
+ $a = (
21
+ null !== $extra
22
+ );
23
+ ]]>
24
+ </code>
25
+ </code_comparison>
26
+ </documentation>
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Arrays/ArrayIndentSniff.php CHANGED
@@ -10,7 +10,6 @@
10
  namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays;
11
 
12
  use PHP_CodeSniffer\Sniffs\AbstractArraySniff;
13
- use PHP_CodeSniffer\Files\File;
14
  use PHP_CodeSniffer\Util\Tokens;
15
 
16
  class ArrayIndentSniff extends AbstractArraySniff
10
  namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays;
11
 
12
  use PHP_CodeSniffer\Sniffs\AbstractArraySniff;
 
13
  use PHP_CodeSniffer\Util\Tokens;
14
 
15
  class ArrayIndentSniff extends AbstractArraySniff
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php CHANGED
@@ -150,10 +150,15 @@ class AssignmentInConditionSniff implements Sniff
150
  }
151
 
152
  if ($hasVariable === true) {
 
 
 
 
 
153
  $phpcsFile->addWarning(
154
  'Variable assignment found within a condition. Did you mean to do a comparison ?',
155
  $hasAssignment,
156
- 'Found'
157
  );
158
  }
159
 
150
  }
151
 
152
  if ($hasVariable === true) {
153
+ $errorCode = 'Found';
154
+ if ($token['code'] === T_WHILE) {
155
+ $errorCode = 'FoundInWhileCondition';
156
+ }
157
+
158
  $phpcsFile->addWarning(
159
  'Variable assignment found within a condition. Did you mean to do a comparison ?',
160
  $hasAssignment,
161
+ $errorCode
162
  );
163
  }
164
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php CHANGED
@@ -119,74 +119,73 @@ class DocCommentSniff implements Sniff
119
  if ($tokens[$short]['code'] !== T_DOC_COMMENT_STRING) {
120
  $error = 'Missing short description in doc comment';
121
  $phpcsFile->addError($error, $stackPtr, 'MissingShort');
122
- return;
123
- }
 
 
 
 
 
 
 
 
 
 
 
124
 
125
- // No extra newline before short description.
126
- if ($tokens[$short]['line'] !== ($tokens[$stackPtr]['line'] + 1)) {
127
- $error = 'Doc comment short description must be on the first line';
128
- $fix = $phpcsFile->addFixableError($error, $short, 'SpacingBeforeShort');
129
- if ($fix === true) {
130
- $phpcsFile->fixer->beginChangeset();
131
- for ($i = $stackPtr; $i < $short; $i++) {
132
- if ($tokens[$i]['line'] === $tokens[$stackPtr]['line']) {
133
- continue;
134
- } else if ($tokens[$i]['line'] === $tokens[$short]['line']) {
135
- break;
136
  }
137
 
138
- $phpcsFile->fixer->replaceToken($i, '');
139
  }
140
-
141
- $phpcsFile->fixer->endChangeset();
142
  }
143
- }
144
 
145
- // Account for the fact that a short description might cover
146
- // multiple lines.
147
- $shortContent = $tokens[$short]['content'];
148
- $shortEnd = $short;
149
- for ($i = ($short + 1); $i < $commentEnd; $i++) {
150
- if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING) {
151
- if ($tokens[$i]['line'] === ($tokens[$shortEnd]['line'] + 1)) {
152
- $shortContent .= $tokens[$i]['content'];
153
- $shortEnd = $i;
154
- } else {
155
- break;
 
156
  }
157
  }
158
- }
159
 
160
- if (preg_match('/^\p{Ll}/u', $shortContent) === 1) {
161
- $error = 'Doc comment short description must start with a capital letter';
162
- $phpcsFile->addError($error, $short, 'ShortNotCapital');
163
- }
164
 
165
- $long = $phpcsFile->findNext($empty, ($shortEnd + 1), ($commentEnd - 1), true);
166
- if ($long !== false && $tokens[$long]['code'] === T_DOC_COMMENT_STRING) {
167
- if ($tokens[$long]['line'] !== ($tokens[$shortEnd]['line'] + 2)) {
168
- $error = 'There must be exactly one blank line between descriptions in a doc comment';
169
- $fix = $phpcsFile->addFixableError($error, $long, 'SpacingBetween');
170
- if ($fix === true) {
171
- $phpcsFile->fixer->beginChangeset();
172
- for ($i = ($shortEnd + 1); $i < $long; $i++) {
173
- if ($tokens[$i]['line'] === $tokens[$shortEnd]['line']) {
174
- continue;
175
- } else if ($tokens[$i]['line'] === ($tokens[$long]['line'] - 1)) {
176
- break;
 
 
 
177
  }
178
 
179
- $phpcsFile->fixer->replaceToken($i, '');
180
  }
181
-
182
- $phpcsFile->fixer->endChangeset();
183
  }
184
- }
185
 
186
- if (preg_match('/^\p{Ll}/u', $tokens[$long]['content']) === 1) {
187
- $error = 'Doc comment long description must start with a capital letter';
188
- $phpcsFile->addError($error, $long, 'LongNotCapital');
189
- }
 
190
  }//end if
191
 
192
  if (empty($tokens[$commentStart]['comment_tags']) === true) {
@@ -196,7 +195,9 @@ class DocCommentSniff implements Sniff
196
 
197
  $firstTag = $tokens[$commentStart]['comment_tags'][0];
198
  $prev = $phpcsFile->findPrevious($empty, ($firstTag - 1), $stackPtr, true);
199
- if ($tokens[$firstTag]['line'] !== ($tokens[$prev]['line'] + 2)) {
 
 
200
  $error = 'There must be exactly one blank line before the tags in a doc comment';
201
  $fix = $phpcsFile->addFixableError($error, $firstTag, 'SpacingBeforeTags');
202
  if ($fix === true) {
@@ -239,10 +240,8 @@ class DocCommentSniff implements Sniff
239
  }
240
 
241
  if ($tokens[$tag]['content'] === '@param') {
242
- if (($paramGroupid === null
243
- && empty($tagGroups[$groupid]) === false)
244
- || ($paramGroupid !== null
245
- && $paramGroupid !== $groupid)
246
  ) {
247
  $error = 'Parameter tags must be grouped together in a doc comment';
248
  $phpcsFile->addError($error, $tag, 'ParamGroup');
@@ -251,18 +250,22 @@ class DocCommentSniff implements Sniff
251
  if ($paramGroupid === null) {
252
  $paramGroupid = $groupid;
253
  }
254
- } else if ($groupid === $paramGroupid) {
255
- $error = 'Tag cannot be grouped with parameter tags in a doc comment';
256
- $phpcsFile->addError($error, $tag, 'NonParamGroup');
257
  }//end if
258
 
259
  $tagGroups[$groupid][] = $tag;
260
  }//end foreach
261
 
262
- foreach ($tagGroups as $group) {
263
  $maxLength = 0;
264
  $paddings = [];
265
  foreach ($group as $pos => $tag) {
 
 
 
 
 
 
 
266
  $tagLength = strlen($tokens[$tag]['content']);
267
  if ($tagLength > $maxLength) {
268
  $maxLength = $tagLength;
119
  if ($tokens[$short]['code'] !== T_DOC_COMMENT_STRING) {
120
  $error = 'Missing short description in doc comment';
121
  $phpcsFile->addError($error, $stackPtr, 'MissingShort');
122
+ } else {
123
+ // No extra newline before short description.
124
+ if ($tokens[$short]['line'] !== ($tokens[$stackPtr]['line'] + 1)) {
125
+ $error = 'Doc comment short description must be on the first line';
126
+ $fix = $phpcsFile->addFixableError($error, $short, 'SpacingBeforeShort');
127
+ if ($fix === true) {
128
+ $phpcsFile->fixer->beginChangeset();
129
+ for ($i = $stackPtr; $i < $short; $i++) {
130
+ if ($tokens[$i]['line'] === $tokens[$stackPtr]['line']) {
131
+ continue;
132
+ } else if ($tokens[$i]['line'] === $tokens[$short]['line']) {
133
+ break;
134
+ }
135
 
136
+ $phpcsFile->fixer->replaceToken($i, '');
 
 
 
 
 
 
 
 
 
 
137
  }
138
 
139
+ $phpcsFile->fixer->endChangeset();
140
  }
 
 
141
  }
 
142
 
143
+ // Account for the fact that a short description might cover
144
+ // multiple lines.
145
+ $shortContent = $tokens[$short]['content'];
146
+ $shortEnd = $short;
147
+ for ($i = ($short + 1); $i < $commentEnd; $i++) {
148
+ if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING) {
149
+ if ($tokens[$i]['line'] === ($tokens[$shortEnd]['line'] + 1)) {
150
+ $shortContent .= $tokens[$i]['content'];
151
+ $shortEnd = $i;
152
+ } else {
153
+ break;
154
+ }
155
  }
156
  }
 
157
 
158
+ if (preg_match('/^\p{Ll}/u', $shortContent) === 1) {
159
+ $error = 'Doc comment short description must start with a capital letter';
160
+ $phpcsFile->addError($error, $short, 'ShortNotCapital');
161
+ }
162
 
163
+ $long = $phpcsFile->findNext($empty, ($shortEnd + 1), ($commentEnd - 1), true);
164
+ if ($long !== false && $tokens[$long]['code'] === T_DOC_COMMENT_STRING) {
165
+ if ($tokens[$long]['line'] !== ($tokens[$shortEnd]['line'] + 2)) {
166
+ $error = 'There must be exactly one blank line between descriptions in a doc comment';
167
+ $fix = $phpcsFile->addFixableError($error, $long, 'SpacingBetween');
168
+ if ($fix === true) {
169
+ $phpcsFile->fixer->beginChangeset();
170
+ for ($i = ($shortEnd + 1); $i < $long; $i++) {
171
+ if ($tokens[$i]['line'] === $tokens[$shortEnd]['line']) {
172
+ continue;
173
+ } else if ($tokens[$i]['line'] === ($tokens[$long]['line'] - 1)) {
174
+ break;
175
+ }
176
+
177
+ $phpcsFile->fixer->replaceToken($i, '');
178
  }
179
 
180
+ $phpcsFile->fixer->endChangeset();
181
  }
 
 
182
  }
 
183
 
184
+ if (preg_match('/^\p{Ll}/u', $tokens[$long]['content']) === 1) {
185
+ $error = 'Doc comment long description must start with a capital letter';
186
+ $phpcsFile->addError($error, $long, 'LongNotCapital');
187
+ }
188
+ }//end if
189
  }//end if
190
 
191
  if (empty($tokens[$commentStart]['comment_tags']) === true) {
195
 
196
  $firstTag = $tokens[$commentStart]['comment_tags'][0];
197
  $prev = $phpcsFile->findPrevious($empty, ($firstTag - 1), $stackPtr, true);
198
+ if ($tokens[$firstTag]['line'] !== ($tokens[$prev]['line'] + 2)
199
+ && $tokens[$prev]['code'] !== T_DOC_COMMENT_OPEN_TAG
200
+ ) {
201
  $error = 'There must be exactly one blank line before the tags in a doc comment';
202
  $fix = $phpcsFile->addFixableError($error, $firstTag, 'SpacingBeforeTags');
203
  if ($fix === true) {
240
  }
241
 
242
  if ($tokens[$tag]['content'] === '@param') {
243
+ if ($paramGroupid !== null
244
+ && $paramGroupid !== $groupid
 
 
245
  ) {
246
  $error = 'Parameter tags must be grouped together in a doc comment';
247
  $phpcsFile->addError($error, $tag, 'ParamGroup');
250
  if ($paramGroupid === null) {
251
  $paramGroupid = $groupid;
252
  }
 
 
 
253
  }//end if
254
 
255
  $tagGroups[$groupid][] = $tag;
256
  }//end foreach
257
 
258
+ foreach ($tagGroups as $groupid => $group) {
259
  $maxLength = 0;
260
  $paddings = [];
261
  foreach ($group as $pos => $tag) {
262
+ if ($paramGroupid === $groupid
263
+ && $tokens[$tag]['content'] !== '@param'
264
+ ) {
265
+ $error = 'Tag cannot be grouped with parameter tags in a doc comment';
266
+ $phpcsFile->addError($error, $tag, 'NonParamGroup');
267
+ }
268
+
269
  $tagLength = strlen($tokens[$tag]['content']);
270
  if ($tagLength > $maxLength) {
271
  $maxLength = $tagLength;
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php CHANGED
@@ -191,6 +191,12 @@ class InlineControlStructureSniff implements Sniff
191
  if ($type === T_TRY && $nextType === T_CATCH) {
192
  $end = $tokens[$next]['scope_closer'];
193
  }
 
 
 
 
 
 
194
  }//end if
195
 
196
  if ($tokens[$end]['code'] !== T_END_HEREDOC
@@ -215,30 +221,34 @@ class InlineControlStructureSniff implements Sniff
215
  $end = $lastNonEmpty;
216
  }
217
 
218
- $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($end + 1), null, true);
219
-
220
- if ($next === false || $tokens[$next]['line'] !== $tokens[$end]['line']) {
221
  // Looks for completely empty statements.
222
  $next = $phpcsFile->findNext(T_WHITESPACE, ($closer + 1), ($end + 1), true);
223
-
224
- // Account for a comment on the end of the line.
225
- for ($endLine = $end; $endLine < $phpcsFile->numTokens; $endLine++) {
226
- if (isset($tokens[($endLine + 1)]) === false
227
- || $tokens[$endLine]['line'] !== $tokens[($endLine + 1)]['line']
228
- ) {
229
- break;
230
- }
231
- }
232
-
233
- if ($tokens[$endLine]['code'] !== T_COMMENT) {
234
- $endLine = $end;
235
- }
236
  } else {
237
  $next = ($end + 1);
238
  $endLine = $end;
239
  }
240
 
241
  if ($next !== $end) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  if ($endLine !== $end) {
243
  $endToken = $endLine;
244
  $addedContent = '';
@@ -262,9 +272,7 @@ class InlineControlStructureSniff implements Sniff
262
  } else {
263
  $indent = '';
264
  for ($first = $stackPtr; $first > 0; $first--) {
265
- if ($first === 1
266
- || $tokens[($first - 1)]['line'] !== $tokens[$first]['line']
267
- ) {
268
  break;
269
  }
270
  }
@@ -285,6 +293,24 @@ class InlineControlStructureSniff implements Sniff
285
  $phpcsFile->fixer->addContent($endToken, $addedContent);
286
  }//end if
287
  } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
  if ($endLine !== $end) {
289
  $phpcsFile->fixer->replaceToken($end, '');
290
  $phpcsFile->fixer->addNewlineBefore($endLine);
191
  if ($type === T_TRY && $nextType === T_CATCH) {
192
  $end = $tokens[$next]['scope_closer'];
193
  }
194
+ } else if ($type === T_CLOSURE) {
195
+ // There should be a semicolon after the closing brace.
196
+ $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($end + 1), null, true);
197
+ if ($next !== false && $tokens[$next]['code'] === T_SEMICOLON) {
198
+ $end = $next;
199
+ }
200
  }//end if
201
 
202
  if ($tokens[$end]['code'] !== T_END_HEREDOC
221
  $end = $lastNonEmpty;
222
  }
223
 
224
+ $nextContent = $phpcsFile->findNext(Tokens::$emptyTokens, ($end + 1), null, true);
225
+ if ($nextContent === false || $tokens[$nextContent]['line'] !== $tokens[$end]['line']) {
 
226
  // Looks for completely empty statements.
227
  $next = $phpcsFile->findNext(T_WHITESPACE, ($closer + 1), ($end + 1), true);
 
 
 
 
 
 
 
 
 
 
 
 
 
228
  } else {
229
  $next = ($end + 1);
230
  $endLine = $end;
231
  }
232
 
233
  if ($next !== $end) {
234
+ if ($nextContent === false || $tokens[$nextContent]['line'] !== $tokens[$end]['line']) {
235
+ // Account for a comment on the end of the line.
236
+ for ($endLine = $end; $endLine < $phpcsFile->numTokens; $endLine++) {
237
+ if (isset($tokens[($endLine + 1)]) === false
238
+ || $tokens[$endLine]['line'] !== $tokens[($endLine + 1)]['line']
239
+ ) {
240
+ break;
241
+ }
242
+ }
243
+
244
+ if (isset(Tokens::$commentTokens[$tokens[$endLine]['code']]) === false
245
+ && ($tokens[$endLine]['code'] !== T_WHITESPACE
246
+ || isset(Tokens::$commentTokens[$tokens[($endLine - 1)]['code']]) === false)
247
+ ) {
248
+ $endLine = $end;
249
+ }
250
+ }
251
+
252
  if ($endLine !== $end) {
253
  $endToken = $endLine;
254
  $addedContent = '';
272
  } else {
273
  $indent = '';
274
  for ($first = $stackPtr; $first > 0; $first--) {
275
+ if ($tokens[$first]['column'] === 1) {
 
 
276
  break;
277
  }
278
  }
293
  $phpcsFile->fixer->addContent($endToken, $addedContent);
294
  }//end if
295
  } else {
296
+ if ($nextContent === false || $tokens[$nextContent]['line'] !== $tokens[$end]['line']) {
297
+ // Account for a comment on the end of the line.
298
+ for ($endLine = $end; $endLine < $phpcsFile->numTokens; $endLine++) {
299
+ if (isset($tokens[($endLine + 1)]) === false
300
+ || $tokens[$endLine]['line'] !== $tokens[($endLine + 1)]['line']
301
+ ) {
302
+ break;
303
+ }
304
+ }
305
+
306
+ if ($tokens[$endLine]['code'] !== T_COMMENT
307
+ && ($tokens[$endLine]['code'] !== T_WHITESPACE
308
+ || $tokens[($endLine - 1)]['code'] !== T_COMMENT)
309
+ ) {
310
+ $endLine = $end;
311
+ }
312
+ }
313
+
314
  if ($endLine !== $end) {
315
  $phpcsFile->fixer->replaceToken($end, '');
316
  $phpcsFile->fixer->addNewlineBefore($endLine);
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php CHANGED
@@ -96,10 +96,12 @@ class MultipleStatementAlignmentSniff implements Sniff
96
  * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
97
  * @param int $stackPtr The position of the current token
98
  * in the stack passed in $tokens.
 
 
99
  *
100
  * @return int
101
  */
102
- public function checkAlignment($phpcsFile, $stackPtr)
103
  {
104
  $tokens = $phpcsFile->getTokens();
105
 
@@ -110,42 +112,66 @@ class MultipleStatementAlignmentSniff implements Sniff
110
  $stopped = null;
111
  $lastCode = $stackPtr;
112
  $lastSemi = null;
 
 
 
 
 
113
 
114
  $find = Tokens::$assignmentTokens;
115
  unset($find[T_DOUBLE_ARROW]);
116
 
117
- for ($assign = $stackPtr; $assign < $phpcsFile->numTokens; $assign++) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  if (isset($find[$tokens[$assign]['code']]) === false) {
119
- if ($tokens[$assign]['code'] === T_CLOSURE
120
- || $tokens[$assign]['code'] === T_ANON_CLASS
 
 
 
121
  ) {
122
- $assign = $tokens[$assign]['scope_closer'];
123
- $lastCode = $assign;
124
- continue;
 
 
 
125
  }
126
 
127
- // Skip past the content of arrays.
128
  if ($tokens[$assign]['code'] === T_OPEN_SHORT_ARRAY
129
  && isset($tokens[$assign]['bracket_closer']) === true
130
  ) {
131
- $assign = $lastCode = $tokens[$assign]['bracket_closer'];
132
- continue;
133
  }
134
 
135
  if ($tokens[$assign]['code'] === T_ARRAY
136
  && isset($tokens[$assign]['parenthesis_opener']) === true
137
  && isset($tokens[$tokens[$assign]['parenthesis_opener']]['parenthesis_closer']) === true
138
  ) {
139
- $assign = $lastCode = $tokens[$tokens[$assign]['parenthesis_opener']]['parenthesis_closer'];
140
- continue;
141
  }
142
 
143
- // A blank line indicates that the assignment block has ended.
144
  if (isset(Tokens::$emptyTokens[$tokens[$assign]['code']]) === false) {
145
- if (($tokens[$assign]['line'] - $tokens[$lastCode]['line']) > 1) {
146
- break;
147
- }
148
-
149
  $lastCode = $assign;
150
 
151
  if ($tokens[$assign]['code'] === T_SEMICOLON) {
@@ -156,7 +182,7 @@ class MultipleStatementAlignmentSniff implements Sniff
156
  } else {
157
  $lastSemi = $assign;
158
  }
159
- } else {
160
  // Statement is in a different context, so the block is over.
161
  break;
162
  }
@@ -171,9 +197,22 @@ class MultipleStatementAlignmentSniff implements Sniff
171
  }//end if
172
 
173
  if ($assign !== $stackPtr) {
174
- // Has to be nested inside the same conditions as the first assignment.
175
- if ($tokens[$assign]['conditions'] !== $tokens[$stackPtr]['conditions']) {
 
 
 
 
 
 
176
  break;
 
 
 
 
 
 
 
177
  }
178
 
179
  // Make sure it is not assigned inside a condition (eg. IF, FOR).
@@ -199,6 +238,11 @@ class MultipleStatementAlignmentSniff implements Sniff
199
  $varEnd = $tokens[($var + 1)]['column'];
200
  $assignLen = $tokens[$assign]['length'];
201
  if ($assign !== $stackPtr) {
 
 
 
 
 
202
  if (($varEnd + 1) > $assignments[$prevAssign]['assign_col']) {
203
  $padding = 1;
204
  $assignColumn = ($varEnd + 1);
@@ -334,7 +378,7 @@ class MultipleStatementAlignmentSniff implements Sniff
334
  if ($stopped !== null) {
335
  return $this->checkAlignment($phpcsFile, $stopped);
336
  } else {
337
- return $assignment;
338
  }
339
 
340
  }//end checkAlignment()
96
  * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
97
  * @param int $stackPtr The position of the current token
98
  * in the stack passed in $tokens.
99
+ * @param int $end The token where checking should end.
100
+ * If NULL, the entire file will be checked.
101
  *
102
  * @return int
103
  */
104
+ public function checkAlignment($phpcsFile, $stackPtr, $end=null)
105
  {
106
  $tokens = $phpcsFile->getTokens();
107
 
112
  $stopped = null;
113
  $lastCode = $stackPtr;
114
  $lastSemi = null;
115
+ $arrayEnd = null;
116
+
117
+ if ($end === null) {
118
+ $end = $phpcsFile->numTokens;
119
+ }
120
 
121
  $find = Tokens::$assignmentTokens;
122
  unset($find[T_DOUBLE_ARROW]);
123
 
124
+ $scopes = Tokens::$scopeOpeners;
125
+ unset($scopes[T_CLOSURE]);
126
+ unset($scopes[T_ANON_CLASS]);
127
+ unset($scopes[T_OBJECT]);
128
+
129
+ for ($assign = $stackPtr; $assign < $end; $assign++) {
130
+ if ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) {
131
+ // Statement is in a different context, so the block is over.
132
+ break;
133
+ }
134
+
135
+ if (isset($scopes[$tokens[$assign]['code']]) === true
136
+ && isset($tokens[$assign]['scope_opener']) === true
137
+ && $tokens[$assign]['level'] === $tokens[$stackPtr]['level']
138
+ ) {
139
+ break;
140
+ }
141
+
142
+ if ($assign === $arrayEnd) {
143
+ $arrayEnd = null;
144
+ }
145
+
146
  if (isset($find[$tokens[$assign]['code']]) === false) {
147
+ // A blank line indicates that the assignment block has ended.
148
+ if (isset(Tokens::$emptyTokens[$tokens[$assign]['code']]) === false
149
+ && ($tokens[$assign]['line'] - $tokens[$lastCode]['line']) > 1
150
+ && $tokens[$assign]['level'] === $tokens[$stackPtr]['level']
151
+ && $arrayEnd === null
152
  ) {
153
+ break;
154
+ }
155
+
156
+ if ($tokens[$assign]['code'] === T_CLOSE_TAG) {
157
+ // Breaking out of PHP ends the assignment block.
158
+ break;
159
  }
160
 
 
161
  if ($tokens[$assign]['code'] === T_OPEN_SHORT_ARRAY
162
  && isset($tokens[$assign]['bracket_closer']) === true
163
  ) {
164
+ $arrayEnd = $tokens[$assign]['bracket_closer'];
 
165
  }
166
 
167
  if ($tokens[$assign]['code'] === T_ARRAY
168
  && isset($tokens[$assign]['parenthesis_opener']) === true
169
  && isset($tokens[$tokens[$assign]['parenthesis_opener']]['parenthesis_closer']) === true
170
  ) {
171
+ $arrayEnd = $tokens[$tokens[$assign]['parenthesis_opener']]['parenthesis_closer'];
 
172
  }
173
 
 
174
  if (isset(Tokens::$emptyTokens[$tokens[$assign]['code']]) === false) {
 
 
 
 
175
  $lastCode = $assign;
176
 
177
  if ($tokens[$assign]['code'] === T_SEMICOLON) {
182
  } else {
183
  $lastSemi = $assign;
184
  }
185
+ } else if ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) {
186
  // Statement is in a different context, so the block is over.
187
  break;
188
  }
197
  }//end if
198
 
199
  if ($assign !== $stackPtr) {
200
+ if ($tokens[$assign]['level'] > $tokens[$stackPtr]['level']) {
201
+ // Has to be nested inside the same conditions as the first assignment.
202
+ // We've gone one level down, so process this new block.
203
+ $assign = $this->checkAlignment($phpcsFile, $assign);
204
+ $lastCode = $assign;
205
+ continue;
206
+ } else if ($tokens[$assign]['level'] < $tokens[$stackPtr]['level']) {
207
+ // We've gone one level up, so the block we are processing is done.
208
  break;
209
+ } else if ($arrayEnd !== null) {
210
+ // Assignments inside arrays are not part of
211
+ // the original block, so process this new block.
212
+ $assign = ($this->checkAlignment($phpcsFile, $assign, $arrayEnd) - 1);
213
+ $arrayEnd = null;
214
+ $lastCode = $assign;
215
+ continue;
216
  }
217
 
218
  // Make sure it is not assigned inside a condition (eg. IF, FOR).
238
  $varEnd = $tokens[($var + 1)]['column'];
239
  $assignLen = $tokens[$assign]['length'];
240
  if ($assign !== $stackPtr) {
241
+ if ($prevAssign === null) {
242
+ // Processing an inner block but no assignments found.
243
+ break;
244
+ }
245
+
246
  if (($varEnd + 1) > $assignments[$prevAssign]['assign_col']) {
247
  $padding = 1;
248
  $assignColumn = ($varEnd + 1);
378
  if ($stopped !== null) {
379
  return $this->checkAlignment($phpcsFile, $stopped);
380
  } else {
381
+ return $assign;
382
  }
383
 
384
  }//end checkAlignment()
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php CHANGED
@@ -11,7 +11,6 @@ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Formatting;
11
 
12
  use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
14
- use PHP_CodeSniffer\Util\Tokens;
15
 
16
  class SpaceAfterNotSniff implements Sniff
17
  {
11
 
12
  use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
 
14
 
15
  class SpaceAfterNotSniff implements Sniff
16
  {
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php CHANGED
@@ -115,10 +115,19 @@ class FunctionCallArgumentSpacingSniff implements Sniff
115
  $error = 'Space found before comma in function call';
116
  $fix = $phpcsFile->addFixableError($error, $nextSeparator, 'SpaceBeforeComma');
117
  if ($fix === true) {
118
- $phpcsFile->fixer->replaceToken(($nextSeparator - 1), '');
 
 
 
 
 
 
 
 
 
119
  }
120
- }
121
- }
122
 
123
  if ($tokens[($nextSeparator + 1)]['code'] !== T_WHITESPACE) {
124
  $error = 'No space found after comma in function call';
115
  $error = 'Space found before comma in function call';
116
  $fix = $phpcsFile->addFixableError($error, $nextSeparator, 'SpaceBeforeComma');
117
  if ($fix === true) {
118
+ $phpcsFile->fixer->beginChangeset();
119
+
120
+ if ($tokens[$prev]['line'] !== $tokens[$nextSeparator]['line']) {
121
+ $phpcsFile->fixer->addContent($prev, ',');
122
+ $phpcsFile->fixer->replaceToken($nextSeparator, '');
123
+ } else {
124
+ $phpcsFile->fixer->replaceToken(($nextSeparator - 1), '');
125
+ }
126
+
127
+ $phpcsFile->fixer->endChangeset();
128
  }
129
+ }//end if
130
+ }//end if
131
 
132
  if ($tokens[($nextSeparator + 1)]['code'] !== T_WHITESPACE) {
133
  $error = 'No space found after comma in function call';
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php CHANGED
@@ -11,6 +11,7 @@ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\Functions;
11
 
12
  use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
 
14
 
15
  class OpeningFunctionBraceBsdAllmanSniff implements Sniff
16
  {
@@ -80,26 +81,61 @@ class OpeningFunctionBraceBsdAllmanSniff implements Sniff
80
  }
81
  }
82
 
83
- $functionLine = $tokens[$closeBracket]['line'];
 
 
 
84
  $braceLine = $tokens[$openingBrace]['line'];
85
 
86
  $lineDifference = ($braceLine - $functionLine);
87
 
 
 
 
 
 
88
  if ($lineDifference === 0) {
89
  $error = 'Opening brace should be on a new line';
90
  $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceOnSameLine');
91
  if ($fix === true) {
 
 
 
 
 
 
 
 
 
 
 
92
  $phpcsFile->fixer->beginChangeset();
93
  $indent = $phpcsFile->findFirstOnLine([], $openingBrace);
94
- if ($tokens[$indent]['code'] === T_WHITESPACE) {
95
- $phpcsFile->fixer->addContentBefore($openingBrace, $tokens[$indent]['content']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
96
  }
97
 
98
- $phpcsFile->fixer->addNewlineBefore($openingBrace);
99
  $phpcsFile->fixer->endChangeset();
100
- }
101
 
102
- $phpcsFile->recordMetric($stackPtr, 'Function opening brace placement', 'same line');
103
  } else if ($lineDifference > 1) {
104
  $error = 'Opening brace should be on the line after the declaration; found %s blank line(s)';
105
  $data = [($lineDifference - 1)];
@@ -116,7 +152,9 @@ class OpeningFunctionBraceBsdAllmanSniff implements Sniff
116
  }
117
  }//end if
118
 
119
- $next = $phpcsFile->findNext(T_WHITESPACE, ($openingBrace + 1), null, true);
 
 
120
  if ($tokens[$next]['line'] === $tokens[$openingBrace]['line']) {
121
  if ($next === $tokens[$stackPtr]['scope_closer']) {
122
  // Ignore empty functions.
@@ -167,7 +205,7 @@ class OpeningFunctionBraceBsdAllmanSniff implements Sniff
167
  }
168
  }//end if
169
 
170
- $phpcsFile->recordMetric($stackPtr, 'Function opening brace placement', 'new line');
171
 
172
  }//end process()
173
 
11
 
12
  use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
14
+ use PHP_CodeSniffer\Util\Tokens;
15
 
16
  class OpeningFunctionBraceBsdAllmanSniff implements Sniff
17
  {
81
  }
82
  }
83
 
84
+ // Find the end of the function declaration.
85
+ $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($openingBrace - 1), $closeBracket, true);
86
+
87
+ $functionLine = $tokens[$prev]['line'];
88
  $braceLine = $tokens[$openingBrace]['line'];
89
 
90
  $lineDifference = ($braceLine - $functionLine);
91
 
92
+ $metricType = 'Function';
93
+ if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
94
+ $metricType = 'Closure';
95
+ }
96
+
97
  if ($lineDifference === 0) {
98
  $error = 'Opening brace should be on a new line';
99
  $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceOnSameLine');
100
  if ($fix === true) {
101
+ $hasTrailingAnnotation = false;
102
+ for ($nextLine = ($openingBrace + 1); $nextLine < $phpcsFile->numTokens; $nextLine++) {
103
+ if ($tokens[$openingBrace]['line'] !== $tokens[$nextLine]['line']) {
104
+ break;
105
+ }
106
+
107
+ if (isset(Tokens::$phpcsCommentTokens[$tokens[$nextLine]['code']]) === true) {
108
+ $hasTrailingAnnotation = true;
109
+ }
110
+ }
111
+
112
  $phpcsFile->fixer->beginChangeset();
113
  $indent = $phpcsFile->findFirstOnLine([], $openingBrace);
114
+
115
+ if ($hasTrailingAnnotation === false || $nextLine === false) {
116
+ if ($tokens[$indent]['code'] === T_WHITESPACE) {
117
+ $phpcsFile->fixer->addContentBefore($openingBrace, $tokens[$indent]['content']);
118
+ }
119
+
120
+ if ($tokens[($openingBrace - 1)]['code'] === T_WHITESPACE) {
121
+ $phpcsFile->fixer->replaceToken(($openingBrace - 1), '');
122
+ }
123
+
124
+ $phpcsFile->fixer->addNewlineBefore($openingBrace);
125
+ } else {
126
+ $phpcsFile->fixer->replaceToken($openingBrace, '');
127
+ $phpcsFile->fixer->addNewlineBefore($nextLine);
128
+ $phpcsFile->fixer->addContentBefore($nextLine, '{');
129
+
130
+ if ($tokens[$indent]['code'] === T_WHITESPACE) {
131
+ $phpcsFile->fixer->addContentBefore($nextLine, $tokens[$indent]['content']);
132
+ }
133
  }
134
 
 
135
  $phpcsFile->fixer->endChangeset();
136
+ }//end if
137
 
138
+ $phpcsFile->recordMetric($stackPtr, "$metricType opening brace placement", 'same line');
139
  } else if ($lineDifference > 1) {
140
  $error = 'Opening brace should be on the line after the declaration; found %s blank line(s)';
141
  $data = [($lineDifference - 1)];
152
  }
153
  }//end if
154
 
155
+ $ignore = Tokens::$phpcsCommentTokens;
156
+ $ignore[] = T_WHITESPACE;
157
+ $next = $phpcsFile->findNext($ignore, ($openingBrace + 1), null, true);
158
  if ($tokens[$next]['line'] === $tokens[$openingBrace]['line']) {
159
  if ($next === $tokens[$stackPtr]['scope_closer']) {
160
  // Ignore empty functions.
205
  }
206
  }//end if
207
 
208
+ $phpcsFile->recordMetric($stackPtr, "$metricType opening brace placement", 'new line');
209
 
210
  }//end process()
211
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php CHANGED
@@ -82,13 +82,21 @@ class OpeningFunctionBraceKernighanRitchieSniff implements Sniff
82
  }
83
  }
84
 
85
- $functionLine = $tokens[$closeBracket]['line'];
 
 
 
86
  $braceLine = $tokens[$openingBrace]['line'];
87
 
88
  $lineDifference = ($braceLine - $functionLine);
89
 
 
 
 
 
 
90
  if ($lineDifference > 0) {
91
- $phpcsFile->recordMetric($stackPtr, 'Function opening brace placement', 'new line');
92
  $error = 'Opening brace should be on the same line as the declaration';
93
  $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceOnNewLine');
94
  if ($fix === true) {
@@ -107,7 +115,7 @@ class OpeningFunctionBraceKernighanRitchieSniff implements Sniff
107
  && $tokens[($openingBrace - 1)]['line'] === $tokens[$openingBrace]['line']
108
  && $tokens[($openingBrace - 2)]['line'] < $tokens[$openingBrace]['line']
109
  ) {
110
- // Brace is preceeded by indent, so remove it to ensure we don't
111
  // leave behind more indent than is required for the first line.
112
  $phpcsFile->fixer->replaceToken(($openingBrace - 1), '');
113
  }
@@ -116,10 +124,12 @@ class OpeningFunctionBraceKernighanRitchieSniff implements Sniff
116
  $phpcsFile->fixer->endChangeset();
117
  }//end if
118
  } else {
119
- $phpcsFile->recordMetric($stackPtr, 'Function opening brace placement', 'same line');
120
  }//end if
121
 
122
- $next = $phpcsFile->findNext(T_WHITESPACE, ($openingBrace + 1), null, true);
 
 
123
  if ($tokens[$next]['line'] === $tokens[$openingBrace]['line']) {
124
  if ($next === $tokens[$stackPtr]['scope_closer']
125
  || $tokens[$next]['code'] === T_CLOSE_TAG
82
  }
83
  }
84
 
85
+ // Find the end of the function declaration.
86
+ $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($openingBrace - 1), $closeBracket, true);
87
+
88
+ $functionLine = $tokens[$prev]['line'];
89
  $braceLine = $tokens[$openingBrace]['line'];
90
 
91
  $lineDifference = ($braceLine - $functionLine);
92
 
93
+ $metricType = 'Function';
94
+ if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
95
+ $metricType = 'Closure';
96
+ }
97
+
98
  if ($lineDifference > 0) {
99
+ $phpcsFile->recordMetric($stackPtr, "$metricType opening brace placement", 'new line');
100
  $error = 'Opening brace should be on the same line as the declaration';
101
  $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceOnNewLine');
102
  if ($fix === true) {
115
  && $tokens[($openingBrace - 1)]['line'] === $tokens[$openingBrace]['line']
116
  && $tokens[($openingBrace - 2)]['line'] < $tokens[$openingBrace]['line']
117
  ) {
118
+ // Brace is preceded by indent, so remove it to ensure we don't
119
  // leave behind more indent than is required for the first line.
120
  $phpcsFile->fixer->replaceToken(($openingBrace - 1), '');
121
  }
124
  $phpcsFile->fixer->endChangeset();
125
  }//end if
126
  } else {
127
+ $phpcsFile->recordMetric($stackPtr, "$metricType opening brace placement", 'same line');
128
  }//end if
129
 
130
+ $ignore = Tokens::$phpcsCommentTokens;
131
+ $ignore[] = T_WHITESPACE;
132
+ $next = $phpcsFile->findNext($ignore, ($openingBrace + 1), null, true);
133
  if ($tokens[$next]['line'] === $tokens[$openingBrace]['line']) {
134
  if ($next === $tokens[$stackPtr]['scope_closer']
135
  || $tokens[$next]['code'] === T_CLOSE_TAG
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php CHANGED
@@ -58,8 +58,6 @@ class CyclomaticComplexitySniff implements Sniff
58
  */
59
  public function process(File $phpcsFile, $stackPtr)
60
  {
61
- $this->currentFile = $phpcsFile;
62
-
63
  $tokens = $phpcsFile->getTokens();
64
 
65
  // Ignore abstract methods.
58
  */
59
  public function process(File $phpcsFile, $stackPtr)
60
  {
 
 
61
  $tokens = $phpcsFile->getTokens();
62
 
63
  // Ignore abstract methods.
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php CHANGED
@@ -19,7 +19,7 @@ class DeprecatedFunctionsSniff extends ForbiddenFunctionsSniff
19
  * The value is NULL if no alternative exists. IE, the
20
  * function should just not be used.
21
  *
22
- * @var array(string => string|null)
23
  */
24
  public $forbiddenFunctions = [];
25
 
19
  * The value is NULL if no alternative exists. IE, the
20
  * function should just not be used.
21
  *
22
+ * @var array<string, string|null>
23
  */
24
  public $forbiddenFunctions = [];
25
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php CHANGED
@@ -131,9 +131,8 @@ class DisallowAlternativePHPTagsSniff implements Sniff
131
  }//end if
132
 
133
  // Account for incorrect script open tags.
134
- // The "(?:<s)?" in the regex is to work-around a bug in PHP 5.2.
135
  if ($openTag['code'] === T_INLINE_HTML
136
- && preg_match('`((?:<s)?cript (?:[^>]+)?language=[\'"]?php[\'"]?(?:[^>]+)?>)`i', $content, $match) === 1
137
  ) {
138
  $error = 'Script style opening tag used; expected "<?php" but found "%s"';
139
  $snippet = $this->getSnippet($content, $match[1]);
131
  }//end if
132
 
133
  // Account for incorrect script open tags.
 
134
  if ($openTag['code'] === T_INLINE_HTML
135
+ && preg_match('`(<script (?:[^>]+)?language=[\'"]?php[\'"]?(?:[^>]+)?>)`i', $content, $match) === 1
136
  ) {
137
  $error = 'Script style opening tag used; expected "<?php" but found "%s"';
138
  $snippet = $this->getSnippet($content, $match[1]);
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php CHANGED
@@ -11,6 +11,7 @@ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP;
11
 
12
  use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
 
14
 
15
  class LowerCaseKeywordSniff implements Sniff
16
  {
@@ -27,7 +28,6 @@ class LowerCaseKeywordSniff implements Sniff
27
  T_HALT_COMPILER,
28
  T_ABSTRACT,
29
  T_ARRAY,
30
- T_ARRAY_HINT,
31
  T_AS,
32
  T_BREAK,
33
  T_CALLABLE,
@@ -120,10 +120,12 @@ class LowerCaseKeywordSniff implements Sniff
120
  $phpcsFile->recordMetric($stackPtr, 'PHP keyword case', 'mixed');
121
  }
122
 
 
 
123
  $error = 'PHP keywords must be lowercase; expected "%s" but found "%s"';
124
  $data = [
125
- strtolower($keyword),
126
- $keyword,
127
  ];
128
 
129
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data);
@@ -132,7 +134,7 @@ class LowerCaseKeywordSniff implements Sniff
132
  }
133
  } else {
134
  $phpcsFile->recordMetric($stackPtr, 'PHP keyword case', 'lower');
135
- }
136
 
137
  }//end process()
138
 
11
 
12
  use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
14
+ use PHP_CodeSniffer\Util;
15
 
16
  class LowerCaseKeywordSniff implements Sniff
17
  {
28
  T_HALT_COMPILER,
29
  T_ABSTRACT,
30
  T_ARRAY,
 
31
  T_AS,
32
  T_BREAK,
33
  T_CALLABLE,
120
  $phpcsFile->recordMetric($stackPtr, 'PHP keyword case', 'mixed');
121
  }
122
 
123
+ $messageKeyword = Util\Common::prepareForOutput($keyword);
124
+
125
  $error = 'PHP keywords must be lowercase; expected "%s" but found "%s"';
126
  $data = [
127
+ strtolower($messageKeyword),
128
+ $messageKeyword,
129
  ];
130
 
131
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data);
134
  }
135
  } else {
136
  $phpcsFile->recordMetric($stackPtr, 'PHP keyword case', 'lower');
137
+ }//end if
138
 
139
  }//end process()
140
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/LowerCaseTypeSniff.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Checks that all PHP types are lowercase.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\PHP;
11
+
12
+ use PHP_CodeSniffer\Sniffs\Sniff;
13
+ use PHP_CodeSniffer\Files\File;
14
+ use PHP_CodeSniffer\Util\Tokens;
15
+
16
+ class LowerCaseTypeSniff implements Sniff
17
+ {
18
+
19
+
20
+ /**
21
+ * Returns an array of tokens this test wants to listen for.
22
+ *
23
+ * @return array
24
+ */
25
+ public function register()
26
+ {
27
+ $tokens = Tokens::$castTokens;
28
+ $tokens[] = T_FUNCTION;
29
+ $tokens[] = T_CLOSURE;
30
+ return $tokens;
31
+
32
+ }//end register()
33
+
34
+
35
+ /**
36
+ * Processes this sniff, when one of its tokens is encountered.
37
+ *
38
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
39
+ * @param int $stackPtr The position of the current token in the
40
+ * stack passed in $tokens.
41
+ *
42
+ * @return void
43
+ */
44
+ public function process(File $phpcsFile, $stackPtr)
45
+ {
46
+ $tokens = $phpcsFile->getTokens();
47
+
48
+ if (isset(Tokens::$castTokens[$tokens[$stackPtr]['code']]) === true) {
49
+ // A cast token.
50
+ if (strtolower($tokens[$stackPtr]['content']) !== $tokens[$stackPtr]['content']) {
51
+ if ($tokens[$stackPtr]['content'] === strtoupper($tokens[$stackPtr]['content'])) {
52
+ $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'upper');
53
+ } else {
54
+ $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'mixed');
55
+ }
56
+
57
+ $error = 'PHP type casts must be lowercase; expected "%s" but found "%s"';
58
+ $data = [
59
+ strtolower($tokens[$stackPtr]['content']),
60
+ $tokens[$stackPtr]['content'],
61
+ ];
62
+
63
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'TypeCastFound', $data);
64
+ if ($fix === true) {
65
+ $phpcsFile->fixer->replaceToken($stackPtr, strtolower($tokens[$stackPtr]['content']));
66
+ }
67
+ } else {
68
+ $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'lower');
69
+ }//end if
70
+
71
+ return;
72
+ }//end if
73
+
74
+ $phpTypes = [
75
+ 'self' => true,
76
+ 'parent' => true,
77
+ 'array' => true,
78
+ 'callable' => true,
79
+ 'bool' => true,
80
+ 'float' => true,
81
+ 'int' => true,
82
+ 'string' => true,
83
+ 'iterable' => true,
84
+ 'void' => true,
85
+ 'object' => true,
86
+ ];
87
+
88
+ $props = $phpcsFile->getMethodProperties($stackPtr);
89
+
90
+ // Strip off potential nullable indication.
91
+ $returnType = ltrim($props['return_type'], '?');
92
+ $returnTypeLower = strtolower($returnType);
93
+
94
+ if ($returnType !== ''
95
+ && isset($phpTypes[$returnTypeLower]) === true
96
+ ) {
97
+ // A function return type.
98
+ if ($returnTypeLower !== $returnType) {
99
+ if ($returnType === strtoupper($returnType)) {
100
+ $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'upper');
101
+ } else {
102
+ $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'mixed');
103
+ }
104
+
105
+ $error = 'PHP return type declarations must be lowercase; expected "%s" but found "%s"';
106
+ $token = $props['return_type_token'];
107
+ $data = [
108
+ $returnTypeLower,
109
+ $returnType,
110
+ ];
111
+
112
+ $fix = $phpcsFile->addFixableError($error, $token, 'ReturnTypeFound', $data);
113
+ if ($fix === true) {
114
+ $phpcsFile->fixer->replaceToken($token, $returnTypeLower);
115
+ }
116
+ } else {
117
+ $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'lower');
118
+ }//end if
119
+ }//end if
120
+
121
+ $params = $phpcsFile->getMethodParameters($stackPtr);
122
+ if (empty($params) === true) {
123
+ return;
124
+ }
125
+
126
+ foreach ($params as $param) {
127
+ // Strip off potential nullable indication.
128
+ $typeHint = ltrim($param['type_hint'], '?');
129
+ $typeHintLower = strtolower($typeHint);
130
+
131
+ if ($typeHint !== ''
132
+ && isset($phpTypes[$typeHintLower]) === true
133
+ ) {
134
+ // A function return type.
135
+ if ($typeHintLower !== $typeHint) {
136
+ if ($typeHint === strtoupper($typeHint)) {
137
+ $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'upper');
138
+ } else {
139
+ $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'mixed');
140
+ }
141
+
142
+ $error = 'PHP parameter type declarations must be lowercase; expected "%s" but found "%s"';
143
+ $token = $param['type_hint_token'];
144
+ $data = [
145
+ $typeHintLower,
146
+ $typeHint,
147
+ ];
148
+
149
+ $fix = $phpcsFile->addFixableError($error, $token, 'ParamTypeFound', $data);
150
+ if ($fix === true) {
151
+ $phpcsFile->fixer->replaceToken($token, $typeHintLower);
152
+ }
153
+ } else {
154
+ $phpcsFile->recordMetric($stackPtr, 'PHP type case', 'lower');
155
+ }//end if
156
+ }//end if
157
+ }//end foreach
158
+
159
+ }//end process()
160
+
161
+
162
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php CHANGED
@@ -53,12 +53,22 @@ class NoSilencedErrorsSniff implements Sniff
53
  */
54
  public function process(File $phpcsFile, $stackPtr)
55
  {
 
 
 
 
 
 
 
 
 
 
56
  if ($this->error === true) {
57
- $error = 'Silencing errors is forbidden';
58
- $phpcsFile->addError($error, $stackPtr, 'Forbidden');
59
  } else {
60
- $error = 'Silencing errors is discouraged';
61
- $phpcsFile->addWarning($error, $stackPtr, 'Discouraged');
62
  }
63
 
64
  }//end process()
53
  */
54
  public function process(File $phpcsFile, $stackPtr)
55
  {
56
+ // Prepare the "Found" string to display.
57
+ $contextLength = 4;
58
+ $endOfStatement = $phpcsFile->findEndOfStatement($stackPtr, T_COMMA);
59
+ if (($endOfStatement - $stackPtr) < $contextLength) {
60
+ $contextLength = ($endOfStatement - $stackPtr);
61
+ }
62
+
63
+ $found = $phpcsFile->getTokensAsString($stackPtr, $contextLength);
64
+ $found = str_replace(["\t", "\n", "\r"], ' ', $found).'...';
65
+
66
  if ($this->error === true) {
67
+ $error = 'Silencing errors is forbidden; found: %s';
68
+ $phpcsFile->addError($error, $stackPtr, 'Forbidden', [$found]);
69
  } else {
70
+ $error = 'Silencing errors is discouraged; found: %s';
71
+ $phpcsFile->addWarning($error, $stackPtr, 'Discouraged', [$found]);
72
  }
73
 
74
  }//end process()
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/PHP/SyntaxSniff.php CHANGED
@@ -50,25 +50,12 @@ class SyntaxSniff implements Sniff
50
  {
51
  if ($this->phpPath === null) {
52
  $this->phpPath = Config::getExecutablePath('php');
53
- if ($this->phpPath === null) {
54
- // PHP_BINARY is available in PHP 5.4+.
55
- if (defined('PHP_BINARY') === true) {
56
- $this->phpPath = PHP_BINARY;
57
- } else {
58
- return;
59
- }
60
- }
61
  }
62
 
63
  $fileName = escapeshellarg($phpcsFile->getFilename());
64
- if (defined('HHVM_VERSION') === false) {
65
- $cmd = escapeshellcmd($this->phpPath)." -l -d display_errors=1 -d error_prepend_string='' $fileName 2>&1";
66
- } else {
67
- $cmd = escapeshellcmd($this->phpPath)." -l $fileName 2>&1";
68
- }
69
-
70
- $output = shell_exec($cmd);
71
- $matches = [];
72
  if (preg_match('/^.*error:(.*) in .* on line ([0-9]+)/m', trim($output), $matches) === 1) {
73
  $error = trim($matches[1]);
74
  $line = (int) $matches[2];
50
  {
51
  if ($this->phpPath === null) {
52
  $this->phpPath = Config::getExecutablePath('php');
 
 
 
 
 
 
 
 
53
  }
54
 
55
  $fileName = escapeshellarg($phpcsFile->getFilename());
56
+ $cmd = escapeshellcmd($this->phpPath)." -l -d display_errors=1 -d error_prepend_string='' $fileName 2>&1";
57
+ $output = shell_exec($cmd);
58
+ $matches = [];
 
 
 
 
 
59
  if (preg_match('/^.*error:(.*) in .* on line ([0-9]+)/m', trim($output), $matches) === 1) {
60
  $error = trim($matches[1]);
61
  $line = (int) $matches[2];
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/WhiteSpace/ArbitraryParenthesesSpacingSniff.php ADDED
@@ -0,0 +1,238 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Check & fix whitespace on the inside of arbitrary parentheses.
4
+ *
5
+ * Arbitrary parentheses are those which are not owned by a function (call), array or control structure.
6
+ * Spacing on the outside is not checked on purpose as this would too easily conflict with other spacing rules.
7
+ *
8
+ * @author Juliette Reinders Folmer <phpcs_nospam@adviesenzo.nl>
9
+ * @copyright 2017 Juliette Reinders Folmer. All rights reserved.
10
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
11
+ */
12
+
13
+ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace;
14
+
15
+ use PHP_CodeSniffer\Sniffs\Sniff;
16
+ use PHP_CodeSniffer\Files\File;
17
+ use PHP_CodeSniffer\Util\Tokens;
18
+
19
+ class ArbitraryParenthesesSpacingSniff implements Sniff
20
+ {
21
+
22
+ /**
23
+ * The number of spaces desired on the inside of the parentheses.
24
+ *
25
+ * @var integer
26
+ */
27
+ public $spacing = 0;
28
+
29
+ /**
30
+ * Allow newlines instead of spaces.
31
+ *
32
+ * @var boolean
33
+ */
34
+ public $ignoreNewlines = false;
35
+
36
+ /**
37
+ * Tokens which when they precede an open parenthesis indicate
38
+ * that this is a type of structure this sniff should ignore.
39
+ *
40
+ * @var array
41
+ */
42
+ private $ignoreTokens = [];
43
+
44
+
45
+ /**
46
+ * Returns an array of tokens this test wants to listen for.
47
+ *
48
+ * @return array
49
+ */
50
+ public function register()
51
+ {
52
+ $this->ignoreTokens = Tokens::$functionNameTokens;
53
+
54
+ $this->ignoreTokens[T_VARIABLE] = T_VARIABLE;
55
+ $this->ignoreTokens[T_CLOSE_PARENTHESIS] = T_CLOSE_PARENTHESIS;
56
+ $this->ignoreTokens[T_CLOSE_CURLY_BRACKET] = T_CLOSE_CURLY_BRACKET;
57
+ $this->ignoreTokens[T_CLOSE_SQUARE_BRACKET] = T_CLOSE_SQUARE_BRACKET;
58
+ $this->ignoreTokens[T_CLOSE_SHORT_ARRAY] = T_CLOSE_SHORT_ARRAY;
59
+
60
+ $this->ignoreTokens[T_ANON_CLASS] = T_ANON_CLASS;
61
+ $this->ignoreTokens[T_USE] = T_USE;
62
+ $this->ignoreTokens[T_LIST] = T_LIST;
63
+ $this->ignoreTokens[T_DECLARE] = T_DECLARE;
64
+ $this->ignoreTokens[T_THROW] = T_THROW;
65
+ $this->ignoreTokens[T_YIELD] = T_YIELD;
66
+ $this->ignoreTokens[T_YIELD_FROM] = T_YIELD_FROM;
67
+ $this->ignoreTokens[T_CLONE] = T_CLONE;
68
+
69
+ return [
70
+ T_OPEN_PARENTHESIS,
71
+ T_CLOSE_PARENTHESIS,
72
+ ];
73
+
74
+ }//end register()
75
+
76
+
77
+ /**
78
+ * Processes this test, when one of its tokens is encountered.
79
+ *
80
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile All the tokens found in the document.
81
+ * @param int $stackPtr The position of the current token in
82
+ * the stack passed in $tokens.
83
+ *
84
+ * @return void
85
+ */
86
+ public function process(File $phpcsFile, $stackPtr)
87
+ {
88
+ $tokens = $phpcsFile->getTokens();
89
+
90
+ if (isset($tokens[$stackPtr]['parenthesis_owner']) === true) {
91
+ // This parenthesis is owned by a function/control structure etc.
92
+ return;
93
+ }
94
+
95
+ // More checking for the type of parenthesis we *don't* want to handle.
96
+ $opener = $stackPtr;
97
+ if ($tokens[$stackPtr]['code'] === T_CLOSE_PARENTHESIS) {
98
+ if (isset($tokens[$stackPtr]['parenthesis_opener']) === false) {
99
+ // Parse error.
100
+ return;
101
+ }
102
+
103
+ $opener = $tokens[$stackPtr]['parenthesis_opener'];
104
+ }
105
+
106
+ $preOpener = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($opener - 1), null, true);
107
+ if ($preOpener !== false && isset($this->ignoreTokens[$tokens[$preOpener]['code']]) === true) {
108
+ // Function or language construct call.
109
+ return;
110
+ }
111
+
112
+ // Check for empty parentheses.
113
+ if ($tokens[$stackPtr]['code'] === T_OPEN_PARENTHESIS
114
+ && isset($tokens[$stackPtr]['parenthesis_closer']) === true
115
+ ) {
116
+ $nextNonEmpty = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
117
+ if ($nextNonEmpty === $tokens[$stackPtr]['parenthesis_closer']) {
118
+ $phpcsFile->addWarning('Empty set of arbitrary parentheses found.', $stackPtr, 'FoundEmpty');
119
+
120
+ return ($tokens[$stackPtr]['parenthesis_closer'] + 1);
121
+ }
122
+ }
123
+
124
+ // Check the spacing on the inside of the parentheses.
125
+ $this->spacing = (int) $this->spacing;
126
+
127
+ if ($tokens[$stackPtr]['code'] === T_OPEN_PARENTHESIS
128
+ && isset($tokens[($stackPtr + 1)], $tokens[($stackPtr + 2)]) === true
129
+ ) {
130
+ $nextToken = $tokens[($stackPtr + 1)];
131
+
132
+ if ($nextToken['code'] !== T_WHITESPACE) {
133
+ $inside = 0;
134
+ } else {
135
+ if ($tokens[($stackPtr + 2)]['line'] !== $tokens[$stackPtr]['line']) {
136
+ $inside = 'newline';
137
+ } else {
138
+ $inside = $nextToken['length'];
139
+ }
140
+ }
141
+
142
+ if ($this->spacing !== $inside
143
+ && ($inside !== 'newline' || $this->ignoreNewlines === false)
144
+ ) {
145
+ $error = 'Expected %s space after open parenthesis; %s found';
146
+ $data = [
147
+ $this->spacing,
148
+ $inside,
149
+ ];
150
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceAfterOpen', $data);
151
+
152
+ if ($fix === true) {
153
+ $expected = '';
154
+ if ($this->spacing > 0) {
155
+ $expected = str_repeat(' ', $this->spacing);
156
+ }
157
+
158
+ if ($inside === 0) {
159
+ if ($expected !== '') {
160
+ $phpcsFile->fixer->addContent($stackPtr, $expected);
161
+ }
162
+ } else if ($inside === 'newline') {
163
+ $phpcsFile->fixer->beginChangeset();
164
+ for ($i = ($stackPtr + 2); $i < $phpcsFile->numTokens; $i++) {
165
+ if ($tokens[$i]['code'] !== T_WHITESPACE) {
166
+ break;
167
+ }
168
+
169
+ $phpcsFile->fixer->replaceToken($i, '');
170
+ }
171
+
172
+ $phpcsFile->fixer->replaceToken(($stackPtr + 1), $expected);
173
+ $phpcsFile->fixer->endChangeset();
174
+ } else {
175
+ $phpcsFile->fixer->replaceToken(($stackPtr + 1), $expected);
176
+ }
177
+ }//end if
178
+ }//end if
179
+ }//end if
180
+
181
+ if ($tokens[$stackPtr]['code'] === T_CLOSE_PARENTHESIS
182
+ && isset($tokens[($stackPtr - 1)], $tokens[($stackPtr - 2)]) === true
183
+ ) {
184
+ $prevToken = $tokens[($stackPtr - 1)];
185
+
186
+ if ($prevToken['code'] !== T_WHITESPACE) {
187
+ $inside = 0;
188
+ } else {
189
+ if ($tokens[($stackPtr - 2)]['line'] !== $tokens[$stackPtr]['line']) {
190
+ $inside = 'newline';
191
+ } else {
192
+ $inside = $prevToken['length'];
193
+ }
194
+ }
195
+
196
+ if ($this->spacing !== $inside
197
+ && ($inside !== 'newline' || $this->ignoreNewlines === false)
198
+ ) {
199
+ $error = 'Expected %s space before close parenthesis; %s found';
200
+ $data = [
201
+ $this->spacing,
202
+ $inside,
203
+ ];
204
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeClose', $data);
205
+
206
+ if ($fix === true) {
207
+ $expected = '';
208
+ if ($this->spacing > 0) {
209
+ $expected = str_repeat(' ', $this->spacing);
210
+ }
211
+
212
+ if ($inside === 0) {
213
+ if ($expected !== '') {
214
+ $phpcsFile->fixer->addContentBefore($stackPtr, $expected);
215
+ }
216
+ } else if ($inside === 'newline') {
217
+ $phpcsFile->fixer->beginChangeset();
218
+ for ($i = ($stackPtr - 2); $i > 0; $i--) {
219
+ if ($tokens[$i]['code'] !== T_WHITESPACE) {
220
+ break;
221
+ }
222
+
223
+ $phpcsFile->fixer->replaceToken($i, '');
224
+ }
225
+
226
+ $phpcsFile->fixer->replaceToken(($stackPtr - 1), $expected);
227
+ $phpcsFile->fixer->endChangeset();
228
+ } else {
229
+ $phpcsFile->fixer->replaceToken(($stackPtr - 1), $expected);
230
+ }
231
+ }//end if
232
+ }//end if
233
+ }//end if
234
+
235
+ }//end process()
236
+
237
+
238
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ensures all language constructs contain a single space between themselves and their content.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2017 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\Generic\Sniffs\WhiteSpace;
11
+
12
+ use PHP_CodeSniffer\Sniffs\Sniff;
13
+ use PHP_CodeSniffer\Files\File;
14
+ use PHP_CodeSniffer\Util;
15
+
16
+ class LanguageConstructSpacingSniff implements Sniff
17
+ {
18
+
19
+
20
+ /**
21
+ * Returns an array of tokens this test wants to listen for.
22
+ *
23
+ * @return array
24
+ */
25
+ public function register()
26
+ {
27
+ return [
28
+ T_ECHO,
29
+ T_PRINT,
30
+ T_RETURN,
31
+ T_INCLUDE,
32
+ T_INCLUDE_ONCE,
33
+ T_REQUIRE,
34
+ T_REQUIRE_ONCE,
35
+ T_NEW,
36
+ T_YIELD,
37
+ T_YIELD_FROM,
38
+ T_THROW,
39
+ T_NAMESPACE,
40
+ T_USE,
41
+ ];
42
+
43
+ }//end register()
44
+
45
+
46
+ /**
47
+ * Processes this test, when one of its tokens is encountered.
48
+ *
49
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
50
+ * @param int $stackPtr The position of the current token in
51
+ * the stack passed in $tokens.
52
+ *
53
+ * @return void
54
+ */
55
+ public function process(File $phpcsFile, $stackPtr)
56
+ {
57
+ $tokens = $phpcsFile->getTokens();
58
+
59
+ $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
60
+ if ($nextToken === false) {
61
+ // Skip when at end of file.
62
+ return;
63
+ }
64
+
65
+ if ($tokens[($stackPtr + 1)]['code'] === T_SEMICOLON) {
66
+ // No content for this language construct.
67
+ return;
68
+ }
69
+
70
+ $content = $tokens[$stackPtr]['content'];
71
+ if ($tokens[$stackPtr]['code'] === T_YIELD_FROM
72
+ && strtolower($content) !== 'yield from'
73
+ ) {
74
+ if ($tokens[($stackPtr - 1)]['code'] === T_YIELD_FROM) {
75
+ // A multi-line statements that has already been processed.
76
+ return;
77
+ }
78
+
79
+ $found = $content;
80
+ if ($tokens[($stackPtr + 1)]['code'] === T_YIELD_FROM) {
81
+ // This yield from statement is split over multiple lines.
82
+ $i = ($stackPtr + 1);
83
+ do {
84
+ $found .= $tokens[$i]['content'];
85
+ $i++;
86
+ } while ($tokens[$i]['code'] === T_YIELD_FROM);
87
+ }
88
+
89
+ $error = 'Language constructs must be followed by a single space; expected 1 space between YIELD FROM found "%s"';
90
+ $data = [Util\Common::prepareForOutput($found)];
91
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'IncorrectYieldFrom', $data);
92
+ if ($fix === true) {
93
+ preg_match('/yield/i', $found, $yield);
94
+ preg_match('/from/i', $found, $from);
95
+ $phpcsFile->fixer->beginChangeset();
96
+ $phpcsFile->fixer->replaceToken($stackPtr, $yield[0].' '.$from[0]);
97
+
98
+ if ($tokens[($stackPtr + 1)]['code'] === T_YIELD_FROM) {
99
+ $i = ($stackPtr + 1);
100
+ do {
101
+ $phpcsFile->fixer->replaceToken($i, '');
102
+ $i++;
103
+ } while ($tokens[$i]['code'] === T_YIELD_FROM);
104
+ }
105
+
106
+ $phpcsFile->fixer->endChangeset();
107
+ }
108
+
109
+ return;
110
+ }//end if
111
+
112
+ if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
113
+ $content = $tokens[($stackPtr + 1)]['content'];
114
+ if ($content !== ' ') {
115
+ $error = 'Language constructs must be followed by a single space; expected 1 space but found "%s"';
116
+ $data = [Util\Common::prepareForOutput($content)];
117
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'IncorrectSingle', $data);
118
+ if ($fix === true) {
119
+ $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
120
+ }
121
+ }
122
+ } else if ($tokens[($stackPtr + 1)]['code'] !== T_OPEN_PARENTHESIS) {
123
+ $error = 'Language constructs must be followed by a single space; expected "%s" but found "%s"';
124
+ $data = [
125
+ $tokens[$stackPtr]['content'].' '.$tokens[($stackPtr + 1)]['content'],
126
+ $tokens[$stackPtr]['content'].$tokens[($stackPtr + 1)]['content'],
127
+ ];
128
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Incorrect', $data);
129
+ if ($fix === true) {
130
+ $phpcsFile->fixer->addContent($stackPtr, ' ');
131
+ }
132
+ }//end if
133
+
134
+ }//end process()
135
+
136
+
137
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php CHANGED
@@ -523,32 +523,19 @@ class ScopeIndentSniff implements Sniff
523
  && (($adjustments[$first] < 0 && $tokenIndent > $currentIndent)
524
  || ($adjustments[$first] > 0 && $tokenIndent < $currentIndent))
525
  ) {
526
- $padding = ($tokenIndent + $adjustments[$first]);
527
- if ($padding > 0) {
528
- if ($this->tabIndent === true) {
529
- $numTabs = floor($padding / $this->tabWidth);
530
- $numSpaces = ($padding - ($numTabs * $this->tabWidth));
531
- $padding = str_repeat("\t", $numTabs).str_repeat(' ', $numSpaces);
532
- } else {
533
- $padding = str_repeat(' ', $padding);
534
- }
535
- } else {
536
- $padding = '';
537
- }
538
 
 
 
 
539
  if ($phpcsFile->fixer->enabled === true) {
540
- if ($checkToken === $i) {
541
- $phpcsFile->fixer->replaceToken($checkToken, $padding.$trimmed);
542
- } else {
543
- // Easier to just replace the entire indent.
544
- $phpcsFile->fixer->replaceToken(($checkToken - 1), $padding);
545
- }
546
  }
547
 
548
  if ($this->debug === true) {
549
- $length = strlen($padding);
550
- $line = $tokens[$checkToken]['line'];
551
- $type = $tokens[$checkToken]['type'];
552
  echo "Indent adjusted to $length for $type on line $line".PHP_EOL;
553
  }
554
 
@@ -813,16 +800,43 @@ class ScopeIndentSniff implements Sniff
813
  $exact = true;
814
  }
815
 
816
- // PHP tags needs to be indented to exact column positions
817
  // so they don't cause problems with indent checks for the code
818
- // within them, but they don't need to line up with the current indent.
 
819
  if ($checkToken !== null
820
  && ($tokens[$checkToken]['code'] === T_OPEN_TAG
821
- || $tokens[$checkToken]['code'] === T_OPEN_TAG_WITH_ECHO
822
- || $tokens[$checkToken]['code'] === T_CLOSE_TAG)
823
  ) {
824
- $exact = true;
825
  $checkIndent = ($tokens[$checkToken]['column'] - 1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
826
  $checkIndent = (int) (ceil($checkIndent / $this->indent) * $this->indent);
827
  }
828
 
@@ -844,7 +858,7 @@ class ScopeIndentSniff implements Sniff
844
  of this line should be.
845
 
846
  After this IF block, we adjust the indent again for
847
- the checking of future line.
848
  */
849
 
850
  if ($checkToken !== null
@@ -879,40 +893,21 @@ class ScopeIndentSniff implements Sniff
879
  echo "[Line $line] $message".PHP_EOL;
880
  }
881
 
 
 
 
 
 
882
  $fix = $phpcsFile->addFixableError($error, $checkToken, $type, $data);
883
  if ($fix === true || $this->debug === true) {
884
- $padding = '';
885
- if ($this->tabIndent === true) {
886
- $numTabs = floor($checkIndent / $this->tabWidth);
887
- if ($numTabs > 0) {
888
- $numSpaces = ($checkIndent - ($numTabs * $this->tabWidth));
889
- $padding = str_repeat("\t", $numTabs).str_repeat(' ', $numSpaces);
890
- }
891
- } else if ($checkIndent > 0) {
892
- $padding = str_repeat(' ', $checkIndent);
893
- }
894
-
895
- if ($checkToken === $i) {
896
- $accepted = $phpcsFile->fixer->replaceToken($checkToken, $padding.$trimmed);
897
- } else {
898
- // Easier to just replace the entire indent.
899
- $accepted = $phpcsFile->fixer->replaceToken(($checkToken - 1), $padding);
900
- }
901
 
902
- if ($accepted === true) {
903
- $adjustments[$checkToken] = ($checkIndent - $tokenIndent);
904
- if ($this->debug === true) {
905
- $line = $tokens[$checkToken]['line'];
906
- $type = $tokens[$checkToken]['type'];
907
- echo "\t=> Add adjustment of ".$adjustments[$checkToken]." for token $checkToken ($type) on line $line".PHP_EOL;
908
- }
909
  }
910
- } else {
911
- // Assume the change would be applied and continue
912
- // checking indents under this assumption. This gives more
913
- // technically accurate error messages.
914
- $adjustments[$checkToken] = ($checkIndent - $tokenIndent);
915
- }//end if
916
  }//end if
917
 
918
  if ($checkToken !== null) {
@@ -1308,4 +1303,91 @@ class ScopeIndentSniff implements Sniff
1308
  }//end process()
1309
 
1310
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1311
  }//end class
523
  && (($adjustments[$first] < 0 && $tokenIndent > $currentIndent)
524
  || ($adjustments[$first] > 0 && $tokenIndent < $currentIndent))
525
  ) {
526
+ $length = ($tokenIndent + $adjustments[$first]);
 
 
 
 
 
 
 
 
 
 
 
527
 
528
+ // When fixing, we're going to adjust the indent of this line
529
+ // here automatically, so use this new padding value when
530
+ // comparing the expected padding to the actual padding.
531
  if ($phpcsFile->fixer->enabled === true) {
532
+ $tokenIndent = $length;
533
+ $this->adjustIndent($phpcsFile, $checkToken, $length, $adjustments[$first]);
 
 
 
 
534
  }
535
 
536
  if ($this->debug === true) {
537
+ $line = $tokens[$checkToken]['line'];
538
+ $type = $tokens[$checkToken]['type'];
 
539
  echo "Indent adjusted to $length for $type on line $line".PHP_EOL;
540
  }
541
 
800
  $exact = true;
801
  }
802
 
803
+ // Open PHP tags needs to be indented to exact column positions
804
  // so they don't cause problems with indent checks for the code
805
+ // within them, but they don't need to line up with the current indent
806
+ // in most cases.
807
  if ($checkToken !== null
808
  && ($tokens[$checkToken]['code'] === T_OPEN_TAG
809
+ || $tokens[$checkToken]['code'] === T_OPEN_TAG_WITH_ECHO)
 
810
  ) {
 
811
  $checkIndent = ($tokens[$checkToken]['column'] - 1);
812
+
813
+ // If we are re-opening a block that was closed in the same
814
+ // scope as us, then reset the indent back to what the scope opener
815
+ // set instead of using whatever indent this open tag has set.
816
+ if (empty($tokens[$checkToken]['conditions']) === false) {
817
+ $close = $phpcsFile->findPrevious(T_CLOSE_TAG, ($checkToken - 1));
818
+ if ($close !== false
819
+ && $tokens[$checkToken]['conditions'] === $tokens[$close]['conditions']
820
+ ) {
821
+ $conditions = array_keys($tokens[$checkToken]['conditions']);
822
+ $lastCondition = array_pop($conditions);
823
+ $lastOpener = $tokens[$lastCondition]['scope_opener'];
824
+ $lastCloser = $tokens[$lastCondition]['scope_closer'];
825
+ if ($tokens[$lastCloser]['line'] !== $tokens[$checkToken]['line']
826
+ && isset($setIndents[$lastOpener]) === true
827
+ ) {
828
+ $checkIndent = $setIndents[$lastOpener];
829
+ }
830
+ }
831
+ }
832
+
833
+ $checkIndent = (int) (ceil($checkIndent / $this->indent) * $this->indent);
834
+ }//end if
835
+
836
+ // Close tags needs to be indented to exact column positions.
837
+ if ($checkToken !== null && $tokens[$checkToken]['code'] === T_CLOSE_TAG) {
838
+ $exact = true;
839
+ $checkIndent = $currentIndent;
840
  $checkIndent = (int) (ceil($checkIndent / $this->indent) * $this->indent);
841
  }
842
 
858
  of this line should be.
859
 
860
  After this IF block, we adjust the indent again for
861
+ the checking of future lines
862
  */
863
 
864
  if ($checkToken !== null
893
  echo "[Line $line] $message".PHP_EOL;
894
  }
895
 
896
+ // Assume the change would be applied and continue
897
+ // checking indents under this assumption. This gives more
898
+ // technically accurate error messages.
899
+ $adjustments[$checkToken] = ($checkIndent - $tokenIndent);
900
+
901
  $fix = $phpcsFile->addFixableError($error, $checkToken, $type, $data);
902
  if ($fix === true || $this->debug === true) {
903
+ $accepted = $this->adjustIndent($phpcsFile, $checkToken, $checkIndent, ($checkIndent - $tokenIndent));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
904
 
905
+ if ($accepted === true && $this->debug === true) {
906
+ $line = $tokens[$checkToken]['line'];
907
+ $type = $tokens[$checkToken]['type'];
908
+ echo "\t=> Add adjustment of ".$adjustments[$checkToken]." for token $checkToken ($type) on line $line".PHP_EOL;
 
 
 
909
  }
910
+ }
 
 
 
 
 
911
  }//end if
912
 
913
  if ($checkToken !== null) {
1303
  }//end process()
1304
 
1305
 
1306
+ /**
1307
+ * Processes this test, when one of its tokens is encountered.
1308
+ *
1309
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile All the tokens found in the document.
1310
+ * @param int $stackPtr The position of the current token
1311
+ * in the stack passed in $tokens.
1312
+ * @param int $length The length of the new indent.
1313
+ * @param int $change The difference in length between
1314
+ * the old and new indent.
1315
+ *
1316
+ * @return void
1317
+ */
1318
+ protected function adjustIndent(File $phpcsFile, $stackPtr, $length, $change)
1319
+ {
1320
+ $tokens = $phpcsFile->getTokens();
1321
+
1322
+ // We don't adjust indents outside of PHP.
1323
+ if ($tokens[$stackPtr]['code'] === T_INLINE_HTML) {
1324
+ return false;
1325
+ }
1326
+
1327
+ $padding = '';
1328
+ if ($length > 0) {
1329
+ if ($this->tabIndent === true) {
1330
+ $numTabs = floor($length / $this->tabWidth);
1331
+ if ($numTabs > 0) {
1332
+ $numSpaces = ($length - ($numTabs * $this->tabWidth));
1333
+ $padding = str_repeat("\t", $numTabs).str_repeat(' ', $numSpaces);
1334
+ }
1335
+ } else {
1336
+ $padding = str_repeat(' ', $length);
1337
+ }
1338
+ }
1339
+
1340
+ if ($tokens[$stackPtr]['column'] === 1) {
1341
+ $trimmed = ltrim($tokens[$stackPtr]['content']);
1342
+ $accepted = $phpcsFile->fixer->replaceToken($stackPtr, $padding.$trimmed);
1343
+ } else {
1344
+ // Easier to just replace the entire indent.
1345
+ $accepted = $phpcsFile->fixer->replaceToken(($stackPtr - 1), $padding);
1346
+ }
1347
+
1348
+ if ($accepted === false) {
1349
+ return false;
1350
+ }
1351
+
1352
+ if ($tokens[$stackPtr]['code'] === T_DOC_COMMENT_OPEN_TAG) {
1353
+ // We adjusted the start of a comment, so adjust the rest of it
1354
+ // as well so the alignment remains correct.
1355
+ for ($x = ($stackPtr + 1); $x < $tokens[$stackPtr]['comment_closer']; $x++) {
1356
+ if ($tokens[$x]['column'] !== 1) {
1357
+ continue;
1358
+ }
1359
+
1360
+ $length = 0;
1361
+ if ($tokens[$x]['code'] === T_DOC_COMMENT_WHITESPACE) {
1362
+ $length = $tokens[$x]['length'];
1363
+ }
1364
+
1365
+ $padding = ($length + $change);
1366
+ if ($padding > 0) {
1367
+ if ($this->tabIndent === true) {
1368
+ $numTabs = floor($padding / $this->tabWidth);
1369
+ $numSpaces = ($padding - ($numTabs * $this->tabWidth));
1370
+ $padding = str_repeat("\t", $numTabs).str_repeat(' ', $numSpaces);
1371
+ } else {
1372
+ $padding = str_repeat(' ', $padding);
1373
+ }
1374
+ } else {
1375
+ $padding = '';
1376
+ }
1377
+
1378
+ $phpcsFile->fixer->replaceToken($x, $padding);
1379
+ if ($this->debug === true) {
1380
+ $length = strlen($padding);
1381
+ $line = $tokens[$x]['line'];
1382
+ $type = $tokens[$x]['type'];
1383
+ echo "\t=> Indent adjusted to $length for $type on line $line".PHP_EOL;
1384
+ }
1385
+ }//end for
1386
+ }//end if
1387
+
1388
+ return true;
1389
+
1390
+ }//end adjustIndent()
1391
+
1392
+
1393
  }//end class
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc CHANGED
@@ -43,6 +43,12 @@ $var = array(
43
  'two' => 2,
44
  );
45
 
 
 
 
 
 
 
46
  // phpcs:set Generic.Arrays.ArrayIndent indent 2
47
 
48
  $var = [
43
  'two' => 2,
44
  );
45
 
46
+ return [
47
+ [
48
+ 'foo' => true,
49
+ ]
50
+ ];
51
+
52
  // phpcs:set Generic.Arrays.ArrayIndent indent 2
53
 
54
  $var = [
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.inc.fixed CHANGED
@@ -44,6 +44,12 @@ $var = array(
44
  'two' => 2,
45
  );
46
 
 
 
 
 
 
 
47
  // phpcs:set Generic.Arrays.ArrayIndent indent 2
48
 
49
  $var = [
44
  'two' => 2,
45
  );
46
 
47
+ return [
48
+ [
49
+ 'foo' => true,
50
+ ]
51
+ ];
52
+
53
  // phpcs:set Generic.Arrays.ArrayIndent indent 2
54
 
55
  $var = [
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/ArrayIndentUnitTest.php CHANGED
@@ -33,10 +33,10 @@ class ArrayIndentUnitTest extends AbstractSniffUnitTest
33
  31 => 1,
34
  33 => 1,
35
  41 => 1,
36
- 49 => 1,
37
- 50 => 1,
38
- 51 => 1,
39
- 52 => 1,
40
  ];
41
 
42
  }//end getErrorList()
33
  31 => 1,
34
  33 => 1,
35
  41 => 1,
36
+ 55 => 1,
37
+ 56 => 1,
38
+ 57 => 1,
39
+ 58 => 1,
40
  ];
41
 
42
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc CHANGED
@@ -5,8 +5,8 @@ $var = array(1,2,3);
5
  echo $var[1];
6
  $foo = array($var[1],$var[2]);
7
  $foo = array(
8
- 1
9
- 2
10
  3
11
  );
12
  $var = array/*comment*/(1,2,3);
@@ -14,7 +14,7 @@ $var = array;
14
 
15
  function foo(array $array) {}
16
 
17
- function foo(array $array) use ($foo): array {}
18
 
19
  abstract function foo(): array;
20
 
5
  echo $var[1];
6
  $foo = array($var[1],$var[2]);
7
  $foo = array(
8
+ 1,
9
+ 2,
10
  3
11
  );
12
  $var = array/*comment*/(1,2,3);
14
 
15
  function foo(array $array) {}
16
 
17
+ $a = function (array $array) use ($foo): array {};
18
 
19
  abstract function foo(): array;
20
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.1.inc.fixed CHANGED
@@ -5,8 +5,8 @@ $var = [1,2,3];
5
  echo $var[1];
6
  $foo = [$var[1],$var[2]];
7
  $foo = [
8
- 1
9
- 2
10
  3
11
  ];
12
  $var = /*comment*/[1,2,3];
@@ -14,7 +14,7 @@ $var = array;
14
 
15
  function foo(array $array) {}
16
 
17
- function foo(array $array) use ($foo): array {}
18
 
19
  abstract function foo(): array;
20
 
5
  echo $var[1];
6
  $foo = [$var[1],$var[2]];
7
  $foo = [
8
+ 1,
9
+ 2,
10
  3
11
  ];
12
  $var = /*comment*/[1,2,3];
14
 
15
  function foo(array $array) {}
16
 
17
+ $a = function (array $array) use ($foo): array {};
18
 
19
  abstract function foo(): array;
20
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.2.inc CHANGED
@@ -7,7 +7,7 @@ $var = array();
7
  function test()
8
  {
9
  $arr = array(
10
- 'a' => 'a'
11
  <<<<<<< HEAD
12
  'b' => 'b'
13
  =======
7
  function test()
8
  {
9
  $arr = array(
10
+ 'a' => 'a',
11
  <<<<<<< HEAD
12
  'b' => 'b'
13
  =======
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.2.inc.fixed CHANGED
@@ -7,7 +7,7 @@ $var = [];
7
  function test()
8
  {
9
  $arr = array(
10
- 'a' => 'a'
11
  <<<<<<< HEAD
12
  'b' => 'b'
13
  =======
7
  function test()
8
  {
9
  $arr = array(
10
+ 'a' => 'a',
11
  <<<<<<< HEAD
12
  'b' => 'b'
13
  =======
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowLongArraySyntaxUnitTest.php CHANGED
@@ -15,28 +15,6 @@ class DisallowLongArraySyntaxUnitTest extends AbstractSniffUnitTest
15
  {
16
 
17
 
18
- /**
19
- * Get a list of all test files to check.
20
- *
21
- * @param string $testFileBase The base path that the unit tests files will have.
22
- *
23
- * @return string[]
24
- */
25
- protected function getTestFiles($testFileBase)
26
- {
27
- $testFiles = [$testFileBase.'1.inc'];
28
-
29
- // HHVM doesn't tokenize any of the file after a git
30
- // merge conflict, so only run this check on non-HHVM versions.
31
- if (defined('HHVM_VERSION') === false) {
32
- $testFiles[] = $testFileBase.'2.inc';
33
- }
34
-
35
- return $testFiles;
36
-
37
- }//end getTestFiles()
38
-
39
-
40
  /**
41
  * Returns the lines where errors should occur.
42
  *
15
  {
16
 
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  /**
19
  * Returns the lines where errors should occur.
20
  *
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.inc CHANGED
@@ -6,7 +6,7 @@ $var = [1,2,3];
6
  echo $var[1];
7
  $foo = [$var[1],$var[2]];
8
  $foo = [
9
- 1
10
- 2
11
  3
12
- ];
6
  echo $var[1];
7
  $foo = [$var[1],$var[2]];
8
  $foo = [
9
+ 1,
10
+ 2,
11
  3
12
+ ];
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Arrays/DisallowShortArraySyntaxUnitTest.inc.fixed CHANGED
@@ -6,7 +6,7 @@ $var = array(1,2,3);
6
  echo $var[1];
7
  $foo = array($var[1],$var[2]);
8
  $foo = array(
9
- 1
10
- 2
11
  3
12
- );
6
  echo $var[1];
7
  $foo = array($var[1],$var[2]);
8
  $foo = array(
9
+ 1,
10
+ 2,
11
  3
12
+ );
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.inc CHANGED
@@ -1,24 +1,29 @@
1
  <?php
2
 
3
  class Foo {
4
- public final $FOOBAR = 23;
5
- protected final $FOO = 42;
6
- private final $BAR = 17;
7
  }
8
 
9
  final class Foo_Bar {
10
  public $foobar;
11
- public final $FOOBAR = 23;
12
-
13
- protected $foo;
14
- protected final $FOO = 42;
15
-
16
- private $bar;
17
- private final $BAR = 17;
 
18
  }
19
 
20
  final class Bar_Foo {
21
  public $foobar;
22
  protected $foo;
23
- private $bar;
24
- }
 
 
 
 
1
  <?php
2
 
3
  class Foo {
4
+ public final function fooBar() {}
5
+ protected final function fool() {}
6
+ private final function Bar() {}
7
  }
8
 
9
  final class Foo_Bar {
10
  public $foobar;
11
+ public final $FOOBAR = 23; // Parse error, but that's not the concern of this sniff, so report it.
12
+ public final function fooBar() {}
13
+
14
+ protected function foo() {}
15
+ protected final function fool() {}
16
+
17
+ private function Bar() {}
18
+ private final function Bard() {}
19
  }
20
 
21
  final class Bar_Foo {
22
  public $foobar;
23
  protected $foo;
24
+ private $bar;
25
+
26
+ public function fooBar() {}
27
+ protected function foo() {}
28
+ private function Bar() {}
29
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UnnecessaryFinalModifierUnitTest.php CHANGED
@@ -42,8 +42,9 @@ class UnnecessaryFinalModifierUnitTest extends AbstractSniffUnitTest
42
  {
43
  return [
44
  11 => 1,
45
- 14 => 1,
46
- 17 => 1,
 
47
  ];
48
 
49
  }//end getWarningList()
42
  {
43
  return [
44
  11 => 1,
45
+ 12 => 1,
46
+ 15 => 1,
47
+ 18 => 1,
48
  ];
49
 
50
  }//end getWarningList()
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/CodeAnalysis/UnusedFunctionParameterUnitTest.inc CHANGED
@@ -34,7 +34,7 @@ function foo($bar)
34
  {
35
  print <<<BAZ
36
  $bar
37
- BAZ
38
  }
39
 
40
  function foo( $parameter ) {
@@ -75,6 +75,6 @@ function bar($x)
75
  return 2 * ${x};
76
  }
77
 
78
- function ($a, $b) {
79
  return $a * 2;
80
- }
34
  {
35
  print <<<BAZ
36
  $bar
37
+ BAZ;
38
  }
39
 
40
  function foo( $parameter ) {
75
  return 2 * ${x};
76
  }
77
 
78
+ $foo = function ($a, $b) {
79
  return $a * 2;
80
+ };
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.inc CHANGED
@@ -187,6 +187,26 @@
187
  * @param boolean $bar Blah.
188
  */
189
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  /**
191
  * étude des ...
192
  */
187
  * @param boolean $bar Blah.
188
  */
189
 
190
+ /**
191
+ * Short description.
192
+ *
193
+ * @tag one
194
+ * @param int $number
195
+ * @param string $text
196
+ * @return something
197
+ */
198
+
199
+ /**
200
+ *
201
+ * @param int $number
202
+ * @param string $text
203
+ * @return something
204
+ */
205
+
206
+ /**
207
+ * @param int $number
208
+ */
209
+
210
  /**
211
  * étude des ...
212
  */
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.js CHANGED
@@ -187,6 +187,26 @@
187
  * @param boolean $bar Blah.
188
  */
189
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  /**
191
  * étude des ...
192
  */
187
  * @param boolean $bar Blah.
188
  */
189
 
190
+ /**
191
+ * Short description.
192
+ *
193
+ * @tag one
194
+ * @param int $number
195
+ * @param string $text
196
+ * @return something
197
+ */
198
+
199
+ /**
200
+ *
201
+ * @param int $number
202
+ * @param string $text
203
+ * @return something
204
+ */
205
+
206
+ /**
207
+ * @param int $number
208
+ */
209
+
210
  /**
211
  * étude des ...
212
  */
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Commenting/DocCommentUnitTest.php CHANGED
@@ -53,12 +53,17 @@ class DocCommentUnitTest extends AbstractSniffUnitTest
53
  171 => 3,
54
  179 => 1,
55
  183 => 1,
56
- 184 => 1,
57
- 185 => 2,
58
  186 => 1,
59
  187 => 2,
60
- 191 => 1,
61
- 194 => 4,
 
 
 
 
 
62
  ];
63
 
64
  }//end getErrorList()
53
  171 => 3,
54
  179 => 1,
55
  183 => 1,
56
+ 184 => 2,
57
+ 185 => 1,
58
  186 => 1,
59
  187 => 2,
60
+ 193 => 1,
61
+ 196 => 1,
62
+ 199 => 1,
63
+ 203 => 1,
64
+ 206 => 1,
65
+ 211 => 1,
66
+ 214 => 4,
67
  ];
68
 
69
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc CHANGED
@@ -217,3 +217,24 @@ do {
217
  }
218
  // Comment
219
  while ($i < 10);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
217
  }
218
  // Comment
219
  while ($i < 10);
220
+
221
+ if ($this) {
222
+ if ($that)
223
+ foo(${$a[$b]});
224
+ }
225
+
226
+ while (!$this->readLine($tokens, $tag)); //phpcs:ignore Standard.Category.Sniff
227
+
228
+ while (!$this->readLine($tokens, $tag)); // comment
229
+
230
+ while (!$this->readLine($tokens, $tag)); /* comment */
231
+
232
+ foreach ($stringParade as $hit)
233
+ $hitParade[] = $hit + 0; // phpcs:ignore Standard.Category.Sniff
234
+
235
+ if ($bar)
236
+ if ($foo) echo 'hi'; /* @phpcs:ignore Standard.Category.Sniff */
237
+
238
+ if (true) $callable = function () {
239
+ return true;
240
+ };
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.inc.fixed CHANGED
@@ -247,3 +247,29 @@ do {
247
  }
248
  // Comment
249
  while ($i < 10);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
247
  }
248
  // Comment
249
  while ($i < 10);
250
+
251
+ if ($this) {
252
+ if ($that) {
253
+ foo(${$a[$b]});
254
+ }
255
+ }
256
+
257
+ while (!$this->readLine($tokens, $tag)) {} //phpcs:ignore Standard.Category.Sniff
258
+
259
+ while (!$this->readLine($tokens, $tag)) {
260
+ // comment
261
+ }
262
+ while (!$this->readLine($tokens, $tag)) { /* comment */
263
+
264
+ }
265
+ foreach ($stringParade as $hit) {
266
+ $hitParade[] = $hit + 0; // phpcs:ignore Standard.Category.Sniff
267
+ }
268
+ if ($bar) {
269
+ if ($foo) { echo 'hi'; /* @phpcs:ignore Standard.Category.Sniff */
270
+ }
271
+ }
272
+ if (true) { $callable = function () {
273
+ return true;
274
+ };
275
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/ControlStructures/InlineControlStructureUnitTest.php CHANGED
@@ -67,6 +67,14 @@ class InlineControlStructureUnitTest extends AbstractSniffUnitTest
67
  195 => 1,
68
  198 => 1,
69
  206 => 1,
 
 
 
 
 
 
 
 
70
  ];
71
  break;
72
  case 'InlineControlStructureUnitTest.js':
67
  195 => 1,
68
  198 => 1,
69
  206 => 1,
70
+ 222 => 1,
71
+ 226 => 1,
72
+ 228 => 1,
73
+ 230 => 1,
74
+ 232 => 1,
75
+ 235 => 1,
76
+ 236 => 1,
77
+ 238 => 1,
78
  ];
79
  break;
80
  case 'InlineControlStructureUnitTest.js':
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/EndFileNewlineUnitTest.php CHANGED
@@ -31,12 +31,7 @@ class EndFileNewlineUnitTest extends AbstractSniffUnitTest
31
  case 'EndFileNewlineUnitTest.3.inc':
32
  case 'EndFileNewlineUnitTest.3.js':
33
  case 'EndFileNewlineUnitTest.3.css':
34
- return [2 => 1];
35
  case 'EndFileNewlineUnitTest.4.inc':
36
- // HHVM just removes the entire comment token, as if it was never there.
37
- if (defined('HHVM_VERSION') === true) {
38
- return [];
39
- }
40
  return [2 => 1];
41
  default:
42
  return [];
31
  case 'EndFileNewlineUnitTest.3.inc':
32
  case 'EndFileNewlineUnitTest.3.js':
33
  case 'EndFileNewlineUnitTest.3.css':
 
34
  case 'EndFileNewlineUnitTest.4.inc':
 
 
 
 
35
  return [2 => 1];
36
  default:
37
  return [];
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/EndFileNoNewlineUnitTest.php CHANGED
@@ -35,19 +35,10 @@ class EndFileNoNewlineUnitTest extends AbstractSniffUnitTest
35
  return [3 => 1];
36
  case 'EndFileNoNewlineUnitTest.2.css':
37
  case 'EndFileNoNewlineUnitTest.2.js':
 
38
  return [2 => 1];
39
  case 'EndFileNoNewlineUnitTest.5.inc':
40
- // HHVM just removes the entire comment token, as if it was never there.
41
- if (defined('HHVM_VERSION') === true) {
42
- return [1 => 1];
43
- }
44
  return [];
45
- case 'EndFileNoNewlineUnitTest.6.inc':
46
- // HHVM just removes the entire comment token, as if it was never there.
47
- if (defined('HHVM_VERSION') === true) {
48
- return [1 => 1];
49
- }
50
- return [2 => 1];
51
  default:
52
  return [];
53
  }//end switch
35
  return [3 => 1];
36
  case 'EndFileNoNewlineUnitTest.2.css':
37
  case 'EndFileNoNewlineUnitTest.2.js':
38
+ case 'EndFileNoNewlineUnitTest.6.inc':
39
  return [2 => 1];
40
  case 'EndFileNoNewlineUnitTest.5.inc':
 
 
 
 
41
  return [];
 
 
 
 
 
 
42
  default:
43
  return [];
44
  }//end switch
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/LineLengthUnitTest.4.inc CHANGED
@@ -7,4 +7,4 @@ phpcs:set Generic.Files.LineLength absoluteLineLimit 120
7
  if($thisIsOk === true) {}
8
 
9
  /* This line is too long but will be ignored. This line is too long but will be ignored. */
10
- if (($anotherReallyLongVarName === true) || (is_array($anotherReallyLongVarName) === false)) {
7
  if($thisIsOk === true) {}
8
 
9
  /* This line is too long but will be ignored. This line is too long but will be ignored. */
10
+ if (($anotherReallyLongVarName === true) || (is_array($anotherReallyLongVarName) === false)) {}
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Files/OneTraitPerFileUnitTest.php CHANGED
@@ -15,18 +15,6 @@ class OneTraitPerFileUnitTest extends AbstractSniffUnitTest
15
  {
16
 
17
 
18
- /**
19
- * Should this test be skipped for some reason.
20
- *
21
- * @return bool
22
- */
23
- protected function shouldSkipTest()
24
- {
25
- return (PHP_VERSION_ID < 50400);
26
-
27
- }//end shouldSkipTest()
28
-
29
-
30
  /**
31
  * Returns the lines where errors should occur.
32
  *
15
  {
16
 
17
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  /**
19
  * Returns the lines where errors should occur.
20
  *
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc CHANGED
@@ -86,14 +86,14 @@ class MyClass
86
  const MODE_DEBUG = 'debug';
87
  const MODE_DEBUG2 = 'debug';
88
 
89
- $array[$test] = 'anything';
90
- $var = 'anything';
91
-
92
- const MODE_DEBUG2 = 'debug';
93
- $array[$test] = 'anything';
94
- $var = 'anything';
95
- $array[($test + 1)] = 'anything';
96
- $array[($blah + (10 - $test))] = 'anything';
97
  }
98
 
99
  function myFunction($var=true)
@@ -265,3 +265,141 @@ $foo = [
265
  'a' => 'b',
266
  ];
267
  $barbar = 'bar';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  const MODE_DEBUG = 'debug';
87
  const MODE_DEBUG2 = 'debug';
88
 
89
+ var $array[$test] = 'anything';
90
+ var $var = 'anything';
91
+
92
+ const MODE_DEBUG3 = 'debug';
93
+ public $array[$test] = 'anything';
94
+ private $vara = 'anything';
95
+ protected $array[($test + 1)] = 'anything';
96
+ var $array[($blah + (10 - $test))] = 'anything';
97
  }
98
 
99
  function myFunction($var=true)
265
  'a' => 'b',
266
  ];
267
  $barbar = 'bar';
268
+
269
+ $foo = [
270
+
271
+ 'a' => 'b',
272
+ ];
273
+ $barbar = 'bar';
274
+
275
+ function buildForm(FormBuilderInterface $builder, array $options)
276
+ {
277
+ $transformer = new ContractTransformer($options['contracts']);
278
+ $types = ['support.contact.question' => ContactData::QUESTION];
279
+
280
+ [$important, $questions, $incidents, $requests] = $this->createContractBuckets($options['contracts']);
281
+ }
282
+
283
+ function buildForm(FormBuilderInterface $builder, array $options)
284
+ {
285
+ $transformer = new ContractTransformer($options['contracts']);
286
+ $types = ['support.contact.question' => ContactData::QUESTION];
287
+ [$important, $questions, $incidents, $requests] = $this->createContractBuckets($options['contracts']);
288
+ }
289
+
290
+ $loggerResult = $util->setLogger(new class {
291
+ public function log($msg)
292
+ {
293
+ $a = $msg;
294
+ $foobar = $msg;
295
+ $foo = function() {
296
+ $a = $msg;
297
+ $foobar = $msg;
298
+ $loggerResult = $util->setLogger(new class {
299
+ public function log($msg)
300
+ {
301
+ $a = $msg;
302
+ $foobar = $msg;
303
+ $foo = function() {
304
+ foo(function() {
305
+ foo(function() {
306
+ echo 'hi';
307
+ });
308
+ $a = $msg;
309
+ $foobar = $msg;
310
+
311
+ $foo = function() {
312
+
313
+ $foo = 1;
314
+ $barbar=2;
315
+ };
316
+ $barbar = function() {
317
+ $foo = 1;
318
+ $barbar = 2;
319
+ };
320
+ });
321
+ $a = $msg;
322
+ $foobar = $msg;
323
+ };
324
+ $bar = $msg;
325
+ }
326
+
327
+ public function log2($msg)
328
+ {
329
+ $a = $msg;
330
+ $foobar = $msg;
331
+ $foo = function() {
332
+ foo(function() {
333
+ foo(function() {
334
+ echo 'hi';
335
+ });
336
+ $a = $msg;
337
+ $foobar = $msg;
338
+
339
+ $foo = function() {
340
+
341
+ $foo = 1;
342
+ $barbar=2;
343
+ };
344
+ $barbar = function() {
345
+ $foo = 1;
346
+ $barbar = 2;
347
+ };
348
+ });
349
+ $a = $msg;
350
+ $foobar = $msg;
351
+ };
352
+ $bar = $msg;
353
+ }
354
+ });
355
+ $foo = 5;
356
+ };
357
+ $bar = $msg;
358
+ }
359
+ });
360
+ $foo = 5;
361
+
362
+ $foo = [
363
+ 0 => function () {
364
+ $foo = 'foo';
365
+ $barbar = 'bar';
366
+ },
367
+ 1 => function () {
368
+ $foo = 'foo';
369
+ $barbar = 'bar';
370
+ },
371
+ ];
372
+
373
+ $abc = 'something';
374
+ if ($foo) {}
375
+ $defghi = 'longer something';
376
+
377
+ function foo() {
378
+ $foo = 'foo';
379
+ $bar = 'bar';
380
+ ?>
381
+
382
+ <div>
383
+ <?php
384
+ $foo = 'foo';
385
+ $bar = 'bar';
386
+ ?>
387
+ </div>
388
+ <?php
389
+ }
390
+
391
+ $foo = new Foo([
392
+ $a = new Bar(),
393
+ $b = new Bar(),
394
+ ]);
395
+
396
+ $foo = new Foo([
397
+ $a = new Bar(),
398
+ $b = new Bar(),
399
+ $c = new Bar(),
400
+ ]);
401
+ $foofoo = new Foo([
402
+ $a = new Bar(),
403
+ $b = new Bar(),
404
+ $c = new Bar(),
405
+ ]);
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.inc.fixed CHANGED
@@ -86,14 +86,14 @@ class MyClass
86
  const MODE_DEBUG = 'debug';
87
  const MODE_DEBUG2 = 'debug';
88
 
89
- $array[$test] = 'anything';
90
- $var = 'anything';
91
-
92
- const MODE_DEBUG2 = 'debug';
93
- $array[$test] = 'anything';
94
- $var = 'anything';
95
- $array[($test + 1)] = 'anything';
96
- $array[($blah + (10 - $test))] = 'anything';
97
  }
98
 
99
  function myFunction($var=true)
@@ -265,3 +265,141 @@ $foo = [
265
  'a' => 'b',
266
  ];
267
  $barbar = 'bar';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  const MODE_DEBUG = 'debug';
87
  const MODE_DEBUG2 = 'debug';
88
 
89
+ var $array[$test] = 'anything';
90
+ var $var = 'anything';
91
+
92
+ const MODE_DEBUG3 = 'debug';
93
+ public $array[$test] = 'anything';
94
+ private $vara = 'anything';
95
+ protected $array[($test + 1)] = 'anything';
96
+ var $array[($blah + (10 - $test))] = 'anything';
97
  }
98
 
99
  function myFunction($var=true)
265
  'a' => 'b',
266
  ];
267
  $barbar = 'bar';
268
+
269
+ $foo = [
270
+
271
+ 'a' => 'b',
272
+ ];
273
+ $barbar = 'bar';
274
+
275
+ function buildForm(FormBuilderInterface $builder, array $options)
276
+ {
277
+ $transformer = new ContractTransformer($options['contracts']);
278
+ $types = ['support.contact.question' => ContactData::QUESTION];
279
+
280
+ [$important, $questions, $incidents, $requests] = $this->createContractBuckets($options['contracts']);
281
+ }
282
+
283
+ function buildForm(FormBuilderInterface $builder, array $options)
284
+ {
285
+ $transformer = new ContractTransformer($options['contracts']);
286
+ $types = ['support.contact.question' => ContactData::QUESTION];
287
+ [$important, $questions, $incidents, $requests] = $this->createContractBuckets($options['contracts']);
288
+ }
289
+
290
+ $loggerResult = $util->setLogger(new class {
291
+ public function log($msg)
292
+ {
293
+ $a = $msg;
294
+ $foobar = $msg;
295
+ $foo = function() {
296
+ $a = $msg;
297
+ $foobar = $msg;
298
+ $loggerResult = $util->setLogger(new class {
299
+ public function log($msg)
300
+ {
301
+ $a = $msg;
302
+ $foobar = $msg;
303
+ $foo = function() {
304
+ foo(function() {
305
+ foo(function() {
306
+ echo 'hi';
307
+ });
308
+ $a = $msg;
309
+ $foobar = $msg;
310
+
311
+ $foo = function() {
312
+
313
+ $foo = 1;
314
+ $barbar =2;
315
+ };
316
+ $barbar = function() {
317
+ $foo = 1;
318
+ $barbar = 2;
319
+ };
320
+ });
321
+ $a = $msg;
322
+ $foobar = $msg;
323
+ };
324
+ $bar = $msg;
325
+ }
326
+
327
+ public function log2($msg)
328
+ {
329
+ $a = $msg;
330
+ $foobar = $msg;
331
+ $foo = function() {
332
+ foo(function() {
333
+ foo(function() {
334
+ echo 'hi';
335
+ });
336
+ $a = $msg;
337
+ $foobar = $msg;
338
+
339
+ $foo = function() {
340
+
341
+ $foo = 1;
342
+ $barbar =2;
343
+ };
344
+ $barbar = function() {
345
+ $foo = 1;
346
+ $barbar = 2;
347
+ };
348
+ });
349
+ $a = $msg;
350
+ $foobar = $msg;
351
+ };
352
+ $bar = $msg;
353
+ }
354
+ });
355
+ $foo = 5;
356
+ };
357
+ $bar = $msg;
358
+ }
359
+ });
360
+ $foo = 5;
361
+
362
+ $foo = [
363
+ 0 => function () {
364
+ $foo = 'foo';
365
+ $barbar = 'bar';
366
+ },
367
+ 1 => function () {
368
+ $foo = 'foo';
369
+ $barbar = 'bar';
370
+ },
371
+ ];
372
+
373
+ $abc = 'something';
374
+ if ($foo) {}
375
+ $defghi = 'longer something';
376
+
377
+ function foo() {
378
+ $foo = 'foo';
379
+ $bar = 'bar';
380
+ ?>
381
+
382
+ <div>
383
+ <?php
384
+ $foo = 'foo';
385
+ $bar = 'bar';
386
+ ?>
387
+ </div>
388
+ <?php
389
+ }
390
+
391
+ $foo = new Foo([
392
+ $a = new Bar(),
393
+ $b = new Bar(),
394
+ ]);
395
+
396
+ $foo = new Foo([
397
+ $a = new Bar(),
398
+ $b = new Bar(),
399
+ $c = new Bar(),
400
+ ]);
401
+ $foofoo = new Foo([
402
+ $a = new Bar(),
403
+ $b = new Bar(),
404
+ $c = new Bar(),
405
+ ]);
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/MultipleStatementAlignmentUnitTest.php CHANGED
@@ -82,6 +82,35 @@ class MultipleStatementAlignmentUnitTest extends AbstractSniffUnitTest
82
  252 => 1,
83
  257 => 1,
84
  263 => 1,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  ];
86
  break;
87
  case 'MultipleStatementAlignmentUnitTest.js':
82
  252 => 1,
83
  257 => 1,
84
  263 => 1,
85
+ 269 => 1,
86
+ 293 => 1,
87
+ 295 => 1,
88
+ 296 => 1,
89
+ 297 => 1,
90
+ 301 => 1,
91
+ 303 => 1,
92
+ 308 => 1,
93
+ 311 => 1,
94
+ 313 => 1,
95
+ 314 => 1,
96
+ 321 => 1,
97
+ 322 => 1,
98
+ 324 => 1,
99
+ 329 => 1,
100
+ 331 => 1,
101
+ 336 => 1,
102
+ 339 => 1,
103
+ 341 => 1,
104
+ 342 => 1,
105
+ 349 => 1,
106
+ 350 => 1,
107
+ 352 => 1,
108
+ 357 => 1,
109
+ 364 => 1,
110
+ 396 => 1,
111
+ 398 => 1,
112
+ 399 => 1,
113
+ 401 => 1,
114
  ];
115
  break;
116
  case 'MultipleStatementAlignmentUnitTest.js':
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.inc CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if (!$someVar || !$x instanceOf 'stdClass') {}
3
- if (! $someVar || ! $x instanceOf 'stdClass') {}
4
  if (!foo() && (!$x || true)) {}
5
  $var = !($x || $y);
1
  <?php
2
+ if (!$someVar || !$x instanceOf stdClass) {}
3
+ if (! $someVar || ! $x instanceOf stdClass) {}
4
  if (!foo() && (!$x || true)) {}
5
  $var = !($x || $y);
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Formatting/SpaceAfterNotUnitTest.inc.fixed CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- if (! $someVar || ! $x instanceOf 'stdClass') {}
3
- if (! $someVar || ! $x instanceOf 'stdClass') {}
4
  if (! foo() && (! $x || true)) {}
5
  $var = ! ($x || $y);
1
  <?php
2
+ if (! $someVar || ! $x instanceOf stdClass) {}
3
+ if (! $someVar || ! $x instanceOf stdClass) {}
4
  if (! foo() && (! $x || true)) {}
5
  $var = ! ($x || $y);
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc CHANGED
@@ -123,3 +123,13 @@ $obj->{$var}($foo,$bar);
123
  echo $a, $b, $c, $d;
124
  };
125
  })('a','b')('c','d');
 
 
 
 
 
 
 
 
 
 
123
  echo $a, $b, $c, $d;
124
  };
125
  })('a','b')('c','d');
126
+
127
+ my_function_call(
128
+ 'a'
129
+ /* Comment */
130
+ ,'b'
131
+ , 'c' // Comment.
132
+ ,'d'
133
+ ,'e' // phpcs:ignore Standard.Category.Sniff -- for reasons.
134
+ , 'f'
135
+ );
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.inc.fixed CHANGED
@@ -123,3 +123,13 @@ $obj->{$var}($foo, $bar);
123
  echo $a, $b, $c, $d;
124
  };
125
  })('a', 'b')('c', 'd');
 
 
 
 
 
 
 
 
 
 
123
  echo $a, $b, $c, $d;
124
  };
125
  })('a', 'b')('c', 'd');
126
+
127
+ my_function_call(
128
+ 'a',
129
+ /* Comment */
130
+ 'b',
131
+ 'c', // Comment.
132
+ 'd',
133
+ 'e', // phpcs:ignore Standard.Category.Sniff -- for reasons.
134
+ 'f'
135
+ );
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/FunctionCallArgumentSpacingUnitTest.php CHANGED
@@ -47,6 +47,11 @@ class FunctionCallArgumentSpacingUnitTest extends AbstractSniffUnitTest
47
  115 => 1,
48
  119 => 1,
49
  125 => 2,
 
 
 
 
 
50
  ];
51
 
52
  }//end getErrorList()
47
  115 => 1,
48
  119 => 1,
49
  125 => 2,
50
+ 130 => 2,
51
+ 131 => 1,
52
+ 132 => 2,
53
+ 133 => 2,
54
+ 134 => 1,
55
  ];
56
 
57
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc CHANGED
@@ -24,7 +24,7 @@ function myFunction()
24
  {
25
  }
26
 
27
- class myClass()
28
  {
29
  // Brace should be on new line.
30
  function myFunction() {
@@ -91,7 +91,7 @@ function myFunction($variable1, $variable2,
91
  {
92
  }
93
 
94
- class myClass()
95
  {
96
  // Brace should be on new line.
97
  function myFunction($variable1, $variable2,
@@ -129,7 +129,7 @@ class myClass()
129
  }
130
  }
131
 
132
- interface MyInterface()
133
  {
134
  function myFunction();
135
  }
@@ -171,7 +171,7 @@ $closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2) {
171
 
172
  $test = function ($param) use ($result) {
173
  return null;
174
- }
175
 
176
  $test = function ($param) use ($result) : Something {
177
  return null;
@@ -196,3 +196,43 @@ class Foo
196
  function myFunction() : Something {
197
  return null;
198
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
  {
25
  }
26
 
27
+ class myClass
28
  {
29
  // Brace should be on new line.
30
  function myFunction() {
91
  {
92
  }
93
 
94
+ class myClass
95
  {
96
  // Brace should be on new line.
97
  function myFunction($variable1, $variable2,
129
  }
130
  }
131
 
132
+ interface MyInterface
133
  {
134
  function myFunction();
135
  }
171
 
172
  $test = function ($param) use ($result) {
173
  return null;
174
+ };
175
 
176
  $test = function ($param) use ($result) : Something {
177
  return null;
196
  function myFunction() : Something {
197
  return null;
198
  }
199
+
200
+ function myFunction($a, $lot, $of, $params)
201
+ : array {
202
+ return null;
203
+ }
204
+
205
+ function myFunction($a, $lot, $of, $params) { // comment
206
+ return null;
207
+ }
208
+
209
+ function myFunction($a, $lot, $of, $params)
210
+ : array { // comment
211
+ return null;
212
+ }
213
+
214
+ function myFunction($a, $lot, $of, $params)
215
+ : array { // phpcs:ignore Standard.Category.Sniff -- for reasons.
216
+ return null;
217
+ }
218
+
219
+ function myFunction($a, $lot, $of, $params)
220
+ : array {// phpcs:ignore Standard.Category.Sniff -- for reasons.
221
+ return null;
222
+ }
223
+
224
+ function myFunction($a, $lot, $of, $params)
225
+ : array
226
+ { // phpcs:ignore Standard.Category.Sniff -- for reasons.
227
+ return null;
228
+ }
229
+
230
+ function myFunction($a, $lot, $of, $params)
231
+ : array /* phpcs:ignore Standard.Category.Sniff -- for reasons */ {
232
+ return null;
233
+ }
234
+
235
+ function myFunction($a, $lot, $of, $params)
236
+ : array /* comment */ {
237
+ return null;
238
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.inc.fixed CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
 
3
  // Brace should be on new line.
4
- function myFunction()
5
  {
6
  }
7
 
@@ -11,7 +11,7 @@ function myFunction()
11
  }
12
 
13
  // Too many spaces.
14
- function myFunction()
15
  {
16
  }
17
 
@@ -25,10 +25,10 @@ function myFunction()
25
  {
26
  }
27
 
28
- class myClass()
29
  {
30
  // Brace should be on new line.
31
- function myFunction()
32
  {
33
  }
34
 
@@ -43,7 +43,7 @@ class myClass()
43
  }
44
 
45
  // Too many spaces.
46
- function myFunction()
47
  {
48
  }
49
 
@@ -66,7 +66,7 @@ class myClass()
66
 
67
  // Brace should be on new line.
68
  function myFunction($variable1, $variable2,
69
- $variable3, $variable4)
70
  {
71
  }
72
 
@@ -78,7 +78,7 @@ function myFunction($variable1, $variable2,
78
 
79
  // Too many spaces.
80
  function myFunction($variable1, $variable2,
81
- $variable3, $variable4)
82
  {
83
  }
84
 
@@ -94,11 +94,11 @@ function myFunction($variable1, $variable2,
94
  {
95
  }
96
 
97
- class myClass()
98
  {
99
  // Brace should be on new line.
100
  function myFunction($variable1, $variable2,
101
- $variable3, $variable4)
102
  {
103
  }
104
 
@@ -116,7 +116,7 @@ class myClass()
116
 
117
  // Too many spaces.
118
  function myFunction($variable1, $variable2,
119
- $variable3, $variable4)
120
  {
121
  }
122
 
@@ -133,7 +133,7 @@ class myClass()
133
  }
134
  }
135
 
136
- interface MyInterface()
137
  {
138
  function myFunction();
139
  }
@@ -156,33 +156,33 @@ function myFunction(
156
  $arg4,
157
  $arg5,
158
  $arg6
159
- )
160
  {
161
  }
162
 
163
- function myFunction()
164
  {}
165
  function myFunction()
166
  {}
167
 
168
  // phpcs:set Generic.Functions.OpeningFunctionBraceBsdAllman checkClosures 1
169
 
170
- $closureWithArgs = function ($arg1, $arg2)
171
  {
172
  // body
173
  };
174
 
175
- $closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2)
176
  {
177
  // body
178
  };
179
 
180
- $test = function ($param) use ($result)
181
  {
182
  return null;
183
- }
184
 
185
- $test = function ($param) use ($result) : Something
186
  {
187
  return null;
188
  };
@@ -203,7 +203,56 @@ class Foo
203
  //Comments should not affect code
204
  }
205
 
206
- function myFunction() : Something
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  {
208
  return null;
209
  }
1
  <?php
2
 
3
  // Brace should be on new line.
4
+ function myFunction()
5
  {
6
  }
7
 
11
  }
12
 
13
  // Too many spaces.
14
+ function myFunction()
15
  {
16
  }
17
 
25
  {
26
  }
27
 
28
+ class myClass
29
  {
30
  // Brace should be on new line.
31
+ function myFunction()
32
  {
33
  }
34
 
43
  }
44
 
45
  // Too many spaces.
46
+ function myFunction()
47
  {
48
  }
49
 
66
 
67
  // Brace should be on new line.
68
  function myFunction($variable1, $variable2,
69
+ $variable3, $variable4)
70
  {
71
  }
72
 
78
 
79
  // Too many spaces.
80
  function myFunction($variable1, $variable2,
81
+ $variable3, $variable4)
82
  {
83
  }
84
 
94
  {
95
  }
96
 
97
+ class myClass
98
  {
99
  // Brace should be on new line.
100
  function myFunction($variable1, $variable2,
101
+ $variable3, $variable4)
102
  {
103
  }
104
 
116
 
117
  // Too many spaces.
118
  function myFunction($variable1, $variable2,
119
+ $variable3, $variable4)
120
  {
121
  }
122
 
133
  }
134
  }
135
 
136
+ interface MyInterface
137
  {
138
  function myFunction();
139
  }
156
  $arg4,
157
  $arg5,
158
  $arg6
159
+ )
160
  {
161
  }
162
 
163
+ function myFunction()
164
  {}
165
  function myFunction()
166
  {}
167
 
168
  // phpcs:set Generic.Functions.OpeningFunctionBraceBsdAllman checkClosures 1
169
 
170
+ $closureWithArgs = function ($arg1, $arg2)
171
  {
172
  // body
173
  };
174
 
175
+ $closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2)
176
  {
177
  // body
178
  };
179
 
180
+ $test = function ($param) use ($result)
181
  {
182
  return null;
183
+ };
184
 
185
+ $test = function ($param) use ($result) : Something
186
  {
187
  return null;
188
  };
203
  //Comments should not affect code
204
  }
205
 
206
+ function myFunction() : Something
207
+ {
208
+ return null;
209
+ }
210
+
211
+ function myFunction($a, $lot, $of, $params)
212
+ : array
213
+ {
214
+ return null;
215
+ }
216
+
217
+ function myFunction($a, $lot, $of, $params)
218
+ {
219
+ // comment
220
+ return null;
221
+ }
222
+
223
+ function myFunction($a, $lot, $of, $params)
224
+ : array
225
+ {
226
+ // comment
227
+ return null;
228
+ }
229
+
230
+ function myFunction($a, $lot, $of, $params)
231
+ : array // phpcs:ignore Standard.Category.Sniff -- for reasons.
232
+ {
233
+ return null;
234
+ }
235
+
236
+ function myFunction($a, $lot, $of, $params)
237
+ : array // phpcs:ignore Standard.Category.Sniff -- for reasons.
238
+ {
239
+ return null;
240
+ }
241
+
242
+ function myFunction($a, $lot, $of, $params)
243
+ : array
244
+ { // phpcs:ignore Standard.Category.Sniff -- for reasons.
245
+ return null;
246
+ }
247
+
248
+ function myFunction($a, $lot, $of, $params)
249
+ : array /* phpcs:ignore Standard.Category.Sniff -- for reasons */
250
+ {
251
+ return null;
252
+ }
253
+
254
+ function myFunction($a, $lot, $of, $params)
255
+ : array /* comment */
256
  {
257
  return null;
258
  }
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceBsdAllmanUnitTest.php CHANGED
@@ -51,6 +51,13 @@ class OpeningFunctionBraceBsdAllmanUnitTest extends AbstractSniffUnitTest
51
  172 => 1,
52
  176 => 1,
53
  196 => 1,
 
 
 
 
 
 
 
54
  ];
55
 
56
  }//end getErrorList()
51
  172 => 1,
52
  176 => 1,
53
  196 => 1,
54
+ 201 => 1,
55
+ 205 => 2,
56
+ 210 => 2,
57
+ 215 => 1,
58
+ 220 => 1,
59
+ 231 => 1,
60
+ 236 => 1,
61
  ];
62
 
63
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc CHANGED
@@ -18,7 +18,7 @@ function myFunction() {
18
  }
19
 
20
 
21
- class myClass()
22
  {
23
  // Good.
24
  function myFunction() {
@@ -64,7 +64,7 @@ function myFunction($variable1, $variable2,
64
  }
65
 
66
 
67
- class myClass()
68
  {
69
  // Good.
70
  function myFunction($variable1, $variable2,
@@ -88,7 +88,7 @@ class myClass()
88
  }
89
  }
90
 
91
- interface MyInterface()
92
  {
93
  function myFunction();
94
  }
@@ -131,17 +131,17 @@ $closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2){
131
  $test = function ($param) use ($result)
132
  {
133
  return null;
134
- }
135
 
136
  $test = function ($param) use ($result) : Something
137
  {
138
  return null;
139
- }
140
 
141
  $test = function ($param) use ($result): Something
142
  {
143
  return null;
144
- }
145
 
146
  foo(function ($bar) { ?>
147
  <div><?php echo $bar; ?></div>
@@ -175,3 +175,36 @@ function myFunction(): Something
175
  function myFunction($bar) { ?>
176
  <div><?php echo $bar; ?></div>
177
  <?php }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  }
19
 
20
 
21
+ class myClass
22
  {
23
  // Good.
24
  function myFunction() {
64
  }
65
 
66
 
67
+ class myClass
68
  {
69
  // Good.
70
  function myFunction($variable1, $variable2,
88
  }
89
  }
90
 
91
+ interface MyInterface
92
  {
93
  function myFunction();
94
  }
131
  $test = function ($param) use ($result)
132
  {
133
  return null;
134
+ };
135
 
136
  $test = function ($param) use ($result) : Something
137
  {
138
  return null;
139
+ };
140
 
141
  $test = function ($param) use ($result): Something
142
  {
143
  return null;
144
+ };
145
 
146
  foo(function ($bar) { ?>
147
  <div><?php echo $bar; ?></div>
175
  function myFunction($bar) { ?>
176
  <div><?php echo $bar; ?></div>
177
  <?php }
178
+
179
+ function myFunction($a, $lot, $of, $params)
180
+ : array
181
+ {
182
+ return null;
183
+ }
184
+
185
+ function myFunction($a, $lot, $of, $params)
186
+ : array {
187
+ return null;
188
+ }
189
+
190
+ function myFunction($a, $lot, $of, $params) // comment
191
+ {
192
+ return null;
193
+ }
194
+
195
+ function myFunction($a, $lot, $of, $params)
196
+ : array // comment
197
+ {
198
+ return null;
199
+ }
200
+
201
+ function myFunction($a, $lot, $of, $params)
202
+ : array // phpcs:ignore Standard.Category.Sniff -- for reasons.
203
+ {
204
+ return null;
205
+ }
206
+
207
+ function myFunction($a, $lot, $of, $params)
208
+ : array { // phpcs:ignore Standard.Category.Sniff -- for reasons.
209
+ return null;
210
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.inc.fixed CHANGED
@@ -17,7 +17,7 @@ function myFunction() {
17
  }
18
 
19
 
20
- class myClass()
21
  {
22
  // Good.
23
  function myFunction() {
@@ -61,7 +61,7 @@ function myFunction($variable1, $variable2,
61
  }
62
 
63
 
64
- class myClass()
65
  {
66
  // Good.
67
  function myFunction($variable1, $variable2,
@@ -84,7 +84,7 @@ class myClass()
84
  }
85
  }
86
 
87
- interface MyInterface()
88
  {
89
  function myFunction();
90
  }
@@ -125,15 +125,15 @@ $closureWithArgsAndVars = function ($arg1, $arg2) use ($var1, $var2) {
125
 
126
  $test = function ($param) use ($result) {
127
  return null;
128
- }
129
 
130
  $test = function ($param) use ($result) : Something {
131
  return null;
132
- }
133
 
134
  $test = function ($param) use ($result): Something {
135
  return null;
136
- }
137
 
138
  foo(function ($bar) { ?>
139
  <div><?php echo $bar; ?></div>
@@ -165,3 +165,34 @@ function myFunction(): Something {
165
  function myFunction($bar) { ?>
166
  <div><?php echo $bar; ?></div>
167
  <?php }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
18
 
19
 
20
+ class myClass
21
  {
22
  // Good.
23
  function myFunction() {
61
  }
62
 
63
 
64
+ class myClass
65
  {
66
  // Good.
67
  function myFunction($variable1, $variable2,
84
  }
85
  }
86
 
87
+ interface MyInterface
88
  {
89
  function myFunction();
90
  }
125
 
126
  $test = function ($param) use ($result) {
127
  return null;
128
+ };
129
 
130
  $test = function ($param) use ($result) : Something {
131
  return null;
132
+ };
133
 
134
  $test = function ($param) use ($result): Something {
135
  return null;
136
+ };
137
 
138
  foo(function ($bar) { ?>
139
  <div><?php echo $bar; ?></div>
165
  function myFunction($bar) { ?>
166
  <div><?php echo $bar; ?></div>
167
  <?php }
168
+
169
+ function myFunction($a, $lot, $of, $params)
170
+ : array {
171
+ return null;
172
+ }
173
+
174
+ function myFunction($a, $lot, $of, $params)
175
+ : array {
176
+ return null;
177
+ }
178
+
179
+ function myFunction($a, $lot, $of, $params) {
180
+ // comment
181
+ return null;
182
+ }
183
+
184
+ function myFunction($a, $lot, $of, $params)
185
+ : array {
186
+ // comment
187
+ return null;
188
+ }
189
+
190
+ function myFunction($a, $lot, $of, $params)
191
+ : array { // phpcs:ignore Standard.Category.Sniff -- for reasons.
192
+ return null;
193
+ }
194
+
195
+ function myFunction($a, $lot, $of, $params)
196
+ : array { // phpcs:ignore Standard.Category.Sniff -- for reasons.
197
+ return null;
198
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Functions/OpeningFunctionBraceKernighanRitchieUnitTest.php CHANGED
@@ -48,6 +48,10 @@ class OpeningFunctionBraceKernighanRitchieUnitTest extends AbstractSniffUnitTest
48
  157 => 1,
49
  162 => 1,
50
  171 => 1,
 
 
 
 
51
  ];
52
 
53
  }//end getErrorList()
48
  157 => 1,
49
  162 => 1,
50
  171 => 1,
51
+ 181 => 1,
52
+ 191 => 1,
53
+ 197 => 1,
54
+ 203 => 1,
55
  ];
56
 
57
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.inc CHANGED
@@ -36,12 +36,12 @@ function get_some_value() {}
36
  class Magic_Test {
37
  function __construct() {}
38
  function __destruct() {}
39
- function __call() {}
40
- function __callStatic() {}
41
- function __get() {}
42
- function __set() {}
43
- function __isset() {}
44
- function __unset() {}
45
  function __sleep() {}
46
  function __wakeup() {}
47
  function __toString() {}
@@ -51,7 +51,7 @@ class Magic_Test {
51
  function __invoke() {}
52
  function __myFunction() {}
53
  function __my_function() {}
54
- function __call() {}
55
  }
56
 
57
  function __construct() {}
@@ -67,11 +67,11 @@ function __wakeup() {}
67
  function __toString() {}
68
  function __set_state() {}
69
  function __clone() {}
70
- function __autoload() {}
71
  function __invoke() {}
72
  function __myFunction() {}
73
  function __my_function() {}
74
- function __call() {}
75
 
76
  class Closure_Test {
77
  function test() {
@@ -92,15 +92,15 @@ class MyClass
92
 
93
  trait Foo
94
  {
95
- function __call() {}
96
  }
97
 
98
  class Magic_Case_Test {
99
  function __Construct() {}
100
- function __isSet() {}
101
  function __tostring() {}
102
  }
103
- function __autoLoad() {}
104
 
105
  class Foo extends \SoapClient
106
  {
@@ -130,12 +130,12 @@ class triple {
130
  $a = new class {
131
  function __construct() {}
132
  function __destruct() {}
133
- function __call() {}
134
- function __callStatic() {}
135
- function __get() {}
136
- function __set() {}
137
- function __isset() {}
138
- function __unset() {}
139
  function __sleep() {}
140
  function __wakeup() {}
141
  function __toString() {}
@@ -145,5 +145,5 @@ $a = new class {
145
  function __invoke() {}
146
  function __myFunction() {}
147
  function __my_function() {}
148
- function __call() {}
149
- }
36
  class Magic_Test {
37
  function __construct() {}
38
  function __destruct() {}
39
+ function __call($name, $args) {}
40
+ static function __callStatic($name, $args) {}
41
+ function __get($name) {}
42
+ function __set($name, $value) {}
43
+ function __isset($name) {}
44
+ function __unset($name) {}
45
  function __sleep() {}
46
  function __wakeup() {}
47
  function __toString() {}
51
  function __invoke() {}
52
  function __myFunction() {}
53
  function __my_function() {}
54
+
55
  }
56
 
57
  function __construct() {}
67
  function __toString() {}
68
  function __set_state() {}
69
  function __clone() {}
70
+ function __autoload($class) {}
71
  function __invoke() {}
72
  function __myFunction() {}
73
  function __my_function() {}
74
+
75
 
76
  class Closure_Test {
77
  function test() {
92
 
93
  trait Foo
94
  {
95
+ function __call($name, $args) {}
96
  }
97
 
98
  class Magic_Case_Test {
99
  function __Construct() {}
100
+ function __isSet($name) {}
101
  function __tostring() {}
102
  }
103
+ function __autoLoad($class) {}
104
 
105
  class Foo extends \SoapClient
106
  {
130
  $a = new class {
131
  function __construct() {}
132
  function __destruct() {}
133
+ function __call($name, $args) {}
134
+ static function __callStatic($name, $args) {}
135
+ function __get($name) {}
136
+ function __set($name, $value) {}
137
+ function __isset($name) {}
138
+ function __unset($name) {}
139
  function __sleep() {}
140
  function __wakeup() {}
141
  function __toString() {}
145
  function __invoke() {}
146
  function __myFunction() {}
147
  function __my_function() {}
148
+
149
+ };
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/NamingConventions/CamelCapsFunctionNameUnitTest.php CHANGED
@@ -57,7 +57,6 @@ class CamelCapsFunctionNameUnitTest extends AbstractSniffUnitTest
57
  71 => 1,
58
  72 => 1,
59
  73 => 2,
60
- 74 => 1,
61
  118 => 1,
62
  144 => 1,
63
  146 => 1,
57
  71 => 1,
58
  72 => 1,
59
  73 => 2,
 
60
  118 => 1,
61
  144 => 1,
62
  146 => 1,
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/NamingConventions/UpperCaseConstantNameUnitTest.inc CHANGED
@@ -13,7 +13,7 @@ define('bar\foo\baz\invalidNameWithNamespace', true);
13
  define("bar\foo\baz\VALID_NAME_WITH_NAMESPACE", true);
14
  define("bar\foo\baz\invalidNameWithNamespace", true);
15
 
16
- class TestClass extends MyClass, YourClass
17
  {
18
 
19
  const const1 = 'hello';
13
  define("bar\foo\baz\VALID_NAME_WITH_NAMESPACE", true);
14
  define("bar\foo\baz\invalidNameWithNamespace", true);
15
 
16
+ class TestClass extends MyClass implements MyInterface, YourInterface
17
  {
18
 
19
  const const1 = 'hello';
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/DisallowAlternativePHPTagsUnitTest.php CHANGED
@@ -42,18 +42,6 @@ class DisallowAlternativePHPTagsUnitTest extends AbstractSniffUnitTest
42
  }//end getTestFiles()
43
 
44
 
45
- /**
46
- * Skip this test on HHVM.
47
- *
48
- * @return bool Whether to skip this test.
49
- */
50
- protected function shouldSkipTest()
51
- {
52
- return defined('HHVM_VERSION');
53
-
54
- }//end shouldSkipTest()
55
-
56
-
57
  /**
58
  * Returns the lines where errors should occur.
59
  *
42
  }//end getTestFiles()
43
 
44
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  /**
46
  * Returns the lines where errors should occur.
47
  *
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/DisallowShortOpenTagUnitTest.php CHANGED
@@ -27,7 +27,7 @@ class DisallowShortOpenTagUnitTest extends AbstractSniffUnitTest
27
  $testFiles = [$testFileBase.'1.inc'];
28
 
29
  $option = (boolean) ini_get('short_open_tag');
30
- if ($option === true || defined('HHVM_VERSION') === true) {
31
  $testFiles[] = $testFileBase.'2.inc';
32
  } else {
33
  $testFiles[] = $testFileBase.'3.inc';
@@ -52,13 +52,6 @@ class DisallowShortOpenTagUnitTest extends AbstractSniffUnitTest
52
  {
53
  switch ($testFile) {
54
  case 'DisallowShortOpenTagUnitTest.1.inc':
55
- if (PHP_VERSION_ID < 50400) {
56
- $option = (boolean) ini_get('short_open_tag');
57
- if ($option === false) {
58
- // Short open tags are off and PHP isn't doing short echo by default.
59
- return [];
60
- }
61
- }
62
  return [
63
  5 => 1,
64
  6 => 1,
@@ -93,18 +86,6 @@ class DisallowShortOpenTagUnitTest extends AbstractSniffUnitTest
93
  {
94
  switch ($testFile) {
95
  case 'DisallowShortOpenTagUnitTest.1.inc':
96
- if (PHP_VERSION_ID < 50400) {
97
- $option = (boolean) ini_get('short_open_tag');
98
- if ($option === false) {
99
- // Short open tags are off and PHP isn't doing short echo by default.
100
- return [
101
- 5 => 1,
102
- 6 => 1,
103
- 7 => 1,
104
- 10 => 1,
105
- ];
106
- }
107
- }
108
  return [];
109
  case 'DisallowShortOpenTagUnitTest.3.inc':
110
  return [
27
  $testFiles = [$testFileBase.'1.inc'];
28
 
29
  $option = (boolean) ini_get('short_open_tag');
30
+ if ($option === true) {
31
  $testFiles[] = $testFileBase.'2.inc';
32
  } else {
33
  $testFiles[] = $testFileBase.'3.inc';
52
  {
53
  switch ($testFile) {
54
  case 'DisallowShortOpenTagUnitTest.1.inc':
 
 
 
 
 
 
 
55
  return [
56
  5 => 1,
57
  6 => 1,
86
  {
87
  switch ($testFile) {
88
  case 'DisallowShortOpenTagUnitTest.1.inc':
 
 
 
 
 
 
 
 
 
 
 
 
89
  return [];
90
  case 'DisallowShortOpenTagUnitTest.3.inc':
91
  return [
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/ForbiddenFunctionsUnitTest.inc CHANGED
@@ -43,7 +43,7 @@ class RightSideTest {
43
  class RightSideVisTest {
44
  use DelProvider {
45
  delete as protected delete;
46
- delete insteadof delete;
47
  }
48
  }
49
 
43
  class RightSideVisTest {
44
  use DelProvider {
45
  delete as protected delete;
46
+ DelProvider::delete insteadof delete;
47
  }
48
  }
49
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc CHANGED
@@ -1,25 +1,25 @@
1
  <?php
2
  // A few keywords. Obviously not valid syntax.
3
- class Something extends SomethingElse implements Whatever
4
  abstract public private protected function whatever() {}
5
- const array()
6
- for ($var as $var) { exit; }
7
- if ($a and $b or $c xor $d) { die; } elseif { } else
8
  goto a;
9
 
10
- Class Something EXTENDS SomethingElse implementS Whatever
11
  Abstract Public Private Protected function whatever() {}
12
- CONST array()
13
- For ($var As $var) { Exit; }
14
- If ($a AND $b OR $c XOR $d) { Die; } ElseIf { } Else
15
  GOTO a;
16
- function (Array $a) {}
17
  const PRIVATE;
18
  HttpStatus::CONTINUE;
19
- Function ($f) {
20
  Yield $f;
21
  Yield From fun();
22
- }
23
  class X extends Y {
24
  public function m() {
25
  Parent::m();
1
  <?php
2
  // A few keywords. Obviously not valid syntax.
3
+ class Something extends SomethingElse implements Whatever {}
4
  abstract public private protected function whatever() {}
5
+ const array();
6
+ foreach ($var as $var) { exit; }
7
+ if ($a and $b or $c xor $d) { die; } elseif( $var ) { } else {}
8
  goto a;
9
 
10
+ Class Something EXTENDS SomethingElse implementS Whatever {}
11
  Abstract Public Private Protected function whatever() {}
12
+ CONST array();
13
+ ForEach ($var As $var) { Exit; }
14
+ If ($a AND $b OR $c XOR $d) { Die; } ElseIf( $var ) { } Else {}
15
  GOTO a;
16
+ $b = function (Array $a) {};
17
  const PRIVATE;
18
  HttpStatus::CONTINUE;
19
+ $c = Function ($f) {
20
  Yield $f;
21
  Yield From fun();
22
+ };
23
  class X extends Y {
24
  public function m() {
25
  Parent::m();
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.inc.fixed CHANGED
@@ -1,25 +1,25 @@
1
  <?php
2
  // A few keywords. Obviously not valid syntax.
3
- class Something extends SomethingElse implements Whatever
4
  abstract public private protected function whatever() {}
5
- const array()
6
- for ($var as $var) { exit; }
7
- if ($a and $b or $c xor $d) { die; } elseif { } else
8
  goto a;
9
 
10
- class Something extends SomethingElse implements Whatever
11
  abstract public private protected function whatever() {}
12
- const array()
13
- for ($var as $var) { exit; }
14
- if ($a and $b or $c xor $d) { die; } elseif { } else
15
  goto a;
16
- function (array $a) {}
17
  const PRIVATE;
18
  HttpStatus::CONTINUE;
19
- function ($f) {
20
  yield $f;
21
  yield from fun();
22
- }
23
  class X extends Y {
24
  public function m() {
25
  parent::m();
1
  <?php
2
  // A few keywords. Obviously not valid syntax.
3
+ class Something extends SomethingElse implements Whatever {}
4
  abstract public private protected function whatever() {}
5
+ const array();
6
+ foreach ($var as $var) { exit; }
7
+ if ($a and $b or $c xor $d) { die; } elseif( $var ) { } else {}
8
  goto a;
9
 
10
+ class Something extends SomethingElse implements Whatever {}
11
  abstract public private protected function whatever() {}
12
+ const array();
13
+ foreach ($var as $var) { exit; }
14
+ if ($a and $b or $c xor $d) { die; } elseif( $var ) { } else {}
15
  goto a;
16
+ $b = function (Array $a) {};
17
  const PRIVATE;
18
  HttpStatus::CONTINUE;
19
+ $c = function ($f) {
20
  yield $f;
21
  yield from fun();
22
+ };
23
  class X extends Y {
24
  public function m() {
25
  parent::m();
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseKeywordUnitTest.php CHANGED
@@ -32,7 +32,6 @@ class LowerCaseKeywordUnitTest extends AbstractSniffUnitTest
32
  13 => 3,
33
  14 => 7,
34
  15 => 1,
35
- 16 => 1,
36
  19 => 1,
37
  20 => 1,
38
  21 => 1,
32
  13 => 3,
33
  14 => 7,
34
  15 => 1,
 
35
  19 => 1,
36
  20 => 1,
37
  21 => 1,
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $foo = (int) $bar;
3
+ $foo = (integer) $bar;
4
+ $foo = (bool) $bar;
5
+ $foo = (boolean) $bar;
6
+ $foo = (float) $bar;
7
+ $foo = (double) $bar;
8
+ $foo = (real) $bar;
9
+ $foo = (string) $bar;
10
+ $foo = (array) $bar;
11
+ $foo = (object) $bar;
12
+ $foo = (unset) $bar;
13
+
14
+ $foo = (Int) $bar;
15
+ $foo = (INTEGER) $bar;
16
+ $foo = (BOOL) $bar;
17
+ $foo = (String) $bar;
18
+ $foo = (Array) $bar;
19
+
20
+ function foo(int $a, string $b, bool $c, array $d, Foo\Bar $e) : int {}
21
+ function foo(Int $a, String $b, BOOL $c, Array $d, Foo\Bar $e) : Foo\Bar {}
22
+ function foo(Int $a, Bar $b, BOOL $c, Array $d, Foo\Bar $e) : Bar {}
23
+ function foo(callable $a, Callable $b, self $c, Iterable $d, iterable $e) : Float {}
24
+
25
+ $foo = function (int $a, Bool $b) {};
26
+ $foo = function (int $a, Callable $b) :INT{};
27
+ $foo = function (BOOL $a, float $b) use ($foo) : INT {};
28
+ $foo = function (Foo $a, Foo\Bar $b) use ($foo) : \Foo\Bar {};
29
+ $foo = function (bool $a, callable $b) use ($foo) : Bar {};
30
+
31
+ class Testing {
32
+ public function TestThis(SELF $a, obJect $b, Parent $c) : VOID {}
33
+ }
34
+
35
+ function foo(
36
+ ?Float $a,
37
+ ? String $b,
38
+ ?ITERABLE $c,
39
+ ? Object $d,
40
+ ?Foo\Bar $e
41
+ ) : ?Foo\Bar {}
42
+
43
+ $foo = function (?Int $a, ? Callable $b)
44
+ :?INT{};
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.inc.fixed ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $foo = (int) $bar;
3
+ $foo = (integer) $bar;
4
+ $foo = (bool) $bar;
5
+ $foo = (boolean) $bar;
6
+ $foo = (float) $bar;
7
+ $foo = (double) $bar;
8
+ $foo = (real) $bar;
9
+ $foo = (string) $bar;
10
+ $foo = (array) $bar;
11
+ $foo = (object) $bar;
12
+ $foo = (unset) $bar;
13
+
14
+ $foo = (int) $bar;
15
+ $foo = (integer) $bar;
16
+ $foo = (bool) $bar;
17
+ $foo = (string) $bar;
18
+ $foo = (array) $bar;
19
+
20
+ function foo(int $a, string $b, bool $c, array $d, Foo\Bar $e) : int {}
21
+ function foo(int $a, string $b, bool $c, array $d, Foo\Bar $e) : Foo\Bar {}
22
+ function foo(int $a, Bar $b, bool $c, array $d, Foo\Bar $e) : Bar {}
23
+ function foo(callable $a, callable $b, self $c, iterable $d, iterable $e) : float {}
24
+
25
+ $foo = function (int $a, bool $b) {};
26
+ $foo = function (int $a, callable $b) :int{};
27
+ $foo = function (bool $a, float $b) use ($foo) : int {};
28
+ $foo = function (Foo $a, Foo\Bar $b) use ($foo) : \Foo\Bar {};
29
+ $foo = function (bool $a, callable $b) use ($foo) : Bar {};
30
+
31
+ class Testing {
32
+ public function TestThis(self $a, object $b, parent $c) : void {}
33
+ }
34
+
35
+ function foo(
36
+ ?float $a,
37
+ ? string $b,
38
+ ?iterable $c,
39
+ ? object $d,
40
+ ?Foo\Bar $e
41
+ ) : ?Foo\Bar {}
42
+
43
+ $foo = function (?int $a, ? callable $b)
44
+ :?int{};
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/LowerCaseTypeUnitTest.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Unit test class for the LowerCaseType sniff.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\Generic\Tests\PHP;
11
+
12
+ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
13
+
14
+ class LowerCaseTypeUnitTest extends AbstractSniffUnitTest
15
+ {
16
+
17
+
18
+ /**
19
+ * Returns the lines where errors should occur.
20
+ *
21
+ * The key of the array should represent the line number and the value
22
+ * should represent the number of errors that should occur on that line.
23
+ *
24
+ * @return array<int, int>
25
+ */
26
+ public function getErrorList()
27
+ {
28
+ return [
29
+ 14 => 1,
30
+ 15 => 1,
31
+ 16 => 1,
32
+ 17 => 1,
33
+ 18 => 1,
34
+ 21 => 4,
35
+ 22 => 3,
36
+ 23 => 3,
37
+ 25 => 1,
38
+ 26 => 2,
39
+ 27 => 2,
40
+ 32 => 4,
41
+ 36 => 1,
42
+ 37 => 1,
43
+ 38 => 1,
44
+ 39 => 1,
45
+ 43 => 2,
46
+ 44 => 1,
47
+ ];
48
+
49
+ }//end getErrorList()
50
+
51
+
52
+ /**
53
+ * Returns the lines where warnings should occur.
54
+ *
55
+ * The key of the array should represent the line number and the value
56
+ * should represent the number of warnings that should occur on that line.
57
+ *
58
+ * @return array<int, int>
59
+ */
60
+ public function getWarningList()
61
+ {
62
+ return [];
63
+
64
+ }//end getWarningList()
65
+
66
+
67
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/SyntaxUnitTest.php CHANGED
@@ -17,27 +17,6 @@ class SyntaxUnitTest extends AbstractSniffUnitTest
17
  {
18
 
19
 
20
- /**
21
- * Should this test be skipped for some reason.
22
- *
23
- * @return void
24
- */
25
- protected function shouldSkipTest()
26
- {
27
- if (defined('PHP_BINARY') === true) {
28
- return false;
29
- }
30
-
31
- $phpPath = Config::getExecutablePath('php');
32
- if ($phpPath === null) {
33
- return true;
34
- }
35
-
36
- return false;
37
-
38
- }//end shouldSkipTest()
39
-
40
-
41
  /**
42
  * Returns the lines where errors should occur.
43
  *
17
  {
18
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  /**
21
  * Returns the lines where errors should occur.
22
  *
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc CHANGED
@@ -51,7 +51,7 @@ $x = new stdClass();
51
  $x->null = 7;
52
 
53
  use Zend\Log\Writer\Null as NullWriter;
54
- new \Zend\Log\Writer\Null()
55
 
56
  namespace False;
57
 
51
  $x->null = 7;
52
 
53
  use Zend\Log\Writer\Null as NullWriter;
54
+ new \Zend\Log\Writer\Null();
55
 
56
  namespace False;
57
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/PHP/UpperCaseConstantUnitTest.inc.fixed CHANGED
@@ -51,7 +51,7 @@ $x = new stdClass();
51
  $x->null = 7;
52
 
53
  use Zend\Log\Writer\Null as NullWriter;
54
- new \Zend\Log\Writer\Null()
55
 
56
  namespace False;
57
 
51
  $x->null = 7;
52
 
53
  use Zend\Log\Writer\Null as NullWriter;
54
+ new \Zend\Log\Writer\Null();
55
 
56
  namespace False;
57
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/Strings/UnnecessaryStringConcatUnitTest.inc CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  $x = 'My '.'string';
3
- $x = 'My '.1234;
4
  $x = 'My '.$y.' test';
5
 
6
  echo $data['my'.'index'];
7
- echo $data['my'.4];
8
  echo $data['my'.$x];
9
  echo $data[$x.$y.'My'.'String'];
10
 
1
  <?php
2
  $x = 'My '.'string';
3
+ $x = 'My '. 1234;
4
  $x = 'My '.$y.' test';
5
 
6
  echo $data['my'.'index'];
7
+ echo $data['my'. 4];
8
  echo $data['my'.$x];
9
  echo $data[$x.$y.'My'.'String'];
10
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.inc ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Make sure the sniff does not act on structures it shouldn't act on.
5
+ * All parentheses have extra spacing around it to test this properly.
6
+ */
7
+ $b = functioncall( $something ) ;
8
+ $b = function( $something ) {};
9
+ $c = myFunction( $arg1 , $arg2 = array( ) );
10
+
11
+ function something( $param ) {}
12
+
13
+ $d = new MyClass( );
14
+ $e = new class( ) {};
15
+
16
+ try {
17
+ } catch( Exception $e ) {
18
+ }
19
+
20
+ include( PATH . 'file.php' );
21
+
22
+ if ( in_array( $arg1, array( 'foo','bar' ) ) ) {}
23
+ isset( $abc );
24
+ unset( $abc );
25
+ empty( $abc );
26
+ eval( $abc );
27
+ exit( $abc );
28
+ clone( $_date1 <= $_date2 ? $_date1 : $_date2 );
29
+ declare( ticks=1 );
30
+ list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $q );
31
+ throw( $e );
32
+ yield from ( function(){} );
33
+
34
+ $obj->{$var}( $foo,$bar );
35
+
36
+ $bar(function( $a, $b ) {
37
+ return function( $c, $d ) use ( $a, $b ) {
38
+ echo $a, $b, $c, $d;
39
+ };
40
+ })( 'a','b' )( 'c','d' );
41
+
42
+ $closure( $foo,$bar );
43
+ $var = $closure() + $closure( $foo,$bar ) + self::$closure( $foo,$bar );
44
+
45
+ class Test {
46
+ public static function baz( $foo, $bar ) {
47
+ $a = new self( $foo,$bar );
48
+ $b = new static( $foo,$bar );
49
+ }
50
+ }
51
+
52
+ /*
53
+ * Test warning for empty parentheses.
54
+ */
55
+ $a = 4 + (); // Warning.
56
+ $a = 4 + ( ); // Warning.
57
+ $a = 4 + (/* Not empty */);
58
+
59
+ /*
60
+ * Test the actual sniff.
61
+ */
62
+ if ((null !== $extra) && ($row->extra !== $extra)) {}
63
+
64
+ if (( null !== $extra ) && ( $row->extra !== $extra )) {} // Bad x 4.
65
+
66
+ if (( null !== $extra // Bad x 1.
67
+ && is_int($extra))
68
+ && ( $row->extra !== $extra // Bad x 1.
69
+ || $something ) // Bad x 1.
70
+ ) {}
71
+
72
+ if (( null !== $extra ) // Bad x 2.
73
+ && ( $row->extra !== $extra ) // Bad x 2.
74
+ ) {}
75
+
76
+ $a = (null !== $extra);
77
+ $a = ( null !== $extra ); // Bad x 2.
78
+
79
+ $sx = $vert ? ($w - 1) : 0;
80
+
81
+ $this->is_overloaded = ( ( ini_get("mbstring.func_overload") & 2 ) != 0 ) && function_exists('mb_substr'); // Bad x 4.
82
+
83
+ $image->flip( ($operation->axis & 1) != 0, ($operation->axis & 2) != 0 );
84
+
85
+ if ( $success && ('nothumb' == $target || 'all' == $target) ) {}
86
+
87
+ $directory = ('/' == $file[ strlen($file)-1 ]);
88
+
89
+ // phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing spacing 1
90
+ if ((null !== $extra) && ($row->extra !== $extra)) {} // Bad x 4.
91
+
92
+ if (( null !== $extra ) && ( $row->extra !== $extra )) {}
93
+
94
+ if (( null !== $extra // Bad x 1.
95
+ && is_int($extra)) // Bad x 1.
96
+ && ( $row->extra !== $extra
97
+ || $something ) // Bad x 1.
98
+ ) {}
99
+
100
+ if ((null !== $extra) // Bad x 2.
101
+ && ($row->extra !== $extra) // Bad x 2.
102
+ ) {}
103
+
104
+ $a = (null !== $extra); // Bad x 2.
105
+ $a = ( null !== $extra );
106
+
107
+ $sx = $vert ? ($w - 1) : 0; // Bad x 2.
108
+
109
+ $this->is_overloaded = ((ini_get("mbstring.func_overload") & 2) != 0) && function_exists('mb_substr'); // Bad x 4.
110
+
111
+ $image->flip( ($operation->axis & 1) != 0, ($operation->axis & 2) != 0 ); // Bad x 4.
112
+
113
+ if ( $success && ('nothumb' == $target || 'all' == $target) ) {} // Bad x 2.
114
+
115
+ $directory = ('/' == $file[ strlen($file)-1 ]); // Bad x 2.
116
+
117
+ // phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing spacing 0
118
+
119
+ /*
120
+ * Test handling of ignoreNewlines.
121
+ */
122
+ if (
123
+ (
124
+ null !== $extra
125
+ ) && (
126
+ $row->extra !== $extra
127
+ )
128
+ ) {} // Bad x 4, 1 x line 123, 2 x line 125, 1 x line 127.
129
+
130
+
131
+ $a = (
132
+ null !== $extra
133
+ ); // Bad x 2, 1 x line 131, 1 x line 133.
134
+
135
+ // phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing spacing 1
136
+ if (
137
+ (
138
+ null !== $extra
139
+ ) && (
140
+ $row->extra !== $extra
141
+ )
142
+ ) {} // Bad x 4, 1 x line 137, 2 x line 139, 1 x line 141.
143
+
144
+ $a = (
145
+ null !== $extra
146
+ ); // Bad x 2, 1 x line 144, 1 x line 146.
147
+ // phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing spacing 0
148
+
149
+ // phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing ignoreNewlines true
150
+ if (
151
+ (
152
+ null !== $extra
153
+ ) && (
154
+ $row->extra !== $extra
155
+ )
156
+ ) {}
157
+
158
+ $a = (
159
+ null !== $extra
160
+ );
161
+ // phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing ignoreNewlines false
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.inc.fixed ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Make sure the sniff does not act on structures it shouldn't act on.
5
+ * All parentheses have extra spacing around it to test this properly.
6
+ */
7
+ $b = functioncall( $something ) ;
8
+ $b = function( $something ) {};
9
+ $c = myFunction( $arg1 , $arg2 = array( ) );
10
+
11
+ function something( $param ) {}
12
+
13
+ $d = new MyClass( );
14
+ $e = new class( ) {};
15
+
16
+ try {
17
+ } catch( Exception $e ) {
18
+ }
19
+
20
+ include( PATH . 'file.php' );
21
+
22
+ if ( in_array( $arg1, array( 'foo','bar' ) ) ) {}
23
+ isset( $abc );
24
+ unset( $abc );
25
+ empty( $abc );
26
+ eval( $abc );
27
+ exit( $abc );
28
+ clone( $_date1 <= $_date2 ? $_date1 : $_date2 );
29
+ declare( ticks=1 );
30
+ list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $q );
31
+ throw( $e );
32
+ yield from ( function(){} );
33
+
34
+ $obj->{$var}( $foo,$bar );
35
+
36
+ $bar(function( $a, $b ) {
37
+ return function( $c, $d ) use ( $a, $b ) {
38
+ echo $a, $b, $c, $d;
39
+ };
40
+ })( 'a','b' )( 'c','d' );
41
+
42
+ $closure( $foo,$bar );
43
+ $var = $closure() + $closure( $foo,$bar ) + self::$closure( $foo,$bar );
44
+
45
+ class Test {
46
+ public static function baz( $foo, $bar ) {
47
+ $a = new self( $foo,$bar );
48
+ $b = new static( $foo,$bar );
49
+ }
50
+ }
51
+
52
+ /*
53
+ * Test warning for empty parentheses.
54
+ */
55
+ $a = 4 + (); // Warning.
56
+ $a = 4 + ( ); // Warning.
57
+ $a = 4 + (/* Not empty */);
58
+
59
+ /*
60
+ * Test the actual sniff.
61
+ */
62
+ if ((null !== $extra) && ($row->extra !== $extra)) {}
63
+
64
+ if ((null !== $extra) && ($row->extra !== $extra)) {} // Bad x 4.
65
+
66
+ if ((null !== $extra // Bad x 1.
67
+ && is_int($extra))
68
+ && ($row->extra !== $extra // Bad x 1.
69
+ || $something) // Bad x 1.
70
+ ) {}
71
+
72
+ if ((null !== $extra) // Bad x 2.
73
+ && ($row->extra !== $extra) // Bad x 2.
74
+ ) {}
75
+
76
+ $a = (null !== $extra);
77
+ $a = (null !== $extra); // Bad x 2.
78
+
79
+ $sx = $vert ? ($w - 1) : 0;
80
+
81
+ $this->is_overloaded = ((ini_get("mbstring.func_overload") & 2) != 0) && function_exists('mb_substr'); // Bad x 4.
82
+
83
+ $image->flip( ($operation->axis & 1) != 0, ($operation->axis & 2) != 0 );
84
+
85
+ if ( $success && ('nothumb' == $target || 'all' == $target) ) {}
86
+
87
+ $directory = ('/' == $file[ strlen($file)-1 ]);
88
+
89
+ // phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing spacing 1
90
+ if (( null !== $extra ) && ( $row->extra !== $extra )) {} // Bad x 4.
91
+
92
+ if (( null !== $extra ) && ( $row->extra !== $extra )) {}
93
+
94
+ if (( null !== $extra // Bad x 1.
95
+ && is_int($extra) ) // Bad x 1.
96
+ && ( $row->extra !== $extra
97
+ || $something ) // Bad x 1.
98
+ ) {}
99
+
100
+ if (( null !== $extra ) // Bad x 2.
101
+ && ( $row->extra !== $extra ) // Bad x 2.
102
+ ) {}
103
+
104
+ $a = ( null !== $extra ); // Bad x 2.
105
+ $a = ( null !== $extra );
106
+
107
+ $sx = $vert ? ( $w - 1 ) : 0; // Bad x 2.
108
+
109
+ $this->is_overloaded = ( ( ini_get("mbstring.func_overload") & 2 ) != 0 ) && function_exists('mb_substr'); // Bad x 4.
110
+
111
+ $image->flip( ( $operation->axis & 1 ) != 0, ( $operation->axis & 2 ) != 0 ); // Bad x 4.
112
+
113
+ if ( $success && ( 'nothumb' == $target || 'all' == $target ) ) {} // Bad x 2.
114
+
115
+ $directory = ( '/' == $file[ strlen($file)-1 ] ); // Bad x 2.
116
+
117
+ // phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing spacing 0
118
+
119
+ /*
120
+ * Test handling of ignoreNewlines.
121
+ */
122
+ if (
123
+ (null !== $extra) && ($row->extra !== $extra)
124
+ ) {} // Bad x 4, 1 x line 123, 2 x line 125, 1 x line 127.
125
+
126
+
127
+ $a = (null !== $extra); // Bad x 2, 1 x line 131, 1 x line 133.
128
+
129
+ // phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing spacing 1
130
+ if (
131
+ ( null !== $extra ) && ( $row->extra !== $extra )
132
+ ) {} // Bad x 4, 1 x line 137, 2 x line 139, 1 x line 141.
133
+
134
+ $a = ( null !== $extra ); // Bad x 2, 1 x line 144, 1 x line 146.
135
+ // phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing spacing 0
136
+
137
+ // phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing ignoreNewlines true
138
+ if (
139
+ (
140
+ null !== $extra
141
+ ) && (
142
+ $row->extra !== $extra
143
+ )
144
+ ) {}
145
+
146
+ $a = (
147
+ null !== $extra
148
+ );
149
+ // phpcs:set Generic.WhiteSpace.ArbitraryParenthesesSpacing ignoreNewlines false
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ArbitraryParenthesesSpacingUnitTest.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Unit test class for the ArbitraryParenthesesSpacing sniff.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2017 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\Generic\Tests\WhiteSpace;
11
+
12
+ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
13
+
14
+ class ArbitraryParenthesesSpacingUnitTest extends AbstractSniffUnitTest
15
+ {
16
+
17
+
18
+ /**
19
+ * Returns the lines where errors should occur.
20
+ *
21
+ * The key of the array should represent the line number and the value
22
+ * should represent the number of errors that should occur on that line.
23
+ *
24
+ * @return array<int, int>
25
+ */
26
+ public function getErrorList()
27
+ {
28
+ return [
29
+ 64 => 4,
30
+ 66 => 1,
31
+ 68 => 1,
32
+ 69 => 1,
33
+ 72 => 2,
34
+ 73 => 2,
35
+ 77 => 2,
36
+ 81 => 4,
37
+ 90 => 4,
38
+ 94 => 1,
39
+ 95 => 1,
40
+ 97 => 1,
41
+ 100 => 2,
42
+ 101 => 2,
43
+ 104 => 2,
44
+ 107 => 2,
45
+ 109 => 4,
46
+ 111 => 4,
47
+ 113 => 2,
48
+ 115 => 2,
49
+ 123 => 1,
50
+ 125 => 2,
51
+ 127 => 1,
52
+ 131 => 1,
53
+ 133 => 1,
54
+ 137 => 1,
55
+ 139 => 2,
56
+ 141 => 1,
57
+ 144 => 1,
58
+ 146 => 1,
59
+ ];
60
+
61
+ }//end getErrorList()
62
+
63
+
64
+ /**
65
+ * Returns the lines where warnings should occur.
66
+ *
67
+ * The key of the array should represent the line number and the value
68
+ * should represent the number of warnings that should occur on that line.
69
+ *
70
+ * @return array<int, int>
71
+ */
72
+ public function getWarningList()
73
+ {
74
+ return [
75
+ 55 => 1,
76
+ 56 => 1,
77
+ ];
78
+
79
+ }//end getWarningList()
80
+
81
+
82
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.1.inc CHANGED
@@ -64,10 +64,10 @@ $x = 1;
64
 
65
  // Issue #1404
66
  // This is a line with mixed tabs and spaces.
67
- echo 'And here is another line with mixed tabs and spaces.'
68
- echo 'And another one.'
69
- echo 'And another one.'
70
- echo 'And another one.'
71
 
72
  // Spaces after comment.
73
 
64
 
65
  // Issue #1404
66
  // This is a line with mixed tabs and spaces.
67
+ echo 'And here is another line with mixed tabs and spaces.';
68
+ echo 'And another one.';
69
+ echo 'And another one.';
70
+ echo 'And another one.';
71
 
72
  // Spaces after comment.
73
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.1.inc.fixed CHANGED
@@ -64,10 +64,10 @@ $x = 1;
64
 
65
  // Issue #1404
66
  // This is a line with mixed tabs and spaces.
67
- echo 'And here is another line with mixed tabs and spaces.'
68
- echo 'And another one.'
69
- echo 'And another one.'
70
- echo 'And another one.'
71
 
72
  // Spaces after comment.
73
 
64
 
65
  // Issue #1404
66
  // This is a line with mixed tabs and spaces.
67
+ echo 'And here is another line with mixed tabs and spaces.';
68
+ echo 'And another one.';
69
+ echo 'And another one.';
70
+ echo 'And another one.';
71
 
72
  // Spaces after comment.
73
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.2.inc CHANGED
@@ -64,10 +64,10 @@ $x = 1;
64
 
65
  // Issue #1404
66
  // This is a line with mixed tabs and spaces.
67
- echo 'And here is another line with mixed tabs and spaces.'
68
- echo 'And another one.'
69
- echo 'And another one.'
70
- echo 'And another one.'
71
 
72
  // Spaces after comment.
73
 
64
 
65
  // Issue #1404
66
  // This is a line with mixed tabs and spaces.
67
+ echo 'And here is another line with mixed tabs and spaces.';
68
+ echo 'And another one.';
69
+ echo 'And another one.';
70
+ echo 'And another one.';
71
 
72
  // Spaces after comment.
73
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.2.inc.fixed CHANGED
@@ -64,10 +64,10 @@ $x = 1;
64
 
65
  // Issue #1404
66
  // This is a line with mixed tabs and spaces.
67
- echo 'And here is another line with mixed tabs and spaces.'
68
- echo 'And another one.'
69
- echo 'And another one.'
70
- echo 'And another one.'
71
 
72
  // Spaces after comment.
73
 
64
 
65
  // Issue #1404
66
  // This is a line with mixed tabs and spaces.
67
+ echo 'And here is another line with mixed tabs and spaces.';
68
+ echo 'And another one.';
69
+ echo 'And another one.';
70
+ echo 'And another one.';
71
 
72
  // Spaces after comment.
73
 
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.inc CHANGED
@@ -53,10 +53,10 @@ $var = "$hello $there";
53
  <?php
54
  // Issue #1404
55
  // This is a line with mixed tabs and spaces.
56
- echo 'And here is another line with mixed tabs and spaces.'
57
- echo 'And another one.'
58
- echo 'And another one.'
59
- echo 'And another one.'
60
 
61
  /**
62
  * This doc block should be fine and should be ignored for metrics.
53
  <?php
54
  // Issue #1404
55
  // This is a line with mixed tabs and spaces.
56
+ echo 'And here is another line with mixed tabs and spaces.';
57
+ echo 'And another one.';
58
+ echo 'And another one.';
59
+ echo 'And another one.';
60
 
61
  /**
62
  * This doc block should be fine and should be ignored for metrics.
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/DisallowTabIndentUnitTest.inc.fixed CHANGED
@@ -53,10 +53,10 @@ $var = "$hello $there";
53
  <?php
54
  // Issue #1404
55
  // This is a line with mixed tabs and spaces.
56
- echo 'And here is another line with mixed tabs and spaces.'
57
- echo 'And another one.'
58
- echo 'And another one.'
59
- echo 'And another one.'
60
 
61
  /**
62
  * This doc block should be fine and should be ignored for metrics.
53
  <?php
54
  // Issue #1404
55
  // This is a line with mixed tabs and spaces.
56
+ echo 'And here is another line with mixed tabs and spaces.';
57
+ echo 'And another one.';
58
+ echo 'And another one.';
59
+ echo 'And another one.';
60
 
61
  /**
62
  * This doc block should be fine and should be ignored for metrics.
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ echo $blah;
3
+ echo $blah;
4
+ echo($blah);
5
+
6
+ print $blah;
7
+ print $blah;
8
+ print($blah);
9
+
10
+ include $blah;
11
+ include $blah;
12
+ include($blah);
13
+
14
+ include_once $blah;
15
+ include_once $blah;
16
+ include_once($blah);
17
+
18
+ require $blah;
19
+ require $blah;
20
+ require($blah);
21
+
22
+ require_once $blah;
23
+ require_once $blah;
24
+ require_once($blah);
25
+
26
+ $obj = new MyClass();
27
+ $obj = new MyClass();
28
+
29
+ yield $blah;
30
+ yield $blah;
31
+
32
+ yield from $test();
33
+ yield FROM $test();
34
+ YIELD from $test();
35
+ yield from $test();
36
+ yield
37
+ from $test();
38
+ yield
39
+
40
+
41
+ From $test();
42
+
43
+ throw new Exception();
44
+ throw new Exception();
45
+ throw new Exception();
46
+ throw new Exception();
47
+
48
+ namespace MyClass;
49
+ namespace MyClass;
50
+ namespace MyNamespace\MyClass;
51
+ namespace MyNamespace\MyClass;
52
+ namespace \MyNamespace\MyClass;
53
+ namespace \MyNamespace\MyClass;
54
+
55
+ use MyClass;
56
+ use MyClass;
57
+ use MyNamespace\MyClass;
58
+ use MyNamespace\MyClass;
59
+ use \MyNamespace\MyClass;
60
+ use \MyNamespace\MyClass;
61
+
62
+ return;
63
+ return $blah;
64
+ return $blah;
65
+ return($blah);
66
+
67
+ return $tab;
68
+ return
69
+ $newLine;
70
+
71
+ // The following line must have a single space at the end (after return)
72
+ return
73
+ $spaceAndNewLine;
74
+
75
+ // The following line must be the last line in the file
76
+ return
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.inc.fixed ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ echo $blah;
3
+ echo $blah;
4
+ echo($blah);
5
+
6
+ print $blah;
7
+ print $blah;
8
+ print($blah);
9
+
10
+ include $blah;
11
+ include $blah;
12
+ include($blah);
13
+
14
+ include_once $blah;
15
+ include_once $blah;
16
+ include_once($blah);
17
+
18
+ require $blah;
19
+ require $blah;
20
+ require($blah);
21
+
22
+ require_once $blah;
23
+ require_once $blah;
24
+ require_once($blah);
25
+
26
+ $obj = new MyClass();
27
+ $obj = new MyClass();
28
+
29
+ yield $blah;
30
+ yield $blah;
31
+
32
+ yield from $test();
33
+ yield FROM $test();
34
+ YIELD from $test();
35
+ yield from $test();
36
+ yield from $test();
37
+ yield From $test();
38
+
39
+ throw new Exception();
40
+ throw new Exception();
41
+ throw new Exception();
42
+ throw new Exception();
43
+
44
+ namespace MyClass;
45
+ namespace MyClass;
46
+ namespace MyNamespace\MyClass;
47
+ namespace MyNamespace\MyClass;
48
+ namespace \MyNamespace\MyClass;
49
+ namespace \MyNamespace\MyClass;
50
+
51
+ use MyClass;
52
+ use MyClass;
53
+ use MyNamespace\MyClass;
54
+ use MyNamespace\MyClass;
55
+ use \MyNamespace\MyClass;
56
+ use \MyNamespace\MyClass;
57
+
58
+ return;
59
+ return $blah;
60
+ return $blah;
61
+ return($blah);
62
+
63
+ return $tab;
64
+ return $newLine;
65
+
66
+ // The following line must have a single space at the end (after return)
67
+ return $spaceAndNewLine;
68
+
69
+ // The following line must be the last line in the file
70
+ return
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/LanguageConstructSpacingUnitTest.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Unit test class for the LanguageConstructSpacing sniff.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2017 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\Generic\Tests\WhiteSpace;
11
+
12
+ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
13
+
14
+ class LanguageConstructSpacingUnitTest extends AbstractSniffUnitTest
15
+ {
16
+
17
+
18
+ /**
19
+ * Returns the lines where errors should occur.
20
+ *
21
+ * The key of the array should represent the line number and the value
22
+ * should represent the number of errors that should occur on that line.
23
+ *
24
+ * @return array<int, int>
25
+ */
26
+ public function getErrorList()
27
+ {
28
+ return [
29
+ 3 => 1,
30
+ 7 => 1,
31
+ 11 => 1,
32
+ 15 => 1,
33
+ 19 => 1,
34
+ 23 => 1,
35
+ 27 => 1,
36
+ 30 => 1,
37
+ 33 => 1,
38
+ 34 => 1,
39
+ 35 => 1,
40
+ 36 => 1,
41
+ 38 => 1,
42
+ 44 => 1,
43
+ 45 => 1,
44
+ 46 => 2,
45
+ 49 => 1,
46
+ 51 => 1,
47
+ 53 => 1,
48
+ 56 => 1,
49
+ 58 => 1,
50
+ 60 => 1,
51
+ 64 => 1,
52
+ 67 => 1,
53
+ 68 => 1,
54
+ 72 => 1,
55
+ ];
56
+
57
+ }//end getErrorList()
58
+
59
+
60
+ /**
61
+ * Returns the lines where warnings should occur.
62
+ *
63
+ * The key of the array should represent the line number and the value
64
+ * should represent the number of warnings that should occur on that line.
65
+ *
66
+ * @return array<int, int>
67
+ */
68
+ public function getWarningList()
69
+ {
70
+ return [];
71
+
72
+ }//end getWarningList()
73
+
74
+
75
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc CHANGED
@@ -181,7 +181,7 @@ abstract class Test3
181
  }
182
  }
183
 
184
- public function test()
185
  {
186
  $o = <<<EOF
187
  this is some text
@@ -396,7 +396,7 @@ $myFunction = function() {
396
  if ($a === 404) {
397
  $a = 403;
398
  }
399
- }
400
 
401
  class Whatever
402
  {
@@ -626,7 +626,7 @@ $var = call_user_func(
626
  } else {
627
  return $a--;
628
  }
629
- }
630
  }
631
  }
632
  );
@@ -636,7 +636,7 @@ a(
636
  $a = function() {
637
  $b = false;
638
  };
639
- true
640
  }
641
  );
642
 
@@ -999,7 +999,7 @@ try {
999
  } catch (\Exception $e) {
1000
  $foo = function() {
1001
  return 'foo';
1002
- }
1003
 
1004
  if (true) {
1005
  }
@@ -1007,17 +1007,17 @@ try {
1007
 
1008
  if ($foo) {
1009
  foo();
1010
- } else if (\Exception $e) {
1011
  $foo = function() {
1012
  return 'foo';
1013
- }
1014
 
1015
  if (true) {
1016
  }
1017
  } else {
1018
  $foo = function() {
1019
  return 'foo';
1020
- }
1021
 
1022
  if (true) {
1023
  }
@@ -1070,7 +1070,7 @@ class Test123
1070
  ],
1071
  $prop2 = [
1072
  'testB' => 456,
1073
- ],
1074
 
1075
  protected static
1076
  $prop3 = array(
@@ -1078,7 +1078,7 @@ class Test123
1078
  ),
1079
  $prop4 = array(
1080
  'testB' => 456,
1081
- ),
1082
 
1083
  protected static $prop5;
1084
  }
@@ -1184,7 +1184,7 @@ function test()
1184
 
1185
  switch ($a) {
1186
  case 0:
1187
- function () {
1188
  };
1189
  case 1:
1190
  break;
@@ -1238,13 +1238,13 @@ array_map(
1238
  /**
1239
  * Comment.
1240
  */
1241
- (function () use ($app) {
1242
  echo 'hi';
1243
  })();
1244
 
1245
  $app->run();
1246
 
1247
- public function foo()
1248
  {
1249
  $foo('some
1250
  long description', function () {
@@ -1260,6 +1260,49 @@ public function foo()
1260
  });
1261
  }
1262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1263
  function foo()
1264
  {
1265
  $foo = array(
181
  }
182
  }
183
 
184
+ function test()
185
  {
186
  $o = <<<EOF
187
  this is some text
396
  if ($a === 404) {
397
  $a = 403;
398
  }
399
+ };
400
 
401
  class Whatever
402
  {
626
  } else {
627
  return $a--;
628
  }
629
+ };
630
  }
631
  }
632
  );
636
  $a = function() {
637
  $b = false;
638
  };
639
+ true;
640
  }
641
  );
642
 
999
  } catch (\Exception $e) {
1000
  $foo = function() {
1001
  return 'foo';
1002
+ };
1003
 
1004
  if (true) {
1005
  }
1007
 
1008
  if ($foo) {
1009
  foo();
1010
+ } else if ($e) {
1011
  $foo = function() {
1012
  return 'foo';
1013
+ };
1014
 
1015
  if (true) {
1016
  }
1017
  } else {
1018
  $foo = function() {
1019
  return 'foo';
1020
+ };
1021
 
1022
  if (true) {
1023
  }
1070
  ],
1071
  $prop2 = [
1072
  'testB' => 456,
1073
+ ];
1074
 
1075
  protected static
1076
  $prop3 = array(
1078
  ),
1079
  $prop4 = array(
1080
  'testB' => 456,
1081
+ );
1082
 
1083
  protected static $prop5;
1084
  }
1184
 
1185
  switch ($a) {
1186
  case 0:
1187
+ $a = function () {
1188
  };
1189
  case 1:
1190
  break;
1238
  /**
1239
  * Comment.
1240
  */
1241
+ $a(function () use ($app) {
1242
  echo 'hi';
1243
  })();
1244
 
1245
  $app->run();
1246
 
1247
+ function foo()
1248
  {
1249
  $foo('some
1250
  long description', function () {
1260
  });
1261
  }
1262
 
1263
+ switch ( $a ) {
1264
+ case 'a':
1265
+ $b = 2;
1266
+ /**
1267
+ * A comment.
1268
+ */
1269
+ apply_filter( 'something', $b );
1270
+ break;
1271
+
1272
+ case 'aa':
1273
+ $b = 2;
1274
+ /*
1275
+ * A comment.
1276
+ */
1277
+ apply_filter( 'something', $b );
1278
+ break;
1279
+
1280
+ case 'b':
1281
+ $b = 3;
1282
+ ?>
1283
+ <input name="something" value="<?php echo $b; ?>">
1284
+ <?php
1285
+ $b = 4;
1286
+ break;
1287
+
1288
+ default:
1289
+ $b = 3;
1290
+ ?>
1291
+ <input name="something" value="<?php echo $b; ?>">
1292
+ <?php
1293
+ $b = 4;
1294
+ break;
1295
+ }
1296
+
1297
+ if ($foo) {
1298
+ if ($oo) {
1299
+ /*
1300
+ *
1301
+ *
1302
+ */
1303
+ }
1304
+ }
1305
+
1306
  function foo()
1307
  {
1308
  $foo = array(
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.1.inc.fixed CHANGED
@@ -181,7 +181,7 @@ abstract class Test3
181
  }
182
  }
183
 
184
- public function test()
185
  {
186
  $o = <<<EOF
187
  this is some text
@@ -396,7 +396,7 @@ $myFunction = function() {
396
  if ($a === 404) {
397
  $a = 403;
398
  }
399
- }
400
 
401
  class Whatever
402
  {
@@ -626,7 +626,7 @@ $var = call_user_func(
626
  } else {
627
  return $a--;
628
  }
629
- }
630
  }
631
  }
632
  );
@@ -636,7 +636,7 @@ a(
636
  $a = function() {
637
  $b = false;
638
  };
639
- true
640
  }
641
  );
642
 
@@ -999,7 +999,7 @@ try {
999
  } catch (\Exception $e) {
1000
  $foo = function() {
1001
  return 'foo';
1002
- }
1003
 
1004
  if (true) {
1005
  }
@@ -1007,17 +1007,17 @@ try {
1007
 
1008
  if ($foo) {
1009
  foo();
1010
- } else if (\Exception $e) {
1011
  $foo = function() {
1012
  return 'foo';
1013
- }
1014
 
1015
  if (true) {
1016
  }
1017
  } else {
1018
  $foo = function() {
1019
  return 'foo';
1020
- }
1021
 
1022
  if (true) {
1023
  }
@@ -1070,7 +1070,7 @@ class Test123
1070
  ],
1071
  $prop2 = [
1072
  'testB' => 456,
1073
- ],
1074
 
1075
  protected static
1076
  $prop3 = array(
@@ -1078,7 +1078,7 @@ class Test123
1078
  ),
1079
  $prop4 = array(
1080
  'testB' => 456,
1081
- ),
1082
 
1083
  protected static $prop5;
1084
  }
@@ -1184,7 +1184,7 @@ function test()
1184
 
1185
  switch ($a) {
1186
  case 0:
1187
- function () {
1188
  };
1189
  case 1:
1190
  break;
@@ -1238,13 +1238,13 @@ array_map(
1238
  /**
1239
  * Comment.
1240
  */
1241
- (function () use ($app) {
1242
  echo 'hi';
1243
  })();
1244
 
1245
  $app->run();
1246
 
1247
- public function foo()
1248
  {
1249
  $foo('some
1250
  long description', function () {
@@ -1260,6 +1260,49 @@ public function foo()
1260
  });
1261
  }
1262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1263
  function foo()
1264
  {
1265
  $foo = array(
181
  }
182
  }
183
 
184
+ function test()
185
  {
186
  $o = <<<EOF
187
  this is some text
396
  if ($a === 404) {
397
  $a = 403;
398
  }
399
+ };
400
 
401
  class Whatever
402
  {
626
  } else {
627
  return $a--;
628
  }
629
+ };
630
  }
631
  }
632
  );
636
  $a = function() {
637
  $b = false;
638
  };
639
+ true;
640
  }
641
  );
642
 
999
  } catch (\Exception $e) {
1000
  $foo = function() {
1001
  return 'foo';
1002
+ };
1003
 
1004
  if (true) {
1005
  }
1007
 
1008
  if ($foo) {
1009
  foo();
1010
+ } else if ($e) {
1011
  $foo = function() {
1012
  return 'foo';
1013
+ };
1014
 
1015
  if (true) {
1016
  }
1017
  } else {
1018
  $foo = function() {
1019
  return 'foo';
1020
+ };
1021
 
1022
  if (true) {
1023
  }
1070
  ],
1071
  $prop2 = [
1072
  'testB' => 456,
1073
+ ];
1074
 
1075
  protected static
1076
  $prop3 = array(
1078
  ),
1079
  $prop4 = array(
1080
  'testB' => 456,
1081
+ );
1082
 
1083
  protected static $prop5;
1084
  }
1184
 
1185
  switch ($a) {
1186
  case 0:
1187
+ $a = function () {
1188
  };
1189
  case 1:
1190
  break;
1238
  /**
1239
  * Comment.
1240
  */
1241
+ $a(function () use ($app) {
1242
  echo 'hi';
1243
  })();
1244
 
1245
  $app->run();
1246
 
1247
+ function foo()
1248
  {
1249
  $foo('some
1250
  long description', function () {
1260
  });
1261
  }
1262
 
1263
+ switch ( $a ) {
1264
+ case 'a':
1265
+ $b = 2;
1266
+ /**
1267
+ * A comment.
1268
+ */
1269
+ apply_filter( 'something', $b );
1270
+ break;
1271
+
1272
+ case 'aa':
1273
+ $b = 2;
1274
+ /*
1275
+ * A comment.
1276
+ */
1277
+ apply_filter( 'something', $b );
1278
+ break;
1279
+
1280
+ case 'b':
1281
+ $b = 3;
1282
+ ?>
1283
+ <input name="something" value="<?php echo $b; ?>">
1284
+ <?php
1285
+ $b = 4;
1286
+ break;
1287
+
1288
+ default:
1289
+ $b = 3;
1290
+ ?>
1291
+ <input name="something" value="<?php echo $b; ?>">
1292
+ <?php
1293
+ $b = 4;
1294
+ break;
1295
+ }
1296
+
1297
+ if ($foo) {
1298
+ if ($oo) {
1299
+ /*
1300
+ *
1301
+ *
1302
+ */
1303
+ }
1304
+ }
1305
+
1306
  function foo()
1307
  {
1308
  $foo = array(
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc CHANGED
@@ -181,7 +181,7 @@ abstract class Test3
181
  }
182
  }
183
 
184
- public function test()
185
  {
186
  $o = <<<EOF
187
  this is some text
@@ -396,7 +396,7 @@ $myFunction = function() {
396
  if ($a === 404) {
397
  $a = 403;
398
  }
399
- }
400
 
401
  class Whatever
402
  {
@@ -626,7 +626,7 @@ $var = call_user_func(
626
  } else {
627
  return $a--;
628
  }
629
- }
630
  }
631
  }
632
  );
@@ -636,7 +636,7 @@ a(
636
  $a = function() {
637
  $b = false;
638
  };
639
- true
640
  }
641
  );
642
 
@@ -999,7 +999,7 @@ try {
999
  } catch (\Exception $e) {
1000
  $foo = function() {
1001
  return 'foo';
1002
- }
1003
 
1004
  if (true) {
1005
  }
@@ -1007,17 +1007,17 @@ try {
1007
 
1008
  if ($foo) {
1009
  foo();
1010
- } else if (\Exception $e) {
1011
  $foo = function() {
1012
  return 'foo';
1013
- }
1014
 
1015
  if (true) {
1016
  }
1017
  } else {
1018
  $foo = function() {
1019
  return 'foo';
1020
- }
1021
 
1022
  if (true) {
1023
  }
@@ -1070,7 +1070,7 @@ class Test123
1070
  ],
1071
  $prop2 = [
1072
  'testB' => 456,
1073
- ],
1074
 
1075
  protected static
1076
  $prop3 = array(
@@ -1078,7 +1078,7 @@ class Test123
1078
  ),
1079
  $prop4 = array(
1080
  'testB' => 456,
1081
- ),
1082
 
1083
  protected static $prop5;
1084
  }
@@ -1184,7 +1184,7 @@ function test()
1184
 
1185
  switch ($a) {
1186
  case 0:
1187
- function () {
1188
  };
1189
  case 1:
1190
  break;
@@ -1238,13 +1238,13 @@ array_map(
1238
  /**
1239
  * Comment.
1240
  */
1241
- (function () use ($app) {
1242
  echo 'hi';
1243
  })();
1244
 
1245
  $app->run();
1246
 
1247
- public function foo()
1248
  {
1249
  $foo('some
1250
  long description', function () {
@@ -1260,6 +1260,49 @@ public function foo()
1260
  });
1261
  }
1262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1263
  function foo()
1264
  {
1265
  $foo = array(
181
  }
182
  }
183
 
184
+ function test()
185
  {
186
  $o = <<<EOF
187
  this is some text
396
  if ($a === 404) {
397
  $a = 403;
398
  }
399
+ };
400
 
401
  class Whatever
402
  {
626
  } else {
627
  return $a--;
628
  }
629
+ };
630
  }
631
  }
632
  );
636
  $a = function() {
637
  $b = false;
638
  };
639
+ true;
640
  }
641
  );
642
 
999
  } catch (\Exception $e) {
1000
  $foo = function() {
1001
  return 'foo';
1002
+ };
1003
 
1004
  if (true) {
1005
  }
1007
 
1008
  if ($foo) {
1009
  foo();
1010
+ } else if ($e) {
1011
  $foo = function() {
1012
  return 'foo';
1013
+ };
1014
 
1015
  if (true) {
1016
  }
1017
  } else {
1018
  $foo = function() {
1019
  return 'foo';
1020
+ };
1021
 
1022
  if (true) {
1023
  }
1070
  ],
1071
  $prop2 = [
1072
  'testB' => 456,
1073
+ ];
1074
 
1075
  protected static
1076
  $prop3 = array(
1078
  ),
1079
  $prop4 = array(
1080
  'testB' => 456,
1081
+ );
1082
 
1083
  protected static $prop5;
1084
  }
1184
 
1185
  switch ($a) {
1186
  case 0:
1187
+ $a = function () {
1188
  };
1189
  case 1:
1190
  break;
1238
  /**
1239
  * Comment.
1240
  */
1241
+ $a(function () use ($app) {
1242
  echo 'hi';
1243
  })();
1244
 
1245
  $app->run();
1246
 
1247
+ function foo()
1248
  {
1249
  $foo('some
1250
  long description', function () {
1260
  });
1261
  }
1262
 
1263
+ switch ( $a ) {
1264
+ case 'a':
1265
+ $b = 2;
1266
+ /**
1267
+ * A comment.
1268
+ */
1269
+ apply_filter( 'something', $b );
1270
+ break;
1271
+
1272
+ case 'aa':
1273
+ $b = 2;
1274
+ /*
1275
+ * A comment.
1276
+ */
1277
+ apply_filter( 'something', $b );
1278
+ break;
1279
+
1280
+ case 'b':
1281
+ $b = 3;
1282
+ ?>
1283
+ <input name="something" value="<?php echo $b; ?>">
1284
+ <?php
1285
+ $b = 4;
1286
+ break;
1287
+
1288
+ default:
1289
+ $b = 3;
1290
+ ?>
1291
+ <input name="something" value="<?php echo $b; ?>">
1292
+ <?php
1293
+ $b = 4;
1294
+ break;
1295
+ }
1296
+
1297
+ if ($foo) {
1298
+ if ($oo) {
1299
+ /*
1300
+ *
1301
+ *
1302
+ */
1303
+ }
1304
+ }
1305
+
1306
  function foo()
1307
  {
1308
  $foo = array(
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.2.inc.fixed CHANGED
@@ -181,7 +181,7 @@ abstract class Test3
181
  }
182
  }
183
 
184
- public function test()
185
  {
186
  $o = <<<EOF
187
  this is some text
@@ -396,7 +396,7 @@ $myFunction = function() {
396
  if ($a === 404) {
397
  $a = 403;
398
  }
399
- }
400
 
401
  class Whatever
402
  {
@@ -626,7 +626,7 @@ $var = call_user_func(
626
  } else {
627
  return $a--;
628
  }
629
- }
630
  }
631
  }
632
  );
@@ -636,7 +636,7 @@ a(
636
  $a = function() {
637
  $b = false;
638
  };
639
- true
640
  }
641
  );
642
 
@@ -999,7 +999,7 @@ try {
999
  } catch (\Exception $e) {
1000
  $foo = function() {
1001
  return 'foo';
1002
- }
1003
 
1004
  if (true) {
1005
  }
@@ -1007,17 +1007,17 @@ try {
1007
 
1008
  if ($foo) {
1009
  foo();
1010
- } else if (\Exception $e) {
1011
  $foo = function() {
1012
  return 'foo';
1013
- }
1014
 
1015
  if (true) {
1016
  }
1017
  } else {
1018
  $foo = function() {
1019
  return 'foo';
1020
- }
1021
 
1022
  if (true) {
1023
  }
@@ -1070,7 +1070,7 @@ class Test123
1070
  ],
1071
  $prop2 = [
1072
  'testB' => 456,
1073
- ],
1074
 
1075
  protected static
1076
  $prop3 = array(
@@ -1078,7 +1078,7 @@ class Test123
1078
  ),
1079
  $prop4 = array(
1080
  'testB' => 456,
1081
- ),
1082
 
1083
  protected static $prop5;
1084
  }
@@ -1184,7 +1184,7 @@ function test()
1184
 
1185
  switch ($a) {
1186
  case 0:
1187
- function () {
1188
  };
1189
  case 1:
1190
  break;
@@ -1238,13 +1238,13 @@ array_map(
1238
  /**
1239
  * Comment.
1240
  */
1241
- (function () use ($app) {
1242
  echo 'hi';
1243
  })();
1244
 
1245
  $app->run();
1246
 
1247
- public function foo()
1248
  {
1249
  $foo('some
1250
  long description', function () {
@@ -1260,6 +1260,49 @@ public function foo()
1260
  });
1261
  }
1262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1263
  function foo()
1264
  {
1265
  $foo = array(
181
  }
182
  }
183
 
184
+ function test()
185
  {
186
  $o = <<<EOF
187
  this is some text
396
  if ($a === 404) {
397
  $a = 403;
398
  }
399
+ };
400
 
401
  class Whatever
402
  {
626
  } else {
627
  return $a--;
628
  }
629
+ };
630
  }
631
  }
632
  );
636
  $a = function() {
637
  $b = false;
638
  };
639
+ true;
640
  }
641
  );
642
 
999
  } catch (\Exception $e) {
1000
  $foo = function() {
1001
  return 'foo';
1002
+ };
1003
 
1004
  if (true) {
1005
  }
1007
 
1008
  if ($foo) {
1009
  foo();
1010
+ } else if ($e) {
1011
  $foo = function() {
1012
  return 'foo';
1013
+ };
1014
 
1015
  if (true) {
1016
  }
1017
  } else {
1018
  $foo = function() {
1019
  return 'foo';
1020
+ };
1021
 
1022
  if (true) {
1023
  }
1070
  ],
1071
  $prop2 = [
1072
  'testB' => 456,
1073
+ ];
1074
 
1075
  protected static
1076
  $prop3 = array(
1078
  ),
1079
  $prop4 = array(
1080
  'testB' => 456,
1081
+ );
1082
 
1083
  protected static $prop5;
1084
  }
1184
 
1185
  switch ($a) {
1186
  case 0:
1187
+ $a = function () {
1188
  };
1189
  case 1:
1190
  break;
1238
  /**
1239
  * Comment.
1240
  */
1241
+ $a(function () use ($app) {
1242
  echo 'hi';
1243
  })();
1244
 
1245
  $app->run();
1246
 
1247
+ function foo()
1248
  {
1249
  $foo('some
1250
  long description', function () {
1260
  });
1261
  }
1262
 
1263
+ switch ( $a ) {
1264
+ case 'a':
1265
+ $b = 2;
1266
+ /**
1267
+ * A comment.
1268
+ */
1269
+ apply_filter( 'something', $b );
1270
+ break;
1271
+
1272
+ case 'aa':
1273
+ $b = 2;
1274
+ /*
1275
+ * A comment.
1276
+ */
1277
+ apply_filter( 'something', $b );
1278
+ break;
1279
+
1280
+ case 'b':
1281
+ $b = 3;
1282
+ ?>
1283
+ <input name="something" value="<?php echo $b; ?>">
1284
+ <?php
1285
+ $b = 4;
1286
+ break;
1287
+
1288
+ default:
1289
+ $b = 3;
1290
+ ?>
1291
+ <input name="something" value="<?php echo $b; ?>">
1292
+ <?php
1293
+ $b = 4;
1294
+ break;
1295
+ }
1296
+
1297
+ if ($foo) {
1298
+ if ($oo) {
1299
+ /*
1300
+ *
1301
+ *
1302
+ */
1303
+ }
1304
+ }
1305
+
1306
  function foo()
1307
  {
1308
  $foo = array(
vendor/squizlabs/php_codesniffer/src/Standards/Generic/Tests/WhiteSpace/ScopeIndentUnitTest.php CHANGED
@@ -142,14 +142,40 @@ class ScopeIndentUnitTest extends AbstractSniffUnitTest
142
  1197 => 1,
143
  1198 => 1,
144
  1259 => 1,
145
- 1263 => 1,
146
- 1268 => 1,
147
- 1270 => 1,
 
 
148
  1273 => 1,
 
 
 
149
  1277 => 1,
150
- 1278 => 1,
151
- 1279 => 1,
152
  1280 => 1,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  ];
154
 
155
  }//end getErrorList()
142
  1197 => 1,
143
  1198 => 1,
144
  1259 => 1,
145
+ 1264 => 1,
146
+ 1265 => 1,
147
+ 1266 => 1,
148
+ 1269 => 1,
149
+ 1272 => 1,
150
  1273 => 1,
151
+ 1274 => 1,
152
+ 1275 => 1,
153
+ 1276 => 1,
154
  1277 => 1,
 
 
155
  1280 => 1,
156
+ 1281 => 1,
157
+ 1282 => 1,
158
+ 1284 => 1,
159
+ 1285 => 1,
160
+ 1288 => 1,
161
+ 1289 => 1,
162
+ 1290 => 1,
163
+ 1292 => 1,
164
+ 1293 => 1,
165
+ 1298 => 1,
166
+ 1299 => 1,
167
+ 1300 => 1,
168
+ 1301 => 1,
169
+ 1302 => 1,
170
+ 1303 => 1,
171
+ 1306 => 1,
172
+ 1311 => 1,
173
+ 1313 => 1,
174
+ 1316 => 1,
175
+ 1320 => 1,
176
+ 1321 => 1,
177
+ 1322 => 1,
178
+ 1323 => 1,
179
  ];
180
 
181
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php CHANGED
@@ -43,8 +43,6 @@ class ClassCommentSniff extends FileCommentSniff
43
  */
44
  public function process(File $phpcsFile, $stackPtr)
45
  {
46
- $this->currentFile = $phpcsFile;
47
-
48
  $tokens = $phpcsFile->getTokens();
49
  $type = strtolower($tokens[$stackPtr]['content']);
50
  $errorData = [$type];
43
  */
44
  public function process(File $phpcsFile, $stackPtr)
45
  {
 
 
46
  $tokens = $phpcsFile->getTokens();
47
  $type = strtolower($tokens[$stackPtr]['content']);
48
  $errorData = [$type];
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php CHANGED
@@ -431,7 +431,14 @@ class FunctionCommentSniff implements Sniff
431
  $expected,
432
  $found,
433
  ];
434
- $fix = $phpcsFile->addFixableError($error, $commentToken, 'ParamCommentAlignment', $data);
 
 
 
 
 
 
 
435
  if ($fix === true) {
436
  $padding = str_repeat(' ', $expected);
437
  if ($tokens[($commentToken - 1)]['code'] === T_DOC_COMMENT_WHITESPACE) {
431
  $expected,
432
  $found,
433
  ];
434
+
435
+ if ($found < $expected) {
436
+ $code = 'ParamCommentAlignment';
437
+ } else {
438
+ $code = 'ParamCommentAlignmentExceeded';
439
+ }
440
+
441
+ $fix = $phpcsFile->addFixableError($error, $commentToken, $code, $data);
442
  if ($fix === true) {
443
  $padding = str_repeat(' ', $expected);
444
  if ($tokens[($commentToken - 1)]['code'] === T_DOC_COMMENT_WHITESPACE) {
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php CHANGED
@@ -11,7 +11,6 @@ namespace PHP_CodeSniffer\Standards\PEAR\Sniffs\Functions;
11
 
12
  use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
14
- use PHP_CodeSniffer\Util\Tokens;
15
 
16
  class ValidDefaultValueSniff implements Sniff
17
  {
11
 
12
  use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
 
14
 
15
  class ValidDefaultValueSniff implements Sniff
16
  {
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php CHANGED
@@ -232,6 +232,7 @@ class ValidFunctionNameSniff extends AbstractScopeSniff
232
  if ($packagePart !== '') {
233
  // Check that each new word starts with a capital.
234
  $nameBits = explode('_', $packagePart);
 
235
  foreach ($nameBits as $bit) {
236
  if ($bit{0} !== strtoupper($bit{0})) {
237
  $newPackagePart = '';
232
  if ($packagePart !== '') {
233
  // Check that each new word starts with a capital.
234
  $nameBits = explode('_', $packagePart);
235
+ $nameBits = array_filter($nameBits);
236
  foreach ($nameBits as $bit) {
237
  if ($bit{0} !== strtoupper($bit{0})) {
238
  $newPackagePart = '';
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php CHANGED
@@ -49,29 +49,23 @@ class ObjectOperatorIndentSniff implements Sniff
49
  $tokens = $phpcsFile->getTokens();
50
 
51
  // Make sure this is the first object operator in a chain of them.
52
- $varToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
53
- if ($varToken === false || $tokens[$varToken]['code'] !== T_VARIABLE) {
 
54
  return;
55
  }
56
 
57
  // Make sure this is a chained call.
58
- $next = $phpcsFile->findNext(
59
- T_OBJECT_OPERATOR,
60
- ($stackPtr + 1),
61
- null,
62
- false,
63
- null,
64
- true
65
- );
66
-
67
  if ($next === false) {
68
  // Not a chained call.
69
  return;
70
  }
71
 
72
  // Determine correct indent.
73
- for ($i = ($varToken - 1); $i >= 0; $i--) {
74
- if ($tokens[$i]['line'] !== $tokens[$varToken]['line']) {
75
  $i++;
76
  break;
77
  }
@@ -98,7 +92,7 @@ class ObjectOperatorIndentSniff implements Sniff
98
  // Check indentation of each object operator in the chain.
99
  // If the first object operator is on a different line than
100
  // the variable, make sure we check its indentation too.
101
- if ($tokens[$stackPtr]['line'] > $tokens[$varToken]['line']) {
102
  $next = $stackPtr;
103
  }
104
 
49
  $tokens = $phpcsFile->getTokens();
50
 
51
  // Make sure this is the first object operator in a chain of them.
52
+ $start = $phpcsFile->findStartOfStatement($stackPtr);
53
+ $prev = $phpcsFile->findPrevious(T_OBJECT_OPERATOR, ($stackPtr - 1), $start);
54
+ if ($prev !== false) {
55
  return;
56
  }
57
 
58
  // Make sure this is a chained call.
59
+ $end = $phpcsFile->findEndOfStatement($stackPtr);
60
+ $next = $phpcsFile->findNext(T_OBJECT_OPERATOR, ($stackPtr + 1), $end);
 
 
 
 
 
 
 
61
  if ($next === false) {
62
  // Not a chained call.
63
  return;
64
  }
65
 
66
  // Determine correct indent.
67
+ for ($i = ($start - 1); $i >= 0; $i--) {
68
+ if ($tokens[$i]['line'] !== $tokens[$start]['line']) {
69
  $i++;
70
  break;
71
  }
92
  // Check indentation of each object operator in the chain.
93
  // If the first object operator is on a different line than
94
  // the variable, make sure we check its indentation too.
95
+ if ($tokens[$stackPtr]['line'] > $tokens[$start]['line']) {
96
  $next = $stackPtr;
97
  }
98
 
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc CHANGED
@@ -157,7 +157,7 @@ class PHP_CodeSniffer_File
157
  *
158
  * @return void
159
  */
160
- public function functionOutsideClass(&$str, &$foo)
161
  {
162
  return;
163
  }//end functionOutsideClass()
@@ -181,7 +181,7 @@ function tagBeforeComment()
181
  *
182
  *
183
  */
184
- public function noReturnOutsideClass()
185
  {
186
 
187
  }//end noReturnOutsideClass()
@@ -195,7 +195,7 @@ public function noReturnOutsideClass()
195
  * @return void
196
  * @fine Unknown tag
197
  */
198
- public function missingTwoParamComment($one, $two, $three)
199
  {
200
 
201
  }//end missingTwoParamComment()
@@ -243,13 +243,13 @@ function myFunction($arg1) {}
243
  */
244
  function myFunction() {}
245
 
246
- class MyClass() {
247
  /**
248
  * An abstract function.
249
  *
250
  * @return string[]
251
  */
252
- abstract final protected function myFunction();
253
  }
254
 
255
  /**
@@ -261,7 +261,7 @@ class MyClass() {
261
  *
262
  * @return void
263
  */
264
- public function foo(&$tokens, $tokenizer, $eolChar)
265
  {
266
 
267
  }//end foo()
@@ -270,7 +270,7 @@ public function foo(&$tokens, $tokenizer, $eolChar)
270
  * Gettext.
271
  *
272
  */
273
- public function _() {
274
  return $foo;
275
  }
276
 
@@ -294,7 +294,7 @@ class Baz {
294
  *
295
  * @return void
296
  */
297
- public function completeStep($status, array $array = [Class1::class, 'test'], $note = '') {
298
  echo 'foo';
299
  }
300
 
@@ -306,7 +306,7 @@ public function completeStep($status, array $array = [Class1::class, 'test'], $n
306
  *
307
  * @return void
308
  */
309
- public function myFunction(string $name1, string ...$name2) {
310
  }
311
 
312
 
@@ -318,7 +318,7 @@ public function myFunction(string $name1, string ...$name2) {
318
  *
319
  * @return void
320
  */
321
- public function myFunction(string $name1, string ...$name2) {
322
  }
323
 
324
  /**
157
  *
158
  * @return void
159
  */
160
+ function functionOutsideClass(&$str, &$foo)
161
  {
162
  return;
163
  }//end functionOutsideClass()
181
  *
182
  *
183
  */
184
+ function noReturnOutsideClass()
185
  {
186
 
187
  }//end noReturnOutsideClass()
195
  * @return void
196
  * @fine Unknown tag
197
  */
198
+ function missingTwoParamComment($one, $two, $three)
199
  {
200
 
201
  }//end missingTwoParamComment()
243
  */
244
  function myFunction() {}
245
 
246
+ abstract class MyClass {
247
  /**
248
  * An abstract function.
249
  *
250
  * @return string[]
251
  */
252
+ abstract protected function myFunction();
253
  }
254
 
255
  /**
261
  *
262
  * @return void
263
  */
264
+ function foo(&$tokens, $tokenizer, $eolChar)
265
  {
266
 
267
  }//end foo()
270
  * Gettext.
271
  *
272
  */
273
+ function _() {
274
  return $foo;
275
  }
276
 
294
  *
295
  * @return void
296
  */
297
+ function completeStep($status, array $array = [Class1::class, 'test'], $note = '') {
298
  echo 'foo';
299
  }
300
 
306
  *
307
  * @return void
308
  */
309
+ function myFunction(string $name1, string ...$name2) {
310
  }
311
 
312
 
318
  *
319
  * @return void
320
  */
321
+ function myFunction(string $name1, string ...$name2) {
322
  }
323
 
324
  /**
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Commenting/FunctionCommentUnitTest.inc.fixed CHANGED
@@ -157,7 +157,7 @@ class PHP_CodeSniffer_File
157
  *
158
  * @return void
159
  */
160
- public function functionOutsideClass(&$str, &$foo)
161
  {
162
  return;
163
  }//end functionOutsideClass()
@@ -181,7 +181,7 @@ function tagBeforeComment()
181
  *
182
  *
183
  */
184
- public function noReturnOutsideClass()
185
  {
186
 
187
  }//end noReturnOutsideClass()
@@ -195,7 +195,7 @@ public function noReturnOutsideClass()
195
  * @return void
196
  * @fine Unknown tag
197
  */
198
- public function missingTwoParamComment($one, $two, $three)
199
  {
200
 
201
  }//end missingTwoParamComment()
@@ -243,13 +243,13 @@ function myFunction($arg1) {}
243
  */
244
  function myFunction() {}
245
 
246
- class MyClass() {
247
  /**
248
  * An abstract function.
249
  *
250
  * @return string[]
251
  */
252
- abstract final protected function myFunction();
253
  }
254
 
255
  /**
@@ -261,7 +261,7 @@ class MyClass() {
261
  *
262
  * @return void
263
  */
264
- public function foo(&$tokens, $tokenizer, $eolChar)
265
  {
266
 
267
  }//end foo()
@@ -270,7 +270,7 @@ public function foo(&$tokens, $tokenizer, $eolChar)
270
  * Gettext.
271
  *
272
  */
273
- public function _() {
274
  return $foo;
275
  }
276
 
@@ -294,7 +294,7 @@ class Baz {
294
  *
295
  * @return void
296
  */
297
- public function completeStep($status, array $array = [Class1::class, 'test'], $note = '') {
298
  echo 'foo';
299
  }
300
 
@@ -306,7 +306,7 @@ public function completeStep($status, array $array = [Class1::class, 'test'], $n
306
  *
307
  * @return void
308
  */
309
- public function myFunction(string $name1, string ...$name2) {
310
  }
311
 
312
 
@@ -318,7 +318,7 @@ public function myFunction(string $name1, string ...$name2) {
318
  *
319
  * @return void
320
  */
321
- public function myFunction(string $name1, string ...$name2) {
322
  }
323
 
324
  /**
157
  *
158
  * @return void
159
  */
160
+ function functionOutsideClass(&$str, &$foo)
161
  {
162
  return;
163
  }//end functionOutsideClass()
181
  *
182
  *
183
  */
184
+ function noReturnOutsideClass()
185
  {
186
 
187
  }//end noReturnOutsideClass()
195
  * @return void
196
  * @fine Unknown tag
197
  */
198
+ function missingTwoParamComment($one, $two, $three)
199
  {
200
 
201
  }//end missingTwoParamComment()
243
  */
244
  function myFunction() {}
245
 
246
+ abstract class MyClass {
247
  /**
248
  * An abstract function.
249
  *
250
  * @return string[]
251
  */
252
+ abstract protected function myFunction();
253
  }
254
 
255
  /**
261
  *
262
  * @return void
263
  */
264
+ function foo(&$tokens, $tokenizer, $eolChar)
265
  {
266
 
267
  }//end foo()
270
  * Gettext.
271
  *
272
  */
273
+ function _() {
274
  return $foo;
275
  }
276
 
294
  *
295
  * @return void
296
  */
297
+ function completeStep($status, array $array = [Class1::class, 'test'], $note = '') {
298
  echo 'foo';
299
  }
300
 
306
  *
307
  * @return void
308
  */
309
+ function myFunction(string $name1, string ...$name2) {
310
  }
311
 
312
 
318
  *
319
  * @return void
320
  */
321
+ function myFunction(string $name1, string ...$name2) {
322
  }
323
 
324
  /**
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/ControlStructures/ControlSignatureUnitTest.inc CHANGED
@@ -57,7 +57,7 @@ foreach($items as $item){
57
  echo $item;
58
  }
59
 
60
- for ($items as $item) { echo $item; }
61
 
62
 
63
  // if
@@ -130,7 +130,7 @@ if ($i == 0) {
130
  }
131
 
132
  if ($i == 0) { $i = 1; } else if ($i == 2) { $i = 0; }
133
- if ($i == 0) { $i = 1; } elseif ($1 == 2) { $i = 0; }
134
 
135
  if ($i == 0) { // this is ok because comments are allowed
136
  $i = 1;
57
  echo $item;
58
  }
59
 
60
+ foreach ($items as $item) { echo $item; }
61
 
62
 
63
  // if
130
  }
131
 
132
  if ($i == 0) { $i = 1; } else if ($i == 2) { $i = 0; }
133
+ if ($i == 0) { $i = 1; } elseif ($i == 2) { $i = 0; }
134
 
135
  if ($i == 0) { // this is ok because comments are allowed
136
  $i = 1;
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Formatting/MultiLineAssignmentUnitTest.inc CHANGED
@@ -10,7 +10,7 @@ $GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName] =
10
 
11
  $GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName]
12
  = $this->xajax->getJavascript(t3lib_extMgm::siteRelPath('nr_xajax'));
13
- $GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName] = 'boo'
14
 
15
  $var='string';
16
 
10
 
11
  $GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName]
12
  = $this->xajax->getJavascript(t3lib_extMgm::siteRelPath('nr_xajax'));
13
+ $GLOBALS['TSFE']->additionalHeaderData[$this->strApplicationName] = 'boo';
14
 
15
  $var='string';
16
 
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc CHANGED
@@ -65,7 +65,7 @@ $something
65
 
66
  // This is not a function call.
67
  function &testFunction($arg1,
68
- $arg2,
69
  ) {
70
  }
71
 
@@ -105,7 +105,7 @@ $foo = new stdClass(
105
  2,
106
  3);
107
 
108
- public function doSomething()
109
  {
110
  return $this->getFoo()
111
  ->doBar(
@@ -142,7 +142,7 @@ $bar = new stdClass(
142
  4, /* thanks */ 5, /* PSR-2 */ 6
143
  );
144
 
145
- public function doSomething()
146
  {
147
  return $this->getFoo()
148
  ->doBar(
@@ -204,7 +204,7 @@ function foo()
204
  /* comment
205
  * comment
206
  */
207
- 'string'.
208
  );
209
  }
210
 
@@ -345,7 +345,7 @@ $x = $var('y',
345
  $obj->{$x}(1,
346
  2);
347
 
348
- (function ($a, $b) {
349
  return function ($c, $d) use ($a, $b) {
350
  echo $a, $b, $c, $d;
351
  };
@@ -366,7 +366,7 @@ class Foo
366
  }
367
  }
368
 
369
- (function ($a, $b) {
370
  return function ($c, $d) use ($a, $b) {
371
  echo $a, $b, $c, $d;
372
  };
65
 
66
  // This is not a function call.
67
  function &testFunction($arg1,
68
+ $arg2
69
  ) {
70
  }
71
 
105
  2,
106
  3);
107
 
108
+ function doSomething()
109
  {
110
  return $this->getFoo()
111
  ->doBar(
142
  4, /* thanks */ 5, /* PSR-2 */ 6
143
  );
144
 
145
+ function doSomething()
146
  {
147
  return $this->getFoo()
148
  ->doBar(
204
  /* comment
205
  * comment
206
  */
207
+ 'string'
208
  );
209
  }
210
 
345
  $obj->{$x}(1,
346
  2);
347
 
348
+ return (function ($a, $b) {
349
  return function ($c, $d) use ($a, $b) {
350
  echo $a, $b, $c, $d;
351
  };
366
  }
367
  }
368
 
369
+ return (function ($a, $b) {
370
  return function ($c, $d) use ($a, $b) {
371
  echo $a, $b, $c, $d;
372
  };
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionCallSignatureUnitTest.inc.fixed CHANGED
@@ -67,7 +67,7 @@ fputs(
67
 
68
  // This is not a function call.
69
  function &testFunction($arg1,
70
- $arg2,
71
  ) {
72
  }
73
 
@@ -106,7 +106,7 @@ $foo = new stdClass(
106
  3
107
  );
108
 
109
- public function doSomething()
110
  {
111
  return $this->getFoo()
112
  ->doBar(
@@ -147,7 +147,7 @@ $bar = new stdClass(
147
  6
148
  );
149
 
150
- public function doSomething()
151
  {
152
  return $this->getFoo()
153
  ->doBar(
@@ -209,7 +209,7 @@ function foo()
209
  /* comment
210
  * comment
211
  */
212
- 'string'.
213
  );
214
  }
215
 
@@ -356,7 +356,7 @@ $obj->{$x}(
356
  2
357
  );
358
 
359
- (function ($a, $b) {
360
  return function ($c, $d) use ($a, $b) {
361
  echo $a, $b, $c, $d;
362
  };
@@ -379,7 +379,7 @@ class Foo
379
  }
380
  }
381
 
382
- (function ($a, $b) {
383
  return function ($c, $d) use ($a, $b) {
384
  echo $a, $b, $c, $d;
385
  };
67
 
68
  // This is not a function call.
69
  function &testFunction($arg1,
70
+ $arg2
71
  ) {
72
  }
73
 
106
  3
107
  );
108
 
109
+ function doSomething()
110
  {
111
  return $this->getFoo()
112
  ->doBar(
147
  6
148
  );
149
 
150
+ function doSomething()
151
  {
152
  return $this->getFoo()
153
  ->doBar(
209
  /* comment
210
  * comment
211
  */
212
+ 'string'
213
  );
214
  }
215
 
356
  2
357
  );
358
 
359
+ return (function ($a, $b) {
360
  return function ($c, $d) use ($a, $b) {
361
  echo $a, $b, $c, $d;
362
  };
379
  }
380
  }
381
 
382
+ return (function ($a, $b) {
383
  return function ($c, $d) use ($a, $b) {
384
  echo $a, $b, $c, $d;
385
  };
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- public function someFunctionWithAVeryLongName($firstParameter='something',
3
  $secondParameter='booooo', $third=null, $fourthParameter=false,
4
  $fifthParameter=123.12, $sixthParam=true
5
  ){
@@ -18,7 +18,7 @@ function blah()
18
  {
19
  }
20
 
21
- class MyClass
22
  {
23
 
24
  public function someFunctionWithAVeryLongName($firstParameter='something',
@@ -182,21 +182,21 @@ $b = function &() {
182
  function foo(
183
  $param1,
184
  $param2,
185
- $param3,
186
  ) : SomeClass {
187
  }
188
 
189
  function foo(
190
  $param1,
191
  $param2,
192
- $param3,
193
  ): SomeClass {
194
  }
195
 
196
  function foo(
197
  $param1,
198
  $param2,
199
- $param3,
200
  ): SomeClass // Comment here
201
  {
202
  }
@@ -206,7 +206,7 @@ function foo(
206
 
207
  $param2,
208
 
209
- $param3,
210
  ) : SomeClass {
211
  }
212
 
1
  <?php
2
+ function someFunctionWithAVeryLongName($firstParameter='something',
3
  $secondParameter='booooo', $third=null, $fourthParameter=false,
4
  $fifthParameter=123.12, $sixthParam=true
5
  ){
18
  {
19
  }
20
 
21
+ abstract class MyClass
22
  {
23
 
24
  public function someFunctionWithAVeryLongName($firstParameter='something',
182
  function foo(
183
  $param1,
184
  $param2,
185
+ $param3
186
  ) : SomeClass {
187
  }
188
 
189
  function foo(
190
  $param1,
191
  $param2,
192
+ $param3
193
  ): SomeClass {
194
  }
195
 
196
  function foo(
197
  $param1,
198
  $param2,
199
+ $param3
200
  ): SomeClass // Comment here
201
  {
202
  }
206
 
207
  $param2,
208
 
209
+ $param3
210
  ) : SomeClass {
211
  }
212
 
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.inc.fixed CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- public function someFunctionWithAVeryLongName($firstParameter='something',
3
  $secondParameter='booooo', $third=null, $fourthParameter=false,
4
  $fifthParameter=123.12, $sixthParam=true
5
  ) {
@@ -11,7 +11,7 @@ function someFunctionWithAVeryLongName2($firstParameter='something',
11
  ) {
12
  }
13
 
14
- function blah()
15
  {
16
  }
17
 
@@ -19,7 +19,7 @@ function blah()
19
  {
20
  }
21
 
22
- class MyClass
23
  {
24
 
25
  public function someFunctionWithAVeryLongName($firstParameter='something',
@@ -186,28 +186,28 @@ $b = function &() {
186
  function foo(
187
  $param1,
188
  $param2,
189
- $param3,
190
  ) : SomeClass {
191
  }
192
 
193
  function foo(
194
  $param1,
195
  $param2,
196
- $param3,
197
  ): SomeClass {
198
  }
199
 
200
  function foo(
201
  $param1,
202
  $param2,
203
- $param3,
204
  ): SomeClass { // Comment here
205
  }
206
 
207
  function foo(
208
  $param1,
209
  $param2,
210
- $param3,
211
  ) : SomeClass {
212
  }
213
 
1
  <?php
2
+ function someFunctionWithAVeryLongName($firstParameter='something',
3
  $secondParameter='booooo', $third=null, $fourthParameter=false,
4
  $fifthParameter=123.12, $sixthParam=true
5
  ) {
11
  ) {
12
  }
13
 
14
+ function blah()
15
  {
16
  }
17
 
19
  {
20
  }
21
 
22
+ abstract class MyClass
23
  {
24
 
25
  public function someFunctionWithAVeryLongName($firstParameter='something',
186
  function foo(
187
  $param1,
188
  $param2,
189
+ $param3
190
  ) : SomeClass {
191
  }
192
 
193
  function foo(
194
  $param1,
195
  $param2,
196
+ $param3
197
  ): SomeClass {
198
  }
199
 
200
  function foo(
201
  $param1,
202
  $param2,
203
+ $param3
204
  ): SomeClass { // Comment here
205
  }
206
 
207
  function foo(
208
  $param1,
209
  $param2,
210
+ $param3
211
  ) : SomeClass {
212
  }
213
 
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/FunctionDeclarationUnitTest.js.fixed CHANGED
@@ -11,7 +11,7 @@ function someFunctionWithAVeryLongName2(firstParameter='something',
11
  ) {
12
  }
13
 
14
- function blah()
15
  {
16
  }
17
 
@@ -45,7 +45,7 @@ var a = Function('return 1+1');
45
 
46
  class test
47
  {
48
- myFunction()
49
  {
50
  return false;
51
  }
11
  ) {
12
  }
13
 
14
+ function blah()
15
  {
16
  }
17
 
45
 
46
  class test
47
  {
48
+ myFunction()
49
  {
50
  return false;
51
  }
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/Functions/ValidDefaultValueUnitTest.inc CHANGED
@@ -40,7 +40,7 @@ function myFunction(array $arg2=array(), array $arg1)
40
  {
41
  }
42
 
43
- class myClass()
44
  {
45
  // No args.
46
  function myFunction()
@@ -93,7 +93,7 @@ function foo($baz, Foo $foo = null, $bar = true) {}
93
  function foo($baz, $bar = true, Foo $foo = null) {}
94
 
95
  // Valid closure
96
- function ($arg1, $arg2='hello') {}
97
 
98
  // Invalid closure
99
- function(array $arg2=array(), array $arg1) {}
40
  {
41
  }
42
 
43
+ class myClass
44
  {
45
  // No args.
46
  function myFunction()
93
  function foo($baz, $bar = true, Foo $foo = null) {}
94
 
95
  // Valid closure
96
+ $closure = function ($arg1, $arg2='hello') {};
97
 
98
  // Invalid closure
99
+ $closure = function(array $arg2=array(), array $arg1) {}
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.inc CHANGED
@@ -62,57 +62,31 @@ abstract class My_Class {
62
 
63
  interface My_Interface {
64
 
65
- public function getSomeValue() {}
66
- public function parseMyDSN() {}
67
- public function get_some_value() {}
68
- public function GetSomeValue() {}
69
- public function getSomeValue_Again() {}
70
- public function My_Package_getSomeValue() {}
71
- public function _getSomeValue() {}
72
- public function _parseMyDSN() {}
73
- public function _get_some_value() {}
74
- public function _GetSomeValue() {}
75
- public function _getSomeValue_Again() {}
76
- public function _My_Package_getSomeValue() {}
77
-
78
- protected function getSomeValue() {}
79
- protected function parseMyDSN() {}
80
- protected function get_some_value() {}
81
- protected function GetSomeValue() {}
82
- protected function getSomeValue_Again() {}
83
- protected function My_Package_getSomeValue() {}
84
- protected function _getSomeValue() {}
85
- protected function _parseMyDSN() {}
86
- protected function _get_some_value() {}
87
- protected function _GetSomeValue() {}
88
- protected function _getSomeValue_Again() {}
89
- protected function _My_Package_getSomeValue() {}
90
-
91
- private function getSomeValue() {}
92
- private function parseMyDSN() {}
93
- private function get_some_value() {}
94
- private function GetSomeValue() {}
95
- private function getSomeValue_Again() {}
96
- private function My_Package_getSomeValue() {}
97
- private function _getSomeValue() {}
98
- private function _parseMyDSN() {}
99
- private function _get_some_value() {}
100
- private function _GetSomeValue() {}
101
- private function _getSomeValue_Again() {}
102
- private function _My_Package_getSomeValue() {}
103
-
104
- function getSomeValue() {}
105
- function parseMyDSN() {}
106
- function get_some_value() {}
107
- function GetSomeValue() {}
108
- function getSomeValue_Again() {}
109
- function My_Package_getSomeValue() {}
110
- function _getSomeValue() {}
111
- function _parseMyDSN() {}
112
- function _get_some_value() {}
113
- function _GetSomeValue() {}
114
- function _getSomeValue_Again() {}
115
- function _My_Package_getSomeValue() {}
116
 
117
  }//end interface
118
 
@@ -135,12 +109,12 @@ function _My_Package() {}
135
  class Magic_Test {
136
  function __construct() {}
137
  function __destruct() {}
138
- function __call() {}
139
- function __callStatic() {}
140
- function __get() {}
141
- function __set() {}
142
- function __isset() {}
143
- function __unset() {}
144
  function __sleep() {}
145
  function __wakeup() {}
146
  function __toString() {}
@@ -165,7 +139,7 @@ function __wakeup() {}
165
  function __toString() {}
166
  function __set_state() {}
167
  function __clone() {}
168
- function __autoload() {}
169
  function __invoke() {}
170
  function __myFunction() {}
171
  function __my_function() {}
@@ -193,15 +167,15 @@ class MyClass
193
 
194
  trait Foo
195
  {
196
- function __call() {}
197
  }
198
 
199
  class Magic_Case_Test {
200
  function __Construct() {}
201
- function __isSet() {}
202
  function __tostring() {}
203
  }
204
- function __autoLoad() {}
205
  function _() {}
206
 
207
  function __debugInfo() {}
@@ -210,15 +184,15 @@ class Foo {
210
  }
211
 
212
  /* Magic methods in anonymous classes. */
213
- $a new class {
214
  function __construct() {}
215
  function __destruct() {}
216
- function __call() {}
217
- function __callStatic() {}
218
- function __get() {}
219
- function __set() {}
220
- function __isset() {}
221
- function __unset() {}
222
  function __sleep() {}
223
  function __wakeup() {}
224
  function __toString() {}
@@ -228,4 +202,6 @@ $a new class {
228
  function __invoke() {}
229
  function __myFunction() {}
230
  function __my_function() {}
231
- }
 
 
62
 
63
  interface My_Interface {
64
 
65
+ public function getSomeValue();
66
+ public function parseMyDSN();
67
+ public function get_some_value();
68
+ public function GetSomeValue();
69
+ public function getSomeValue_Again();
70
+ public function My_Package_getSomeValue();
71
+ public function _getSomeValue();
72
+ public function _parseMyDSN();
73
+ public function _get_some_value();
74
+ public function _GetSomeValue();
75
+ public function _getSomeValue_Again();
76
+ public function _My_Package_getSomeValue();
77
+
78
+ function getSomeValue();
79
+ function parseMyDSN();
80
+ function get_some_value();
81
+ function GetSomeValue();
82
+ function getSomeValue_Again();
83
+ function My_Package_getSomeValue();
84
+ function _getSomeValue();
85
+ function _parseMyDSN();
86
+ function _get_some_value();
87
+ function _GetSomeValue();
88
+ function _getSomeValue_Again();
89
+ function _My_Package_getSomeValue();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
  }//end interface
92
 
109
  class Magic_Test {
110
  function __construct() {}
111
  function __destruct() {}
112
+ function __call($name, $args) {}
113
+ static function __callStatic($name, $args) {}
114
+ function __get($name) {}
115
+ function __set($name, $value) {}
116
+ function __isset($name) {}
117
+ function __unset($name) {}
118
  function __sleep() {}
119
  function __wakeup() {}
120
  function __toString() {}
139
  function __toString() {}
140
  function __set_state() {}
141
  function __clone() {}
142
+ function __autoload($class) {}
143
  function __invoke() {}
144
  function __myFunction() {}
145
  function __my_function() {}
167
 
168
  trait Foo
169
  {
170
+ function __call($name, $args) {}
171
  }
172
 
173
  class Magic_Case_Test {
174
  function __Construct() {}
175
+ function __isSet($name) {}
176
  function __tostring() {}
177
  }
178
+ function __autoLoad($class) {}
179
  function _() {}
180
 
181
  function __debugInfo() {}
184
  }
185
 
186
  /* Magic methods in anonymous classes. */
187
+ $a = new class {
188
  function __construct() {}
189
  function __destruct() {}
190
+ function __call($name, $args) {}
191
+ static function __callStatic($name, $args) {}
192
+ function __get($name) {}
193
+ function __set($name, $value) {}
194
+ function __isset($name) {}
195
+ function __unset($name) {}
196
  function __sleep() {}
197
  function __wakeup() {}
198
  function __toString() {}
202
  function __invoke() {}
203
  function __myFunction() {}
204
  function __my_function() {}
205
+ };
206
+
207
+ function send_system_email__to_user($body, $recipient){}
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/NamingConventions/ValidFunctionNameUnitTest.php CHANGED
@@ -78,66 +78,47 @@ class ValidFunctionNameUnitTest extends AbstractSniffUnitTest
78
  81 => 1,
79
  82 => 1,
80
  83 => 1,
81
- 84 => 1,
82
- 85 => 1,
83
- 86 => 2,
84
- 87 => 2,
85
- 88 => 2,
86
- 89 => 2,
87
- 91 => 1,
88
- 92 => 1,
89
- 93 => 2,
90
- 94 => 2,
91
- 95 => 2,
92
- 96 => 2,
93
  99 => 1,
94
  100 => 1,
95
- 101 => 1,
96
- 102 => 1,
97
- 106 => 1,
98
- 107 => 1,
99
- 108 => 1,
100
- 109 => 1,
101
- 112 => 1,
102
- 113 => 1,
103
- 114 => 1,
104
- 115 => 1,
105
- 121 => 1,
106
- 122 => 1,
107
  123 => 1,
108
- 124 => 1,
109
  125 => 1,
110
- 126 => 1,
111
- 127 => 2,
112
- 128 => 2,
113
- 129 => 2,
114
- 130 => 2,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  149 => 1,
116
- 151 => 1,
117
- 152 => 2,
118
- 155 => 1,
119
- 156 => 1,
120
- 157 => 1,
121
- 158 => 1,
122
- 159 => 1,
123
- 160 => 1,
124
- 161 => 1,
125
- 162 => 1,
126
- 163 => 1,
127
- 164 => 1,
128
- 165 => 1,
129
- 166 => 3,
130
- 167 => 1,
131
- 169 => 1,
132
- 170 => 1,
133
- 171 => 3,
134
- 173 => 2,
135
- 174 => 1,
136
- 175 => 1,
137
- 207 => 1,
138
- 227 => 1,
139
- 229 => 1,
140
- 230 => 2,
141
  ];
142
 
143
  }//end getErrorList()
78
  81 => 1,
79
  82 => 1,
80
  83 => 1,
81
+ 86 => 1,
82
+ 87 => 1,
83
+ 88 => 1,
84
+ 89 => 1,
85
+ 95 => 1,
86
+ 96 => 1,
87
+ 97 => 1,
88
+ 98 => 1,
 
 
 
 
89
  99 => 1,
90
  100 => 1,
91
+ 101 => 2,
92
+ 102 => 2,
93
+ 103 => 2,
94
+ 104 => 2,
 
 
 
 
 
 
 
 
95
  123 => 1,
 
96
  125 => 1,
97
+ 126 => 2,
98
+ 129 => 1,
99
+ 130 => 1,
100
+ 131 => 1,
101
+ 132 => 1,
102
+ 133 => 1,
103
+ 134 => 1,
104
+ 135 => 1,
105
+ 136 => 1,
106
+ 137 => 1,
107
+ 138 => 1,
108
+ 139 => 1,
109
+ 140 => 3,
110
+ 141 => 1,
111
+ 143 => 1,
112
+ 144 => 1,
113
+ 145 => 3,
114
+ 147 => 2,
115
+ 148 => 1,
116
  149 => 1,
117
+ 181 => 1,
118
+ 201 => 1,
119
+ 203 => 1,
120
+ 204 => 2,
121
+ 207 => 2,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  ];
123
 
124
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/NamingConventions/ValidVariableNameUnitTest.inc CHANGED
@@ -1,10 +1,10 @@
1
  <?php
2
  class MyClass
3
  {
4
- $varName = 'hello';
5
- $var_name = 'hello';
6
- $varname = 'hello';
7
- $_varName = 'hello';
8
 
9
  public $varName = 'hello';
10
  public $var_name = 'hello';
@@ -43,8 +43,8 @@ class MyClass
43
  if (true) {
44
  class MyClass
45
  {
46
- $varName = 'hello';
47
- $var_name = 'hello';
48
  }
49
  }
50
 
1
  <?php
2
  class MyClass
3
  {
4
+ var $varName = 'hello';
5
+ var $var_name = 'hello';
6
+ var $varname = 'hello';
7
+ var $_varName = 'hello';
8
 
9
  public $varName = 'hello';
10
  public $var_name = 'hello';
43
  if (true) {
44
  class MyClass
45
  {
46
+ var $varName = 'hello';
47
+ var $var_name = 'hello';
48
  }
49
  }
50
 
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc CHANGED
@@ -48,3 +48,26 @@ $response
48
  -> CompletedTrackDetails
49
  -> TrackDetails
50
  -> Events;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  -> CompletedTrackDetails
49
  -> TrackDetails
50
  -> Events;
51
+
52
+ $var = get_object(
53
+ $foo->something()
54
+ ->query()
55
+ )->two()
56
+ ->three();
57
+
58
+ $foo->one(
59
+ $foo
60
+ ->two()
61
+ );
62
+
63
+ get_object()->one()
64
+ ->two()
65
+ ->three();
66
+
67
+ someclass::one()
68
+ ->two()
69
+ ->three();
70
+
71
+ (new someclass())->one()
72
+ ->two()
73
+ ->three();
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.inc.fixed ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $someObject->someFunction("some", "parameter")
3
+ ->someOtherFunc(23, 42)
4
+ ->someOtherFunc2($one, $two)
5
+
6
+ ->someOtherFunc3(23, 42)
7
+ ->andAThirdFunction();
8
+
9
+ $someObject->someFunction("some", "parameter")
10
+ ->someOtherFunc(23, 42);
11
+
12
+ $someObject->someFunction("some", "parameter")->someOtherFunc(23, 42);
13
+
14
+ $someObject->someFunction("some", "parameter")
15
+ ->someOtherFunc(23, 42);
16
+
17
+ func(
18
+ $bar->foo()
19
+ )
20
+ ->bar();
21
+
22
+ func(
23
+ $bar->foo()
24
+ )
25
+ ->bar(
26
+ $bar->foo()
27
+ ->bar()
28
+ ->func()
29
+ );
30
+
31
+ $object
32
+ ->setBar($foo)
33
+ ->setFoo($bar);
34
+
35
+ if ($bar) {
36
+ $object
37
+ ->setBar($foo)
38
+ ->setFoo($bar);
39
+ }
40
+
41
+ $response -> CompletedTrackDetails -> TrackDetails -> Events;
42
+ $response
43
+ -> CompletedTrackDetails
44
+ -> TrackDetails
45
+ -> Events;
46
+
47
+ $response
48
+ -> CompletedTrackDetails
49
+ -> TrackDetails
50
+ -> Events;
51
+
52
+ $var = get_object(
53
+ $foo->something()
54
+ ->query()
55
+ )->two()
56
+ ->three();
57
+
58
+ $foo->one(
59
+ $foo
60
+ ->two()
61
+ );
62
+
63
+ get_object()->one()
64
+ ->two()
65
+ ->three();
66
+
67
+ someclass::one()
68
+ ->two()
69
+ ->three();
70
+
71
+ (new someclass())->one()
72
+ ->two()
73
+ ->three();
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ObjectOperatorIndentUnitTest.php CHANGED
@@ -35,6 +35,9 @@ class ObjectOperatorIndentUnitTest extends AbstractSniffUnitTest
35
  48 => 1,
36
  49 => 1,
37
  50 => 1,
 
 
 
38
  ];
39
 
40
  }//end getErrorList()
35
  48 => 1,
36
  49 => 1,
37
  50 => 1,
38
+ 65 => 1,
39
+ 69 => 1,
40
+ 73 => 1,
41
  ];
42
 
43
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc CHANGED
@@ -24,7 +24,7 @@ class Test2
24
  }
25
 
26
 
27
- public function test2()
28
  {
29
  if ($str{0}) {
30
  $chr = $str{0}; }
24
  }
25
 
26
 
27
+ function test2()
28
  {
29
  if ($str{0}) {
30
  $chr = $str{0}; }
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeClosingBraceUnitTest.inc.fixed CHANGED
@@ -25,7 +25,7 @@ class Test2
25
  }
26
 
27
 
28
- public function test2()
29
  {
30
  if ($str{0}) {
31
  $chr = $str{0};
25
  }
26
 
27
 
28
+ function test2()
29
  {
30
  if ($str{0}) {
31
  $chr = $str{0};
vendor/squizlabs/php_codesniffer/src/Standards/PEAR/Tests/WhiteSpace/ScopeIndentUnitTest.inc CHANGED
@@ -181,7 +181,7 @@ abstract class Test3
181
  }
182
  }
183
 
184
- public function test()
185
  {
186
  $o = <<<EOF
187
  this is some text
181
  }
182
  }
183
 
184
+ function test()
185
  {
186
  $o = <<<EOF
187
  this is some text
vendor/squizlabs/php_codesniffer/src/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php CHANGED
@@ -91,11 +91,14 @@ class SideEffectsSniff implements Sniff
91
  T_ELSEIF => T_ELSEIF,
92
  ];
93
 
 
 
94
  $firstSymbol = null;
95
  $firstEffect = null;
96
  for ($i = $start; $i <= $end; $i++) {
97
  // Respect phpcs:disable comments.
98
- if ($tokens[$i]['code'] === T_PHPCS_DISABLE
 
99
  && (empty($tokens[$i]['sniffCodes']) === true
100
  || isset($tokens[$i]['sniffCodes']['PSR1']) === true
101
  || isset($tokens[$i]['sniffCodes']['PSR1.Files']) === true
@@ -135,6 +138,11 @@ class SideEffectsSniff implements Sniff
135
  continue;
136
  }
137
 
 
 
 
 
 
138
  // Ignore entire namespace, declare, const and use statements.
139
  if ($tokens[$i]['code'] === T_NAMESPACE
140
  || $tokens[$i]['code'] === T_USE
@@ -177,9 +185,10 @@ class SideEffectsSniff implements Sniff
177
  } else if ($tokens[$i]['code'] === T_STRING
178
  && strtolower($tokens[$i]['content']) === 'define'
179
  ) {
180
- $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($i - 1), null, true);
181
  if ($tokens[$prev]['code'] !== T_OBJECT_OPERATOR
182
  && $tokens[$prev]['code'] !== T_DOUBLE_COLON
 
183
  ) {
184
  if ($firstSymbol === null) {
185
  $firstSymbol = $i;
@@ -194,6 +203,27 @@ class SideEffectsSniff implements Sniff
194
  }
195
  }//end if
196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  // Conditional statements are allowed in symbol files as long as the
198
  // contents is only a symbol definition. So don't count these as effects
199
  // in this case.
91
  T_ELSEIF => T_ELSEIF,
92
  ];
93
 
94
+ $checkAnnotations = $phpcsFile->config->annotations;
95
+
96
  $firstSymbol = null;
97
  $firstEffect = null;
98
  for ($i = $start; $i <= $end; $i++) {
99
  // Respect phpcs:disable comments.
100
+ if ($checkAnnotations === true
101
+ && $tokens[$i]['code'] === T_PHPCS_DISABLE
102
  && (empty($tokens[$i]['sniffCodes']) === true
103
  || isset($tokens[$i]['sniffCodes']['PSR1']) === true
104
  || isset($tokens[$i]['sniffCodes']['PSR1.Files']) === true
138
  continue;
139
  }
140
 
141
+ // Ignore logical operators.
142
+ if (isset(Tokens::$booleanOperators[$tokens[$i]['code']]) === true) {
143
+ continue;
144
+ }
145
+
146
  // Ignore entire namespace, declare, const and use statements.
147
  if ($tokens[$i]['code'] === T_NAMESPACE
148
  || $tokens[$i]['code'] === T_USE
185
  } else if ($tokens[$i]['code'] === T_STRING
186
  && strtolower($tokens[$i]['content']) === 'define'
187
  ) {
188
+ $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($i - 1), null, true);
189
  if ($tokens[$prev]['code'] !== T_OBJECT_OPERATOR
190
  && $tokens[$prev]['code'] !== T_DOUBLE_COLON
191
+ && $tokens[$prev]['code'] !== T_FUNCTION
192
  ) {
193
  if ($firstSymbol === null) {
194
  $firstSymbol = $i;
203
  }
204
  }//end if
205
 
206
+ // Special case for defined() as it can be used to see
207
+ // if a constant (a symbol) should be defined or not and
208
+ // doesn't need to use a full conditional block.
209
+ if ($tokens[$i]['code'] === T_STRING
210
+ && strtolower($tokens[$i]['content']) === 'defined'
211
+ ) {
212
+ $openBracket = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
213
+ if ($tokens[$openBracket]['code'] === T_OPEN_PARENTHESIS
214
+ && isset($tokens[$openBracket]['parenthesis_closer']) === true
215
+ ) {
216
+ $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($i - 1), null, true);
217
+ if ($tokens[$prev]['code'] !== T_OBJECT_OPERATOR
218
+ && $tokens[$prev]['code'] !== T_DOUBLE_COLON
219
+ && $tokens[$prev]['code'] !== T_FUNCTION
220
+ ) {
221
+ $i = $tokens[$openBracket]['parenthesis_closer'];
222
+ continue;
223
+ }
224
+ }
225
+ }//end if
226
+
227
  // Conditional statements are allowed in symbol files as long as the
228
  // contents is only a symbol definition. So don't count these as effects
229
  // in this case.
vendor/squizlabs/php_codesniffer/src/Standards/PSR1/Tests/Classes/ClassDeclarationUnitTest.php CHANGED
@@ -31,14 +31,10 @@ class ClassDeclarationUnitTest extends AbstractSniffUnitTest
31
  return [];
32
  }
33
 
34
- if (PHP_VERSION_ID >= 50300) {
35
- return [
36
- 2 => 1,
37
- 3 => 2,
38
- ];
39
- } else {
40
- return [3 => 1];
41
- }
42
 
43
  }//end getErrorList()
44
 
31
  return [];
32
  }
33
 
34
+ return [
35
+ 2 => 1,
36
+ 3 => 2,
37
+ ];
 
 
 
 
38
 
39
  }//end getErrorList()
40
 
vendor/squizlabs/php_codesniffer/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.1.inc CHANGED
@@ -63,4 +63,6 @@ namespace {
63
  class A {}
64
  }
65
 
 
 
66
  ?>
63
  class A {}
64
  }
65
 
66
+ defined('APP_BASE_URL') or define('APP_BASE_URL', '/');
67
+
68
  ?>
vendor/squizlabs/php_codesniffer/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.12.inc ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // phpcs:disable PSR1.Files.SideEffects
3
+ define("MAXSIZE", 100);
4
+ // phpcs:enable
5
+ $defined = true;
6
+ if (defined('MINSIZE') === false) {
7
+ $defined = false;
8
+ }
vendor/squizlabs/php_codesniffer/src/Standards/PSR1/Tests/Files/SideEffectsUnitTest.php CHANGED
@@ -15,6 +15,23 @@ class SideEffectsUnitTest extends AbstractSniffUnitTest
15
  {
16
 
17
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  /**
19
  * Returns the lines where errors should occur.
20
  *
@@ -49,6 +66,7 @@ class SideEffectsUnitTest extends AbstractSniffUnitTest
49
  case 'SideEffectsUnitTest.4.inc':
50
  case 'SideEffectsUnitTest.5.inc':
51
  case 'SideEffectsUnitTest.10.inc':
 
52
  return [1 => 1];
53
  default:
54
  return [];
15
  {
16
 
17
 
18
+ /**
19
+ * Set CLI values before the file is tested.
20
+ *
21
+ * @param string $testFile The name of the file being tested.
22
+ * @param \PHP_CodeSniffer\Config $config The config data for the test run.
23
+ *
24
+ * @return void
25
+ */
26
+ public function setCliValues($testFile, $config)
27
+ {
28
+ if ($testFile === 'SideEffectsUnitTest.12.inc') {
29
+ $config->annotations = false;
30
+ }
31
+
32
+ }//end setCliValues()
33
+
34
+
35
  /**
36
  * Returns the lines where errors should occur.
37
  *
66
  case 'SideEffectsUnitTest.4.inc':
67
  case 'SideEffectsUnitTest.5.inc':
68
  case 'SideEffectsUnitTest.10.inc':
69
+ case 'SideEffectsUnitTest.12.inc':
70
  return [1 => 1];
71
  default:
72
  return [];
vendor/squizlabs/php_codesniffer/src/Standards/PSR1/ruleset.xml CHANGED
@@ -7,6 +7,7 @@
7
  <!-- 2.1. PHP Tags -->
8
 
9
  <!-- PHP code MUST use the long <?php ?> tags or the short-echo <?= ?> tags; it MUST NOT use the other tag variations. -->
 
10
  <rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound">
11
  <severity>0</severity>
12
  </rule>
7
  <!-- 2.1. PHP Tags -->
8
 
9
  <!-- PHP code MUST use the long <?php ?> tags or the short-echo <?= ?> tags; it MUST NOT use the other tag variations. -->
10
+ <rule ref="Generic.PHP.DisallowShortOpenTag"/>
11
  <rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound">
12
  <severity>0</severity>
13
  </rule>
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Docs/Classes/ClassInstantiationStandard.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Class Instantiation">
2
+ <standard>
3
+ <![CDATA[
4
+ When instantiating a new class, parenthesis MUST always be present even when there are no arguments passed to the constructor.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Parenthesis used.">
9
+ <![CDATA[
10
+ new Foo();
11
+ ]]>
12
+ </code>
13
+ <code title="Invalid: Parenthesis not used.">
14
+ <![CDATA[
15
+ new Foo;
16
+ ]]>
17
+ </code>
18
+ </code_comparison>
19
+ </documentation>
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Docs/Keywords/ShortFormTypeKeywordsStandard.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Short Form Type Keywords">
2
+ <standard>
3
+ <![CDATA[
4
+ Short form of type keywords MUST be used i.e. bool instead of boolean, int instead of integer etc.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Short form type used.">
9
+ <![CDATA[
10
+ $foo = (bool) $isValid;
11
+ ]]>
12
+ </code>
13
+ <code title="Invalid: Long form type type used.">
14
+ <![CDATA[
15
+ $foo = <em>(boolean)</em> $isValid;
16
+ ]]>
17
+ </code>
18
+ </code_comparison>
19
+ </documentation>
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Docs/Namespaces/CompoundNamespaceDepthStandard.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Compound Namespace Depth">
2
+ <standard>
3
+ <![CDATA[
4
+ Compound namespaces with a depth of more than two MUST NOT be used.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Max depth of 2.">
9
+ <![CDATA[
10
+ use Vendor\Package\SomeNamespace\{
11
+ SubnamespaceOne\ClassA,
12
+ SubnamespaceOne\ClassB,
13
+ SubnamespaceTwo\ClassY,
14
+ ClassZ,
15
+ };
16
+ ]]>
17
+ </code>
18
+ <code title="Invalid: Max depth of 3.">
19
+ <![CDATA[
20
+ use Vendor\Package\SomeNamespace\{
21
+ <em>SubnamespaceOne\AnotherNamespace\ClassA,</em>
22
+ SubnamespaceOne\ClassB,
23
+ ClassZ,
24
+ };
25
+ ]]>
26
+ </code>
27
+ </code_comparison>
28
+ </documentation>
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Docs/Operators/OperatorSpacingStandard.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Operator Spacing">
2
+ <standard>
3
+ <![CDATA[
4
+ All binary and ternary (but not unary) operators MUST be preceded and followed by at least one space. This includes all arithmetic, comparison, assignment, bitwise, logical (excluding ! which is unary), string concatenation, type operators, trait operators (insteadof and as), and the single pipe operator (e.g. ExceptionType1 | ExceptionType2 $e).
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: At least 1 space used.">
9
+ <![CDATA[
10
+ if ($a === $b) {
11
+ $foo = $bar ?? $a ?? $b;
12
+ } elseif ($a > $b) {
13
+ $variable = $foo ? 'foo' : 'bar';
14
+ }
15
+ ]]>
16
+ </code>
17
+ <code title="Invalid: No spacing used.">
18
+ <![CDATA[
19
+ if ($a===$b) {
20
+ $foo=$bar??$a??$b;
21
+ } elseif ($a>$b) {
22
+ $variable=$foo?'foo':'bar';
23
+ }
24
+ ]]>
25
+ </code>
26
+ </code_comparison>
27
+ </documentation>
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Sniffs/Classes/ClassInstantiationSniff.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Verifies that classes are instantiated with parenthesis.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Classes;
11
+
12
+ use PHP_CodeSniffer\Sniffs\Sniff;
13
+ use PHP_CodeSniffer\Files\File;
14
+ use PHP_CodeSniffer\Util\Tokens;
15
+
16
+ class ClassInstantiationSniff implements Sniff
17
+ {
18
+
19
+
20
+ /**
21
+ * Returns an array of tokens this test wants to listen for.
22
+ *
23
+ * @return array
24
+ */
25
+ public function register()
26
+ {
27
+ return [T_NEW];
28
+
29
+ }//end register()
30
+
31
+
32
+ /**
33
+ * Processes this test, when one of its tokens is encountered.
34
+ *
35
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
36
+ * @param int $stackPtr The position of the current token in the
37
+ * stack passed in $tokens.
38
+ *
39
+ * @return void
40
+ */
41
+ public function process(File $phpcsFile, $stackPtr)
42
+ {
43
+ $tokens = $phpcsFile->getTokens();
44
+
45
+ // Find the class name.
46
+ $allowed = [
47
+ T_STRING => T_STRING,
48
+ T_NS_SEPARATOR => T_NS_SEPARATOR,
49
+ T_SELF => T_SELF,
50
+ T_STATIC => T_STATIC,
51
+ T_VARIABLE => T_VARIABLE,
52
+ T_DOLLAR => T_DOLLAR,
53
+ T_OBJECT_OPERATOR => T_OBJECT_OPERATOR,
54
+ T_DOUBLE_COLON => T_DOUBLE_COLON,
55
+ ];
56
+
57
+ $allowed += Tokens::$emptyTokens;
58
+
59
+ $classNameEnd = null;
60
+ for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
61
+ if (isset($allowed[$tokens[$i]['code']]) === true) {
62
+ continue;
63
+ }
64
+
65
+ if ($tokens[$i]['code'] === T_OPEN_SQUARE_BRACKET
66
+ || $tokens[$i]['code'] === T_OPEN_CURLY_BRACKET
67
+ ) {
68
+ $i = $tokens[$i]['bracket_closer'];
69
+ continue;
70
+ }
71
+
72
+ $classNameEnd = $i;
73
+ break;
74
+ }
75
+
76
+ if ($classNameEnd === null) {
77
+ return;
78
+ }
79
+
80
+ if ($tokens[$classNameEnd]['code'] === T_ANON_CLASS) {
81
+ // Ignore anon classes.
82
+ return;
83
+ }
84
+
85
+ if ($tokens[$classNameEnd]['code'] === T_OPEN_PARENTHESIS) {
86
+ // Using parenthesis.
87
+ return;
88
+ }
89
+
90
+ $error = 'Parenthesis must be used when instantiating a new class';
91
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'MissingParenthesis');
92
+ if ($fix === true) {
93
+ $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($classNameEnd - 1), null, true);
94
+ $phpcsFile->fixer->addContent($prev, '()');
95
+ }
96
+
97
+ }//end process()
98
+
99
+
100
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Sniffs/Keywords/ShortFormTypeKeywordsSniff.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Verifies that the short form of type keywords is used (e.g., int, bool).
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Keywords;
11
+
12
+ use PHP_CodeSniffer\Sniffs\Sniff;
13
+ use PHP_CodeSniffer\Files\File;
14
+
15
+ class ShortFormTypeKeywordsSniff implements Sniff
16
+ {
17
+
18
+
19
+ /**
20
+ * Returns an array of tokens this test wants to listen for.
21
+ *
22
+ * @return array
23
+ */
24
+ public function register()
25
+ {
26
+ return [
27
+ T_BOOL_CAST,
28
+ T_INT_CAST,
29
+ ];
30
+
31
+ }//end register()
32
+
33
+
34
+ /**
35
+ * Processes this test, when one of its tokens is encountered.
36
+ *
37
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
38
+ * @param int $stackPtr The position of the current token in the
39
+ * stack passed in $tokens.
40
+ *
41
+ * @return void
42
+ */
43
+ public function process(File $phpcsFile, $stackPtr)
44
+ {
45
+ $tokens = $phpcsFile->getTokens();
46
+
47
+ if (($tokens[$stackPtr]['code'] === T_BOOL_CAST
48
+ && strtolower($tokens[$stackPtr]['content']) === '(bool)')
49
+ || ($tokens[$stackPtr]['code'] === T_INT_CAST
50
+ && strtolower($tokens[$stackPtr]['content']) === '(int)')
51
+ ) {
52
+ return;
53
+ }
54
+
55
+ $error = 'Short form type keywords must be used';
56
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'LongFound');
57
+ if ($fix === true) {
58
+ if ($tokens[$stackPtr]['code'] === T_BOOL_CAST) {
59
+ $phpcsFile->fixer->replaceToken($stackPtr, '(bool)');
60
+ } else {
61
+ $phpcsFile->fixer->replaceToken($stackPtr, '(int)');
62
+ }
63
+ }
64
+
65
+ }//end process()
66
+
67
+
68
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Sniffs/Namespaces/CompoundNamespaceDepthSniff.php ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Verifies that compound namespaces are not defined too deep.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Namespaces;
11
+
12
+ use PHP_CodeSniffer\Sniffs\Sniff;
13
+ use PHP_CodeSniffer\Files\File;
14
+
15
+ class CompoundNamespaceDepthSniff implements Sniff
16
+ {
17
+
18
+ /**
19
+ * The max depth for compound namespaces.
20
+ *
21
+ * @var integer
22
+ */
23
+ public $maxDepth = 2;
24
+
25
+
26
+ /**
27
+ * Returns an array of tokens this test wants to listen for.
28
+ *
29
+ * @return array
30
+ */
31
+ public function register()
32
+ {
33
+ return [T_OPEN_USE_GROUP];
34
+
35
+ }//end register()
36
+
37
+
38
+ /**
39
+ * Processes this test, when one of its tokens is encountered.
40
+ *
41
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
42
+ * @param int $stackPtr The position of the current token in the
43
+ * stack passed in $tokens.
44
+ *
45
+ * @return void
46
+ */
47
+ public function process(File $phpcsFile, $stackPtr)
48
+ {
49
+ $this->maxDepth = (int) $this->maxDepth;
50
+
51
+ $tokens = $phpcsFile->getTokens();
52
+
53
+ $end = $phpcsFile->findNext(T_CLOSE_USE_GROUP, ($stackPtr + 1));
54
+ if ($end === false) {
55
+ return;
56
+ }
57
+
58
+ $depth = 1;
59
+ for ($i = ($stackPtr + 1); $i <= $end; $i++) {
60
+ if ($tokens[$i]['code'] === T_NS_SEPARATOR) {
61
+ $depth++;
62
+ continue;
63
+ }
64
+
65
+ if ($i === $end || $tokens[$i]['code'] === T_COMMA) {
66
+ // End of a namespace.
67
+ if ($depth > $this->maxDepth) {
68
+ $error = 'Compound namespaces cannot have a depth more than %s';
69
+ $data = [$this->maxDepth];
70
+ $phpcsFile->addError($error, $i, 'TooDeep', $data);
71
+ }
72
+
73
+ $depth = 1;
74
+ }
75
+ }
76
+
77
+ }//end process()
78
+
79
+
80
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Sniffs/Operators/OperatorSpacingSniff.php ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Verifies that operators have valid spacing surrounding them.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\PSR12\Sniffs\Operators;
11
+
12
+ use PHP_CodeSniffer\Files\File;
13
+ use PHP_CodeSniffer\Util\Tokens;
14
+ use PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\OperatorSpacingSniff as SquizOperatorSpacingSniff;
15
+
16
+ class OperatorSpacingSniff extends SquizOperatorSpacingSniff
17
+ {
18
+
19
+
20
+ /**
21
+ * Returns an array of tokens this test wants to listen for.
22
+ *
23
+ * @return array
24
+ */
25
+ public function register()
26
+ {
27
+ return array_unique(
28
+ array_merge(
29
+ Tokens::$comparisonTokens,
30
+ Tokens::$operators,
31
+ Tokens::$assignmentTokens,
32
+ Tokens::$booleanOperators,
33
+ [
34
+ T_INLINE_THEN,
35
+ T_INLINE_ELSE,
36
+ T_STRING_CONCAT,
37
+ T_INSTANCEOF,
38
+ ]
39
+ )
40
+ );
41
+
42
+ }//end register()
43
+
44
+
45
+ /**
46
+ * Processes this sniff, when one of its tokens is encountered.
47
+ *
48
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The current file being checked.
49
+ * @param int $stackPtr The position of the current token in
50
+ * the stack passed in $tokens.
51
+ *
52
+ * @return void
53
+ */
54
+ public function process(File $phpcsFile, $stackPtr)
55
+ {
56
+ $tokens = $phpcsFile->getTokens();
57
+
58
+ if ($this->isOperator($phpcsFile, $stackPtr) === false) {
59
+ return;
60
+ }
61
+
62
+ $operator = $tokens[$stackPtr]['content'];
63
+
64
+ $checkBefore = true;
65
+ $checkAfter = true;
66
+
67
+ // Skip short ternary.
68
+ if ($tokens[($stackPtr)]['code'] === T_INLINE_ELSE
69
+ && $tokens[($stackPtr - 1)]['code'] === T_INLINE_THEN
70
+ ) {
71
+ $checkBefore = false;
72
+ }
73
+
74
+ // Skip operator with comment on previous line.
75
+ if ($tokens[($stackPtr - 1)]['code'] === T_COMMENT
76
+ && $tokens[($stackPtr - 1)]['line'] < $tokens[$stackPtr]['line']
77
+ ) {
78
+ $checkBefore = false;
79
+ }
80
+
81
+ if (isset($tokens[($stackPtr + 1)]) === true) {
82
+ // Skip short ternary.
83
+ if ($tokens[$stackPtr]['code'] === T_INLINE_THEN
84
+ && $tokens[($stackPtr + 1)]['code'] === T_INLINE_ELSE
85
+ ) {
86
+ $checkAfter = false;
87
+ }
88
+ } else {
89
+ // Skip partial files.
90
+ $checkAfter = false;
91
+ }
92
+
93
+ if ($checkBefore === true && $tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) {
94
+ $error = 'Expected at least 1 space before "%s"; 0 found';
95
+ $data = [$operator];
96
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSpaceBefore', $data);
97
+ if ($fix === true) {
98
+ $phpcsFile->fixer->addContentBefore($stackPtr, ' ');
99
+ }
100
+ }
101
+
102
+ if ($checkAfter === true && $tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
103
+ $error = 'Expected at least 1 space after "%s"; 0 found';
104
+ $data = [$operator];
105
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSpaceAfter', $data);
106
+ if ($fix === true) {
107
+ $phpcsFile->fixer->addContent($stackPtr, ' ');
108
+ }
109
+ }
110
+
111
+ }//end process()
112
+
113
+
114
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $foo = new Foo();
3
+ $foo = new Foo;
4
+ $foo = new Foo\Bar;
5
+ $foo = new Foo\Bar();
6
+ $foo = new Foo /* comment */ ();
7
+
8
+ $foo = new $foo();
9
+ $foo = new $foo;
10
+ $foo = new $$foo();
11
+ $foo = new $$foo;
12
+
13
+ $foo = new self();
14
+ $foo = new self;
15
+ $foo = new static();
16
+ $foo = new static;
17
+
18
+ foo(new class {});
19
+ echo (new Foo())->bar();
20
+ echo (new Foo)->bar();
21
+ echo (new Foo((new Bar)->getBaz()))->bar();
22
+ $foo = (new Foo)::$bar;
23
+
24
+ echo (new Foo((new Bar//comment
25
+ )->getBaz(new Baz /* comment */)))->bar();
26
+
27
+ $foo = new $bar['a']();
28
+ $foo = new $bar['a']['b']();
29
+ $foo = new $bar['a'][$baz['a']['b']]['b']();
30
+ $foo = new $bar['a'] [$baz['a']/* comment */ ['b']]['b'];
31
+
32
+ $a = new self::$transport[$cap_string];
33
+ $renderer = new $this->inline_diff_renderer;
34
+ $a = new ${$varHoldingClassName};
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.inc.fixed ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $foo = new Foo();
3
+ $foo = new Foo();
4
+ $foo = new Foo\Bar();
5
+ $foo = new Foo\Bar();
6
+ $foo = new Foo /* comment */ ();
7
+
8
+ $foo = new $foo();
9
+ $foo = new $foo();
10
+ $foo = new $$foo();
11
+ $foo = new $$foo();
12
+
13
+ $foo = new self();
14
+ $foo = new self();
15
+ $foo = new static();
16
+ $foo = new static();
17
+
18
+ foo(new class {});
19
+ echo (new Foo())->bar();
20
+ echo (new Foo())->bar();
21
+ echo (new Foo((new Bar())->getBaz()))->bar();
22
+ $foo = (new Foo())::$bar;
23
+
24
+ echo (new Foo((new Bar()//comment
25
+ )->getBaz(new Baz() /* comment */)))->bar();
26
+
27
+ $foo = new $bar['a']();
28
+ $foo = new $bar['a']['b']();
29
+ $foo = new $bar['a'][$baz['a']['b']]['b']();
30
+ $foo = new $bar['a'] [$baz['a']/* comment */ ['b']]['b']();
31
+
32
+ $a = new self::$transport[$cap_string]();
33
+ $renderer = new $this->inline_diff_renderer();
34
+ $a = new ${$varHoldingClassName}();
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Classes/ClassInstantiationUnitTest.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Unit test class for the ClassInstantiation sniff.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Classes;
11
+
12
+ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
13
+
14
+ class ClassInstantiationUnitTest extends AbstractSniffUnitTest
15
+ {
16
+
17
+
18
+ /**
19
+ * Returns the lines where errors should occur.
20
+ *
21
+ * The key of the array should represent the line number and the value
22
+ * should represent the number of errors that should occur on that line.
23
+ *
24
+ * @return array<int, int>
25
+ */
26
+ public function getErrorList()
27
+ {
28
+ return [
29
+ 3 => 1,
30
+ 4 => 1,
31
+ 9 => 1,
32
+ 11 => 1,
33
+ 14 => 1,
34
+ 16 => 1,
35
+ 20 => 1,
36
+ 21 => 1,
37
+ 22 => 1,
38
+ 24 => 1,
39
+ 25 => 1,
40
+ 30 => 1,
41
+ 32 => 1,
42
+ 33 => 1,
43
+ 34 => 1,
44
+ ];
45
+
46
+ }//end getErrorList()
47
+
48
+
49
+ /**
50
+ * Returns the lines where warnings should occur.
51
+ *
52
+ * The key of the array should represent the line number and the value
53
+ * should represent the number of warnings that should occur on that line.
54
+ *
55
+ * @return array<int, int>
56
+ */
57
+ public function getWarningList()
58
+ {
59
+ return [];
60
+
61
+ }//end getWarningList()
62
+
63
+
64
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.inc ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $bar = (bool) $foo;
3
+ $bar = (boolean) $foo;
4
+ $bar = (Bool) $foo;
5
+ $bar = (BOOLEAN) $foo;
6
+ $bar = (int) $foo;
7
+ $bar = (integer) $foo;
8
+ $bar = (INT) $foo;
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.inc.fixed ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $bar = (bool) $foo;
3
+ $bar = (bool) $foo;
4
+ $bar = (Bool) $foo;
5
+ $bar = (bool) $foo;
6
+ $bar = (int) $foo;
7
+ $bar = (int) $foo;
8
+ $bar = (INT) $foo;
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Keywords/ShortFormTypeKeywordsUnitTest.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Unit test class for the ShortFormTypeKeywords sniff.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Keywords;
11
+
12
+ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
13
+
14
+ class ShortFormTypeKeywordsUnitTest extends AbstractSniffUnitTest
15
+ {
16
+
17
+
18
+ /**
19
+ * Returns the lines where errors should occur.
20
+ *
21
+ * The key of the array should represent the line number and the value
22
+ * should represent the number of errors that should occur on that line.
23
+ *
24
+ * @return array<int, int>
25
+ */
26
+ public function getErrorList()
27
+ {
28
+ return [
29
+ 3 => 1,
30
+ 5 => 1,
31
+ 7 => 1,
32
+ ];
33
+
34
+ }//end getErrorList()
35
+
36
+
37
+ /**
38
+ * Returns the lines where warnings should occur.
39
+ *
40
+ * The key of the array should represent the line number and the value
41
+ * should represent the number of warnings that should occur on that line.
42
+ *
43
+ * @return array<int, int>
44
+ */
45
+ public function getWarningList()
46
+ {
47
+ return [];
48
+
49
+ }//end getWarningList()
50
+
51
+
52
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.inc ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ use Vendor\Package\SomeNamespace\{
3
+ SubnamespaceOne\ClassA,
4
+ SubnamespaceOne\ClassB,
5
+ SubnamespaceTwo\ClassY,
6
+ ClassZ,
7
+ };
8
+
9
+ use Vendor\Package\SomeNamespace\{
10
+ SubnamespaceOne\AnotherNamespace\ClassA,
11
+ SubnamespaceOne\ClassB,
12
+ ClassZ,
13
+ };
14
+
15
+ use Vendor\Package\SomeNamespace\{
16
+ SubnamespaceOne /* comment */
17
+ \AnotherNamespace // comment
18
+ \ClassA,
19
+ SubnamespaceOne
20
+ \AnotherNamespace
21
+ \ClassB,
22
+ ClassZ,
23
+ };
24
+
25
+ // phpcs:set PSR12.Namespaces.CompoundNamespaceDepth maxDepth 3
26
+
27
+ use Vendor\Package\SomeNamespace\{
28
+ SubnamespaceOne\AnotherNamespace\ClassA,
29
+ SubnamespaceOne\ClassB,
30
+ ClassZ,
31
+ };
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Namespaces/CompoundNamespaceDepthUnitTest.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Unit test class for the CompoundNamespaceDepth sniff.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Namespaces;
11
+
12
+ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
13
+
14
+ class CompoundNamespaceDepthUnitTest extends AbstractSniffUnitTest
15
+ {
16
+
17
+
18
+ /**
19
+ * Returns the lines where errors should occur.
20
+ *
21
+ * The key of the array should represent the line number and the value
22
+ * should represent the number of errors that should occur on that line.
23
+ *
24
+ * @return array<int, int>
25
+ */
26
+ public function getErrorList()
27
+ {
28
+ return [
29
+ 10 => 1,
30
+ 18 => 1,
31
+ 21 => 1,
32
+ ];
33
+
34
+ }//end getErrorList()
35
+
36
+
37
+ /**
38
+ * Returns the lines where warnings should occur.
39
+ *
40
+ * The key of the array should represent the line number and the value
41
+ * should represent the number of warnings that should occur on that line.
42
+ *
43
+ * @return array<int, int>
44
+ */
45
+ public function getWarningList()
46
+ {
47
+ return [];
48
+
49
+ }//end getWarningList()
50
+
51
+
52
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.inc ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ($a ===$b) {
3
+ $foo = $bar ??$a?? $b;
4
+ } elseif ($a> $b) {
5
+ $variable =$foo ? 'foo' :'bar';
6
+ $variable.='text'.'text';
7
+ }
8
+
9
+ $foo+= $a&$b;
10
+ $foo = $a|$b;
11
+ $foo =$a^$b;
12
+ $foo = ~$a;
13
+ $foo *=$a<<$b;
14
+ $foo = $a>>$b;
15
+
16
+ function foo(&$a,& $b) {}
17
+
18
+ $foo = $a and$b;
19
+ $foo = $a or $b;
20
+ $foo = $a xor$b;
21
+ $foo = !$a;
22
+ $foo = $a&&$b;
23
+ $foo = $a||$b;
24
+
25
+ $foo = $a instanceof Foo;
26
+ $foo = $a instanceof$b;
27
+
28
+ $foo .= 'hi'
29
+ .= 'there';
30
+
31
+ $foo .= 'hi'
32
+ .= 'there';
33
+
34
+ $foo .= 'hi' // comment
35
+ .= 'there';
36
+
37
+ $foo/*comment*/=/*comment*/$a/*comment*/and/*comment*/$b;
38
+
39
+ $foo .=//comment
40
+ 'string' .=/*comment*/
41
+ 'string';
42
+
43
+ $foo = $foo ?: 'bar';
44
+ $foo = $foo?:'bar';
45
+
46
+ try {
47
+ } catch (ExceptionType1|ExceptionType2 $e) {
48
+ }
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.inc.fixed ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ($a === $b) {
3
+ $foo = $bar ?? $a ?? $b;
4
+ } elseif ($a > $b) {
5
+ $variable = $foo ? 'foo' : 'bar';
6
+ $variable .= 'text' . 'text';
7
+ }
8
+
9
+ $foo += $a & $b;
10
+ $foo = $a | $b;
11
+ $foo = $a ^ $b;
12
+ $foo = ~$a;
13
+ $foo *= $a << $b;
14
+ $foo = $a >> $b;
15
+
16
+ function foo(&$a,& $b) {}
17
+
18
+ $foo = $a and $b;
19
+ $foo = $a or $b;
20
+ $foo = $a xor $b;
21
+ $foo = !$a;
22
+ $foo = $a && $b;
23
+ $foo = $a || $b;
24
+
25
+ $foo = $a instanceof Foo;
26
+ $foo = $a instanceof $b;
27
+
28
+ $foo .= 'hi'
29
+ .= 'there';
30
+
31
+ $foo .= 'hi'
32
+ .= 'there';
33
+
34
+ $foo .= 'hi' // comment
35
+ .= 'there';
36
+
37
+ $foo/*comment*/ = /*comment*/$a/*comment*/ and /*comment*/$b;
38
+
39
+ $foo .= //comment
40
+ 'string' .= /*comment*/
41
+ 'string';
42
+
43
+ $foo = $foo ?: 'bar';
44
+ $foo = $foo ?: 'bar';
45
+
46
+ try {
47
+ } catch (ExceptionType1 | ExceptionType2 $e) {
48
+ }
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/Tests/Operators/OperatorSpacingUnitTest.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Unit test class for the OperatorSpacing sniff.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Standards\PSR12\Tests\Operators;
11
+
12
+ use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
13
+
14
+ class OperatorSpacingUnitTest extends AbstractSniffUnitTest
15
+ {
16
+
17
+
18
+ /**
19
+ * Returns the lines where errors should occur.
20
+ *
21
+ * The key of the array should represent the line number and the value
22
+ * should represent the number of errors that should occur on that line.
23
+ *
24
+ * @return array<int, int>
25
+ */
26
+ public function getErrorList()
27
+ {
28
+ return [
29
+ 2 => 1,
30
+ 3 => 2,
31
+ 4 => 1,
32
+ 5 => 2,
33
+ 6 => 4,
34
+ 9 => 3,
35
+ 10 => 2,
36
+ 11 => 3,
37
+ 13 => 3,
38
+ 14 => 2,
39
+ 18 => 1,
40
+ 20 => 1,
41
+ 22 => 2,
42
+ 23 => 2,
43
+ 26 => 1,
44
+ 37 => 4,
45
+ 39 => 1,
46
+ 40 => 1,
47
+ 44 => 2,
48
+ 47 => 2,
49
+ ];
50
+
51
+ }//end getErrorList()
52
+
53
+
54
+ /**
55
+ * Returns the lines where warnings should occur.
56
+ *
57
+ * The key of the array should represent the line number and the value
58
+ * should represent the number of warnings that should occur on that line.
59
+ *
60
+ * @return array<int, int>
61
+ */
62
+ public function getWarningList()
63
+ {
64
+ return [];
65
+
66
+ }//end getWarningList()
67
+
68
+
69
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/PSR12/ruleset.xml ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <ruleset name="PSR12">
3
+ <description>The PSR-12 coding standard.</description>
4
+ <arg name="tab-width" value="4"/>
5
+
6
+ <!-- 2. General -->
7
+
8
+ <!-- 2.1 Basic Coding Standard -->
9
+
10
+ <!-- Code MUST follow all rules outlined in PSR-1. -->
11
+ <rule ref="PSR1"/>
12
+
13
+ <!-- 2.2 Files -->
14
+
15
+ <!-- All PHP files MUST use the Unix LF (linefeed) line ending only. -->
16
+ <rule ref="Generic.Files.LineEndings">
17
+ <properties>
18
+ <property name="eolChar" value="\n"/>
19
+ </properties>
20
+ </rule>
21
+
22
+ <!-- All PHP files MUST end with a non-blank line, terminated with a single LF. -->
23
+ <rule ref="PSR2.Files.EndFileNewline"/>
24
+
25
+ <!-- The closing ?> tag MUST be omitted from files containing only PHP. -->
26
+ <rule ref="PSR2.Files.ClosingTag"/>
27
+
28
+ <!-- 2.3 Lines -->
29
+
30
+ <!-- There MUST NOT be a hard limit on line length.
31
+ The soft limit on line length MUST be 120 characters.
32
+ Lines SHOULD NOT be longer than 80 characters; lines longer than that SHOULD be split into multiple subsequent lines of no more than 80 characters each. -->
33
+ <rule ref="Generic.Files.LineLength">
34
+ <properties>
35
+ <property name="lineLimit" value="120"/>
36
+ <property name="absoluteLineLimit" value="0"/>
37
+ </properties>
38
+ </rule>
39
+
40
+ <!-- There MUST NOT be trailing whitespace at the end of lines.
41
+ Blank lines MAY be added to improve readability and to indicate related blocks of code except where explicitly forbidden. -->
42
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace">
43
+ <properties>
44
+ <property name="ignoreBlankLines" value="true"/>
45
+ </properties>
46
+ </rule>
47
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile">
48
+ <severity>0</severity>
49
+ </rule>
50
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile">
51
+ <severity>0</severity>
52
+ </rule>
53
+ <rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines">
54
+ <severity>0</severity>
55
+ </rule>
56
+
57
+ <!-- There MUST NOT be more than one statement per line. -->
58
+ <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
59
+
60
+ <!-- 2.4 Indenting -->
61
+
62
+ <!-- Code MUST use an indent of 4 spaces for each indent level, and MUST NOT use tabs for indenting. -->
63
+ <rule ref="Generic.WhiteSpace.ScopeIndent">
64
+ <properties>
65
+ <property name="ignoreIndentationTokens" type="array">
66
+ <element value="T_COMMENT"/>
67
+ <element value="T_DOC_COMMENT_OPEN_TAG"/>
68
+ </property>
69
+ </properties>
70
+ </rule>
71
+ <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
72
+
73
+ <!-- 2.5 Keywords and Types -->
74
+
75
+ <!-- All PHP reserved keywords and types [1][2] MUST be in lower case.
76
+ Any new types and keywords added to future PHP versions MUST be in lower case. -->
77
+ <rule ref="Generic.PHP.LowerCaseKeyword"/>
78
+ <rule ref="Generic.PHP.LowerCaseConstant"/>
79
+ <rule ref="Generic.PHP.LowerCaseType"/>
80
+
81
+ <!-- Short form of type keywords MUST be used i.e. bool instead of boolean, int instead of integer etc. -->
82
+ <!-- checked by PSR12.Keywords.ShortFormTypeKeywords -->
83
+
84
+ <!-- 3. Declare Statements, Namespace, and Import Statements -->
85
+
86
+ <!-- The header of a PHP file may consist of a number of different blocks. If present, each of the blocks below MUST be separated by a single blank line, and MUST NOT contain a blank line. Each block MUST be in the order listed below, although blocks that are not relevant may be omitted.
87
+
88
+ Opening PHP tag.
89
+ File-level docblock.
90
+ One or more declare statements.
91
+ The namespace declaration of the file.
92
+ One or more class-based use import statements.
93
+ One or more function-based use import statements.
94
+ One or more constant-based use import statements.
95
+ The remainder of the code in the file.
96
+ When a file contains a mix of HTML and PHP, any of the above sections may still be used. If so, they MUST be present at the top of the file, even if the remainder of the code consists a closing PHP tag and then a mixture of HTML and PHP. -->
97
+
98
+ <!-- When the opening PHP tag is on the first line of the file, it MUST be on its own line with no other statements unless it is a file containing markup outside of PHP opening and closing tags. -->
99
+
100
+ <!-- Import statements MUST never begin with a leading backslash as they must always be fully qualified. -->
101
+
102
+ <!-- Compound namespaces with a depth of more than two MUST NOT be used. -->
103
+ <!-- checked by PSR12.Namespaces.CompoundNamespaceDepth -->
104
+
105
+ <!-- When wishing to declare strict types in files containing markup outside PHP opening and closing tags MUST, on the first line, include an opening PHP tag, the strict types declaration and closing tag. -->
106
+
107
+ <!-- Declare statements MUST contain no spaces and MUST be exactly declare(strict_types=1) (with an optional semi-colon terminator). -->
108
+
109
+ <!-- Block declare statements are allowed and MUST be formatted as below. -->
110
+
111
+ <!-- 4. Classes, Properties, and Methods -->
112
+
113
+ <!-- Any closing brace MUST NOT be followed by any comment or statement on the same line. -->
114
+
115
+ <!-- When instantiating a new class, parenthesis MUST always be present even when there are no arguments passed to the constructor. -->
116
+ <!-- checked by PSR12.Classes.ClassInstantiation -->
117
+
118
+ <!-- 4.1 Extends and Implements -->
119
+
120
+ <!-- The extends and implements keywords MUST be declared on the same line as the class name. -->
121
+ <!-- The opening brace for the class MUST go on its own line; the closing brace for the class MUST go on the next line after the body. -->
122
+ <!-- Opening braces MUST be on their own line and MUST NOT be preceded or followed by a blank line. -->
123
+ <!-- Closing braces MUST be on their own line and MUST NOT be preceded by a blank line. -->
124
+ <!-- Lists of implements and extends MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one interface per line. -->
125
+ <rule ref="PSR2.Classes.ClassDeclaration"/>
126
+
127
+ <!-- 4.2 Using traits -->
128
+
129
+ <!-- The use keyword used inside the classes to implement traits MUST be declared on the next line after the opening brace. -->
130
+
131
+ <!-- Each individual Trait that is imported into a class MUST be included one-per-line, and each inclusion MUST have its own use import statement. -->
132
+
133
+ <!-- When the class has nothing after the use import statement, the class closing brace MUST be on the next line after the use import statement. Otherwise it MUST have a blank line after the use import statement. -->
134
+
135
+ <!-- When using the insteadof and as operators they must be used as follows taking note of indentation, spacing and new lines. -->
136
+
137
+ <!-- 4.3 Properties and Constants -->
138
+
139
+ <!-- Visibility MUST be declared on all properties. -->
140
+ <!-- The var keyword MUST NOT be used to declare a property. -->
141
+ <!-- There MUST NOT be more than one property declared per statement. -->
142
+ <!-- Property names MUST NOT be prefixed with a single underscore to indicate protected or private visibility. -->
143
+ <rule ref="PSR2.Classes.PropertyDeclaration"/>
144
+
145
+ <!-- Visibility MUST be declared on all constants if your project PHP minimum version supports constant visibilities (PHP 7.1 or later). -->
146
+
147
+ <!-- 4.4 Methods and Functions -->
148
+
149
+ <!-- Visibility MUST be declared on all methods. -->
150
+ <rule ref="Squiz.Scope.MethodScope"/>
151
+ <rule ref="Squiz.WhiteSpace.ScopeKeywordSpacing"/>
152
+
153
+ <!-- Method names MUST NOT be prefixed with a single underscore to indicate protected or private visibility. That is, an underscore prefix explicitly has no meaning. -->
154
+ <rule ref="PSR2.Methods.MethodDeclaration"/>
155
+ <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
156
+ <type>error</type>
157
+ <message>Method name "%s" must not be prefixed with an underscore to indicate visibility</message>
158
+ </rule>
159
+
160
+ <!-- Method and function names MUST NOT be declared with a space after the method name. The opening brace MUST go on its own line, and the closing brace MUST go on the next line following the body. There MUST NOT be a space after the opening parenthesis, and there MUST NOT be a space before the closing parenthesis. -->
161
+ <rule ref="PSR2.Methods.FunctionClosingBrace"/>
162
+ <rule ref="Squiz.Functions.FunctionDeclaration"/>
163
+ <rule ref="Squiz.Functions.LowercaseFunctionKeywords"/>
164
+
165
+ <!-- 4.5 Method and function Arguments -->
166
+
167
+ <!-- In the argument list, there MUST NOT be a space before each comma, and there MUST be one space after each comma. -->
168
+ <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
169
+ <properties>
170
+ <property name="equalsSpacing" value="1"/>
171
+ </properties>
172
+ </rule>
173
+ <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint">
174
+ <severity>0</severity>
175
+ </rule>
176
+
177
+ <!-- Method and function arguments with default values MUST go at the end of the argument list. -->
178
+ <rule ref="PEAR.Functions.ValidDefaultValue"/>
179
+
180
+ <!-- Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line. When the argument list is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them. -->
181
+ <rule ref="Squiz.Functions.MultiLineFunctionDeclaration"/>
182
+
183
+ <!-- When you have a return type declaration present there MUST be one space after the colon followed by the type declaration. The colon and declaration MUST be on the same line as the argument list closing parentheses with no spaces between the two characters. -->
184
+
185
+ <!-- In nullable type declarations there MUST NOT be a space between the question mark and the type. -->
186
+
187
+ <!-- 4.6 abstract, final, and static -->
188
+
189
+ <!-- When present, the abstract and final declarations MUST precede the visibility declaration. -->
190
+ <!-- When present, the static declaration MUST come after the visibility declaration. -->
191
+ <!-- checked by PSR2.Methods.MethodDeclaration included above -->
192
+
193
+ <!-- 4.7 Method and Function Calls -->
194
+
195
+ <!-- When making a method or function call, there MUST NOT be a space between the method or function name and the opening parenthesis, there MUST NOT be a space after the opening parenthesis, and there MUST NOT be a space before the closing parenthesis. In the argument list, there MUST NOT be a space before each comma, and there MUST be one space after each comma. -->
196
+ <!-- Argument lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument per line. A single argument being split across multiple lines (as might be the case with an anonymous function or array) does not constitute splitting the argument list itself. -->
197
+ <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
198
+ <rule ref="PSR2.Methods.FunctionCallSignature"/>
199
+ <rule ref="PSR2.Methods.FunctionCallSignature.SpaceAfterCloseBracket">
200
+ <severity>0</severity>
201
+ </rule>
202
+ <rule ref="PSR2.Methods.FunctionCallSignature.OpeningIndent">
203
+ <severity>0</severity>
204
+ </rule>
205
+
206
+ <!-- 5. Control Structures -->
207
+
208
+ <!-- The general style rules for control structures are as follows:
209
+ There MUST be one space after the control structure keyword
210
+ There MUST NOT be a space after the opening parenthesis
211
+ There MUST NOT be a space before the closing parenthesis
212
+ There MUST be one space between the closing parenthesis and the opening brace
213
+ The structure body MUST be indented once
214
+ The closing brace MUST be on the next line after the body
215
+ The body of each structure MUST be enclosed by braces. This standardizes how the structures look, and reduces the likelihood of introducing errors as new lines get added to the body. -->
216
+ <rule ref="Squiz.ControlStructures.ControlSignature"/>
217
+ <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingAfterOpen" />
218
+ <rule ref="Squiz.WhiteSpace.ControlStructureSpacing.SpacingBeforeClose" />
219
+ <rule ref="Squiz.WhiteSpace.ScopeClosingBrace"/>
220
+ <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration"/>
221
+ <rule ref="Squiz.ControlStructures.ForLoopDeclaration"/>
222
+ <rule ref="Squiz.ControlStructures.LowercaseDeclaration"/>
223
+ <rule ref="PSR2.ControlStructures.ControlStructureSpacing"/>
224
+ <rule ref="Generic.ControlStructures.InlineControlStructure"/>
225
+
226
+ <!-- exclude this message as it is already checked in Generic.PHP.LowerCaseKeyword -->
227
+ <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">
228
+ <severity>0</severity>
229
+ </rule>
230
+
231
+ <!-- 5.1 if, elseif, else -->
232
+
233
+ <!-- else and elseif are on the same line as the closing brace from the earlier body. -->
234
+
235
+ <!-- The keyword elseif SHOULD be used instead of else if so that all control keywords look like single words. -->
236
+ <rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
237
+
238
+ <!-- Expressions in parentheses MAY be split across multiple lines, where each subsequent line is indented at least once. When doing so, the first condition MUST be on the next line. The closing parenthesis and opening brace MUST be placed together on their own line with one space between them. Boolean operators between conditions MUST always be at the beginning or at the end of the line, not a mix of both. -->
239
+
240
+ <!-- 5.2 switch, case -->
241
+
242
+ <!-- The case statement MUST be indented once from switch, and the break keyword (or other terminating keywords) MUST be indented at the same level as the case body. There MUST be a comment such as // no break when fall-through is intentional in a non-empty case body. -->
243
+ <rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
244
+
245
+ <!-- Expressions in parentheses MAY be split across multiple lines, where each subsequent line is indented at least once. When doing so, the first condition MUST be on the next line. The closing parenthesis and opening brace MUST be placed together on their own line with one space between them. Boolean operators between conditions MUST always be at the beginning or at the end of the line, not a mix of both. -->
246
+
247
+ <!-- 5.3 while, do while -->
248
+
249
+ <!-- Expressions in parentheses MAY be split across multiple lines, where each subsequent line is indented at least once. When doing so, the first condition MUST be on the next line. The closing parenthesis and opening brace MUST be placed together on their own line. Boolean operators between conditions MUST always be at the beginning or at the end of the line, not a mix of both. -->
250
+
251
+ <!-- 5.4 for -->
252
+
253
+ <!-- Expressions in parentheses MAY be split across multiple lines, where each subsequent line is indented at least once. When doing so, the first expression MUST be on the next line. The closing parenthesis and opening brace MUST be placed together on their own line with one space between them. -->
254
+
255
+ <!-- 5.5 foreach -->
256
+
257
+ <!-- 5.6 try, catch, finally -->
258
+
259
+ <!-- 6. Operators -->
260
+
261
+ <!-- All binary and ternary (but not unary) operators MUST be preceded and followed by at least one space. This includes all arithmetic, comparison, assignment, bitwise, logical (excluding ! which is unary), string concatenation, type operators, trait operators (insteadof and as), and the single pipe operator (e.g. ExceptionType1 | ExceptionType2 $e). -->
262
+ <!-- Other operators are left undefined. -->
263
+ <!-- checked by PSR12.Operators.OperatorSpacing -->
264
+
265
+ <!-- 7. Closures -->
266
+
267
+ <!-- Closures MUST be declared with a space after the function keyword, and a space before and after the use keyword. -->
268
+ <!-- The opening brace MUST go on the same line, and the closing brace MUST go on the next line following the body. -->
269
+ <!-- There MUST NOT be a space after the opening parenthesis of the argument list or variable list, and there MUST NOT be a space before the closing parenthesis of the argument list or variable list. -->
270
+ <!-- In the argument list and variable list, there MUST NOT be a space before each comma, and there MUST be one space after each comma. -->
271
+ <!-- Closure arguments with default values MUST go at the end of the argument list. -->
272
+ <!-- Argument lists and variable lists MAY be split across multiple lines, where each subsequent line is indented once. When doing so, the first item in the list MUST be on the next line, and there MUST be only one argument or variable per line. -->
273
+ <!-- When the ending list (whether of arguments or variables) is split across multiple lines, the closing parenthesis and opening brace MUST be placed together on their own line with one space between them. -->
274
+ <!-- checked by Squiz.Functions.MultiLineFunctionDeclaration -->
275
+
276
+ <!-- 8. Anonymous Classes -->
277
+
278
+ <!-- Anonymous Classes MUST follow the same guidelines and principles as closures in the above section. -->
279
+
280
+ <!-- The opening parenthesis MAY be on the same line as the class keyword so long as the list of implements interfaces does not wrap. If the list of interfaces wraps, the parenthesis MUST be placed on the line immediately following the last interface. -->
281
+
282
+ </ruleset>
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php CHANGED
@@ -41,8 +41,9 @@ class NamespaceDeclarationSniff implements Sniff
41
  {
42
  $tokens = $phpcsFile->getTokens();
43
 
44
- for ($i = ($stackPtr + 1); $i < ($phpcsFile->numTokens - 1); $i++) {
45
- if ($tokens[$i]['line'] === $tokens[$stackPtr]['line']) {
 
46
  continue;
47
  }
48
 
41
  {
42
  $tokens = $phpcsFile->getTokens();
43
 
44
+ $end = $phpcsFile->findEndOfStatement($stackPtr);
45
+ for ($i = ($end + 1); $i < ($phpcsFile->numTokens - 1); $i++) {
46
+ if ($tokens[$i]['line'] === $tokens[$end]['line']) {
47
  continue;
48
  }
49
 
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php CHANGED
@@ -62,54 +62,105 @@ class UseDeclarationSniff implements Sniff
62
  && $tokens[$next]['code'] !== T_CLOSE_TAG
63
  ) {
64
  $error = 'There must be one USE keyword per declaration';
65
- $fix = $phpcsFile->addFixableError($error, $stackPtr, 'MultipleDeclarations');
66
- if ($fix === true) {
67
- if ($tokens[$next]['code'] === T_COMMA) {
68
- $phpcsFile->fixer->replaceToken($next, ';'.$phpcsFile->eolChar.'use ');
69
- } else {
70
- $baseUse = rtrim($phpcsFile->getTokensAsString($stackPtr, ($next - $stackPtr)));
71
- $closingCurly = $phpcsFile->findNext(T_CLOSE_USE_GROUP, ($next + 1));
72
 
73
- $phpcsFile->fixer->beginChangeset();
74
-
75
- // Remove base use statement.
76
- for ($i = $stackPtr; $i <= $next; $i++) {
77
- $phpcsFile->fixer->replaceToken($i, '');
 
 
 
 
 
 
 
78
  }
79
 
80
- // Convert grouped use statements into full use statements.
81
- do {
82
- $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), $closingCurly, true);
 
 
 
 
 
 
 
 
 
 
 
83
 
84
- $whitespace = $phpcsFile->findPrevious(T_WHITESPACE, ($next - 1), null, true);
85
- for ($i = ($whitespace + 1); $i < $next; $i++) {
86
  $phpcsFile->fixer->replaceToken($i, '');
87
  }
88
 
89
- if ($tokens[$next]['code'] === T_CONST || $tokens[$next]['code'] === T_FUNCTION) {
90
- $phpcsFile->fixer->addContentBefore($next, 'use ');
91
- $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), $closingCurly, true);
92
- $phpcsFile->fixer->addContentBefore($next, str_replace('use ', '', $baseUse));
93
- } else {
94
- $phpcsFile->fixer->addContentBefore($next, $baseUse);
95
  }
96
 
97
- $next = $phpcsFile->findNext(T_COMMA, ($next + 1), $closingCurly);
98
- if ($next !== false) {
99
- $phpcsFile->fixer->replaceToken($next, ';'.$phpcsFile->eolChar);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  }
101
- } while ($next !== false);
102
 
103
- $phpcsFile->fixer->replaceToken($closingCurly, '');
104
-
105
- // Remove any trailing whitespace.
106
- $next = $phpcsFile->findNext(T_SEMICOLON, $closingCurly);
107
- $whitespace = $phpcsFile->findPrevious(T_WHITESPACE, ($closingCurly - 1), null, true);
108
- for ($i = ($whitespace + 1); $i < $next; $i++) {
109
- $phpcsFile->fixer->replaceToken($i, '');
110
- }
111
 
112
- $phpcsFile->fixer->endChangeset();
 
113
  }//end if
114
  }//end if
115
  }//end if
@@ -122,6 +173,12 @@ class UseDeclarationSniff implements Sniff
122
  $error = 'USE declarations must go after the first namespace declaration';
123
  $phpcsFile->addError($error, $stackPtr, 'UseAfterNamespace');
124
  }
 
 
 
 
 
 
125
  }
126
 
127
  // Only interested in the last USE statement from here onwards.
@@ -137,11 +194,18 @@ class UseDeclarationSniff implements Sniff
137
  return;
138
  }
139
 
140
- $end = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1));
141
  if ($end === false) {
142
  return;
143
  }
144
 
 
 
 
 
 
 
 
145
  // Find either the start of the next line or the beginning of the next statement,
146
  // whichever comes first.
147
  for ($end = ++$end; $end < $phpcsFile->numTokens; $end++) {
62
  && $tokens[$next]['code'] !== T_CLOSE_TAG
63
  ) {
64
  $error = 'There must be one USE keyword per declaration';
 
 
 
 
 
 
 
65
 
66
+ if ($tokens[$next]['code'] === T_COMMA) {
67
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'MultipleDeclarations');
68
+ if ($fix === true) {
69
+ switch ($tokens[($stackPtr + 2)]['content']) {
70
+ case 'const':
71
+ $baseUse = 'use const';
72
+ break;
73
+ case 'function':
74
+ $baseUse = 'use function';
75
+ break;
76
+ default:
77
+ $baseUse = 'use';
78
  }
79
 
80
+ $phpcsFile->fixer->replaceToken($next, ';'.$phpcsFile->eolChar.$baseUse);
81
+ }
82
+ } else {
83
+ $closingCurly = $phpcsFile->findNext(T_CLOSE_USE_GROUP, ($next + 1));
84
+ if ($closingCurly === false) {
85
+ // Parse error or live coding. Not auto-fixable.
86
+ $phpcsFile->addError($error, $stackPtr, 'MultipleDeclarations');
87
+ } else {
88
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'MultipleDeclarations');
89
+ if ($fix === true) {
90
+ $baseUse = rtrim($phpcsFile->getTokensAsString($stackPtr, ($next - $stackPtr)));
91
+ $lastNonWhitespace = $phpcsFile->findPrevious(T_WHITESPACE, ($closingCurly - 1), null, true);
92
+
93
+ $phpcsFile->fixer->beginChangeset();
94
 
95
+ // Remove base use statement.
96
+ for ($i = $stackPtr; $i <= $next; $i++) {
97
  $phpcsFile->fixer->replaceToken($i, '');
98
  }
99
 
100
+ if (preg_match('`^[\r\n]+$`', $tokens[($next + 1)]['content']) === 1) {
101
+ $phpcsFile->fixer->replaceToken(($next + 1), '');
 
 
 
 
102
  }
103
 
104
+ // Convert grouped use statements into full use statements.
105
+ do {
106
+ $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), $closingCurly, true);
107
+ if ($next === false) {
108
+ // Group use statement with trailing comma after last item.
109
+ break;
110
+ }
111
+
112
+ $nonWhitespace = $phpcsFile->findPrevious(T_WHITESPACE, ($next - 1), null, true);
113
+ for ($i = ($nonWhitespace + 1); $i < $next; $i++) {
114
+ if (preg_match('`^[\r\n]+$`', $tokens[$i]['content']) === 1) {
115
+ // Preserve new lines.
116
+ continue;
117
+ }
118
+
119
+ $phpcsFile->fixer->replaceToken($i, '');
120
+ }
121
+
122
+ if ($tokens[$next]['code'] === T_CONST || $tokens[$next]['code'] === T_FUNCTION) {
123
+ $phpcsFile->fixer->addContentBefore($next, 'use ');
124
+ $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), $closingCurly, true);
125
+ $phpcsFile->fixer->addContentBefore($next, str_replace('use ', '', $baseUse));
126
+ } else {
127
+ $phpcsFile->fixer->addContentBefore($next, $baseUse);
128
+ }
129
+
130
+ $next = $phpcsFile->findNext(T_COMMA, ($next + 1), $closingCurly);
131
+ if ($next !== false) {
132
+ $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($next + 1), $closingCurly, true);
133
+ if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['line'] === $tokens[$next]['line']) {
134
+ $prevNonWhitespace = $phpcsFile->findPrevious(T_WHITESPACE, ($nextNonEmpty - 1), $next, true);
135
+ if ($prevNonWhitespace === $next) {
136
+ $phpcsFile->fixer->replaceToken($next, ';'.$phpcsFile->eolChar);
137
+ } else {
138
+ $phpcsFile->fixer->replaceToken($next, ';');
139
+ $phpcsFile->fixer->addNewline($prevNonWhitespace);
140
+ }
141
+ } else {
142
+ // Last item with trailing comma or next item already on new line.
143
+ $phpcsFile->fixer->replaceToken($next, ';');
144
+ }
145
+ } else {
146
+ // Last item without trailing comma.
147
+ $phpcsFile->fixer->addContent($lastNonWhitespace, ';');
148
+ }
149
+ } while ($next !== false);
150
+
151
+ // Remove closing curly,semi-colon and any whitespace between last child and closing curly.
152
+ $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($closingCurly + 1), null, true);
153
+ if ($next === false || $tokens[$next]['code'] !== T_SEMICOLON) {
154
+ // Parse error, forgotten semi-colon.
155
+ $next = $closingCurly;
156
  }
 
157
 
158
+ for ($i = ($lastNonWhitespace + 1); $i <= $next; $i++) {
159
+ $phpcsFile->fixer->replaceToken($i, '');
160
+ }
 
 
 
 
 
161
 
162
+ $phpcsFile->fixer->endChangeset();
163
+ }//end if
164
  }//end if
165
  }//end if
166
  }//end if
173
  $error = 'USE declarations must go after the first namespace declaration';
174
  $phpcsFile->addError($error, $stackPtr, 'UseAfterNamespace');
175
  }
176
+ } else {
177
+ $next = $phpcsFile->findNext(T_NAMESPACE, ($stackPtr + 1));
178
+ if ($next !== false) {
179
+ $error = 'USE declarations must go after the namespace declaration';
180
+ $phpcsFile->addError($error, $stackPtr, 'UseBeforeNamespace');
181
+ }
182
  }
183
 
184
  // Only interested in the last USE statement from here onwards.
194
  return;
195
  }
196
 
197
+ $end = $phpcsFile->findNext([T_SEMICOLON, T_CLOSE_USE_GROUP, T_CLOSE_TAG], ($stackPtr + 1));
198
  if ($end === false) {
199
  return;
200
  }
201
 
202
+ if ($tokens[$end]['code'] === T_CLOSE_USE_GROUP) {
203
+ $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($end + 1), null, true);
204
+ if ($tokens[$nextNonEmpty]['code'] === T_SEMICOLON) {
205
+ $end = $nextNonEmpty;
206
+ }
207
+ }
208
+
209
  // Find either the start of the next line or the beginning of the next statement,
210
  // whichever comes first.
211
  for ($end = ++$end; $end < $phpcsFile->numTokens; $end++) {
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Files/EndFileNewlineUnitTest.php CHANGED
@@ -32,13 +32,8 @@ class EndFileNewlineUnitTest extends AbstractSniffUnitTest
32
  case 'EndFileNewlineUnitTest.3.inc':
33
  case 'EndFileNewlineUnitTest.6.inc':
34
  case 'EndFileNewlineUnitTest.7.inc':
35
- return [2 => 1];
36
  case 'EndFileNewlineUnitTest.9.inc':
37
  case 'EndFileNewlineUnitTest.10.inc':
38
- // HHVM just removes the entire comment token, as if it was never there.
39
- if (defined('HHVM_VERSION') === true) {
40
- return [];
41
- }
42
  return [2 => 1];
43
  default:
44
  return [];
32
  case 'EndFileNewlineUnitTest.3.inc':
33
  case 'EndFileNewlineUnitTest.6.inc':
34
  case 'EndFileNewlineUnitTest.7.inc':
 
35
  case 'EndFileNewlineUnitTest.9.inc':
36
  case 'EndFileNewlineUnitTest.10.inc':
 
 
 
 
37
  return [2 => 1];
38
  default:
39
  return [];
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.inc CHANGED
@@ -11,4 +11,12 @@ namespace Vendor\Package;
11
 
12
  use BarClass as Bar;
13
 
 
 
 
 
 
 
 
 
14
  namespace Vendor\Package;
11
 
12
  use BarClass as Bar;
13
 
14
+ namespace Vendor
15
+ \Package;
16
+
17
+ namespace Vendor\
18
+ Package;
19
+ namespace Vendor\
20
+
21
+ Package;
22
  namespace Vendor\Package;
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.inc.fixed CHANGED
@@ -11,4 +11,14 @@ namespace Vendor\Package;
11
 
12
  use BarClass as Bar;
13
 
 
 
 
 
 
 
 
 
 
 
14
  namespace Vendor\Package;
11
 
12
  use BarClass as Bar;
13
 
14
+ namespace Vendor
15
+ \Package;
16
+
17
+ namespace Vendor\
18
+ Package;
19
+
20
+ namespace Vendor\
21
+
22
+ Package;
23
+
24
  namespace Vendor\Package;
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/NamespaceDeclarationUnitTest.php CHANGED
@@ -26,8 +26,10 @@ class NamespaceDeclarationUnitTest extends AbstractSniffUnitTest
26
  public function getErrorList()
27
  {
28
  return [
29
- 6 => 1,
30
- 9 => 1,
 
 
31
  ];
32
 
33
  }//end getErrorList()
26
  public function getErrorList()
27
  {
28
  return [
29
+ 6 => 1,
30
+ 9 => 1,
31
+ 17 => 1,
32
+ 19 => 1,
33
  ];
34
 
35
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.15.inc ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use BarClass as Bar;
4
+ use My\Full\Classname as Another;
5
+ use ArrayObject;
6
+
7
+ namespace AnotherProject;
8
+
9
+ $foo = 'bar';
10
+
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.16.inc ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ use Vendor\Package\SomeNamespace\{
3
+ SubnamespaceOne\ClassA,
4
+ SubnamespaceOne\ClassB,
5
+ }
6
+
7
+ class Test {
8
+ public function __construct() {
9
+ $var = 1;
10
+ }
11
+ }
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.16.inc.fixed ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ use Vendor\Package\SomeNamespace\SubnamespaceOne\ClassA;
3
+ use Vendor\Package\SomeNamespace\SubnamespaceOne\ClassB;
4
+
5
+ class Test {
6
+ public function __construct() {
7
+ $var = 1;
8
+ }
9
+ }
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.17.inc ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ use UnfinishedGroup\NotFixable {
3
+ ClassT,
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.2.inc CHANGED
@@ -3,6 +3,8 @@ namespace MyProject;
3
 
4
  use BarClass as Bar;
5
  use My\Full\Classname as Another, My\Full\NSname;
 
 
6
 
7
 
8
  namespace AnotherProject;
3
 
4
  use BarClass as Bar;
5
  use My\Full\Classname as Another, My\Full\NSname;
6
+ use function My\Full\functionname as somefunction, My\Full\otherfunction;
7
+ use const My\Full\constantname as someconstant, My\Full\otherconstant;
8
 
9
 
10
  namespace AnotherProject;
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.2.inc.fixed CHANGED
@@ -4,6 +4,10 @@ namespace MyProject;
4
  use BarClass as Bar;
5
  use My\Full\Classname as Another;
6
  use My\Full\NSname;
 
 
 
 
7
 
8
 
9
  namespace AnotherProject;
4
  use BarClass as Bar;
5
  use My\Full\Classname as Another;
6
  use My\Full\NSname;
7
+ use function My\Full\functionname as somefunction;
8
+ use function My\Full\otherfunction;
9
+ use const My\Full\constantname as someconstant;
10
+ use const My\Full\otherconstant;
11
 
12
 
13
  namespace AnotherProject;
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.5.inc CHANGED
@@ -18,6 +18,30 @@ use function foo\math\{ sin, cos, cosh };
18
  use const foo\math\{ PI, E, GAMMA, GOLDEN_RATIO };
19
  use foo\math\{ Math, const PI, function sin, function cos, function cosh };
20
 
21
- class PHP7 {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- }
18
  use const foo\math\{ PI, E, GAMMA, GOLDEN_RATIO };
19
  use foo\math\{ Math, const PI, function sin, function cos, function cosh };
20
 
21
+ use Grouped\TrailingComma\ {
22
+ ClassL,
23
+ const ConstM,
24
+ function func_n,
25
+ ClassO as O,
26
+ };
27
+
28
+ use function foo\math\trailingcomma\no\whitespace\{sin,cos,cosh,};
29
+
30
+ use function foo\math\multipleonnewline\{
31
+ sin, cos, /* comment */ cosh
32
+ };
33
+
34
+ // phpcs:disable Standard.Cat.Sniff -- for reasons.
35
+ use Grouped\TrailingCommaWithCommentsAndAnnotations\ {
36
+ // A comment.
37
+ ClassP,
38
+ /* Another comment. */
39
+ const ConstQ, // A trailing comment.
40
+
41
+ function func_r, // phpcs:ignore Standard.Cat.Sniff -- for reasons.
42
+ // phpcs:ignore Standard.Cat.Sniff -- for reasons.
43
+ ClassS as S,
44
+ // Some other comment.
45
+ };
46
 
47
+ // phpcs:enable
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.5.inc.fixed CHANGED
@@ -27,6 +27,30 @@ use function foo\math\sin;
27
  use function foo\math\cos;
28
  use function foo\math\cosh;
29
 
30
- class PHP7 {
 
 
 
31
 
32
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  use function foo\math\cos;
28
  use function foo\math\cosh;
29
 
30
+ use Grouped\TrailingComma\ClassL;
31
+ use const Grouped\TrailingComma\ConstM;
32
+ use function Grouped\TrailingComma\func_n;
33
+ use Grouped\TrailingComma\ClassO as O;
34
 
35
+ use function foo\math\trailingcomma\no\whitespace\sin;
36
+ use function foo\math\trailingcomma\no\whitespace\cos;
37
+ use function foo\math\trailingcomma\no\whitespace\cosh;
38
+
39
+ use function foo\math\multipleonnewline\sin;
40
+ use function foo\math\multipleonnewline\cos; /* comment */
41
+ use function foo\math\multipleonnewline\cosh;
42
+
43
+ // phpcs:disable Standard.Cat.Sniff -- for reasons.
44
+ // A comment.
45
+ use Grouped\TrailingCommaWithCommentsAndAnnotations\ClassP;
46
+ /* Another comment. */
47
+ use const Grouped\TrailingCommaWithCommentsAndAnnotations\ConstQ; // A trailing comment.
48
+
49
+ use function Grouped\TrailingCommaWithCommentsAndAnnotations\func_r; // phpcs:ignore Standard.Cat.Sniff -- for reasons.
50
+ // phpcs:ignore Standard.Cat.Sniff -- for reasons.
51
+ use Grouped\TrailingCommaWithCommentsAndAnnotations\ClassS as S;
52
+
53
+ // Some other comment.
54
+
55
+
56
+ // phpcs:enable
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/Tests/Namespaces/UseDeclarationUnitTest.php CHANGED
@@ -32,7 +32,9 @@ class UseDeclarationUnitTest extends AbstractSniffUnitTest
32
  return [
33
  4 => 1,
34
  5 => 1,
35
- 10 => 2,
 
 
36
  ];
37
  case 'UseDeclarationUnitTest.3.inc':
38
  return [
@@ -48,13 +50,25 @@ class UseDeclarationUnitTest extends AbstractSniffUnitTest
48
  17 => 1,
49
  18 => 1,
50
  19 => 1,
 
 
 
 
51
  ];
52
  case 'UseDeclarationUnitTest.10.inc':
53
  case 'UseDeclarationUnitTest.11.inc':
54
  case 'UseDeclarationUnitTest.12.inc':
55
  case 'UseDeclarationUnitTest.13.inc':
56
  case 'UseDeclarationUnitTest.14.inc':
 
 
57
  return [2 => 1];
 
 
 
 
 
 
58
  default:
59
  return [];
60
  }//end switch
32
  return [
33
  4 => 1,
34
  5 => 1,
35
+ 6 => 1,
36
+ 7 => 1,
37
+ 12 => 2,
38
  ];
39
  case 'UseDeclarationUnitTest.3.inc':
40
  return [
50
  17 => 1,
51
  18 => 1,
52
  19 => 1,
53
+ 21 => 1,
54
+ 28 => 1,
55
+ 30 => 1,
56
+ 35 => 1,
57
  ];
58
  case 'UseDeclarationUnitTest.10.inc':
59
  case 'UseDeclarationUnitTest.11.inc':
60
  case 'UseDeclarationUnitTest.12.inc':
61
  case 'UseDeclarationUnitTest.13.inc':
62
  case 'UseDeclarationUnitTest.14.inc':
63
+ case 'UseDeclarationUnitTest.16.inc':
64
+ case 'UseDeclarationUnitTest.17.inc':
65
  return [2 => 1];
66
+ case 'UseDeclarationUnitTest.15.inc':
67
+ return [
68
+ 3 => 1,
69
+ 4 => 1,
70
+ 5 => 1,
71
+ ];
72
  default:
73
  return [];
74
  }//end switch
vendor/squizlabs/php_codesniffer/src/Standards/PSR2/ruleset.xml CHANGED
@@ -59,7 +59,10 @@
59
  <!-- Code MUST use an indent of 4 spaces, and MUST NOT use tabs for indenting. -->
60
  <rule ref="Generic.WhiteSpace.ScopeIndent">
61
  <properties>
62
- <property name="ignoreIndentationTokens" type="array" value="T_COMMENT,T_DOC_COMMENT_OPEN_TAG"/>
 
 
 
63
  </properties>
64
  </rule>
65
  <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
@@ -167,6 +170,11 @@
167
  <rule ref="Squiz.ControlStructures.LowercaseDeclaration"/>
168
  <!-- checked in ControlStructures/ControlStructureSpacingSniff -->
169
 
 
 
 
 
 
170
  <!-- The body of each structure MUST be enclosed by braces. This standardizes how the structures look, and reduces the likelihood of introducing errors as new lines get added to the body. -->
171
  <rule ref="Generic.ControlStructures.InlineControlStructure"/>
172
 
59
  <!-- Code MUST use an indent of 4 spaces, and MUST NOT use tabs for indenting. -->
60
  <rule ref="Generic.WhiteSpace.ScopeIndent">
61
  <properties>
62
+ <property name="ignoreIndentationTokens" type="array">
63
+ <element value="T_COMMENT"/>
64
+ <element value="T_DOC_COMMENT_OPEN_TAG"/>
65
+ </property>
66
  </properties>
67
  </rule>
68
  <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
170
  <rule ref="Squiz.ControlStructures.LowercaseDeclaration"/>
171
  <!-- checked in ControlStructures/ControlStructureSpacingSniff -->
172
 
173
+ <!-- exclude this message as it is already checked Generic.PHP.LowerCaseKeyword -->
174
+ <rule ref="Squiz.ControlStructures.ForEachLoopDeclaration.AsNotLower">
175
+ <severity>0</severity>
176
+ </rule>
177
+
178
  <!-- The body of each structure MUST be enclosed by braces. This standardizes how the structures look, and reduces the likelihood of introducing errors as new lines get added to the body. -->
179
  <rule ref="Generic.ControlStructures.InlineControlStructure"/>
180
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php CHANGED
@@ -11,7 +11,6 @@ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Arrays;
11
 
12
  use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
14
- use PHP_CodeSniffer\Util\Tokens;
15
 
16
  class ArrayBracketSpacingSniff implements Sniff
17
  {
11
 
12
  use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
 
14
 
15
  class ArrayBracketSpacingSniff implements Sniff
16
  {
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php CHANGED
@@ -431,24 +431,27 @@ class ArrayDeclarationSniff implements Sniff
431
 
432
  if ($keyUsed === false) {
433
  if ($tokens[($nextToken - 1)]['code'] === T_WHITESPACE) {
434
- $content = $tokens[($nextToken - 2)]['content'];
435
- if ($tokens[($nextToken - 1)]['content'] === $phpcsFile->eolChar) {
436
- $spaceLength = 'newline';
437
- } else {
438
- $spaceLength = $tokens[($nextToken - 1)]['length'];
439
- }
 
 
 
 
 
440
 
441
- $error = 'Expected 0 spaces between "%s" and comma; %s found';
442
- $data = [
443
- $content,
444
- $spaceLength,
445
- ];
446
 
447
- $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpaceBeforeComma', $data);
448
- if ($fix === true) {
449
- $phpcsFile->fixer->replaceToken(($nextToken - 1), '');
 
450
  }
451
- }
452
 
453
  $valueContent = $phpcsFile->findNext(
454
  Tokens::$emptyTokens,
@@ -482,14 +485,19 @@ class ArrayDeclarationSniff implements Sniff
482
  if ($indexStart === $indexEnd) {
483
  $currentEntry['index'] = $indexEnd;
484
  $currentEntry['index_content'] = $tokens[$indexEnd]['content'];
 
485
  } else {
486
  $currentEntry['index'] = $indexStart;
487
- $currentEntry['index_content'] = $phpcsFile->getTokensAsString($indexStart, ($indexEnd - $indexStart + 1));
 
 
 
 
 
488
  }
489
 
490
- $indexLength = strlen($currentEntry['index_content']);
491
- if ($maxLength < $indexLength) {
492
- $maxLength = $indexLength;
493
  }
494
 
495
  // Find the value of this index.
@@ -524,8 +532,18 @@ class ArrayDeclarationSniff implements Sniff
524
  if ($singleValue === true) {
525
  // Array cannot be empty, so this is a multi-line array with
526
  // a single value. It should be defined on single line.
527
- $error = 'Multi-line array contains a single value; use single-line array instead';
528
- $fix = $phpcsFile->addFixableError($error, $stackPtr, 'MultiLineNotAllowed');
 
 
 
 
 
 
 
 
 
 
529
 
530
  if ($fix === true) {
531
  $phpcsFile->fixer->beginChangeset();
@@ -660,8 +678,6 @@ class ArrayDeclarationSniff implements Sniff
660
  $numValues = count($indices);
661
 
662
  $indicesStart = ($keywordStart + 1);
663
- $arrowStart = ($indicesStart + $maxLength + 1);
664
- $valueStart = ($arrowStart + 3);
665
  $indexLine = $tokens[$stackPtr]['line'];
666
  $lastIndexLine = null;
667
  foreach ($indices as $index) {
@@ -705,7 +721,9 @@ class ArrayDeclarationSniff implements Sniff
705
  continue;
706
  }
707
 
708
- if ($tokens[$index['index']]['column'] !== $indicesStart) {
 
 
709
  $expected = ($indicesStart - 1);
710
  $found = ($tokens[$index['index']]['column'] - 1);
711
  $error = 'Array key not aligned correctly; expected %s spaces but found %s';
@@ -716,19 +734,18 @@ class ArrayDeclarationSniff implements Sniff
716
 
717
  $fix = $phpcsFile->addFixableError($error, $index['index'], 'KeyNotAligned', $data);
718
  if ($fix === true) {
719
- if ($found === 0) {
720
  $phpcsFile->fixer->addContent(($index['index'] - 1), str_repeat(' ', $expected));
721
  } else {
722
  $phpcsFile->fixer->replaceToken(($index['index'] - 1), str_repeat(' ', $expected));
723
  }
724
  }
725
-
726
- continue;
727
  }
728
 
 
729
  if ($tokens[$index['arrow']]['column'] !== $arrowStart) {
730
- $expected = ($arrowStart - (strlen($index['index_content']) + $tokens[$index['index']]['column']));
731
- $found = ($tokens[$index['arrow']]['column'] - (strlen($index['index_content']) + $tokens[$index['index']]['column']));
732
  $error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s';
733
  $data = [
734
  $expected,
@@ -747,6 +764,7 @@ class ArrayDeclarationSniff implements Sniff
747
  continue;
748
  }
749
 
 
750
  if ($tokens[$index['value']]['column'] !== $valueStart) {
751
  $expected = ($valueStart - ($tokens[$index['arrow']]['length'] + $tokens[$index['arrow']]['column']));
752
  $found = ($tokens[$index['value']]['column'] - ($tokens[$index['arrow']]['length'] + $tokens[$index['arrow']]['column']));
@@ -780,55 +798,28 @@ class ArrayDeclarationSniff implements Sniff
780
  }//end if
781
 
782
  // Check each line ends in a comma.
783
- $valueLine = $tokens[$index['value']]['line'];
784
- $nextComma = false;
785
- for ($i = $index['value']; $i < $arrayEnd; $i++) {
786
- // Skip bracketed statements, like function calls.
787
- if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) {
788
- $i = $tokens[$i]['parenthesis_closer'];
789
- $valueLine = $tokens[$i]['line'];
790
- continue;
791
- }
792
-
793
- if ($tokens[$i]['code'] === T_ARRAY) {
794
- $i = $tokens[$tokens[$i]['parenthesis_opener']]['parenthesis_closer'];
795
- $valueLine = $tokens[$i]['line'];
796
- continue;
797
- }
798
-
799
- // Skip to the end of multi-line strings.
800
- if (isset(Tokens::$stringTokens[$tokens[$i]['code']]) === true) {
801
- $i = $phpcsFile->findNext($tokens[$i]['code'], ($i + 1), null, true);
802
- $i--;
803
- $valueLine = $tokens[$i]['line'];
804
- continue;
805
- }
806
-
807
- if ($tokens[$i]['code'] === T_START_HEREDOC || $tokens[$i]['code'] === T_START_NOWDOC) {
808
- // Here/nowdoc closing tags must not be followed by a comma,
809
- // so it must be on the next line.
810
- $i = $tokens[$i]['scope_closer'];
811
- $valueLine = ($tokens[$i]['line'] + 1);
812
- continue;
813
- }
814
-
815
- if ($tokens[$i]['code'] === T_OPEN_SHORT_ARRAY) {
816
- $i = $tokens[$i]['bracket_closer'];
817
- $valueLine = $tokens[$i]['line'];
818
- continue;
819
- }
820
-
821
- if ($tokens[$i]['code'] === T_CLOSURE) {
822
- $i = $tokens[$i]['scope_closer'];
823
- $valueLine = $tokens[$i]['line'];
824
- continue;
825
  }
 
826
 
827
- if ($tokens[$i]['code'] === T_COMMA) {
828
- $nextComma = $i;
829
- break;
830
- }
831
- }//end for
832
 
833
  if ($nextComma === false || ($tokens[$nextComma]['line'] !== $valueLine)) {
834
  $error = 'Each line in an array declaration must end in a comma';
@@ -836,19 +827,25 @@ class ArrayDeclarationSniff implements Sniff
836
 
837
  if ($fix === true) {
838
  // Find the end of the line and put a comma there.
839
- for ($i = ($index['value'] + 1); $i < $arrayEnd; $i++) {
840
  if ($tokens[$i]['line'] > $valueLine) {
841
  break;
842
  }
843
  }
844
 
 
845
  $phpcsFile->fixer->addContentBefore(($i - 1), ',');
 
 
 
 
 
846
  }
847
- }
848
 
849
  // Check that there is no space before the comma.
850
  if ($nextComma !== false && $tokens[($nextComma - 1)]['code'] === T_WHITESPACE) {
851
- // Here/nowdoc closing tags must have the command on the next line.
852
  $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($nextComma - 1), null, true);
853
  if ($tokens[$prev]['code'] !== T_END_HEREDOC && $tokens[$prev]['code'] !== T_END_NOWDOC) {
854
  $content = $tokens[($nextComma - 2)]['content'];
431
 
432
  if ($keyUsed === false) {
433
  if ($tokens[($nextToken - 1)]['code'] === T_WHITESPACE) {
434
+ $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($nextToken - 1), null, true);
435
+ if (($tokens[$prev]['code'] !== T_END_HEREDOC
436
+ && $tokens[$prev]['code'] !== T_END_NOWDOC)
437
+ || $tokens[($nextToken - 1)]['line'] === $tokens[$nextToken]['line']
438
+ ) {
439
+ $content = $tokens[($nextToken - 2)]['content'];
440
+ if ($tokens[($nextToken - 1)]['content'] === $phpcsFile->eolChar) {
441
+ $spaceLength = 'newline';
442
+ } else {
443
+ $spaceLength = $tokens[($nextToken - 1)]['length'];
444
+ }
445
 
446
+ $error = 'Expected 0 spaces before comma; %s found';
447
+ $data = [$spaceLength];
 
 
 
448
 
449
+ $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpaceBeforeComma', $data);
450
+ if ($fix === true) {
451
+ $phpcsFile->fixer->replaceToken(($nextToken - 1), '');
452
+ }
453
  }
454
+ }//end if
455
 
456
  $valueContent = $phpcsFile->findNext(
457
  Tokens::$emptyTokens,
485
  if ($indexStart === $indexEnd) {
486
  $currentEntry['index'] = $indexEnd;
487
  $currentEntry['index_content'] = $tokens[$indexEnd]['content'];
488
+ $currentEntry['index_length'] = $tokens[$indexEnd]['length'];
489
  } else {
490
  $currentEntry['index'] = $indexStart;
491
+ $currentEntry['index_content'] = '';
492
+ $currentEntry['index_length'] = 0;
493
+ for ($i = $indexStart; $i <= $indexEnd; $i++) {
494
+ $currentEntry['index_content'] .= $tokens[$i]['content'];
495
+ $currentEntry['index_length'] += $tokens[$i]['length'];
496
+ }
497
  }
498
 
499
+ if ($maxLength < $currentEntry['index_length']) {
500
+ $maxLength = $currentEntry['index_length'];
 
501
  }
502
 
503
  // Find the value of this index.
532
  if ($singleValue === true) {
533
  // Array cannot be empty, so this is a multi-line array with
534
  // a single value. It should be defined on single line.
535
+ $error = 'Multi-line array contains a single value; use single-line array instead';
536
+ $errorCode = 'MultiLineNotAllowed';
537
+
538
+ $find = Tokens::$phpcsCommentTokens;
539
+ $find[] = T_COMMENT;
540
+ $comment = $phpcsFile->findNext($find, ($arrayStart + 1), $arrayEnd);
541
+ if ($comment === false) {
542
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, $errorCode);
543
+ } else {
544
+ $fix = false;
545
+ $phpcsFile->addError($error, $stackPtr, $errorCode);
546
+ }
547
 
548
  if ($fix === true) {
549
  $phpcsFile->fixer->beginChangeset();
678
  $numValues = count($indices);
679
 
680
  $indicesStart = ($keywordStart + 1);
 
 
681
  $indexLine = $tokens[$stackPtr]['line'];
682
  $lastIndexLine = null;
683
  foreach ($indices as $index) {
721
  continue;
722
  }
723
 
724
+ if ($tokens[$index['index']]['column'] !== $indicesStart
725
+ && ($index['index'] - 1) !== $arrayStart
726
+ ) {
727
  $expected = ($indicesStart - 1);
728
  $found = ($tokens[$index['index']]['column'] - 1);
729
  $error = 'Array key not aligned correctly; expected %s spaces but found %s';
734
 
735
  $fix = $phpcsFile->addFixableError($error, $index['index'], 'KeyNotAligned', $data);
736
  if ($fix === true) {
737
+ if ($found === 0 || $tokens[($index['index'] - 1)]['code'] !== T_WHITESPACE) {
738
  $phpcsFile->fixer->addContent(($index['index'] - 1), str_repeat(' ', $expected));
739
  } else {
740
  $phpcsFile->fixer->replaceToken(($index['index'] - 1), str_repeat(' ', $expected));
741
  }
742
  }
 
 
743
  }
744
 
745
+ $arrowStart = ($tokens[$index['index']]['column'] + $maxLength + 1);
746
  if ($tokens[$index['arrow']]['column'] !== $arrowStart) {
747
+ $expected = ($arrowStart - ($index['index_length'] + $tokens[$index['index']]['column']));
748
+ $found = ($tokens[$index['arrow']]['column'] - ($index['index_length'] + $tokens[$index['index']]['column']));
749
  $error = 'Array double arrow not aligned correctly; expected %s space(s) but found %s';
750
  $data = [
751
  $expected,
764
  continue;
765
  }
766
 
767
+ $valueStart = ($arrowStart + 3);
768
  if ($tokens[$index['value']]['column'] !== $valueStart) {
769
  $expected = ($valueStart - ($tokens[$index['arrow']]['length'] + $tokens[$index['arrow']]['column']));
770
  $found = ($tokens[$index['value']]['column'] - ($tokens[$index['arrow']]['length'] + $tokens[$index['arrow']]['column']));
798
  }//end if
799
 
800
  // Check each line ends in a comma.
801
+ $valueStart = $index['value'];
802
+ $valueLine = $tokens[$index['value']]['line'];
803
+ $nextComma = false;
804
+
805
+ $end = $phpcsFile->findEndOfStatement($valueStart);
806
+ if ($end === false) {
807
+ $valueEnd = $valueStart;
808
+ } else if ($tokens[$end]['code'] === T_COMMA) {
809
+ $valueEnd = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($end - 1), $valueStart, true);
810
+ $nextComma = $end;
811
+ } else {
812
+ $valueEnd = $end;
813
+ $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($end + 1), $arrayEnd, true);
814
+ if ($next !== false && $tokens[$next]['code'] === T_COMMA) {
815
+ $nextComma = $next;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
816
  }
817
+ }
818
 
819
+ $valueLine = $tokens[$valueEnd]['line'];
820
+ if ($tokens[$valueEnd]['code'] === T_END_HEREDOC || $tokens[$valueEnd]['code'] === T_END_NOWDOC) {
821
+ $valueLine++;
822
+ }
 
823
 
824
  if ($nextComma === false || ($tokens[$nextComma]['line'] !== $valueLine)) {
825
  $error = 'Each line in an array declaration must end in a comma';
827
 
828
  if ($fix === true) {
829
  // Find the end of the line and put a comma there.
830
+ for ($i = ($index['value'] + 1); $i <= $arrayEnd; $i++) {
831
  if ($tokens[$i]['line'] > $valueLine) {
832
  break;
833
  }
834
  }
835
 
836
+ $phpcsFile->fixer->beginChangeset();
837
  $phpcsFile->fixer->addContentBefore(($i - 1), ',');
838
+ if ($nextComma !== false) {
839
+ $phpcsFile->fixer->replaceToken($nextComma, '');
840
+ }
841
+
842
+ $phpcsFile->fixer->endChangeset();
843
  }
844
+ }//end if
845
 
846
  // Check that there is no space before the comma.
847
  if ($nextComma !== false && $tokens[($nextComma - 1)]['code'] === T_WHITESPACE) {
848
+ // Here/nowdoc closing tags must have the comma on the next line.
849
  $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($nextComma - 1), null, true);
850
  if ($tokens[$prev]['code'] !== T_END_HEREDOC && $tokens[$prev]['code'] !== T_END_NOWDOC) {
851
  $content = $tokens[($nextComma - 2)]['content'];
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php CHANGED
@@ -9,9 +9,9 @@
9
 
10
  namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS;
11
 
12
- use PHP_CodeSniffer\Sniffs\Sniff;
13
- use PHP_CodeSniffer\Files\File;
14
- use PHP_CodeSniffer\Util\Tokens;
15
 
16
  class ClassDefinitionClosingBraceSpaceSniff implements Sniff
17
  {
9
 
10
  namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\CSS;
11
 
12
+ use PHP_CodeSniffer\Sniffs\Sniff;
13
+ use PHP_CodeSniffer\Files\File;
14
+ use PHP_CodeSniffer\Util\Tokens;
15
 
16
  class ClassDefinitionClosingBraceSpaceSniff implements Sniff
17
  {
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php CHANGED
@@ -106,7 +106,7 @@ class ClassDeclarationSniff extends PSR2ClassDeclarationSniff
106
 
107
  // Check that the closing brace has one blank line after it.
108
  for ($nextContent = ($closeBrace + 1); $nextContent < $phpcsFile->numTokens; $nextContent++) {
109
- // Ignore comments on the same lines as the brace.
110
  if ($tokens[$nextContent]['line'] === $tokens[$closeBrace]['line']
111
  && ($tokens[$nextContent]['code'] === T_WHITESPACE
112
  || $tokens[$nextContent]['code'] === T_COMMENT
@@ -166,6 +166,13 @@ class ClassDeclarationSniff extends PSR2ClassDeclarationSniff
166
  }//end if
167
 
168
  if ($difference !== -1 && $difference !== 1) {
 
 
 
 
 
 
 
169
  $error = 'Closing brace of a %s must be followed by a single blank line; found %s';
170
  $data = [
171
  $tokens[$stackPtr]['content'],
106
 
107
  // Check that the closing brace has one blank line after it.
108
  for ($nextContent = ($closeBrace + 1); $nextContent < $phpcsFile->numTokens; $nextContent++) {
109
+ // Ignore comments on the same line as the brace.
110
  if ($tokens[$nextContent]['line'] === $tokens[$closeBrace]['line']
111
  && ($tokens[$nextContent]['code'] === T_WHITESPACE
112
  || $tokens[$nextContent]['code'] === T_COMMENT
166
  }//end if
167
 
168
  if ($difference !== -1 && $difference !== 1) {
169
+ if ($tokens[$nextContent]['code'] === T_DOC_COMMENT_OPEN_TAG) {
170
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($tokens[$nextContent]['comment_closer'] + 1), null, true);
171
+ if ($next !== false && $tokens[$next]['code'] === T_FUNCTION) {
172
+ return;
173
+ }
174
+ }
175
+
176
  $error = 'Closing brace of a %s must be followed by a single blank line; found %s';
177
  $data = [
178
  $tokens[$stackPtr]['content'],
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php CHANGED
@@ -65,19 +65,19 @@ class ValidClassNameSniff implements Sniff
65
  $name = trim($phpcsFile->getTokensAsString($nameStart, ($nameEnd - $nameStart)));
66
  }
67
 
68
- // Check for camel caps format.
69
  $valid = Common::isCamelCaps($name, true, true, false);
70
  if ($valid === false) {
71
  $type = ucfirst($tokens[$stackPtr]['content']);
72
- $error = '%s name "%s" is not in camel caps format';
73
  $data = [
74
  $type,
75
  $name,
76
  ];
77
  $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data);
78
- $phpcsFile->recordMetric($stackPtr, 'CamelCase class name', 'no');
79
  } else {
80
- $phpcsFile->recordMetric($stackPtr, 'CamelCase class name', 'yes');
81
  }
82
 
83
  }//end process()
65
  $name = trim($phpcsFile->getTokensAsString($nameStart, ($nameEnd - $nameStart)));
66
  }
67
 
68
+ // Check for PascalCase format.
69
  $valid = Common::isCamelCaps($name, true, true, false);
70
  if ($valid === false) {
71
  $type = ucfirst($tokens[$stackPtr]['content']);
72
+ $error = '%s name "%s" is not in PascalCase format';
73
  $data = [
74
  $type,
75
  $name,
76
  ];
77
  $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $data);
78
+ $phpcsFile->recordMetric($stackPtr, 'PascalCase class name', 'no');
79
  } else {
80
+ $phpcsFile->recordMetric($stackPtr, 'PascalCase class name', 'yes');
81
  }
82
 
83
  }//end process()
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php CHANGED
@@ -118,7 +118,9 @@ class BlockCommentSniff implements Sniff
118
 
119
  // Construct the comment into an array.
120
  while (($nextComment = $phpcsFile->findNext(T_WHITESPACE, ($nextComment + 1), null, true)) !== false) {
121
- if ($tokens[$nextComment]['code'] !== $tokens[$stackPtr]['code']) {
 
 
122
  // Found the next bit of code.
123
  break;
124
  }
@@ -131,13 +133,15 @@ class BlockCommentSniff implements Sniff
131
  $lastLine = $tokens[$nextComment]['line'];
132
  $commentLines[] = $nextComment;
133
  $commentString .= $tokens[$nextComment]['content'];
134
- if ($tokens[$nextComment]['code'] === T_DOC_COMMENT_CLOSE_TAG) {
 
 
135
  break;
136
  }
137
- }
138
 
139
  $commentText = str_replace($phpcsFile->eolChar, '', $commentString);
140
- $commentText = trim($commentText, '/* ');
141
  if ($commentText === '') {
142
  $error = 'Empty block comment not allowed';
143
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Empty');
@@ -157,10 +161,17 @@ class BlockCommentSniff implements Sniff
157
 
158
  if (count($commentLines) === 1) {
159
  $error = 'Single line block comment not allowed; use inline ("// text") comment instead';
160
- $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SingleLine');
161
- if ($fix === true) {
162
- $comment = '// '.$commentText.$phpcsFile->eolChar;
163
- $phpcsFile->fixer->replaceToken($stackPtr, $comment);
 
 
 
 
 
 
 
164
  }
165
 
166
  return;
@@ -192,7 +203,8 @@ class BlockCommentSniff implements Sniff
192
  return;
193
  }//end if
194
 
195
- $starColumn = ($tokens[$stackPtr]['column'] + 3);
 
196
 
197
  // Make sure first line isn't blank.
198
  if (trim($tokens[$commentLines[1]]['content']) === '') {
@@ -206,14 +218,21 @@ class BlockCommentSniff implements Sniff
206
  $content = $tokens[$commentLines[1]]['content'];
207
  $commentText = ltrim($content);
208
  $leadingSpace = (strlen($content) - strlen($commentText));
209
- if ($leadingSpace !== $starColumn) {
210
- $expected = $starColumn.' space';
211
- if ($starColumn !== 1) {
212
- $expected .= 's';
 
 
 
 
 
 
 
213
  }
214
 
215
  $data = [
216
- $expected,
217
  $leadingSpace,
218
  ];
219
 
@@ -224,12 +243,13 @@ class BlockCommentSniff implements Sniff
224
  && $tokens[$commentLines[1]]['orig_content'][0] === "\t"
225
  ) {
226
  // Line is indented using tabs.
227
- $padding = str_repeat("\t", floor($starColumn / $this->tabWidth));
 
228
  } else {
229
- $padding = str_repeat(' ', $starColumn);
230
  }
231
 
232
- $phpcsFile->fixer->replaceToken($commentLines[1], $padding.ltrim($content));
233
  }
234
  }//end if
235
 
@@ -241,7 +261,6 @@ class BlockCommentSniff implements Sniff
241
 
242
  // Check that each line of the comment is indented past the star.
243
  foreach ($commentLines as $line) {
244
- $leadingSpace = (strlen($tokens[$line]['content']) - strlen(ltrim($tokens[$line]['content'])));
245
  // First and last lines (comment opener and closer) are handled separately.
246
  if ($line === $commentLines[(count($commentLines) - 1)] || $line === $commentLines[0]) {
247
  continue;
@@ -257,14 +276,23 @@ class BlockCommentSniff implements Sniff
257
  continue;
258
  }
259
 
260
- if ($leadingSpace < $starColumn) {
261
- $expected = $starColumn.' space';
262
- if ($starColumn !== 1) {
263
- $expected .= 's';
 
 
 
 
 
 
 
 
 
264
  }
265
 
266
  $data = [
267
- $expected,
268
  $leadingSpace,
269
  ];
270
 
@@ -275,42 +303,59 @@ class BlockCommentSniff implements Sniff
275
  && $tokens[$line]['orig_content'][0] === "\t"
276
  ) {
277
  // Line is indented using tabs.
278
- $padding = str_repeat("\t", floor($starColumn / $this->tabWidth));
 
279
  } else {
280
- $padding = str_repeat(' ', $starColumn);
281
  }
282
 
283
- $phpcsFile->fixer->replaceToken($line, $padding.ltrim($tokens[$line]['content']));
284
  }
285
  }//end if
286
  }//end foreach
287
 
288
  // Finally, test the last line is correct.
289
- $lastIndex = (count($commentLines) - 1);
290
- $content = trim($tokens[$commentLines[$lastIndex]]['content']);
291
- if ($content !== '*/' && $content !== '**/') {
 
292
  $error = 'Comment closer must be on a new line';
293
  $phpcsFile->addError($error, $commentLines[$lastIndex], 'CloserSameLine');
294
  } else {
295
- $content = $tokens[$commentLines[$lastIndex]]['content'];
296
- $commentText = ltrim($content);
297
  $leadingSpace = (strlen($content) - strlen($commentText));
298
- if ($leadingSpace !== ($tokens[$stackPtr]['column'] - 1)) {
299
- $expected = ($tokens[$stackPtr]['column'] - 1);
300
- if ($expected === 1) {
301
- $expected .= ' space';
302
- } else {
303
- $expected .= ' spaces';
 
 
 
 
304
  }
305
 
306
  $data = [
307
- $expected,
308
  $leadingSpace,
309
  ];
310
 
311
  $error = 'Last line of comment aligned incorrectly; expected %s but found %s';
312
- $phpcsFile->addError($error, $commentLines[$lastIndex], 'LastLineIndent', $data);
313
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  }//end if
315
 
316
  // Check that the lines before and after this comment are blank.
118
 
119
  // Construct the comment into an array.
120
  while (($nextComment = $phpcsFile->findNext(T_WHITESPACE, ($nextComment + 1), null, true)) !== false) {
121
+ if ($tokens[$nextComment]['code'] !== $tokens[$stackPtr]['code']
122
+ && isset(Tokens::$phpcsCommentTokens[$tokens[$nextComment]['code']]) === false
123
+ ) {
124
  // Found the next bit of code.
125
  break;
126
  }
133
  $lastLine = $tokens[$nextComment]['line'];
134
  $commentLines[] = $nextComment;
135
  $commentString .= $tokens[$nextComment]['content'];
136
+ if ($tokens[$nextComment]['code'] === T_DOC_COMMENT_CLOSE_TAG
137
+ || substr($tokens[$nextComment]['content'], -2) === '*/'
138
+ ) {
139
  break;
140
  }
141
+ }//end while
142
 
143
  $commentText = str_replace($phpcsFile->eolChar, '', $commentString);
144
+ $commentText = trim($commentText, "/* \t");
145
  if ($commentText === '') {
146
  $error = 'Empty block comment not allowed';
147
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Empty');
161
 
162
  if (count($commentLines) === 1) {
163
  $error = 'Single line block comment not allowed; use inline ("// text") comment instead';
164
+
165
+ // Only fix comments when they are the last token on a line.
166
+ $nextNonEmpty = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
167
+ if ($tokens[$stackPtr]['line'] !== $tokens[$nextNonEmpty]['line']) {
168
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SingleLine');
169
+ if ($fix === true) {
170
+ $comment = '// '.$commentText.$phpcsFile->eolChar;
171
+ $phpcsFile->fixer->replaceToken($stackPtr, $comment);
172
+ }
173
+ } else {
174
+ $phpcsFile->addError($error, $stackPtr, 'SingleLine');
175
  }
176
 
177
  return;
203
  return;
204
  }//end if
205
 
206
+ $starColumn = $tokens[$stackPtr]['column'];
207
+ $hasStars = false;
208
 
209
  // Make sure first line isn't blank.
210
  if (trim($tokens[$commentLines[1]]['content']) === '') {
218
  $content = $tokens[$commentLines[1]]['content'];
219
  $commentText = ltrim($content);
220
  $leadingSpace = (strlen($content) - strlen($commentText));
221
+
222
+ $expected = ($starColumn + 3);
223
+ if ($commentText[0] === '*') {
224
+ $expected = $starColumn;
225
+ $hasStars = true;
226
+ }
227
+
228
+ if ($leadingSpace !== $expected) {
229
+ $expectedTxt = $expected.' space';
230
+ if ($expected !== 1) {
231
+ $expectedTxt .= 's';
232
  }
233
 
234
  $data = [
235
+ $expectedTxt,
236
  $leadingSpace,
237
  ];
238
 
243
  && $tokens[$commentLines[1]]['orig_content'][0] === "\t"
244
  ) {
245
  // Line is indented using tabs.
246
+ $padding = str_repeat("\t", floor($expected / $this->tabWidth));
247
+ $padding .= str_repeat(' ', ($expected % $this->tabWidth));
248
  } else {
249
+ $padding = str_repeat(' ', $expected);
250
  }
251
 
252
+ $phpcsFile->fixer->replaceToken($commentLines[1], $padding.$commentText);
253
  }
254
  }//end if
255
 
261
 
262
  // Check that each line of the comment is indented past the star.
263
  foreach ($commentLines as $line) {
 
264
  // First and last lines (comment opener and closer) are handled separately.
265
  if ($line === $commentLines[(count($commentLines) - 1)] || $line === $commentLines[0]) {
266
  continue;
276
  continue;
277
  }
278
 
279
+ $commentText = ltrim($tokens[$line]['content']);
280
+ $leadingSpace = (strlen($tokens[$line]['content']) - strlen($commentText));
281
+
282
+ $expected = ($starColumn + 3);
283
+ if ($commentText[0] === '*') {
284
+ $expected = $starColumn;
285
+ $hasStars = true;
286
+ }
287
+
288
+ if ($leadingSpace < $expected) {
289
+ $expectedTxt = $expected.' space';
290
+ if ($expected !== 1) {
291
+ $expectedTxt .= 's';
292
  }
293
 
294
  $data = [
295
+ $expectedTxt,
296
  $leadingSpace,
297
  ];
298
 
303
  && $tokens[$line]['orig_content'][0] === "\t"
304
  ) {
305
  // Line is indented using tabs.
306
+ $padding = str_repeat("\t", floor($expected / $this->tabWidth));
307
+ $padding .= str_repeat(' ', ($expected % $this->tabWidth));
308
  } else {
309
+ $padding = str_repeat(' ', $expected);
310
  }
311
 
312
+ $phpcsFile->fixer->replaceToken($line, $padding.$commentText);
313
  }
314
  }//end if
315
  }//end foreach
316
 
317
  // Finally, test the last line is correct.
318
+ $lastIndex = (count($commentLines) - 1);
319
+ $content = $tokens[$commentLines[$lastIndex]]['content'];
320
+ $commentText = ltrim($content);
321
+ if ($commentText !== '*/' && $commentText !== '**/') {
322
  $error = 'Comment closer must be on a new line';
323
  $phpcsFile->addError($error, $commentLines[$lastIndex], 'CloserSameLine');
324
  } else {
 
 
325
  $leadingSpace = (strlen($content) - strlen($commentText));
326
+
327
+ $expected = ($starColumn - 1);
328
+ if ($hasStars === true) {
329
+ $expected = $starColumn;
330
+ }
331
+
332
+ if ($leadingSpace !== $expected) {
333
+ $expectedTxt = $expected.' space';
334
+ if ($expected !== 1) {
335
+ $expectedTxt .= 's';
336
  }
337
 
338
  $data = [
339
+ $expectedTxt,
340
  $leadingSpace,
341
  ];
342
 
343
  $error = 'Last line of comment aligned incorrectly; expected %s but found %s';
344
+ $fix = $phpcsFile->addFixableError($error, $commentLines[$lastIndex], 'LastLineIndent', $data);
345
+ if ($fix === true) {
346
+ if (isset($tokens[$line]['orig_content']) === true
347
+ && $tokens[$line]['orig_content'][0] === "\t"
348
+ ) {
349
+ // Line is indented using tabs.
350
+ $padding = str_repeat("\t", floor($expected / $this->tabWidth));
351
+ $padding .= str_repeat(' ', ($expected % $this->tabWidth));
352
+ } else {
353
+ $padding = str_repeat(' ', $expected);
354
+ }
355
+
356
+ $phpcsFile->fixer->replaceToken($commentLines[$lastIndex], $padding.$commentText);
357
+ }
358
+ }//end if
359
  }//end if
360
 
361
  // Check that the lines before and after this comment are blank.
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php CHANGED
@@ -49,8 +49,6 @@ class FileCommentSniff implements Sniff
49
  */
50
  public function process(File $phpcsFile, $stackPtr)
51
  {
52
- $this->currentFile = $phpcsFile;
53
-
54
  $tokens = $phpcsFile->getTokens();
55
  $commentStart = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
56
 
49
  */
50
  public function process(File $phpcsFile, $stackPtr)
51
  {
 
 
52
  $tokens = $phpcsFile->getTokens();
53
  $commentStart = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
54
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php CHANGED
@@ -423,8 +423,8 @@ class FunctionCommentSniff extends PEARFunctionCommentSniff
423
  if ($suggestedTypeHint !== '' && isset($realParams[$pos]) === true) {
424
  $typeHint = $realParams[$pos]['type_hint'];
425
 
426
- // Remove namespace prefixes.
427
- $suggestedTypeHint = substr($suggestedTypeHint, (strlen($typeHint) * -1));
428
 
429
  if ($typeHint === '') {
430
  $error = 'Type hint "%s" missing for %s';
@@ -443,7 +443,7 @@ class FunctionCommentSniff extends PEARFunctionCommentSniff
443
  }
444
 
445
  $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
446
- } else if ($typeHint !== $suggestedTypeHint && $typeHint !== '?'.$suggestedTypeHint) {
447
  $error = 'Expected type hint "%s"; found "%s" for %s';
448
  $data = [
449
  $suggestedTypeHint,
@@ -611,6 +611,7 @@ class FunctionCommentSniff extends PEARFunctionCommentSniff
611
  $phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content);
612
 
613
  // Fix up the indent of additional comment lines.
 
614
  foreach ($param['commentLines'] as $lineNum => $line) {
615
  if ($lineNum === 0
616
  || $param['commentLines'][$lineNum]['indent'] === 0
@@ -618,8 +619,11 @@ class FunctionCommentSniff extends PEARFunctionCommentSniff
618
  continue;
619
  }
620
 
621
- $diff = ($param['type_space'] - $spaces);
622
  $newIndent = ($param['commentLines'][$lineNum]['indent'] - $diff);
 
 
 
 
623
  $phpcsFile->fixer->replaceToken(
624
  ($param['commentLines'][$lineNum]['token'] - 1),
625
  str_repeat(' ', $newIndent)
423
  if ($suggestedTypeHint !== '' && isset($realParams[$pos]) === true) {
424
  $typeHint = $realParams[$pos]['type_hint'];
425
 
426
+ // Remove namespace prefixes when comparing.
427
+ $compareTypeHint = substr($suggestedTypeHint, (strlen($typeHint) * -1));
428
 
429
  if ($typeHint === '') {
430
  $error = 'Type hint "%s" missing for %s';
443
  }
444
 
445
  $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
446
+ } else if ($typeHint !== $compareTypeHint && $typeHint !== '?'.$compareTypeHint) {
447
  $error = 'Expected type hint "%s"; found "%s" for %s';
448
  $data = [
449
  $suggestedTypeHint,
611
  $phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content);
612
 
613
  // Fix up the indent of additional comment lines.
614
+ $diff = ($param['type_space'] - $spaces);
615
  foreach ($param['commentLines'] as $lineNum => $line) {
616
  if ($lineNum === 0
617
  || $param['commentLines'][$lineNum]['indent'] === 0
619
  continue;
620
  }
621
 
 
622
  $newIndent = ($param['commentLines'][$lineNum]['indent'] - $diff);
623
+ if ($newIndent <= 0) {
624
+ continue;
625
+ }
626
+
627
  $phpcsFile->fixer->replaceToken(
628
  ($param['commentLines'][$lineNum]['token'] - 1),
629
  str_repeat(' ', $newIndent)
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php CHANGED
@@ -292,6 +292,27 @@ class InlineCommentSniff implements Sniff
292
  return;
293
  }
294
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
295
  for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
296
  if ($tokens[$i]['line'] === ($tokens[$stackPtr]['line'] + 1)) {
297
  if ($tokens[$i]['code'] !== T_WHITESPACE) {
@@ -303,7 +324,7 @@ class InlineCommentSniff implements Sniff
303
  }
304
 
305
  $error = 'There must be no blank line following an inline comment';
306
- $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfter');
307
  if ($fix === true) {
308
  $phpcsFile->fixer->beginChangeset();
309
  for ($i = ($stackPtr + 1); $i < $next; $i++) {
292
  return;
293
  }
294
 
295
+ if ($tokens[$next]['code'] === T_DOC_COMMENT_OPEN_TAG) {
296
+ // If this inline comment is followed by a docblock,
297
+ // ignore spacing as docblock/function etc spacing rules
298
+ // are likely to conflict with our rules.
299
+ return;
300
+ }
301
+
302
+ $errorCode = 'SpacingAfter';
303
+
304
+ if (isset($tokens[$stackPtr]['conditions']) === true) {
305
+ $conditions = $tokens[$stackPtr]['conditions'];
306
+ $type = end($conditions);
307
+ $conditionPtr = key($conditions);
308
+
309
+ if (($type === T_FUNCTION || $type === T_CLOSURE)
310
+ && $tokens[$conditionPtr]['scope_closer'] === $next
311
+ ) {
312
+ $errorCode = 'SpacingAfterAtFunctionEnd';
313
+ }
314
+ }
315
+
316
  for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
317
  if ($tokens[$i]['line'] === ($tokens[$stackPtr]['line'] + 1)) {
318
  if ($tokens[$i]['code'] !== T_WHITESPACE) {
324
  }
325
 
326
  $error = 'There must be no blank line following an inline comment';
327
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, $errorCode);
328
  if ($fix === true) {
329
  $phpcsFile->fixer->beginChangeset();
330
  for ($i = ($stackPtr + 1); $i < $next; $i++) {
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php CHANGED
@@ -98,18 +98,40 @@ class VariableCommentSniff extends AbstractVariableSniff
98
  return;
99
  }
100
 
101
- $varType = $tokens[($foundVar + 2)]['content'];
102
- $suggestedType = Common::suggestType($varType);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  if ($varType !== $suggestedType) {
104
  $error = 'Expected "%s" but found "%s" for @var tag in member variable comment';
105
  $data = [
106
  $suggestedType,
107
  $varType,
108
  ];
109
-
110
- $fix = $phpcsFile->addFixableError($error, ($foundVar + 2), 'IncorrectVarType', $data);
111
  if ($fix === true) {
112
- $phpcsFile->fixer->replaceToken(($foundVar + 2), $suggestedType);
 
 
 
 
 
 
113
  }
114
  }
115
 
98
  return;
99
  }
100
 
101
+ // Support both a var type and a description.
102
+ preg_match('`^((?:\|?(?:array\([^\)]*\)|[\\\\a-z0-9\[\]]+))*)( .*)?`i', $tokens[($foundVar + 2)]['content'], $varParts);
103
+ if (isset($varParts[1]) === false) {
104
+ return;
105
+ }
106
+
107
+ $varType = $varParts[1];
108
+
109
+ // Check var type (can be multiple, separated by '|').
110
+ $typeNames = explode('|', $varType);
111
+ $suggestedNames = [];
112
+ foreach ($typeNames as $i => $typeName) {
113
+ $suggestedName = Common::suggestType($typeName);
114
+ if (in_array($suggestedName, $suggestedNames) === false) {
115
+ $suggestedNames[] = $suggestedName;
116
+ }
117
+ }
118
+
119
+ $suggestedType = implode('|', $suggestedNames);
120
  if ($varType !== $suggestedType) {
121
  $error = 'Expected "%s" but found "%s" for @var tag in member variable comment';
122
  $data = [
123
  $suggestedType,
124
  $varType,
125
  ];
126
+ $fix = $phpcsFile->addFixableError($error, $foundVar, 'IncorrectVarType', $data);
 
127
  if ($fix === true) {
128
+ $replacement = $suggestedType;
129
+ if (empty($varParts[2]) === false) {
130
+ $replacement .= $varParts[2];
131
+ }
132
+
133
+ $phpcsFile->fixer->replaceToken(($foundVar + 2), $replacement);
134
+ unset($replacement);
135
  }
136
  }
137
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php CHANGED
@@ -251,15 +251,22 @@ class ControlSignatureSniff implements Sniff
251
  }//end if
252
 
253
  // Only want to check multi-keyword structures from here on.
254
- if ($tokens[$stackPtr]['code'] === T_DO) {
255
- if (isset($tokens[$stackPtr]['scope_closer']) === false) {
256
  return;
257
  }
258
 
259
- $closer = $tokens[$stackPtr]['scope_closer'];
 
 
 
 
 
 
260
  } else if ($tokens[$stackPtr]['code'] === T_ELSE
261
  || $tokens[$stackPtr]['code'] === T_ELSEIF
262
  || $tokens[$stackPtr]['code'] === T_CATCH
 
263
  ) {
264
  if (isset($tokens[$stackPtr]['scope_opener']) === true
265
  && $tokens[$tokens[$stackPtr]['scope_opener']]['code'] === T_COLON
@@ -281,18 +288,23 @@ class ControlSignatureSniff implements Sniff
281
  $found = 1;
282
  if ($tokens[($closer + 1)]['code'] !== T_WHITESPACE) {
283
  $found = 0;
 
 
284
  } else if ($tokens[($closer + 1)]['content'] !== ' ') {
285
- if (strpos($tokens[($closer + 1)]['content'], $phpcsFile->eolChar) !== false) {
286
- $found = 'newline';
287
- } else {
288
- $found = strlen($tokens[($closer + 1)]['content']);
289
- }
290
  }
291
 
292
  if ($found !== 1) {
293
  $error = 'Expected 1 space after closing brace; %s found';
294
  $data = [$found];
295
- $fix = $phpcsFile->addFixableError($error, $closer, 'SpaceAfterCloseBrace', $data);
 
 
 
 
 
 
 
296
  if ($fix === true) {
297
  if ($found === 0) {
298
  $phpcsFile->fixer->addContent($closer, ' ');
251
  }//end if
252
 
253
  // Only want to check multi-keyword structures from here on.
254
+ if ($tokens[$stackPtr]['code'] === T_WHILE) {
255
+ if (isset($tokens[$stackPtr]['scope_closer']) !== false) {
256
  return;
257
  }
258
 
259
+ $closer = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
260
+ if ($closer === false
261
+ || $tokens[$closer]['code'] !== T_CLOSE_CURLY_BRACKET
262
+ || $tokens[$tokens[$closer]['scope_condition']]['code'] !== T_DO
263
+ ) {
264
+ return;
265
+ }
266
  } else if ($tokens[$stackPtr]['code'] === T_ELSE
267
  || $tokens[$stackPtr]['code'] === T_ELSEIF
268
  || $tokens[$stackPtr]['code'] === T_CATCH
269
+ || $tokens[$stackPtr]['code'] === T_FINALLY
270
  ) {
271
  if (isset($tokens[$stackPtr]['scope_opener']) === true
272
  && $tokens[$tokens[$stackPtr]['scope_opener']]['code'] === T_COLON
288
  $found = 1;
289
  if ($tokens[($closer + 1)]['code'] !== T_WHITESPACE) {
290
  $found = 0;
291
+ } else if ($tokens[$closer]['line'] !== $tokens[$stackPtr]['line']) {
292
+ $found = 'newline';
293
  } else if ($tokens[($closer + 1)]['content'] !== ' ') {
294
+ $found = strlen($tokens[($closer + 1)]['content']);
 
 
 
 
295
  }
296
 
297
  if ($found !== 1) {
298
  $error = 'Expected 1 space after closing brace; %s found';
299
  $data = [$found];
300
+
301
+ if ($phpcsFile->findNext(Tokens::$commentTokens, ($closer + 1), $stackPtr) !== false) {
302
+ // Comment found between closing brace and keyword, don't auto-fix.
303
+ $phpcsFile->addError($error, $closer, 'SpaceAfterCloseBrace', $data);
304
+ return;
305
+ }
306
+
307
+ $fix = $phpcsFile->addFixableError($error, $closer, 'SpaceAfterCloseBrace', $data);
308
  if ($fix === true) {
309
  if ($found === 0) {
310
  $phpcsFile->fixer->addContent($closer, ' ');
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php CHANGED
@@ -49,7 +49,7 @@ class JavaScriptLintSniff implements Sniff
49
  public function process(File $phpcsFile, $stackPtr)
50
  {
51
  $jslPath = Config::getExecutablePath('jsl');
52
- if (is_null($jslPath) === true) {
53
  return;
54
  }
55
 
49
  public function process(File $phpcsFile, $stackPtr)
50
  {
51
  $jslPath = Config::getExecutablePath('jsl');
52
+ if ($jslPath === null) {
53
  return;
54
  }
55
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php CHANGED
@@ -77,9 +77,9 @@ class OperatorBracketSniff implements Sniff
77
  if ($tokens[$number]['code'] === T_LNUMBER || $tokens[$number]['code'] === T_DNUMBER) {
78
  $previous = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
79
  if ($previous !== false) {
80
- $isAssignment = in_array($tokens[$previous]['code'], Tokens::$assignmentTokens);
81
- $isEquality = in_array($tokens[$previous]['code'], Tokens::$equalityTokens);
82
- $isComparison = in_array($tokens[$previous]['code'], Tokens::$comparisonTokens);
83
  if ($isAssignment === true || $isEquality === true || $isComparison === true) {
84
  // This is a negative assignment or comparison.
85
  // We need to check that the minus and the number are
@@ -100,15 +100,15 @@ class OperatorBracketSniff implements Sniff
100
  // A list of tokens that indicate that the token is not
101
  // part of an arithmetic operation.
102
  $invalidTokens = [
103
- T_COMMA,
104
- T_COLON,
105
- T_OPEN_PARENTHESIS,
106
- T_OPEN_SQUARE_BRACKET,
107
- T_OPEN_SHORT_ARRAY,
108
- T_CASE,
109
  ];
110
 
111
- if (in_array($tokens[$previousToken]['code'], $invalidTokens) === true) {
112
  return;
113
  }
114
  }
@@ -122,7 +122,7 @@ class OperatorBracketSniff implements Sniff
122
  && $tokens[$tokens[$lastBracket]['parenthesis_owner']]['code'] === T_CATCH
123
  ) {
124
  // This is a pipe character inside a catch statement, so it is acting
125
- // as an exception type seperator and not an arithmetic operation.
126
  return;
127
  }
128
  }
@@ -268,20 +268,21 @@ class OperatorBracketSniff implements Sniff
268
  $tokens = $phpcsFile->getTokens();
269
 
270
  $allowed = [
271
- T_VARIABLE => true,
272
- T_LNUMBER => true,
273
- T_DNUMBER => true,
274
- T_STRING => true,
275
- T_WHITESPACE => true,
276
- T_NS_SEPARATOR => true,
277
- T_THIS => true,
278
- T_SELF => true,
279
- T_OBJECT_OPERATOR => true,
280
- T_DOUBLE_COLON => true,
281
- T_MODULUS => true,
282
- T_ISSET => true,
283
- T_ARRAY => true,
284
- T_NONE => true,
 
285
  ];
286
 
287
  // Find the first token in the expression.
@@ -323,7 +324,7 @@ class OperatorBracketSniff implements Sniff
323
  // Find the last token in the expression.
324
  for ($after = ($stackPtr + 1); $after < $phpcsFile->numTokens; $after++) {
325
  // Special case for plus operators because we can't tell if they are used
326
- // for addition or string contact. So assume string concat to be safe.
327
  if ($phpcsFile->tokenizerType === 'JS' && $tokens[$after]['code'] === T_PLUS) {
328
  break;
329
  }
@@ -356,7 +357,7 @@ class OperatorBracketSniff implements Sniff
356
 
357
  $after = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($after - 1), null, true);
358
 
359
- $error = 'Arithmetic operation must be bracketed';
360
  if ($before === $after || $before === $stackPtr || $after === $stackPtr) {
361
  $phpcsFile->addError($error, $stackPtr, 'MissingBrackets');
362
  return;
77
  if ($tokens[$number]['code'] === T_LNUMBER || $tokens[$number]['code'] === T_DNUMBER) {
78
  $previous = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
79
  if ($previous !== false) {
80
+ $isAssignment = isset(Tokens::$assignmentTokens[$tokens[$previous]['code']]);
81
+ $isEquality = isset(Tokens::$equalityTokens[$tokens[$previous]['code']]);
82
+ $isComparison = isset(Tokens::$comparisonTokens[$tokens[$previous]['code']]);
83
  if ($isAssignment === true || $isEquality === true || $isComparison === true) {
84
  // This is a negative assignment or comparison.
85
  // We need to check that the minus and the number are
100
  // A list of tokens that indicate that the token is not
101
  // part of an arithmetic operation.
102
  $invalidTokens = [
103
+ T_COMMA => true,
104
+ T_COLON => true,
105
+ T_OPEN_PARENTHESIS => true,
106
+ T_OPEN_SQUARE_BRACKET => true,
107
+ T_OPEN_SHORT_ARRAY => true,
108
+ T_CASE => true,
109
  ];
110
 
111
+ if (isset($invalidTokens[$tokens[$previousToken]['code']]) === true) {
112
  return;
113
  }
114
  }
122
  && $tokens[$tokens[$lastBracket]['parenthesis_owner']]['code'] === T_CATCH
123
  ) {
124
  // This is a pipe character inside a catch statement, so it is acting
125
+ // as an exception type separator and not an arithmetic operation.
126
  return;
127
  }
128
  }
268
  $tokens = $phpcsFile->getTokens();
269
 
270
  $allowed = [
271
+ T_VARIABLE => true,
272
+ T_LNUMBER => true,
273
+ T_DNUMBER => true,
274
+ T_STRING => true,
275
+ T_CONSTANT_ENCAPSED_STRING => true,
276
+ T_WHITESPACE => true,
277
+ T_NS_SEPARATOR => true,
278
+ T_THIS => true,
279
+ T_SELF => true,
280
+ T_OBJECT_OPERATOR => true,
281
+ T_DOUBLE_COLON => true,
282
+ T_MODULUS => true,
283
+ T_ISSET => true,
284
+ T_ARRAY => true,
285
+ T_NONE => true,
286
  ];
287
 
288
  // Find the first token in the expression.
324
  // Find the last token in the expression.
325
  for ($after = ($stackPtr + 1); $after < $phpcsFile->numTokens; $after++) {
326
  // Special case for plus operators because we can't tell if they are used
327
+ // for addition or string concat. So assume string concat to be safe.
328
  if ($phpcsFile->tokenizerType === 'JS' && $tokens[$after]['code'] === T_PLUS) {
329
  break;
330
  }
357
 
358
  $after = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($after - 1), null, true);
359
 
360
+ $error = 'Operation must be bracketed';
361
  if ($before === $after || $before === $stackPtr || $after === $stackPtr) {
362
  $phpcsFile->addError($error, $stackPtr, 'MissingBrackets');
363
  return;
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php CHANGED
@@ -298,95 +298,64 @@ class FunctionDeclarationArgumentSpacingSniff implements Sniff
298
  $nextToken++;
299
  }
300
 
301
- if ($tokens[$nextToken]['code'] !== T_ELLIPSIS && $nextToken !== $nextParam) {
302
- // There was a type hint, so check the spacing between
303
- // the hint and the variable as well.
304
- $hint = $tokens[$nextToken]['content'];
305
-
306
- if ($gap !== 1) {
307
- $error = 'Expected 1 space between type hint and argument "%s"; %s found';
308
- $data = [
309
- $arg,
310
- $gap,
311
- ];
312
- $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpacingAfterHint', $data);
313
- if ($fix === true) {
314
- if ($gap === 0) {
315
- $phpcsFile->fixer->addContent($nextToken, ' ');
316
- } else {
317
- $phpcsFile->fixer->replaceToken(($nextToken + 1), ' ');
318
- }
319
- }
320
- }
321
-
322
- $spaceAfterOpen = 0;
323
- if ($tokens[($bracket + 1)]['code'] === T_WHITESPACE) {
324
- $spaceAfterOpen = strlen($tokens[($bracket + 1)]['content']);
325
- }
326
-
327
- if ($multiLine === false && $spaceAfterOpen !== $this->requiredSpacesAfterOpen) {
328
- $error = 'Expected %s spaces between opening bracket and type hint "%s"; %s found';
329
- $data = [
330
- $this->requiredSpacesAfterOpen,
331
- $hint,
332
- $spaceAfterOpen,
333
- ];
334
- $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpacingAfterOpenHint', $data);
335
- if ($fix === true) {
336
- $padding = str_repeat(' ', $this->requiredSpacesAfterOpen);
337
- if ($spaceAfterOpen === 0) {
338
- $phpcsFile->fixer->addContent($openBracket, $padding);
339
- } else {
340
- $phpcsFile->fixer->replaceToken(($openBracket + 1), $padding);
341
- }
342
- }
343
- }
344
- } else if ($multiLine === false && $gap !== $this->requiredSpacesAfterOpen) {
345
- $error = 'Expected %s spaces between opening bracket and argument "%s"; %s found';
346
  $data = [
347
- $this->requiredSpacesAfterOpen,
348
  $arg,
349
  $gap,
350
  ];
351
- $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpacingAfterOpen', $data);
352
  if ($fix === true) {
353
- $padding = str_repeat(' ', $this->requiredSpacesAfterOpen);
354
  if ($gap === 0) {
355
- $phpcsFile->fixer->addContent($openBracket, $padding);
356
  } else {
357
- $phpcsFile->fixer->replaceToken(($openBracket + 1), $padding);
358
  }
359
  }
360
- }//end if
361
  }//end if
362
 
363
  $params[] = $nextParam;
364
  }//end while
365
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
  $gap = 0;
367
  if ($tokens[($closeBracket - 1)]['code'] === T_WHITESPACE) {
368
- $gap = strlen($tokens[($closeBracket - 1)]['content']);
369
  }
370
 
371
- if (empty($params) === true) {
372
- // There are no parameters for this function.
373
- if (($closeBracket - $openBracket) !== 1) {
374
- $error = 'Expected 0 spaces between brackets of function declaration; %s found';
375
- $data = [$gap];
376
- $fix = $phpcsFile->addFixableError($error, $openBracket, 'SpacingBetween', $data);
377
- if ($fix === true) {
378
- $phpcsFile->fixer->replaceToken(($openBracket + 1), '');
379
- }
380
- }
381
- } else if ($multiLine === false && $gap !== $this->requiredSpacesBeforeClose) {
382
- $lastParam = array_pop($params);
383
- $error = 'Expected %s spaces between argument "%s" and closing bracket; %s found';
384
- $data = [
385
  $this->requiredSpacesBeforeClose,
386
- $tokens[$lastParam]['content'],
387
  $gap,
388
  ];
389
- $fix = $phpcsFile->addFixableError($error, $closeBracket, 'SpacingBeforeClose', $data);
390
  if ($fix === true) {
391
  $padding = str_repeat(' ', $this->requiredSpacesBeforeClose);
392
  if ($gap === 0) {
@@ -395,7 +364,29 @@ class FunctionDeclarationArgumentSpacingSniff implements Sniff
395
  $phpcsFile->fixer->replaceToken(($closeBracket - 1), $padding);
396
  }
397
  }
398
- }//end if
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
399
 
400
  }//end processBracket()
401
 
298
  $nextToken++;
299
  }
300
 
301
+ if ($gap !== 1
302
+ && $tokens[$nextToken]['code'] !== T_ELLIPSIS
303
+ && $nextToken !== $nextParam
304
+ ) {
305
+ $error = 'Expected 1 space between type hint and argument "%s"; %s found';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  $data = [
 
307
  $arg,
308
  $gap,
309
  ];
310
+ $fix = $phpcsFile->addFixableError($error, $nextToken, 'SpacingAfterHint', $data);
311
  if ($fix === true) {
 
312
  if ($gap === 0) {
313
+ $phpcsFile->fixer->addContent($nextToken, ' ');
314
  } else {
315
+ $phpcsFile->fixer->replaceToken(($nextToken + 1), ' ');
316
  }
317
  }
318
+ }
319
  }//end if
320
 
321
  $params[] = $nextParam;
322
  }//end while
323
 
324
+ if (empty($params) === true) {
325
+ // Check spacing around parenthesis.
326
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), $closeBracket, true);
327
+ if ($next === false) {
328
+ if (($closeBracket - $openBracket) !== 1) {
329
+ $error = 'Expected 0 spaces between parenthesis of function declaration; %s found';
330
+ $data = [$tokens[($openBracket + 1)]['length']];
331
+ $fix = $phpcsFile->addFixableError($error, $openBracket, 'SpacingBetween', $data);
332
+ if ($fix === true) {
333
+ $phpcsFile->fixer->replaceToken(($openBracket + 1), '');
334
+ }
335
+ }
336
+
337
+ // No params, so we don't check normal spacing rules.
338
+ return;
339
+ }
340
+ }
341
+
342
+ // Only check spacing around parenthesis for single line definitions.
343
+ if ($multiLine === true) {
344
+ return;
345
+ }
346
+
347
  $gap = 0;
348
  if ($tokens[($closeBracket - 1)]['code'] === T_WHITESPACE) {
349
+ $gap = $tokens[($closeBracket - 1)]['length'];
350
  }
351
 
352
+ if ($gap !== $this->requiredSpacesBeforeClose) {
353
+ $error = 'Expected %s spaces before closing parenthesis; %s found';
354
+ $data = [
 
 
 
 
 
 
 
 
 
 
 
355
  $this->requiredSpacesBeforeClose,
 
356
  $gap,
357
  ];
358
+ $fix = $phpcsFile->addFixableError($error, $closeBracket, 'SpacingBeforeClose', $data);
359
  if ($fix === true) {
360
  $padding = str_repeat(' ', $this->requiredSpacesBeforeClose);
361
  if ($gap === 0) {
364
  $phpcsFile->fixer->replaceToken(($closeBracket - 1), $padding);
365
  }
366
  }
367
+ }
368
+
369
+ $gap = 0;
370
+ if ($tokens[($openBracket + 1)]['code'] === T_WHITESPACE) {
371
+ $gap = $tokens[($openBracket + 1)]['length'];
372
+ }
373
+
374
+ if ($gap !== $this->requiredSpacesAfterOpen) {
375
+ $error = 'Expected %s spaces after opening parenthesis; %s found';
376
+ $data = [
377
+ $this->requiredSpacesAfterOpen,
378
+ $gap,
379
+ ];
380
+ $fix = $phpcsFile->addFixableError($error, $openBracket, 'SpacingAfterOpen', $data);
381
+ if ($fix === true) {
382
+ $padding = str_repeat(' ', $this->requiredSpacesAfterOpen);
383
+ if ($gap === 0) {
384
+ $phpcsFile->fixer->addContent($openBracket, $padding);
385
+ } else {
386
+ $phpcsFile->fixer->replaceToken(($openBracket + 1), $padding);
387
+ }
388
+ }
389
+ }
390
 
391
  }//end processBracket()
392
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php CHANGED
@@ -179,7 +179,7 @@ class MultiLineFunctionDeclarationSniff extends PEARFunctionDeclarationSniff
179
  continue;
180
  }
181
 
182
- $next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true);
183
  if ($tokens[$next]['line'] === $tokens[$i]['line']) {
184
  $error = 'Multi-line '.$type.' declarations must define one parameter per line';
185
  $fix = $phpcsFile->addFixableError($error, $next, $errorPrefix.'OneParamPerLine');
179
  continue;
180
  }
181
 
182
+ $next = $phpcsFile->findNext(Tokens::$emptyTokens, ($i + 1), null, true);
183
  if ($tokens[$next]['line'] === $tokens[$i]['line']) {
184
  $error = 'Multi-line '.$type.' declarations must define one parameter per line';
185
  $fix = $phpcsFile->addFixableError($error, $next, $errorPrefix.'OneParamPerLine');
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php CHANGED
@@ -31,23 +31,8 @@ class ValidVariableNameSniff extends AbstractVariableSniff
31
  $tokens = $phpcsFile->getTokens();
32
  $varName = ltrim($tokens[$stackPtr]['content'], '$');
33
 
34
- $phpReservedVars = [
35
- '_SERVER',
36
- '_GET',
37
- '_POST',
38
- '_REQUEST',
39
- '_SESSION',
40
- '_ENV',
41
- '_COOKIE',
42
- '_FILES',
43
- 'GLOBALS',
44
- 'http_response_header',
45
- 'HTTP_RAW_POST_DATA',
46
- 'php_errormsg',
47
- ];
48
-
49
  // If it's a php reserved var, then its ok.
50
- if (in_array($varName, $phpReservedVars) === true) {
51
  return;
52
  }
53
 
@@ -171,25 +156,10 @@ class ValidVariableNameSniff extends AbstractVariableSniff
171
  {
172
  $tokens = $phpcsFile->getTokens();
173
 
174
- $phpReservedVars = [
175
- '_SERVER',
176
- '_GET',
177
- '_POST',
178
- '_REQUEST',
179
- '_SESSION',
180
- '_ENV',
181
- '_COOKIE',
182
- '_FILES',
183
- 'GLOBALS',
184
- 'http_response_header',
185
- 'HTTP_RAW_POST_DATA',
186
- 'php_errormsg',
187
- ];
188
-
189
  if (preg_match_all('|[^\\\]\${?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)|', $tokens[$stackPtr]['content'], $matches) !== 0) {
190
  foreach ($matches[1] as $varName) {
191
  // If it's a php reserved var, then its ok.
192
- if (in_array($varName, $phpReservedVars) === true) {
193
  continue;
194
  }
195
 
31
  $tokens = $phpcsFile->getTokens();
32
  $varName = ltrim($tokens[$stackPtr]['content'], '$');
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  // If it's a php reserved var, then its ok.
35
+ if (isset($this->phpReservedVars[$varName]) === true) {
36
  return;
37
  }
38
 
156
  {
157
  $tokens = $phpcsFile->getTokens();
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  if (preg_match_all('|[^\\\]\${?([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)|', $tokens[$stackPtr]['content'], $matches) !== 0) {
160
  foreach ($matches[1] as $varName) {
161
  // If it's a php reserved var, then its ok.
162
+ if (isset($this->phpReservedVars[$varName]) === true) {
163
  continue;
164
  }
165
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php CHANGED
@@ -32,13 +32,13 @@ class ComparisonOperatorUsageSniff implements Sniff
32
  * @var array
33
  */
34
  private static $validOps = [
35
- T_IS_IDENTICAL,
36
- T_IS_NOT_IDENTICAL,
37
- T_LESS_THAN,
38
- T_GREATER_THAN,
39
- T_IS_GREATER_OR_EQUAL,
40
- T_IS_SMALLER_OR_EQUAL,
41
- T_INSTANCEOF,
42
  ];
43
 
44
  /**
@@ -153,9 +153,11 @@ class ComparisonOperatorUsageSniff implements Sniff
153
  $foundOps = 0;
154
  $foundBools = 0;
155
 
 
 
156
  for ($i = $start; $i <= $end; $i++) {
157
  $type = $tokens[$i]['code'];
158
- if (in_array($type, array_keys(self::$invalidOps[$tokenizer])) === true) {
159
  $error = 'Operator %s prohibited; use %s instead';
160
  $data = [
161
  $tokens[$i]['content'],
@@ -163,10 +165,19 @@ class ComparisonOperatorUsageSniff implements Sniff
163
  ];
164
  $phpcsFile->addError($error, $i, 'NotAllowed', $data);
165
  $foundOps++;
166
- } else if (in_array($type, self::$validOps) === true) {
167
  $foundOps++;
168
  }
169
 
 
 
 
 
 
 
 
 
 
170
  if ($tokens[$i]['code'] === T_TRUE || $tokens[$i]['code'] === T_FALSE) {
171
  $foundBools++;
172
  }
@@ -193,6 +204,10 @@ class ComparisonOperatorUsageSniff implements Sniff
193
  $foundOps++;
194
  }
195
  }
 
 
 
 
196
  }//end for
197
 
198
  $requiredOps++;
32
  * @var array
33
  */
34
  private static $validOps = [
35
+ T_IS_IDENTICAL => true,
36
+ T_IS_NOT_IDENTICAL => true,
37
+ T_LESS_THAN => true,
38
+ T_GREATER_THAN => true,
39
+ T_IS_GREATER_OR_EQUAL => true,
40
+ T_IS_SMALLER_OR_EQUAL => true,
41
+ T_INSTANCEOF => true,
42
  ];
43
 
44
  /**
153
  $foundOps = 0;
154
  $foundBools = 0;
155
 
156
+ $lastNonEmpty = $start;
157
+
158
  for ($i = $start; $i <= $end; $i++) {
159
  $type = $tokens[$i]['code'];
160
+ if (isset(self::$invalidOps[$tokenizer][$type]) === true) {
161
  $error = 'Operator %s prohibited; use %s instead';
162
  $data = [
163
  $tokens[$i]['content'],
165
  ];
166
  $phpcsFile->addError($error, $i, 'NotAllowed', $data);
167
  $foundOps++;
168
+ } else if (isset(self::$validOps[$type]) === true) {
169
  $foundOps++;
170
  }
171
 
172
+ if ($type === T_OPEN_PARENTHESIS
173
+ && isset($tokens[$i]['parenthesis_closer']) === true
174
+ && isset(Tokens::$functionNameTokens[$tokens[$lastNonEmpty]['code']]) === true
175
+ ) {
176
+ $i = $tokens[$i]['parenthesis_closer'];
177
+ $lastNonEmpty = $i;
178
+ continue;
179
+ }
180
+
181
  if ($tokens[$i]['code'] === T_TRUE || $tokens[$i]['code'] === T_FALSE) {
182
  $foundBools++;
183
  }
204
  $foundOps++;
205
  }
206
  }
207
+
208
+ if (isset(Tokens::$emptyTokens[$type]) === false) {
209
+ $lastNonEmpty = $i;
210
+ }
211
  }//end for
212
 
213
  $requiredOps++;
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php CHANGED
@@ -75,6 +75,10 @@ class CommentedOutCodeSniff implements Sniff
75
 
76
  $lastCommentBlockToken = $stackPtr;
77
  for ($i = $stackPtr; $i < $phpcsFile->numTokens; $i++) {
 
 
 
 
78
  if ($tokens[$i]['code'] === T_WHITESPACE) {
79
  continue;
80
  }
@@ -84,9 +88,18 @@ class CommentedOutCodeSniff implements Sniff
84
  continue;
85
  }
86
 
87
- if ($tokens[$stackPtr]['code'] !== $tokens[$i]['code']
88
- || ($lastLineSeen + 1) < $tokens[$i]['line']
 
89
  ) {
 
 
 
 
 
 
 
 
90
  break;
91
  }
92
 
@@ -96,6 +109,7 @@ class CommentedOutCodeSniff implements Sniff
96
  */
97
 
98
  $tokenContent = trim($tokens[$i]['content']);
 
99
 
100
  if ($commentStyle === 'line') {
101
  if (substr($tokenContent, 0, 2) === '//') {
@@ -116,6 +130,7 @@ class CommentedOutCodeSniff implements Sniff
116
 
117
  if (substr($tokenContent, -2) === '*/') {
118
  $tokenContent = substr($tokenContent, 0, -2);
 
119
  }
120
 
121
  if (substr($tokenContent, 0, 1) === '*') {
@@ -127,8 +142,18 @@ class CommentedOutCodeSniff implements Sniff
127
  $lastLineSeen = $tokens[$i]['line'];
128
 
129
  $lastCommentBlockToken = $i;
 
 
 
 
 
130
  }//end for
131
 
 
 
 
 
 
132
  // Quite a few comments use multiple dashes, equals signs etc
133
  // to frame comments and licence headers.
134
  $content = preg_replace('/[-=#*]{2,}/', '-', $content);
@@ -172,24 +197,35 @@ class CommentedOutCodeSniff implements Sniff
172
  valid code.
173
  */
174
 
175
- // First token is always the opening PHP tag.
176
  if ($stringTokens[0]['code'] !== T_OPEN_TAG) {
177
  return ($lastCommentBlockToken + 1);
 
 
 
178
  }
179
 
180
- // Last token is always the closing PHP tag, unless something went wrong.
181
  if (isset($stringTokens[($numTokens - 1)]) === false
182
  || $stringTokens[($numTokens - 1)]['code'] !== T_CLOSE_TAG
183
  ) {
184
  return ($lastCommentBlockToken + 1);
 
 
 
185
  }
186
 
187
  // Second last token is always whitespace or a comment, depending
188
  // on the code inside the comment.
189
- if ($phpcsFile->tokenizerType === 'PHP'
190
- && isset(Tokens::$emptyTokens[$stringTokens[($numTokens - 2)]['code']]) === false
191
- ) {
192
- return ($lastCommentBlockToken + 1);
 
 
 
 
 
193
  }
194
 
195
  $emptyTokens = [
@@ -202,9 +238,10 @@ class CommentedOutCodeSniff implements Sniff
202
  ];
203
  $emptyTokens += Tokens::$phpcsCommentTokens;
204
 
205
- $numComment = 0;
206
- $numPossible = 0;
207
- $numCode = 0;
 
208
 
209
  for ($i = 0; $i < $numTokens; $i++) {
210
  if (isset($emptyTokens[$stringTokens[$i]['code']]) === true) {
@@ -221,17 +258,16 @@ class CommentedOutCodeSniff implements Sniff
221
  // Looks like code.
222
  $numCode++;
223
  }
224
- }
225
 
226
- // We subtract 3 from the token number so we ignore the start/end tokens
227
- // and their surrounding whitespace. We take 2 off the number of code
228
- // tokens so we ignore the start/end tokens.
229
- if ($numTokens > 3) {
230
- $numTokens -= 3;
231
  }
232
 
233
- if ($numCode >= 2) {
234
- $numCode -= 2;
 
 
235
  }
236
 
237
  $percentCode = ceil((($numCode / $numTokens) * 100));
75
 
76
  $lastCommentBlockToken = $stackPtr;
77
  for ($i = $stackPtr; $i < $phpcsFile->numTokens; $i++) {
78
+ if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === false) {
79
+ break;
80
+ }
81
+
82
  if ($tokens[$i]['code'] === T_WHITESPACE) {
83
  continue;
84
  }
88
  continue;
89
  }
90
 
91
+ if ($commentStyle === 'line'
92
+ && ($lastLineSeen + 1) <= $tokens[$i]['line']
93
+ && strpos($tokens[$i]['content'], '/*') === 0
94
  ) {
95
+ // First non-whitespace token on a new line is start of a different style comment.
96
+ break;
97
+ }
98
+
99
+ if ($commentStyle === 'line'
100
+ && ($lastLineSeen + 1) < $tokens[$i]['line']
101
+ ) {
102
+ // Blank line breaks a '//' style comment block.
103
  break;
104
  }
105
 
109
  */
110
 
111
  $tokenContent = trim($tokens[$i]['content']);
112
+ $break = false;
113
 
114
  if ($commentStyle === 'line') {
115
  if (substr($tokenContent, 0, 2) === '//') {
130
 
131
  if (substr($tokenContent, -2) === '*/') {
132
  $tokenContent = substr($tokenContent, 0, -2);
133
+ $break = true;
134
  }
135
 
136
  if (substr($tokenContent, 0, 1) === '*') {
142
  $lastLineSeen = $tokens[$i]['line'];
143
 
144
  $lastCommentBlockToken = $i;
145
+
146
+ if ($break === true) {
147
+ // Closer of a block comment found.
148
+ break;
149
+ }
150
  }//end for
151
 
152
+ // Ignore typical warning suppression annotations from other tools.
153
+ if (preg_match('`^\s*@[A-Za-z()\._-]+\s*$`', $content) === 1) {
154
+ return ($lastCommentBlockToken + 1);
155
+ }
156
+
157
  // Quite a few comments use multiple dashes, equals signs etc
158
  // to frame comments and licence headers.
159
  $content = preg_replace('/[-=#*]{2,}/', '-', $content);
197
  valid code.
198
  */
199
 
200
+ // First token is always the opening tag.
201
  if ($stringTokens[0]['code'] !== T_OPEN_TAG) {
202
  return ($lastCommentBlockToken + 1);
203
+ } else {
204
+ array_shift($stringTokens);
205
+ --$numTokens;
206
  }
207
 
208
+ // Last token is always the closing tag, unless something went wrong.
209
  if (isset($stringTokens[($numTokens - 1)]) === false
210
  || $stringTokens[($numTokens - 1)]['code'] !== T_CLOSE_TAG
211
  ) {
212
  return ($lastCommentBlockToken + 1);
213
+ } else {
214
+ array_pop($stringTokens);
215
+ --$numTokens;
216
  }
217
 
218
  // Second last token is always whitespace or a comment, depending
219
  // on the code inside the comment.
220
+ if ($phpcsFile->tokenizerType === 'PHP') {
221
+ if (isset(Tokens::$emptyTokens[$stringTokens[($numTokens - 1)]['code']]) === false) {
222
+ return ($lastCommentBlockToken + 1);
223
+ }
224
+
225
+ if ($stringTokens[($numTokens - 1)]['code'] === T_WHITESPACE) {
226
+ array_pop($stringTokens);
227
+ --$numTokens;
228
+ }
229
  }
230
 
231
  $emptyTokens = [
238
  ];
239
  $emptyTokens += Tokens::$phpcsCommentTokens;
240
 
241
+ $numComment = 0;
242
+ $numPossible = 0;
243
+ $numCode = 0;
244
+ $numNonWhitespace = 0;
245
 
246
  for ($i = 0; $i < $numTokens; $i++) {
247
  if (isset($emptyTokens[$stringTokens[$i]['code']]) === true) {
258
  // Looks like code.
259
  $numCode++;
260
  }
 
261
 
262
+ if ($stringTokens[$i]['code'] !== T_WHITESPACE) {
263
+ ++$numNonWhitespace;
264
+ }
 
 
265
  }
266
 
267
+ // Ignore comments with only two or less non-whitespace tokens.
268
+ // Sample size too small for a reliably determination.
269
+ if ($numNonWhitespace <= 2) {
270
+ return ($lastCommentBlockToken + 1);
271
  }
272
 
273
  $percentCode = ceil((($numCode / $numTokens) * 100));
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php CHANGED
@@ -90,7 +90,8 @@ class DisallowComparisonAssignmentSniff implements Sniff
90
  }
91
 
92
  for ($i = ($stackPtr + 1); $i < $endStatement; $i++) {
93
- if (isset(Tokens::$comparisonTokens[$tokens[$i]['code']]) === true
 
94
  || $tokens[$i]['code'] === T_INLINE_THEN
95
  ) {
96
  $error = 'The value of a comparison must not be assigned to a variable';
90
  }
91
 
92
  for ($i = ($stackPtr + 1); $i < $endStatement; $i++) {
93
+ if ((isset(Tokens::$comparisonTokens[$tokens[$i]['code']]) === true
94
+ && $tokens[$i]['code'] !== T_COALESCE)
95
  || $tokens[$i]['code'] === T_INLINE_THEN
96
  ) {
97
  $error = 'The value of a comparison must not be assigned to a variable';
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php CHANGED
@@ -52,6 +52,18 @@ class DisallowMultipleAssignmentsSniff implements Sniff
52
  }
53
  }
54
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  /*
56
  The general rule is:
57
  Find an equal sign and go backwards along the line. If you hit an
@@ -89,81 +101,61 @@ class DisallowMultipleAssignmentsSniff implements Sniff
89
  return;
90
  }
91
 
92
- // Deal with this type of variable: self::$var by setting the var
93
- // token to be "self" rather than "$var".
94
- if ($tokens[($varToken - 1)]['code'] === T_DOUBLE_COLON) {
95
- $varToken = ($varToken - 2);
96
- }
97
 
98
- // Deal with this type of variable: $obj->$var by setting the var
99
- // token to be "$obj" rather than "$var".
100
- if ($tokens[($varToken - 1)]['code'] === T_OBJECT_OPERATOR) {
101
- $varToken = ($varToken - 2);
102
- }
103
 
104
- // Deal with this type of variable: $$var by setting the var
105
- // token to be "$" rather than "$var".
106
- if ($tokens[($varToken - 1)]['content'] === '$') {
107
- $varToken--;
108
- }
 
 
 
 
109
 
110
- // Ignore member var definitions.
111
- $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($varToken - 1), null, true);
112
- if (isset(Tokens::$scopeModifiers[$tokens[$prev]['code']]) === true
113
- || $tokens[$prev]['code'] === T_VAR
 
114
  ) {
115
- return;
116
  }
117
 
118
- if ($tokens[$prev]['code'] === T_STATIC) {
 
 
 
 
119
  return;
120
  }
121
 
122
- // Make sure this variable is the first thing in the statement.
123
- $varLine = $tokens[$varToken]['line'];
124
- $prevLine = 0;
125
- for ($i = ($varToken - 1); $i >= 0; $i--) {
126
- if ($tokens[$i]['code'] === T_SEMICOLON) {
127
- // We reached the end of the statement.
128
- return;
129
- }
130
-
131
- if ($tokens[$i]['code'] === T_INLINE_THEN) {
132
- // We reached the end of the inline THEN statement.
133
- return;
134
- }
135
-
136
- if ($tokens[$i]['code'] === T_INLINE_ELSE) {
137
- // We reached the end of the inline ELSE statement.
138
- return;
139
- }
140
-
141
- if ($tokens[$i]['code'] === T_OPEN_TAG) {
142
- // We reached the end of the code block.
143
- return;
144
- }
145
-
146
- if (isset(Tokens::$emptyTokens[$tokens[$i]['code']]) === false) {
147
- $prevLine = $tokens[$i]['line'];
148
- break;
149
- }
150
- }//end for
151
-
152
  // Ignore the first part of FOR loops as we are allowed to
153
  // assign variables there even though the variable is not the
154
- // first thing on the line. Also ignore WHILE loops.
155
- if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS && isset($tokens[$i]['parenthesis_owner']) === true) {
156
- $owner = $tokens[$i]['parenthesis_owner'];
157
- if ($tokens[$owner]['code'] === T_FOR || $tokens[$owner]['code'] === T_WHILE) {
158
  return;
159
  }
160
  }
161
 
162
- if ($prevLine === $varLine) {
163
- $error = 'Assignments must be the first block of code on a line';
164
- $phpcsFile->addError($error, $stackPtr, 'Found');
 
 
 
 
 
 
165
  }
166
 
 
 
 
167
  }//end process()
168
 
169
 
52
  }
53
  }
54
 
55
+ // Ignore assignments in WHILE loop conditions.
56
+ if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
57
+ $nested = $tokens[$stackPtr]['nested_parenthesis'];
58
+ foreach ($nested as $opener => $closer) {
59
+ if (isset($tokens[$opener]['parenthesis_owner']) === true
60
+ && $tokens[$tokens[$opener]['parenthesis_owner']]['code'] === T_WHILE
61
+ ) {
62
+ return;
63
+ }
64
+ }
65
+ }
66
+
67
  /*
68
  The general rule is:
69
  Find an equal sign and go backwards along the line. If you hit an
101
  return;
102
  }
103
 
104
+ $start = $phpcsFile->findStartOfStatement($varToken);
 
 
 
 
105
 
106
+ $allowed = Tokens::$emptyTokens;
 
 
 
 
107
 
108
+ $allowed[T_STRING] = T_STRING;
109
+ $allowed[T_NS_SEPARATOR] = T_NS_SEPARATOR;
110
+ $allowed[T_DOUBLE_COLON] = T_DOUBLE_COLON;
111
+ $allowed[T_OBJECT_OPERATOR] = T_OBJECT_OPERATOR;
112
+ $allowed[T_ASPERAND] = T_ASPERAND;
113
+ $allowed[T_DOLLAR] = T_DOLLAR;
114
+ $allowed[T_SELF] = T_SELF;
115
+ $allowed[T_PARENT] = T_PARENT;
116
+ $allowed[T_STATIC] = T_STATIC;
117
 
118
+ $varToken = $phpcsFile->findPrevious($allowed, ($varToken - 1), null, true);
119
+
120
+ if ($varToken < $start
121
+ && $tokens[$varToken]['code'] !== T_OPEN_PARENTHESIS
122
+ && $tokens[$varToken]['code'] !== T_OPEN_SQUARE_BRACKET
123
  ) {
124
+ $varToken = $start;
125
  }
126
 
127
+ // Ignore member var definitions.
128
+ if (isset(Tokens::$scopeModifiers[$tokens[$varToken]['code']]) === true
129
+ || $tokens[$varToken]['code'] === T_VAR
130
+ || $tokens[$varToken]['code'] === T_STATIC
131
+ ) {
132
  return;
133
  }
134
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135
  // Ignore the first part of FOR loops as we are allowed to
136
  // assign variables there even though the variable is not the
137
+ // first thing on the line.
138
+ if ($tokens[$varToken]['code'] === T_OPEN_PARENTHESIS && isset($tokens[$varToken]['parenthesis_owner']) === true) {
139
+ $owner = $tokens[$varToken]['parenthesis_owner'];
140
+ if ($tokens[$owner]['code'] === T_FOR) {
141
  return;
142
  }
143
  }
144
 
145
+ if ($tokens[$varToken]['code'] === T_VARIABLE
146
+ || $tokens[$varToken]['code'] === T_OPEN_TAG
147
+ || $tokens[$varToken]['code'] === T_INLINE_THEN
148
+ || $tokens[$varToken]['code'] === T_INLINE_ELSE
149
+ || $tokens[$varToken]['code'] === T_SEMICOLON
150
+ || $tokens[$varToken]['code'] === T_CLOSE_PARENTHESIS
151
+ || isset($allowed[$tokens[$varToken]['code']]) === true
152
+ ) {
153
+ return;
154
  }
155
 
156
+ $error = 'Assignments must be the first block of code on a line';
157
+ $phpcsFile->addError($error, $stackPtr, 'Found');
158
+
159
  }//end process()
160
 
161
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php CHANGED
@@ -11,7 +11,6 @@ namespace PHP_CodeSniffer\Standards\Squiz\Sniffs\Scope;
11
 
12
  use PHP_CodeSniffer\Sniffs\AbstractVariableSniff;
13
  use PHP_CodeSniffer\Files\File;
14
- use PHP_CodeSniffer\Util\Tokens;
15
 
16
  class MemberVarScopeSniff extends AbstractVariableSniff
17
  {
@@ -27,24 +26,17 @@ class MemberVarScopeSniff extends AbstractVariableSniff
27
  */
28
  protected function processMemberVar(File $phpcsFile, $stackPtr)
29
  {
30
- $tokens = $phpcsFile->getTokens();
31
-
32
- $modifier = null;
33
- for ($i = ($stackPtr - 1); $i > 0; $i--) {
34
- if ($tokens[$i]['line'] < $tokens[$stackPtr]['line']) {
35
- break;
36
- } else if (isset(Tokens::$scopeModifiers[$tokens[$i]['code']]) === true) {
37
- $modifier = $i;
38
- break;
39
- }
40
- }
41
 
42
- if ($modifier === null) {
43
- $error = 'Scope modifier not specified for member variable "%s"';
44
- $data = [$tokens[$stackPtr]['content']];
45
- $phpcsFile->addError($error, $stackPtr, 'Missing', $data);
46
  }
47
 
 
 
 
 
48
  }//end processMemberVar()
49
 
50
 
11
 
12
  use PHP_CodeSniffer\Sniffs\AbstractVariableSniff;
13
  use PHP_CodeSniffer\Files\File;
 
14
 
15
  class MemberVarScopeSniff extends AbstractVariableSniff
16
  {
26
  */
27
  protected function processMemberVar(File $phpcsFile, $stackPtr)
28
  {
29
+ $tokens = $phpcsFile->getTokens();
30
+ $properties = $phpcsFile->getMemberProperties($stackPtr);
 
 
 
 
 
 
 
 
 
31
 
32
+ if ($properties === [] || $properties['scope_specified'] !== false) {
33
+ return;
 
 
34
  }
35
 
36
+ $error = 'Scope modifier not specified for member variable "%s"';
37
+ $data = [$tokens[$stackPtr]['content']];
38
+ $phpcsFile->addError($error, $stackPtr, 'Missing', $data);
39
+
40
  }//end processMemberVar()
41
 
42
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php CHANGED
@@ -292,8 +292,7 @@ class ControlStructureSpacingSniff implements Sniff
292
  }
293
 
294
  if ($tokens[$owner]['code'] === T_CLOSURE
295
- && ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true
296
- || $phpcsFile->hasCondition($stackPtr, T_CLOSURE) === true
297
  || isset($tokens[$stackPtr]['nested_parenthesis']) === true)
298
  ) {
299
  return;
292
  }
293
 
294
  if ($tokens[$owner]['code'] === T_CLOSURE
295
+ && ($phpcsFile->hasCondition($stackPtr, [T_FUNCTION, T_CLOSURE]) === true
 
296
  || isset($tokens[$stackPtr]['nested_parenthesis']) === true)
297
  ) {
298
  return;
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php CHANGED
@@ -83,8 +83,7 @@ class FunctionClosingBraceSpaceSniff implements Sniff
83
  }
84
 
85
  $nestedFunction = false;
86
- if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true
87
- || $phpcsFile->hasCondition($stackPtr, T_CLOSURE) === true
88
  || isset($tokens[$stackPtr]['nested_parenthesis']) === true
89
  ) {
90
  $nestedFunction = true;
83
  }
84
 
85
  $nestedFunction = false;
86
+ if ($phpcsFile->hasCondition($stackPtr, [T_FUNCTION, T_CLOSURE]) === true
 
87
  || isset($tokens[$stackPtr]['nested_parenthesis']) === true
88
  ) {
89
  $nestedFunction = true;
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
  /**
3
- * Checks the separation between methods in a class or interface.
4
  *
5
  * @author Greg Sherwood <gsherwood@squiz.net>
6
  * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
@@ -23,6 +23,27 @@ class FunctionSpacingSniff implements Sniff
23
  */
24
  public $spacing = 2;
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  /**
28
  * Returns an array of tokens this test wants to listen for.
@@ -47,13 +68,39 @@ class FunctionSpacingSniff implements Sniff
47
  */
48
  public function process(File $phpcsFile, $stackPtr)
49
  {
50
- $tokens = $phpcsFile->getTokens();
51
- $this->spacing = (int) $this->spacing;
 
 
 
 
 
 
 
52
 
53
- /*
54
- Check the number of blank lines
55
- after the function.
56
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
58
  if (isset($tokens[$stackPtr]['scope_closer']) === false) {
59
  // Must be an interface method, so the closer is the semicolon.
@@ -62,6 +109,32 @@ class FunctionSpacingSniff implements Sniff
62
  $closer = $tokens[$stackPtr]['scope_closer'];
63
  }
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  // Allow for comments on the same line as the closer.
66
  for ($nextLineToken = ($closer + 1); $nextLineToken < $phpcsFile->numTokens; $nextLineToken++) {
67
  if ($tokens[$nextLineToken]['line'] !== $tokens[$closer]['line']) {
@@ -69,42 +142,50 @@ class FunctionSpacingSniff implements Sniff
69
  }
70
  }
71
 
 
 
 
 
 
 
 
 
72
  $foundLines = 0;
73
  if ($nextLineToken === ($phpcsFile->numTokens - 1)) {
74
  // We are at the end of the file.
75
  // Don't check spacing after the function because this
76
  // should be done by an EOF sniff.
77
- $foundLines = $this->spacing;
78
  } else {
79
  $nextContent = $phpcsFile->findNext(T_WHITESPACE, $nextLineToken, null, true);
80
  if ($nextContent === false) {
81
  // We are at the end of the file.
82
  // Don't check spacing after the function because this
83
  // should be done by an EOF sniff.
84
- $foundLines = $this->spacing;
85
  } else {
86
  $foundLines += ($tokens[$nextContent]['line'] - $tokens[$nextLineToken]['line']);
87
  }
88
  }
89
 
90
- if ($foundLines !== $this->spacing) {
91
  $error = 'Expected %s blank line';
92
- if ($this->spacing !== 1) {
93
  $error .= 's';
94
  }
95
 
96
  $error .= ' after function; %s found';
97
  $data = [
98
- $this->spacing,
99
  $foundLines,
100
  ];
101
 
102
- $fix = $phpcsFile->addFixableError($error, $closer, 'After', $data);
103
  if ($fix === true) {
104
  $phpcsFile->fixer->beginChangeset();
105
  for ($i = $nextLineToken; $i <= $nextContent; $i++) {
106
  if ($tokens[$i]['line'] === $tokens[$nextContent]['line']) {
107
- $phpcsFile->fixer->addContentBefore($i, str_repeat($phpcsFile->eolChar, $this->spacing));
108
  break;
109
  }
110
 
@@ -130,7 +211,7 @@ class FunctionSpacingSniff implements Sniff
130
  }
131
  }
132
 
133
- if (is_null($prevLineToken) === true) {
134
  // Never found the previous line, which means
135
  // there are 0 blank lines before the function.
136
  $foundLines = 0;
@@ -188,19 +269,27 @@ class FunctionSpacingSniff implements Sniff
188
  }//end while
189
  }//end if
190
 
191
- if ($foundLines !== $this->spacing) {
 
 
 
 
 
 
 
 
192
  $error = 'Expected %s blank line';
193
- if ($this->spacing !== 1) {
194
  $error .= 's';
195
  }
196
 
197
  $error .= ' before function; %s found';
198
  $data = [
199
- $this->spacing,
200
  $foundLines,
201
  ];
202
 
203
- $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Before', $data);
204
  if ($fix === true) {
205
  if ($prevContent === 0) {
206
  $nextSpace = 0;
@@ -211,17 +300,21 @@ class FunctionSpacingSniff implements Sniff
211
  }
212
  }
213
 
214
- if ($foundLines < $this->spacing) {
215
- $padding = str_repeat($phpcsFile->eolChar, ($this->spacing - $foundLines));
216
- $phpcsFile->fixer->addContent($nextSpace, $padding);
217
  } else {
218
  $nextContent = $phpcsFile->findNext(T_WHITESPACE, ($nextSpace + 1), null, true);
219
  $phpcsFile->fixer->beginChangeset();
220
- for ($i = $nextSpace; $i < ($nextContent - 1); $i++) {
 
 
 
 
 
221
  $phpcsFile->fixer->replaceToken($i, '');
222
  }
223
 
224
- $phpcsFile->fixer->replaceToken($i, str_repeat($phpcsFile->eolChar, $this->spacing));
225
  $phpcsFile->fixer->endChangeset();
226
  }
227
  }//end if
1
  <?php
2
  /**
3
+ * Checks the separation between functions and methods.
4
  *
5
  * @author Greg Sherwood <gsherwood@squiz.net>
6
  * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
23
  */
24
  public $spacing = 2;
25
 
26
+ /**
27
+ * The number of blank lines before the first function in a class.
28
+ *
29
+ * @var integer
30
+ */
31
+ public $spacingBeforeFirst = 2;
32
+
33
+ /**
34
+ * The number of blank lines after the last function in a class.
35
+ *
36
+ * @var integer
37
+ */
38
+ public $spacingAfterLast = 2;
39
+
40
+ /**
41
+ * The number of blank lines after the last function in a class.
42
+ *
43
+ * @var integer
44
+ */
45
+ private $rulesetProperties = null;
46
+
47
 
48
  /**
49
  * Returns an array of tokens this test wants to listen for.
68
  */
69
  public function process(File $phpcsFile, $stackPtr)
70
  {
71
+ $tokens = $phpcsFile->getTokens();
72
+ $previousNonEmpty = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
73
+ if ($previousNonEmpty !== false
74
+ && $tokens[$previousNonEmpty]['code'] === T_OPEN_TAG
75
+ && $tokens[$previousNonEmpty]['line'] !== 1
76
+ ) {
77
+ // Ignore functions at the start of an embedded PHP block.
78
+ return;
79
+ }
80
 
81
+ // If the ruleset has only overridden the spacing property, use
82
+ // that value for all spacing rules.
83
+ if ($this->rulesetProperties === null) {
84
+ $this->rulesetProperties = [];
85
+ if (isset($phpcsFile->ruleset->ruleset['Squiz.WhiteSpace.FunctionSpacing']) === true
86
+ && isset($phpcsFile->ruleset->ruleset['Squiz.WhiteSpace.FunctionSpacing']['properties']) === true
87
+ ) {
88
+ $this->rulesetProperties = $phpcsFile->ruleset->ruleset['Squiz.WhiteSpace.FunctionSpacing']['properties'];
89
+ if (isset($this->rulesetProperties['spacing']) === true) {
90
+ if (isset($this->rulesetProperties['spacingBeforeFirst']) === false) {
91
+ $this->spacingBeforeFirst = $this->spacing;
92
+ }
93
+
94
+ if (isset($this->rulesetProperties['spacingAfterLast']) === false) {
95
+ $this->spacingAfterLast = $this->spacing;
96
+ }
97
+ }
98
+ }
99
+ }
100
+
101
+ $this->spacing = (int) $this->spacing;
102
+ $this->spacingBeforeFirst = (int) $this->spacingBeforeFirst;
103
+ $this->spacingAfterLast = (int) $this->spacingAfterLast;
104
 
105
  if (isset($tokens[$stackPtr]['scope_closer']) === false) {
106
  // Must be an interface method, so the closer is the semicolon.
109
  $closer = $tokens[$stackPtr]['scope_closer'];
110
  }
111
 
112
+ $isFirst = false;
113
+ $isLast = false;
114
+
115
+ $ignore = (Tokens::$emptyTokens + Tokens::$methodPrefixes);
116
+
117
+ $prev = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
118
+ if (isset($tokens[$prev]['scope_opener']) === true
119
+ && $tokens[$prev]['scope_opener'] === $prev
120
+ && isset(Tokens::$ooScopeTokens[$tokens[$tokens[$prev]['scope_condition']]['code']]) === true
121
+ ) {
122
+ $isFirst = true;
123
+ }
124
+
125
+ $next = $phpcsFile->findNext($ignore, ($closer + 1), null, true);
126
+ if (isset($tokens[$next]['scope_closer']) === true
127
+ && $tokens[$next]['scope_closer'] === $next
128
+ && isset(Tokens::$ooScopeTokens[$tokens[$tokens[$next]['scope_condition']]['code']]) === true
129
+ ) {
130
+ $isLast = true;
131
+ }
132
+
133
+ /*
134
+ Check the number of blank lines
135
+ after the function.
136
+ */
137
+
138
  // Allow for comments on the same line as the closer.
139
  for ($nextLineToken = ($closer + 1); $nextLineToken < $phpcsFile->numTokens; $nextLineToken++) {
140
  if ($tokens[$nextLineToken]['line'] !== $tokens[$closer]['line']) {
142
  }
143
  }
144
 
145
+ if ($isLast === true) {
146
+ $requiredSpacing = $this->spacingAfterLast;
147
+ $errorCode = 'AfterLast';
148
+ } else {
149
+ $requiredSpacing = $this->spacing;
150
+ $errorCode = 'After';
151
+ }
152
+
153
  $foundLines = 0;
154
  if ($nextLineToken === ($phpcsFile->numTokens - 1)) {
155
  // We are at the end of the file.
156
  // Don't check spacing after the function because this
157
  // should be done by an EOF sniff.
158
+ $foundLines = $requiredSpacing;
159
  } else {
160
  $nextContent = $phpcsFile->findNext(T_WHITESPACE, $nextLineToken, null, true);
161
  if ($nextContent === false) {
162
  // We are at the end of the file.
163
  // Don't check spacing after the function because this
164
  // should be done by an EOF sniff.
165
+ $foundLines = $requiredSpacing;
166
  } else {
167
  $foundLines += ($tokens[$nextContent]['line'] - $tokens[$nextLineToken]['line']);
168
  }
169
  }
170
 
171
+ if ($foundLines !== $requiredSpacing) {
172
  $error = 'Expected %s blank line';
173
+ if ($requiredSpacing !== 1) {
174
  $error .= 's';
175
  }
176
 
177
  $error .= ' after function; %s found';
178
  $data = [
179
+ $requiredSpacing,
180
  $foundLines,
181
  ];
182
 
183
+ $fix = $phpcsFile->addFixableError($error, $closer, $errorCode, $data);
184
  if ($fix === true) {
185
  $phpcsFile->fixer->beginChangeset();
186
  for ($i = $nextLineToken; $i <= $nextContent; $i++) {
187
  if ($tokens[$i]['line'] === $tokens[$nextContent]['line']) {
188
+ $phpcsFile->fixer->addContentBefore($i, str_repeat($phpcsFile->eolChar, $requiredSpacing));
189
  break;
190
  }
191
 
211
  }
212
  }
213
 
214
+ if ($prevLineToken === null) {
215
  // Never found the previous line, which means
216
  // there are 0 blank lines before the function.
217
  $foundLines = 0;
269
  }//end while
270
  }//end if
271
 
272
+ if ($isFirst === true) {
273
+ $requiredSpacing = $this->spacingBeforeFirst;
274
+ $errorCode = 'BeforeFirst';
275
+ } else {
276
+ $requiredSpacing = $this->spacing;
277
+ $errorCode = 'Before';
278
+ }
279
+
280
+ if ($foundLines !== $requiredSpacing) {
281
  $error = 'Expected %s blank line';
282
+ if ($requiredSpacing !== 1) {
283
  $error .= 's';
284
  }
285
 
286
  $error .= ' before function; %s found';
287
  $data = [
288
+ $requiredSpacing,
289
  $foundLines,
290
  ];
291
 
292
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, $errorCode, $data);
293
  if ($fix === true) {
294
  if ($prevContent === 0) {
295
  $nextSpace = 0;
300
  }
301
  }
302
 
303
+ if ($foundLines < $requiredSpacing) {
304
+ $padding = str_repeat($phpcsFile->eolChar, ($requiredSpacing - $foundLines));
305
+ $phpcsFile->fixer->addContentBefore($nextSpace, $padding);
306
  } else {
307
  $nextContent = $phpcsFile->findNext(T_WHITESPACE, ($nextSpace + 1), null, true);
308
  $phpcsFile->fixer->beginChangeset();
309
+ for ($i = $nextSpace; $i < $nextContent; $i++) {
310
+ if ($tokens[$i]['line'] === $tokens[$nextContent]['line']) {
311
+ $phpcsFile->fixer->addContentBefore($i, str_repeat($phpcsFile->eolChar, $requiredSpacing));
312
+ break;
313
+ }
314
+
315
  $phpcsFile->fixer->replaceToken($i, '');
316
  }
317
 
 
318
  $phpcsFile->fixer->endChangeset();
319
  }
320
  }//end if
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php CHANGED
@@ -51,9 +51,8 @@ class LanguageConstructSpacingSniff implements Sniff
51
  {
52
  $tokens = $phpcsFile->getTokens();
53
 
54
- $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
55
- if ($nextToken === false) {
56
- // Skip when at end of file.
57
  return;
58
  }
59
 
51
  {
52
  $tokens = $phpcsFile->getTokens();
53
 
54
+ if (isset($tokens[($stackPtr + 1)]) === false) {
55
+ // Skip if there is no next token.
 
56
  return;
57
  }
58
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php CHANGED
@@ -37,24 +37,35 @@ class MemberVarSpacingSniff extends AbstractVariableSniff
37
  * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found.
38
  * @param int $stackPtr The position where the token was found.
39
  *
40
- * @return void
 
 
41
  */
42
  protected function processMemberVar(File $phpcsFile, $stackPtr)
43
  {
44
  $tokens = $phpcsFile->getTokens();
45
 
46
- $ignore = Tokens::$methodPrefixes;
47
- $ignore[] = T_VAR;
 
 
 
 
 
 
 
 
 
48
  $ignore[] = T_WHITESPACE;
49
 
50
- $start = $stackPtr;
51
- $prev = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
52
  if (isset(Tokens::$commentTokens[$tokens[$prev]['code']]) === true) {
53
  // Assume the comment belongs to the member var if it is on a line by itself.
54
  $prevContent = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true);
55
  if ($tokens[$prevContent]['line'] !== $tokens[$prev]['line']) {
56
  // Check the spacing, but then skip it.
57
- $foundLines = ($tokens[$stackPtr]['line'] - $tokens[$prev]['line'] - 1);
58
  if ($foundLines > 0) {
59
  $error = 'Expected 0 blank lines after member var comment; %s found';
60
  $data = [$foundLines];
@@ -67,8 +78,8 @@ class MemberVarSpacingSniff extends AbstractVariableSniff
67
  $phpcsFile->fixer->replaceToken($prev, rtrim($tokens[$prev]['content']));
68
  }
69
 
70
- for ($i = ($prev + 1); $i <= $stackPtr; $i++) {
71
- if ($tokens[$i]['line'] === $tokens[$stackPtr]['line']) {
72
  break;
73
  }
74
 
@@ -85,7 +96,7 @@ class MemberVarSpacingSniff extends AbstractVariableSniff
85
  }//end if
86
 
87
  // There needs to be n blank lines before the var, not counting comments.
88
- if ($start === $stackPtr) {
89
  // No comment found.
90
  $first = $phpcsFile->findFirstOnLine(Tokens::$emptyTokens, $start, true);
91
  if ($first === false) {
@@ -100,6 +111,13 @@ class MemberVarSpacingSniff extends AbstractVariableSniff
100
 
101
  // Determine if this is the first member var.
102
  $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($first - 1), null, true);
 
 
 
 
 
 
 
103
  if ($tokens[$prev]['code'] === T_OPEN_CURLY_BRACKET
104
  && isset(Tokens::$ooScopeTokens[$tokens[$tokens[$prev]['scope_condition']]['code']]) === true
105
  ) {
@@ -114,6 +132,10 @@ class MemberVarSpacingSniff extends AbstractVariableSniff
114
 
115
  $foundLines = ($tokens[$first]['line'] - $tokens[$prev]['line'] - 1);
116
  if ($foundLines === $spacing) {
 
 
 
 
117
  return;
118
  }
119
 
@@ -122,7 +144,7 @@ class MemberVarSpacingSniff extends AbstractVariableSniff
122
  $foundLines,
123
  ];
124
 
125
- $fix = $phpcsFile->addFixableError($errorMsg, $stackPtr, $errorCode, $data);
126
  if ($fix === true) {
127
  $phpcsFile->fixer->beginChangeset();
128
  for ($i = ($prev + 1); $i < $first; $i++) {
@@ -144,6 +166,12 @@ class MemberVarSpacingSniff extends AbstractVariableSniff
144
  $phpcsFile->fixer->endChangeset();
145
  }//end if
146
 
 
 
 
 
 
 
147
  }//end processMemberVar()
148
 
149
 
37
  * @param \PHP_CodeSniffer\Files\File $phpcsFile The file where this token was found.
38
  * @param int $stackPtr The position where the token was found.
39
  *
40
+ * @return void|int Optionally returns a stack pointer. The sniff will not be
41
+ * called again on the current file until the returned stack
42
+ * pointer is reached.
43
  */
44
  protected function processMemberVar(File $phpcsFile, $stackPtr)
45
  {
46
  $tokens = $phpcsFile->getTokens();
47
 
48
+ $validPrefixes = Tokens::$methodPrefixes;
49
+ $validPrefixes[] = T_VAR;
50
+
51
+ $startOfStatement = $phpcsFile->findPrevious($validPrefixes, ($stackPtr - 1), null, false, null, true);
52
+ if ($startOfStatement === false) {
53
+ return;
54
+ }
55
+
56
+ $endOfStatement = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1), null, false, null, true);
57
+
58
+ $ignore = $validPrefixes;
59
  $ignore[] = T_WHITESPACE;
60
 
61
+ $start = $startOfStatement;
62
+ $prev = $phpcsFile->findPrevious($ignore, ($startOfStatement - 1), null, true);
63
  if (isset(Tokens::$commentTokens[$tokens[$prev]['code']]) === true) {
64
  // Assume the comment belongs to the member var if it is on a line by itself.
65
  $prevContent = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($prev - 1), null, true);
66
  if ($tokens[$prevContent]['line'] !== $tokens[$prev]['line']) {
67
  // Check the spacing, but then skip it.
68
+ $foundLines = ($tokens[$startOfStatement]['line'] - $tokens[$prev]['line'] - 1);
69
  if ($foundLines > 0) {
70
  $error = 'Expected 0 blank lines after member var comment; %s found';
71
  $data = [$foundLines];
78
  $phpcsFile->fixer->replaceToken($prev, rtrim($tokens[$prev]['content']));
79
  }
80
 
81
+ for ($i = ($prev + 1); $i <= $startOfStatement; $i++) {
82
+ if ($tokens[$i]['line'] === $tokens[$startOfStatement]['line']) {
83
  break;
84
  }
85
 
96
  }//end if
97
 
98
  // There needs to be n blank lines before the var, not counting comments.
99
+ if ($start === $startOfStatement) {
100
  // No comment found.
101
  $first = $phpcsFile->findFirstOnLine(Tokens::$emptyTokens, $start, true);
102
  if ($first === false) {
111
 
112
  // Determine if this is the first member var.
113
  $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($first - 1), null, true);
114
+ if ($tokens[$prev]['code'] === T_CLOSE_CURLY_BRACKET
115
+ && isset($tokens[$prev]['scope_condition']) === true
116
+ && $tokens[$tokens[$prev]['scope_condition']]['code'] === T_FUNCTION
117
+ ) {
118
+ return;
119
+ }
120
+
121
  if ($tokens[$prev]['code'] === T_OPEN_CURLY_BRACKET
122
  && isset(Tokens::$ooScopeTokens[$tokens[$tokens[$prev]['scope_condition']]['code']]) === true
123
  ) {
132
 
133
  $foundLines = ($tokens[$first]['line'] - $tokens[$prev]['line'] - 1);
134
  if ($foundLines === $spacing) {
135
+ if ($endOfStatement !== false) {
136
+ return $endOfStatement;
137
+ }
138
+
139
  return;
140
  }
141
 
144
  $foundLines,
145
  ];
146
 
147
+ $fix = $phpcsFile->addFixableError($errorMsg, $startOfStatement, $errorCode, $data);
148
  if ($fix === true) {
149
  $phpcsFile->fixer->beginChangeset();
150
  for ($i = ($prev + 1); $i < $first; $i++) {
166
  $phpcsFile->fixer->endChangeset();
167
  }//end if
168
 
169
+ if ($endOfStatement !== false) {
170
+ return $endOfStatement;
171
+ }
172
+
173
+ return;
174
+
175
  }//end processMemberVar()
176
 
177
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php CHANGED
@@ -69,42 +69,11 @@ class OperatorSpacingSniff implements Sniff
69
  {
70
  $tokens = $phpcsFile->getTokens();
71
 
72
- // Skip default values in function declarations.
73
- // Skip declare statements.
74
- if ($tokens[$stackPtr]['code'] === T_EQUAL
75
- || $tokens[$stackPtr]['code'] === T_MINUS
76
- ) {
77
- if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
78
- $parenthesis = array_keys($tokens[$stackPtr]['nested_parenthesis']);
79
- $bracket = array_pop($parenthesis);
80
- if (isset($tokens[$bracket]['parenthesis_owner']) === true) {
81
- $function = $tokens[$bracket]['parenthesis_owner'];
82
- if ($tokens[$function]['code'] === T_FUNCTION
83
- || $tokens[$function]['code'] === T_CLOSURE
84
- || $tokens[$function]['code'] === T_DECLARE
85
- ) {
86
- return;
87
- }
88
- }
89
- }
90
- }
91
-
92
- if ($tokens[$stackPtr]['code'] === T_EQUAL) {
93
- // Skip for '=&' case.
94
- if (isset($tokens[($stackPtr + 1)]) === true
95
- && $tokens[($stackPtr + 1)]['code'] === T_BITWISE_AND
96
- ) {
97
- return;
98
- }
99
  }
100
 
101
  if ($tokens[$stackPtr]['code'] === T_BITWISE_AND) {
102
- // If it's not a reference, then we expect one space either side of the
103
- // bitwise operator.
104
- if ($phpcsFile->isReference($stackPtr) === true) {
105
- return;
106
- }
107
-
108
  // Check there is one space before the & operator.
109
  if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) {
110
  $error = 'Expected 1 space before "&" operator; 0 found';
@@ -166,60 +135,11 @@ class OperatorSpacingSniff implements Sniff
166
  return;
167
  }//end if
168
 
169
- if ($tokens[$stackPtr]['code'] === T_MINUS || $tokens[$stackPtr]['code'] === T_PLUS) {
170
- // Check minus spacing, but make sure we aren't just assigning
171
- // a minus value or returning one.
172
- $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
173
- if ($tokens[$prev]['code'] === T_RETURN) {
174
- // Just returning a negative value; eg. (return -1).
175
- return;
176
- }
177
-
178
- if (isset(Tokens::$operators[$tokens[$prev]['code']]) === true) {
179
- // Just trying to operate on a negative value; eg. ($var * -1).
180
- return;
181
- }
182
-
183
- if (isset(Tokens::$comparisonTokens[$tokens[$prev]['code']]) === true) {
184
- // Just trying to compare a negative value; eg. ($var === -1).
185
- return;
186
- }
187
-
188
- if (isset(Tokens::$booleanOperators[$tokens[$prev]['code']]) === true) {
189
- // Just trying to compare a negative value; eg. ($var || -1 === $b).
190
- return;
191
- }
192
-
193
- if (isset(Tokens::$assignmentTokens[$tokens[$prev]['code']]) === true) {
194
- // Just trying to assign a negative value; eg. ($var = -1).
195
- return;
196
- }
197
-
198
- // A list of tokens that indicate that the token is not
199
- // part of an arithmetic operation.
200
- $invalidTokens = [
201
- T_COMMA => true,
202
- T_OPEN_PARENTHESIS => true,
203
- T_OPEN_SQUARE_BRACKET => true,
204
- T_OPEN_SHORT_ARRAY => true,
205
- T_DOUBLE_ARROW => true,
206
- T_COLON => true,
207
- T_INLINE_THEN => true,
208
- T_INLINE_ELSE => true,
209
- T_CASE => true,
210
- ];
211
-
212
- if (isset($invalidTokens[$tokens[$prev]['code']]) === true) {
213
- // Just trying to use a negative value; eg. myFunction($var, -2).
214
- return;
215
- }
216
- }//end if
217
-
218
  $operator = $tokens[$stackPtr]['content'];
219
 
220
  if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE
221
  && (($tokens[($stackPtr - 1)]['code'] === T_INLINE_THEN
222
- && $tokens[($stackPtr )]['code'] === T_INLINE_ELSE) === false)
223
  ) {
224
  $error = "Expected 1 space before \"$operator\"; 0 found";
225
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSpaceBefore');
@@ -300,14 +220,129 @@ class OperatorSpacingSniff implements Sniff
300
  $operator,
301
  $found,
302
  ];
303
- $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfter', $data);
304
- if ($fix === true) {
305
- $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
 
 
 
 
 
 
 
 
 
 
 
306
  }
307
- }
308
  }//end if
309
 
310
  }//end process()
311
 
312
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
313
  }//end class
69
  {
70
  $tokens = $phpcsFile->getTokens();
71
 
72
+ if ($this->isOperator($phpcsFile, $stackPtr) === false) {
73
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  }
75
 
76
  if ($tokens[$stackPtr]['code'] === T_BITWISE_AND) {
 
 
 
 
 
 
77
  // Check there is one space before the & operator.
78
  if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE) {
79
  $error = 'Expected 1 space before "&" operator; 0 found';
135
  return;
136
  }//end if
137
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  $operator = $tokens[$stackPtr]['content'];
139
 
140
  if ($tokens[($stackPtr - 1)]['code'] !== T_WHITESPACE
141
  && (($tokens[($stackPtr - 1)]['code'] === T_INLINE_THEN
142
+ && $tokens[($stackPtr)]['code'] === T_INLINE_ELSE) === false)
143
  ) {
144
  $error = "Expected 1 space before \"$operator\"; 0 found";
145
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSpaceBefore');
220
  $operator,
221
  $found,
222
  ];
223
+
224
+ $nextNonWhitespace = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
225
+ if ($nextNonWhitespace !== false
226
+ && isset(Tokens::$commentTokens[$tokens[$nextNonWhitespace]['code']]) === true
227
+ && $found === 'newline'
228
+ ) {
229
+ // Don't auto-fix when it's a comment or PHPCS annotation on a new line as
230
+ // it causes fixer conflicts and can cause the meaning of annotations to change.
231
+ $phpcsFile->addError($error, $stackPtr, 'SpacingAfter', $data);
232
+ } else {
233
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfter', $data);
234
+ if ($fix === true) {
235
+ $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
236
+ }
237
  }
238
+ }//end if
239
  }//end if
240
 
241
  }//end process()
242
 
243
 
244
+ /**
245
+ * Checks if an operator is actually a different type of token in the current context.
246
+ *
247
+ * @param \PHP_CodeSniffer\Files\File $phpcsFile The current file being checked.
248
+ * @param int $stackPtr The position of the operator in
249
+ * the stack.
250
+ *
251
+ * @return boolean
252
+ */
253
+ protected function isOperator(File $phpcsFile, $stackPtr)
254
+ {
255
+ $tokens = $phpcsFile->getTokens();
256
+
257
+ // Skip default values in function declarations.
258
+ // Skip declare statements.
259
+ if ($tokens[$stackPtr]['code'] === T_EQUAL
260
+ || $tokens[$stackPtr]['code'] === T_MINUS
261
+ ) {
262
+ if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
263
+ $parenthesis = array_keys($tokens[$stackPtr]['nested_parenthesis']);
264
+ $bracket = array_pop($parenthesis);
265
+ if (isset($tokens[$bracket]['parenthesis_owner']) === true) {
266
+ $function = $tokens[$bracket]['parenthesis_owner'];
267
+ if ($tokens[$function]['code'] === T_FUNCTION
268
+ || $tokens[$function]['code'] === T_CLOSURE
269
+ || $tokens[$function]['code'] === T_DECLARE
270
+ ) {
271
+ return false;
272
+ }
273
+ }
274
+ }
275
+ }
276
+
277
+ if ($tokens[$stackPtr]['code'] === T_EQUAL) {
278
+ // Skip for '=&' case.
279
+ if (isset($tokens[($stackPtr + 1)]) === true
280
+ && $tokens[($stackPtr + 1)]['code'] === T_BITWISE_AND
281
+ ) {
282
+ return false;
283
+ }
284
+ }
285
+
286
+ if ($tokens[$stackPtr]['code'] === T_BITWISE_AND) {
287
+ // If it's not a reference, then we expect one space either side of the
288
+ // bitwise operator.
289
+ if ($phpcsFile->isReference($stackPtr) === true) {
290
+ return false;
291
+ }
292
+ }
293
+
294
+ if ($tokens[$stackPtr]['code'] === T_MINUS || $tokens[$stackPtr]['code'] === T_PLUS) {
295
+ // Check minus spacing, but make sure we aren't just assigning
296
+ // a minus value or returning one.
297
+ $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
298
+ if ($tokens[$prev]['code'] === T_RETURN) {
299
+ // Just returning a negative value; eg. (return -1).
300
+ return false;
301
+ }
302
+
303
+ if (isset(Tokens::$operators[$tokens[$prev]['code']]) === true) {
304
+ // Just trying to operate on a negative value; eg. ($var * -1).
305
+ return false;
306
+ }
307
+
308
+ if (isset(Tokens::$comparisonTokens[$tokens[$prev]['code']]) === true) {
309
+ // Just trying to compare a negative value; eg. ($var === -1).
310
+ return false;
311
+ }
312
+
313
+ if (isset(Tokens::$booleanOperators[$tokens[$prev]['code']]) === true) {
314
+ // Just trying to compare a negative value; eg. ($var || -1 === $b).
315
+ return false;
316
+ }
317
+
318
+ if (isset(Tokens::$assignmentTokens[$tokens[$prev]['code']]) === true) {
319
+ // Just trying to assign a negative value; eg. ($var = -1).
320
+ return false;
321
+ }
322
+
323
+ // A list of tokens that indicate that the token is not
324
+ // part of an arithmetic operation.
325
+ $invalidTokens = [
326
+ T_COMMA => true,
327
+ T_OPEN_PARENTHESIS => true,
328
+ T_OPEN_SQUARE_BRACKET => true,
329
+ T_OPEN_SHORT_ARRAY => true,
330
+ T_DOUBLE_ARROW => true,
331
+ T_COLON => true,
332
+ T_INLINE_THEN => true,
333
+ T_INLINE_ELSE => true,
334
+ T_CASE => true,
335
+ ];
336
+
337
+ if (isset($invalidTokens[$tokens[$prev]['code']]) === true) {
338
+ // Just trying to use a negative value; eg. myFunction($var, -2).
339
+ return false;
340
+ }
341
+ }//end if
342
+
343
+ return true;
344
+
345
+ }//end isOperator()
346
+
347
+
348
  }//end class
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php CHANGED
@@ -44,22 +44,43 @@ class ScopeKeywordSpacingSniff implements Sniff
44
  {
45
  $tokens = $phpcsFile->getTokens();
46
 
47
- $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
48
- $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
 
 
 
 
49
 
50
  if ($tokens[$stackPtr]['code'] === T_STATIC
51
- && ($tokens[$nextToken]['code'] === T_DOUBLE_COLON
52
  || $tokens[$prevToken]['code'] === T_NEW)
53
  ) {
54
- // Late static binding, e.g., static:: OR new static() usage.
55
  return;
56
  }
57
 
58
  if ($tokens[$prevToken]['code'] === T_AS) {
59
- // Trait visibilty change, e.g., "use HelloWorld { sayHello as private; }".
60
  return;
61
  }
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
  if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
64
  $spacing = 0;
65
  } else {
@@ -82,10 +103,21 @@ class ScopeKeywordSpacingSniff implements Sniff
82
  if ($spacing === 0) {
83
  $phpcsFile->fixer->addContent($stackPtr, ' ');
84
  } else {
 
 
 
 
 
 
 
 
 
 
85
  $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
 
86
  }
87
- }
88
- }
89
 
90
  }//end process()
91
 
44
  {
45
  $tokens = $phpcsFile->getTokens();
46
 
47
+ if (isset($tokens[($stackPtr + 1)]) === false) {
48
+ return;
49
+ }
50
+
51
+ $prevToken = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($stackPtr - 1), null, true);
52
+ $nextToken = $phpcsFile->findNext(Tokens::$emptyTokens, ($stackPtr + 1), null, true);
53
 
54
  if ($tokens[$stackPtr]['code'] === T_STATIC
55
+ && (($nextToken === false || $tokens[$nextToken]['code'] === T_DOUBLE_COLON)
56
  || $tokens[$prevToken]['code'] === T_NEW)
57
  ) {
58
+ // Late static binding, e.g., static:: OR new static() usage or live coding.
59
  return;
60
  }
61
 
62
  if ($tokens[$prevToken]['code'] === T_AS) {
63
+ // Trait visibility change, e.g., "use HelloWorld { sayHello as private; }".
64
  return;
65
  }
66
 
67
+ if ($nextToken !== false && $tokens[$nextToken]['code'] === T_VARIABLE) {
68
+ $endOfStatement = $phpcsFile->findNext(T_SEMICOLON, ($nextToken + 1));
69
+ if ($endOfStatement === false) {
70
+ // Live coding.
71
+ return;
72
+ }
73
+
74
+ $multiProperty = $phpcsFile->findNext(T_VARIABLE, ($nextToken + 1), $endOfStatement);
75
+ if ($multiProperty !== false
76
+ && $tokens[$stackPtr]['line'] !== $tokens[$nextToken]['line']
77
+ && $tokens[$nextToken]['line'] !== $tokens[$endOfStatement]['line']
78
+ ) {
79
+ // Allow for multiple properties definitions to each be on their own line.
80
+ return;
81
+ }
82
+ }
83
+
84
  if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
85
  $spacing = 0;
86
  } else {
103
  if ($spacing === 0) {
104
  $phpcsFile->fixer->addContent($stackPtr, ' ');
105
  } else {
106
+ $phpcsFile->fixer->beginChangeset();
107
+
108
+ for ($i = ($stackPtr + 2); $i < $phpcsFile->numTokens; $i++) {
109
+ if (isset($tokens[$i]) === false || $tokens[$i]['code'] !== T_WHITESPACE) {
110
+ break;
111
+ }
112
+
113
+ $phpcsFile->fixer->replaceToken($i, '');
114
+ }
115
+
116
  $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
117
+ $phpcsFile->fixer->endChangeset();
118
  }
119
+ }//end if
120
+ }//end if
121
 
122
  }//end process()
123
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Checks for unneeded whitespace.
4
  *
5
- * Checks that no whitespace preceeds the first content of the file, exists
6
  * after the last content of the file, resides after content on any line, or
7
  * are two empty lines in functions.
8
  *
@@ -95,17 +95,20 @@ class SuperfluousWhitespaceSniff implements Sniff
95
  return;
96
  }
97
 
 
 
98
  for ($i = ($stackPtr - 1); $i >= 0; $i--) {
99
  // If we find something that isn't inline html then there is something previous in the file.
100
  if ($tokens[$i]['type'] !== 'T_INLINE_HTML') {
101
  return;
102
  }
103
 
104
- // If we have ended up with inline html make sure it isn't just whitespace.
105
- $tokenContent = trim($tokens[$i]['content']);
106
- if ($tokenContent !== '') {
107
- return;
108
- }
 
109
  }
110
  }//end if
111
 
@@ -129,6 +132,8 @@ class SuperfluousWhitespaceSniff implements Sniff
129
  return;
130
  }
131
 
 
 
132
  for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
133
  // If we find something that isn't inline HTML then there
134
  // is more to the file.
@@ -136,12 +141,12 @@ class SuperfluousWhitespaceSniff implements Sniff
136
  return;
137
  }
138
 
139
- // If we have ended up with inline html make sure it
140
- // isn't just whitespace.
141
- $tokenContent = trim($tokens[$i]['content']);
142
- if (empty($tokenContent) === false) {
143
- return;
144
- }
145
  }
146
  } else {
147
  // The last token is always the close tag inserted when tokenized
@@ -162,15 +167,15 @@ class SuperfluousWhitespaceSniff implements Sniff
162
  ) {
163
  return;
164
  }
 
165
 
166
- if ($phpcsFile->fixer->enabled === true) {
 
 
167
  $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
168
  $stackPtr = ($prev + 1);
169
  }
170
- }//end if
171
 
172
- $fix = $phpcsFile->addFixableError('Additional whitespace found at end of file', $stackPtr, 'EndFile');
173
- if ($fix === true) {
174
  $phpcsFile->fixer->beginChangeset();
175
  for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
176
  $phpcsFile->fixer->replaceToken($i, '');
@@ -219,8 +224,7 @@ class SuperfluousWhitespaceSniff implements Sniff
219
  Check for multiple blank lines in a function.
220
  */
221
 
222
- if (($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true
223
- || $phpcsFile->hasCondition($stackPtr, T_CLOSURE) === true)
224
  && $tokens[($stackPtr - 1)]['line'] < $tokens[$stackPtr]['line']
225
  && $tokens[($stackPtr - 2)]['line'] === $tokens[($stackPtr - 1)]['line']
226
  ) {
2
  /**
3
  * Checks for unneeded whitespace.
4
  *
5
+ * Checks that no whitespace precedes the first content of the file, exists
6
  * after the last content of the file, resides after content on any line, or
7
  * are two empty lines in functions.
8
  *
95
  return;
96
  }
97
 
98
+ $beforeOpen = '';
99
+
100
  for ($i = ($stackPtr - 1); $i >= 0; $i--) {
101
  // If we find something that isn't inline html then there is something previous in the file.
102
  if ($tokens[$i]['type'] !== 'T_INLINE_HTML') {
103
  return;
104
  }
105
 
106
+ $beforeOpen .= $tokens[$i]['content'];
107
+ }
108
+
109
+ // If we have ended up with inline html make sure it isn't just whitespace.
110
+ if (preg_match('`^[\pZ\s]+$`u', $beforeOpen) !== 1) {
111
+ return;
112
  }
113
  }//end if
114
 
132
  return;
133
  }
134
 
135
+ $afterClose = '';
136
+
137
  for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
138
  // If we find something that isn't inline HTML then there
139
  // is more to the file.
141
  return;
142
  }
143
 
144
+ $afterClose .= $tokens[$i]['content'];
145
+ }
146
+
147
+ // If we have ended up with inline html make sure it isn't just whitespace.
148
+ if (preg_match('`^[\pZ\s]+$`u', $afterClose) !== 1) {
149
+ return;
150
  }
151
  } else {
152
  // The last token is always the close tag inserted when tokenized
167
  ) {
168
  return;
169
  }
170
+ }//end if
171
 
172
+ $fix = $phpcsFile->addFixableError('Additional whitespace found at end of file', $stackPtr, 'EndFile');
173
+ if ($fix === true) {
174
+ if ($phpcsFile->tokenizerType !== 'PHP') {
175
  $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
176
  $stackPtr = ($prev + 1);
177
  }
 
178
 
 
 
179
  $phpcsFile->fixer->beginChangeset();
180
  for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
181
  $phpcsFile->fixer->replaceToken($i, '');
224
  Check for multiple blank lines in a function.
225
  */
226
 
227
+ if (($phpcsFile->hasCondition($stackPtr, [T_FUNCTION, T_CLOSURE]) === true)
 
228
  && $tokens[($stackPtr - 1)]['line'] < $tokens[$stackPtr]['line']
229
  && $tokens[($stackPtr - 2)]['line'] === $tokens[($stackPtr - 1)]['line']
230
  ) {
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
 
3
  function test()
4
  {
@@ -11,7 +12,6 @@ function test()
11
  );
12
  }
13
 
14
-
15
  class TestClass
16
  {
17
  public $good = array(
@@ -350,3 +350,56 @@ $a = array
350
  ( 'a', 'b' );
351
 
352
  $a = array /* comment */ ( 'a', 'b' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ array($a, array($b)) = $array;
3
 
4
  function test()
5
  {
12
  );
13
  }
14
 
 
15
  class TestClass
16
  {
17
  public $good = array(
350
  ( 'a', 'b' );
351
 
352
  $a = array /* comment */ ( 'a', 'b' );
353
+
354
+ $x = array(
355
+ 'a' => false);
356
+
357
+ $x = array(
358
+ 'xxxx' => array('aaaaaaaaaa' => 'ccccccccccc',
359
+ 'bbbbbbbb' => false),
360
+ );
361
+
362
+ $foo = array
363
+ ('foo' => array
364
+ ('bar1' => 1
365
+ ,'bar2' => 1
366
+ ,'bar3' => 1
367
+ ,'bar4' => 1
368
+ ,'bar5' => 1
369
+ )
370
+ );
371
+
372
+ $foo = array(
373
+ '1' => $row['status'] === 'rejected'
374
+ ? self::REJECTED_CODE
375
+ : self::VERIFIED_CODE,
376
+ '2' => in_array($row['status'], array('notverified', 'unverified'), true)
377
+ ? self::STATUS_PENDING
378
+ : self::STATUS_VERIFIED,
379
+ '3' => strtotime($row['date']),
380
+ );
381
+
382
+ $foo = foo(
383
+ array(
384
+ // comment
385
+ )
386
+ );
387
+
388
+ $foo = array(
389
+ <<<HERE
390
+ HERE
391
+ ,
392
+ <<<HERE
393
+ HERE
394
+ ,
395
+ );
396
+
397
+ $foo = array(
398
+ 'тип' => 'авто',
399
+ 'цвет' => 'синий',
400
+ );
401
+
402
+ $paths = array(
403
+ Init::ROOT_DIR.'/тип' => 'авто',
404
+ Init::ROOT_DIR.'/цвет' => 'синий',
405
+ );
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.1.inc.fixed CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
 
3
  function test()
4
  {
@@ -9,7 +13,6 @@ function test()
9
  $c = array('a' => 1);
10
  }
11
 
12
-
13
  class TestClass
14
  {
15
  public $good = array(
@@ -374,3 +377,57 @@ $a = array /* comment */ (
374
  'a',
375
  'b',
376
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ array(
3
+ $a,
4
+ array($b),
5
+ ) = $array;
6
 
7
  function test()
8
  {
13
  $c = array('a' => 1);
14
  }
15
 
 
16
  class TestClass
17
  {
18
  public $good = array(
377
  'a',
378
  'b',
379
  );
380
+
381
+ $x = array('a' => false);
382
+
383
+ $x = array(
384
+ 'xxxx' => array(
385
+ 'aaaaaaaaaa' => 'ccccccccccc',
386
+ 'bbbbbbbb' => false,
387
+ ),
388
+ );
389
+
390
+ $foo = array(
391
+ 'foo' => array(
392
+ 'bar1' => 1,
393
+ 'bar2' => 1,
394
+ 'bar3' => 1,
395
+ 'bar4' => 1,
396
+ 'bar5' => 1,
397
+ ),
398
+ );
399
+
400
+ $foo = array(
401
+ '1' => $row['status'] === 'rejected'
402
+ ? self::REJECTED_CODE
403
+ : self::VERIFIED_CODE,
404
+ '2' => in_array($row['status'], array('notverified', 'unverified'), true)
405
+ ? self::STATUS_PENDING
406
+ : self::STATUS_VERIFIED,
407
+ '3' => strtotime($row['date']),
408
+ );
409
+
410
+ $foo = foo(
411
+ array(
412
+ // comment
413
+ )
414
+ );
415
+
416
+ $foo = array(
417
+ <<<HERE
418
+ HERE
419
+ ,
420
+ <<<HERE
421
+ HERE
422
+ ,
423
+ );
424
+
425
+ $foo = array(
426
+ 'тип' => 'авто',
427
+ 'цвет' => 'синий',
428
+ );
429
+
430
+ $paths = array(
431
+ Init::ROOT_DIR.'/тип' => 'авто',
432
+ Init::ROOT_DIR.'/цвет' => 'синий',
433
+ );
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
 
3
  function test()
4
  {
@@ -11,7 +12,6 @@ function test()
11
  ];
12
  }
13
 
14
-
15
  class TestClass
16
  {
17
  public $good = [
@@ -340,3 +340,55 @@ EOD
340
  echo [1][0];
341
  echo 'PHP'[0];
342
  echo [1][0, 1, 2]; // not valid code, but should not be picked up here
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ [$a, [$b]] = $array;
3
 
4
  function test()
5
  {
12
  ];
13
  }
14
 
 
15
  class TestClass
16
  {
17
  public $good = [
340
  echo [1][0];
341
  echo 'PHP'[0];
342
  echo [1][0, 1, 2]; // not valid code, but should not be picked up here
343
+
344
+ $x = [
345
+ 'a' => false];
346
+
347
+ $x = [
348
+ 'xxxx' => ['aaaaaaaaaa' => 'ccccccccccc',
349
+ 'bbbbbbbb' => false],
350
+ ];
351
+
352
+ $foo = ['foo' => ['bar1' => 1
353
+ ,'bar2' => 1
354
+ ,'bar3' => 1
355
+ ,'bar4' => 1
356
+ ,'bar5' => 1
357
+ ]
358
+ ];
359
+
360
+ $foo = [
361
+ '1' => $row['status'] === 'rejected'
362
+ ? self::REJECTED_CODE
363
+ : self::VERIFIED_CODE,
364
+ '2' => in_array($row['status'], ['notverified', 'unverified'], true)
365
+ ? self::STATUS_PENDING
366
+ : self::STATUS_VERIFIED,
367
+ '3' => strtotime($row['date']),
368
+ ];
369
+
370
+
371
+ $foo = foo(
372
+ [
373
+ // comment
374
+ ]
375
+ );
376
+
377
+ $foo = [
378
+ <<<HERE
379
+ HERE
380
+ ,
381
+ <<<HERE
382
+ HERE
383
+ ,
384
+ ];
385
+
386
+ $foo = [
387
+ 'тип' => 'авто',
388
+ 'цвет' => 'синий',
389
+ ];
390
+
391
+ $paths = [
392
+ Init::ROOT_DIR.'/тип' => 'авто',
393
+ Init::ROOT_DIR.'/цвет' => 'синий',
394
+ ];
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.2.inc.fixed CHANGED
@@ -1,4 +1,8 @@
1
  <?php
 
 
 
 
2
 
3
  function test()
4
  {
@@ -9,7 +13,6 @@ function test()
9
  $c = ['a' => 1];
10
  }
11
 
12
-
13
  class TestClass
14
  {
15
  public $good = [
@@ -360,3 +363,58 @@ EOD
360
  echo [1][0];
361
  echo 'PHP'[0];
362
  echo [1][0, 1, 2]; // not valid code, but should not be picked up here
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ [
3
+ $a,
4
+ [$b],
5
+ ] = $array;
6
 
7
  function test()
8
  {
13
  $c = ['a' => 1];
14
  }
15
 
 
16
  class TestClass
17
  {
18
  public $good = [
363
  echo [1][0];
364
  echo 'PHP'[0];
365
  echo [1][0, 1, 2]; // not valid code, but should not be picked up here
366
+
367
+ $x = ['a' => false];
368
+
369
+ $x = [
370
+ 'xxxx' => [
371
+ 'aaaaaaaaaa' => 'ccccccccccc',
372
+ 'bbbbbbbb' => false,
373
+ ],
374
+ ];
375
+
376
+ $foo = [
377
+ 'foo' => [
378
+ 'bar1' => 1,
379
+ 'bar2' => 1,
380
+ 'bar3' => 1,
381
+ 'bar4' => 1,
382
+ 'bar5' => 1,
383
+ ],
384
+ ];
385
+
386
+ $foo = [
387
+ '1' => $row['status'] === 'rejected'
388
+ ? self::REJECTED_CODE
389
+ : self::VERIFIED_CODE,
390
+ '2' => in_array($row['status'], ['notverified', 'unverified'], true)
391
+ ? self::STATUS_PENDING
392
+ : self::STATUS_VERIFIED,
393
+ '3' => strtotime($row['date']),
394
+ ];
395
+
396
+
397
+ $foo = foo(
398
+ [
399
+ // comment
400
+ ]
401
+ );
402
+
403
+ $foo = [
404
+ <<<HERE
405
+ HERE
406
+ ,
407
+ <<<HERE
408
+ HERE
409
+ ,
410
+ ];
411
+
412
+ $foo = [
413
+ 'тип' => 'авто',
414
+ 'цвет' => 'синий',
415
+ ];
416
+
417
+ $paths = [
418
+ Init::ROOT_DIR.'/тип' => 'авто',
419
+ Init::ROOT_DIR.'/цвет' => 'синий',
420
+ ];
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Arrays/ArrayDeclarationUnitTest.php CHANGED
@@ -30,15 +30,16 @@ class ArrayDeclarationUnitTest extends AbstractSniffUnitTest
30
  switch ($testFile) {
31
  case 'ArrayDeclarationUnitTest.1.inc':
32
  return [
33
- 7 => 2,
34
- 9 => 2,
 
35
  22 => 1,
36
- 23 => 1,
37
- 24 => 1,
38
  25 => 1,
39
- 31 => 1,
40
  35 => 1,
41
- 36 => 1,
42
  41 => 1,
43
  46 => 1,
44
  47 => 1,
@@ -83,7 +84,7 @@ class ArrayDeclarationUnitTest extends AbstractSniffUnitTest
83
  182 => 1,
84
  188 => 1,
85
  207 => 1,
86
- 212 => 1,
87
  214 => 1,
88
  218 => 2,
89
  219 => 2,
@@ -97,15 +98,31 @@ class ArrayDeclarationUnitTest extends AbstractSniffUnitTest
97
  339 => 2,
98
  348 => 2,
99
  352 => 2,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  ];
101
  case 'ArrayDeclarationUnitTest.2.inc':
102
  return [
103
- 9 => 1,
104
- 23 => 1,
105
- 24 => 1,
 
106
  25 => 1,
107
- 31 => 1,
108
- 36 => 1,
109
  41 => 1,
110
  46 => 1,
111
  47 => 1,
@@ -158,6 +175,19 @@ class ArrayDeclarationUnitTest extends AbstractSniffUnitTest
158
  303 => 1,
159
  309 => 1,
160
  331 => 2,
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  ];
162
  default:
163
  return [];
30
  switch ($testFile) {
31
  case 'ArrayDeclarationUnitTest.1.inc':
32
  return [
33
+ 2 => 1,
34
+ 8 => 2,
35
+ 10 => 2,
36
  22 => 1,
37
+ 23 => 2,
38
+ 24 => 2,
39
  25 => 1,
40
+ 31 => 2,
41
  35 => 1,
42
+ 36 => 2,
43
  41 => 1,
44
  46 => 1,
45
  47 => 1,
84
  182 => 1,
85
  188 => 1,
86
  207 => 1,
87
+ 212 => 2,
88
  214 => 1,
89
  218 => 2,
90
  219 => 2,
98
  339 => 2,
99
  348 => 2,
100
  352 => 2,
101
+ 355 => 3,
102
+ 358 => 3,
103
+ 359 => 2,
104
+ 360 => 1,
105
+ 362 => 1,
106
+ 363 => 2,
107
+ 364 => 1,
108
+ 365 => 2,
109
+ 366 => 2,
110
+ 367 => 2,
111
+ 368 => 2,
112
+ 369 => 1,
113
+ 370 => 1,
114
+ 383 => 1,
115
+ 394 => 1,
116
  ];
117
  case 'ArrayDeclarationUnitTest.2.inc':
118
  return [
119
+ 2 => 1,
120
+ 10 => 1,
121
+ 23 => 2,
122
+ 24 => 2,
123
  25 => 1,
124
+ 31 => 2,
125
+ 36 => 2,
126
  41 => 1,
127
  46 => 1,
128
  47 => 1,
175
  303 => 1,
176
  309 => 1,
177
  331 => 2,
178
+ 345 => 3,
179
+ 348 => 3,
180
+ 349 => 2,
181
+ 350 => 1,
182
+ 352 => 2,
183
+ 353 => 2,
184
+ 354 => 2,
185
+ 355 => 2,
186
+ 356 => 2,
187
+ 357 => 1,
188
+ 358 => 1,
189
+ 372 => 1,
190
+ 383 => 1,
191
  ];
192
  default:
193
  return [];
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc CHANGED
@@ -94,6 +94,17 @@ interface MyInterface
94
 
95
  <?php
96
 
 
 
 
 
 
 
 
 
 
 
 
97
  class CorrectClassDeclaration
98
  {
99
 
94
 
95
  <?php
96
 
97
+ class MyClass2
98
+ {
99
+ var $x;
100
+ }
101
+
102
+
103
+ /**
104
+ * No error.
105
+ */
106
+ function example() {}
107
+
108
  class CorrectClassDeclaration
109
  {
110
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.inc.fixed CHANGED
@@ -102,6 +102,17 @@ interface MyInterface
102
 
103
  <?php
104
 
 
 
 
 
 
 
 
 
 
 
 
105
  class CorrectClassDeclaration
106
  {
107
 
102
 
103
  <?php
104
 
105
+ class MyClass2
106
+ {
107
+ var $x;
108
+ }
109
+
110
+
111
+ /**
112
+ * No error.
113
+ */
114
+ function example() {}
115
+
116
  class CorrectClassDeclaration
117
  {
118
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Classes/ClassDeclarationUnitTest.php CHANGED
@@ -56,10 +56,11 @@ class ClassDeclarationUnitTest extends AbstractSniffUnitTest
56
  89 => 1,
57
  92 => 1,
58
  97 => 1,
59
- 103 => 1,
60
- 105 => 1,
61
- 107 => 1,
62
- 110 => 1,
 
63
  ];
64
 
65
  }//end getErrorList()
56
  89 => 1,
57
  92 => 1,
58
  97 => 1,
59
+ 108 => 1,
60
+ 114 => 1,
61
+ 116 => 1,
62
+ 118 => 1,
63
+ 121 => 1,
64
  ];
65
 
66
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Classes/ValidClassNameUnitTest.inc CHANGED
@@ -136,3 +136,6 @@ trait Base
136
  };
137
  }
138
  }
 
 
 
136
  };
137
  }
138
  }
139
+
140
+ if ( class_exists( Test :: class ) ) {}
141
+ if ( class_exists( Test2 ::class ) ) {}
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc CHANGED
@@ -220,3 +220,25 @@ class TabTest {
220
  }
221
  }
222
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
220
  }
221
  }
222
  }
223
+
224
+ /*
225
+ * Test distinguishing between two distinct block comments which directly follow each other.
226
+ */
227
+ /*
228
+ *
229
+ */
230
+
231
+ // Mid-line inline comment style should not be auto-fixed.
232
+ if (true || /* test */ -1 == $b) {}
233
+ $y = 10 + /* test */ -2;
234
+
235
+ /*
236
+ * When the comment contains PHPCS annotations, the comment closer was being misidentified.
237
+ * phpcs:disable Standard.Category.Sniff
238
+ */
239
+
240
+ /*
241
+ * When the comment contains PHPCS annotations, the comment closer was being misidentified.
242
+ * See: {@link https://github.com/squizlabs/PHP_CodeSniffer/issues/1918}
243
+ * @phpcs:disable Standard.Category.Sniff
244
+ */
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.inc.fixed CHANGED
@@ -42,11 +42,11 @@ $code = 'should not be here';
42
 
43
  /*
44
  Closing comment not aligned
45
- */
46
 
47
  /*
48
  Closing comment not aligned
49
- */
50
 
51
  // Not allowed
52
 
@@ -91,7 +91,7 @@ function func()
91
  /*
92
  Test
93
  here
94
- */
95
 
96
  }//end func()
97
 
@@ -206,9 +206,9 @@ class Foo
206
  class TabTest {
207
  public function bar() {
208
  /*
209
- * Comment line 1.
210
- * Comment line 2.
211
- */
212
 
213
  if ($foo) {
214
  echo 'foo';
@@ -224,3 +224,23 @@ class TabTest {
224
  }
225
  }
226
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  /*
44
  Closing comment not aligned
45
+ */
46
 
47
  /*
48
  Closing comment not aligned
49
+ */
50
 
51
  // Not allowed
52
 
91
  /*
92
  Test
93
  here
94
+ */
95
 
96
  }//end func()
97
 
206
  class TabTest {
207
  public function bar() {
208
  /*
209
+ * Comment line 1.
210
+ * Comment line 2.
211
+ */
212
 
213
  if ($foo) {
214
  echo 'foo';
224
  }
225
  }
226
  }
227
+
228
+ /*
229
+ * Test distinguishing between two distinct block comments which directly follow each other.
230
+ */
231
+
232
+
233
+ // Mid-line inline comment style should not be auto-fixed.
234
+ if (true || /* test */ -1 == $b) {}
235
+ $y = 10 + /* test */ -2;
236
+
237
+ /*
238
+ * When the comment contains PHPCS annotations, the comment closer was being misidentified.
239
+ * phpcs:disable Standard.Category.Sniff
240
+ */
241
+
242
+ /*
243
+ * When the comment contains PHPCS annotations, the comment closer was being misidentified.
244
+ * See: {@link https://github.com/squizlabs/PHP_CodeSniffer/issues/1918}
245
+ * @phpcs:disable Standard.Category.Sniff
246
+ */
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/BlockCommentUnitTest.php CHANGED
@@ -69,9 +69,12 @@ class BlockCommentUnitTest extends AbstractSniffUnitTest
69
  159 => 1,
70
  181 => 1,
71
  188 => 1,
72
- 206 => 1,
73
- 207 => 1,
74
  214 => 1,
 
 
 
 
75
  ];
76
 
77
  return $errors;
69
  159 => 1,
70
  181 => 1,
71
  188 => 1,
72
+ 208 => 1,
 
73
  214 => 1,
74
+ 226 => 1,
75
+ 227 => 1,
76
+ 232 => 1,
77
+ 233 => 1,
78
  ];
79
 
80
  return $errors;
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.php CHANGED
@@ -41,12 +41,6 @@ class FileCommentUnitTest extends AbstractSniffUnitTest
41
  28 => 2,
42
  32 => 2,
43
  ];
44
- case 'FileCommentUnitTest.3.inc':
45
- // HHVM just removes the entire comment token, as if it was never there.
46
- if (defined('HHVM_VERSION') === true) {
47
- return [1 => 1];
48
- }
49
- return [];
50
  default:
51
  return [];
52
  }//end switch
41
  28 => 2,
42
  32 => 2,
43
  ];
 
 
 
 
 
 
44
  default:
45
  return [];
46
  }//end switch
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc CHANGED
@@ -990,3 +990,13 @@ public static function foo(?int $a, ?array $b) {}
990
  * @return void
991
  */
992
  public function foo(object $a, ?object $b) {}
 
 
 
 
 
 
 
 
 
 
990
  * @return void
991
  */
992
  public function foo(object $a, ?object $b) {}
993
+
994
+ /**
995
+ * Prepares given PHP class method for later code building.
996
+ *
997
+ * @param integer $foo Comment.
998
+ * - Additional comment.
999
+ *
1000
+ * @return void
1001
+ */
1002
+ function foo($foo) {}
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed CHANGED
@@ -990,3 +990,13 @@ public static function foo(?int $a, ?array $b) {}
990
  * @return void
991
  */
992
  public function foo(object $a, ?object $b) {}
 
 
 
 
 
 
 
 
 
 
990
  * @return void
991
  */
992
  public function foo(object $a, ?object $b) {}
993
+
994
+ /**
995
+ * Prepares given PHP class method for later code building.
996
+ *
997
+ * @param integer $foo Comment.
998
+ * - Additional comment.
999
+ *
1000
+ * @return void
1001
+ */
1002
+ function foo($foo) {}
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php CHANGED
@@ -112,20 +112,22 @@ class FunctionCommentUnitTest extends AbstractSniffUnitTest
112
  888 => 1,
113
  890 => 1,
114
  978 => 1,
 
115
  ];
116
 
117
  // Scalar type hints only work from PHP 7 onwards.
118
  if (PHP_VERSION_ID >= 70000) {
119
- $errors[17] = 3;
120
- $errors[128] = 1;
121
- $errors[143] = 3;
122
- $errors[161] = 2;
123
- $errors[201] = 1;
124
- $errors[232] = 7;
125
- $errors[363] = 3;
126
- $errors[377] = 1;
127
- $errors[575] = 2;
128
- $errors[627] = 1;
 
129
  } else {
130
  $errors[729] = 4;
131
  $errors[740] = 2;
112
  888 => 1,
113
  890 => 1,
114
  978 => 1,
115
+ 997 => 1,
116
  ];
117
 
118
  // Scalar type hints only work from PHP 7 onwards.
119
  if (PHP_VERSION_ID >= 70000) {
120
+ $errors[17] = 3;
121
+ $errors[128] = 1;
122
+ $errors[143] = 3;
123
+ $errors[161] = 2;
124
+ $errors[201] = 1;
125
+ $errors[232] = 7;
126
+ $errors[363] = 3;
127
+ $errors[377] = 1;
128
+ $errors[575] = 2;
129
+ $errors[627] = 1;
130
+ $errors[1002] = 1;
131
  } else {
132
  $errors[729] = 4;
133
  $errors[740] = 2;
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc CHANGED
@@ -129,6 +129,16 @@ echo $foo; // An unrelated comment.
129
  // An unrelated comment.
130
  echo $foo; // some comment without capital or full stop
131
 
 
 
 
 
 
 
 
 
 
 
132
  /*
133
  * N.B.: The below test line must be the last test in the file.
134
  * Testing that a new line after an inline comment when it's the last non-whitespace
129
  // An unrelated comment.
130
  echo $foo; // some comment without capital or full stop
131
 
132
+ class Foo
133
+ {
134
+ // This is fine.
135
+
136
+ /**
137
+ * Spacing is ignored above.
138
+ */
139
+ function bar(){}
140
+ }
141
+
142
  /*
143
  * N.B.: The below test line must be the last test in the file.
144
  * Testing that a new line after an inline comment when it's the last non-whitespace
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/InlineCommentUnitTest.inc.fixed CHANGED
@@ -122,6 +122,16 @@ echo $foo; // An unrelated comment.
122
  // An unrelated comment.
123
  echo $foo; // some comment without capital or full stop
124
 
 
 
 
 
 
 
 
 
 
 
125
  /*
126
  * N.B.: The below test line must be the last test in the file.
127
  * Testing that a new line after an inline comment when it's the last non-whitespace
122
  // An unrelated comment.
123
  echo $foo; // some comment without capital or full stop
124
 
125
+ class Foo
126
+ {
127
+ // This is fine.
128
+
129
+ /**
130
+ * Spacing is ignored above.
131
+ */
132
+ function bar(){}
133
+ }
134
+
135
  /*
136
  * N.B.: The below test line must be the last test in the file.
137
  * Testing that a new line after an inline comment when it's the last non-whitespace
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc CHANGED
@@ -290,6 +290,12 @@ class VariableCommentUnitTest
290
  protected $noComment2 = '';
291
 
292
 
 
 
 
 
 
 
293
  }//end class
294
 
295
 
290
  protected $noComment2 = '';
291
 
292
 
293
+ /**
294
+ * @var int Var type checking (int v.s. integer) with single-line comment.
295
+ */
296
+ private $_varSimpleTypeCheckSingleLine;
297
+
298
+
299
  }//end class
300
 
301
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.inc.fixed CHANGED
@@ -290,6 +290,12 @@ class VariableCommentUnitTest
290
  protected $noComment2 = '';
291
 
292
 
 
 
 
 
 
 
293
  }//end class
294
 
295
 
290
  protected $noComment2 = '';
291
 
292
 
293
+ /**
294
+ * @var integer Var type checking (int v.s. integer) with single-line comment.
295
+ */
296
+ private $_varSimpleTypeCheckSingleLine;
297
+
298
+
299
  }//end class
300
 
301
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Commenting/VariableCommentUnitTest.php CHANGED
@@ -53,8 +53,9 @@ class VariableCommentUnitTest extends AbstractSniffUnitTest
53
  272 => 1,
54
  280 => 1,
55
  290 => 1,
56
- 305 => 1,
57
- 330 => 1,
 
58
  ];
59
 
60
  }//end getErrorList()
53
  272 => 1,
54
  280 => 1,
55
  290 => 1,
56
+ 294 => 1,
57
+ 311 => 1,
58
+ 336 => 1,
59
  ];
60
 
61
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc CHANGED
@@ -252,3 +252,40 @@ endif;
252
  ?>
253
  hello
254
  <?php endforeach; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  ?>
253
  hello
254
  <?php endforeach; ?>
255
+ <?php
256
+
257
+ // Issue #1857/#1927.
258
+ if ($something) {
259
+ }
260
+ // phpcs:ignore Standard.Category.Sniff
261
+ elseif ($something) {
262
+ } // comment
263
+ else {
264
+ }
265
+
266
+ if ($something) {
267
+ } // phpcs:ignore Standard.Category.Sniff
268
+ elseif ($something) {
269
+ }
270
+ // comment
271
+ else {
272
+ }
273
+
274
+ try {
275
+ $x = 1;
276
+ } // stray comment here
277
+ catch (CustomException $exception) {
278
+ $x = 2;
279
+ }
280
+ // phpcs:ignore Standard.Category.Sniff
281
+ catch (Exception $exception) {
282
+ $x = 2;
283
+ }
284
+ finally {
285
+ $x = 3;
286
+ }
287
+
288
+ if ($this) {
289
+ if ($that)
290
+ foo(${$a[$b]});
291
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.inc.fixed CHANGED
@@ -256,3 +256,39 @@ endif;
256
  ?>
257
  hello
258
  <?php endforeach; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
256
  ?>
257
  hello
258
  <?php endforeach; ?>
259
+ <?php
260
+
261
+ // Issue #1857/#1927.
262
+ if ($something) {
263
+ }
264
+ // phpcs:ignore Standard.Category.Sniff
265
+ elseif ($something) {
266
+ } // comment
267
+ else {
268
+ }
269
+
270
+ if ($something) {
271
+ } // phpcs:ignore Standard.Category.Sniff
272
+ elseif ($something) {
273
+ }
274
+ // comment
275
+ else {
276
+ }
277
+
278
+ try {
279
+ $x = 1;
280
+ } // stray comment here
281
+ catch (CustomException $exception) {
282
+ $x = 2;
283
+ }
284
+ // phpcs:ignore Standard.Category.Sniff
285
+ catch (Exception $exception) {
286
+ $x = 2;
287
+ } finally {
288
+ $x = 3;
289
+ }
290
+
291
+ if ($this) {
292
+ if ($that)
293
+ foo(${$a[$b]});
294
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/ControlStructures/ControlSignatureUnitTest.php CHANGED
@@ -69,7 +69,14 @@ class ControlSignatureUnitTest extends AbstractSniffUnitTest
69
  $errors[243] = 2;
70
  $errors[244] = 2;
71
  $errors[248] = 1;
72
- }
 
 
 
 
 
 
 
73
 
74
  return $errors;
75
 
69
  $errors[243] = 2;
70
  $errors[244] = 2;
71
  $errors[248] = 1;
72
+ $errors[259] = 1;
73
+ $errors[262] = 1;
74
+ $errors[267] = 1;
75
+ $errors[269] = 1;
76
+ $errors[276] = 1;
77
+ $errors[279] = 1;
78
+ $errors[283] = 1;
79
+ }//end if
80
 
81
  return $errors;
82
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Debug/JSLintUnitTest.php CHANGED
@@ -24,7 +24,11 @@ class JSLintUnitTest extends AbstractSniffUnitTest
24
  protected function shouldSkipTest()
25
  {
26
  $jslPath = Config::getExecutablePath('jslint');
27
- return (is_null($jslPath));
 
 
 
 
28
 
29
  }//end shouldSkipTest()
30
 
24
  protected function shouldSkipTest()
25
  {
26
  $jslPath = Config::getExecutablePath('jslint');
27
+ if ($jslPath === null) {
28
+ return true;
29
+ }
30
+
31
+ return false;
32
 
33
  }//end shouldSkipTest()
34
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Debug/JavaScriptLintUnitTest.php CHANGED
@@ -24,7 +24,11 @@ class JavaScriptLintUnitTest extends AbstractSniffUnitTest
24
  protected function shouldSkipTest()
25
  {
26
  $jslPath = Config::getExecutablePath('jsl');
27
- return (is_null($jslPath));
 
 
 
 
28
 
29
  }//end shouldSkipTest()
30
 
24
  protected function shouldSkipTest()
25
  {
26
  $jslPath = Config::getExecutablePath('jsl');
27
+ if ($jslPath === null) {
28
+ return true;
29
+ }
30
+
31
+ return false;
32
 
33
  }//end shouldSkipTest()
34
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc CHANGED
@@ -161,3 +161,5 @@ try {
161
  $var = $foo['blah'] + [];
162
 
163
  $a = 2 * ${x} - ${minus};
 
 
161
  $var = $foo['blah'] + [];
162
 
163
  $a = 2 * ${x} - ${minus};
164
+
165
+ $foo = $bar ?? $baz ?? '';
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.inc.fixed CHANGED
@@ -161,3 +161,5 @@ try {
161
  $var = ($foo['blah'] + []);
162
 
163
  $a = 2 * ${x} - ${minus};
 
 
161
  $var = ($foo['blah'] + []);
162
 
163
  $a = 2 * ${x} - ${minus};
164
+
165
+ $foo = ($bar ?? $baz ?? '');
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js CHANGED
@@ -114,3 +114,5 @@ if (something === true
114
  }
115
 
116
  if (true === /^\d*\.?\d*$/.test(input)) return true;
 
 
114
  }
115
 
116
  if (true === /^\d*\.?\d*$/.test(input)) return true;
117
+
118
+ if ( ! /^(?:a|select)$/i.test( element.tagName ) ) return true;
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.js.fixed CHANGED
@@ -114,3 +114,5 @@ if (something === true
114
  }
115
 
116
  if (true === /^\d*\.?\d*$/.test(input)) return true;
 
 
114
  }
115
 
116
  if (true === /^\d*\.?\d*$/.test(input)) return true;
117
+
118
+ if ( ! /^(?:a|select)$/i.test( element.tagName ) ) return true;
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Formatting/OperatorBracketUnitTest.php CHANGED
@@ -64,6 +64,7 @@ class OperatorBracketUnitTest extends AbstractSniffUnitTest
64
  150 => 1,
65
  161 => 1,
66
  163 => 2,
 
67
  ];
68
  break;
69
  case 'OperatorBracketUnitTest.js':
64
  150 => 1,
65
  161 => 1,
66
  163 => 2,
67
+ 165 => 2,
68
  ];
69
  break;
70
  case 'OperatorBracketUnitTest.js':
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc CHANGED
@@ -84,3 +84,6 @@ function foo( // comment
84
  ) { // comment
85
  // ...
86
  }
 
 
 
84
  ) { // comment
85
  // ...
86
  }
87
+
88
+ function myFunc(/*...*/) {}
89
+ function myFunc( /*...*/ ) {}
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.inc.fixed CHANGED
@@ -84,3 +84,6 @@ function foo( // comment
84
  ) { // comment
85
  // ...
86
  }
 
 
 
84
  ) { // comment
85
  // ...
86
  }
87
+
88
+ function myFunc(/*...*/) {}
89
+ function myFunc(/*...*/) {}
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Functions/FunctionDeclarationArgumentSpacingUnitTest.php CHANGED
@@ -50,6 +50,7 @@ class FunctionDeclarationArgumentSpacingUnitTest extends AbstractSniffUnitTest
50
  73 => 7,
51
  76 => 1,
52
  81 => 1,
 
53
  ];
54
 
55
  }//end getErrorList()
50
  73 => 7,
51
  76 => 1,
52
  81 => 1,
53
+ 89 => 2,
54
  ];
55
 
56
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc CHANGED
@@ -161,3 +161,19 @@ function foo(
161
  $param3,
162
  ) : SomeClass {
163
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  $param3,
162
  ) : SomeClass {
163
  }
164
+
165
+ // Issue 1959.
166
+ function __construct(
167
+ $foo, // This is foo
168
+ $bar
169
+ ) {}
170
+
171
+ function __construct(
172
+ $foo /* this is foo */,
173
+ $bar // this is bar
174
+ ) {}
175
+
176
+ function __construct(
177
+ $foo, // phpcs:ignore Standard.Category.Sniff -- for reasons.
178
+ $bar
179
+ ) {}
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.inc.fixed CHANGED
@@ -15,7 +15,7 @@ function someFunctionWithAVeryLongName2(
15
  ) {
16
  }
17
 
18
- function blah()
19
  {
20
  }
21
 
@@ -173,3 +173,19 @@ function foo(
173
  $param3,
174
  ) : SomeClass {
175
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  ) {
16
  }
17
 
18
+ function blah()
19
  {
20
  }
21
 
173
  $param3,
174
  ) : SomeClass {
175
  }
176
+
177
+ // Issue 1959.
178
+ function __construct(
179
+ $foo, // This is foo
180
+ $bar
181
+ ) {}
182
+
183
+ function __construct(
184
+ $foo /* this is foo */,
185
+ $bar // this is bar
186
+ ) {}
187
+
188
+ function __construct(
189
+ $foo, // phpcs:ignore Standard.Category.Sniff -- for reasons.
190
+ $bar
191
+ ) {}
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Functions/MultiLineFunctionDeclarationUnitTest.js.fixed CHANGED
@@ -15,7 +15,7 @@ function someFunctionWithAVeryLongName2(
15
  ) {
16
  }
17
 
18
- function blah()
19
  {
20
  }
21
 
@@ -69,7 +69,7 @@ var a = Function('return 1+1');
69
 
70
  class test
71
  {
72
- myFunction()
73
  {
74
  return false;
75
  }
15
  ) {
16
  }
17
 
18
+ function blah()
19
  {
20
  }
21
 
69
 
70
  class test
71
  {
72
+ myFunction()
73
  {
74
  return false;
75
  }
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.inc CHANGED
@@ -106,6 +106,12 @@ class a
106
  $_sheet,
107
  $_FieldParser,
108
  $_key;
 
 
 
 
 
 
109
  }
110
 
111
  var_dump($http_response_header);
@@ -117,3 +123,13 @@ trait MyTrait
117
  public $_varName = 'hello';
118
  private $_varName = 'hello';
119
  }
 
 
 
 
 
 
 
 
 
 
106
  $_sheet,
107
  $_FieldParser,
108
  $_key;
109
+
110
+ private
111
+ $varN = true,
112
+ $varO = array( 'a', 'b' ),
113
+ $varP = 'string',
114
+ $varQ = 123;
115
  }
116
 
117
  var_dump($http_response_header);
123
  public $_varName = 'hello';
124
  private $_varName = 'hello';
125
  }
126
+
127
+ class TestClass
128
+ {
129
+ /**
130
+ * Comment goes here.
131
+ *
132
+ * @var array
133
+ */
134
+ private static $_foo = [];
135
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/NamingConventions/ValidVariableNameUnitTest.php CHANGED
@@ -53,7 +53,11 @@ class ValidVariableNameUnitTest extends AbstractSniffUnitTest
53
  106 => 1,
54
  107 => 2,
55
  108 => 1,
56
- 117 => 1,
 
 
 
 
57
  ];
58
 
59
  return $errors;
53
  106 => 1,
54
  107 => 2,
55
  108 => 1,
56
+ 111 => 1,
57
+ 112 => 1,
58
+ 113 => 1,
59
+ 114 => 1,
60
+ 123 => 1,
61
  ];
62
 
63
  return $errors;
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.inc CHANGED
@@ -131,3 +131,6 @@ $var = ($var1 === 0) ? $var1 : "foobar";
131
  $var = ($var1 == 0) ? $var1 : "foobar";
132
 
133
  function foo(string $bar, array $baz, ?MyClass $object) : MyClass {}
 
 
 
131
  $var = ($var1 == 0) ? $var1 : "foobar";
132
 
133
  function foo(string $bar, array $baz, ?MyClass $object) : MyClass {}
134
+
135
+ if (empty($argTags > 0)) {
136
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Operators/ComparisonOperatorUsageUnitTest.php CHANGED
@@ -57,6 +57,7 @@ class ComparisonOperatorUsageUnitTest extends AbstractSniffUnitTest
57
  123 => 1,
58
  127 => 1,
59
  131 => 1,
 
60
  ];
61
  break;
62
  case 'ComparisonOperatorUsageUnitTest.js':
57
  123 => 1,
58
  127 => 1,
59
  131 => 1,
60
+ 135 => 1,
61
  ];
62
  break;
63
  case 'ComparisonOperatorUsageUnitTest.js':
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.inc CHANGED
@@ -132,3 +132,27 @@ function myFunction( $param )
132
  // phpcs:enable Standard.Category.Sniff -- for reasons.
133
  // }//end myFunction()
134
  //
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
  // phpcs:enable Standard.Category.Sniff -- for reasons.
133
  // }//end myFunction()
134
  //
135
+
136
+ echo 'something'; // @codeCoverageIgnore
137
+ echo 'something'; // @codeCoverageIgnoreStart
138
+ echo 'something'; // @SuppressWarnings(PHPMD.UnusedLocalVariable)
139
+
140
+ // Ok!
141
+
142
+ /* Go! */
143
+
144
+ // ISO-639-3
145
+
146
+ // But override with a different text if any.
147
+ /*
148
+ $id = intval( str_replace( 'hook_name', '', $order_method['method_id'] ) );
149
+ if ( ! empty( $id ) ) {
150
+ $info_text = get_post_meta( $location_id, 'meta_name' );
151
+
152
+ if ( ! empty( $info_text ) ) {
153
+ $text = $info_text;
154
+ }
155
+
156
+ }
157
+ */
158
+ // function() { $a = $b; };
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/CommentedOutCodeUnitTest.php CHANGED
@@ -56,6 +56,8 @@ class CommentedOutCodeUnitTest extends AbstractSniffUnitTest
56
  109 => 1,
57
  116 => 1,
58
  128 => 1,
 
 
59
  ];
60
  break;
61
  case 'CommentedOutCodeUnitTest.css':
56
  109 => 1,
57
  116 => 1,
58
  128 => 1,
59
+ 147 => 1,
60
+ 158 => 1,
61
  ];
62
  break;
63
  case 'CommentedOutCodeUnitTest.css':
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/DisallowComparisonAssignmentUnitTest.inc CHANGED
@@ -51,3 +51,6 @@ for ($node = $fieldsTag->nextSibling; $node; $node = $node->nextSibling) {
51
 
52
  $a = $b ? $c : $d;
53
  $a = $b === true ? $c : $d;
 
 
 
51
 
52
  $a = $b ? $c : $d;
53
  $a = $b === true ? $c : $d;
54
+
55
+ $this->_args = $this->_getArgs(($_SERVER['argv'] ?? []));
56
+ $args = ($_SERVER['argv'] ?? []);
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.inc CHANGED
@@ -12,14 +12,17 @@ function getVar($varname='var', $var='var')
12
  for ($i = $var; (null !== ($key = key($i))); next($i)) {
13
  while ($i = true) {
14
  echo $i = getVar();
 
15
  }
16
  }
17
 
18
  while ($row = $query->fetch(PDO::FETCH_NUM)) {
19
- $result[$row[0]] = array()
20
  $result[$row[0]][] = $current;
21
 
22
  self::$_inTransaction = TRUE;
 
 
23
  $$varName = $varValue;
24
  }
25
 
@@ -33,6 +36,17 @@ class myClass
33
  var $dbh = NULL; // Old PHP4 compatible code.
34
  }
35
 
 
 
 
 
 
 
 
 
 
 
 
36
  $var = $var2;
37
  list ($a, $b) = explode(',', $c);
38
  $var1 ? $var2 = 0 : $var2 = 1;
@@ -42,3 +56,9 @@ $obj->$classVar = $prefix.'-'.$type;
42
  $closureWithDefaultParamter = function(array $testArray=array()) {};
43
  ?>
44
  <?php $var = false; ?>
 
 
 
 
 
 
12
  for ($i = $var; (null !== ($key = key($i))); next($i)) {
13
  while ($i = true) {
14
  echo $i = getVar();
15
+ echo \A\B\C::$d = getVar();
16
  }
17
  }
18
 
19
  while ($row = $query->fetch(PDO::FETCH_NUM)) {
20
+ $result[$row[0]] = array();
21
  $result[$row[0]][] = $current;
22
 
23
  self::$_inTransaction = TRUE;
24
+ parent::$_inTransaction = TRUE;
25
+ static::$_inTransaction = TRUE;
26
  $$varName = $varValue;
27
  }
28
 
36
  var $dbh = NULL; // Old PHP4 compatible code.
37
  }
38
 
39
+ A::$a = 'b';
40
+ \A::$a = 'c';
41
+ \A\B\C::$d = 'd';
42
+ B\C::$d = 'e';
43
+
44
+ @$a = 1;
45
+
46
+ $a = [];
47
+ foreach ($a as $b)
48
+ $c = 'd';
49
+
50
  $var = $var2;
51
  list ($a, $b) = explode(',', $c);
52
  $var1 ? $var2 = 0 : $var2 = 1;
56
  $closureWithDefaultParamter = function(array $testArray=array()) {};
57
  ?>
58
  <?php $var = false; ?>
59
+
60
+ <?php
61
+
62
+ while ( ( $csvdata = fgetcsv( $handle, 2000, $separator ) ) !== false ) {
63
+ // Do something.
64
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/PHP/DisallowMultipleAssignmentsUnitTest.php CHANGED
@@ -32,6 +32,7 @@ class DisallowMultipleAssignmentsUnitTest extends AbstractSniffUnitTest
32
  9 => 1,
33
  12 => 1,
34
  14 => 1,
 
35
  ];
36
 
37
  }//end getErrorList()
32
  9 => 1,
33
  12 => 1,
34
  14 => 1,
35
+ 15 => 1,
36
  ];
37
 
38
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.inc CHANGED
@@ -53,4 +53,20 @@ class MyClass {
53
 
54
  $var = null;
55
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
53
 
54
  $var = null;
55
  }
56
+
57
+ public $mCounter, $mSearchUser, $mSearchPeriodStart, $mSearchPeriodEnd,
58
+ $mTestFilter;
59
+
60
+ protected $mCounter,
61
+ $mSearchUser,
62
+ $mSearchPeriodStart,
63
+ $mSearchPeriodEnd,
64
+ $mTestFilter;
65
+
66
+ var $mCounter, $mSearchUser,
67
+ $mSearchPeriodStart;
68
+ }
69
+
70
+ interface Base {
71
+ protected $anonymous;
72
  }
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/Scope/MemberVarScopeUnitTest.php CHANGED
@@ -32,6 +32,8 @@ class MemberVarScopeUnitTest extends AbstractSniffUnitTest
32
  33 => 1,
33
  39 => 1,
34
  41 => 1,
 
 
35
  ];
36
 
37
  }//end getErrorList()
@@ -47,7 +49,7 @@ class MemberVarScopeUnitTest extends AbstractSniffUnitTest
47
  */
48
  public function getWarningList()
49
  {
50
- return [];
51
 
52
  }//end getWarningList()
53
 
32
  33 => 1,
33
  39 => 1,
34
  41 => 1,
35
+ 66 => 2,
36
+ 67 => 1,
37
  ];
38
 
39
  }//end getErrorList()
49
  */
50
  public function getWarningList()
51
  {
52
+ return [71 => 1];
53
 
54
  }//end getWarningList()
55
 
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.inc CHANGED
@@ -118,7 +118,7 @@ class MyClass
118
  {
119
 
120
  /**
121
- * The tag that this element represents (omiting the @ symbol).
122
  *
123
  * @var string
124
  */
@@ -305,3 +305,109 @@ function foo() {
305
  // phpcs:disable Standard.Category.Sniff -- for reasons.
306
  function bar() {
307
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  {
119
 
120
  /**
121
+ * The tag that this element represents (omitting the @ symbol).
122
  *
123
  * @var string
124
  */
305
  // phpcs:disable Standard.Category.Sniff -- for reasons.
306
  function bar() {
307
  }
308
+
309
+
310
+ // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacingBeforeFirst 0
311
+ // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacingAfterLast 0
312
+ class MyClass
313
+ {
314
+ protected $tag = '';
315
+
316
+ /**
317
+ * Function comment.
318
+ *
319
+ * @return boolean
320
+ */
321
+ private static function func1() {
322
+
323
+ }//end func1()
324
+
325
+ /**
326
+ * Function comment.
327
+ *
328
+ * @return boolean
329
+ */
330
+ private static function func2() {
331
+
332
+ }//end func1()
333
+
334
+
335
+ }//end class
336
+
337
+ class MyClass {
338
+ function a(){}
339
+ function b(){}
340
+ function c(){}
341
+ }
342
+
343
+ // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacing 1
344
+ // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacingBeforeFirst 1
345
+ // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacingAfterLast 1
346
+
347
+ class MyClass {
348
+ function a(){}
349
+ function b(){}
350
+ function c(){}
351
+ }
352
+
353
+ $util->setLogger(new class {
354
+ public function a(){}
355
+ private function b(){}
356
+ protected function c(){}
357
+ });
358
+
359
+ ?>
360
+
361
+ <?php
362
+ function functionInEmbeddedPHP() {
363
+
364
+ }
365
+
366
+ // Make sure the indentation for the function comment does not get removed.
367
+ class MyClass
368
+ {
369
+
370
+ protected $tag = '';
371
+
372
+
373
+
374
+ /**
375
+ * Function comment.
376
+ *
377
+ * @return boolean
378
+ */
379
+ function func1() {}
380
+
381
+ }//end class
382
+
383
+ class MyClass
384
+ {
385
+
386
+
387
+
388
+ /**
389
+ * Function comment.
390
+ *
391
+ * @return boolean
392
+ */
393
+ function func1() {}
394
+
395
+ }//end class
396
+
397
+ class MyClass
398
+ {
399
+ // Unrelated comment.
400
+ /**
401
+ * Function comment.
402
+ *
403
+ * @return boolean
404
+ */
405
+ function func1() {}
406
+ // phpcs:disable Standard.Category.Sniff -- for reasons.
407
+ /**
408
+ * Function comment.
409
+ *
410
+ * @return boolean
411
+ */
412
+ function func2() {}
413
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.inc.fixed CHANGED
@@ -136,7 +136,7 @@ class MyClass
136
  {
137
 
138
  /**
139
- * The tag that this element represents (omiting the @ symbol).
140
  *
141
  * @var string
142
  */
@@ -231,6 +231,7 @@ class MyClass
231
  interface MyInterface
232
  {
233
 
 
234
  /**
235
  * Function comment.
236
  *
@@ -252,6 +253,7 @@ interface MyInterface
252
  */
253
  function func3();
254
 
 
255
  }//end interface
256
 
257
  class MyClass
@@ -270,6 +272,7 @@ class MyClass
270
 
271
  }//end func1()
272
 
 
273
  }//end class
274
 
275
  // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacing 2
@@ -333,3 +336,121 @@ function foo() {
333
  // phpcs:disable Standard.Category.Sniff -- for reasons.
334
  function bar() {
335
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  {
137
 
138
  /**
139
+ * The tag that this element represents (omitting the @ symbol).
140
  *
141
  * @var string
142
  */
231
  interface MyInterface
232
  {
233
 
234
+
235
  /**
236
  * Function comment.
237
  *
253
  */
254
  function func3();
255
 
256
+
257
  }//end interface
258
 
259
  class MyClass
272
 
273
  }//end func1()
274
 
275
+
276
  }//end class
277
 
278
  // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacing 2
336
  // phpcs:disable Standard.Category.Sniff -- for reasons.
337
  function bar() {
338
  }
339
+
340
+
341
+ // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacingBeforeFirst 0
342
+ // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacingAfterLast 0
343
+ class MyClass
344
+ {
345
+ protected $tag = '';
346
+
347
+
348
+ /**
349
+ * Function comment.
350
+ *
351
+ * @return boolean
352
+ */
353
+ private static function func1() {
354
+
355
+ }//end func1()
356
+
357
+
358
+ /**
359
+ * Function comment.
360
+ *
361
+ * @return boolean
362
+ */
363
+ private static function func2() {
364
+
365
+ }//end func1()
366
+ }//end class
367
+
368
+ class MyClass {
369
+ function a(){}
370
+
371
+
372
+ function b(){}
373
+
374
+
375
+ function c(){}
376
+ }
377
+
378
+ // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacing 1
379
+ // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacingBeforeFirst 1
380
+ // phpcs:set Squiz.WhiteSpace.FunctionSpacing spacingAfterLast 1
381
+
382
+ class MyClass {
383
+
384
+ function a(){}
385
+
386
+ function b(){}
387
+
388
+ function c(){}
389
+
390
+ }
391
+
392
+ $util->setLogger(new class {
393
+
394
+ public function a(){}
395
+
396
+ private function b(){}
397
+
398
+ protected function c(){}
399
+
400
+ });
401
+
402
+ ?>
403
+
404
+ <?php
405
+ function functionInEmbeddedPHP() {
406
+
407
+ }
408
+
409
+ // Make sure the indentation for the function comment does not get removed.
410
+ class MyClass
411
+ {
412
+
413
+ protected $tag = '';
414
+
415
+ /**
416
+ * Function comment.
417
+ *
418
+ * @return boolean
419
+ */
420
+ function func1() {}
421
+
422
+ }//end class
423
+
424
+ class MyClass
425
+ {
426
+
427
+ /**
428
+ * Function comment.
429
+ *
430
+ * @return boolean
431
+ */
432
+ function func1() {}
433
+
434
+ }//end class
435
+
436
+ class MyClass
437
+ {
438
+ // Unrelated comment.
439
+
440
+ /**
441
+ * Function comment.
442
+ *
443
+ * @return boolean
444
+ */
445
+ function func1() {}
446
+
447
+ // phpcs:disable Standard.Category.Sniff -- for reasons.
448
+
449
+ /**
450
+ * Function comment.
451
+ *
452
+ * @return boolean
453
+ */
454
+ function func2() {}
455
+
456
+ }//end class
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/FunctionSpacingUnitTest.php CHANGED
@@ -43,14 +43,27 @@ class FunctionSpacingUnitTest extends AbstractSniffUnitTest
43
  154 => 1,
44
  167 => 2,
45
  184 => 1,
46
- 218 => 1,
47
- 233 => 1,
48
- 252 => 1,
49
  275 => 1,
50
  276 => 1,
51
  289 => 1,
52
  291 => 1,
53
  297 => 1,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  ];
55
 
56
  }//end getErrorList()
43
  154 => 1,
44
  167 => 2,
45
  184 => 1,
46
+ 218 => 2,
 
 
47
  275 => 1,
48
  276 => 1,
49
  289 => 1,
50
  291 => 1,
51
  297 => 1,
52
+ 321 => 1,
53
+ 323 => 1,
54
+ 332 => 1,
55
+ 338 => 1,
56
+ 339 => 1,
57
+ 348 => 2,
58
+ 349 => 1,
59
+ 350 => 1,
60
+ 354 => 2,
61
+ 355 => 1,
62
+ 356 => 1,
63
+ 379 => 1,
64
+ 393 => 1,
65
+ 405 => 2,
66
+ 412 => 2,
67
  ];
68
 
69
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc CHANGED
@@ -246,3 +246,61 @@ class phpcsCommentTest {
246
  public $var1 = 'value';
247
 
248
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  public $var1 = 'value';
247
 
248
  }
249
+
250
+ class MyOtherClass
251
+ {
252
+ public
253
+ $varK = array( 'a', 'b' );
254
+ protected static
255
+ $varK,
256
+ $varL,
257
+ $varM;
258
+
259
+
260
+
261
+ private
262
+ $varO = true,
263
+ $varP = array( 'a' => 'a', 'b' => 'b' ),
264
+ $varQ = 'string',
265
+ $varR = 123;
266
+ }
267
+
268
+ // Make sure the determination of whether a property is the first property or not is done correctly.
269
+ class ClassUsingSimpleTraits
270
+ {
271
+ use HelloWorld;
272
+
273
+
274
+ /* comment */
275
+ public $firstVar = array( 'a', 'b' );
276
+ protected $secondVar = true;
277
+ }
278
+
279
+ class ClassUsingComplexTraits
280
+ {
281
+ use A, B {
282
+ B::smallTalk insteadof A;
283
+ A::bigTalk insteadof B;
284
+ }
285
+
286
+
287
+
288
+ public $firstVar = array( 'a', 'b' );
289
+
290
+
291
+ /* comment */
292
+ protected $secondVar = true;
293
+ }
294
+
295
+ class Foo
296
+ {
297
+
298
+
299
+ private function foo()
300
+ {
301
+ }
302
+
303
+
304
+ /* no error here because after function */
305
+ private $bar = false;
306
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.inc.fixed CHANGED
@@ -235,3 +235,58 @@ class phpcsCommentTest {
235
  public $var1 = 'value';
236
 
237
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  public $var1 = 'value';
236
 
237
  }
238
+
239
+ class MyOtherClass
240
+ {
241
+
242
+ public
243
+ $varK = array( 'a', 'b' );
244
+
245
+ protected static
246
+ $varK,
247
+ $varL,
248
+ $varM;
249
+
250
+ private
251
+ $varO = true,
252
+ $varP = array( 'a' => 'a', 'b' => 'b' ),
253
+ $varQ = 'string',
254
+ $varR = 123;
255
+ }
256
+
257
+ // Make sure the determination of whether a property is the first property or not is done correctly.
258
+ class ClassUsingSimpleTraits
259
+ {
260
+ use HelloWorld;
261
+
262
+ /* comment */
263
+ public $firstVar = array( 'a', 'b' );
264
+
265
+ protected $secondVar = true;
266
+ }
267
+
268
+ class ClassUsingComplexTraits
269
+ {
270
+ use A, B {
271
+ B::smallTalk insteadof A;
272
+ A::bigTalk insteadof B;
273
+ }
274
+
275
+ public $firstVar = array( 'a', 'b' );
276
+
277
+ /* comment */
278
+ protected $secondVar = true;
279
+ }
280
+
281
+ class Foo
282
+ {
283
+
284
+
285
+ private function foo()
286
+ {
287
+ }
288
+
289
+
290
+ /* no error here because after function */
291
+ private $bar = false;
292
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/MemberVarSpacingUnitTest.php CHANGED
@@ -49,6 +49,13 @@ class MemberVarSpacingUnitTest extends AbstractSniffUnitTest
49
  229 => 1,
50
  241 => 1,
51
  246 => 1,
 
 
 
 
 
 
 
52
  ];
53
 
54
  }//end getErrorList()
49
  229 => 1,
50
  241 => 1,
51
  246 => 1,
52
+ 252 => 1,
53
+ 254 => 1,
54
+ 261 => 1,
55
+ 275 => 1,
56
+ 276 => 1,
57
+ 288 => 1,
58
+ 292 => 1,
59
  ];
60
 
61
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc CHANGED
@@ -235,3 +235,24 @@ $x = $foo ? function ($foo) use /* comment */ ($bar): int {
235
  $x = !$foo ? $bar : function (): int {
236
  return 1;
237
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  $x = !$foo ? $bar : function (): int {
236
  return 1;
237
  };
238
+
239
+ $a =
240
+ // Comment.
241
+ [
242
+ 'a',
243
+ 'b',
244
+ ];
245
+
246
+ $a =
247
+ // phpcs:ignore Standard.Category.Sniff -- for reasons.
248
+ [
249
+ 'a',
250
+ 'b',
251
+ ];
252
+
253
+ $foo = is_array($bar) ? array_map(
254
+ function () {},
255
+ $bar
256
+ ) : $bar;
257
+
258
+ function bar(): array {}
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.inc.fixed CHANGED
@@ -229,3 +229,24 @@ $x = $foo ? function ($foo) use /* comment */ ($bar): int {
229
  $x = !$foo ? $bar : function (): int {
230
  return 1;
231
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  $x = !$foo ? $bar : function (): int {
230
  return 1;
231
  };
232
+
233
+ $a =
234
+ // Comment.
235
+ [
236
+ 'a',
237
+ 'b',
238
+ ];
239
+
240
+ $a =
241
+ // phpcs:ignore Standard.Category.Sniff -- for reasons.
242
+ [
243
+ 'a',
244
+ 'b',
245
+ ];
246
+
247
+ $foo = is_array($bar) ? array_map(
248
+ function () {},
249
+ $bar
250
+ ) : $bar;
251
+
252
+ function bar(): array {}
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/OperatorSpacingUnitTest.php CHANGED
@@ -94,6 +94,8 @@ class OperatorSpacingUnitTest extends AbstractSniffUnitTest
94
  199 => 1,
95
  200 => 1,
96
  201 => 2,
 
 
97
  ];
98
  break;
99
  case 'OperatorSpacingUnitTest.js':
94
  199 => 1,
95
  200 => 1,
96
  201 => 2,
97
+ 239 => 1,
98
+ 246 => 1,
99
  ];
100
  break;
101
  case 'OperatorSpacingUnitTest.js':
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc CHANGED
@@ -38,10 +38,47 @@ abstract class Foo
38
  }
39
  }
40
 
41
- if ($geometry instanceof static) {
42
  echo 'foo';
43
  }
44
 
45
  class MyClass1 {
46
  use HelloWorld { sayHello as private; }
47
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
  }
40
 
41
+ if ($geometry instanceof static || $geometry instanceof static) {
42
  echo 'foo';
43
  }
44
 
45
  class MyClass1 {
46
  use HelloWorld { sayHello as private; }
47
  }
48
+
49
+ abstract class Foo
50
+ {
51
+ public static function getInstance()
52
+ {
53
+ return new /* comment */ static();
54
+ }
55
+
56
+ public static function output()
57
+ {
58
+ static /* comment */ :: bar();
59
+ }
60
+ }
61
+
62
+ class MyOtherClass
63
+ {
64
+ public
65
+ $varK = array( 'a', 'b' );
66
+
67
+ protected $varK,
68
+ $varL,
69
+ $varM;
70
+
71
+ protected static
72
+ $varK, $varL, $varM;
73
+
74
+ private
75
+ $varO = true,
76
+ $varP = array( 'a' => 'a', 'b' => 'b' ),
77
+ $varQ = 'string',
78
+ $varR = 123;
79
+
80
+ // Intentionally missing a semi-colon for testing.
81
+ public
82
+ $varS,
83
+ $varT
84
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.inc.fixed CHANGED
@@ -35,10 +35,45 @@ abstract class Foo
35
  }
36
  }
37
 
38
- if ($geometry instanceof static) {
39
  echo 'foo';
40
  }
41
 
42
  class MyClass1 {
43
  use HelloWorld { sayHello as private; }
44
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  }
36
  }
37
 
38
+ if ($geometry instanceof static || $geometry instanceof static) {
39
  echo 'foo';
40
  }
41
 
42
  class MyClass1 {
43
  use HelloWorld { sayHello as private; }
44
  }
45
+
46
+ abstract class Foo
47
+ {
48
+ public static function getInstance()
49
+ {
50
+ return new /* comment */ static();
51
+ }
52
+
53
+ public static function output()
54
+ {
55
+ static /* comment */ :: bar();
56
+ }
57
+ }
58
+
59
+ class MyOtherClass
60
+ {
61
+ public $varK = array( 'a', 'b' );
62
+
63
+ protected $varK,
64
+ $varL,
65
+ $varM;
66
+
67
+ protected static $varK, $varL, $varM;
68
+
69
+ private
70
+ $varO = true,
71
+ $varP = array( 'a' => 'a', 'b' => 'b' ),
72
+ $varQ = 'string',
73
+ $varR = 123;
74
+
75
+ // Intentionally missing a semi-colon for testing.
76
+ public
77
+ $varS,
78
+ $varT
79
+ }
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/ScopeKeywordSpacingUnitTest.php CHANGED
@@ -35,6 +35,9 @@ class ScopeKeywordSpacingUnitTest extends AbstractSniffUnitTest
35
  26 => 1,
36
  28 => 1,
37
  29 => 1,
 
 
 
38
  ];
39
 
40
  }//end getErrorList()
35
  26 => 1,
36
  28 => 1,
37
  29 => 1,
38
+ 64 => 1,
39
+ 67 => 1,
40
+ 71 => 1,
41
  ];
42
 
43
  }//end getErrorList()
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.inc ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php
3
+ echo 'hi';
4
+ echo 'hello';
5
+
6
+ if ($something) {
7
+
8
+ }
9
+
10
+
11
+ function myFunction()
12
+ {
13
+ echo 'code here';
14
+
15
+ echo 'code here';
16
+
17
+
18
+ // Hello.
19
+
20
+ /*
21
+ HI
22
+ */
23
+
24
+
25
+ }
26
+
27
+ /**
28
+ * Doc comment with a white space at the end.
29
+ */
30
+ function myFunction2()
31
+ {
32
+ echo 'code here';
33
+
34
+
35
+ echo 'code here';
36
+
37
+ }
38
+
39
+ // phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines true
40
+
41
+ function myFunction2()
42
+ {
43
+ echo 'code here';
44
+
45
+ echo 'code here';
46
+
47
+ }
48
+
49
+ // Ordinary comment with extra whitespace at the end
50
+
51
+ // phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines false
52
+
53
+ // Уберём из системных свойств все кроме информации об услугах
54
+
55
+ ?>
56
+
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.1.inc.fixed ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ echo 'hi';
3
+ echo 'hello';
4
+
5
+ if ($something) {
6
+
7
+ }
8
+
9
+
10
+ function myFunction()
11
+ {
12
+ echo 'code here';
13
+
14
+ echo 'code here';
15
+
16
+ // Hello.
17
+
18
+ /*
19
+ HI
20
+ */
21
+
22
+ }
23
+
24
+ /**
25
+ * Doc comment with a white space at the end.
26
+ */
27
+ function myFunction2()
28
+ {
29
+ echo 'code here';
30
+
31
+ echo 'code here';
32
+
33
+ }
34
+
35
+ // phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines true
36
+
37
+ function myFunction2()
38
+ {
39
+ echo 'code here';
40
+
41
+ echo 'code here';
42
+
43
+ }
44
+
45
+ // Ordinary comment with extra whitespace at the end
46
+
47
+ // phpcs:set Squiz.WhiteSpace.SuperfluousWhitespace ignoreBlankLines false
48
+
49
+ // Уберём из системных свойств все кроме информации об услугах
50
+
51
+ ?>
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.inc ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php /* phpcs:set foo bar */
3
+ ?>
4
+ <p>
5
+ <?php /* phpcs:ignore Squiz.WhiteSpace.SuperfluousWhitespace.EndLine */ ?>
6
+ <p><?php echo 'foo';
7
+
8
+ /* phpcs:set foo bar */ ?>
9
+
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.2.inc.fixed ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php /* phpcs:set foo bar */
2
+ ?>
3
+ <p>
4
+ <?php /* phpcs:ignore Squiz.WhiteSpace.SuperfluousWhitespace.EndLine */ ?>
5
+ <p><?php echo 'foo';
6
+
7
+ /* phpcs:set foo bar */ ?>
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.inc ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+
4
+
5
+
6
+ <?php
7
+
8
+ // This should throw an error - mixed: spaces, tabs, new lines.
9
+
10
+ ?>
11
+
12
+
13
+
14
+
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.3.inc.fixed ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+
3
+ // This should throw an error - mixed: spaces, tabs, new lines.
4
+
5
+ ?>
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.4.inc ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+
3
+ // This should throw an error - single space before open tag, tab + space after closing tag.
4
+ ?>
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.4.inc.fixed ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+
3
+ // This should throw an error - single space before open tag, tab + space after closing tag.
4
+ ?>
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.5.inc ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+  <?php
2
+
3
+ // This should throw an error - unicode space before open tag and after close tag.
4
+ ?> 
5
+  
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.5.inc.fixed ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+
3
+ // This should throw an error - unicode space before open tag and after close tag.
4
+ ?>
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/Tests/WhiteSpace/SuperfluousWhitespaceUnitTest.php CHANGED
@@ -28,7 +28,7 @@ class SuperfluousWhitespaceUnitTest extends AbstractSniffUnitTest
28
  public function getErrorList($testFile='SuperfluousWhitespaceUnitTest.inc')
29
  {
30
  switch ($testFile) {
31
- case 'SuperfluousWhitespaceUnitTest.inc':
32
  return [
33
  2 => 1,
34
  4 => 1,
@@ -43,6 +43,25 @@ class SuperfluousWhitespaceUnitTest extends AbstractSniffUnitTest
43
  55 => 1,
44
  ];
45
  break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  case 'SuperfluousWhitespaceUnitTest.1.js':
47
  return [
48
  1 => 1,
28
  public function getErrorList($testFile='SuperfluousWhitespaceUnitTest.inc')
29
  {
30
  switch ($testFile) {
31
+ case 'SuperfluousWhitespaceUnitTest.1.inc':
32
  return [
33
  2 => 1,
34
  4 => 1,
43
  55 => 1,
44
  ];
45
  break;
46
+ case 'SuperfluousWhitespaceUnitTest.2.inc':
47
+ return [
48
+ 2 => 1,
49
+ 8 => 1,
50
+ ];
51
+ break;
52
+ case 'SuperfluousWhitespaceUnitTest.3.inc':
53
+ return [
54
+ 6 => 1,
55
+ 10 => 1,
56
+ ];
57
+ break;
58
+ case 'SuperfluousWhitespaceUnitTest.4.inc':
59
+ case 'SuperfluousWhitespaceUnitTest.5.inc':
60
+ return [
61
+ 1 => 1,
62
+ 4 => 1,
63
+ ];
64
+ break;
65
  case 'SuperfluousWhitespaceUnitTest.1.js':
66
  return [
67
  1 => 1,
vendor/squizlabs/php_codesniffer/src/Standards/Squiz/ruleset.xml CHANGED
@@ -1,92 +1,131 @@
1
  <?xml version="1.0"?>
2
  <ruleset name="Squiz">
3
- <description>The Squiz coding standard.</description>
4
 
5
- <!-- Include some specific sniffs -->
6
- <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
7
- <rule ref="Generic.CodeAnalysis.EmptyStatement"/>
8
- <rule ref="Generic.Commenting.Todo"/>
9
- <rule ref="Generic.Commenting.DocComment"/>
10
- <rule ref="Generic.ControlStructures.InlineControlStructure"/>
11
- <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
12
- <rule ref="Generic.Formatting.SpaceAfterCast"/>
13
- <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
14
- <rule ref="Generic.NamingConventions.ConstructorName"/>
15
- <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
16
- <rule ref="Generic.PHP.DeprecatedFunctions"/>
17
- <rule ref="Generic.PHP.DisallowShortOpenTag"/>
18
- <rule ref="Generic.PHP.LowerCaseKeyword"/>
19
- <rule ref="Generic.PHP.LowerCaseConstant"/>
20
- <rule ref="Generic.Strings.UnnecessaryStringConcat"/>
21
- <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
22
- <rule ref="Generic.WhiteSpace.ScopeIndent"/>
23
- <rule ref="PEAR.ControlStructures.MultiLineCondition"/>
24
- <rule ref="PEAR.Files.IncludingFile"/>
25
- <rule ref="PEAR.Formatting.MultiLineAssignment"/>
26
- <rule ref="PEAR.Functions.ValidDefaultValue"/>
27
- <rule ref="PSR2.Files.EndFileNewline"/>
28
- <rule ref="Zend.Files.ClosingTag"/>
29
- <rule ref="Zend.Debug.CodeAnalyzer"/>
 
30
 
31
- <!-- Lines can be 120 chars long, but never show errors -->
32
- <rule ref="Generic.Files.LineLength">
33
- <properties>
34
- <property name="lineLimit" value="120"/>
35
- <property name="absoluteLineLimit" value="0"/>
36
- </properties>
37
- </rule>
38
 
39
- <!-- Use Unix newlines -->
40
- <rule ref="Generic.Files.LineEndings">
41
- <properties>
42
- <property name="eolChar" value="\n"/>
43
- </properties>
44
- </rule>
45
 
46
- <!-- Have 20 chars padding maximum and always show as errors -->
47
- <rule ref="Generic.Formatting.MultipleStatementAlignment">
48
- <properties>
49
- <property name="maxPadding" value="20"/>
50
- <property name="error" value="true"/>
51
- </properties>
52
- </rule>
53
 
54
- <!-- We allow empty catch statements -->
55
- <rule ref="Generic.CodeAnalysis.EmptyStatement.DetectedCATCH">
56
- <severity>0</severity>
57
- </rule>
 
 
 
 
 
 
 
 
58
 
59
- <!-- We don't want gsjlint throwing errors for things we already check -->
60
- <rule ref="Generic.Debug.ClosureLinter">
61
- <properties>
62
- <property name="errorCodes" type="array" value="0210"/>
63
- <property name="ignoreCodes" type="array" value="0001,0110,0240"/>
64
- </properties>
65
- </rule>
66
- <rule ref="Generic.Debug.ClosureLinter.ExternalToolError">
67
- <message>%2$s</message>
68
- </rule>
69
 
70
- <!-- Only one argument per line in multi-line function calls -->
71
- <rule ref="PEAR.Functions.FunctionCallSignature">
72
- <properties>
73
- <property name="allowMultipleArguments" value="false"/>
74
- </properties>
75
- </rule>
 
 
 
 
76
 
77
- <!-- We use custom indent rules for arrays -->
78
- <rule ref="Generic.Arrays.ArrayIndent"/>
79
- <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
80
- <severity>0</severity>
81
- </rule>
82
- <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
83
- <severity>0</severity>
84
- </rule>
85
- <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
86
- <severity>0</severity>
87
- </rule>
88
- <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine">
89
- <severity>0</severity>
90
- </rule>
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  </ruleset>
1
  <?xml version="1.0"?>
2
  <ruleset name="Squiz">
3
+ <description>The Squiz coding standard.</description>
4
 
5
+ <!-- Include some specific sniffs -->
6
+ <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
7
+ <rule ref="Generic.CodeAnalysis.EmptyStatement"/>
8
+ <rule ref="Generic.Commenting.Todo"/>
9
+ <rule ref="Generic.Commenting.DocComment"/>
10
+ <rule ref="Generic.ControlStructures.InlineControlStructure"/>
11
+ <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
12
+ <rule ref="Generic.Formatting.SpaceAfterCast"/>
13
+ <rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
14
+ <rule ref="Generic.NamingConventions.ConstructorName"/>
15
+ <rule ref="Generic.NamingConventions.UpperCaseConstantName"/>
16
+ <rule ref="Generic.PHP.DeprecatedFunctions"/>
17
+ <rule ref="Generic.PHP.DisallowShortOpenTag"/>
18
+ <rule ref="Generic.PHP.LowerCaseKeyword"/>
19
+ <rule ref="Generic.PHP.LowerCaseConstant"/>
20
+ <rule ref="Generic.Strings.UnnecessaryStringConcat"/>
21
+ <rule ref="Generic.WhiteSpace.DisallowTabIndent"/>
22
+ <rule ref="Generic.WhiteSpace.LanguageConstructSpacing"/>
23
+ <rule ref="Generic.WhiteSpace.ScopeIndent"/>
24
+ <rule ref="PEAR.ControlStructures.MultiLineCondition"/>
25
+ <rule ref="PEAR.Files.IncludingFile"/>
26
+ <rule ref="PEAR.Formatting.MultiLineAssignment"/>
27
+ <rule ref="PEAR.Functions.ValidDefaultValue"/>
28
+ <rule ref="PSR2.Files.EndFileNewline"/>
29
+ <rule ref="Zend.Files.ClosingTag"/>
30
+ <rule ref="Zend.Debug.CodeAnalyzer"/>
31
 
32
+ <!-- Lines can be 120 chars long, but never show errors -->
33
+ <rule ref="Generic.Files.LineLength">
34
+ <properties>
35
+ <property name="lineLimit" value="120"/>
36
+ <property name="absoluteLineLimit" value="0"/>
37
+ </properties>
38
+ </rule>
39
 
40
+ <!-- Use Unix newlines -->
41
+ <rule ref="Generic.Files.LineEndings">
42
+ <properties>
43
+ <property name="eolChar" value="\n"/>
44
+ </properties>
45
+ </rule>
46
 
47
+ <!-- Have 20 chars padding maximum and always show as errors -->
48
+ <rule ref="Generic.Formatting.MultipleStatementAlignment">
49
+ <properties>
50
+ <property name="maxPadding" value="20"/>
51
+ <property name="error" value="true"/>
52
+ </properties>
53
+ </rule>
54
 
55
+ <!-- Ban some functions -->
56
+ <rule ref="Generic.PHP.ForbiddenFunctions">
57
+ <properties>
58
+ <property name="forbiddenFunctions" type="array">
59
+ <element key="sizeof" value="count"/>
60
+ <element key="delete" value="unset"/>
61
+ <element key="print" value="echo"/>
62
+ <element key="is_null" value="null"/>
63
+ <element key="create_function" value="null"/>
64
+ </property>
65
+ </properties>
66
+ </rule>
67
 
68
+ <!-- We allow empty catch statements -->
69
+ <rule ref="Generic.CodeAnalysis.EmptyStatement.DetectedCATCH">
70
+ <severity>0</severity>
71
+ </rule>
 
 
 
 
 
 
72
 
73
+ <!-- We don't want gsjlint throwing errors for things we already check -->
74
+ <rule ref="Generic.Debug.ClosureLinter">
75
+ <properties>
76
+ <property name="errorCodes" type="array" value="0210"/>
77
+ <property name="ignoreCodes" type="array" value="0001,0110,0240"/>
78
+ </properties>
79
+ </rule>
80
+ <rule ref="Generic.Debug.ClosureLinter.ExternalToolError">
81
+ <message>%2$s</message>
82
+ </rule>
83
 
84
+ <!-- Only one argument per line in multi-line function calls -->
85
+ <rule ref="PEAR.Functions.FunctionCallSignature">
86
+ <properties>
87
+ <property name="allowMultipleArguments" value="false"/>
88
+ </properties>
89
+ </rule>
 
 
 
 
 
 
 
 
90
 
91
+ <!-- We use custom indent rules for arrays -->
92
+ <rule ref="Generic.Arrays.ArrayIndent"/>
93
+ <rule ref="Squiz.Arrays.ArrayDeclaration.KeyNotAligned">
94
+ <severity>0</severity>
95
+ </rule>
96
+ <rule ref="Squiz.Arrays.ArrayDeclaration.ValueNotAligned">
97
+ <severity>0</severity>
98
+ </rule>
99
+ <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNotAligned">
100
+ <severity>0</severity>
101
+ </rule>
102
+ <rule ref="Squiz.Arrays.ArrayDeclaration.CloseBraceNewLine">
103
+ <severity>0</severity>
104
+ </rule>
105
+
106
+ <!-- Squiz.WhiteSpace.LanguageConstructSpacing is deprecated -->
107
+ <rule ref="Squiz.WhiteSpace.LanguageConstructSpacing">
108
+ <severity>0</severity>
109
+ </rule>
110
+
111
+ <!-- Prevent fixer conflict for conflicting rules. -->
112
+ <rule ref="Squiz.Commenting.InlineComment">
113
+ <exclude name="Squiz.Commenting.InlineComment.SpacingAfterAtFunctionEnd"/>
114
+ </rule>
115
+
116
+ <!-- Private methods MUST not be prefixed with an underscore -->
117
+ <rule ref="Squiz.NamingConventions.ValidFunctionName.PrivateNoUnderscore">
118
+ <severity>0</severity>
119
+ </rule>
120
+ <rule ref="PSR2.Methods.MethodDeclaration.Underscore">
121
+ <type>error</type>
122
+ </rule>
123
+
124
+ <!-- Private properties MUST not be prefixed with an underscore -->
125
+ <rule ref="Squiz.NamingConventions.ValidVariableName.PrivateNoUnderscore">
126
+ <severity>0</severity>
127
+ </rule>
128
+ <rule ref="PSR2.Classes.PropertyDeclaration.Underscore">
129
+ <type>error</type>
130
+ </rule>
131
  </ruleset>
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php CHANGED
@@ -43,7 +43,7 @@ class CodeAnalyzerSniff implements Sniff
43
  public function process(File $phpcsFile, $stackPtr)
44
  {
45
  $analyzerPath = Config::getExecutablePath('zend_ca');
46
- if (is_null($analyzerPath) === true) {
47
  return;
48
  }
49
 
43
  public function process(File $phpcsFile, $stackPtr)
44
  {
45
  $analyzerPath = Config::getExecutablePath('zend_ca');
46
+ if ($analyzerPath === null) {
47
  return;
48
  }
49
 
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/Files/ClosingTagSniff.php CHANGED
@@ -11,6 +11,7 @@ namespace PHP_CodeSniffer\Standards\Zend\Sniffs\Files;
11
 
12
  use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
 
14
 
15
  class ClosingTagSniff implements Sniff
16
  {
@@ -51,13 +52,22 @@ class ClosingTagSniff implements Sniff
51
  $error = 'A closing tag is not permitted at the end of a PHP file';
52
  $fix = $phpcsFile->addFixableError($error, $last, 'NotAllowed');
53
  if ($fix === true) {
54
- $phpcsFile->fixer->replaceToken($last, '');
 
 
 
 
 
 
 
 
 
55
  }
56
 
57
  $phpcsFile->recordMetric($stackPtr, 'PHP closing tag at EOF', 'yes');
58
  } else {
59
  $phpcsFile->recordMetric($stackPtr, 'PHP closing tag at EOF', 'no');
60
- }
61
 
62
  // Ignore the rest of the file.
63
  return ($phpcsFile->numTokens + 1);
11
 
12
  use PHP_CodeSniffer\Sniffs\Sniff;
13
  use PHP_CodeSniffer\Files\File;
14
+ use PHP_CodeSniffer\Util\Tokens;
15
 
16
  class ClosingTagSniff implements Sniff
17
  {
52
  $error = 'A closing tag is not permitted at the end of a PHP file';
53
  $fix = $phpcsFile->addFixableError($error, $last, 'NotAllowed');
54
  if ($fix === true) {
55
+ $phpcsFile->fixer->beginChangeset();
56
+ $phpcsFile->fixer->replaceToken($last, $phpcsFile->eolChar);
57
+ $prev = $phpcsFile->findPrevious(Tokens::$emptyTokens, ($last - 1), null, true);
58
+ if ($tokens[$prev]['code'] !== T_SEMICOLON
59
+ && $tokens[$prev]['code'] !== T_CLOSE_CURLY_BRACKET
60
+ ) {
61
+ $phpcsFile->fixer->addContent($prev, ';');
62
+ }
63
+
64
+ $phpcsFile->fixer->endChangeset();
65
  }
66
 
67
  $phpcsFile->recordMetric($stackPtr, 'PHP closing tag at EOF', 'yes');
68
  } else {
69
  $phpcsFile->recordMetric($stackPtr, 'PHP closing tag at EOF', 'no');
70
+ }//end if
71
 
72
  // Ignore the rest of the file.
73
  return ($phpcsFile->numTokens + 1);
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php CHANGED
@@ -31,23 +31,8 @@ class ValidVariableNameSniff extends AbstractVariableSniff
31
  $tokens = $phpcsFile->getTokens();
32
  $varName = ltrim($tokens[$stackPtr]['content'], '$');
33
 
34
- $phpReservedVars = [
35
- '_SERVER' => true,
36
- '_GET' => true,
37
- '_POST' => true,
38
- '_REQUEST' => true,
39
- '_SESSION' => true,
40
- '_ENV' => true,
41
- '_COOKIE' => true,
42
- '_FILES' => true,
43
- 'GLOBALS' => true,
44
- 'http_response_header' => true,
45
- 'HTTP_RAW_POST_DATA' => true,
46
- 'php_errormsg' => true,
47
- ];
48
-
49
  // If it's a php reserved var, then its ok.
50
- if (isset($phpReservedVars[$varName]) === true) {
51
  return;
52
  }
53
 
@@ -183,25 +168,10 @@ class ValidVariableNameSniff extends AbstractVariableSniff
183
  {
184
  $tokens = $phpcsFile->getTokens();
185
 
186
- $phpReservedVars = [
187
- '_SERVER',
188
- '_GET',
189
- '_POST',
190
- '_REQUEST',
191
- '_SESSION',
192
- '_ENV',
193
- '_COOKIE',
194
- '_FILES',
195
- 'GLOBALS',
196
- 'http_response_header',
197
- 'HTTP_RAW_POST_DATA',
198
- 'php_errormsg',
199
- ];
200
-
201
  if (preg_match_all('|[^\\\]\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)|', $tokens[$stackPtr]['content'], $matches) !== 0) {
202
  foreach ($matches[1] as $varName) {
203
  // If it's a php reserved var, then its ok.
204
- if (in_array($varName, $phpReservedVars) === true) {
205
  continue;
206
  }
207
 
31
  $tokens = $phpcsFile->getTokens();
32
  $varName = ltrim($tokens[$stackPtr]['content'], '$');
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  // If it's a php reserved var, then its ok.
35
+ if (isset($this->phpReservedVars[$varName]) === true) {
36
  return;
37
  }
38
 
168
  {
169
  $tokens = $phpcsFile->getTokens();
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  if (preg_match_all('|[^\\\]\$([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)|', $tokens[$stackPtr]['content'], $matches) !== 0) {
172
  foreach ($matches[1] as $varName) {
173
  // If it's a php reserved var, then its ok.
174
+ if (isset($this->phpReservedVars[$varName]) === true) {
175
  continue;
176
  }
177
 
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Debug/CodeAnalyzerUnitTest.php CHANGED
@@ -24,7 +24,11 @@ class CodeAnalyzerUnitTest extends AbstractSniffUnitTest
24
  protected function shouldSkipTest()
25
  {
26
  $analyzerPath = Config::getExecutablePath('zend_ca');
27
- return (is_null($analyzerPath));
 
 
 
 
28
 
29
  }//end shouldSkipTest()
30
 
24
  protected function shouldSkipTest()
25
  {
26
  $analyzerPath = Config::getExecutablePath('zend_ca');
27
+ if ($analyzerPath === null) {
28
+ return true;
29
+ }
30
+
31
+ return false;
32
 
33
  }//end shouldSkipTest()
34
 
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.1.inc.fixed ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ echo 'hi';
4
+
5
+ ?>
6
+
7
+ <?php
8
+
9
+ echo 'bye';
10
+
11
+
12
+
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.2.inc CHANGED
@@ -1,3 +1,3 @@
1
  <div class="clear"></div>
2
  <?php include('inc.php'); ?>
3
- </div>
1
  <div class="clear"></div>
2
  <?php include('inc.php'); ?>
3
+ </div>
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.3.inc ADDED
@@ -0,0 +1 @@
 
1
+ <?php include($this->add('arg'))?>
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.3.inc.fixed ADDED
@@ -0,0 +1 @@
 
1
+ <?php include($this->add('arg'));
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.4.inc ADDED
@@ -0,0 +1 @@
 
1
+ <?php include($this->add('arg')) /* comment */ ?>
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.4.inc.fixed ADDED
@@ -0,0 +1 @@
 
1
+ <?php include($this->add('arg')); /* comment */
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.5.inc ADDED
@@ -0,0 +1 @@
 
1
+ <?php function foo() { include($this->add('arg')); } ?>
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.5.inc.fixed ADDED
@@ -0,0 +1 @@
 
1
+ <?php function foo() { include($this->add('arg')); }
vendor/squizlabs/php_codesniffer/src/Standards/Zend/Tests/Files/ClosingTagUnitTest.php CHANGED
@@ -27,12 +27,20 @@ class ClosingTagUnitTest extends AbstractSniffUnitTest
27
  */
28
  public function getErrorList($testFile='')
29
  {
30
- if ($testFile !== 'ClosingTagUnitTest.1.inc') {
 
 
 
 
 
 
 
 
 
31
  return [];
 
32
  }
33
 
34
- return [11 => 1];
35
-
36
  }//end getErrorList()
37
 
38
 
27
  */
28
  public function getErrorList($testFile='')
29
  {
30
+ switch ($testFile) {
31
+ case 'ClosingTagUnitTest.1.inc':
32
+ return [11 => 1];
33
+ break;
34
+ case 'ClosingTagUnitTest.3.inc':
35
+ case 'ClosingTagUnitTest.4.inc':
36
+ case 'ClosingTagUnitTest.5.inc':
37
+ return [1 => 1];
38
+ break;
39
+ default:
40
  return [];
41
+ break;
42
  }
43
 
 
 
44
  }//end getErrorList()
45
 
46
 
vendor/squizlabs/php_codesniffer/src/Tokenizers/CSS.php CHANGED
@@ -390,7 +390,7 @@ class CSS extends PHP
390
 
391
  // Needs to be in the format "url(" for it to be a URL.
392
  if ($finalTokens[$x]['code'] !== T_OPEN_PARENTHESIS) {
393
- continue;
394
  }
395
 
396
  // Make sure the content isn't empty.
@@ -401,7 +401,7 @@ class CSS extends PHP
401
  }
402
 
403
  if ($finalTokens[$y]['code'] === T_CLOSE_PARENTHESIS) {
404
- continue;
405
  }
406
 
407
  if (PHP_CODESNIFFER_VERBOSITY > 1) {
390
 
391
  // Needs to be in the format "url(" for it to be a URL.
392
  if ($finalTokens[$x]['code'] !== T_OPEN_PARENTHESIS) {
393
+ continue 2;
394
  }
395
 
396
  // Make sure the content isn't empty.
401
  }
402
 
403
  if ($finalTokens[$y]['code'] === T_CLOSE_PARENTHESIS) {
404
+ continue 2;
405
  }
406
 
407
  if (PHP_CODESNIFFER_VERBOSITY > 1) {
vendor/squizlabs/php_codesniffer/src/Tokenizers/JS.php CHANGED
@@ -932,6 +932,7 @@ class JS extends Tokenizer
932
  T_RETURN => true,
933
  T_BOOLEAN_OR => true,
934
  T_BOOLEAN_AND => true,
 
935
  T_BITWISE_OR => true,
936
  T_BITWISE_AND => true,
937
  T_COMMA => true,
932
  T_RETURN => true,
933
  T_BOOLEAN_OR => true,
934
  T_BOOLEAN_AND => true,
935
+ T_BOOLEAN_NOT => true,
936
  T_BITWISE_OR => true,
937
  T_BITWISE_AND => true,
938
  T_COMMA => true,
vendor/squizlabs/php_codesniffer/src/Tokenizers/PHP.php CHANGED
@@ -420,7 +420,6 @@ class PHP extends Tokenizer
420
  T_SR => 2,
421
  T_SL_EQUAL => 3,
422
  T_SR_EQUAL => 3,
423
- T_ARRAY_HINT => 5,
424
  T_GREATER_THAN => 1,
425
  T_LESS_THAN => 1,
426
  T_BOOLEAN_NOT => 1,
@@ -477,6 +476,11 @@ class PHP extends Tokenizer
477
  $commentTokenizer = new Comment();
478
 
479
  for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) {
 
 
 
 
 
480
  $token = (array) $tokens[$stackPtr];
481
  $tokenIsArray = isset($token[1]);
482
 
@@ -646,7 +650,7 @@ class PHP extends Tokenizer
646
  // Check if this is actually a nowdoc and use a different token
647
  // to help the sniffs.
648
  $nowdoc = false;
649
- if ($token[1][3] === "'") {
650
  $finalTokens[$newStackPtr]['code'] = T_START_NOWDOC;
651
  $finalTokens[$newStackPtr]['type'] = 'T_START_NOWDOC';
652
  $nowdoc = true;
@@ -746,15 +750,20 @@ class PHP extends Tokenizer
746
  && $tokens[($stackPtr + 2)][0] === T_STRING
747
  && strtolower($tokens[($stackPtr + 2)][1]) === 'from'
748
  ) {
749
- $newToken = [];
750
- $newToken['code'] = T_YIELD_FROM;
751
- $newToken['type'] = 'T_YIELD_FROM';
752
- $newToken['content'] = $token[1].$tokens[($stackPtr + 1)][1].$tokens[($stackPtr + 2)][1];
753
- $finalTokens[$newStackPtr] = $newToken;
754
 
755
- $newStackPtr++;
756
- $stackPtr += 2;
757
- continue;
 
 
 
 
 
 
 
758
  }
759
 
760
  /*
@@ -775,25 +784,30 @@ class PHP extends Tokenizer
775
  && $tokens[($stackPtr + 2)][0] === T_STRING
776
  && strtolower($tokens[($stackPtr + 2)][1]) === 'from'
777
  ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
778
  $newToken = [];
779
- $newToken['code'] = T_YIELD_FROM;
780
- $newToken['type'] = 'T_YIELD_FROM';
781
- $newToken['content'] = $token[1].$tokens[($stackPtr + 1)][1].$tokens[($stackPtr + 2)][1];
782
  $finalTokens[$newStackPtr] = $newToken;
783
 
784
  $newStackPtr++;
785
- $stackPtr += 2;
786
  continue;
787
- }
788
-
789
- $newToken = [];
790
- $newToken['code'] = T_YIELD;
791
- $newToken['type'] = 'T_YIELD';
792
- $newToken['content'] = $token[1];
793
- $finalTokens[$newStackPtr] = $newToken;
794
-
795
- $newStackPtr++;
796
- continue;
797
  }//end if
798
 
799
  /*
@@ -1002,7 +1016,8 @@ class PHP extends Tokenizer
1002
  so go forward and change the token type before it is processed.
1003
  */
1004
 
1005
- if ($tokenIsArray === true && $token[0] === T_FUNCTION
 
1006
  && $finalTokens[$lastNotEmptyToken]['code'] !== T_USE
1007
  ) {
1008
  for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
@@ -1017,7 +1032,108 @@ class PHP extends Tokenizer
1017
  if ($x < $numTokens && is_array($tokens[$x]) === true) {
1018
  $tokens[$x][0] = T_STRING;
1019
  }
1020
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1021
 
1022
  /*
1023
  Before PHP 7, the <=> operator was tokenized as
@@ -1088,64 +1204,6 @@ class PHP extends Tokenizer
1088
  }
1089
  }//end if
1090
 
1091
- /*
1092
- HHVM 3.5 tokenizes "else[\s]+if" as a T_ELSEIF token while PHP
1093
- proper only tokenizes "elseif" as a T_ELSEIF token. So split
1094
- up the HHVM token to make it looks like proper PHP.
1095
- */
1096
-
1097
- if ($tokenIsArray === true
1098
- && $token[0] === T_ELSEIF
1099
- && strtolower($token[1]) !== 'elseif'
1100
- ) {
1101
- $finalTokens[$newStackPtr] = [
1102
- 'content' => substr($token[1], 0, 4),
1103
- 'code' => T_ELSE,
1104
- 'type' => 'T_ELSE',
1105
- ];
1106
-
1107
- $newStackPtr++;
1108
- $finalTokens[$newStackPtr] = [
1109
- 'content' => substr($token[1], 4, -2),
1110
- 'code' => T_WHITESPACE,
1111
- 'type' => 'T_WHITESPACE',
1112
- ];
1113
-
1114
- $newStackPtr++;
1115
- $finalTokens[$newStackPtr] = [
1116
- 'content' => substr($token[1], -2),
1117
- 'code' => T_IF,
1118
- 'type' => 'T_IF',
1119
- ];
1120
-
1121
- if (PHP_CODESNIFFER_VERBOSITY > 1) {
1122
- echo "\t\t* token $stackPtr changed from T_ELSEIF to T_ELSE/T_WHITESPACE/T_IF".PHP_EOL;
1123
- }
1124
-
1125
- $newStackPtr++;
1126
- continue;
1127
- }//end if
1128
-
1129
- /*
1130
- HHVM 3.5 and 3.6 tokenizes a hashbang line such as #!/usr/bin/php
1131
- as T_HASHBANG while PHP proper uses T_INLINE_HTML.
1132
- */
1133
-
1134
- if ($tokenIsArray === true && token_name($token[0]) === 'T_HASHBANG') {
1135
- $finalTokens[$newStackPtr] = [
1136
- 'content' => $token[1],
1137
- 'code' => T_INLINE_HTML,
1138
- 'type' => 'T_INLINE_HTML',
1139
- ];
1140
-
1141
- if (PHP_CODESNIFFER_VERBOSITY > 1) {
1142
- echo "\t\t* token $stackPtr changed from T_HASHBANG to T_INLINE_HTML".PHP_EOL;
1143
- }
1144
-
1145
- $newStackPtr++;
1146
- continue;
1147
- }//end if
1148
-
1149
  /*
1150
  If this token has newlines in its content, split each line up
1151
  and create a new token for each line. We do this so it's easier
@@ -1157,7 +1215,7 @@ class PHP extends Tokenizer
1157
  $tokenLines = explode($this->eolChar, $token[1]);
1158
  $numLines = count($tokenLines);
1159
  $newToken = [
1160
- 'type' => token_name($token[0]),
1161
  'code' => $token[0],
1162
  'content' => '',
1163
  ];
@@ -1255,9 +1313,15 @@ class PHP extends Tokenizer
1255
  }
1256
 
1257
  if ($tokens[$i] === ')') {
 
1258
  for ($i--; $i > 0; $i--) {
1259
  if ($tokens[$i] === '(') {
1260
- break;
 
 
 
 
 
1261
  }
1262
  }
1263
 
@@ -1288,14 +1352,14 @@ class PHP extends Tokenizer
1288
  // This is a special condition for T_ARRAY tokens used for
1289
  // type hinting function arguments as being arrays. We want to keep
1290
  // the parenthesis map clean, so let's tag these tokens as
1291
- // T_ARRAY_HINT.
1292
  if ($newToken['code'] === T_ARRAY) {
1293
  for ($i = $stackPtr; $i < $numTokens; $i++) {
1294
  if ($tokens[$i] === '(') {
1295
  break;
1296
  } else if ($tokens[$i][0] === T_VARIABLE) {
1297
- $newToken['code'] = T_ARRAY_HINT;
1298
- $newToken['type'] = 'T_ARRAY_HINT';
1299
  break;
1300
  }
1301
  }
@@ -1314,7 +1378,7 @@ class PHP extends Tokenizer
1314
  // where "class" should be T_STRING instead of T_CLASS.
1315
  if (($newToken['code'] === T_CLASS
1316
  || $newToken['code'] === T_FUNCTION)
1317
- && $finalTokens[($newStackPtr - 1)]['code'] === T_DOUBLE_COLON
1318
  ) {
1319
  $newToken['code'] = T_STRING;
1320
  $newToken['type'] = 'T_STRING';
@@ -1424,60 +1488,8 @@ class PHP extends Tokenizer
1424
  }
1425
  }
1426
  }
1427
-
1428
- $tokenAfterReturnTypeHint = $this->tokens[$i]['scope_opener'];
1429
- } else if (isset($this->tokens[$i]['parenthesis_closer']) === true) {
1430
- $tokenAfterReturnTypeHint = null;
1431
- for ($x = ($this->tokens[$i]['parenthesis_closer'] + 1); $x < $numTokens; $x++) {
1432
- if ($this->tokens[$x]['code'] === T_SEMICOLON) {
1433
- $tokenAfterReturnTypeHint = $x;
1434
- break;
1435
- }
1436
- }
1437
-
1438
- if ($tokenAfterReturnTypeHint === null) {
1439
- // Probably a syntax error.
1440
- continue;
1441
- }
1442
- } else {
1443
- // Probably a syntax error.
1444
- continue;
1445
  }//end if
1446
 
1447
- /*
1448
- Detect function return values and assign them
1449
- a special token, because PHP doesn't.
1450
- */
1451
-
1452
- for ($x = ($tokenAfterReturnTypeHint - 1); $x > $i; $x--) {
1453
- if (isset(Util\Tokens::$emptyTokens[$this->tokens[$x]['code']]) === false) {
1454
- if (in_array($this->tokens[$x]['code'], [T_STRING, T_ARRAY, T_ARRAY_HINT, T_CALLABLE, T_SELF, T_PARENT], true) === true) {
1455
- if (PHP_CODESNIFFER_VERBOSITY > 1) {
1456
- $line = $this->tokens[$x]['line'];
1457
- $type = $this->tokens[$x]['type'];
1458
- echo "\t* token $x on line $line changed from $type to T_RETURN_TYPE".PHP_EOL;
1459
- }
1460
-
1461
- $this->tokens[$x]['code'] = T_RETURN_TYPE;
1462
- $this->tokens[$x]['type'] = 'T_RETURN_TYPE';
1463
-
1464
- if (array_key_exists('parenthesis_opener', $this->tokens[$x]) === true) {
1465
- unset($this->tokens[$x]['parenthesis_opener']);
1466
- }
1467
-
1468
- if (array_key_exists('parenthesis_closer', $this->tokens[$x]) === true) {
1469
- unset($this->tokens[$x]['parenthesis_closer']);
1470
- }
1471
-
1472
- if (array_key_exists('parenthesis_owner', $this->tokens[$x]) === true) {
1473
- unset($this->tokens[$x]['parenthesis_owner']);
1474
- }
1475
- }//end if
1476
-
1477
- break;
1478
- }//end if
1479
- }//end for
1480
-
1481
  continue;
1482
  } else if ($this->tokens[$i]['code'] === T_CLASS && isset($this->tokens[$i]['scope_opener']) === true) {
1483
  /*
@@ -1534,7 +1546,7 @@ class PHP extends Tokenizer
1534
  T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING,
1535
  ];
1536
 
1537
- for ($x = ($i - 1); $x > 0; $x--) {
1538
  // If we hit a scope opener, the statement has ended
1539
  // without finding anything, so it's probably an array
1540
  // using PHP 7.1 short list syntax.
@@ -1586,15 +1598,6 @@ class PHP extends Tokenizer
1586
  }
1587
 
1588
  continue;
1589
- } else if ($this->tokens[$i]['code'] === T_ECHO && $this->tokens[$i]['content'] === '<?=') {
1590
- // HHVM tokenizes <?= as T_ECHO but it should be T_OPEN_TAG_WITH_ECHO.
1591
- $this->tokens[$i]['code'] = T_OPEN_TAG_WITH_ECHO;
1592
- $this->tokens[$i]['type'] = 'T_OPEN_TAG_WITH_ECHO';
1593
-
1594
- if (PHP_CODESNIFFER_VERBOSITY > 1) {
1595
- $line = $this->tokens[$i]['line'];
1596
- echo "\t* token $i on line $line changed from T_ECHO to T_OPEN_TAG_WITH_ECHO".PHP_EOL;
1597
- }
1598
  } else if ($this->tokens[$i]['code'] === T_TRUE
1599
  || $this->tokens[$i]['code'] === T_FALSE
1600
  || $this->tokens[$i]['code'] === T_NULL
@@ -1857,7 +1860,7 @@ class PHP extends Tokenizer
1857
  } else {
1858
  $newToken = [
1859
  'code' => $token[0],
1860
- 'type' => token_name($token[0]),
1861
  ];
1862
 
1863
  self::$resolveTokenCache[$token[0]] = $newToken;
420
  T_SR => 2,
421
  T_SL_EQUAL => 3,
422
  T_SR_EQUAL => 3,
 
423
  T_GREATER_THAN => 1,
424
  T_LESS_THAN => 1,
425
  T_BOOLEAN_NOT => 1,
476
  $commentTokenizer = new Comment();
477
 
478
  for ($stackPtr = 0; $stackPtr < $numTokens; $stackPtr++) {
479
+ // Special case for tokens we have needed to blank out.
480
+ if ($tokens[$stackPtr] === null) {
481
+ continue;
482
+ }
483
+
484
  $token = (array) $tokens[$stackPtr];
485
  $tokenIsArray = isset($token[1]);
486
 
650
  // Check if this is actually a nowdoc and use a different token
651
  // to help the sniffs.
652
  $nowdoc = false;
653
+ if (strpos($token[1], "'") !== false) {
654
  $finalTokens[$newStackPtr]['code'] = T_START_NOWDOC;
655
  $finalTokens[$newStackPtr]['type'] = 'T_START_NOWDOC';
656
  $nowdoc = true;
750
  && $tokens[($stackPtr + 2)][0] === T_STRING
751
  && strtolower($tokens[($stackPtr + 2)][1]) === 'from'
752
  ) {
753
+ // Could be multi-line, so just just the token stack.
754
+ $token[0] = T_YIELD_FROM;
755
+ $token[1] = $token[1].$tokens[($stackPtr + 1)][1].$tokens[($stackPtr + 2)][1];
 
 
756
 
757
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
758
+ for ($i = ($stackPtr + 1); $i <= ($stackPtr + 2); $i++) {
759
+ $type = Util\Tokens::tokenName($tokens[$i][0]);
760
+ $content = Util\Common::prepareForOutput($tokens[$i][1]);
761
+ echo "\t\t* token $i merged into T_YIELD_FROM; was: $type => $content".PHP_EOL;
762
+ }
763
+ }
764
+
765
+ $tokens[($stackPtr + 1)] = null;
766
+ $tokens[($stackPtr + 2)] = null;
767
  }
768
 
769
  /*
784
  && $tokens[($stackPtr + 2)][0] === T_STRING
785
  && strtolower($tokens[($stackPtr + 2)][1]) === 'from'
786
  ) {
787
+ // Could be multi-line, so just just the token stack.
788
+ $token[0] = T_YIELD_FROM;
789
+ $token[1] = $token[1].$tokens[($stackPtr + 1)][1].$tokens[($stackPtr + 2)][1];
790
+
791
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
792
+ for ($i = ($stackPtr + 1); $i <= ($stackPtr + 2); $i++) {
793
+ $type = Util\Tokens::tokenName($tokens[$i][0]);
794
+ $content = Util\Common::prepareForOutput($tokens[$i][1]);
795
+ echo "\t\t* token $i merged into T_YIELD_FROM; was: $type => $content".PHP_EOL;
796
+ }
797
+ }
798
+
799
+ $tokens[($stackPtr + 1)] = null;
800
+ $tokens[($stackPtr + 2)] = null;
801
+ } else {
802
  $newToken = [];
803
+ $newToken['code'] = T_YIELD;
804
+ $newToken['type'] = 'T_YIELD';
805
+ $newToken['content'] = $token[1];
806
  $finalTokens[$newStackPtr] = $newToken;
807
 
808
  $newStackPtr++;
 
809
  continue;
810
+ }//end if
 
 
 
 
 
 
 
 
 
811
  }//end if
812
 
813
  /*
1016
  so go forward and change the token type before it is processed.
1017
  */
1018
 
1019
+ if ($tokenIsArray === true
1020
+ && $token[0] === T_FUNCTION
1021
  && $finalTokens[$lastNotEmptyToken]['code'] !== T_USE
1022
  ) {
1023
  for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
1032
  if ($x < $numTokens && is_array($tokens[$x]) === true) {
1033
  $tokens[$x][0] = T_STRING;
1034
  }
1035
+
1036
+ /*
1037
+ This is a special condition for T_ARRAY tokens used for
1038
+ function return types. We want to keep the parenthesis map clean,
1039
+ so let's tag these tokens as T_STRING.
1040
+ */
1041
+
1042
+ // Go looking for the colon to start the return type hint.
1043
+ // Start by finding the closing parenthesis of the function.
1044
+ $parenthesisStack = [];
1045
+ $parenthesisCloser = false;
1046
+ for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
1047
+ if (is_array($tokens[$x]) === false && $tokens[$x] === '(') {
1048
+ $parenthesisStack[] = $x;
1049
+ } else if (is_array($tokens[$x]) === false && $tokens[$x] === ')') {
1050
+ array_pop($parenthesisStack);
1051
+ if (empty($parenthesisStack) === true) {
1052
+ $parenthesisCloser = $x;
1053
+ break;
1054
+ }
1055
+ }
1056
+ }
1057
+
1058
+ if ($parenthesisCloser !== false) {
1059
+ for ($x = ($parenthesisCloser + 1); $x < $numTokens; $x++) {
1060
+ if (is_array($tokens[$x]) === false
1061
+ || isset(Util\Tokens::$emptyTokens[$tokens[$x][0]]) === false
1062
+ ) {
1063
+ // Non-empty content.
1064
+ if (is_array($tokens[$x]) === true && $tokens[$x][0] === T_USE) {
1065
+ // Found a use statements, so search ahead for the closing parenthesis.
1066
+ for ($x = ($x + 1); $x < $numTokens; $x++) {
1067
+ if (is_array($tokens[$x]) === false && $tokens[$x] === ')') {
1068
+ continue(2);
1069
+ }
1070
+ }
1071
+ }
1072
+
1073
+ break;
1074
+ }
1075
+ }
1076
+
1077
+ if (isset($tokens[$x]) === true
1078
+ && is_array($tokens[$x]) === false
1079
+ && $tokens[$x] === ':'
1080
+ ) {
1081
+ $allowed = [
1082
+ T_STRING => T_STRING,
1083
+ T_ARRAY => T_ARRAY,
1084
+ T_CALLABLE => T_CALLABLE,
1085
+ T_SELF => T_SELF,
1086
+ T_PARENT => T_PARENT,
1087
+ T_NS_SEPARATOR => T_NS_SEPARATOR,
1088
+ ];
1089
+
1090
+ $allowed += Util\Tokens::$emptyTokens;
1091
+
1092
+ // Find the start of the return type.
1093
+ for ($x = ($x + 1); $x < $numTokens; $x++) {
1094
+ if (is_array($tokens[$x]) === true
1095
+ && isset(Util\Tokens::$emptyTokens[$tokens[$x][0]]) === true
1096
+ ) {
1097
+ // Whitespace or coments before the return type.
1098
+ continue;
1099
+ }
1100
+
1101
+ if (is_array($tokens[$x]) === false && $tokens[$x] === '?') {
1102
+ // Found a nullable operator, so skip it.
1103
+ // But also covert the token to save the tokenizer
1104
+ // a bit of time later on.
1105
+ $tokens[$x] = [
1106
+ T_NULLABLE,
1107
+ '?',
1108
+ ];
1109
+
1110
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1111
+ echo "\t\t* token $x changed from ? to T_NULLABLE".PHP_EOL;
1112
+ }
1113
+
1114
+ continue;
1115
+ }
1116
+
1117
+ break;
1118
+ }//end for
1119
+
1120
+ // Any T_ARRAY tokens we find between here and the next
1121
+ // token that can't be part of the return type need to be
1122
+ // converted to T_STRING tokens.
1123
+ for ($x; $x < $numTokens; $x++) {
1124
+ if (is_array($tokens[$x]) === false || isset($allowed[$tokens[$x][0]]) === false) {
1125
+ break;
1126
+ } else if ($tokens[$x][0] === T_ARRAY) {
1127
+ $tokens[$x][0] = T_STRING;
1128
+
1129
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1130
+ echo "\t\t* token $x changed from T_ARRAY to T_STRING".PHP_EOL;
1131
+ }
1132
+ }
1133
+ }
1134
+ }//end if
1135
+ }//end if
1136
+ }//end if
1137
 
1138
  /*
1139
  Before PHP 7, the <=> operator was tokenized as
1204
  }
1205
  }//end if
1206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1207
  /*
1208
  If this token has newlines in its content, split each line up
1209
  and create a new token for each line. We do this so it's easier
1215
  $tokenLines = explode($this->eolChar, $token[1]);
1216
  $numLines = count($tokenLines);
1217
  $newToken = [
1218
+ 'type' => Util\Tokens::tokenName($token[0]),
1219
  'code' => $token[0],
1220
  'content' => '',
1221
  ];
1313
  }
1314
 
1315
  if ($tokens[$i] === ')') {
1316
+ $parenCount = 1;
1317
  for ($i--; $i > 0; $i--) {
1318
  if ($tokens[$i] === '(') {
1319
+ $parenCount--;
1320
+ if ($parenCount === 0) {
1321
+ break;
1322
+ }
1323
+ } else if ($tokens[$i] === ')') {
1324
+ $parenCount++;
1325
  }
1326
  }
1327
 
1352
  // This is a special condition for T_ARRAY tokens used for
1353
  // type hinting function arguments as being arrays. We want to keep
1354
  // the parenthesis map clean, so let's tag these tokens as
1355
+ // T_STRING.
1356
  if ($newToken['code'] === T_ARRAY) {
1357
  for ($i = $stackPtr; $i < $numTokens; $i++) {
1358
  if ($tokens[$i] === '(') {
1359
  break;
1360
  } else if ($tokens[$i][0] === T_VARIABLE) {
1361
+ $newToken['code'] = T_STRING;
1362
+ $newToken['type'] = 'T_STRING';
1363
  break;
1364
  }
1365
  }
1378
  // where "class" should be T_STRING instead of T_CLASS.
1379
  if (($newToken['code'] === T_CLASS
1380
  || $newToken['code'] === T_FUNCTION)
1381
+ && $finalTokens[$lastNotEmptyToken]['code'] === T_DOUBLE_COLON
1382
  ) {
1383
  $newToken['code'] = T_STRING;
1384
  $newToken['type'] = 'T_STRING';
1488
  }
1489
  }
1490
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1491
  }//end if
1492
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1493
  continue;
1494
  } else if ($this->tokens[$i]['code'] === T_CLASS && isset($this->tokens[$i]['scope_opener']) === true) {
1495
  /*
1546
  T_CONSTANT_ENCAPSED_STRING => T_CONSTANT_ENCAPSED_STRING,
1547
  ];
1548
 
1549
+ for ($x = ($i - 1); $x >= 0; $x--) {
1550
  // If we hit a scope opener, the statement has ended
1551
  // without finding anything, so it's probably an array
1552
  // using PHP 7.1 short list syntax.
1598
  }
1599
 
1600
  continue;
 
 
 
 
 
 
 
 
 
1601
  } else if ($this->tokens[$i]['code'] === T_TRUE
1602
  || $this->tokens[$i]['code'] === T_FALSE
1603
  || $this->tokens[$i]['code'] === T_NULL
1860
  } else {
1861
  $newToken = [
1862
  'code' => $token[0],
1863
+ 'type' => Util\Tokens::tokenName($token[0]),
1864
  ];
1865
 
1866
  self::$resolveTokenCache[$token[0]] = $newToken;
vendor/squizlabs/php_codesniffer/src/Tokenizers/Tokenizer.php CHANGED
@@ -160,6 +160,8 @@ abstract class Tokenizer
160
  }
161
 
162
  $checkAnnotations = $this->config->annotations;
 
 
163
 
164
  $this->tokensWithTabs = [
165
  T_WHITESPACE => true,
@@ -183,7 +185,7 @@ abstract class Tokenizer
183
  // There are no tabs in the tokens we know the length of.
184
  $length = $this->knownLengths[$this->tokens[$i]['code']];
185
  $currColumn += $length;
186
- } else if ($this->config->tabWidth === 0
187
  || isset($this->tokensWithTabs[$this->tokens[$i]['code']]) === false
188
  || strpos($this->tokens[$i]['content'], "\t") === false
189
  ) {
@@ -192,7 +194,7 @@ abstract class Tokenizer
192
  // Not using the default encoding, so take a bit more care.
193
  $oldLevel = error_reporting();
194
  error_reporting(0);
195
- $length = iconv_strlen($this->tokens[$i]['content'], $this->config->encoding);
196
  error_reporting($oldLevel);
197
 
198
  if ($length === false) {
@@ -222,11 +224,10 @@ abstract class Tokenizer
222
  $this->tokens[$i]['length'] -= $eolLen;
223
  }
224
 
225
- if ($checkAnnotations === true
226
- && ($this->tokens[$i]['code'] === T_COMMENT
227
  || $this->tokens[$i]['code'] === T_DOC_COMMENT_STRING
228
  || $this->tokens[$i]['code'] === T_DOC_COMMENT_TAG
229
- || ($inTests === true && $this->tokens[$i]['code'] === T_INLINE_HTML))
230
  ) {
231
  $commentText = ltrim($this->tokens[$i]['content'], " \t/*");
232
  $commentText = rtrim($commentText, " */\t\r\n");
@@ -253,7 +254,7 @@ abstract class Tokenizer
253
  if ($ignoring === null
254
  && strpos($commentText, '@codingStandardsIgnoreStart') !== false
255
  ) {
256
- $ignoring = ['all' => true];
257
  if ($ownLine === true) {
258
  $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring;
259
  }
@@ -261,7 +262,7 @@ abstract class Tokenizer
261
  && strpos($commentText, '@codingStandardsIgnoreEnd') !== false
262
  ) {
263
  if ($ownLine === true) {
264
- $this->ignoredLines[$this->tokens[$i]['line']] = ['all' => true];
265
  } else {
266
  $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring;
267
  }
@@ -270,7 +271,7 @@ abstract class Tokenizer
270
  } else if ($ignoring === null
271
  && strpos($commentText, '@codingStandardsIgnoreLine') !== false
272
  ) {
273
- $ignoring = ['all' => true];
274
  if ($ownLine === true) {
275
  $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring;
276
  $this->ignoredLines[($this->tokens[$i]['line'] + 1)] = $ignoring;
@@ -284,7 +285,7 @@ abstract class Tokenizer
284
  || substr($commentTextLower, 0, 7) === '@phpcs:'
285
  ) {
286
  // If the @phpcs: syntax is being used, strip the @ to make
287
- // comparisions easier.
288
  if ($commentText[0] === '@') {
289
  $commentText = substr($commentText, 1);
290
  $commentTextLower = strtolower($commentText);
@@ -300,29 +301,72 @@ abstract class Tokenizer
300
  // If this comment is the only thing on the line, it tells us
301
  // to ignore the following line. If the line contains other content
302
  // then we are just ignoring this one single line.
303
- $ownLine = false;
 
304
  if ($i > 0) {
305
  for ($prev = ($i - 1); $prev > 0; $prev--) {
 
 
 
 
 
306
  if ($this->tokens[$prev]['code'] === T_WHITESPACE
307
- || $this->tokens[$prev]['code'] === T_OPEN_TAG
308
  || ($this->tokens[$prev]['code'] === T_INLINE_HTML
309
  && trim($this->tokens[$prev]['content']) === '')
310
  ) {
311
  continue;
312
  }
313
 
 
 
 
 
 
 
 
314
  break;
315
- }
316
 
317
- if ($this->tokens[$prev]['line'] !== $this->tokens[$i]['line']) {
318
- $ownLine = true;
319
- }
320
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
 
322
  if (substr($commentTextLower, 0, 9) === 'phpcs:set') {
323
  // Ignore standards for complete lines that change sniff settings.
324
- if ($ownLine === true) {
325
- $this->ignoredLines[$this->tokens[$i]['line']] = true;
326
  }
327
 
328
  $this->tokens[$i]['code'] = T_PHPCS_SET;
@@ -332,9 +376,9 @@ abstract class Tokenizer
332
  $this->tokens[$i]['code'] = T_PHPCS_IGNORE_FILE;
333
  $this->tokens[$i]['type'] = 'T_PHPCS_IGNORE_FILE';
334
  } else if (substr($commentTextLower, 0, 13) === 'phpcs:disable') {
335
- if ($ownLine === true) {
336
  // Completely ignore the comment line.
337
- $this->ignoredLines[$this->tokens[$i]['line']] = ['all' => true];
338
  }
339
 
340
  if ($ignoring === null) {
@@ -345,15 +389,31 @@ abstract class Tokenizer
345
 
346
  $additionalText = substr($commentText, 14);
347
  if ($additionalText === false) {
348
- $ignoring = ['all' => true];
349
  } else {
350
  $parts = explode(',', substr($commentText, 13));
351
  foreach ($parts as $sniffCode) {
352
  $sniffCode = trim($sniffCode);
353
  $disabledSniffs[$sniffCode] = true;
354
  $ignoring[$sniffCode] = true;
355
- }
356
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
357
 
358
  $this->tokens[$i]['code'] = T_PHPCS_DISABLE;
359
  $this->tokens[$i]['type'] = 'T_PHPCS_DISABLE';
@@ -370,19 +430,45 @@ abstract class Tokenizer
370
  foreach ($parts as $sniffCode) {
371
  $sniffCode = trim($sniffCode);
372
  $enabledSniffs[$sniffCode] = true;
373
- if (isset($ignoring[$sniffCode]) === true) {
374
- unset($ignoring[$sniffCode]);
 
 
 
 
 
 
 
375
  }
376
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
377
 
378
  if (empty($ignoring) === true) {
379
  $ignoring = null;
 
 
 
 
 
 
380
  }
381
- }
382
 
383
- if ($ownLine === true) {
384
  // Completely ignore the comment line.
385
- $this->ignoredLines[$this->tokens[$i]['line']] = ['all' => true];
386
  } else {
387
  // The comment is on the same line as the code it is ignoring,
388
  // so respect the new ignore rules.
@@ -399,7 +485,7 @@ abstract class Tokenizer
399
 
400
  $additionalText = substr($commentText, 13);
401
  if ($additionalText === false) {
402
- $ignoreRules = ['all' => true];
403
  } else {
404
  $parts = explode(',', substr($commentText, 13));
405
  foreach ($parts as $sniffCode) {
@@ -415,10 +501,10 @@ abstract class Tokenizer
415
  $ignoreRules += $ignoring;
416
  }
417
 
418
- if ($ownLine === true) {
419
  // Completely ignore the comment line, and set the folllowing
420
  // line to include the ignore rules we've set.
421
- $this->ignoredLines[$this->tokens[$i]['line']] = ['all' => true];
422
  $this->ignoredLines[($this->tokens[$i]['line'] + 1)] = $ignoreRules;
423
  } else {
424
  // The comment is on the same line as the code it is ignoring,
@@ -434,6 +520,12 @@ abstract class Tokenizer
434
  }
435
  }//end for
436
 
 
 
 
 
 
 
437
  }//end createPositionMap()
438
 
439
 
@@ -467,7 +559,7 @@ abstract class Tokenizer
467
  }
468
  }
469
 
470
- if (str_replace("\t", '', $token['content']) === '') {
471
  // String only contains tabs, so we can shortcut the process.
472
  $numTabs = strlen($token['content']);
473
 
@@ -651,7 +743,7 @@ abstract class Tokenizer
651
  }
652
  break;
653
  default:
654
- continue;
655
  }//end switch
656
  }//end for
657
 
@@ -1117,6 +1209,7 @@ abstract class Tokenizer
1117
  // a new statement, it isn't a scope opener.
1118
  $disallowed = Util\Tokens::$assignmentTokens;
1119
  $disallowed += [
 
1120
  T_VARIABLE => true,
1121
  T_OBJECT_OPERATOR => true,
1122
  T_COMMA => true,
160
  }
161
 
162
  $checkAnnotations = $this->config->annotations;
163
+ $encoding = $this->config->encoding;
164
+ $tabWidth = $this->config->tabWidth;
165
 
166
  $this->tokensWithTabs = [
167
  T_WHITESPACE => true,
185
  // There are no tabs in the tokens we know the length of.
186
  $length = $this->knownLengths[$this->tokens[$i]['code']];
187
  $currColumn += $length;
188
+ } else if ($tabWidth === 0
189
  || isset($this->tokensWithTabs[$this->tokens[$i]['code']]) === false
190
  || strpos($this->tokens[$i]['content'], "\t") === false
191
  ) {
194
  // Not using the default encoding, so take a bit more care.
195
  $oldLevel = error_reporting();
196
  error_reporting(0);
197
+ $length = iconv_strlen($this->tokens[$i]['content'], $encoding);
198
  error_reporting($oldLevel);
199
 
200
  if ($length === false) {
224
  $this->tokens[$i]['length'] -= $eolLen;
225
  }
226
 
227
+ if ($this->tokens[$i]['code'] === T_COMMENT
 
228
  || $this->tokens[$i]['code'] === T_DOC_COMMENT_STRING
229
  || $this->tokens[$i]['code'] === T_DOC_COMMENT_TAG
230
+ || ($inTests === true && $this->tokens[$i]['code'] === T_INLINE_HTML)
231
  ) {
232
  $commentText = ltrim($this->tokens[$i]['content'], " \t/*");
233
  $commentText = rtrim($commentText, " */\t\r\n");
254
  if ($ignoring === null
255
  && strpos($commentText, '@codingStandardsIgnoreStart') !== false
256
  ) {
257
+ $ignoring = ['.all' => true];
258
  if ($ownLine === true) {
259
  $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring;
260
  }
262
  && strpos($commentText, '@codingStandardsIgnoreEnd') !== false
263
  ) {
264
  if ($ownLine === true) {
265
+ $this->ignoredLines[$this->tokens[$i]['line']] = ['.all' => true];
266
  } else {
267
  $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring;
268
  }
271
  } else if ($ignoring === null
272
  && strpos($commentText, '@codingStandardsIgnoreLine') !== false
273
  ) {
274
+ $ignoring = ['.all' => true];
275
  if ($ownLine === true) {
276
  $this->ignoredLines[$this->tokens[$i]['line']] = $ignoring;
277
  $this->ignoredLines[($this->tokens[$i]['line'] + 1)] = $ignoring;
285
  || substr($commentTextLower, 0, 7) === '@phpcs:'
286
  ) {
287
  // If the @phpcs: syntax is being used, strip the @ to make
288
+ // comparisons easier.
289
  if ($commentText[0] === '@') {
290
  $commentText = substr($commentText, 1);
291
  $commentTextLower = strtolower($commentText);
301
  // If this comment is the only thing on the line, it tells us
302
  // to ignore the following line. If the line contains other content
303
  // then we are just ignoring this one single line.
304
+ $lineHasOtherContent = false;
305
+ $lineHasOtherTokens = false;
306
  if ($i > 0) {
307
  for ($prev = ($i - 1); $prev > 0; $prev--) {
308
+ if ($this->tokens[$prev]['line'] !== $this->tokens[$i]['line']) {
309
+ // Changed lines.
310
+ break;
311
+ }
312
+
313
  if ($this->tokens[$prev]['code'] === T_WHITESPACE
 
314
  || ($this->tokens[$prev]['code'] === T_INLINE_HTML
315
  && trim($this->tokens[$prev]['content']) === '')
316
  ) {
317
  continue;
318
  }
319
 
320
+ $lineHasOtherTokens = true;
321
+
322
+ if ($this->tokens[$prev]['code'] === T_OPEN_TAG) {
323
+ continue;
324
+ }
325
+
326
+ $lineHasOtherContent = true;
327
  break;
328
+ }//end for
329
 
330
+ $changedLines = false;
331
+ for ($next = $i; $next < $this->numTokens; $next++) {
332
+ if ($changedLines === true) {
333
+ // Changed lines.
334
+ break;
335
+ }
336
+
337
+ if (isset($this->knownLengths[$this->tokens[$next]['code']]) === false
338
+ && strpos($this->tokens[$next]['content'], $this->eolChar) !== false
339
+ ) {
340
+ // Last token on the current line.
341
+ $changedLines = true;
342
+ }
343
+
344
+ if ($next === $i) {
345
+ continue;
346
+ }
347
+
348
+ if ($this->tokens[$next]['code'] === T_WHITESPACE
349
+ || ($this->tokens[$next]['code'] === T_INLINE_HTML
350
+ && trim($this->tokens[$next]['content']) === '')
351
+ ) {
352
+ continue;
353
+ }
354
+
355
+ $lineHasOtherTokens = true;
356
+
357
+ if ($this->tokens[$next]['code'] === T_CLOSE_TAG) {
358
+ continue;
359
+ }
360
+
361
+ $lineHasOtherContent = true;
362
+ break;
363
+ }//end for
364
+ }//end if
365
 
366
  if (substr($commentTextLower, 0, 9) === 'phpcs:set') {
367
  // Ignore standards for complete lines that change sniff settings.
368
+ if ($lineHasOtherTokens === false) {
369
+ $this->ignoredLines[$this->tokens[$i]['line']] = ['.all' => true];
370
  }
371
 
372
  $this->tokens[$i]['code'] = T_PHPCS_SET;
376
  $this->tokens[$i]['code'] = T_PHPCS_IGNORE_FILE;
377
  $this->tokens[$i]['type'] = 'T_PHPCS_IGNORE_FILE';
378
  } else if (substr($commentTextLower, 0, 13) === 'phpcs:disable') {
379
+ if ($lineHasOtherContent === false) {
380
  // Completely ignore the comment line.
381
+ $this->ignoredLines[$this->tokens[$i]['line']] = ['.all' => true];
382
  }
383
 
384
  if ($ignoring === null) {
389
 
390
  $additionalText = substr($commentText, 14);
391
  if ($additionalText === false) {
392
+ $ignoring = ['.all' => true];
393
  } else {
394
  $parts = explode(',', substr($commentText, 13));
395
  foreach ($parts as $sniffCode) {
396
  $sniffCode = trim($sniffCode);
397
  $disabledSniffs[$sniffCode] = true;
398
  $ignoring[$sniffCode] = true;
399
+
400
+ // This newly disabled sniff might be disabling an existing
401
+ // enabled exception that we are tracking.
402
+ if (isset($ignoring['.except']) === true) {
403
+ foreach (array_keys($ignoring['.except']) as $ignoredSniffCode) {
404
+ if ($ignoredSniffCode === $sniffCode
405
+ || strpos($ignoredSniffCode, $sniffCode.'.') === 0
406
+ ) {
407
+ unset($ignoring['.except'][$ignoredSniffCode]);
408
+ }
409
+ }
410
+
411
+ if (empty($ignoring['.except']) === true) {
412
+ unset($ignoring['.except']);
413
+ }
414
+ }
415
+ }//end foreach
416
+ }//end if
417
 
418
  $this->tokens[$i]['code'] = T_PHPCS_DISABLE;
419
  $this->tokens[$i]['type'] = 'T_PHPCS_DISABLE';
430
  foreach ($parts as $sniffCode) {
431
  $sniffCode = trim($sniffCode);
432
  $enabledSniffs[$sniffCode] = true;
433
+
434
+ // This new enabled sniff might remove previously disabled
435
+ // sniffs if it is actually a standard or category of sniffs.
436
+ foreach (array_keys($ignoring) as $ignoredSniffCode) {
437
+ if ($ignoredSniffCode === $sniffCode
438
+ || strpos($ignoredSniffCode, $sniffCode.'.') === 0
439
+ ) {
440
+ unset($ignoring[$ignoredSniffCode]);
441
+ }
442
  }
443
+
444
+ // This new enabled sniff might be able to clear up
445
+ // previously enabled sniffs if it is actually a standard or
446
+ // category of sniffs.
447
+ if (isset($ignoring['.except']) === true) {
448
+ foreach (array_keys($ignoring['.except']) as $ignoredSniffCode) {
449
+ if ($ignoredSniffCode === $sniffCode
450
+ || strpos($ignoredSniffCode, $sniffCode.'.') === 0
451
+ ) {
452
+ unset($ignoring['.except'][$ignoredSniffCode]);
453
+ }
454
+ }
455
+ }
456
+ }//end foreach
457
 
458
  if (empty($ignoring) === true) {
459
  $ignoring = null;
460
+ } else {
461
+ if (isset($ignoring['.except']) === true) {
462
+ $ignoring['.except'] += $enabledSniffs;
463
+ } else {
464
+ $ignoring['.except'] = $enabledSniffs;
465
+ }
466
  }
467
+ }//end if
468
 
469
+ if ($lineHasOtherContent === false) {
470
  // Completely ignore the comment line.
471
+ $this->ignoredLines[$this->tokens[$i]['line']] = ['.all' => true];
472
  } else {
473
  // The comment is on the same line as the code it is ignoring,
474
  // so respect the new ignore rules.
485
 
486
  $additionalText = substr($commentText, 13);
487
  if ($additionalText === false) {
488
+ $ignoreRules = ['.all' => true];
489
  } else {
490
  $parts = explode(',', substr($commentText, 13));
491
  foreach ($parts as $sniffCode) {
501
  $ignoreRules += $ignoring;
502
  }
503
 
504
+ if ($lineHasOtherContent === false) {
505
  // Completely ignore the comment line, and set the folllowing
506
  // line to include the ignore rules we've set.
507
+ $this->ignoredLines[$this->tokens[$i]['line']] = ['.all' => true];
508
  $this->ignoredLines[($this->tokens[$i]['line'] + 1)] = $ignoreRules;
509
  } else {
510
  // The comment is on the same line as the code it is ignoring,
520
  }
521
  }//end for
522
 
523
+ // If annotations are being ignored, we clear out all the ignore rules
524
+ // but leave the annotations tokenized as normal.
525
+ if ($checkAnnotations === false) {
526
+ $this->ignoredLines = [];
527
+ }
528
+
529
  }//end createPositionMap()
530
 
531
 
559
  }
560
  }
561
 
562
+ if (rtrim($token['content'], "\t") === '') {
563
  // String only contains tabs, so we can shortcut the process.
564
  $numTabs = strlen($token['content']);
565
 
743
  }
744
  break;
745
  default:
746
+ continue 2;
747
  }//end switch
748
  }//end for
749
 
1209
  // a new statement, it isn't a scope opener.
1210
  $disallowed = Util\Tokens::$assignmentTokens;
1211
  $disallowed += [
1212
+ T_DOLLAR => true,
1213
  T_VARIABLE => true,
1214
  T_OBJECT_OPERATOR => true,
1215
  T_COMMA => true,
vendor/squizlabs/php_codesniffer/src/Util/Cache.php CHANGED
@@ -12,7 +12,6 @@ namespace PHP_CodeSniffer\Util;
12
  use PHP_CodeSniffer\Autoload;
13
  use PHP_CodeSniffer\Config;
14
  use PHP_CodeSniffer\Ruleset;
15
- use PHP_CodeSniffer\Util\Common;
16
 
17
  class Cache
18
  {
@@ -124,8 +123,7 @@ class Cache
124
  }
125
  );
126
 
127
- $iterator = new \RecursiveIteratorIterator($filter);
128
- $coreFiles = [];
129
  foreach ($iterator as $file) {
130
  if (PHP_CODESNIFFER_VERBOSITY > 1) {
131
  echo "\t\t=> core file: $file".PHP_EOL;
@@ -152,16 +150,26 @@ class Cache
152
  'encoding' => $config->encoding,
153
  'recordErrors' => $config->recordErrors,
154
  'annotations' => $config->annotations,
 
155
  'codeHash' => $codeHash,
156
  'rulesetHash' => $rulesetHash,
157
  ];
158
 
159
- $configString = implode(',', $configData);
160
  $cacheHash = substr(sha1($configString), 0, 12);
161
 
162
  if (PHP_CODESNIFFER_VERBOSITY > 1) {
163
  echo "\tGenerating cache key data".PHP_EOL;
164
  foreach ($configData as $key => $value) {
 
 
 
 
 
 
 
 
 
165
  if ($value === true || $value === false) {
166
  $value = (int) $value;
167
  }
@@ -170,7 +178,7 @@ class Cache
170
  }
171
 
172
  echo "\t\t=> cacheHash: $cacheHash".PHP_EOL;
173
- }
174
 
175
  if ($config->cacheFile !== null) {
176
  $cacheFile = $config->cacheFile;
12
  use PHP_CodeSniffer\Autoload;
13
  use PHP_CodeSniffer\Config;
14
  use PHP_CodeSniffer\Ruleset;
 
15
 
16
  class Cache
17
  {
123
  }
124
  );
125
 
126
+ $iterator = new \RecursiveIteratorIterator($filter);
 
127
  foreach ($iterator as $file) {
128
  if (PHP_CODESNIFFER_VERBOSITY > 1) {
129
  echo "\t\t=> core file: $file".PHP_EOL;
150
  'encoding' => $config->encoding,
151
  'recordErrors' => $config->recordErrors,
152
  'annotations' => $config->annotations,
153
+ 'configData' => Config::getAllConfigData(),
154
  'codeHash' => $codeHash,
155
  'rulesetHash' => $rulesetHash,
156
  ];
157
 
158
+ $configString = var_export($configData, true);
159
  $cacheHash = substr(sha1($configString), 0, 12);
160
 
161
  if (PHP_CODESNIFFER_VERBOSITY > 1) {
162
  echo "\tGenerating cache key data".PHP_EOL;
163
  foreach ($configData as $key => $value) {
164
+ if (is_array($value) === true) {
165
+ echo "\t\t=> $key:".PHP_EOL;
166
+ foreach ($value as $subKey => $subValue) {
167
+ echo "\t\t\t=> $subKey: $subValue".PHP_EOL;
168
+ }
169
+
170
+ continue;
171
+ }
172
+
173
  if ($value === true || $value === false) {
174
  $value = (int) $value;
175
  }
178
  }
179
 
180
  echo "\t\t=> cacheHash: $cacheHash".PHP_EOL;
181
+ }//end if
182
 
183
  if ($config->cacheFile !== null) {
184
  $cacheFile = $config->cacheFile;
vendor/squizlabs/php_codesniffer/src/Util/Common.php CHANGED
@@ -9,9 +9,6 @@
9
 
10
  namespace PHP_CodeSniffer\Util;
11
 
12
- use PHP_CodeSniffer\Config;
13
- use PHP_CodeSniffer\Exceptions\RuntimeException;
14
-
15
  class Common
16
  {
17
 
9
 
10
  namespace PHP_CodeSniffer\Util;
11
 
 
 
 
12
  class Common
13
  {
14
 
vendor/squizlabs/php_codesniffer/src/Util/Standards.php CHANGED
@@ -90,6 +90,10 @@ class Standards
90
  continue;
91
  }
92
 
 
 
 
 
93
  $di = new \DirectoryIterator($standardsDir);
94
  foreach ($di as $file) {
95
  if ($file->isDir() === true && $file->isDot() === false) {
90
  continue;
91
  }
92
 
93
+ if (is_dir($standardsDir) === false) {
94
+ continue;
95
+ }
96
+
97
  $di = new \DirectoryIterator($standardsDir);
98
  foreach ($di as $file) {
99
  if ($file->isDir() === true && $file->isDot() === false) {
vendor/squizlabs/php_codesniffer/src/Util/Tokens.php CHANGED
@@ -282,6 +282,40 @@ final class Tokens
282
  T_POW => T_POW,
283
  ];
284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  /**
286
  * Tokens that represent casting.
287
  *
@@ -374,40 +408,6 @@ final class Tokens
374
  T_FINAL => T_FINAL,
375
  ];
376
 
377
- /**
378
- * Tokens that perform operations.
379
- *
380
- * @var array<int, int>
381
- */
382
- public static $operators = [
383
- T_MINUS => T_MINUS,
384
- T_PLUS => T_PLUS,
385
- T_MULTIPLY => T_MULTIPLY,
386
- T_DIVIDE => T_DIVIDE,
387
- T_MODULUS => T_MODULUS,
388
- T_POW => T_POW,
389
- T_SPACESHIP => T_SPACESHIP,
390
- T_COALESCE => T_COALESCE,
391
- T_BITWISE_AND => T_BITWISE_AND,
392
- T_BITWISE_OR => T_BITWISE_OR,
393
- T_BITWISE_XOR => T_BITWISE_XOR,
394
- T_SL => T_SL,
395
- T_SR => T_SR,
396
- ];
397
-
398
- /**
399
- * Tokens that perform boolean operations.
400
- *
401
- * @var array<int, int>
402
- */
403
- public static $booleanOperators = [
404
- T_BOOLEAN_AND => T_BOOLEAN_AND,
405
- T_BOOLEAN_OR => T_BOOLEAN_OR,
406
- T_LOGICAL_AND => T_LOGICAL_AND,
407
- T_LOGICAL_OR => T_LOGICAL_OR,
408
- T_LOGICAL_XOR => T_LOGICAL_XOR,
409
- ];
410
-
411
  /**
412
  * Tokens that open code blocks.
413
  *
@@ -469,11 +469,11 @@ final class Tokens
469
  * @var array<int, int>
470
  */
471
  public static $phpcsCommentTokens = [
472
- T_PHPCS_ENABLE => T_PHPCS_ENABLE,
473
- T_PHPCS_DISABLE => T_PHPCS_DISABLE,
474
- T_PHPCS_SET => T_PHPCS_SET,
475
- T_PHPCS_IGNORE => T_PHPCS_IGNORE,
476
- T_PHPCS_IGNORE_FILE => T_PHPCS_IGNORE_FILE,
477
  ];
478
 
479
  /**
282
  T_POW => T_POW,
283
  ];
284
 
285
+ /**
286
+ * Tokens that perform operations.
287
+ *
288
+ * @var array<int, int>
289
+ */
290
+ public static $operators = [
291
+ T_MINUS => T_MINUS,
292
+ T_PLUS => T_PLUS,
293
+ T_MULTIPLY => T_MULTIPLY,
294
+ T_DIVIDE => T_DIVIDE,
295
+ T_MODULUS => T_MODULUS,
296
+ T_POW => T_POW,
297
+ T_SPACESHIP => T_SPACESHIP,
298
+ T_COALESCE => T_COALESCE,
299
+ T_BITWISE_AND => T_BITWISE_AND,
300
+ T_BITWISE_OR => T_BITWISE_OR,
301
+ T_BITWISE_XOR => T_BITWISE_XOR,
302
+ T_SL => T_SL,
303
+ T_SR => T_SR,
304
+ ];
305
+
306
+ /**
307
+ * Tokens that perform boolean operations.
308
+ *
309
+ * @var array<int, int>
310
+ */
311
+ public static $booleanOperators = [
312
+ T_BOOLEAN_AND => T_BOOLEAN_AND,
313
+ T_BOOLEAN_OR => T_BOOLEAN_OR,
314
+ T_LOGICAL_AND => T_LOGICAL_AND,
315
+ T_LOGICAL_OR => T_LOGICAL_OR,
316
+ T_LOGICAL_XOR => T_LOGICAL_XOR,
317
+ ];
318
+
319
  /**
320
  * Tokens that represent casting.
321
  *
408
  T_FINAL => T_FINAL,
409
  ];
410
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
411
  /**
412
  * Tokens that open code blocks.
413
  *
469
  * @var array<int, int>
470
  */
471
  public static $phpcsCommentTokens = [
472
+ T_PHPCS_ENABLE => T_PHPCS_ENABLE,
473
+ T_PHPCS_DISABLE => T_PHPCS_DISABLE,
474
+ T_PHPCS_SET => T_PHPCS_SET,
475
+ T_PHPCS_IGNORE => T_PHPCS_IGNORE,
476
+ T_PHPCS_IGNORE_FILE => T_PHPCS_IGNORE_FILE,
477
  ];
478
 
479
  /**
vendor/squizlabs/php_codesniffer/tests/AllTests.php CHANGED
@@ -9,7 +9,6 @@
9
 
10
  namespace PHP_CodeSniffer\Tests;
11
 
12
- use PHP_CodeSniffer\Tests\TestSuite;
13
  use PHPUnit\TextUI\TestRunner;
14
 
15
  if (is_file(__DIR__.'/../autoload.php') === true) {
9
 
10
  namespace PHP_CodeSniffer\Tests;
11
 
 
12
  use PHPUnit\TextUI\TestRunner;
13
 
14
  if (is_file(__DIR__.'/../autoload.php') === true) {
vendor/squizlabs/php_codesniffer/tests/Core/AllTests.php CHANGED
@@ -14,9 +14,12 @@ use PHPUnit\Framework\TestSuite;
14
 
15
  require_once 'IsCamelCapsTest.php';
16
  require_once 'ErrorSuppressionTest.php';
17
- require_once 'File/GetMethodParametersTest.php';
18
  require_once 'File/FindExtendedClassNameTest.php';
19
  require_once 'File/FindImplementedInterfaceNamesTest.php';
 
 
 
20
  require_once 'File/IsReferenceTest.php';
21
 
22
  class AllTests
@@ -45,9 +48,12 @@ class AllTests
45
  $suite = new TestSuite('PHP CodeSniffer Core');
46
  $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\IsCamelCapsTest');
47
  $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\ErrorSuppressionTest');
48
- $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\GetMethodParametersTest');
49
  $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\FindExtendedClassNameTest');
50
  $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\FindImplementedInterfaceNamesTest');
 
 
 
51
  $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\IsReferenceTest');
52
  return $suite;
53
 
14
 
15
  require_once 'IsCamelCapsTest.php';
16
  require_once 'ErrorSuppressionTest.php';
17
+ require_once 'File/FindEndOfStatementTest.php';
18
  require_once 'File/FindExtendedClassNameTest.php';
19
  require_once 'File/FindImplementedInterfaceNamesTest.php';
20
+ require_once 'File/GetMemberPropertiesTest.php';
21
+ require_once 'File/GetMethodParametersTest.php';
22
+ require_once 'File/GetMethodPropertiesTest.php';
23
  require_once 'File/IsReferenceTest.php';
24
 
25
  class AllTests
48
  $suite = new TestSuite('PHP CodeSniffer Core');
49
  $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\IsCamelCapsTest');
50
  $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\ErrorSuppressionTest');
51
+ $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\FindEndOfStatementTest');
52
  $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\FindExtendedClassNameTest');
53
  $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\FindImplementedInterfaceNamesTest');
54
+ $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\GetMemberPropertiesTest');
55
+ $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\GetMethodParametersTest');
56
+ $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\GetMethodPropertiesTest');
57
  $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\IsReferenceTest');
58
  return $suite;
59
 
vendor/squizlabs/php_codesniffer/tests/Core/ErrorSuppressionTest.php CHANGED
@@ -970,6 +970,90 @@ class ErrorSuppressionTest extends TestCase
970
  $this->assertEquals(1, $numWarnings);
971
  $this->assertCount(1, $warnings);
972
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
973
  }//end testEnableSelected()
974
 
975
 
970
  $this->assertEquals(1, $numWarnings);
971
  $this->assertCount(1, $warnings);
972
 
973
+ // Suppress a whole standard and re-enable a category.
974
+ $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting'.PHP_EOL.'//TODO: write some code';
975
+ $file = new DummyFile($content, $ruleset, $config);
976
+ $file->process();
977
+
978
+ $errors = $file->getErrors();
979
+ $numErrors = $file->getErrorCount();
980
+ $warnings = $file->getWarnings();
981
+ $numWarnings = $file->getWarningCount();
982
+ $this->assertEquals(0, $numErrors);
983
+ $this->assertCount(0, $errors);
984
+ $this->assertEquals(1, $numWarnings);
985
+ $this->assertCount(1, $warnings);
986
+
987
+ // Suppress a category and re-enable a whole standard.
988
+ $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic'.PHP_EOL.'//TODO: write some code';
989
+ $file = new DummyFile($content, $ruleset, $config);
990
+ $file->process();
991
+
992
+ $errors = $file->getErrors();
993
+ $numErrors = $file->getErrorCount();
994
+ $warnings = $file->getWarnings();
995
+ $numWarnings = $file->getWarningCount();
996
+ $this->assertEquals(1, $numErrors);
997
+ $this->assertCount(1, $errors);
998
+ $this->assertEquals(1, $numWarnings);
999
+ $this->assertCount(1, $warnings);
1000
+
1001
+ // Suppress a sniff and re-enable a category.
1002
+ $content = '<?php '.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting'.PHP_EOL.'//TODO: write some code';
1003
+ $file = new DummyFile($content, $ruleset, $config);
1004
+ $file->process();
1005
+
1006
+ $errors = $file->getErrors();
1007
+ $numErrors = $file->getErrorCount();
1008
+ $warnings = $file->getWarnings();
1009
+ $numWarnings = $file->getWarningCount();
1010
+ $this->assertEquals(1, $numErrors);
1011
+ $this->assertCount(1, $errors);
1012
+ $this->assertEquals(1, $numWarnings);
1013
+ $this->assertCount(1, $warnings);
1014
+
1015
+ // Suppress a whole standard and re-enable a sniff.
1016
+ $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code';
1017
+ $file = new DummyFile($content, $ruleset, $config);
1018
+ $file->process();
1019
+
1020
+ $errors = $file->getErrors();
1021
+ $numErrors = $file->getErrorCount();
1022
+ $warnings = $file->getWarnings();
1023
+ $numWarnings = $file->getWarningCount();
1024
+ $this->assertEquals(0, $numErrors);
1025
+ $this->assertCount(0, $errors);
1026
+ $this->assertEquals(1, $numWarnings);
1027
+ $this->assertCount(1, $warnings);
1028
+
1029
+ // Suppress a whole standard and re-enable and re-disable a sniff.
1030
+ $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:disable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable'.PHP_EOL.'//TODO: write some code';
1031
+ $file = new DummyFile($content, $ruleset, $config);
1032
+ $file->process();
1033
+
1034
+ $errors = $file->getErrors();
1035
+ $numErrors = $file->getErrorCount();
1036
+ $warnings = $file->getWarnings();
1037
+ $numWarnings = $file->getWarningCount();
1038
+ $this->assertEquals(0, $numErrors);
1039
+ $this->assertCount(0, $errors);
1040
+ $this->assertEquals(2, $numWarnings);
1041
+ $this->assertCount(2, $warnings);
1042
+
1043
+ // Suppress a whole standard and re-enable 2 specific sniffs independently.
1044
+ $content = '<?php '.PHP_EOL.'// phpcs:disable Generic'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'// phpcs:enable Generic.Commenting.Todo'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'$var = FALSE;'.PHP_EOL.'// phpcs:enable Generic.PHP.LowerCaseConstant'.PHP_EOL.'//TODO: write some code'.PHP_EOL.'$var = FALSE;'.PHP_EOL;
1045
+ $file = new DummyFile($content, $ruleset, $config);
1046
+ $file->process();
1047
+
1048
+ $errors = $file->getErrors();
1049
+ $numErrors = $file->getErrorCount();
1050
+ $warnings = $file->getWarnings();
1051
+ $numWarnings = $file->getWarningCount();
1052
+ $this->assertEquals(1, $numErrors);
1053
+ $this->assertCount(1, $errors);
1054
+ $this->assertEquals(2, $numWarnings);
1055
+ $this->assertCount(2, $warnings);
1056
+
1057
  }//end testEnableSelected()
1058
 
1059
 
vendor/squizlabs/php_codesniffer/tests/Core/File/FindEndOfStatementTest.inc ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* phpcs:ignoreFile */
3
+
4
+ /* testSimpleAssignment */
5
+ $a = false;
6
+
7
+ /* testControlStructure */
8
+ while(true) {}
9
+ $a = 1;
10
+
11
+ /* testClosureAssignment */
12
+ $a = function($b=false;){};
13
+
14
+ /* testHeredocFunctionArg */
15
+ myFunction(<<<END
16
+ Foo
17
+ END
18
+ , 'bar');
19
+
20
+ /* testSwitch */
21
+ switch ($a) {
22
+ case 1: {break;}
23
+ default: {break;}
24
+ }
25
+
26
+ /* testStatementAsArrayValue */
27
+ $a = [new Datetime];
28
+ $a = array(new Datetime);
29
+ $a = new Datetime;
vendor/squizlabs/php_codesniffer/tests/Core/File/FindEndOfStatementTest.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Tests for the \PHP_CodeSniffer\Files\File:findEndOfStatement method.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Tests\Core\File;
11
+
12
+ use PHP_CodeSniffer\Config;
13
+ use PHP_CodeSniffer\Ruleset;
14
+ use PHP_CodeSniffer\Files\DummyFile;
15
+ use PHPUnit\Framework\TestCase;
16
+
17
+ class FindEndOfStatementTest extends TestCase
18
+ {
19
+
20
+ /**
21
+ * The PHP_CodeSniffer_File object containing parsed contents of the test case file.
22
+ *
23
+ * @var \PHP_CodeSniffer\Files\File
24
+ */
25
+ private $phpcsFile;
26
+
27
+
28
+ /**
29
+ * Initialize & tokenize \PHP_CodeSniffer\Files\File with code from the test case file.
30
+ *
31
+ * Methods used for these tests can be found in a test case file in the same
32
+ * directory and with the same name, using the .inc extension.
33
+ *
34
+ * @return void
35
+ */
36
+ public function setUp()
37
+ {
38
+ $config = new Config();
39
+ $config->standards = ['Generic'];
40
+
41
+ $ruleset = new Ruleset($config);
42
+
43
+ $pathToTestFile = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc';
44
+ $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config);
45
+ $this->phpcsFile->process();
46
+
47
+ }//end setUp()
48
+
49
+
50
+ /**
51
+ * Clean up after finished test.
52
+ *
53
+ * @return void
54
+ */
55
+ public function tearDown()
56
+ {
57
+ unset($this->phpcsFile);
58
+
59
+ }//end tearDown()
60
+
61
+
62
+ /**
63
+ * Test a simple assignment.
64
+ *
65
+ * @return void
66
+ */
67
+ public function testSimpleAssignment()
68
+ {
69
+ $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testSimpleAssignment */') + 2);
70
+ $found = $this->phpcsFile->findEndOfStatement($start);
71
+
72
+ $tokens = $this->phpcsFile->getTokens();
73
+ $this->assertSame($tokens[($start + 5)], $tokens[$found]);
74
+
75
+ }//end testSimpleAssignment()
76
+
77
+
78
+ /**
79
+ * Test a direct call to a control strucutre.
80
+ *
81
+ * @return void
82
+ */
83
+ public function testControlStructure()
84
+ {
85
+ $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testControlStructure */') + 2);
86
+ $found = $this->phpcsFile->findEndOfStatement($start);
87
+
88
+ $tokens = $this->phpcsFile->getTokens();
89
+ $this->assertSame($tokens[($start + 6)], $tokens[$found]);
90
+
91
+ }//end testControlStructure()
92
+
93
+
94
+ /**
95
+ * Test the assignment of a closure.
96
+ *
97
+ * @return void
98
+ */
99
+ public function testClosureAssignment()
100
+ {
101
+ $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testClosureAssignment */') + 2);
102
+ $found = $this->phpcsFile->findEndOfStatement($start);
103
+
104
+ $tokens = $this->phpcsFile->getTokens();
105
+ $this->assertSame($tokens[($start + 13)], $tokens[$found]);
106
+
107
+ }//end testClosureAssignment()
108
+
109
+
110
+ /**
111
+ * Test using a heredoc in a function argument.
112
+ *
113
+ * @return void
114
+ */
115
+ public function testHeredocFunctionArg()
116
+ {
117
+ // Find the end of the function.
118
+ $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testHeredocFunctionArg */') + 2);
119
+ $found = $this->phpcsFile->findEndOfStatement($start);
120
+
121
+ $tokens = $this->phpcsFile->getTokens();
122
+ $this->assertSame($tokens[($start + 10)], $tokens[$found]);
123
+
124
+ // Find the end of the heredoc.
125
+ $start += 2;
126
+ $found = $this->phpcsFile->findEndOfStatement($start);
127
+
128
+ $tokens = $this->phpcsFile->getTokens();
129
+ $this->assertSame($tokens[($start + 4)], $tokens[$found]);
130
+
131
+ // Find the end of the last arg.
132
+ $start = ($found + 2);
133
+ $found = $this->phpcsFile->findEndOfStatement($start);
134
+
135
+ $tokens = $this->phpcsFile->getTokens();
136
+ $this->assertSame($tokens[$start], $tokens[$found]);
137
+
138
+ }//end testHeredocFunctionArg()
139
+
140
+
141
+ /**
142
+ * Test parts of a switch statement.
143
+ *
144
+ * @return void
145
+ */
146
+ public function testSwitch()
147
+ {
148
+ // Find the end of the swtich.
149
+ $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testSwitch */') + 2);
150
+ $found = $this->phpcsFile->findEndOfStatement($start);
151
+
152
+ $tokens = $this->phpcsFile->getTokens();
153
+ $this->assertSame($tokens[($start + 28)], $tokens[$found]);
154
+
155
+ // Find the end of the case.
156
+ $start += 9;
157
+ $found = $this->phpcsFile->findEndOfStatement($start);
158
+
159
+ $tokens = $this->phpcsFile->getTokens();
160
+ $this->assertSame($tokens[($start + 8)], $tokens[$found]);
161
+
162
+ // Find the end of default case.
163
+ $start += 11;
164
+ $found = $this->phpcsFile->findEndOfStatement($start);
165
+
166
+ $tokens = $this->phpcsFile->getTokens();
167
+ $this->assertSame($tokens[($start + 6)], $tokens[$found]);
168
+
169
+ }//end testSwitch()
170
+
171
+
172
+ /**
173
+ * Test statements that are array values.
174
+ *
175
+ * @return void
176
+ */
177
+ public function testStatementAsArrayValue()
178
+ {
179
+ // Test short array syntax.
180
+ $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testStatementAsArrayValue */') + 7);
181
+ $found = $this->phpcsFile->findEndOfStatement($start);
182
+
183
+ $tokens = $this->phpcsFile->getTokens();
184
+ $this->assertSame($tokens[($start + 2)], $tokens[$found]);
185
+
186
+ // Test long array syntax.
187
+ $start += 12;
188
+ $found = $this->phpcsFile->findEndOfStatement($start);
189
+
190
+ $tokens = $this->phpcsFile->getTokens();
191
+ $this->assertSame($tokens[($start + 2)], $tokens[$found]);
192
+
193
+ // Test same statement outside of array.
194
+ $start += 10;
195
+ $found = $this->phpcsFile->findEndOfStatement($start);
196
+
197
+ $tokens = $this->phpcsFile->getTokens();
198
+ $this->assertSame($tokens[($start + 3)], $tokens[$found]);
199
+
200
+ }//end testStatementAsArrayValue()
201
+
202
+
203
+ }//end class
vendor/squizlabs/php_codesniffer/tests/Core/File/FindExtendedClassNameTest.inc CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /* @codingStandardsIgnoreFile */
3
 
4
  namespace PHP_CodeSniffer\Tests\Core\File;
5
 
@@ -22,3 +22,17 @@ interface testInterfaceThatExtendsInterface extends testFECNInterface{}
22
 
23
  /* testInterfaceThatExtendsFQCNInterface */
24
  interface testInterfaceThatExtendsFQCNInterface extends \PHP_CodeSniffer\Tests\Core\File\testFECNInterface{}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ /* phpcs:ignoreFile */
3
 
4
  namespace PHP_CodeSniffer\Tests\Core\File;
5
 
22
 
23
  /* testInterfaceThatExtendsFQCNInterface */
24
  interface testInterfaceThatExtendsFQCNInterface extends \PHP_CodeSniffer\Tests\Core\File\testFECNInterface{}
25
+
26
+ /* testNestedExtendedClass */
27
+ class testFECNNestedExtendedClass {
28
+ public function someMethod() {
29
+ /* testNestedExtendedAnonClass */
30
+ $anon = new class extends testFECNAnonClass {};
31
+ }
32
+ }
33
+
34
+ /* testClassThatExtendsAndImplements */
35
+ class testFECNClassThatExtendsAndImplements extends testFECNClass implements InterfaceA, InterfaceB {}
36
+
37
+ /* testClassThatImplementsAndExtends */
38
+ class testFECNClassThatImplementsAndExtends implements InterfaceA, InterfaceB extends testFECNClass {}
vendor/squizlabs/php_codesniffer/tests/Core/File/FindExtendedClassNameTest.php CHANGED
@@ -60,135 +60,87 @@ class FindExtendedClassNameTest extends TestCase
60
 
61
 
62
  /**
63
- * Test a class that extends another.
 
64
  *
65
- * @return void
66
- */
67
- public function testExtendedClass()
68
- {
69
- $start = ($this->phpcsFile->numTokens - 1);
70
- $class = $this->phpcsFile->findPrevious(
71
- T_COMMENT,
72
- $start,
73
- null,
74
- false,
75
- '/* testExtendedClass */'
76
- );
77
-
78
- $found = $this->phpcsFile->findExtendedClassName(($class + 2));
79
- $this->assertSame('testFECNClass', $found);
80
-
81
- }//end testExtendedClass()
82
-
83
-
84
- /**
85
- * Test a class that extends another, using namespaces.
86
  *
87
- * @return void
88
- */
89
- public function testNamespacedClass()
90
- {
91
- $start = ($this->phpcsFile->numTokens - 1);
92
- $class = $this->phpcsFile->findPrevious(
93
- T_COMMENT,
94
- $start,
95
- null,
96
- false,
97
- '/* testNamespacedClass */'
98
- );
99
-
100
- $found = $this->phpcsFile->findExtendedClassName(($class + 2));
101
- $this->assertSame('\PHP_CodeSniffer\Tests\Core\File\testFECNClass', $found);
102
-
103
- }//end testNamespacedClass()
104
-
105
-
106
- /**
107
- * Test a class that doesn't extend another.
108
  *
109
  * @return void
110
  */
111
- public function testNonExtendedClass()
112
  {
113
- $start = ($this->phpcsFile->numTokens - 1);
114
- $class = $this->phpcsFile->findPrevious(
115
  T_COMMENT,
116
  $start,
117
  null,
118
  false,
119
- '/* testNonExtendedClass */'
120
  );
 
121
 
122
- $found = $this->phpcsFile->findExtendedClassName(($class + 2));
123
- $this->assertFalse($found);
124
 
125
- }//end testNonExtendedClass()
126
 
127
 
128
  /**
129
- * Test an interface.
130
  *
131
- * @return void
132
- */
133
- public function testInterface()
134
- {
135
- $start = ($this->phpcsFile->numTokens - 1);
136
- $class = $this->phpcsFile->findPrevious(
137
- T_COMMENT,
138
- $start,
139
- null,
140
- false,
141
- '/* testInterface */'
142
- );
143
-
144
- $found = $this->phpcsFile->findExtendedClassName(($class + 2));
145
- $this->assertFalse($found);
146
-
147
- }//end testInterface()
148
-
149
-
150
- /**
151
- * Test an interface that extends another.
152
- *
153
- * @return void
154
- */
155
- public function testExtendedInterface()
156
- {
157
- $start = ($this->phpcsFile->numTokens - 1);
158
- $class = $this->phpcsFile->findPrevious(
159
- T_COMMENT,
160
- $start,
161
- null,
162
- false,
163
- '/* testInterfaceThatExtendsInterface */'
164
- );
165
-
166
- $found = $this->phpcsFile->findExtendedClassName(($class + 2));
167
- $this->assertSame('testFECNInterface', $found);
168
-
169
- }//end testExtendedInterface()
170
-
171
-
172
- /**
173
- * Test an interface that extends another, using namespaces.
174
  *
175
- * @return void
176
  */
177
- public function testExtendedNamespacedInterface()
178
  {
179
- $start = ($this->phpcsFile->numTokens - 1);
180
- $class = $this->phpcsFile->findPrevious(
181
- T_COMMENT,
182
- $start,
183
- null,
184
- false,
185
- '/* testInterfaceThatExtendsFQCNInterface */'
186
- );
187
-
188
- $found = $this->phpcsFile->findExtendedClassName(($class + 2));
189
- $this->assertSame('\PHP_CodeSniffer\Tests\Core\File\testFECNInterface', $found);
190
-
191
- }//end testExtendedNamespacedInterface()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
 
193
 
194
  }//end class
60
 
61
 
62
  /**
63
+ * Test retrieving the name of the class being extended by another class
64
+ * (or interface).
65
  *
66
+ * @param string $identifier Comment which preceeds the test case.
67
+ * @param bool $expected Expected function output.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  *
69
+ * @dataProvider dataExtendedClass
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  *
71
  * @return void
72
  */
73
+ public function testFindExtendedClassName($identifier, $expected)
74
  {
75
+ $start = ($this->phpcsFile->numTokens - 1);
76
+ $delim = $this->phpcsFile->findPrevious(
77
  T_COMMENT,
78
  $start,
79
  null,
80
  false,
81
+ $identifier
82
  );
83
+ $OOToken = $this->phpcsFile->findNext([T_CLASS, T_ANON_CLASS, T_INTERFACE], ($delim + 1));
84
 
85
+ $result = $this->phpcsFile->findExtendedClassName($OOToken);
86
+ $this->assertSame($expected, $result);
87
 
88
+ }//end testFindExtendedClassName()
89
 
90
 
91
  /**
92
+ * Data provider for the FindExtendedClassName test.
93
  *
94
+ * @see testFindExtendedClassName()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  *
96
+ * @return array
97
  */
98
+ public function dataExtendedClass()
99
  {
100
+ return [
101
+ [
102
+ '/* testExtendedClass */',
103
+ 'testFECNClass',
104
+ ],
105
+ [
106
+ '/* testNamespacedClass */',
107
+ '\PHP_CodeSniffer\Tests\Core\File\testFECNClass',
108
+ ],
109
+ [
110
+ '/* testNonExtendedClass */',
111
+ false,
112
+ ],
113
+ [
114
+ '/* testInterface */',
115
+ false,
116
+ ],
117
+ [
118
+ '/* testInterfaceThatExtendsInterface */',
119
+ 'testFECNInterface',
120
+ ],
121
+ [
122
+ '/* testInterfaceThatExtendsFQCNInterface */',
123
+ '\PHP_CodeSniffer\Tests\Core\File\testFECNInterface',
124
+ ],
125
+ [
126
+ '/* testNestedExtendedClass */',
127
+ false,
128
+ ],
129
+ [
130
+ '/* testNestedExtendedAnonClass */',
131
+ 'testFECNAnonClass',
132
+ ],
133
+ [
134
+ '/* testClassThatExtendsAndImplements */',
135
+ 'testFECNClass',
136
+ ],
137
+ [
138
+ '/* testClassThatImplementsAndExtends */',
139
+ 'testFECNClass',
140
+ ],
141
+ ];
142
+
143
+ }//end dataExtendedClass()
144
 
145
 
146
  }//end class
vendor/squizlabs/php_codesniffer/tests/Core/File/FindImplementedInterfaceNamesTest.inc CHANGED
@@ -3,7 +3,6 @@
3
 
4
  namespace PHP_CodeSniffer\Tests\Core\File;
5
 
6
- \PHP_CodeSniffer\Tests\Core\File\testFECNClass
7
  interface testFIINInterface2 {}
8
 
9
  /* testInterface */
@@ -20,3 +19,9 @@ class testFIINNamespacedClass implements \PHP_CodeSniffer\Tests\Core\File\testFI
20
 
21
  /* testNonImplementedClass */
22
  class testFIINNonImplementedClass {}
 
 
 
 
 
 
3
 
4
  namespace PHP_CodeSniffer\Tests\Core\File;
5
 
 
6
  interface testFIINInterface2 {}
7
 
8
  /* testInterface */
19
 
20
  /* testNonImplementedClass */
21
  class testFIINNonImplementedClass {}
22
+
23
+ /* testClassThatExtendsAndImplements */
24
+ class testFECNClassThatExtendsAndImplements extends testFECNClass implements InterfaceA, \NameSpaced\Cat\InterfaceB {}
25
+
26
+ /* testClassThatImplementsAndExtends */
27
+ class testFECNClassThatImplementsAndExtends implements \InterfaceA, InterfaceB extends testFECNClass {}
vendor/squizlabs/php_codesniffer/tests/Core/File/FindImplementedInterfaceNamesTest.php CHANGED
@@ -60,113 +60,83 @@ class FindImplementedInterfaceNamesTest extends TestCase
60
 
61
 
62
  /**
63
- * Test a class that implements a single interface.
64
  *
65
- * @return void
66
- */
67
- public function testImplementedClass()
68
- {
69
- $start = ($this->phpcsFile->numTokens - 1);
70
- $class = $this->phpcsFile->findPrevious(
71
- T_COMMENT,
72
- $start,
73
- null,
74
- false,
75
- '/* testImplementedClass */'
76
- );
77
-
78
- $found = $this->phpcsFile->findImplementedInterfaceNames(($class + 2));
79
- $this->assertSame(['testFIINInterface'], $found);
80
-
81
- }//end testImplementedClass()
82
-
83
-
84
- /**
85
- * Test a class that implements multiple interfaces.
86
  *
87
- * @return void
88
- */
89
- public function testMultiImplementedClass()
90
- {
91
- $start = ($this->phpcsFile->numTokens - 1);
92
- $class = $this->phpcsFile->findPrevious(
93
- T_COMMENT,
94
- $start,
95
- null,
96
- false,
97
- '/* testMultiImplementedClass */'
98
- );
99
-
100
- $found = $this->phpcsFile->findImplementedInterfaceNames(($class + 2));
101
- $this->assertSame(['testFIINInterface', 'testFIINInterface2'], $found);
102
-
103
- }//end testMultiImplementedClass()
104
-
105
-
106
- /**
107
- * Test a class that implements an interface, using namespaces.
108
  *
109
  * @return void
110
  */
111
- public function testNamespacedClass()
112
  {
113
- $start = ($this->phpcsFile->numTokens - 1);
114
- $class = $this->phpcsFile->findPrevious(
115
  T_COMMENT,
116
  $start,
117
  null,
118
  false,
119
- '/* testNamespacedClass */'
120
  );
 
121
 
122
- $found = $this->phpcsFile->findImplementedInterfaceNames(($class + 2));
123
- $this->assertSame(['\PHP_CodeSniffer\Tests\Core\File\testFIINInterface'], $found);
124
 
125
- }//end testNamespacedClass()
126
 
127
 
128
  /**
129
- * Test a class that doesn't implement an interface.
130
  *
131
- * @return void
132
- */
133
- public function testNonImplementedClass()
134
- {
135
- $start = ($this->phpcsFile->numTokens - 1);
136
- $class = $this->phpcsFile->findPrevious(
137
- T_COMMENT,
138
- $start,
139
- null,
140
- false,
141
- '/* testNonImplementedClass */'
142
- );
143
-
144
- $found = $this->phpcsFile->findImplementedInterfaceNames(($class + 2));
145
- $this->assertFalse($found);
146
-
147
- }//end testNonImplementedClass()
148
-
149
-
150
- /**
151
- * Test an interface.
152
  *
153
- * @return void
154
  */
155
- public function testInterface()
156
  {
157
- $start = ($this->phpcsFile->numTokens - 1);
158
- $class = $this->phpcsFile->findPrevious(
159
- T_COMMENT,
160
- $start,
161
- null,
162
- false,
163
- '/* testInterface */'
164
- );
165
-
166
- $found = $this->phpcsFile->findImplementedInterfaceNames(($class + 2));
167
- $this->assertFalse($found);
168
-
169
- }//end testInterface()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
170
 
171
 
172
  }//end class
60
 
61
 
62
  /**
63
+ * Test retrieving the name(s) of the interfaces being implemented by a class.
64
  *
65
+ * @param string $identifier Comment which preceeds the test case.
66
+ * @param bool $expected Expected function output.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  *
68
+ * @dataProvider dataImplementedInterface
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
  *
70
  * @return void
71
  */
72
+ public function testFindImplementedInterfaceNames($identifier, $expected)
73
  {
74
+ $start = ($this->phpcsFile->numTokens - 1);
75
+ $delim = $this->phpcsFile->findPrevious(
76
  T_COMMENT,
77
  $start,
78
  null,
79
  false,
80
+ $identifier
81
  );
82
+ $OOToken = $this->phpcsFile->findNext([T_CLASS, T_ANON_CLASS, T_INTERFACE], ($delim + 1));
83
 
84
+ $result = $this->phpcsFile->findImplementedInterfaceNames($OOToken);
85
+ $this->assertSame($expected, $result);
86
 
87
+ }//end testFindImplementedInterfaceNames()
88
 
89
 
90
  /**
91
+ * Data provider for the FindImplementedInterfaceNames test.
92
  *
93
+ * @see testFindImplementedInterfaceNames()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  *
95
+ * @return array
96
  */
97
+ public function dataImplementedInterface()
98
  {
99
+ return [
100
+ [
101
+ '/* testImplementedClass */',
102
+ ['testFIINInterface'],
103
+ ],
104
+ [
105
+ '/* testMultiImplementedClass */',
106
+ [
107
+ 'testFIINInterface',
108
+ 'testFIINInterface2',
109
+ ],
110
+ ],
111
+ [
112
+ '/* testNamespacedClass */',
113
+ ['\PHP_CodeSniffer\Tests\Core\File\testFIINInterface'],
114
+ ],
115
+ [
116
+ '/* testNonImplementedClass */',
117
+ false,
118
+ ],
119
+ [
120
+ '/* testInterface */',
121
+ false,
122
+ ],
123
+ [
124
+ '/* testClassThatExtendsAndImplements */',
125
+ [
126
+ 'InterfaceA',
127
+ '\NameSpaced\Cat\InterfaceB',
128
+ ],
129
+ ],
130
+ [
131
+ '/* testClassThatImplementsAndExtends */',
132
+ [
133
+ '\InterfaceA',
134
+ 'InterfaceB',
135
+ ],
136
+ ],
137
+ ];
138
+
139
+ }//end dataImplementedInterface()
140
 
141
 
142
  }//end class
vendor/squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.inc ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* phpcs:ignoreFile */
3
+
4
+ class TestMemberProperties
5
+ {
6
+ /* testVar */
7
+ var $varA = true;
8
+
9
+ /* testPublic */
10
+ public $varB = true;
11
+
12
+ /* testProtected */
13
+ protected $varC = true;
14
+
15
+ /* testPrivate */
16
+ private $varD = true;
17
+
18
+ /* testStatic */
19
+ static $varE = true;
20
+
21
+ /* testStaticVar */
22
+ static var $varF = true;
23
+
24
+ /* testVarStatic */
25
+ var static $varG = true;
26
+
27
+ /* testPublicStatic */
28
+ public static $varH = true;
29
+
30
+ /* testProtectedStatic */
31
+ static protected $varI = true;
32
+
33
+ /* testPrivateStatic */
34
+ private static $varJ = true;
35
+
36
+ /* testNoPrefix */
37
+ $varK = true;
38
+
39
+ /* testPublicStaticWithDocblock */
40
+ /**
41
+ * Comment here.
42
+ *
43
+ * @phpcs:ignore Standard.Category.Sniff -- because
44
+ * @var boolean
45
+ */
46
+ public static $varH = true;
47
+
48
+ /* testProtectedStaticWithDocblock */
49
+ /**
50
+ * Comment here.
51
+ *
52
+ * @phpcs:ignore Standard.Category.Sniff -- because
53
+ * @var boolean
54
+ */
55
+ static protected $varI = true;
56
+
57
+ /* testPrivateStaticWithDocblock */
58
+ /**
59
+ * Comment here.
60
+ *
61
+ * @phpcs:ignore Standard.Category.Sniff -- because
62
+ * @var boolean
63
+ */
64
+ private static $varJ = true;
65
+
66
+
67
+ protected static
68
+ /* testGroupProtectedStatic 1 */
69
+ $varL,
70
+ /* testGroupProtectedStatic 2 */
71
+ $varM,
72
+ /* testGroupProtectedStatic 3 */
73
+ $varN;
74
+
75
+ private
76
+ /* testGroupPrivate 1 */
77
+ $varO = true,
78
+ /* testGroupPrivate 2 */
79
+ $varP = array( 'a' => 'a', 'b' => 'b' ),
80
+ /* testGroupPrivate 3 */
81
+ $varQ = 'string',
82
+ /* testGroupPrivate 4 */
83
+ $varR = 123,
84
+ /* testGroupPrivate 5 */
85
+ $varS = ONE / self::THREE,
86
+ /* testGroupPrivate 6 */
87
+ $varT = [
88
+ 'a' => 'a',
89
+ 'b' => 'b'
90
+ ],
91
+ /* testGroupPrivate 7 */
92
+ $varU = __DIR__ . "/base";
93
+
94
+
95
+ /* testMethodParam */
96
+ public function methodName($param) {
97
+ /* testImportedGlobal */
98
+ global $importedGlobal = true;
99
+
100
+ /* testLocalVariable */
101
+ $localVariable = true;
102
+ }
103
+
104
+ /* testPropertyAfterMethod */
105
+ private static $varV = true;
106
+
107
+ }
108
+
109
+ interface Base
110
+ {
111
+ /* testInterfaceProperty */
112
+ protected $anonymous;
113
+ }
114
+
115
+ /* testGlobalVariable */
116
+ $globalVariable = true;
117
+
118
+ /* testNotAVariable */
119
+ return;
vendor/squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.php ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Tests for the \PHP_CodeSniffer\Files\File::getMemberProperties method.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Tests\Core\File;
11
+
12
+ use PHP_CodeSniffer\Config;
13
+ use PHP_CodeSniffer\Ruleset;
14
+ use PHP_CodeSniffer\Files\DummyFile;
15
+ use PHP_CodeSniffer\Exceptions\TokenizerException;
16
+ use PHPUnit\Framework\TestCase;
17
+
18
+ class GetMemberPropertiesTest extends TestCase
19
+ {
20
+
21
+ /**
22
+ * The PHP_CodeSniffer_File object containing parsed contents of the test case file.
23
+ *
24
+ * @var \PHP_CodeSniffer\Files\File
25
+ */
26
+ private $phpcsFile;
27
+
28
+
29
+ /**
30
+ * Initialize & tokenize PHP_CodeSniffer_File with code from the test case file.
31
+ *
32
+ * Methods used for these tests can be found in a test case file in the same
33
+ * directory and with the same name, using the .inc extension.
34
+ *
35
+ * @return void
36
+ */
37
+ public function setUp()
38
+ {
39
+ $config = new Config();
40
+ $config->standards = ['Generic'];
41
+
42
+ $ruleset = new Ruleset($config);
43
+
44
+ $pathToTestFile = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc';
45
+ $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config);
46
+ $this->phpcsFile->process();
47
+
48
+ }//end setUp()
49
+
50
+
51
+ /**
52
+ * Clean up after finished test.
53
+ *
54
+ * @return void
55
+ */
56
+ public function tearDown()
57
+ {
58
+ unset($this->phpcsFile);
59
+
60
+ }//end tearDown()
61
+
62
+
63
+ /**
64
+ * Test the getMemberProperties() method.
65
+ *
66
+ * @param string $identifier Comment which preceeds the test case.
67
+ * @param bool $expected Expected function output.
68
+ *
69
+ * @dataProvider dataGetMemberProperties
70
+ *
71
+ * @return void
72
+ */
73
+ public function testGetMemberProperties($identifier, $expected)
74
+ {
75
+ $start = ($this->phpcsFile->numTokens - 1);
76
+ $delim = $this->phpcsFile->findPrevious(
77
+ T_COMMENT,
78
+ $start,
79
+ null,
80
+ false,
81
+ $identifier
82
+ );
83
+ $variable = $this->phpcsFile->findNext(T_VARIABLE, ($delim + 1));
84
+
85
+ $result = $this->phpcsFile->getMemberProperties($variable);
86
+ $this->assertSame($expected, $result);
87
+
88
+ }//end testGetMemberProperties()
89
+
90
+
91
+ /**
92
+ * Data provider for the GetMemberProperties test.
93
+ *
94
+ * @see testGetMemberProperties()
95
+ *
96
+ * @return array
97
+ */
98
+ public function dataGetMemberProperties()
99
+ {
100
+ return [
101
+ [
102
+ '/* testVar */',
103
+ [
104
+ 'scope' => 'public',
105
+ 'scope_specified' => false,
106
+ 'is_static' => false,
107
+ ],
108
+ ],
109
+ [
110
+ '/* testPublic */',
111
+ [
112
+ 'scope' => 'public',
113
+ 'scope_specified' => true,
114
+ 'is_static' => false,
115
+ ],
116
+ ],
117
+ [
118
+ '/* testProtected */',
119
+ [
120
+ 'scope' => 'protected',
121
+ 'scope_specified' => true,
122
+ 'is_static' => false,
123
+ ],
124
+ ],
125
+ [
126
+ '/* testPrivate */',
127
+ [
128
+ 'scope' => 'private',
129
+ 'scope_specified' => true,
130
+ 'is_static' => false,
131
+ ],
132
+ ],
133
+ [
134
+ '/* testStatic */',
135
+ [
136
+ 'scope' => 'public',
137
+ 'scope_specified' => false,
138
+ 'is_static' => true,
139
+ ],
140
+ ],
141
+ [
142
+ '/* testStaticVar */',
143
+ [
144
+ 'scope' => 'public',
145
+ 'scope_specified' => false,
146
+ 'is_static' => true,
147
+ ],
148
+ ],
149
+ [
150
+ '/* testVarStatic */',
151
+ [
152
+ 'scope' => 'public',
153
+ 'scope_specified' => false,
154
+ 'is_static' => true,
155
+ ],
156
+ ],
157
+ [
158
+ '/* testPublicStatic */',
159
+ [
160
+ 'scope' => 'public',
161
+ 'scope_specified' => true,
162
+ 'is_static' => true,
163
+ ],
164
+ ],
165
+ [
166
+ '/* testProtectedStatic */',
167
+ [
168
+ 'scope' => 'protected',
169
+ 'scope_specified' => true,
170
+ 'is_static' => true,
171
+ ],
172
+ ],
173
+ [
174
+ '/* testPrivateStatic */',
175
+ [
176
+ 'scope' => 'private',
177
+ 'scope_specified' => true,
178
+ 'is_static' => true,
179
+ ],
180
+ ],
181
+ [
182
+ '/* testPublicStaticWithDocblock */',
183
+ [
184
+ 'scope' => 'public',
185
+ 'scope_specified' => true,
186
+ 'is_static' => true,
187
+ ],
188
+ ],
189
+ [
190
+ '/* testProtectedStaticWithDocblock */',
191
+ [
192
+ 'scope' => 'protected',
193
+ 'scope_specified' => true,
194
+ 'is_static' => true,
195
+ ],
196
+ ],
197
+ [
198
+ '/* testPrivateStaticWithDocblock */',
199
+ [
200
+ 'scope' => 'private',
201
+ 'scope_specified' => true,
202
+ 'is_static' => true,
203
+ ],
204
+ ],
205
+ [
206
+ '/* testNoPrefix */',
207
+ [
208
+ 'scope' => 'public',
209
+ 'scope_specified' => false,
210
+ 'is_static' => false,
211
+ ],
212
+ ],
213
+ [
214
+ '/* testGroupProtectedStatic 1 */',
215
+ [
216
+ 'scope' => 'protected',
217
+ 'scope_specified' => true,
218
+ 'is_static' => true,
219
+ ],
220
+ ],
221
+ [
222
+ '/* testGroupProtectedStatic 2 */',
223
+ [
224
+ 'scope' => 'protected',
225
+ 'scope_specified' => true,
226
+ 'is_static' => true,
227
+ ],
228
+ ],
229
+ [
230
+ '/* testGroupProtectedStatic 3 */',
231
+ [
232
+ 'scope' => 'protected',
233
+ 'scope_specified' => true,
234
+ 'is_static' => true,
235
+ ],
236
+ ],
237
+ [
238
+ '/* testGroupPrivate 1 */',
239
+ [
240
+ 'scope' => 'private',
241
+ 'scope_specified' => true,
242
+ 'is_static' => false,
243
+ ],
244
+ ],
245
+ [
246
+ '/* testGroupPrivate 2 */',
247
+ [
248
+ 'scope' => 'private',
249
+ 'scope_specified' => true,
250
+ 'is_static' => false,
251
+ ],
252
+ ],
253
+ [
254
+ '/* testGroupPrivate 3 */',
255
+ [
256
+ 'scope' => 'private',
257
+ 'scope_specified' => true,
258
+ 'is_static' => false,
259
+ ],
260
+ ],
261
+ [
262
+ '/* testGroupPrivate 4 */',
263
+ [
264
+ 'scope' => 'private',
265
+ 'scope_specified' => true,
266
+ 'is_static' => false,
267
+ ],
268
+ ],
269
+ [
270
+ '/* testGroupPrivate 5 */',
271
+ [
272
+ 'scope' => 'private',
273
+ 'scope_specified' => true,
274
+ 'is_static' => false,
275
+ ],
276
+ ],
277
+ [
278
+ '/* testGroupPrivate 6 */',
279
+ [
280
+ 'scope' => 'private',
281
+ 'scope_specified' => true,
282
+ 'is_static' => false,
283
+ ],
284
+ ],
285
+ [
286
+ '/* testGroupPrivate 7 */',
287
+ [
288
+ 'scope' => 'private',
289
+ 'scope_specified' => true,
290
+ 'is_static' => false,
291
+ ],
292
+ ],
293
+ [
294
+ '/* testPropertyAfterMethod */',
295
+ [
296
+ 'scope' => 'private',
297
+ 'scope_specified' => true,
298
+ 'is_static' => true,
299
+ ],
300
+ ],
301
+ [
302
+ '/* testInterfaceProperty */',
303
+ [],
304
+ ],
305
+ ];
306
+
307
+ }//end dataGetMemberProperties()
308
+
309
+
310
+ /**
311
+ * Test receiving an expected exception when a non property is passed.
312
+ *
313
+ * @param string $identifier Comment which preceeds the test case.
314
+ *
315
+ * @expectedException PHP_CodeSniffer\Exceptions\TokenizerException
316
+ * @expectedExceptionMessage $stackPtr is not a class member var
317
+ *
318
+ * @dataProvider dataNotClassProperty
319
+ *
320
+ * @return void
321
+ */
322
+ public function testNotClassPropertyException($identifier)
323
+ {
324
+ $start = ($this->phpcsFile->numTokens - 1);
325
+ $delim = $this->phpcsFile->findPrevious(
326
+ T_COMMENT,
327
+ $start,
328
+ null,
329
+ false,
330
+ $identifier
331
+ );
332
+ $variable = $this->phpcsFile->findNext(T_VARIABLE, ($delim + 1));
333
+
334
+ $result = $this->phpcsFile->getMemberProperties($variable);
335
+
336
+ }//end testNotClassPropertyException()
337
+
338
+
339
+ /**
340
+ * Data provider for the NotClassPropertyException test.
341
+ *
342
+ * @see testNotClassPropertyException()
343
+ *
344
+ * @return array
345
+ */
346
+ public function dataNotClassProperty()
347
+ {
348
+ return [
349
+ ['/* testImportedGlobal */'],
350
+ ['/* testLocalVariable */'],
351
+ ['/* testGlobalVariable */'],
352
+ ];
353
+
354
+ }//end dataNotClassProperty()
355
+
356
+
357
+ /**
358
+ * Test receiving an expected exception when a non variable is passed.
359
+ *
360
+ * @expectedException PHP_CodeSniffer\Exceptions\TokenizerException
361
+ * @expectedExceptionMessage $stackPtr must be of type T_VARIABLE
362
+ *
363
+ * @return void
364
+ */
365
+ public function testNotAVariableException()
366
+ {
367
+ $start = ($this->phpcsFile->numTokens - 1);
368
+ $delim = $this->phpcsFile->findPrevious(
369
+ T_COMMENT,
370
+ $start,
371
+ null,
372
+ false,
373
+ '/* testNotAVariable */'
374
+ );
375
+ $next = $this->phpcsFile->findNext(T_WHITESPACE, ($delim + 1), null, true);
376
+
377
+ $result = $this->phpcsFile->getMemberProperties($next);
378
+
379
+ }//end testNotAVariableException()
380
+
381
+
382
+ }//end class
vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodParametersTest.inc CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /* @codingStandardsIgnoreFile */
3
 
4
  /* testPassByReference */
5
  function passByReference(&$var) {}
1
  <?php
2
+ /* phpcs:ignoreFile */
3
 
4
  /* testPassByReference */
5
  function passByReference(&$var) {}
vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodParametersTest.php CHANGED
@@ -87,6 +87,7 @@ class GetMethodParametersTest extends TestCase
87
 
88
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
89
  unset($found[0]['token']);
 
90
  $this->assertSame($expected, $found);
91
 
92
  }//end testPassByReference()
@@ -120,6 +121,7 @@ class GetMethodParametersTest extends TestCase
120
 
121
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
122
  unset($found[0]['token']);
 
123
  $this->assertSame($expected, $found);
124
 
125
  }//end testArrayHint()
@@ -163,6 +165,8 @@ class GetMethodParametersTest extends TestCase
163
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
164
  unset($found[0]['token']);
165
  unset($found[1]['token']);
 
 
166
  $this->assertSame($expected, $found);
167
 
168
  }//end testTypeHint()
@@ -196,6 +200,7 @@ class GetMethodParametersTest extends TestCase
196
 
197
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
198
  unset($found[0]['token']);
 
199
  $this->assertSame($expected, $found);
200
 
201
  }//end testSelfTypeHint()
@@ -239,6 +244,8 @@ class GetMethodParametersTest extends TestCase
239
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
240
  unset($found[0]['token']);
241
  unset($found[1]['token']);
 
 
242
  $this->assertSame($expected, $found);
243
 
244
  }//end testNullableTypeHint()
@@ -272,6 +279,7 @@ class GetMethodParametersTest extends TestCase
272
 
273
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
274
  unset($found[0]['token']);
 
275
  $this->assertSame($expected, $found);
276
 
277
  }//end testVariable()
@@ -306,6 +314,7 @@ class GetMethodParametersTest extends TestCase
306
 
307
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
308
  unset($found[0]['token']);
 
309
  $this->assertSame($expected, $found);
310
 
311
  }//end testSingleDefaultValue()
@@ -350,6 +359,8 @@ class GetMethodParametersTest extends TestCase
350
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
351
  unset($found[0]['token']);
352
  unset($found[1]['token']);
 
 
353
  $this->assertSame($expected, $found);
354
 
355
  }//end testDefaultValues()
@@ -384,6 +395,7 @@ class GetMethodParametersTest extends TestCase
384
 
385
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
386
  unset($found[0]['token']);
 
387
  $this->assertSame($expected, $found);
388
 
389
  }//end testBitwiseAndConstantExpressionDefaultValue()
87
 
88
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
89
  unset($found[0]['token']);
90
+ unset($found[0]['type_hint_token']);
91
  $this->assertSame($expected, $found);
92
 
93
  }//end testPassByReference()
121
 
122
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
123
  unset($found[0]['token']);
124
+ unset($found[0]['type_hint_token']);
125
  $this->assertSame($expected, $found);
126
 
127
  }//end testArrayHint()
165
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
166
  unset($found[0]['token']);
167
  unset($found[1]['token']);
168
+ unset($found[0]['type_hint_token']);
169
+ unset($found[1]['type_hint_token']);
170
  $this->assertSame($expected, $found);
171
 
172
  }//end testTypeHint()
200
 
201
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
202
  unset($found[0]['token']);
203
+ unset($found[0]['type_hint_token']);
204
  $this->assertSame($expected, $found);
205
 
206
  }//end testSelfTypeHint()
244
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
245
  unset($found[0]['token']);
246
  unset($found[1]['token']);
247
+ unset($found[0]['type_hint_token']);
248
+ unset($found[1]['type_hint_token']);
249
  $this->assertSame($expected, $found);
250
 
251
  }//end testNullableTypeHint()
279
 
280
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
281
  unset($found[0]['token']);
282
+ unset($found[0]['type_hint_token']);
283
  $this->assertSame($expected, $found);
284
 
285
  }//end testVariable()
314
 
315
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
316
  unset($found[0]['token']);
317
+ unset($found[0]['type_hint_token']);
318
  $this->assertSame($expected, $found);
319
 
320
  }//end testSingleDefaultValue()
359
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
360
  unset($found[0]['token']);
361
  unset($found[1]['token']);
362
+ unset($found[0]['type_hint_token']);
363
+ unset($found[1]['type_hint_token']);
364
  $this->assertSame($expected, $found);
365
 
366
  }//end testDefaultValues()
395
 
396
  $found = $this->phpcsFile->getMethodParameters(($function + 2));
397
  unset($found[0]['token']);
398
+ unset($found[0]['type_hint_token']);
399
  $this->assertSame($expected, $found);
400
 
401
  }//end testBitwiseAndConstantExpressionDefaultValue()
vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.inc ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* phpcs:ignoreFile */
3
+
4
+ /* testBasicFunction */
5
+ function myFunction() {}
6
+
7
+ /* testReturnFunction */
8
+ function myFunction(array ...$arrays): array
9
+ {
10
+ return array_map(/* testNestedClosure */function(array $array): int {
11
+ return array_sum($array);
12
+ }, $arrays);
13
+ }
14
+
15
+ class MyClass {
16
+ /* testBasicMethod */
17
+ function myFunction() {}
18
+
19
+ /* testPrivateStaticMethod */
20
+ private static function myFunction() {}
21
+
22
+ /* testFinalMethod */
23
+ final public function myFunction() {}
24
+
25
+ /* testProtectedReturnMethod */
26
+ protected function myFunction() : int {}
27
+
28
+ /* testPublicReturnMethod */
29
+ public function myFunction(): array {}
30
+
31
+ /* testNullableReturnMethod */
32
+ public function myFunction(): ?array {}
33
+
34
+ /* testMessyNullableReturnMethod */
35
+ public function myFunction() /* comment
36
+ */ :
37
+ /* comment */ ? //comment
38
+ array {}
39
+
40
+ /* testReturnNamespace */
41
+ function myFunction(): \MyNamespace\MyClass {}
42
+
43
+ /* testReturnMultilineNamespace */
44
+ function myFunction(): \MyNamespace /** comment *\/ comment */
45
+ \MyClass /* comment */
46
+ \Foo {}
47
+ }
48
+
49
+ abstract class MyClass
50
+ {
51
+ /* testAbstractMethod */
52
+ abstract function myFunction();
53
+
54
+ /* testAbstractReturnMethod */
55
+ abstract protected function myFunction(): bool;
56
+ }
57
+
vendor/squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.php ADDED
@@ -0,0 +1,524 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Tests for the \PHP_CodeSniffer\Files\File:getMethodProperties method.
4
+ *
5
+ * @author Greg Sherwood <gsherwood@squiz.net>
6
+ * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
7
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
8
+ */
9
+
10
+ namespace PHP_CodeSniffer\Tests\Core\File;
11
+
12
+ use PHP_CodeSniffer\Config;
13
+ use PHP_CodeSniffer\Ruleset;
14
+ use PHP_CodeSniffer\Files\DummyFile;
15
+ use PHPUnit\Framework\TestCase;
16
+
17
+ class GetMethodPropertiesTest extends TestCase
18
+ {
19
+
20
+ /**
21
+ * The PHP_CodeSniffer_File object containing parsed contents of the test case file.
22
+ *
23
+ * @var \PHP_CodeSniffer\Files\File
24
+ */
25
+ private $phpcsFile;
26
+
27
+
28
+ /**
29
+ * Initialize & tokenize PHP_CodeSniffer_File with code from the test case file.
30
+ *
31
+ * Methods used for these tests can be found in a test case file in the same
32
+ * directory and with the same name, using the .inc extension.
33
+ *
34
+ * @return void
35
+ */
36
+ public function setUp()
37
+ {
38
+ $config = new Config();
39
+ $config->standards = ['Generic'];
40
+
41
+ $ruleset = new Ruleset($config);
42
+
43
+ $pathToTestFile = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc';
44
+ $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config);
45
+ $this->phpcsFile->process();
46
+
47
+ }//end setUp()
48
+
49
+
50
+ /**
51
+ * Clean up after finished test.
52
+ *
53
+ * @return void
54
+ */
55
+ public function tearDown()
56
+ {
57
+ unset($this->phpcsFile);
58
+
59
+ }//end tearDown()
60
+
61
+
62
+ /**
63
+ * Test a basic function.
64
+ *
65
+ * @return void
66
+ */
67
+ public function testBasicFunction()
68
+ {
69
+ $expected = [
70
+ 'scope' => 'public',
71
+ 'scope_specified' => false,
72
+ 'return_type' => '',
73
+ 'nullable_return_type' => false,
74
+ 'is_abstract' => false,
75
+ 'is_final' => false,
76
+ 'is_static' => false,
77
+ ];
78
+
79
+ $start = ($this->phpcsFile->numTokens - 1);
80
+ $function = $this->phpcsFile->findPrevious(
81
+ T_COMMENT,
82
+ $start,
83
+ null,
84
+ false,
85
+ '/* testBasicFunction */'
86
+ );
87
+
88
+ $found = $this->phpcsFile->getMethodProperties(($function + 2));
89
+ unset($found['return_type_token']);
90
+ $this->assertSame($expected, $found);
91
+
92
+ }//end testBasicFunction()
93
+
94
+
95
+ /**
96
+ * Test a function with a return type.
97
+ *
98
+ * @return void
99
+ */
100
+ public function testReturnFunction()
101
+ {
102
+ $expected = [
103
+ 'scope' => 'public',
104
+ 'scope_specified' => false,
105
+ 'return_type' => 'array',
106
+ 'nullable_return_type' => false,
107
+ 'is_abstract' => false,
108
+ 'is_final' => false,
109
+ 'is_static' => false,
110
+ ];
111
+
112
+ $start = ($this->phpcsFile->numTokens - 1);
113
+ $function = $this->phpcsFile->findPrevious(
114
+ T_COMMENT,
115
+ $start,
116
+ null,
117
+ false,
118
+ '/* testReturnFunction */'
119
+ );
120
+
121
+ $found = $this->phpcsFile->getMethodProperties(($function + 2));
122
+ unset($found['return_type_token']);
123
+ $this->assertSame($expected, $found);
124
+
125
+ }//end testReturnFunction()
126
+
127
+
128
+ /**
129
+ * Test a closure used as a function argument.
130
+ *
131
+ * @return void
132
+ */
133
+ public function testNestedClosure()
134
+ {
135
+ $expected = [
136
+ 'scope' => 'public',
137
+ 'scope_specified' => false,
138
+ 'return_type' => 'int',
139
+ 'nullable_return_type' => false,
140
+ 'is_abstract' => false,
141
+ 'is_final' => false,
142
+ 'is_static' => false,
143
+ ];
144
+
145
+ $start = ($this->phpcsFile->numTokens - 1);
146
+ $function = $this->phpcsFile->findPrevious(
147
+ T_COMMENT,
148
+ $start,
149
+ null,
150
+ false,
151
+ '/* testNestedClosure */'
152
+ );
153
+
154
+ $found = $this->phpcsFile->getMethodProperties(($function + 1));
155
+ unset($found['return_type_token']);
156
+ $this->assertSame($expected, $found);
157
+
158
+ }//end testNestedClosure()
159
+
160
+
161
+ /**
162
+ * Test a basic method.
163
+ *
164
+ * @return void
165
+ */
166
+ public function testBasicMethod()
167
+ {
168
+ $expected = [
169
+ 'scope' => 'public',
170
+ 'scope_specified' => false,
171
+ 'return_type' => '',
172
+ 'nullable_return_type' => false,
173
+ 'is_abstract' => false,
174
+ 'is_final' => false,
175
+ 'is_static' => false,
176
+ ];
177
+
178
+ $start = ($this->phpcsFile->numTokens - 1);
179
+ $function = $this->phpcsFile->findPrevious(
180
+ T_COMMENT,
181
+ $start,
182
+ null,
183
+ false,
184
+ '/* testBasicMethod */'
185
+ );
186
+
187
+ $found = $this->phpcsFile->getMethodProperties(($function + 3));
188
+ unset($found['return_type_token']);
189
+ $this->assertSame($expected, $found);
190
+
191
+ }//end testBasicMethod()
192
+
193
+
194
+ /**
195
+ * Test a private static method.
196
+ *
197
+ * @return void
198
+ */
199
+ public function testPrivateStaticMethod()
200
+ {
201
+ $expected = [
202
+ 'scope' => 'private',
203
+ 'scope_specified' => true,
204
+ 'return_type' => '',
205
+ 'nullable_return_type' => false,
206
+ 'is_abstract' => false,
207
+ 'is_final' => false,
208
+ 'is_static' => true,
209
+ ];
210
+
211
+ $start = ($this->phpcsFile->numTokens - 1);
212
+ $function = $this->phpcsFile->findPrevious(
213
+ T_COMMENT,
214
+ $start,
215
+ null,
216
+ false,
217
+ '/* testPrivateStaticMethod */'
218
+ );
219
+
220
+ $found = $this->phpcsFile->getMethodProperties(($function + 7));
221
+ unset($found['return_type_token']);
222
+ $this->assertSame($expected, $found);
223
+
224
+ }//end testPrivateStaticMethod()
225
+
226
+
227
+ /**
228
+ * Test a basic final method.
229
+ *
230
+ * @return void
231
+ */
232
+ public function testFinalMethod()
233
+ {
234
+ $expected = [
235
+ 'scope' => 'public',
236
+ 'scope_specified' => true,
237
+ 'return_type' => '',
238
+ 'nullable_return_type' => false,
239
+ 'is_abstract' => false,
240
+ 'is_final' => true,
241
+ 'is_static' => false,
242
+ ];
243
+
244
+ $start = ($this->phpcsFile->numTokens - 1);
245
+ $function = $this->phpcsFile->findPrevious(
246
+ T_COMMENT,
247
+ $start,
248
+ null,
249
+ false,
250
+ '/* testFinalMethod */'
251
+ );
252
+
253
+ $found = $this->phpcsFile->getMethodProperties(($function + 7));
254
+ unset($found['return_type_token']);
255
+ $this->assertSame($expected, $found);
256
+
257
+ }//end testFinalMethod()
258
+
259
+
260
+ /**
261
+ * Test a protected method with a return type.
262
+ *
263
+ * @return void
264
+ */
265
+ public function testProtectedReturnMethod()
266
+ {
267
+ $expected = [
268
+ 'scope' => 'protected',
269
+ 'scope_specified' => true,
270
+ 'return_type' => 'int',
271
+ 'nullable_return_type' => false,
272
+ 'is_abstract' => false,
273
+ 'is_final' => false,
274
+ 'is_static' => false,
275
+ ];
276
+
277
+ $start = ($this->phpcsFile->numTokens - 1);
278
+ $function = $this->phpcsFile->findPrevious(
279
+ T_COMMENT,
280
+ $start,
281
+ null,
282
+ false,
283
+ '/* testProtectedReturnMethod */'
284
+ );
285
+
286
+ $found = $this->phpcsFile->getMethodProperties(($function + 5));
287
+ unset($found['return_type_token']);
288
+ $this->assertSame($expected, $found);
289
+
290
+ }//end testProtectedReturnMethod()
291
+
292
+
293
+ /**
294
+ * Test a public method with a return type.
295
+ *
296
+ * @return void
297
+ */
298
+ public function testPublicReturnMethod()
299
+ {
300
+ $expected = [
301
+ 'scope' => 'public',
302
+ 'scope_specified' => true,
303
+ 'return_type' => 'array',
304
+ 'nullable_return_type' => false,
305
+ 'is_abstract' => false,
306
+ 'is_final' => false,
307
+ 'is_static' => false,
308
+ ];
309
+
310
+ $start = ($this->phpcsFile->numTokens - 1);
311
+ $function = $this->phpcsFile->findPrevious(
312
+ T_COMMENT,
313
+ $start,
314
+ null,
315
+ false,
316
+ '/* testPublicReturnMethod */'
317
+ );
318
+
319
+ $found = $this->phpcsFile->getMethodProperties(($function + 5));
320
+ unset($found['return_type_token']);
321
+ $this->assertSame($expected, $found);
322
+
323
+ }//end testPublicReturnMethod()
324
+
325
+
326
+ /**
327
+ * Test a public method with a nullable return type.
328
+ *
329
+ * @return void
330
+ */
331
+ public function testNullableReturnMethod()
332
+ {
333
+ $expected = [
334
+ 'scope' => 'public',
335
+ 'scope_specified' => true,
336
+ 'return_type' => '?array',
337
+ 'nullable_return_type' => true,
338
+ 'is_abstract' => false,
339
+ 'is_final' => false,
340
+ 'is_static' => false,
341
+ ];
342
+
343
+ $start = ($this->phpcsFile->numTokens - 1);
344
+ $function = $this->phpcsFile->findPrevious(
345
+ T_COMMENT,
346
+ $start,
347
+ null,
348
+ false,
349
+ '/* testNullableReturnMethod */'
350
+ );
351
+
352
+ $found = $this->phpcsFile->getMethodProperties(($function + 5));
353
+ unset($found['return_type_token']);
354
+ $this->assertSame($expected, $found);
355
+
356
+ }//end testNullableReturnMethod()
357
+
358
+
359
+ /**
360
+ * Test a public method with a nullable return type.
361
+ *
362
+ * @return void
363
+ */
364
+ public function testMessyNullableReturnMethod()
365
+ {
366
+ $expected = [
367
+ 'scope' => 'public',
368
+ 'scope_specified' => true,
369
+ 'return_type' => '?array',
370
+ 'nullable_return_type' => true,
371
+ 'is_abstract' => false,
372
+ 'is_final' => false,
373
+ 'is_static' => false,
374
+ ];
375
+
376
+ $start = ($this->phpcsFile->numTokens - 1);
377
+ $function = $this->phpcsFile->findPrevious(
378
+ T_COMMENT,
379
+ $start,
380
+ null,
381
+ false,
382
+ '/* testMessyNullableReturnMethod */'
383
+ );
384
+
385
+ $found = $this->phpcsFile->getMethodProperties(($function + 5));
386
+ unset($found['return_type_token']);
387
+ $this->assertSame($expected, $found);
388
+
389
+ }//end testMessyNullableReturnMethod()
390
+
391
+
392
+ /**
393
+ * Test a method with a namespaced return type.
394
+ *
395
+ * @return void
396
+ */
397
+ public function testReturnNamespace()
398
+ {
399
+ $expected = [
400
+ 'scope' => 'public',
401
+ 'scope_specified' => false,
402
+ 'return_type' => '\MyNamespace\MyClass',
403
+ 'nullable_return_type' => false,
404
+ 'is_abstract' => false,
405
+ 'is_final' => false,
406
+ 'is_static' => false,
407
+ ];
408
+
409
+ $start = ($this->phpcsFile->numTokens - 1);
410
+ $function = $this->phpcsFile->findPrevious(
411
+ T_COMMENT,
412
+ $start,
413
+ null,
414
+ false,
415
+ '/* testReturnNamespace */'
416
+ );
417
+
418
+ $found = $this->phpcsFile->getMethodProperties(($function + 3));
419
+ unset($found['return_type_token']);
420
+ $this->assertSame($expected, $found);
421
+
422
+ }//end testReturnNamespace()
423
+
424
+
425
+ /**
426
+ * Test a method with a messy namespaces return type.
427
+ *
428
+ * @return void
429
+ */
430
+ public function testReturnMultilineNamespace()
431
+ {
432
+ $expected = [
433
+ 'scope' => 'public',
434
+ 'scope_specified' => false,
435
+ 'return_type' => '\MyNamespace\MyClass\Foo',
436
+ 'nullable_return_type' => false,
437
+ 'is_abstract' => false,
438
+ 'is_final' => false,
439
+ 'is_static' => false,
440
+ ];
441
+
442
+ $start = ($this->phpcsFile->numTokens - 1);
443
+ $function = $this->phpcsFile->findPrevious(
444
+ T_COMMENT,
445
+ $start,
446
+ null,
447
+ false,
448
+ '/* testReturnMultilineNamespace */'
449
+ );
450
+
451
+ $found = $this->phpcsFile->getMethodProperties(($function + 3));
452
+ unset($found['return_type_token']);
453
+ $this->assertSame($expected, $found);
454
+
455
+ }//end testReturnMultilineNamespace()
456
+
457
+
458
+ /**
459
+ * Test a basic abstract method.
460
+ *
461
+ * @return void
462
+ */
463
+ public function testAbstractMethod()
464
+ {
465
+ $expected = [
466
+ 'scope' => 'public',
467
+ 'scope_specified' => false,
468
+ 'return_type' => '',
469
+ 'nullable_return_type' => false,
470
+ 'is_abstract' => true,
471
+ 'is_final' => false,
472
+ 'is_static' => false,
473
+ ];
474
+
475
+ $start = ($this->phpcsFile->numTokens - 1);
476
+ $function = $this->phpcsFile->findPrevious(
477
+ T_COMMENT,
478
+ $start,
479
+ null,
480
+ false,
481
+ '/* testAbstractMethod */'
482
+ );
483
+
484
+ $found = $this->phpcsFile->getMethodProperties(($function + 5));
485
+ unset($found['return_type_token']);
486
+ $this->assertSame($expected, $found);
487
+
488
+ }//end testAbstractMethod()
489
+
490
+
491
+ /**
492
+ * Test an abstract method with a return type.
493
+ *
494
+ * @return void
495
+ */
496
+ public function testAbstractReturnMethod()
497
+ {
498
+ $expected = [
499
+ 'scope' => 'protected',
500
+ 'scope_specified' => true,
501
+ 'return_type' => 'bool',
502
+ 'nullable_return_type' => false,
503
+ 'is_abstract' => true,
504
+ 'is_final' => false,
505
+ 'is_static' => false,
506
+ ];
507
+
508
+ $start = ($this->phpcsFile->numTokens - 1);
509
+ $function = $this->phpcsFile->findPrevious(
510
+ T_COMMENT,
511
+ $start,
512
+ null,
513
+ false,
514
+ '/* testAbstractReturnMethod */'
515
+ );
516
+
517
+ $found = $this->phpcsFile->getMethodProperties(($function + 7));
518
+ unset($found['return_type_token']);
519
+ $this->assertSame($expected, $found);
520
+
521
+ }//end testAbstractReturnMethod()
522
+
523
+
524
+ }//end class
vendor/squizlabs/php_codesniffer/tests/Core/File/IsReferenceTest.inc CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- /* @codingStandardsIgnoreFile */
3
 
4
  namespace PHP_CodeSniffer\Tests\Core\File;
5
 
1
  <?php
2
+ /* phpcs:ignoreFile */
3
 
4
  namespace PHP_CodeSniffer\Tests\Core\File;
5
 
vendor/squizlabs/php_codesniffer/tests/Standards/AbstractSniffUnitTest.php CHANGED
@@ -81,7 +81,7 @@ abstract class AbstractSniffUnitTest extends TestCase
81
  foreach ($di as $file) {
82
  $path = $file->getPathname();
83
  if (substr($path, 0, strlen($testFileBase)) === $testFileBase) {
84
- if ($path !== $testFileBase.'php' && substr($path, -5) !== 'fixed') {
85
  $testFiles[] = $path;
86
  }
87
  }
81
  foreach ($di as $file) {
82
  $path = $file->getPathname();
83
  if (substr($path, 0, strlen($testFileBase)) === $testFileBase) {
84
+ if ($path !== $testFileBase.'php' && substr($path, -5) !== 'fixed' && substr($path, -4) !== '.bak') {
85
  $testFiles[] = $path;
86
  }
87
  }
vendor/squizlabs/php_codesniffer/tests/Standards/AllSniffs.php CHANGED
@@ -11,7 +11,6 @@ namespace PHP_CodeSniffer\Tests\Standards;
11
 
12
  use PHP_CodeSniffer\Util\Standards;
13
  use PHP_CodeSniffer\Autoload;
14
- use PHP_CodeSniffer\Tests\Standards\AbstractSniffUnitTest;
15
  use PHPUnit\TextUI\TestRunner;
16
  use PHPUnit\Framework\TestSuite;
17
 
@@ -56,7 +55,7 @@ class AllSniffs
56
  $ignoreTestsForStandards = explode(',', $ignoreTestsForStandards);
57
  }
58
 
59
- $installedStandards = Standards::getInstalledStandardDetails(true);
60
 
61
  foreach ($installedStandards as $standard => $details) {
62
  Autoload::addSearchPath($details['path'], $details['namespace']);
@@ -107,4 +106,17 @@ class AllSniffs
107
  }//end suite()
108
 
109
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  }//end class
11
 
12
  use PHP_CodeSniffer\Util\Standards;
13
  use PHP_CodeSniffer\Autoload;
 
14
  use PHPUnit\TextUI\TestRunner;
15
  use PHPUnit\Framework\TestSuite;
16
 
55
  $ignoreTestsForStandards = explode(',', $ignoreTestsForStandards);
56
  }
57
 
58
+ $installedStandards = self::getInstalledStandardDetails();
59
 
60
  foreach ($installedStandards as $standard => $details) {
61
  Autoload::addSearchPath($details['path'], $details['namespace']);
106
  }//end suite()
107
 
108
 
109
+ /**
110
+ * Get the details of all coding standards installed.
111
+ *
112
+ * @return array
113
+ * @see Standards::getInstalledStandardDetails()
114
+ */
115
+ protected static function getInstalledStandardDetails()
116
+ {
117
+ return Standards::getInstalledStandardDetails(true);
118
+
119
+ }//end getInstalledStandardDetails()
120
+
121
+
122
  }//end class
vendor/symfony/css-selector/CssSelector.php CHANGED
@@ -17,7 +17,7 @@ namespace Symfony\Component\CssSelector;
17
  * CssSelector is the main entry point of the component and can convert CSS
18
  * selectors to XPath expressions.
19
  *
20
- * $xpath = CssSelector::toXpath('h1.foo');
21
  *
22
  * This component is a port of the Python cssselect library,
23
  * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
17
  * CssSelector is the main entry point of the component and can convert CSS
18
  * selectors to XPath expressions.
19
  *
20
+ * $xpath = CssSelector::toXpath('h1.foo');
21
  *
22
  * This component is a port of the Python cssselect library,
23
  * which is copyright Ian Bicking, @see https://github.com/SimonSapin/cssselect.
vendor/symfony/css-selector/Node/AbstractNode.php CHANGED
@@ -34,7 +34,7 @@ abstract class AbstractNode implements NodeInterface
34
  public function getNodeName()
35
  {
36
  if (null === $this->nodeName) {
37
- $this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', get_called_class());
38
  }
39
 
40
  return $this->nodeName;
34
  public function getNodeName()
35
  {
36
  if (null === $this->nodeName) {
37
+ $this->nodeName = preg_replace('~.*\\\\([^\\\\]+)Node$~', '$1', \get_called_class());
38
  }
39
 
40
  return $this->nodeName;
vendor/symfony/css-selector/Node/ElementNode.php CHANGED
@@ -37,7 +37,7 @@ class ElementNode extends AbstractNode
37
  }
38
 
39
  /**
40
- * @return null|string
41
  */
42
  public function getNamespace()
43
  {
@@ -45,7 +45,7 @@ class ElementNode extends AbstractNode
45
  }
46
 
47
  /**
48
- * @return null|string
49
  */
50
  public function getElement()
51
  {
37
  }
38
 
39
  /**
40
+ * @return string|null
41
  */
42
  public function getNamespace()
43
  {
45
  }
46
 
47
  /**
48
+ * @return string|null
49
  */
50
  public function getElement()
51
  {
vendor/symfony/css-selector/Node/SelectorNode.php CHANGED
@@ -28,7 +28,7 @@ class SelectorNode extends AbstractNode
28
 
29
  /**
30
  * @param NodeInterface $tree
31
- * @param null|string $pseudoElement
32
  */
33
  public function __construct(NodeInterface $tree, $pseudoElement = null)
34
  {
@@ -45,7 +45,7 @@ class SelectorNode extends AbstractNode
45
  }
46
 
47
  /**
48
- * @return null|string
49
  */
50
  public function getPseudoElement()
51
  {
28
 
29
  /**
30
  * @param NodeInterface $tree
31
+ * @param string|null $pseudoElement
32
  */
33
  public function __construct(NodeInterface $tree, $pseudoElement = null)
34
  {
45
  }
46
 
47
  /**
48
+ * @return string|null
49
  */
50
  public function getPseudoElement()
51
  {
vendor/symfony/css-selector/Parser/Handler/HashHandler.php CHANGED
@@ -13,9 +13,9 @@ namespace Symfony\Component\CssSelector\Parser\Handler;
13
 
14
  use Symfony\Component\CssSelector\Parser\Reader;
15
  use Symfony\Component\CssSelector\Parser\Token;
16
- use Symfony\Component\CssSelector\Parser\TokenStream;
17
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
18
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
 
19
 
20
  /**
21
  * CSS selector comment handler.
@@ -51,7 +51,7 @@ class HashHandler implements HandlerInterface
51
 
52
  $value = $this->escaping->escapeUnicode($match[1]);
53
  $stream->push(new Token(Token::TYPE_HASH, $value, $reader->getPosition()));
54
- $reader->moveForward(strlen($match[0]));
55
 
56
  return true;
57
  }
13
 
14
  use Symfony\Component\CssSelector\Parser\Reader;
15
  use Symfony\Component\CssSelector\Parser\Token;
 
16
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
17
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
18
+ use Symfony\Component\CssSelector\Parser\TokenStream;
19
 
20
  /**
21
  * CSS selector comment handler.
51
 
52
  $value = $this->escaping->escapeUnicode($match[1]);
53
  $stream->push(new Token(Token::TYPE_HASH, $value, $reader->getPosition()));
54
+ $reader->moveForward(\strlen($match[0]));
55
 
56
  return true;
57
  }
vendor/symfony/css-selector/Parser/Handler/IdentifierHandler.php CHANGED
@@ -13,9 +13,9 @@ namespace Symfony\Component\CssSelector\Parser\Handler;
13
 
14
  use Symfony\Component\CssSelector\Parser\Reader;
15
  use Symfony\Component\CssSelector\Parser\Token;
16
- use Symfony\Component\CssSelector\Parser\TokenStream;
17
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
18
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
 
19
 
20
  /**
21
  * CSS selector comment handler.
@@ -51,7 +51,7 @@ class IdentifierHandler implements HandlerInterface
51
 
52
  $value = $this->escaping->escapeUnicode($match[0]);
53
  $stream->push(new Token(Token::TYPE_IDENTIFIER, $value, $reader->getPosition()));
54
- $reader->moveForward(strlen($match[0]));
55
 
56
  return true;
57
  }
13
 
14
  use Symfony\Component\CssSelector\Parser\Reader;
15
  use Symfony\Component\CssSelector\Parser\Token;
 
16
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
17
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
18
+ use Symfony\Component\CssSelector\Parser\TokenStream;
19
 
20
  /**
21
  * CSS selector comment handler.
51
 
52
  $value = $this->escaping->escapeUnicode($match[0]);
53
  $stream->push(new Token(Token::TYPE_IDENTIFIER, $value, $reader->getPosition()));
54
+ $reader->moveForward(\strlen($match[0]));
55
 
56
  return true;
57
  }
vendor/symfony/css-selector/Parser/Handler/NumberHandler.php CHANGED
@@ -13,8 +13,8 @@ namespace Symfony\Component\CssSelector\Parser\Handler;
13
 
14
  use Symfony\Component\CssSelector\Parser\Reader;
15
  use Symfony\Component\CssSelector\Parser\Token;
16
- use Symfony\Component\CssSelector\Parser\TokenStream;
17
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
 
18
 
19
  /**
20
  * CSS selector comment handler.
@@ -47,7 +47,7 @@ class NumberHandler implements HandlerInterface
47
  }
48
 
49
  $stream->push(new Token(Token::TYPE_NUMBER, $match[0], $reader->getPosition()));
50
- $reader->moveForward(strlen($match[0]));
51
 
52
  return true;
53
  }
13
 
14
  use Symfony\Component\CssSelector\Parser\Reader;
15
  use Symfony\Component\CssSelector\Parser\Token;
 
16
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
17
+ use Symfony\Component\CssSelector\Parser\TokenStream;
18
 
19
  /**
20
  * CSS selector comment handler.
47
  }
48
 
49
  $stream->push(new Token(Token::TYPE_NUMBER, $match[0], $reader->getPosition()));
50
+ $reader->moveForward(\strlen($match[0]));
51
 
52
  return true;
53
  }
vendor/symfony/css-selector/Parser/Handler/StringHandler.php CHANGED
@@ -15,9 +15,9 @@ use Symfony\Component\CssSelector\Exception\InternalErrorException;
15
  use Symfony\Component\CssSelector\Exception\SyntaxErrorException;
16
  use Symfony\Component\CssSelector\Parser\Reader;
17
  use Symfony\Component\CssSelector\Parser\Token;
18
- use Symfony\Component\CssSelector\Parser\TokenStream;
19
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
20
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
 
21
 
22
  /**
23
  * CSS selector comment handler.
@@ -47,7 +47,7 @@ class StringHandler implements HandlerInterface
47
  {
48
  $quote = $reader->getSubstring(1);
49
 
50
- if (!in_array($quote, array("'", '"'))) {
51
  return false;
52
  }
53
 
@@ -59,18 +59,18 @@ class StringHandler implements HandlerInterface
59
  }
60
 
61
  // check unclosed strings
62
- if (strlen($match[0]) === $reader->getRemainingLength()) {
63
  throw SyntaxErrorException::unclosedString($reader->getPosition() - 1);
64
  }
65
 
66
  // check quotes pairs validity
67
- if ($quote !== $reader->getSubstring(1, strlen($match[0]))) {
68
  throw SyntaxErrorException::unclosedString($reader->getPosition() - 1);
69
  }
70
 
71
  $string = $this->escaping->escapeUnicodeAndNewLine($match[0]);
72
  $stream->push(new Token(Token::TYPE_STRING, $string, $reader->getPosition()));
73
- $reader->moveForward(strlen($match[0]) + 1);
74
 
75
  return true;
76
  }
15
  use Symfony\Component\CssSelector\Exception\SyntaxErrorException;
16
  use Symfony\Component\CssSelector\Parser\Reader;
17
  use Symfony\Component\CssSelector\Parser\Token;
 
18
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
19
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
20
+ use Symfony\Component\CssSelector\Parser\TokenStream;
21
 
22
  /**
23
  * CSS selector comment handler.
47
  {
48
  $quote = $reader->getSubstring(1);
49
 
50
+ if (!\in_array($quote, array("'", '"'))) {
51
  return false;
52
  }
53
 
59
  }
60
 
61
  // check unclosed strings
62
+ if (\strlen($match[0]) === $reader->getRemainingLength()) {
63
  throw SyntaxErrorException::unclosedString($reader->getPosition() - 1);
64
  }
65
 
66
  // check quotes pairs validity
67
+ if ($quote !== $reader->getSubstring(1, \strlen($match[0]))) {
68
  throw SyntaxErrorException::unclosedString($reader->getPosition() - 1);
69
  }
70
 
71
  $string = $this->escaping->escapeUnicodeAndNewLine($match[0]);
72
  $stream->push(new Token(Token::TYPE_STRING, $string, $reader->getPosition()));
73
+ $reader->moveForward(\strlen($match[0]) + 1);
74
 
75
  return true;
76
  }
vendor/symfony/css-selector/Parser/Handler/WhitespaceHandler.php CHANGED
@@ -39,7 +39,7 @@ class WhitespaceHandler implements HandlerInterface
39
  }
40
 
41
  $stream->push(new Token(Token::TYPE_WHITESPACE, $match[0], $reader->getPosition()));
42
- $reader->moveForward(strlen($match[0]));
43
 
44
  return true;
45
  }
39
  }
40
 
41
  $stream->push(new Token(Token::TYPE_WHITESPACE, $match[0], $reader->getPosition()));
42
+ $reader->moveForward(\strlen($match[0]));
43
 
44
  return true;
45
  }
vendor/symfony/css-selector/Parser/Parser.php CHANGED
@@ -169,7 +169,7 @@ class Parser implements ParserInterface
169
  {
170
  $stream->skipWhitespace();
171
 
172
- $selectorStart = count($stream->getUsed());
173
  $result = $this->parseElementNode($stream);
174
  $pseudoElement = null;
175
 
@@ -206,7 +206,7 @@ class Parser implements ParserInterface
206
  }
207
 
208
  $identifier = $stream->getNextIdentifier();
209
- if (in_array(strtolower($identifier), array('first-line', 'first-letter', 'before', 'after'))) {
210
  // Special case: CSS 2.1 pseudo-elements can have a single ':'.
211
  // Any new pseudo-element must have two.
212
  $pseudoElement = $identifier;
@@ -272,7 +272,7 @@ class Parser implements ParserInterface
272
  }
273
  }
274
 
275
- if (count($stream->getUsed()) === $selectorStart) {
276
  throw SyntaxErrorException::unexpectedToken('selector', $stream->getPeek());
277
  }
278
 
169
  {
170
  $stream->skipWhitespace();
171
 
172
+ $selectorStart = \count($stream->getUsed());
173
  $result = $this->parseElementNode($stream);
174
  $pseudoElement = null;
175
 
206
  }
207
 
208
  $identifier = $stream->getNextIdentifier();
209
+ if (\in_array(strtolower($identifier), array('first-line', 'first-letter', 'before', 'after'))) {
210
  // Special case: CSS 2.1 pseudo-elements can have a single ':'.
211
  // Any new pseudo-element must have two.
212
  $pseudoElement = $identifier;
272
  }
273
  }
274
 
275
+ if (\count($stream->getUsed()) === $selectorStart) {
276
  throw SyntaxErrorException::unexpectedToken('selector', $stream->getPeek());
277
  }
278
 
vendor/symfony/css-selector/Parser/Reader.php CHANGED
@@ -33,7 +33,7 @@ class Reader
33
  public function __construct($source)
34
  {
35
  $this->source = $source;
36
- $this->length = strlen($source);
37
  }
38
 
39
  /**
33
  public function __construct($source)
34
  {
35
  $this->source = $source;
36
+ $this->length = \strlen($source);
37
  }
38
 
39
  /**
vendor/symfony/css-selector/Parser/Token.php CHANGED
@@ -92,7 +92,7 @@ class Token
92
  return true;
93
  }
94
 
95
- return in_array($this->value, $values);
96
  }
97
 
98
  /**
92
  return true;
93
  }
94
 
95
+ return \in_array($this->value, $values);
96
  }
97
 
98
  /**
vendor/symfony/css-selector/Parser/TokenStream.php CHANGED
@@ -142,7 +142,7 @@ class TokenStream
142
  /**
143
  * Returns nex identifier or star delimiter token.
144
  *
145
- * @return null|string The identifier token value or null if star found
146
  *
147
  * @throws SyntaxErrorException If next token is not an identifier or a star delimiter
148
  */
142
  /**
143
  * Returns nex identifier or star delimiter token.
144
  *
145
+ * @return string|null The identifier token value or null if star found
146
  *
147
  * @throws SyntaxErrorException If next token is not an identifier or a star delimiter
148
  */
vendor/symfony/css-selector/Parser/Tokenizer/TokenizerEscaping.php CHANGED
@@ -65,13 +65,13 @@ class TokenizerEscaping
65
  $c = hexdec($match[1]);
66
 
67
  if (0x80 > $c %= 0x200000) {
68
- return chr($c);
69
  }
70
  if (0x800 > $c) {
71
- return chr(0xC0 | $c >> 6).chr(0x80 | $c & 0x3F);
72
  }
73
  if (0x10000 > $c) {
74
- return chr(0xE0 | $c >> 12).chr(0x80 | $c >> 6 & 0x3F).chr(0x80 | $c & 0x3F);
75
  }
76
  }, $value);
77
  }
65
  $c = hexdec($match[1]);
66
 
67
  if (0x80 > $c %= 0x200000) {
68
+ return \chr($c);
69
  }
70
  if (0x800 > $c) {
71
+ return \chr(0xC0 | $c >> 6).\chr(0x80 | $c & 0x3F);
72
  }
73
  if (0x10000 > $c) {
74
+ return \chr(0xE0 | $c >> 12).\chr(0x80 | $c >> 6 & 0x3F).\chr(0x80 | $c & 0x3F);
75
  }
76
  }, $value);
77
  }
vendor/symfony/css-selector/Parser/Tokenizer/TokenizerPatterns.php CHANGED
@@ -46,7 +46,7 @@ class TokenizerPatterns
46
  $this->nonAsciiPattern = '[^\x00-\x7F]';
47
  $this->nmCharPattern = '[_a-z0-9-]|'.$this->escapePattern.'|'.$this->nonAsciiPattern;
48
  $this->nmStartPattern = '[_a-z]|'.$this->escapePattern.'|'.$this->nonAsciiPattern;
49
- $this->identifierPattern = '(?:'.$this->nmStartPattern.')(?:'.$this->nmCharPattern.')*';
50
  $this->hashPattern = '#((?:'.$this->nmCharPattern.')+)';
51
  $this->numberPattern = '[+-]?(?:[0-9]*\.[0-9]+|[0-9]+)';
52
  $this->quotedStringPattern = '([^\n\r\f%s]|'.$this->stringEscapePattern.')*';
46
  $this->nonAsciiPattern = '[^\x00-\x7F]';
47
  $this->nmCharPattern = '[_a-z0-9-]|'.$this->escapePattern.'|'.$this->nonAsciiPattern;
48
  $this->nmStartPattern = '[_a-z]|'.$this->escapePattern.'|'.$this->nonAsciiPattern;
49
+ $this->identifierPattern = '-?(?:'.$this->nmStartPattern.')(?:'.$this->nmCharPattern.')*';
50
  $this->hashPattern = '#((?:'.$this->nmCharPattern.')+)';
51
  $this->numberPattern = '[+-]?(?:[0-9]*\.[0-9]+|[0-9]+)';
52
  $this->quotedStringPattern = '([^\n\r\f%s]|'.$this->stringEscapePattern.')*';
vendor/symfony/css-selector/Tests/Node/HashNodeTest.php CHANGED
@@ -11,8 +11,8 @@
11
 
12
  namespace Symfony\Component\CssSelector\Tests\Node;
13
 
14
- use Symfony\Component\CssSelector\Node\HashNode;
15
  use Symfony\Component\CssSelector\Node\ElementNode;
 
16
 
17
  class HashNodeTest extends AbstractNodeTest
18
  {
11
 
12
  namespace Symfony\Component\CssSelector\Tests\Node;
13
 
 
14
  use Symfony\Component\CssSelector\Node\ElementNode;
15
+ use Symfony\Component\CssSelector\Node\HashNode;
16
 
17
  class HashNodeTest extends AbstractNodeTest
18
  {
vendor/symfony/css-selector/Tests/Node/NegationNodeTest.php CHANGED
@@ -12,8 +12,8 @@
12
  namespace Symfony\Component\CssSelector\Tests\Node;
13
 
14
  use Symfony\Component\CssSelector\Node\ClassNode;
15
- use Symfony\Component\CssSelector\Node\NegationNode;
16
  use Symfony\Component\CssSelector\Node\ElementNode;
 
17
 
18
  class NegationNodeTest extends AbstractNodeTest
19
  {
12
  namespace Symfony\Component\CssSelector\Tests\Node;
13
 
14
  use Symfony\Component\CssSelector\Node\ClassNode;
 
15
  use Symfony\Component\CssSelector\Node\ElementNode;
16
+ use Symfony\Component\CssSelector\Node\NegationNode;
17
 
18
  class NegationNodeTest extends AbstractNodeTest
19
  {
vendor/symfony/css-selector/Tests/Parser/Handler/AbstractHandlerTest.php CHANGED
@@ -63,7 +63,7 @@ abstract class AbstractHandlerTest extends TestCase
63
  $this->assertEquals(0, $reader->getRemainingLength());
64
  $this->assertTrue($reader->isEOF());
65
  } else {
66
- $this->assertEquals(strlen($remainingContent), $reader->getRemainingLength());
67
  $this->assertEquals(0, $reader->getOffset($remainingContent));
68
  }
69
  }
63
  $this->assertEquals(0, $reader->getRemainingLength());
64
  $this->assertTrue($reader->isEOF());
65
  } else {
66
+ $this->assertEquals(\strlen($remainingContent), $reader->getRemainingLength());
67
  $this->assertEquals(0, $reader->getOffset($remainingContent));
68
  }
69
  }
vendor/symfony/css-selector/Tests/Parser/Handler/HashHandlerTest.php CHANGED
@@ -13,8 +13,8 @@ namespace Symfony\Component\CssSelector\Tests\Parser\Handler;
13
 
14
  use Symfony\Component\CssSelector\Parser\Handler\HashHandler;
15
  use Symfony\Component\CssSelector\Parser\Token;
16
- use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
17
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
 
18
 
19
  class HashHandlerTest extends AbstractHandlerTest
20
  {
13
 
14
  use Symfony\Component\CssSelector\Parser\Handler\HashHandler;
15
  use Symfony\Component\CssSelector\Parser\Token;
 
16
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
17
+ use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
18
 
19
  class HashHandlerTest extends AbstractHandlerTest
20
  {
vendor/symfony/css-selector/Tests/Parser/Handler/IdentifierHandlerTest.php CHANGED
@@ -13,8 +13,8 @@ namespace Symfony\Component\CssSelector\Tests\Parser\Handler;
13
 
14
  use Symfony\Component\CssSelector\Parser\Handler\IdentifierHandler;
15
  use Symfony\Component\CssSelector\Parser\Token;
16
- use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
17
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
 
18
 
19
  class IdentifierHandlerTest extends AbstractHandlerTest
20
  {
13
 
14
  use Symfony\Component\CssSelector\Parser\Handler\IdentifierHandler;
15
  use Symfony\Component\CssSelector\Parser\Token;
 
16
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
17
+ use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
18
 
19
  class IdentifierHandlerTest extends AbstractHandlerTest
20
  {
vendor/symfony/css-selector/Tests/Parser/Handler/StringHandlerTest.php CHANGED
@@ -13,8 +13,8 @@ namespace Symfony\Component\CssSelector\Tests\Parser\Handler;
13
 
14
  use Symfony\Component\CssSelector\Parser\Handler\StringHandler;
15
  use Symfony\Component\CssSelector\Parser\Token;
16
- use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
17
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
 
18
 
19
  class StringHandlerTest extends AbstractHandlerTest
20
  {
13
 
14
  use Symfony\Component\CssSelector\Parser\Handler\StringHandler;
15
  use Symfony\Component\CssSelector\Parser\Token;
 
16
  use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping;
17
+ use Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns;
18
 
19
  class StringHandlerTest extends AbstractHandlerTest
20
  {
vendor/symfony/css-selector/Tests/Parser/ParserTest.php CHANGED
@@ -186,6 +186,7 @@ class ParserTest extends TestCase
186
  array('foo:after', 'Element[foo]', 'after'),
187
  array('foo::selection', 'Element[foo]', 'selection'),
188
  array('lorem#ipsum ~ a#b.c[href]:empty::selection', 'CombinedSelector[Hash[Element[lorem]#ipsum] ~ Pseudo[Attribute[Class[Hash[Element[a]#b].c][href]]:empty]]', 'selection'),
 
189
  );
190
  }
191
 
186
  array('foo:after', 'Element[foo]', 'after'),
187
  array('foo::selection', 'Element[foo]', 'selection'),
188
  array('lorem#ipsum ~ a#b.c[href]:empty::selection', 'CombinedSelector[Hash[Element[lorem]#ipsum] ~ Pseudo[Attribute[Class[Hash[Element[a]#b].c][href]]:empty]]', 'selection'),
189
+ array('video::-webkit-media-controls', 'Element[video]', '-webkit-media-controls'),
190
  );
191
  }
192
 
vendor/symfony/css-selector/Tests/XPath/TranslatorTest.php CHANGED
@@ -37,9 +37,9 @@ class TranslatorTest extends TestCase
37
  $translator = new Translator();
38
  $document = new \SimpleXMLElement(file_get_contents(__DIR__.'/Fixtures/lang.xml'));
39
  $elements = $document->xpath($translator->cssToXPath($css));
40
- $this->assertCount(count($elementsId), $elements);
41
  foreach ($elements as $element) {
42
- $this->assertTrue(in_array($element->attributes()->id, $elementsId));
43
  }
44
  }
45
 
@@ -54,10 +54,10 @@ class TranslatorTest extends TestCase
54
  $document->loadHTMLFile(__DIR__.'/Fixtures/ids.html');
55
  $document = simplexml_import_dom($document);
56
  $elements = $document->xpath($translator->cssToXPath($css));
57
- $this->assertCount(count($elementsId), $elementsId);
58
  foreach ($elements as $element) {
59
  if (null !== $element->attributes()->id) {
60
- $this->assertTrue(in_array($element->attributes()->id, $elementsId));
61
  }
62
  }
63
  libxml_clear_errors();
37
  $translator = new Translator();
38
  $document = new \SimpleXMLElement(file_get_contents(__DIR__.'/Fixtures/lang.xml'));
39
  $elements = $document->xpath($translator->cssToXPath($css));
40
+ $this->assertCount(\count($elementsId), $elements);
41
  foreach ($elements as $element) {
42
+ $this->assertTrue(\in_array($element->attributes()->id, $elementsId));
43
  }
44
  }
45
 
54
  $document->loadHTMLFile(__DIR__.'/Fixtures/ids.html');
55
  $document = simplexml_import_dom($document);
56
  $elements = $document->xpath($translator->cssToXPath($css));
57
+ $this->assertCount(\count($elementsId), $elementsId);
58
  foreach ($elements as $element) {
59
  if (null !== $element->attributes()->id) {
60
+ $this->assertTrue(\in_array($element->attributes()->id, $elementsId));
61
  }
62
  }
63
  libxml_clear_errors();
vendor/symfony/css-selector/XPath/Extension/AttributeMatchingExtension.php CHANGED
@@ -128,7 +128,7 @@ class AttributeMatchingExtension extends AbstractExtension
128
  return $xpath->addCondition($value ? sprintf(
129
  '%1$s and substring(%1$s, string-length(%1$s)-%2$s) = %3$s',
130
  $attribute,
131
- strlen($value) - 1,
132
  Translator::getXpathLiteral($value)
133
  ) : '0');
134
  }
128
  return $xpath->addCondition($value ? sprintf(
129
  '%1$s and substring(%1$s, string-length(%1$s)-%2$s) = %3$s',
130
  $attribute,
131
+ \strlen($value) - 1,
132
  Translator::getXpathLiteral($value)
133
  ) : '0');
134
  }
vendor/symfony/css-selector/XPath/Extension/FunctionExtension.php CHANGED
@@ -150,10 +150,7 @@ class FunctionExtension extends AbstractExtension
150
  $arguments = $function->getArguments();
151
  foreach ($arguments as $token) {
152
  if (!($token->isString() || $token->isIdentifier())) {
153
- throw new ExpressionErrorException(
154
- 'Expected a single string or identifier for :contains(), got '
155
- .implode(', ', $arguments)
156
- );
157
  }
158
  }
159
 
@@ -173,10 +170,7 @@ class FunctionExtension extends AbstractExtension
173
  $arguments = $function->getArguments();
174
  foreach ($arguments as $token) {
175
  if (!($token->isString() || $token->isIdentifier())) {
176
- throw new ExpressionErrorException(
177
- 'Expected a single string or identifier for :lang(), got '
178
- .implode(', ', $arguments)
179
- );
180
  }
181
  }
182
 
150
  $arguments = $function->getArguments();
151
  foreach ($arguments as $token) {
152
  if (!($token->isString() || $token->isIdentifier())) {
153
+ throw new ExpressionErrorException('Expected a single string or identifier for :contains(), got '.implode(', ', $arguments));
 
 
 
154
  }
155
  }
156
 
170
  $arguments = $function->getArguments();
171
  foreach ($arguments as $token) {
172
  if (!($token->isString() || $token->isIdentifier())) {
173
+ throw new ExpressionErrorException('Expected a single string or identifier for :lang(), got '.implode(', ', $arguments));
 
 
 
174
  }
175
  }
176
 
vendor/symfony/css-selector/XPath/Extension/HtmlExtension.php CHANGED
@@ -158,10 +158,7 @@ class HtmlExtension extends AbstractExtension
158
  $arguments = $function->getArguments();
159
  foreach ($arguments as $token) {
160
  if (!($token->isString() || $token->isIdentifier())) {
161
- throw new ExpressionErrorException(
162
- 'Expected a single string or identifier for :lang(), got '
163
- .implode(', ', $arguments)
164
- );
165
  }
166
  }
167
 
158
  $arguments = $function->getArguments();
159
  foreach ($arguments as $token) {
160
  if (!($token->isString() || $token->isIdentifier())) {
161
+ throw new ExpressionErrorException('Expected a single string or identifier for :lang(), got '.implode(', ', $arguments));
 
 
 
162
  }
163
  }
164
 
vendor/symfony/css-selector/XPath/Translator.php CHANGED
@@ -89,7 +89,7 @@ class Translator implements TranslatorInterface
89
  }
90
  }
91
 
92
- return sprintf('concat(%s)', implode($parts, ', '));
93
  }
94
 
95
  /**
@@ -176,7 +176,7 @@ class Translator implements TranslatorInterface
176
  throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName()));
177
  }
178
 
179
- return call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this);
180
  }
181
 
182
  /**
@@ -194,7 +194,7 @@ class Translator implements TranslatorInterface
194
  throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner));
195
  }
196
 
197
- return call_user_func($this->combinationTranslators[$combiner], $this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
198
  }
199
 
200
  /**
@@ -208,7 +208,7 @@ class Translator implements TranslatorInterface
208
  throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName()));
209
  }
210
 
211
- return call_user_func($this->functionTranslators[$function->getName()], $xpath, $function);
212
  }
213
 
214
  /**
@@ -225,7 +225,7 @@ class Translator implements TranslatorInterface
225
  throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass));
226
  }
227
 
228
- return call_user_func($this->pseudoClassTranslators[$pseudoClass], $xpath);
229
  }
230
 
231
  /**
@@ -244,7 +244,7 @@ class Translator implements TranslatorInterface
244
  throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator));
245
  }
246
 
247
- return call_user_func($this->attributeMatchingTranslators[$operator], $xpath, $attribute, $value);
248
  }
249
 
250
  /**
89
  }
90
  }
91
 
92
+ return sprintf('concat(%s)', implode(', ', $parts));
93
  }
94
 
95
  /**
176
  throw new ExpressionErrorException(sprintf('Node "%s" not supported.', $node->getNodeName()));
177
  }
178
 
179
+ return \call_user_func($this->nodeTranslators[$node->getNodeName()], $node, $this);
180
  }
181
 
182
  /**
194
  throw new ExpressionErrorException(sprintf('Combiner "%s" not supported.', $combiner));
195
  }
196
 
197
+ return \call_user_func($this->combinationTranslators[$combiner], $this->nodeToXPath($xpath), $this->nodeToXPath($combinedXpath));
198
  }
199
 
200
  /**
208
  throw new ExpressionErrorException(sprintf('Function "%s" not supported.', $function->getName()));
209
  }
210
 
211
+ return \call_user_func($this->functionTranslators[$function->getName()], $xpath, $function);
212
  }
213
 
214
  /**
225
  throw new ExpressionErrorException(sprintf('Pseudo-class "%s" not supported.', $pseudoClass));
226
  }
227
 
228
+ return \call_user_func($this->pseudoClassTranslators[$pseudoClass], $xpath);
229
  }
230
 
231
  /**
244
  throw new ExpressionErrorException(sprintf('Attribute matcher operator "%s" not supported.', $operator));
245
  }
246
 
247
+ return \call_user_func($this->attributeMatchingTranslators[$operator], $xpath, $attribute, $value);
248
  }
249
 
250
  /**
vendor/symfony/css-selector/phpunit.xml.dist CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0" encoding="UTF-8"?>
2
 
3
  <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
- xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
5
  backupGlobals="false"
6
  colors="true"
7
  bootstrap="vendor/autoload.php"
1
  <?xml version="1.0" encoding="UTF-8"?>
2
 
3
  <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
+ xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/5.2/phpunit.xsd"
5
  backupGlobals="false"
6
  colors="true"
7
  bootstrap="vendor/autoload.php"
vendor/wp-coding-standards/wpcs/.gitattributes CHANGED
@@ -5,6 +5,7 @@
5
  # https://blog.madewithlove.be/post/gitattributes/
6
  #
7
  /.travis.yml export-ignore
 
8
  /phpunit.xml.dist export-ignore
9
  /.github export-ignore
10
  /bin export-ignore
5
  # https://blog.madewithlove.be/post/gitattributes/
6
  #
7
  /.travis.yml export-ignore
8
+ /.phpcs.xml.dist export-ignore
9
  /phpunit.xml.dist export-ignore
10
  /.github export-ignore
11
  /bin export-ignore
vendor/wp-coding-standards/wpcs/.gitignore CHANGED
@@ -1,6 +1,5 @@
1
- .buildpath
2
- .project
3
- .settings/
4
  vendor
5
  composer.lock
6
  phpunit.xml
 
 
 
 
 
1
  vendor
2
  composer.lock
3
  phpunit.xml
4
+ phpcs.xml
5
+ .phpcs.xml
vendor/wp-coding-standards/wpcs/CHANGELOG.md CHANGED
@@ -2,11 +2,291 @@
2
 
3
  All notable changes to this project will be documented in this file.
4
 
5
- This projects adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com/).
6
 
7
  ## [Unreleased]
8
 
9
- _Nothing yet._
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
 
12
  ## [0.14.1] - 2018-02-15
@@ -46,8 +326,8 @@ _Nothing yet._
46
  - The `WordPress.VIP.CronInterval` sniff now allows for customizing the minimum allowed cron interval by [setting a property in a custom ruleset](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#vip-croninterval-minimum-interval).
47
  - The `WordPress.VIP.RestrictedFunctions` sniff used to prohibit the use of certain WP native functions, recommending the use of `wpcom_vip_get_term_link()`, `wpcom_vip_get_term_by()` and `wpcom_vip_get_category_by_slug()` instead, as the WP native functions were not being cached. As the results of the relevant WP native functions are cached as of WP 4.8, the advice has now been reversed i.e. use the WP native functions instead of `wpcom...` functions.
48
  - The `WordPress.VIP.PostsPerPage` sniff now allows for customizing the `post_per_page` limit for which the sniff will trigger by [setting a property in a custom ruleset](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#vip-postsperpage-post-limit).
49
- - The `WordPress.WP.I18n` sniff will now allow and actively encourage omitting the text-domain in I18n function calls if the text-domain passed via the `text_domain` property is `default`, i.e. the domain used by Core.
50
- When `default` is one of several text-domains passed via the `text_domain` property, the error thrown when the domain is missing has been downgraded to a `warning`.
51
  - The `WordPress.XSS.EscapeOutput` sniff now has a separate error code `OutputNotEscapedShortEcho` and the error message texts have been updated.
52
  - Moved `Squiz.PHP.Eval` from the `WordPress-Extra` and `WordPress-VIP` to the `WordPress-Core` ruleset.
53
  - Removed two sniffs from the `WordPress-VIP` ruleset which were already included via the `WordPress-Core` ruleset.
@@ -296,7 +576,7 @@ You are also encouraged to check the file history of any WPCS classes you extend
296
  ## [0.10.0] - 2016-08-29
297
 
298
  ### Added
299
- - `WordPress.WP.I18n` sniff to the `WordPress-Core` ruleset to flag dynamic translatable strings and textdomains.
300
  - `WordPress.PHP.DisallowAlternativePHPTags` sniff to the `WordPress-Core` ruleset to flag - and fix - ASP and `<script>` PHP open tags.
301
  - `WordPress.Classes.ClassOpeningStatement` sniff to the `WordPress-Core` ruleset to flag - and fix - class opening brace placement.
302
  - `WordPress.NamingConventions.ValidHookName` sniff to the `WordPress-Core` ruleset to flag filter and action hooks which don't comply with the guideline of lowercase letters and underscores. For maintaining backward-compatibility of hook names an `additionalWordDelimiters` property can be added via a custom ruleset.
@@ -309,7 +589,7 @@ You are also encouraged to check the file history of any WPCS classes you extend
309
  - Ability to use a whitelist comment for tax queries for the `WordPress.VIP.SlowDBQuery` sniff.
310
  - Instructions on how to use WPCS with Atom and SublimeLinter to the Readme.
311
  - Reference to the [wiki](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki) to the Readme.
312
- - Recommendation to also use the [PHPCompatibility](https://github.com/wimg/PHPCompatibility) ruleset to the Readme.
313
 
314
  ### Changed
315
  - The minimum required PHP_CodeSniffer version to 2.6.0.
@@ -530,6 +810,9 @@ See the comparison for full list.
530
  Initial tagged release.
531
 
532
  [Unreleased]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/master...HEAD
 
 
 
533
  [0.14.1]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.14.0...0.14.1
534
  [0.14.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.13.1...0.14.0
535
  [0.13.1]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.13.0...0.13.1
2
 
3
  All notable changes to this project will be documented in this file.
4
 
5
+ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).
6
 
7
  ## [Unreleased]
8
 
9
+ _No documentation available about unreleased changes as of yet._
10
+
11
+ ## [1.2.0] - 2018-11-12
12
+
13
+ ### Added
14
+ - New `WordPress.PHP.TypeCasts` sniff to the `WordPress-Core` ruleset.
15
+ This new sniff checks that PHP type casts are:
16
+ * lowercase;
17
+ * short form, i.e. `(bool)` not `(boolean)`;
18
+ * normalized, i.e. `(float)` not `(real)`.
19
+ Additionally, the new sniff discourages the use of the `(unset)` and `(binary)` type casts.
20
+ - New `WordPress.Utils.I18nTextDomainFixer` sniff which can compehensively replace/add `text-domain`s in a plugin or theme.
21
+ Important notes:
22
+ - This sniff is disabled by default and intended as a utility tool.
23
+ - The sniff will fix the text domains in all I18n function calls as well as in a plugin/theme `Text Domain:` header.
24
+ - Passing the following properties will activate the sniff:
25
+ - `old_text_domain`: an array with one or more (old) text domains which need to be replaced;
26
+ - `new_text_domain`: the correct (new) text domain as a string.
27
+ - The `WordPress.NamingConventions.PrefixAllGlobals` sniff will now also verify that namespace names use a valid prefix.
28
+ * The sniff allows for underscores and (other) non-word characters in a passed prefix to be converted to namespace separators when used in a namespace name.
29
+ In other words, if a prefix of `my_plugin` is passed as a value to the `prefixes` property, a namespace name of both `My\Plugin` as well as `My_Plugin\\`, will be accepted automatically.
30
+ * Passing a prefix property value containing namespace separators will now also be allowed and will no longer trigger a warning.
31
+ - `WordPress` to the prefix blacklist for the `WordPress.NamingConventions.PrefixAllGlobals` sniff.
32
+ While the prefix cannot be `WordPress`, a prefix can still _start with_ or _contain_ `WordPress`.
33
+ - Additional unit tests covering a change in the tokenizer which will be included in the upcoming `PHP_CodeSniffer` 3.4.0 release.
34
+ - A variety of issue templates for use on GitHub.
35
+
36
+ ### Changed
37
+ - The `Sniff::valid_direct_scope()` method will now return the `$stackPtr` to the valid scope if a valid direct scope has been detected. Previously, it would return `true`.
38
+ - Minor hardening and efficiency improvements to the `WordPress.NamingConventions.PrefixAllGlobals` sniff.
39
+ - The inline documentation of the `WordPress-Core` ruleset has been updated to be in line again with [the handbook](https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/).
40
+ - The inline links to documentation about the VIP requirements have been updated.
41
+ - Updated the [custom ruleset example](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) to recommend using `PHPCompatibilityWP` rather than `PHPCompatibility`.
42
+ - All sniffs are now also being tested against PHP 7.3 for consistent sniff results.
43
+ Note: PHP 7.3 is only supported in combination with PHPCS 3.3.1 or higher as `PHP_CodeSniffer` itself has an incompatibility in earlier versions.
44
+ - Minor grammar fixes in text strings and documentation.
45
+ - Minor consistency improvement for the unit test case files.
46
+ - Minor tweaks to the `composer.json` file.
47
+ - Updated the PHPCompatibility `dev` dependency.
48
+
49
+ ### Removed
50
+ - The `WordPress.WhiteSpace.CastStructureSpacing.NoSpaceAfterCloseParenthesis` error code as an error for the same issue was already being thrown by an included upstream sniff.
51
+
52
+ ### Fixed
53
+ - The `WordPress.CodeAnalysis.EmptyStatement` would throw a false positive for an empty condition in a `for()` statement.
54
+ - The `Sniff::is_class_property()` method could, in certain circumstances, incorrectly recognize parameters in a method declaration as class properties. It would also, incorrectly, fail to recognize class properties when the object they are declared in, was nested in parentheses.
55
+ This affected, amongst others, the `GlobalVariablesOverride` sniff.
56
+ - The `Sniff::get_declared_namespace_name()` method could get confused over whitespace and comments within a namespace name, which could lead to incorrect results (mostly underreporting).
57
+ This affected, amongst others, the `GlobalVariablesOverride` sniff.
58
+ The return value of the method will now no longer contain any whitespace or comments encountered.
59
+ - The `Sniff::has_whitelist_comment()` method would sometimes incorrectly regard `// phpcs:set` comments as whitelist comments.
60
+
61
+ ## [1.1.0] - 2018-09-10
62
+
63
+ ### Added
64
+ - New `WordPress.PHP.NoSilencedErrors` sniff. This sniff replaces the `Generic.PHP.NoSilencedErrors` sniff which was previously used and included in the `WordPress-Core` ruleset.
65
+ The WordPress specific version of the sniff differs from the PHPCS version in that it:
66
+ * Allows the error control operator `@` if it preceeds a function call to a limited list of PHP functions for which no amount of error checking can prevent a PHP warning from being thrown.
67
+ * Allows for a used-defined list of (additional) function names to be passed to the sniff via the `custom_whitelist` property in a custom ruleset, for which - if the error control operator is detected in front of a function call to one of the functions in this whitelist - no warnings will be thrown.
68
+ * Displays a brief snippet of code in the `warning` message text to show the context in which the error control operator is being used. The length of the snippet (in tokens) can be customized via the `context_length` property.
69
+ * Contains a public `use_default_whitelist` property which can be set from a custom ruleset which regulates whether or not the standard whitelist of PHP functions should be used by the sniff.
70
+ The user-defined whitelist will always be respected.
71
+ By default, this property is set to `true` for the `WordPress-Core` ruleset and to `false` for the `WordPress-Extra` ruleset (which is stricter regarding these kind of best practices).
72
+ - Metrics to the `WordPress.NamingConventions.PrefixAllGlobals` sniff to aid people in determining the most commonly used prefix in a legacy project.
73
+ For an example of how to use this feature, please see the detailed explanation in the [pull request](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/1437).
74
+
75
+ ### Changed
76
+ - The `PEAR.Functions.FunctionCallSignature` sniff, which is part of the `WordPress-Core` ruleset, used to allow multiple function call parameters per line in multi-line function calls. This will no longer be allowed.
77
+ As of this release, if a function call is multi-line, each parameter should start on a new line and an `error` will be thrown if the code being analysed does not comply with that rule.
78
+ The sniff behaviour for single-line function calls is not affected by this change.
79
+ - Moved the `WordPress.CodeAnalysis.EmptyStatement` sniff from the `WordPress-Extra` to the `WordPress-Core` ruleset.
80
+ - Moved the `Squiz.PHP.CommentedOutCode` sniff from the `WordPress-Docs` to the `WordPress-Extra` ruleset and lowered the threshold for determining whether or not a comment is commented out code from 45% to 40%.
81
+ - The `WordPress.NamingConventions.PrefixAllGlobals` sniff now has improved support for recognizing whether or not (non-prefixed) globals are declared in the context of unit tests.
82
+ - The `is_foreach_as()` method has been moved from the `GlobalVariablesOverrideSniff` class to the WordPress `Sniff` base class.
83
+ - The `Sniff::is_token_in_test_method()` utility method now has improved support for recognizing test methods in anonymous classes.
84
+ - Minor efficiency improvement to the `Sniff::is_safe_casted()` method.
85
+ - CI: Minor tweaks to the Travis script.
86
+ - CI: Improved Composer scripts for use by WPCS developers.
87
+ - Dev: Removed IDE specific files from `.gitignore`.
88
+ - Readme: Improved the documentation about the project history and the badge display.
89
+
90
+ ### Fixed
91
+ - The `WordPress.Security.ValidatedSanitizedInput` sniff will now recognize array keys in superglobals independently of the string quote-style used for the array key.
92
+ - The `WordPress.WhiteSpace.PrecisionAlignment` sniff will no longer throw false positives for DocBlocks for JavaScript functions within inline HTML.
93
+ - `WordPress.WP.DeprecatedClasses`: The error codes for this sniff were unstable as they were based on the code being analysed instead of on fixed values.
94
+ - Various bugfixes for the `WordPress.WP.GlobalVariablesOverride` sniff:
95
+ - Previously, the sniff only checked variables in the global namespace when a `global` statement would be encountered. As of now, all variable assignments in the global namespace will be checked.
96
+ - Nested functions/closures/classes which don't import the global variable will now be skipped over when encountered within another function, preventing false positives.
97
+ - Parameters in function declarations will no longer throw false positives.
98
+ - The error message for assignments to a subkey of the `$GLOBALS` superglobal has been improved.
99
+ - Various efficiency improvements.
100
+ - The `Sniff::is_in_isset_or_empty()` method presumed the WordPress coding style regarding code layout, which could lead to incorrect results (mostly underreporting).
101
+ This affected, amongst others, the `WordPress.Security.ValidatedSanitizedInput` sniff.
102
+ - Broken links in the inline developer documentation.
103
+
104
+
105
+ ## [1.0.0] - 2018-07-25
106
+
107
+ ### Important information about this release:
108
+
109
+ If you use the WordPress Coding Standards with a custom ruleset, please be aware that a number of sniffs have been moved between categories and that the old sniff names have been deprecated.
110
+ If you selectively include any of these sniffs in your custom ruleset or set custom property values for these sniffs, your custom ruleset will need to be updated.
111
+
112
+ The `WordPress-VIP` ruleset has also been deprecated. If you used that ruleset to check your theme/plugin for hosting on the WordPress.com VIP platform, please use the [Automattic VIP coding standards](https://github.com/Automattic/VIP-Coding-Standards) instead.
113
+ If you used that ruleset for any other reason, you should probably use the `WordPress-Extra` or `WordPress` ruleset instead.
114
+
115
+ These and some related changes have been annotated in detail in the `Deprecated` section of this changelog.
116
+
117
+ Please read the complete changelog carefully before you upgrade.
118
+
119
+ If you are a maintainer of an external standard based on WPCS and any of your custom sniffs are based on or extend WPCS sniffs, the same applies.
120
+
121
+ ### Added
122
+ - `WordPress.PHP.PregQuoteDelimiter` sniff to the `WordPress-Extra` ruleset to warn about calls to `preg_quote()` which don't pass the `$delimiter` parameter.
123
+ - `WordPress.Security.SafeRedirect` sniff to the `WordPress-Extra` ruleset to warn about potential open redirect vulnerabilities.
124
+ - `WordPress.WP.DeprecatedParameterValues` sniff to the `WordPress-Extra` ruleset to detect deprecated parameter values being passed to select functions.
125
+ - `WordPress.WP.EnqueuedResourceParameters` sniff to the `WordPress-Extra` ruleset to detect:
126
+ - Calls to the script/style register/enqueue functions which don't pass a `$version` for the script/style, which can cause issues with browser caching; and/or
127
+ - Calls to the register/enqueue script functions which don't pass the `$in_footer` parameter, which causes scripts - by default - to be loaded in the HTML header in a layout rendering blocking manner.
128
+ - Detection of calls to `strip_tags()` and various PHP native `..rand()` functions to the `WordPress.WP.AlternativeFunctions` sniff.
129
+ - `readonly()` to the list of auto-escaped functions `Sniff::$autoEscapedFunctions`. This affects the `WordPress.Security.EscapeOutput` sniff.
130
+ - The `WordPress.Security.PluginMenuSlug`, `WordPress.WP.CronInterval`, `WordPress.WP.PostsPerPage` and `WordPress.WP.TimezoneChange` sniffs are now included in the `WordPress-Extra` ruleset. Previously, they were already included in the `WordPress` and `WordPress-VIP` rulesets.
131
+ - New utility method `Sniff::is_use_of_global_constant()`.
132
+ - A rationale to the package suggestion made via `composer.json`.
133
+ - CI: Validation of the `composer.json` file on each build.
134
+ - A wiki page with instructions on how to [set up WPCS to run with Eclipse on XAMPP](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/How-to-use-WPCS-with-Eclipse-and-XAMPP).
135
+ - Readme: A link to an external resource with more examples for setting up PHPCS for CI.
136
+ - Readme: A badge-based quick overview of the project.
137
+
138
+ ### Changed
139
+ - The `WordPress` ruleset no longer includes the `WordPress-VIP` ruleset, nor does it include any of the (deprecated) `VIP` sniffs anymore.
140
+ - The following sniffs have been moved to a new category:
141
+ - `CronInterval` from the `VIP` category to the `WP` category.
142
+ - `DirectDatabaseQuery` from the `VIP` category to the `DB` category.
143
+ - `DontExtract` from the `Functions` category to the `PHP` category.
144
+ - `EscapeOutput` from the `XSS` category to the `Security` category.
145
+ - `GlobalVariables` from the `Variables` category to the `WP` category.
146
+ - `NonceVerification` from the `CSRF` category to the `Security` category.
147
+ - `PluginMenuSlug` from the `VIP` category to the `Security` category.
148
+ - `PreparedSQL` from the `WP` category to the `DB` category.
149
+ - `SlowDBQuery` from the `VIP` category to the `DB` category.
150
+ - `TimezoneChange` from the `VIP` category to the `WP` category.
151
+ - `ValidatedSanitizedInput` from the `VIP` category to the `Security` category.
152
+ - The `WordPress.VIP.PostsPerPage` sniff has been split into two distinct sniffs:
153
+ - `WordPress.WP.PostsPerPage` which will check for the use of a high pagination limit and will throw a `warning` when this is encountered. For the `VIP` ruleset, the error level remains `error`.
154
+ - `WordPress.VIP.PostsPerPage` wich will check for disabling of pagination.
155
+ - The default value for `minimum_supported_wp_version`, as used by a [number of sniffs detecting usage of deprecated WP features](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#minimum-wp-version-to-check-for-usage-of-deprecated-functions-classes-and-function-parameters), has been updated to `4.6`.
156
+ - The `WordPress.WP.AlternativeFunctions` sniff will now only throw a warning if/when the recommended alternative function is available in the minimum supported WP version of a project.
157
+ In addition to this, certain alternatives are only valid alternatives in certain circumstances, like when the WP version only supports the first parameter of the PHP function it is trying to replace.
158
+ This will now be taken into account for:
159
+ - `wp_strip_all_tags()` is only a valid alternative for the PHP native `strip_tags()` when the second parameter `$allowed_tags` has not been passed.
160
+ - `wp_parse_url()` only added support for the second parameter `$component` of the PHP native `parse_url()` function in WP 4.7.0.
161
+ - The `WordPress.WP.DeprecatedFunctions` sniff will now detect functions deprecated in WP 4.9.
162
+ - The `WordPress.WP.GlobalVariablesOverride` sniff will now display the name of the variable being overridden in the error message.
163
+ - The `WordPress.WP.I18n` sniff now extends the `AbstractFunctionRestrictionSniff`.
164
+ - Assignments in conditions in ternaries as detected by the `WordPress.CodeAnalysis.AssignmentInCondition` sniff will now be reported under a separate error code `FoundInTernaryCondition`.
165
+ - The default error level for the notices from the `WordPress.DB.DirectDatabaseQuery` sniff has been lowered from `error` to `warning`. For the `VIP` ruleset, the error level remains `error`.
166
+ - The default error level for the notices from the `WordPress.Security.PluginMenuSlug` sniff has been lowered from `error` to `warning`. For the `VIP` ruleset, the error level remains `error`.
167
+ - The default error level for the notices from the `WordPress.WP.CronInterval` sniff has been lowered from `error` to `warning`. For the `VIP` ruleset, the error level remains `error`.
168
+ - The `Sniff::get_function_call_parameters()` utility method now has improved handling of closures when passed as function call parameters.
169
+ - Rulesets: a number of error codes were previously silenced by explicitly `exclude`-ing them. Now, they will be silenced by setting the `severity` to `0` which makes it more easily discoverable for maintainers of custom rulesets how to enable these error codes again.
170
+ - Various performance optimizations which should most notably make a difference when running WPCS on PHP 7.
171
+ - References to the WordPress.com VIP platform have been clarified.
172
+ - Unit Tests: custom properties set in unit test files are reset after use.
173
+ - Various improvements to the ruleset used by the WPCS project itself and minor code clean up related to this.
174
+ - CI: Each change will now also be tested against the lowest supported PHPCS 3 version.
175
+ - CI: Each change will now also be checked for PHP cross-version compatibility.
176
+ - CI: The rulesets will now also be tested on each change to ensure no unexpected messages are thrown.
177
+ - CI: Minor changes to the script to make the build testing faster.
178
+ - Updated the [custom ruleset example](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/phpcs.xml.dist.sample) for the changes contained in this release and to reflect current best practices regarding the PHPCompatibility standard.
179
+ - The instructions on how to set up WPCS for various IDEs have been moved from the `README` to the [wiki](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki).
180
+ - Updated output examples in `README.md` and `CONTRIBUTING.md` and other minor changes to these files.
181
+ - Updated references to the PHPCompatibility standard to reflect its new location and recommend using PHPCompatibilityWP.
182
+
183
+ ### Deprecated
184
+ - The `WordPress-VIP` ruleset has been deprecated.
185
+ For checking a theme/plugin for hosting on the WordPress.com VIP platform, please use the [Automattic VIP coding standards](https://github.com/Automattic/VIP-Coding-Standards) instead.
186
+ If you used the `WordPress-VIP` ruleset for any other reason, you should probably use the `WordPress-Extra` or `WordPress` ruleset instead.
187
+ - The following sniffs have been deprecated and will be removed in WPCS 2.0.0:
188
+ - `WordPress.CSRF.NonceVerification` - use `WordPress.Security.NonceVerification` instead.
189
+ - `WordPress.Functions.DontExtract` - use `WordPress.PHP.DontExtract` instead.
190
+ - `WordPress.Variables.GlobalVariables` - use `WordPress.WP.GlobalVariablesOverride` instead.
191
+ - `WordPress.VIP.CronInterval` - use `WordPress.WP.CronInterval` instead.
192
+ - `WordPress.VIP.DirectDatabaseQuery` - use `WordPress.DB.DirectDatabaseQuery` instead.
193
+ - `WordPress.VIP.PluginMenuSlug` - use `WordPress.Security.PluginMenuSlug` instead.
194
+ - `WordPress.VIP.SlowDBQuery` - use `WordPress.DB.SlowDBQuery` instead.
195
+ - `WordPress.VIP.TimezoneChange` - use `WordPress.WP.TimezoneChange` instead.
196
+ - `WordPress.VIP.ValidatedSanitizedInput` - use `WordPress.Security.ValidatedSanitizedInput` instead.
197
+ - `WordPress.WP.PreparedSQL` - use `WordPress.DB.PreparedSQL` instead.
198
+ - `WordPress.XSS.EscapeOutput` - use `WordPress.Security.EscapeOutput` instead.
199
+ - `WordPress.VIP.AdminBarRemoval` without replacement.
200
+ - `WordPress.VIP.FileSystemWritesDisallow` without replacement.
201
+ - `WordPress.VIP.OrderByRand` without replacement.
202
+ - `WordPress.VIP.RestrictedFunctions` without replacement.
203
+ - `WordPress.VIP.RestrictedVariables` without replacement.
204
+ - `WordPress.VIP.SessionFunctionsUsage` without replacement.
205
+ - `WordPress.VIP.SessionVariableUsage` without replacement.
206
+ - `WordPress.VIP.SuperGlobalInputUsage` without replacement.
207
+ - The following sniff categories have been deprecated and will be removed in WPCS 2.0.0:
208
+ - `CSRF`
209
+ - `Variables`
210
+ - `XSS`
211
+ - The `posts_per_page` property in the `WordPress.VIP.PostsPerPage` sniff has been deprecated as the related functionality has been moved to the `WordPress.WP.PostsPerPage` sniff.
212
+ See [WP PostsPerPage: post limit](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#wp-postsperpage-post-limit) for more information about this property.
213
+ - The `exclude` property which is available to most sniffs which extend the `AbstractArrayAssignmentRestrictions`, `AbstractFunctionRestrictions` and `AbstractVariableRestrictions` classes or any of their children, used to be a `string` property and expected a comma-delimited list of groups to exclude.
214
+ The type of the property has now been changed to `array`. Custom rulesets which pass this property need to be adjusted to reflect this change.
215
+ Support for passing the property as a comma-delimited string has been deprecated and will be removed in WPCS 2.0.0.
216
+ See [Excluding a group of checks](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#excluding-a-group-of-checks) for more information about the sniffs affected by this change.
217
+ - The `AbstractVariableRestrictionsSniff` class has been deprecated as all sniffs depending on this class have been deprecated. Unless a new sniff is created in the near future which uses this class, the abstract class will be removed in WPCS 2.0.0.
218
+ - The `Sniff::has_html_open_tag()` utility method has been deprecated as it is now only used by deprecated sniffs. The method will be removed in WPCS 2.0.0.
219
+
220
+ ### Removed
221
+ - `cancel_comment_reply_link()`, `get_bookmark()`, `get_comment_date()`, `get_comment_time()`, `get_template_part()`, `has_post_thumbnail()`, `is_attachement()`, `post_password_required()` and `wp_attachment_is_image()` from the list of auto-escaped functions `Sniff::$autoEscapedFunctions`. This affects the `WordPress.Security.EscapeOutput` sniff.
222
+ - WPCS no longer explicitly supports HHVM and builds are no longer tested against HHVM.
223
+ For now, running WPCS on HHVM to test PHP code may still work for a little while, but HHVM has announced they are [dropping PHP support](https://hhvm.com/blog/2017/09/18/the-future-of-hhvm.html).
224
+
225
+ ### Fixed
226
+ - Compatibility with PHP 7.3. A change in PHP 7.3 was causing the `WordPress.DB.RestrictedClasses`, `WordPress.DB.RestrictedFunctions` and the `WordPress.WP.AlternativeFunctions` sniffs to fail to correctly detect issues.
227
+ - Compatibility with the latest releases from [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer).
228
+ PHPCS 3.2.0 introduced new annotations which can be used inline to selectively disable/ignore certain sniffs.
229
+ **Note**: The initial implementation of the new annotations was buggy. If you intend to start using these new style annotations, you are strongly advised to use PHPCS 3.3.0 or higher.
230
+ For more information about these annotations, please refer to the [PHPCS Wiki](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#ignoring-parts-of-a-file).
231
+ - The [WPCS native whitelist comments](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Whitelisting-code-which-flags-errors) can now be combined with the new style PHPCS whitelist annotations in the `-- for reasons` part of the annotation.
232
+ - `WordPress.Arrays.ArrayDeclarationSpacing`: the fixer will now handle the new style annotations correctly.
233
+ - `WordPress.Arrays.CommaAfterArrayItem`: prevent a fixer loop when new style annotations are encountered.
234
+ - `WordPress.Files.FileName`: respect the new style annotations if these would selectively disable this sniff.
235
+ - `WordPress.WhiteSpace.ControlStructureSpacing`: handle the new style annotations correctly for the "blank line at the start/end of control structure" checks and prevent a fixer conflict when the new style annotations are encountered.
236
+ - `WordPress.WhiteSpace.PrecisionAlignment`: allow for checking of for precision alignment on lines containing new style annotations when `phpcs` is run with `--ignore-annotations`.
237
+ - The `Sniff::is_test_class()` method now has improved recognition of namespaced test classes.
238
+ This positively affects the `WordPress.Files.FileName`, `WordPress.NamingConventions.PrefixAllGlobals` and `WordPress.WP.GlobalVariablesOverride` sniffs, which each allow for test classes to (partially) not comply with the rules these sniffs check for.
239
+ This fixes the following bugs:
240
+ - Namespaced classes where the classname was one of the whitelisted global classes would incorrectly be recognized as a test class, even though they were not the same class.
241
+ This also happened if a namespaced class `extend`ed one of the whitelisted global classes.
242
+ - A namespaced custom test class where the name was split between the namespace declaration and the extended class declaration was not correctly recognized as the whitelisted test class.
243
+ - A namespaced test class which extended another class using a FQCN prefixed with a `\\` would not be correctly recognized.
244
+ - The `custom_test_class_whitelist` property which is available for each of these sniffs expects to be passed a Fully Qualified Class Name. FQCNs prefixed with a global namespace indicator will now be correctly handled.
245
+ - The determination of whether a `T_STRING` is a function call or not has been improved in the `AbstractFunctionRestrictions` class. This improvement benefits all sniffs which extend this abstract and any of its children (> 10 sniffs) and fixes the following false positives:
246
+ - Class declarations will no longer be confused with function calls.
247
+ - Use statement alias declarations will no longer be confused with function calls.
248
+ - Various bugs in the `WordPress.Arrays.ArrayIndentation` sniff:
249
+ - The sniff will no longer throw false positives or try to fix multi-line text strings where the closing quote is on a line by itself.
250
+ - The sniff would go into a fixer loop when it encountered a multi-line trailing comment after an array item.
251
+ - The `WordPress.CodeAnalysis.AssignmentInCondition` was throwing false positives for ternaries in nested, but unrelated, parentheses.
252
+ - The `WordPress.CodeAnalysis.EmptyStatement` and `WordPress.Files.FileName` sniffs underreported as they did not take PHP short open echo tags into account.
253
+ - Various bugs in the `WordPress.NamingConventions.PrefixAllGlobals` sniff:
254
+ - Parameters in a closure declaration were incorrectly being regarded as global variables.
255
+ - Non-prefixed variables created by a `foreach()` construct in the global namespace were previously not detected.
256
+ - Non-prefixed globals found in namespaced test classes should be ignored by the sniff, but were not.
257
+ - Definition of non-prefixed global WP constants which are intended to be overruled, should not trigger an error from this sniff.
258
+ - The sniff presumed the WP naming conventions for PHP constructs, while it should check for the construct being prefixed regardless of whether camelCase, PascalCase, snake_case or other naming conventions are used.
259
+ - The sniff presumed the WP naming conventions for prefixes used in hook names. The sniff will now be more tolerant when non-conventional word separators are used in prefixes for hooks.
260
+ - The `WordPress.NamingConventions.ValidFunctionName` sniff no longer "hides" one message behind another. The sniff will now correctly throw a message about function names not being in `snake_case`, even when the `FunctionDoubleUnderscore` or `MethodDoubleUnderscore` error codes have been excluded.
261
+ - The `WordPress.PHP.StrictInArray` sniff will no longer throw an error when `in_array`, `array_search` or `array_keys` are used in a file `use` statement.
262
+ - Various bugs in the `WordPress.Security.EscapeOutput` sniff:
263
+ - A limited list of native PHP constants which are safe to use, such as `PHP_EOL`, has been added. When any of these constants are encountered, the sniff will no longer demand output escaping for them.
264
+ - The sniff was underreporting issues with variables passed to `trigger_error()`.
265
+ - While reporting an issue, sometimes the wrong error message was used. The sniff logic has been adjusted to prevent this.
266
+ - The sniff will now correctly ignore the open and close brackets of short arrays.
267
+ - The sniff would throw false positives when `echo`, `print`, `exit` or `die` were encountered as constants, function or class names. While it may not be a good idea to use PHP keywords in such a way, it is allowed, so the sniff should handle this correctly.
268
+ - The `WordPress.WhiteSpace.ControlStructureSpacing` sniff would inadvertently throw an error for the spacing around the colon for a return type in a function declaration.
269
+ - The `WordPress.WP.AlternativeFunctions` sniff used to flag all function calls to `file_get_contents()` twice, suggesting to use `wp_remote_get()` - which is only applicable for remote URLs - and the `WP_FileSystem` API - which is not needed when just _reading_ local files. These messages contradicted each other.
270
+ The sniff will now try to determine whether the file requested is local or remote and will only throw a `warning` suggesting to use `wp_remote_get()`, if a remote URL is being requested or when it could not be determined if the requested file is local or remote.
271
+ - The expected default value for `wp_upload_bits()` in the `WordPress.WP.DeprecatedParameters` sniff.
272
+ - The `WordPress.WP.GlobalVariablesOverride` sniff previously did not detect variables created by a `foreach()` construct which would override WP global variables.
273
+ - Various bugs in the `WordPress.WP.I18n` sniff:
274
+ - The sniff will no longer throw false positives for calls to methods carrying the same name as any of the global WP functions being targeted and has improved handling of parse errors and live coding.
275
+ - A numeric `0` would throw a false positive for "no translatable content found".
276
+ - The fixer in the `WordPress.WhiteSpace.ControlStructureSpacing` sniff will no longer inadvertently remove return type declarations.
277
+ - Various bugs in the `WordPress.WhiteSpace.PrecisionAlignment` sniff:
278
+ - Inline HTML before the first PHP open tag was not being examined.
279
+ - Files which only contained short open echo tags for PHP were not being examined.
280
+ - The last line of inline HTML in a file was not being examined.
281
+ - Some best practice sniffs presumed the WordPress coding style regarding code layout, which could lead to incorrect results (mostly underreporting).
282
+ The following sniffs have received fixes related to this:
283
+ - `WordPress.DB.PreparedSQL`
284
+ - `WordPress.NamingConventions.ValidVariableName`
285
+ - `WordPress.WP.CronInterval`
286
+ - `WordPress.WP.I18n`
287
+ - Various minor fixes based on visual inspection and Scrutinizer analysis feedback.
288
+ - Typo in the instructions contained in `CONTRIBUTING.md`.
289
+ - Broken link in the `README.md` file.
290
 
291
 
292
  ## [0.14.1] - 2018-02-15
326
  - The `WordPress.VIP.CronInterval` sniff now allows for customizing the minimum allowed cron interval by [setting a property in a custom ruleset](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#vip-croninterval-minimum-interval).
327
  - The `WordPress.VIP.RestrictedFunctions` sniff used to prohibit the use of certain WP native functions, recommending the use of `wpcom_vip_get_term_link()`, `wpcom_vip_get_term_by()` and `wpcom_vip_get_category_by_slug()` instead, as the WP native functions were not being cached. As the results of the relevant WP native functions are cached as of WP 4.8, the advice has now been reversed i.e. use the WP native functions instead of `wpcom...` functions.
328
  - The `WordPress.VIP.PostsPerPage` sniff now allows for customizing the `post_per_page` limit for which the sniff will trigger by [setting a property in a custom ruleset](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Customizable-sniff-properties#vip-postsperpage-post-limit).
329
+ - The `WordPress.WP.I18n` sniff will now allow and actively encourage omitting the text domain in I18n function calls if the text domain passed via the `text_domain` property is `default`, i.e. the domain used by Core.
330
+ When `default` is one of several text domains passed via the `text_domain` property, the error thrown when the domain is missing has been downgraded to a `warning`.
331
  - The `WordPress.XSS.EscapeOutput` sniff now has a separate error code `OutputNotEscapedShortEcho` and the error message texts have been updated.
332
  - Moved `Squiz.PHP.Eval` from the `WordPress-Extra` and `WordPress-VIP` to the `WordPress-Core` ruleset.
333
  - Removed two sniffs from the `WordPress-VIP` ruleset which were already included via the `WordPress-Core` ruleset.
576
  ## [0.10.0] - 2016-08-29
577
 
578
  ### Added
579
+ - `WordPress.WP.I18n` sniff to the `WordPress-Core` ruleset to flag dynamic translatable strings and text domains.
580
  - `WordPress.PHP.DisallowAlternativePHPTags` sniff to the `WordPress-Core` ruleset to flag - and fix - ASP and `<script>` PHP open tags.
581
  - `WordPress.Classes.ClassOpeningStatement` sniff to the `WordPress-Core` ruleset to flag - and fix - class opening brace placement.
582
  - `WordPress.NamingConventions.ValidHookName` sniff to the `WordPress-Core` ruleset to flag filter and action hooks which don't comply with the guideline of lowercase letters and underscores. For maintaining backward-compatibility of hook names an `additionalWordDelimiters` property can be added via a custom ruleset.
589
  - Ability to use a whitelist comment for tax queries for the `WordPress.VIP.SlowDBQuery` sniff.
590
  - Instructions on how to use WPCS with Atom and SublimeLinter to the Readme.
591
  - Reference to the [wiki](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki) to the Readme.
592
+ - Recommendation to also use the [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) ruleset to the Readme.
593
 
594
  ### Changed
595
  - The minimum required PHP_CodeSniffer version to 2.6.0.
810
  Initial tagged release.
811
 
812
  [Unreleased]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/master...HEAD
813
+ [1.2.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/1.1.0...1.2.0
814
+ [1.1.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/1.0.0...1.1.0
815
+ [1.0.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.14.1...1.0.0
816
  [0.14.1]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.14.0...0.14.1
817
  [0.14.0]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.13.1...0.14.0
818
  [0.13.1]: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/compare/0.13.0...0.13.1
vendor/wp-coding-standards/wpcs/README.md CHANGED
@@ -1,5 +1,22 @@
1
- [![Build Status](https://travis-ci.org/WordPress-Coding-Standards/WordPress-Coding-Standards.png?branch=master)](https://travis-ci.org/WordPress-Coding-Standards/WordPress-Coding-Standards)
2
- [![Total Downloads](https://poser.pugx.org/wp-coding-standards/wpcs/downloads)](https://packagist.org/packages/wp-coding-standards/wpcs)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  # WordPress Coding Standards for PHP_CodeSniffer
5
 
@@ -16,27 +33,27 @@
16
  + [Recommended additional rulesets](#recommended-additional-rulesets)
17
  * [How to use](#how-to-use)
18
  + [Command line](#command-line)
19
- + [PhpStorm](#phpstorm)
20
- + [Sublime Text](#sublime-text)
21
- + [Atom](#atom)
22
- + [Visual Studio](#visual-studio)
23
  * [Running your code through WPCS automatically using CI tools](#running-your-code-through-wpcs-automatically-using-ci-tools)
24
  + [Travis CI](#travis-ci)
25
  * [Fixing errors or whitelisting them](#fixing-errors-or-whitelisting-them)
 
26
  * [Contributing](#contributing)
27
  * [License](#license)
28
 
29
  ## Introduction
30
 
31
- This project is a collection of [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) rules (sniffs) to validate code developed for WordPress. It ensures code quality and adherence to coding conventions, especially the official [WordPress Coding Standards](http://make.wordpress.org/core/handbook/coding-standards/).
32
 
33
  ## Project history
34
 
35
- - In April 2009 original project from [Urban Giraffe](http://urbangiraffe.com/articles/wordpress-codesniffer-standard/) was published.
36
- - In May 2011 the project was forked on GitHub by [Chris Adams](http://chrisadams.me.uk/).
37
  - In April 2012 [XWP](https://xwp.co/) started to dedicate resources to develop and lead the creation of the sniffs and rulesets for `WordPress-Core`, `WordPress-VIP` (WordPress.com VIP), and `WordPress-Extra`.
 
38
  - In 2015, [J.D. Grimes](https://github.com/JDGrimes) began significant contributions, along with maintenance from [Gary Jones](https://github.com/GaryJones).
39
- - In 2016, [Juliette Reinders Folmer](https://github.com/jrfnl) began contributing heavily, adding more commits in a year than anyone else in 5 years previous since the project's inception.
 
40
 
41
  ## Installation
42
 
@@ -110,17 +127,19 @@ You should then see `WordPress-Core` et al listed when you run `phpcs -i`.
110
 
111
  ### Standards subsets
112
 
113
- The project encompasses a super-set of the sniffs that the WordPress community may need. If you use the `WordPress` standard you will get all the checks. Some of them might be unnecessary for your environment, for example, those specific to WordPress VIP coding requirements.
114
 
115
  You can use the following as standard names when invoking `phpcs` to select sniffs, fitting your needs:
116
 
117
  * `WordPress` - complete set with all of the sniffs in the project
118
- - `WordPress-Core` - main ruleset for [WordPress core coding standards](http://make.wordpress.org/core/handbook/coding-standards/)
119
  - `WordPress-Docs` - additional ruleset for [WordPress inline documentation standards](https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/)
120
  - `WordPress-Extra` - extended ruleset for recommended best practices, not sufficiently covered in the WordPress core coding standards
121
  - includes `WordPress-Core`
122
- - `WordPress-VIP` - extended ruleset for [WordPress VIP coding requirements](http://vip.wordpress.com/documentation/code-review-what-we-look-for/)
123
- - includes `WordPress-Core`
 
 
124
 
125
  ### Using a custom ruleset
126
 
@@ -134,15 +153,18 @@ You can find a complete list of all the properties you can change in the [wiki](
134
 
135
  ### Recommended additional rulesets
136
 
137
- The [PHPCompatibility](https://github.com/wimg/PHPCompatibility) ruleset comes highly recommended.
138
- The [PHPCompatibility](https://github.com/wimg/PHPCompatibility) sniffs are designed to analyse your code for cross-PHP version compatibility.
139
- Install it as a separate ruleset and either run it separately against your code or add it to your custom ruleset.
 
140
 
141
- Whichever way you run it, do make sure you set the `testVersion` to run the sniffs against. The `testVersion` determines for which PHP versions you will receive compatibility information. The recommended setting for this at this moment is `5.2-7.1` to support the same PHP versions as WordPress Core supports.
 
 
142
 
143
  For more information about setting the `testVersion`, see:
144
- * [PHPCompatibility: Using the compatibility sniffs](https://github.com/wimg/PHPCompatibility#using-the-compatibility-sniffs)
145
- * [PHPCompatibility: Using a custom ruleset](https://github.com/wimg/PHPCompatibility#using-a-custom-ruleset)
146
 
147
  ## How to use
148
 
@@ -154,76 +176,50 @@ Run the `phpcs` command line tool on a given file or directory, for example:
154
 
155
  Will result in following output:
156
 
157
- --------------------------------------------------------------------------------
158
- FOUND 10 ERRORS AND 5 WARNINGS AFFECTING 8 LINES
159
- --------------------------------------------------------------------------------
160
  24 | WARNING | [ ] error_reporting() can lead to full path disclosure.
161
- 24 | WARNING | [ ] error_reporting() found. Changing configuration at runtime
162
- | | is rarely necessary.
163
- 34 | ERROR | [x] Expected 1 spaces before closing bracket; 0 found
 
164
  39 | WARNING | [ ] Silencing errors is discouraged
165
  39 | WARNING | [ ] Silencing errors is discouraged
166
- 46 | ERROR | [ ] Inline comments must end in full-stops, exclamation marks,
167
- | | or question marks
 
 
168
  46 | ERROR | [x] There must be no blank line following an inline comment
169
- 63 | WARNING | [ ] Detected access of super global var $_SERVER, probably
170
- | | needs manual inspection.
 
 
 
 
171
  63 | ERROR | [ ] Detected usage of a non-validated input variable: $_SERVER
172
  63 | ERROR | [ ] Missing wp_unslash() before sanitization.
173
  63 | ERROR | [ ] Detected usage of a non-sanitized input variable: $_SERVER
174
- 74 | ERROR | [ ] Inline comments must end in full-stops, exclamation marks,
175
- | | or question marks
176
- 90 | ERROR | [x] String "Create a Configuration File" does not require
177
- | | double quotes; use single quotes instead
178
- 92 | ERROR | [ ] Expected next thing to be an escaping function (see Codex
179
- | | for 'Data Validation'), not '$die'
180
- 92 | ERROR | [ ] Expected next thing to be an escaping function (see Codex
181
- | | for 'Data Validation'), not '__'
182
- --------------------------------------------------------------------------------
183
- PHPCBF CAN FIX THE 3 MARKED SNIFF VIOLATIONS AUTOMATICALLY
184
- --------------------------------------------------------------------------------
185
-
186
- ### PhpStorm
187
-
188
- Please see "[PHP Code Sniffer with WordPress Coding Standards Integration](https://confluence.jetbrains.com/display/PhpStorm/WordPress+Development+using+PhpStorm#WordPressDevelopmentusingPhpStorm-PHPCodeSnifferwithWordPressCodingStandardsIntegrationinPhpStorm)" in the PhpStorm documentation.
189
-
190
- ### Sublime Text
191
-
192
- ##### sublime-phpcs package
193
- Install the [sublime-phpcs package](https://github.com/benmatselby/sublime-phpcs), then use the "Switch coding standard" command in the Command Palette to switch between coding standards.
194
-
195
- ##### SublimeLinter-phpcs
196
- sublime-phpcs is insanely powerful, but if you'd prefer automatic linting, [SublimeLinter-phpcs](https://github.com/SublimeLinter/SublimeLinter-phpcs/) can do that.
197
-
198
- - Install PHP Sniffer and WordPress Coding Standards per above.
199
- - Use [Package Control](https://packagecontrol.io/) to search for and install [SublimeLinter](http://www.sublimelinter.com) then [SublimeLinter-phpcs](https://github.com/SublimeLinter/SublimeLinter-phpcs/).
200
- - From the command palette, select `Preferences: SublimeLinter Settings - User` and change `user.linters.phpcs.standard` to the phpcs standard of your choice (e.g. `WordPress`, `WordPress-VIP`, etc.).
201
-
202
- ![SublimeLinter-phpcs user settings](https://cloud.githubusercontent.com/assets/224636/12946250/068776ba-cfc1-11e5-816b-109e4e32d21b.png)
203
-
204
- - You may need to restart Sublime for these settings to take effect. Error messages appear in the bottom of the editor.
205
-
206
- ![SublimeLinter-phpcs linting](https://cloud.githubusercontent.com/assets/224636/12946326/75986c3a-cfc1-11e5-8537-1243554bbab6.png)
207
-
208
- ![SublimeLinter-phpcs error](https://cloud.githubusercontent.com/assets/224636/12946335/8bee5a30-cfc1-11e5-8b5f-b10e8e4a4909.png)
209
-
210
- ### Atom
211
-
212
- - Install PHP Sniffer and WordPress Coding Standards per above.
213
- - Install [linter-phpcs](https://atom.io/packages/linter-phpcs) via Atom's package manager.
214
- - Run `which phpcs` to get your `phpcs` executable path.
215
- - Open the linter-phpcs package settings; enter your `phpcs` executable path and one of the coding standards specified above (e.g. `WordPress`, `WordPress-VIP`, etc.).
216
- - Below these settings find the Tab Width setting and change it to `4`.
217
-
218
- ![Atom Linter WordPress Coding Standards configuration](https://cloud.githubusercontent.com/assets/224636/12740504/ce4e97b8-c941-11e5-8d83-c77a2470d58e.png)
219
-
220
- ![Atom Linter in action using WordPress Coding Standards](https://cloud.githubusercontent.com/assets/224636/12740542/131c5894-c942-11e5-9e31-5e020c993224.png)
221
-
222
- - Note that certain items within PHPCS config file can cause linting to fail, see [linter-phpcs #95](https://github.com/AtomLinter/linter-phpcs/issues/95#issuecomment-316133107) for more details.
223
-
224
- ### Visual Studio
225
-
226
- Please see "[Setting up PHP CodeSniffer in Visual Studio Code](https://tommcfarlin.com/php-codesniffer-in-visual-studio-code/)", a tutorial by Tom McFarlin.
227
 
228
 
229
  ## Running your code through WPCS automatically using CI tools
@@ -267,11 +263,28 @@ script:
267
  - if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/bin/phpcs -p . --standard=WordPress; fi
268
  ```
269
 
 
 
270
 
271
  ## Fixing errors or whitelisting them
272
 
273
  You can find information on how to deal with some of the more frequent issues in the [wiki](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki).
274
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
275
 
276
  ## Contributing
277
 
1
+ <div aria-hidden="true">
2
+
3
+ [![Latest Stable Version](https://poser.pugx.org/wp-coding-standards/wpcs/v/stable)](https://packagist.org/packages/wp-coding-standards/wpcs)
4
+ [![Travis Build Status](https://travis-ci.org/WordPress-Coding-Standards/WordPress-Coding-Standards.svg?branch=master)](https://travis-ci.org/WordPress-Coding-Standards/WordPress-Coding-Standards)
5
+ [![Release Date of the Latest Version](https://img.shields.io/github/release-date/WordPress-Coding-Standards/WordPress-Coding-Standards.svg?maxAge=1800)](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/releases)
6
+ :construction:
7
+ [![Latest Unstable Version](https://img.shields.io/badge/unstable-dev--develop-e68718.svg?maxAge=2419200)](https://packagist.org/packages/wp-coding-standards/wpcs#dev-develop)
8
+ [![Travis Build Status](https://travis-ci.org/WordPress-Coding-Standards/WordPress-Coding-Standards.svg?branch=develop)](https://travis-ci.org/WordPress-Coding-Standards/WordPress-Coding-Standards)
9
+ [![Last Commit to Unstable](https://img.shields.io/github/last-commit/WordPress-Coding-Standards/WordPress-Coding-Standards/develop.svg)](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/commits/develop)
10
+
11
+ [![Minimum PHP Version](https://img.shields.io/packagist/php-v/wp-coding-standards/wpcs.svg?maxAge=3600)](https://packagist.org/packages/wp-coding-standards/wpcs)
12
+ [![Tested on PHP 5.3 to nightly](https://img.shields.io/badge/tested%20on-PHP%205.3%20|%205.4%20|%205.5%20|%205.6%20|%207.0%20|%207.1%20|%207.2%20|%20nightly-green.svg?maxAge=2419200)](https://travis-ci.org/WordPress-Coding-Standards/WordPress-Coding-Standards)
13
+
14
+ [![License: MIT](https://poser.pugx.org/wp-coding-standards/wpcs/license)](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/blob/develop/LICENSE)
15
+ [![Total Downloads](https://poser.pugx.org/wp-coding-standards/wpcs/downloads)](https://packagist.org/packages/wp-coding-standards/wpcs/stats)
16
+ [![Number of Contributors](https://img.shields.io/github/contributors/WordPress-Coding-Standards/WordPress-Coding-Standards.svg?maxAge=3600)](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors)
17
+
18
+ </div>
19
+
20
 
21
  # WordPress Coding Standards for PHP_CodeSniffer
22
 
33
  + [Recommended additional rulesets](#recommended-additional-rulesets)
34
  * [How to use](#how-to-use)
35
  + [Command line](#command-line)
36
+ + [Using PHPCS and WPCS from within your IDE](#using-phpcs-and-wpcs-from-within-your-ide)
 
 
 
37
  * [Running your code through WPCS automatically using CI tools](#running-your-code-through-wpcs-automatically-using-ci-tools)
38
  + [Travis CI](#travis-ci)
39
  * [Fixing errors or whitelisting them](#fixing-errors-or-whitelisting-them)
40
+ + [Tools shipped with WPCS](#tools-shipped-with-wpcs)
41
  * [Contributing](#contributing)
42
  * [License](#license)
43
 
44
  ## Introduction
45
 
46
+ This project is a collection of [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) rules (sniffs) to validate code developed for WordPress. It ensures code quality and adherence to coding conventions, especially the official [WordPress Coding Standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/).
47
 
48
  ## Project history
49
 
50
+ - On 22nd April 2009, the original project from [Urban Giraffe](https://urbangiraffe.com/articles/wordpress-codesniffer-standard/) was packaged and published.
51
+ - In May 2011 the project was forked and [added](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/commit/04fd547c691ca2baae3fa8e195a46b0c9dd671c5) to GitHub by [Chris Adams](https://chrisadams.me.uk/).
52
  - In April 2012 [XWP](https://xwp.co/) started to dedicate resources to develop and lead the creation of the sniffs and rulesets for `WordPress-Core`, `WordPress-VIP` (WordPress.com VIP), and `WordPress-Extra`.
53
+ - In May 2015, an initial documentation ruleset was [added](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/commit/b1a4bf8232a22563ef66f8a529357275a49f47dc#diff-a17c358c3262a26e9228268eb0a7b8c8) as `WordPress-Docs`.
54
  - In 2015, [J.D. Grimes](https://github.com/JDGrimes) began significant contributions, along with maintenance from [Gary Jones](https://github.com/GaryJones).
55
+ - In 2016, [Juliette Reinders Folmer](https://github.com/jrfnl) began contributing heavily, adding more commits in a year than anyone else in the five years since the project was added to GitHub.
56
+ - In July 2018, version [`1.0.0`](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/releases/tag/1.0.0) of the project was released.
57
 
58
  ## Installation
59
 
127
 
128
  ### Standards subsets
129
 
130
+ The project encompasses a super-set of the sniffs that the WordPress community may need. If you use the `WordPress` standard you will get all the checks. Some of them might be unnecessary for your environment, for example, those specific to WordPress.com VIP coding requirements.
131
 
132
  You can use the following as standard names when invoking `phpcs` to select sniffs, fitting your needs:
133
 
134
  * `WordPress` - complete set with all of the sniffs in the project
135
+ - `WordPress-Core` - main ruleset for [WordPress core coding standards](https://make.wordpress.org/core/handbook/best-practices/coding-standards/)
136
  - `WordPress-Docs` - additional ruleset for [WordPress inline documentation standards](https://make.wordpress.org/core/handbook/best-practices/inline-documentation-standards/)
137
  - `WordPress-Extra` - extended ruleset for recommended best practices, not sufficiently covered in the WordPress core coding standards
138
  - includes `WordPress-Core`
139
+
140
+ **Notes:** This WPCS package contains the sniffs for another ruleset, `WordPress-VIP`. This ruleset was originally intended to aid with the [WordPress.com VIP coding requirements](https://vip.wordpress.com/documentation/vip-go/code-review-blockers-warnings-notices/), but this is no longer used or recommended by the WordPress.com VIP team or their clients, since they prefer to use their [official VIP coding standards](https://github.com/Automattic/VIP-Coding-Standards) ruleset instead.
141
+
142
+ Before WPCS `1.0.0`, the WordPress-VIP ruleset was included as part of the complete `WordPress` ruleset. **As of `1.0.0` the `WordPress-VIP` ruleset is not part of the WordPress ruleset, and it is deprecated**. The remaining `WordPress-VIP` sniffs may still be referenced in custom rulesets, so to maintain some backwards compatibility, they will remain in WPCS until `2.0.0`. See [#1309](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1309) for more information.
143
 
144
  ### Using a custom ruleset
145
 
153
 
154
  ### Recommended additional rulesets
155
 
156
+ The [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) ruleset and its subset [PHPCompatibilityWP](https://github.com/PHPCompatibility/PHPCompatibilityWP) come highly recommended.
157
+ The [PHPCompatibility](https://github.com/PHPCompatibility/PHPCompatibility) sniffs are designed to analyse your code for cross-PHP version compatibility.
158
+
159
+ The [PHPCompatibilityWP](https://github.com/PHPCompatibility/PHPCompatibilityWP) ruleset is based on PHPCompatibility, but specifically crafted to prevent false positives for projects which expect to run within the context of WordPress, i.e. core, plugins and themes.
160
 
161
+ Install either as a separate ruleset and either run it separately against your code or add it to your custom ruleset.
162
+
163
+ Whichever way you run it, do make sure you set the `testVersion` to run the sniffs against. The `testVersion` determines for which PHP versions you will receive compatibility information. The recommended setting for this at this moment is `5.2-` to support the same PHP versions as WordPress Core supports.
164
 
165
  For more information about setting the `testVersion`, see:
166
+ * [PHPCompatibility: Sniffing your code for compatibility with specific PHP version(s)](https://github.com/PHPCompatibility/PHPCompatibility#sniffing-your-code-for-compatibility-with-specific-php-versions)
167
+ * [PHPCompatibility: Using a custom ruleset](https://github.com/PHPCompatibility/PHPCompatibility#using-a-custom-ruleset)
168
 
169
  ## How to use
170
 
176
 
177
  Will result in following output:
178
 
179
+ ------------------------------------------------------------------------------------------
180
+ FOUND 8 ERRORS AND 10 WARNINGS AFFECTING 11 LINES
181
+ ------------------------------------------------------------------------------------------
182
  24 | WARNING | [ ] error_reporting() can lead to full path disclosure.
183
+ 24 | WARNING | [ ] error_reporting() found. Changing configuration at runtime is rarely
184
+ | | necessary.
185
+ 37 | WARNING | [x] "require_once" is a statement not a function; no parentheses are
186
+ | | required
187
  39 | WARNING | [ ] Silencing errors is discouraged
188
  39 | WARNING | [ ] Silencing errors is discouraged
189
+ 42 | WARNING | [x] "require_once" is a statement not a function; no parentheses are
190
+ | | required
191
+ 46 | ERROR | [ ] Inline comments must end in full-stops, exclamation marks, or
192
+ | | question marks
193
  46 | ERROR | [x] There must be no blank line following an inline comment
194
+ 49 | WARNING | [x] "require_once" is a statement not a function; no parentheses are
195
+ | | required
196
+ 54 | WARNING | [x] "require_once" is a statement not a function; no parentheses are
197
+ | | required
198
+ 63 | WARNING | [ ] Detected access of super global var $_SERVER, probably needs manual
199
+ | | inspection.
200
  63 | ERROR | [ ] Detected usage of a non-validated input variable: $_SERVER
201
  63 | ERROR | [ ] Missing wp_unslash() before sanitization.
202
  63 | ERROR | [ ] Detected usage of a non-sanitized input variable: $_SERVER
203
+ 69 | WARNING | [x] "require_once" is a statement not a function; no parentheses are
204
+ | | required
205
+ 74 | ERROR | [ ] Inline comments must end in full-stops, exclamation marks, or
206
+ | | question marks
207
+ 92 | ERROR | [ ] All output should be run through an escaping function (see the
208
+ | | Security sections in the WordPress Developer Handbooks), found
209
+ | | '$die'.
210
+ 92 | ERROR | [ ] All output should be run through an escaping function (see the
211
+ | | Security sections in the WordPress Developer Handbooks), found '__'.
212
+ ------------------------------------------------------------------------------------------
213
+ PHPCBF CAN FIX THE 6 MARKED SNIFF VIOLATIONS AUTOMATICALLY
214
+ ------------------------------------------------------------------------------------------
215
+
216
+ ### Using PHPCS and WPCS from within your IDE
217
+
218
+ * **PhpStorm** : Please see "[PHP Code Sniffer with WordPress Coding Standards Integration](https://confluence.jetbrains.com/display/PhpStorm/WordPress+Development+using+PhpStorm#WordPressDevelopmentusingPhpStorm-PHPCodeSnifferwithWordPressCodingStandardsIntegrationinPhpStorm)" in the PhpStorm documentation.
219
+ * **Sublime Text** : Please see "[Setting up WPCS to work in Sublime Text](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Setting-up-WPCS-to-work-in-Sublime-Text)" in the wiki.
220
+ * **Atom**: Please see "[Setting up WPCS to work in Atom](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/Setting-up-WPCS-to-work-in-Atom)" in the wiki.
221
+ * **Visual Studio**: Please see "[Setting up PHP CodeSniffer in Visual Studio Code](https://tommcfarlin.com/php-codesniffer-in-visual-studio-code/)", a tutorial by Tom McFarlin.
222
+ * **Eclipse with XAMPP**: Please see "[Setting up WPCS when using Eclipse with XAMPP](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki/How-to-use-WPCS-with-Eclipse-and-XAMPP)" in the wiki.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
 
224
 
225
  ## Running your code through WPCS automatically using CI tools
263
  - if [[ "$SNIFF" == "1" ]]; then $PHPCS_DIR/bin/phpcs -p . --standard=WordPress; fi
264
  ```
265
 
266
+ More examples and advice about integrating PHPCS in your Travis build tests can be found here: https://github.com/jrfnl/make-phpcs-work-for-you/tree/master/travis-examples
267
+
268
 
269
  ## Fixing errors or whitelisting them
270
 
271
  You can find information on how to deal with some of the more frequent issues in the [wiki](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/wiki).
272
 
273
+ ### Tools shipped with WPCS
274
+
275
+ Since version 1.2.0, WPCS has a special sniff category `Utils`.
276
+
277
+ This sniff category contains some tools which, generally speaking, will only be needed to be run once over a codebase and for which the fixers can be considered _risky_, i.e. very careful review by a developer is needed before accepting the fixes made by these sniffs.
278
+
279
+ The sniffs in this category are disabled by default and can only be activated by adding some properties for each sniff via a custom ruleset.
280
+
281
+ At this moment, WPCS offer the following tools:
282
+ * `WordPress.Utils.I18nTextDomainFixer` - This sniff can replace the text domain used in a code-base.
283
+ The sniff will fix the text domains in both I18n function calls as well as in a plugin/theme header.
284
+ Passing the following properties will activate the sniff:
285
+ - `old_text_domain`: an array with one or more (old) text domain names which need to be replaced;
286
+ - `new_text_domain`: the correct (new) text domain as a string.
287
+
288
 
289
  ## Contributing
290
 
vendor/wp-coding-standards/wpcs/WordPress-Core/ruleset.xml CHANGED
@@ -13,7 +13,7 @@
13
  <!--
14
  #############################################################################
15
  Handbook: PHP - Single and Double Quotes.
16
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#single-and-double-quotes
17
  #############################################################################
18
  -->
19
  <!-- Covers rule: Use single and double quotes when appropriate.
@@ -30,7 +30,7 @@
30
  <!--
31
  #############################################################################
32
  Handbook: PHP - Indentation.
33
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#indentation
34
  #############################################################################
35
  -->
36
  <!-- Covers rule: Your indentation should always reflect logical structure. -->
@@ -49,7 +49,8 @@
49
  <rule ref="WordPress.WhiteSpace.PrecisionAlignment"/>
50
 
51
  <!-- Generic array layout check. -->
52
- <!-- Covers rule: For associative arrays, values should start on a new line.
 
53
  Also covers various single-line array whitespace issues. -->
54
  <rule ref="WordPress.Arrays.ArrayDeclarationSpacing"/>
55
 
@@ -57,12 +58,17 @@
57
  <rule ref="WordPress.Arrays.CommaAfterArrayItem"/>
58
 
59
  <!-- Covers rule: For switch structures case should indent one tab from the
60
- switch statement and break one tab from the case statement. -->
61
- <rule ref="PSR2.ControlStructures.SwitchDeclaration">
62
- <!-- Prevent duplicate messages for the same issue. Covered by other sniffs. -->
63
- <exclude name="PSR2.ControlStructures.SwitchDeclaration.NotLower"/>
64
- <exclude name="PSR2.ControlStructures.SwitchDeclaration.BreakNotNewLine"/>
65
- <exclude name="PSR2.ControlStructures.SwitchDeclaration.BodyOnNextLine"/>
 
 
 
 
 
66
  </rule>
67
 
68
  <!-- Covers rule: ... while spaces can be used mid-line for alignment. -->
@@ -86,7 +92,7 @@
86
  <!--
87
  #############################################################################
88
  Handbook: PHP - Brace Style.
89
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#brace-style
90
  #############################################################################
91
  -->
92
  <!-- Covers rule: Braces shall be used for all blocks. -->
@@ -99,16 +105,32 @@
99
  <!--
100
  #############################################################################
101
  Handbook: PHP - Use elseif, not else if.
102
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#use-elseif-not-else-if
103
  #############################################################################
104
  -->
 
105
  <rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
106
 
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  <!--
109
  #############################################################################
110
  Handbook: PHP - Regular Expressions.
111
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#regular-expressions
112
  #############################################################################
113
  -->
114
  <!-- Covers rule: Perl compatible regular expressions should be used in preference
@@ -125,23 +147,30 @@
125
  <!--
126
  #############################################################################
127
  Handbook: PHP - Opening and Closing PHP Tags.
128
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#opening-and-closing-php-tags
129
  #############################################################################
130
  -->
131
  <!-- Covers rule: When embedding multi-line PHP snippets within a HTML block, the
132
- PHP open and close tags must be on a line by themselves. -->
133
- <rule ref="Squiz.PHP.EmbeddedPhp">
134
- <exclude name="Squiz.PHP.EmbeddedPhp.SpacingBefore"/>
135
- <exclude name="Squiz.PHP.EmbeddedPhp.Indent"/>
136
- <exclude name="Squiz.PHP.EmbeddedPhp.OpenTagIndent"/>
137
- <exclude name="Squiz.PHP.EmbeddedPhp.SpacingAfter"/>
 
 
 
 
 
 
 
138
  </rule>
139
 
140
 
141
  <!--
142
  #############################################################################
143
  Handbook: PHP - No Shorthand PHP Tags.
144
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#no-shorthand-php-tags
145
  #############################################################################
146
  -->
147
  <!-- Covers rule: Never use shorthand PHP start tags. Always use full PHP tags. -->
@@ -152,7 +181,7 @@
152
  <!--
153
  #############################################################################
154
  Handbook: PHP - Remove Trailing Spaces.
155
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#remove-trailing-spaces
156
  #############################################################################
157
  -->
158
  <!-- Covers rule: Remove trailing whitespace at the end of each line of code. -->
@@ -165,7 +194,7 @@
165
  <!--
166
  #############################################################################
167
  Handbook: PHP - Space Usage.
168
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#space-usage
169
  #############################################################################
170
  -->
171
  <!-- Covers rule: Always put spaces after commas, and on both sides of logical,
@@ -194,22 +223,22 @@
194
  <property name="requiredSpacesAfterOpen" value="1"/>
195
  <property name="requiredSpacesBeforeClose" value="1"/>
196
  </properties>
197
- <exclude name="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeClose"/>
198
  </rule>
 
 
 
 
199
 
200
  <!-- Covers rule: Call a function, like so: my_function( $param1, func_param( $param2 ) ); -->
201
  <rule ref="PEAR.Functions.FunctionCallSignature">
202
  <properties>
203
  <property name="requiredSpacesAfterOpen" value="1"/>
204
  <property name="requiredSpacesBeforeClose" value="1"/>
 
 
 
205
  </properties>
206
  </rule>
207
- <rule ref="PEAR.Functions.FunctionCallSignature.ContentAfterOpenBracket">
208
- <severity phpcs-only="true">0</severity>
209
- </rule>
210
- <rule ref="PEAR.Functions.FunctionCallSignature.CloseBracketLine">
211
- <severity phpcs-only="true">0</severity>
212
- </rule>
213
  <!-- Related to issue #970 / https://github.com/squizlabs/PHP_CodeSniffer/issues/1512 -->
214
  <rule ref="WordPress.Functions.FunctionCallSignatureNoParams"/>
215
 
@@ -221,6 +250,7 @@
221
  <rule ref="Generic.Formatting.SpaceAfterCast"/>
222
  <rule ref="Squiz.WhiteSpace.CastSpacing"/>
223
  <rule ref="WordPress.WhiteSpace.CastStructureSpacing"/>
 
224
 
225
  <!-- Covers rule: ... array items, only include a space around the index if it is a variable. -->
226
  <rule ref="WordPress.Arrays.ArrayKeySpacingRestrictions"/>
@@ -244,7 +274,7 @@
244
  <!--
245
  #############################################################################
246
  Handbook: PHP - Formatting SQL statements.
247
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#formatting-sql-statements
248
  #############################################################################
249
  -->
250
  <!-- Rule: Always capitalize the SQL parts of the statement like UPDATE or WHERE.
@@ -254,18 +284,20 @@
254
  SQL slash escaping when passed.
255
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/640 -->
256
 
257
- <!-- Rule: in $wpdb->prepare - only %s and %d are used as placeholders. Note that they are not "quoted"! -->
 
258
  <rule ref="WordPress.DB.PreparedSQLPlaceholders"/>
259
 
260
- <!-- Covers rule: Escaping should be done as close to the time of the query as possible,
261
- preferably by using $wpdb->prepare() -->
262
- <rule ref="WordPress.WP.PreparedSQL"/>
 
263
 
264
 
265
  <!--
266
  #############################################################################
267
  Handbook: PHP - Database Queries.
268
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#database-queries
269
  #############################################################################
270
  -->
271
  <!-- Covers rule: Avoid touching the database directly. -->
@@ -276,10 +308,10 @@
276
  <!--
277
  #############################################################################
278
  Handbook: PHP - Naming Conventions.
279
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#naming-conventions
280
  #############################################################################
281
  -->
282
- <!-- Covers rule: Use lowercase letters in variable, action, and function names.
283
  Separate words via underscores. -->
284
  <rule ref="WordPress.NamingConventions.ValidFunctionName"/>
285
  <rule ref="WordPress.NamingConventions.ValidHookName"/>
@@ -305,7 +337,7 @@
305
  <!--
306
  #############################################################################
307
  Handbook: PHP - Self-Explanatory Flag Values for Function Arguments.
308
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#self-explanatory-flag-values-for-function-arguments
309
  #############################################################################
310
  -->
311
 
@@ -313,7 +345,7 @@
313
  <!--
314
  #############################################################################
315
  Handbook: PHP - Interpolation for Naming Dynamic Hooks.
316
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#interpolation-for-naming-dynamic-hooks
317
 
318
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/751
319
  #############################################################################
@@ -330,7 +362,7 @@
330
  <!--
331
  #############################################################################
332
  Handbook: PHP - Ternary Operator.
333
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#ternary-operator
334
  #############################################################################
335
  -->
336
  <!-- Rule: Always have Ternaries test if the statement is true, not false.
@@ -341,18 +373,20 @@
341
  <!--
342
  #############################################################################
343
  Handbook: PHP - Yoda Conditions.
344
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#yoda-conditions
345
  #############################################################################
346
  -->
347
  <!-- Covers rule: When doing logical comparisons, always put the variable on the right side,
348
  constants or literals on the left. -->
349
  <rule ref="WordPress.PHP.YodaConditions"/>
350
 
 
 
351
 
352
  <!--
353
  #############################################################################
354
  Handbook: PHP - Clever Code.
355
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#clever-code
356
  #############################################################################
357
  -->
358
  <!-- Rule: In general, readability is more important than cleverness or brevity.
@@ -361,7 +395,7 @@
361
  <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
362
 
363
  <!-- Rule: In a switch statement... If a case contains a block, then falls through
364
- to the next block, this must be explicitly commented. -->
365
  <!-- Covered by the PSR2.ControlStructures.SwitchDeclaration sniff. -->
366
 
367
  <!-- Rule: The goto statement must never be used. -->
@@ -381,26 +415,28 @@
381
  </rule>
382
 
383
  <!-- Rule: create_function() function, which internally performs an eval(),
384
- is deprecated in PHP 7.2. Both of these must not be used. -->
385
  <rule ref="WordPress.PHP.RestrictedPHPFunctions"/>
386
 
387
 
388
  <!--
389
  #############################################################################
390
  Handbook: PHP - (No) Error Control Operator @.
391
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#error-control-operator
392
  #############################################################################
393
  -->
394
- <rule ref="Generic.PHP.NoSilencedErrors"/>
 
 
395
 
396
 
397
  <!--
398
  #############################################################################
399
  Handbook: PHP - Don't extract().
400
- Ref: https://make.wordpress.org/core/handbook/coding-standards/php/#dont-extract
401
  #############################################################################
402
  -->
403
- <rule ref="WordPress.Functions.DontExtract"/>
404
 
405
 
406
  <!--
@@ -427,8 +463,11 @@
427
  https://github.com/squizlabs/PHP_CodeSniffer/pull/1691 -->
428
  <rule ref="WordPress.WhiteSpace.SemicolonSpacing"/>
429
 
 
 
 
430
  <!-- Lowercase PHP constants, like true, false and null. -->
431
- <!-- http://make.wordpress.org/core/handbook/coding-standards/php/#naming-conventions -->
432
  <rule ref="Generic.PHP.LowerCaseConstant"/>
433
 
434
  <!-- Lowercase PHP keywords, like class, function and case. -->
13
  <!--
14
  #############################################################################
15
  Handbook: PHP - Single and Double Quotes.
16
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#single-and-double-quotes
17
  #############################################################################
18
  -->
19
  <!-- Covers rule: Use single and double quotes when appropriate.
30
  <!--
31
  #############################################################################
32
  Handbook: PHP - Indentation.
33
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#indentation
34
  #############################################################################
35
  -->
36
  <!-- Covers rule: Your indentation should always reflect logical structure. -->
49
  <rule ref="WordPress.WhiteSpace.PrecisionAlignment"/>
50
 
51
  <!-- Generic array layout check. -->
52
+ <!-- Covers rule: For associative arrays, each item should start on a new line
53
+ when the array contains more than one item.
54
  Also covers various single-line array whitespace issues. -->
55
  <rule ref="WordPress.Arrays.ArrayDeclarationSpacing"/>
56
 
58
  <rule ref="WordPress.Arrays.CommaAfterArrayItem"/>
59
 
60
  <!-- Covers rule: For switch structures case should indent one tab from the
61
+ switch statement and break one tab from the case statement. -->
62
+ <rule ref="PSR2.ControlStructures.SwitchDeclaration"/>
63
+ <!-- Prevent duplicate messages for the same issue. Covered by other sniffs. -->
64
+ <rule ref="PSR2.ControlStructures.SwitchDeclaration.NotLower">
65
+ <severity>0</severity>
66
+ </rule>
67
+ <rule ref="PSR2.ControlStructures.SwitchDeclaration.BreakNotNewLine">
68
+ <severity>0</severity>
69
+ </rule>
70
+ <rule ref="PSR2.ControlStructures.SwitchDeclaration.BodyOnNextLine">
71
+ <severity>0</severity>
72
  </rule>
73
 
74
  <!-- Covers rule: ... while spaces can be used mid-line for alignment. -->
92
  <!--
93
  #############################################################################
94
  Handbook: PHP - Brace Style.
95
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#brace-style
96
  #############################################################################
97
  -->
98
  <!-- Covers rule: Braces shall be used for all blocks. -->
105
  <!--
106
  #############################################################################
107
  Handbook: PHP - Use elseif, not else if.
108
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#use-elseif-not-else-if
109
  #############################################################################
110
  -->
111
+ <!-- Covers rule: ... use elseif for conditionals. -->
112
  <rule ref="PSR2.ControlStructures.ElseIfDeclaration"/>
113
 
114
 
115
+ <!--
116
+ #############################################################################
117
+ Handbook: PHP - Multiline Function Calls.
118
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#multiline-function-calls
119
+ #############################################################################
120
+ -->
121
+ <!-- Rule: When splitting a function call over multiple lines, each parameter must be on a seperate line.
122
+ Covered via PEAR.Functions.FunctionCallSignature in Space Usage section. -->
123
+
124
+ <!-- Rule: Single line inline comments can take up their own line. -->
125
+ <!-- Rule: Each parameter must take up no more than a single line. Multi-line parameter
126
+ values must be assigned to a variable and then that variable should be passed to the function call.
127
+ https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1330 -->
128
+
129
+
130
  <!--
131
  #############################################################################
132
  Handbook: PHP - Regular Expressions.
133
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#regular-expressions
134
  #############################################################################
135
  -->
136
  <!-- Covers rule: Perl compatible regular expressions should be used in preference
147
  <!--
148
  #############################################################################
149
  Handbook: PHP - Opening and Closing PHP Tags.
150
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#opening-and-closing-php-tags
151
  #############################################################################
152
  -->
153
  <!-- Covers rule: When embedding multi-line PHP snippets within a HTML block, the
154
+ PHP open and close tags must be on a line by themselves. -->
155
+ <rule ref="Squiz.PHP.EmbeddedPhp"/>
156
+ <rule ref="Squiz.PHP.EmbeddedPhp.SpacingBefore">
157
+ <severity>0</severity>
158
+ </rule>
159
+ <rule ref="Squiz.PHP.EmbeddedPhp.Indent">
160
+ <severity>0</severity>
161
+ </rule>
162
+ <rule ref="Squiz.PHP.EmbeddedPhp.OpenTagIndent">
163
+ <severity>0</severity>
164
+ </rule>
165
+ <rule ref="Squiz.PHP.EmbeddedPhp.SpacingAfter">
166
+ <severity>0</severity>
167
  </rule>
168
 
169
 
170
  <!--
171
  #############################################################################
172
  Handbook: PHP - No Shorthand PHP Tags.
173
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#no-shorthand-php-tags
174
  #############################################################################
175
  -->
176
  <!-- Covers rule: Never use shorthand PHP start tags. Always use full PHP tags. -->
181
  <!--
182
  #############################################################################
183
  Handbook: PHP - Remove Trailing Spaces.
184
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#remove-trailing-spaces
185
  #############################################################################
186
  -->
187
  <!-- Covers rule: Remove trailing whitespace at the end of each line of code. -->
194
  <!--
195
  #############################################################################
196
  Handbook: PHP - Space Usage.
197
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#space-usage
198
  #############################################################################
199
  -->
200
  <!-- Covers rule: Always put spaces after commas, and on both sides of logical,
223
  <property name="requiredSpacesAfterOpen" value="1"/>
224
  <property name="requiredSpacesBeforeClose" value="1"/>
225
  </properties>
 
226
  </rule>
227
+ <rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingBeforeClose">
228
+ <severity>0</severity>
229
+ </rule>
230
+
231
 
232
  <!-- Covers rule: Call a function, like so: my_function( $param1, func_param( $param2 ) ); -->
233
  <rule ref="PEAR.Functions.FunctionCallSignature">
234
  <properties>
235
  <property name="requiredSpacesAfterOpen" value="1"/>
236
  <property name="requiredSpacesBeforeClose" value="1"/>
237
+
238
+ <!-- ... and for multi-line function calls, there should only be one parameter per line. -->
239
+ <property name="allowMultipleArguments" value="false"/>
240
  </properties>
241
  </rule>
 
 
 
 
 
 
242
  <!-- Related to issue #970 / https://github.com/squizlabs/PHP_CodeSniffer/issues/1512 -->
243
  <rule ref="WordPress.Functions.FunctionCallSignatureNoParams"/>
244
 
250
  <rule ref="Generic.Formatting.SpaceAfterCast"/>
251
  <rule ref="Squiz.WhiteSpace.CastSpacing"/>
252
  <rule ref="WordPress.WhiteSpace.CastStructureSpacing"/>
253
+ <rule ref="WordPress.PHP.TypeCasts"/>
254
 
255
  <!-- Covers rule: ... array items, only include a space around the index if it is a variable. -->
256
  <rule ref="WordPress.Arrays.ArrayKeySpacingRestrictions"/>
274
  <!--
275
  #############################################################################
276
  Handbook: PHP - Formatting SQL statements.
277
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#formatting-sql-statements
278
  #############################################################################
279
  -->
280
  <!-- Rule: Always capitalize the SQL parts of the statement like UPDATE or WHERE.
284
  SQL slash escaping when passed.
285
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/640 -->
286
 
287
+ <!-- Rule: in $wpdb->prepare - %s is used for string placeholders and %d is used for integer
288
+ placeholders. Note that they are not 'quoted'! -->
289
  <rule ref="WordPress.DB.PreparedSQLPlaceholders"/>
290
 
291
+ <!-- Covers rule: $wpdb->prepare()... The benefit of this is that we don't have to remember
292
+ to manually use esc_sql(), and also that it is easy to see at a glance whether something
293
+ has been escaped or not, because it happens right when the query happens. -->
294
+ <rule ref="WordPress.DB.PreparedSQL"/>
295
 
296
 
297
  <!--
298
  #############################################################################
299
  Handbook: PHP - Database Queries.
300
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#database-queries
301
  #############################################################################
302
  -->
303
  <!-- Covers rule: Avoid touching the database directly. -->
308
  <!--
309
  #############################################################################
310
  Handbook: PHP - Naming Conventions.
311
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#naming-conventions
312
  #############################################################################
313
  -->
314
+ <!-- Covers rule: Use lowercase letters in variable, action/filter, and function names.
315
  Separate words via underscores. -->
316
  <rule ref="WordPress.NamingConventions.ValidFunctionName"/>
317
  <rule ref="WordPress.NamingConventions.ValidHookName"/>
337
  <!--
338
  #############################################################################
339
  Handbook: PHP - Self-Explanatory Flag Values for Function Arguments.
340
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#self-explanatory-flag-values-for-function-arguments
341
  #############################################################################
342
  -->
343
 
345
  <!--
346
  #############################################################################
347
  Handbook: PHP - Interpolation for Naming Dynamic Hooks.
348
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#interpolation-for-naming-dynamic-hooks
349
 
350
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/751
351
  #############################################################################
362
  <!--
363
  #############################################################################
364
  Handbook: PHP - Ternary Operator.
365
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#ternary-operator
366
  #############################################################################
367
  -->
368
  <!-- Rule: Always have Ternaries test if the statement is true, not false.
373
  <!--
374
  #############################################################################
375
  Handbook: PHP - Yoda Conditions.
376
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#yoda-conditions
377
  #############################################################################
378
  -->
379
  <!-- Covers rule: When doing logical comparisons, always put the variable on the right side,
380
  constants or literals on the left. -->
381
  <rule ref="WordPress.PHP.YodaConditions"/>
382
 
383
+ <!-- Rule: Yoda conditions for <, >, <= or >= are significantly more difficult to read
384
+ and are best avoided. -->
385
 
386
  <!--
387
  #############################################################################
388
  Handbook: PHP - Clever Code.
389
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#clever-code
390
  #############################################################################
391
  -->
392
  <!-- Rule: In general, readability is more important than cleverness or brevity.
395
  <rule ref="Generic.Formatting.DisallowMultipleStatements"/>
396
 
397
  <!-- Rule: In a switch statement... If a case contains a block, then falls through
398
+ to the next block, this must be explicitly commented. -->
399
  <!-- Covered by the PSR2.ControlStructures.SwitchDeclaration sniff. -->
400
 
401
  <!-- Rule: The goto statement must never be used. -->
415
  </rule>
416
 
417
  <!-- Rule: create_function() function, which internally performs an eval(),
418
+ is deprecated in PHP 7.2. ... these must not be used. -->
419
  <rule ref="WordPress.PHP.RestrictedPHPFunctions"/>
420
 
421
 
422
  <!--
423
  #############################################################################
424
  Handbook: PHP - (No) Error Control Operator @.
425
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#error-control-operator
426
  #############################################################################
427
  -->
428
+ <!-- Covers rule: This operator is often used lazily instead of doing proper error checking.
429
+ Its use is highly discouraged. -->
430
+ <rule ref="WordPress.PHP.NoSilencedErrors"/>
431
 
432
 
433
  <!--
434
  #############################################################################
435
  Handbook: PHP - Don't extract().
436
+ Ref: https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#dont-extract
437
  #############################################################################
438
  -->
439
+ <rule ref="WordPress.PHP.DontExtract"/>
440
 
441
 
442
  <!--
463
  https://github.com/squizlabs/PHP_CodeSniffer/pull/1691 -->
464
  <rule ref="WordPress.WhiteSpace.SemicolonSpacing"/>
465
 
466
+ <!-- There should be no empty statements, i.e. lone semi-colons or open/close tags without content. -->
467
+ <rule ref="WordPress.CodeAnalysis.EmptyStatement"/>
468
+
469
  <!-- Lowercase PHP constants, like true, false and null. -->
470
+ <!-- https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#naming-conventions -->
471
  <rule ref="Generic.PHP.LowerCaseConstant"/>
472
 
473
  <!-- Lowercase PHP keywords, like class, function and case. -->
vendor/wp-coding-standards/wpcs/WordPress-Docs/ruleset.xml CHANGED
@@ -86,13 +86,6 @@
86
  <exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
87
  </rule>
88
 
89
- <!-- Make this sniff less likely to trigger on end comments. -->
90
- <rule ref="Squiz.PHP.CommentedOutCode">
91
- <properties>
92
- <property name="maxPercentage" value="45"/>
93
- </properties>
94
- </rule>
95
-
96
  <rule ref="Generic.Commenting">
97
  <!-- WP has different alignment of tag values -->
98
  <exclude name="Generic.Commenting.DocComment.TagValueIndent"/>
86
  <exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing"/>
87
  </rule>
88
 
 
 
 
 
 
 
 
89
  <rule ref="Generic.Commenting">
90
  <!-- WP has different alignment of tag values -->
91
  <exclude name="Generic.Commenting.DocComment.TagValueIndent"/>
vendor/wp-coding-standards/wpcs/WordPress-Extra/ruleset.xml CHANGED
@@ -4,6 +4,8 @@
4
 
5
  <autoload>./../WordPress/PHPCSAliases.php</autoload>
6
 
 
 
7
  <!-- Generic PHP best practices.
8
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/382 -->
9
  <rule ref="Generic.PHP.DeprecatedFunctions"/>
@@ -22,7 +24,6 @@
22
  <property name="allowMultiline" value="true"/>
23
  </properties>
24
  </rule>
25
- <rule ref="WordPress.CodeAnalysis.EmptyStatement"/>
26
 
27
  <!-- Duplicate of upstream. Can be removed once minimum PHPCS requirement has gone up.
28
  https://github.com/squizlabs/PHP_CodeSniffer/pull/1594 -->
@@ -41,9 +42,12 @@
41
 
42
  <!-- And yet more best practices.
43
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1143 -->
44
- <rule ref="PEAR.Files.IncludingFile">
45
- <exclude name="PEAR.Files.IncludingFile.UseInclude"/>
46
- <exclude name="PEAR.Files.IncludingFile.UseIncludeOnce"/>
 
 
 
47
  </rule>
48
  <rule ref="PEAR.Files.IncludingFile.BracketsNotRequired">
49
  <type>warning</type>
@@ -83,8 +87,6 @@
83
  <message>Best practice suggestion: Declare only one trait in a file.</message>
84
  </rule>
85
 
86
- <rule ref="WordPress-Core"/>
87
-
88
  <!-- Verify modifier keywords for declared methods and properties in classes.
89
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1101 -->
90
  <rule ref="Squiz.Scope.MethodScope"/>
@@ -101,17 +103,22 @@
101
  <severity>5</severity>
102
  </rule>
103
 
104
- <rule ref="WordPress.XSS.EscapeOutput"/>
 
 
 
 
105
 
106
  <!-- Verify that a nonce check is done before using values in superglobals.
107
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/73 -->
108
- <rule ref="WordPress.CSRF.NonceVerification"/>
109
 
110
  <rule ref="WordPress.PHP.DevelopmentFunctions"/>
111
  <rule ref="WordPress.PHP.DiscouragedPHPFunctions"/>
112
  <rule ref="WordPress.WP.DeprecatedFunctions"/>
113
  <rule ref="WordPress.WP.DeprecatedClasses"/>
114
  <rule ref="WordPress.WP.DeprecatedParameters"/>
 
115
  <rule ref="WordPress.WP.AlternativeFunctions"/>
116
  <rule ref="WordPress.WP.DiscouragedConstants"/>
117
  <rule ref="WordPress.WP.DiscouragedFunctions"/>
@@ -122,7 +129,7 @@
122
 
123
  <!-- Warn against overriding WP global variables.
124
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/26 -->
125
- <rule ref="WordPress.Variables.GlobalVariables"/>
126
 
127
  <!-- Encourage the use of strict ( === and !== ) comparisons.
128
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/242 -->
@@ -133,6 +140,10 @@
133
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/503 -->
134
  <rule ref="WordPress.PHP.StrictInArray"/>
135
 
 
 
 
 
136
  <!-- Discourage use of the backtick operator (execution of shell commands).
137
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/646 -->
138
  <rule ref="Generic.PHP.BacktickOperator"/>
@@ -156,6 +167,32 @@
156
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/919 -->
157
  <rule ref="WordPress.Classes.ClassInstantiation"/>
158
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
 
160
  <!--
161
  #############################################################################
4
 
5
  <autoload>./../WordPress/PHPCSAliases.php</autoload>
6
 
7
+ <rule ref="WordPress-Core"/>
8
+
9
  <!-- Generic PHP best practices.
10
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/382 -->
11
  <rule ref="Generic.PHP.DeprecatedFunctions"/>
24
  <property name="allowMultiline" value="true"/>
25
  </properties>
26
  </rule>
 
27
 
28
  <!-- Duplicate of upstream. Can be removed once minimum PHPCS requirement has gone up.
29
  https://github.com/squizlabs/PHP_CodeSniffer/pull/1594 -->
42
 
43
  <!-- And yet more best practices.
44
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1143 -->
45
+ <rule ref="PEAR.Files.IncludingFile"/>
46
+ <rule ref="PEAR.Files.IncludingFile.UseInclude">
47
+ <severity>0</severity>
48
+ </rule>
49
+ <rule ref="PEAR.Files.IncludingFile.UseIncludeOnce">
50
+ <severity>0</severity>
51
  </rule>
52
  <rule ref="PEAR.Files.IncludingFile.BracketsNotRequired">
53
  <type>warning</type>
87
  <message>Best practice suggestion: Declare only one trait in a file.</message>
88
  </rule>
89
 
 
 
90
  <!-- Verify modifier keywords for declared methods and properties in classes.
91
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1101 -->
92
  <rule ref="Squiz.Scope.MethodScope"/>
103
  <severity>5</severity>
104
  </rule>
105
 
106
+ <rule ref="WordPress.Security.EscapeOutput"/>
107
+
108
+ <!-- Encourage use of wp_safe_redirect() to avoid open redirect vulnerabilities.
109
+ https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/1264 -->
110
+ <rule ref="WordPress.Security.SafeRedirect"/>
111
 
112
  <!-- Verify that a nonce check is done before using values in superglobals.
113
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/73 -->
114
+ <rule ref="WordPress.Security.NonceVerification"/>
115
 
116
  <rule ref="WordPress.PHP.DevelopmentFunctions"/>
117
  <rule ref="WordPress.PHP.DiscouragedPHPFunctions"/>
118
  <rule ref="WordPress.WP.DeprecatedFunctions"/>
119
  <rule ref="WordPress.WP.DeprecatedClasses"/>
120
  <rule ref="WordPress.WP.DeprecatedParameters"/>
121
+ <rule ref="WordPress.WP.DeprecatedParameterValues"/>
122
  <rule ref="WordPress.WP.AlternativeFunctions"/>
123
  <rule ref="WordPress.WP.DiscouragedConstants"/>
124
  <rule ref="WordPress.WP.DiscouragedFunctions"/>
129
 
130
  <!-- Warn against overriding WP global variables.
131
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/26 -->
132
+ <rule ref="WordPress.WP.GlobalVariablesOverride"/>
133
 
134
  <!-- Encourage the use of strict ( === and !== ) comparisons.
135
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/242 -->
140
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/503 -->
141
  <rule ref="WordPress.PHP.StrictInArray"/>
142
 
143
+ <!-- Check enqueue and register styles and scripts to have version and in_footer parameters explicitly set.
144
+ https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1146 -->
145
+ <rule ref="WordPress.WP.EnqueuedResourceParameters"/>
146
+
147
  <!-- Discourage use of the backtick operator (execution of shell commands).
148
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/646 -->
149
  <rule ref="Generic.PHP.BacktickOperator"/>
167
  https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/919 -->
168
  <rule ref="WordPress.Classes.ClassInstantiation"/>
169
 
170
+ <!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1157 -->
171
+ <rule ref="WordPress.Security.PluginMenuSlug"/>
172
+ <rule ref="WordPress.WP.CronInterval"/>
173
+ <rule ref="WordPress.WP.PostsPerPage"/>
174
+ <rule ref="WordPress.WP.TimezoneChange"/>
175
+
176
+ <!-- Verify some regex best practices.
177
+ https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1371 -->
178
+ <rule ref="WordPress.PHP.PregQuoteDelimiter"/>
179
+
180
+ <!-- The Core ruleset respects the whitelist. For `Extra` the sniff is stricter.
181
+ https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/1450 -->
182
+ <rule ref="WordPress.PHP.NoSilencedErrors">
183
+ <properties>
184
+ <property name="use_default_whitelist" value="false"/>
185
+ </properties>
186
+ </rule>
187
+
188
+ <!-- Commented out code should not be committed.
189
+ https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/1463 -->
190
+ <rule ref="Squiz.PHP.CommentedOutCode">
191
+ <properties>
192
+ <property name="maxPercentage" value="40"/>
193
+ </properties>
194
+ </rule>
195
+
196
 
197
  <!--
198
  #############################################################################
vendor/wp-coding-standards/wpcs/WordPress-VIP/ruleset.xml CHANGED
@@ -1,75 +1,50 @@
1
  <?xml version="1.0"?>
2
  <ruleset name="WordPress VIP">
3
- <description>WordPress VIP Coding Standards</description>
 
 
 
4
 
5
  <autoload>./../WordPress/PHPCSAliases.php</autoload>
6
 
7
  <rule ref="WordPress-Core"/>
8
 
9
- <!-- Covers:
10
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#removing-the-admin-bar
11
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#cron-schedules-less-than-15-minutes-or-expensive-events
12
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#direct-database-queries
13
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#filesystem-writes
14
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#order-by-rand
15
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#using-__file__-for-page-registration
16
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#uncached-functions
17
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#flush_rewrite_rules
18
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#session_start-and-other-session-related-functions
19
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#functions-that-use-joins-taxonomy-relation-queries-cat-tax-queries-subselects-or-api-calls
20
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#querying-on-meta_value
21
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#manipulating-the-timezone-server-side
22
- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#validation-sanitization-and-escaping
23
- -->
24
  <rule ref="WordPress.VIP"/>
25
 
26
- <!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#validation-sanitization-and-escaping -->
27
- <!-- https://vip.wordpress.com/documentation/best-practices/security/validating-sanitizing-escaping/ -->
28
- <rule ref="WordPress.XSS.EscapeOutput"/>
29
- <rule ref="WordPress.CSRF.NonceVerification"/>
 
30
 
31
- <!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#using-instead-of -->
32
  <rule ref="WordPress.PHP.StrictComparisons"/>
33
 
34
- <!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#commented-out-code-debug-code-or-output -->
35
  <rule ref="Squiz.PHP.CommentedOutCode">
36
  <properties>
37
  <property name="maxPercentage" value="45"/>
38
  </properties>
39
  </rule>
40
 
41
- <!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#eval-and-create_function -->
42
- <!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#serializing-data -->
43
- <!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#encoding-values-used-when-creating-a-url-or-passed-to-add_query_arg -->
44
- <!-- https://github.com/Automattic/vip-scanner/blob/master/vip-scanner/checks/ForbiddenPHPFunctionsCheck.php -->
45
  <rule ref="WordPress.PHP.DiscouragedPHPFunctions">
46
  <!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/633#issuecomment-266634811 -->
47
  <properties>
48
- <property name="exclude" value="obfuscation"/>
49
  </properties>
50
  </rule>
51
- <!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#settings-alteration -->
52
  <rule ref="WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration">
53
  <type>error</type>
54
  </rule>
55
 
56
- <!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#commented-out-code-debug-code-or-output -->
57
  <rule ref="WordPress.PHP.DevelopmentFunctions"/>
58
  <rule ref="WordPress.PHP.DevelopmentFunctions.error_log">
59
  <type>error</type>
60
  </rule>
61
- <!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#settings-alteration -->
62
  <rule ref="WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure">
63
  <type>error</type>
64
  </rule>
65
 
66
- <!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#using-in_array-without-strict-parameter -->
67
  <rule ref="WordPress.PHP.StrictInArray"/>
68
 
69
- <!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#use-wp_parse_url-instead-of-parse_url -->
70
- <!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#use-wp_json_encode-over-json_encode -->
71
- <!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#filesystem-writes -->
72
- <!-- https://vip.wordpress.com/documentation/vip/code-review-what-we-look-for/#remote-calls -->
73
  <rule ref="WordPress.WP.AlternativeFunctions"/>
74
  <!-- VIP recommends other functions -->
75
  <rule ref="WordPress.WP.AlternativeFunctions.curl">
@@ -79,7 +54,178 @@
79
  <message>%s() is highly discouraged, please use vip_safe_wp_remote_get() instead.</message>
80
  </rule>
81
 
82
- <!-- https://vip.wordpress.com/documentation/code-review-what-we-look-for/#using-theme-constants -->
83
  <rule ref="WordPress.WP.DiscouragedConstants"/>
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  </ruleset>
1
  <?xml version="1.0"?>
2
  <ruleset name="WordPress VIP">
3
+ <description>Deprecated WordPress.com VIP Coding Standards. Use the official VIP coding standards instead which can be found at https://github.com/Automattic/VIP-Coding-Standards</description>
4
+
5
+ <!-- For info on WPCOM requirements: https://lobby.vip.wordpress.com/wordpress-com-documentation/code-review-what-we-look-for/ -->
6
+ <!-- For info on VIP-Go requirements: https://vip.wordpress.com/documentation/vip-go/code-review-blockers-warnings-notices/ -->
7
 
8
  <autoload>./../WordPress/PHPCSAliases.php</autoload>
9
 
10
  <rule ref="WordPress-Core"/>
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  <rule ref="WordPress.VIP"/>
13
 
14
+ <rule ref="WordPress.Security.EscapeOutput"/>
15
+ <rule ref="WordPress.Security.NonceVerification"/>
16
+
17
+ <!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/69 -->
18
+ <rule ref="WordPress.Security.ValidatedSanitizedInput"/>
19
 
 
20
  <rule ref="WordPress.PHP.StrictComparisons"/>
21
 
 
22
  <rule ref="Squiz.PHP.CommentedOutCode">
23
  <properties>
24
  <property name="maxPercentage" value="45"/>
25
  </properties>
26
  </rule>
27
 
 
 
 
 
28
  <rule ref="WordPress.PHP.DiscouragedPHPFunctions">
29
  <!-- https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/pull/633#issuecomment-266634811 -->
30
  <properties>
31
+ <property name="exclude" type="array" value="obfuscation"/>
32
  </properties>
33
  </rule>
 
34
  <rule ref="WordPress.PHP.DiscouragedPHPFunctions.runtime_configuration">
35
  <type>error</type>
36
  </rule>
37
 
 
38
  <rule ref="WordPress.PHP.DevelopmentFunctions"/>
39
  <rule ref="WordPress.PHP.DevelopmentFunctions.error_log">
40
  <type>error</type>
41
  </rule>
 
42
  <rule ref="WordPress.PHP.DevelopmentFunctions.prevent_path_disclosure">
43
  <type>error</type>
44
  </rule>
45
 
 
46
  <rule ref="WordPress.PHP.StrictInArray"/>
47
 
 
 
 
 
48
  <rule ref="WordPress.WP.AlternativeFunctions"/>
49
  <!-- VIP recommends other functions -->
50
  <rule ref="WordPress.WP.AlternativeFunctions.curl">
54
  <message>%s() is highly discouraged, please use vip_safe_wp_remote_get() instead.</message>
55
  </rule>
56
 
 
57
  <rule ref="WordPress.WP.DiscouragedConstants"/>
58
 
59
+ <rule ref="WordPress.DB.DirectDatabaseQuery"/>
60
+ <rule ref="WordPress.DB.DirectDatabaseQuery.SchemaChange">
61
+ <type>error</type>
62
+ <message>Attempting a database schema change is highly discouraged.</message>
63
+ </rule>
64
+ <rule ref="WordPress.DB.DirectDatabaseQuery.NoCaching">
65
+ <type>error</type>
66
+ <message>Usage of a direct database call without caching is prohibited on the VIP platform. Use wp_cache_get / wp_cache_set or wp_cache_delete.</message>
67
+ </rule>
68
+
69
+ <rule ref="WordPress.DB.SlowDBQuery"/>
70
+
71
+ <rule ref="WordPress.Security.PluginMenuSlug"/>
72
+ <rule ref="WordPress.Security.PluginMenuSlug.Using__FILE__">
73
+ <type>error</type>
74
+ </rule>
75
+
76
+ <rule ref="WordPress.WP.CronInterval"/>
77
+ <rule ref="WordPress.WP.CronInterval.CronSchedulesInterval">
78
+ <type>error</type>
79
+ <message>Scheduling crons at %s sec ( less than %s minutes ) is prohibited.</message>
80
+ </rule>
81
+
82
+ <rule ref="WordPress.WP.TimezoneChange"/>
83
+
84
+ <rule ref="WordPress.WP.PostsPerPage"/>
85
+ <rule ref="WordPress.WP.PostsPerPage.posts_per_page_posts_per_page">
86
+ <type>error</type>
87
+ </rule>
88
+ <rule ref="WordPress.WP.PostsPerPage.posts_per_page_numberposts">
89
+ <type>error</type>
90
+ </rule>
91
+
92
+ <rule ref="WordPress.Security.SafeRedirect"/>
93
+
94
+ <!--
95
+ #############################################################################
96
+ Account for deprecated sniffs.
97
+ These directives can be removed when the deprecated sniffs are removed.
98
+ #############################################################################
99
+ -->
100
+
101
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
102
+ <rule ref="WordPress.VIP.AdminBarRemoval.DeprecatedSniff">
103
+ <severity>0</severity>
104
+ </rule>
105
+
106
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
107
+ <rule ref="WordPress.VIP.DirectDatabaseQuery.DeprecatedSniff">
108
+ <severity>0</severity>
109
+ </rule>
110
+
111
+ <!-- Prevent duplicate messages from deprecated sniff. -->
112
+ <rule ref="WordPress.VIP.DirectDatabaseQuery.SchemaChange">
113
+ <severity>0</severity>
114
+ </rule>
115
+ <rule ref="WordPress.VIP.DirectDatabaseQuery.DirectQuery">
116
+ <severity>0</severity>
117
+ </rule>
118
+ <rule ref="WordPress.VIP.DirectDatabaseQuery.NoCaching">
119
+ <severity>0</severity>
120
+ </rule>
121
+
122
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
123
+ <rule ref="WordPress.VIP.SlowDBQuery.DeprecatedSniff">
124
+ <severity>0</severity>
125
+ </rule>
126
+
127
+ <!-- Prevent duplicate messages from deprecated sniff. -->
128
+ <rule ref="WordPress.VIP.SlowDBQuery.slow_db_query_tax_query">
129
+ <severity>0</severity>
130
+ </rule>
131
+ <rule ref="WordPress.VIP.SlowDBQuery.slow_db_query_meta_query">
132
+ <severity>0</severity>
133
+ </rule>
134
+ <rule ref="WordPress.VIP.SlowDBQuery.slow_db_query_meta_key">
135
+ <severity>0</severity>
136
+ </rule>
137
+ <rule ref="WordPress.VIP.SlowDBQuery.slow_db_query_meta_value">
138
+ <severity>0</severity>
139
+ </rule>
140
+ <rule ref="WordPress.VIP.SlowDBQuery.DeprecatedWhitelistFlagFound">
141
+ <severity>0</severity>
142
+ </rule>
143
+
144
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
145
+ <rule ref="WordPress.VIP.PluginMenuSlug.DeprecatedSniff">
146
+ <severity>0</severity>
147
+ </rule>
148
+
149
+ <!-- Prevent duplicate messages from deprecated sniff. -->
150
+ <rule ref="WordPress.VIP.PluginMenuSlug.Using__FILE__">
151
+ <severity>0</severity>
152
+ </rule>
153
+
154
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
155
+ <rule ref="WordPress.VIP.ValidatedSanitizedInput.DeprecatedSniff">
156
+ <severity>0</severity>
157
+ </rule>
158
+
159
+ <!-- Prevent duplicate messages from deprecated sniff. -->
160
+ <rule ref="WordPress.VIP.ValidatedSanitizedInput.InputNotSanitized">
161
+ <severity>0</severity>
162
+ </rule>
163
+ <rule ref="WordPress.VIP.ValidatedSanitizedInput.MissingUnslash">
164
+ <severity>0</severity>
165
+ </rule>
166
+ <rule ref="WordPress.VIP.ValidatedSanitizedInput.InputNotValidated">
167
+ <severity>0</severity>
168
+ </rule>
169
+ <rule ref="WordPress.VIP.ValidatedSanitizedInput.InputNotValidatedNotSanitized">
170
+ <severity>0</severity>
171
+ </rule>
172
+
173
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
174
+ <rule ref="WordPress.VIP.CronInterval.DeprecatedSniff">
175
+ <severity>0</severity>
176
+ </rule>
177
+
178
+ <!-- Prevent duplicate messages from deprecated sniff. -->
179
+ <rule ref="WordPress.VIP.CronInterval.CronSchedulesInterval">
180
+ <severity>0</severity>
181
+ </rule>
182
+ <rule ref="WordPress.VIP.CronInterval.ChangeDetected">
183
+ <severity>0</severity>
184
+ </rule>
185
+
186
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
187
+ <rule ref="WordPress.VIP.FileSystemWritesDisallow.DeprecatedSniff">
188
+ <severity>0</severity>
189
+ </rule>
190
+
191
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
192
+ <rule ref="WordPress.VIP.OrderByRand.DeprecatedSniff">
193
+ <severity>0</severity>
194
+ </rule>
195
+
196
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
197
+ <rule ref="WordPress.VIP.RestrictedFunctions.DeprecatedSniff">
198
+ <severity>0</severity>
199
+ </rule>
200
+
201
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
202
+ <rule ref="WordPress.VIP.RestrictedVariables.DeprecatedSniff">
203
+ <severity>0</severity>
204
+ </rule>
205
+
206
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
207
+ <rule ref="WordPress.VIP.SessionFunctionsUsage.DeprecatedSniff">
208
+ <severity>0</severity>
209
+ </rule>
210
+
211
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
212
+ <rule ref="WordPress.VIP.SessionVariableUsage.DeprecatedSniff">
213
+ <severity>0</severity>
214
+ </rule>
215
+
216
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
217
+ <rule ref="WordPress.VIP.SuperGlobalInputUsage.DeprecatedSniff">
218
+ <severity>0</severity>
219
+ </rule>
220
+
221
+ <!-- Prevent deprecation notice when the sniff is not explicitly included. -->
222
+ <rule ref="WordPress.VIP.TimezoneChange.DeprecatedSniff">
223
+ <severity>0</severity>
224
+ </rule>
225
+
226
+ <!-- Prevent duplicate messages from deprecated sniff. -->
227
+ <rule ref="WordPress.VIP.TimezoneChange.timezone_change_date_default_timezone_set">
228
+ <severity>0</severity>
229
+ </rule>
230
+
231
  </ruleset>
vendor/wp-coding-standards/wpcs/WordPress/AbstractArrayAssignmentRestrictionsSniff.php CHANGED
@@ -29,9 +29,13 @@ abstract class AbstractArrayAssignmentRestrictionsSniff extends Sniff {
29
  *
30
  * Example: 'foo,bar'
31
  *
32
- * @var string Comma-delimited group list.
 
 
 
 
33
  */
34
- public $exclude = '';
35
 
36
  /**
37
  * Groups of variable data to check against.
@@ -72,12 +76,11 @@ abstract class AbstractArrayAssignmentRestrictionsSniff extends Sniff {
72
  }
73
 
74
  return array(
75
- T_DOUBLE_ARROW,
76
- T_CLOSE_SQUARE_BRACKET,
77
- T_CONSTANT_ENCAPSED_STRING,
78
- T_DOUBLE_QUOTED_STRING,
79
  );
80
-
81
  }
82
 
83
  /**
@@ -138,9 +141,9 @@ abstract class AbstractArrayAssignmentRestrictionsSniff extends Sniff {
138
 
139
  $token = $this->tokens[ $stackPtr ];
140
 
141
- if ( T_CLOSE_SQUARE_BRACKET === $token['code'] ) {
142
- $equal = $this->phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
143
- if ( T_EQUAL !== $this->tokens[ $equal ]['code'] ) {
144
  return; // This is not an assignment!
145
  }
146
  }
@@ -153,22 +156,22 @@ abstract class AbstractArrayAssignmentRestrictionsSniff extends Sniff {
153
  * $foo = array( 'bar' => 'taz' );
154
  * $foo['bar'] = $taz;
155
  */
156
- if ( in_array( $token['code'], array( T_CLOSE_SQUARE_BRACKET, T_DOUBLE_ARROW ), true ) ) {
157
  $operator = $stackPtr; // T_DOUBLE_ARROW.
158
- if ( T_CLOSE_SQUARE_BRACKET === $token['code'] ) {
159
- $operator = $this->phpcsFile->findNext( T_EQUAL, ( $stackPtr + 1 ) );
160
  }
161
 
162
- $keyIdx = $this->phpcsFile->findPrevious( array( T_WHITESPACE, T_CLOSE_SQUARE_BRACKET ), ( $operator - 1 ), null, true );
163
  if ( ! is_numeric( $this->tokens[ $keyIdx ]['content'] ) ) {
164
  $key = $this->strip_quotes( $this->tokens[ $keyIdx ]['content'] );
165
- $valStart = $this->phpcsFile->findNext( array( T_WHITESPACE ), ( $operator + 1 ), null, true );
166
- $valEnd = $this->phpcsFile->findNext( array( T_COMMA, T_SEMICOLON ), ( $valStart + 1 ), null, false, null, true );
167
  $val = $this->phpcsFile->getTokensAsString( $valStart, ( $valEnd - $valStart ) );
168
  $val = $this->strip_quotes( $val );
169
  $inst[ $key ][] = array( $val, $token['line'] );
170
  }
171
- } elseif ( in_array( $token['code'], array( T_CONSTANT_ENCAPSED_STRING, T_DOUBLE_QUOTED_STRING ), true ) ) {
172
  // $foo = 'bar=taz&other=thing';
173
  if ( preg_match_all( '#(?:^|&)([a-z_]+)=([^&]*)#i', $this->strip_quotes( $token['content'] ), $matches ) <= 0 ) {
174
  return; // No assignments here, nothing to check.
@@ -194,11 +197,11 @@ abstract class AbstractArrayAssignmentRestrictionsSniff extends Sniff {
194
  foreach ( $assignments as $occurance ) {
195
  list( $val, $line ) = $occurance;
196
 
197
- if ( ! in_array( $key, $group['keys'], true ) ) {
198
  continue;
199
  }
200
 
201
- $output = call_user_func( $callback, $key, $val, $line, $group );
202
 
203
  if ( ! isset( $output ) || false === $output ) {
204
  continue;
@@ -218,8 +221,7 @@ abstract class AbstractArrayAssignmentRestrictionsSniff extends Sniff {
218
  }
219
  }
220
  }
221
-
222
- } // End process_token().
223
 
224
  /**
225
  * Callback to process each confirmed key, to check value.
@@ -235,4 +237,4 @@ abstract class AbstractArrayAssignmentRestrictionsSniff extends Sniff {
235
  */
236
  abstract public function callback( $key, $val, $line, $group );
237
 
238
- } // End class.
29
  *
30
  * Example: 'foo,bar'
31
  *
32
+ * @since 0.3.0
33
+ * @since 1.0.0 This property now expects to be passed an array.
34
+ * Previously a comma-delimited string was expected.
35
+ *
36
+ * @var array
37
  */
38
+ public $exclude = array();
39
 
40
  /**
41
  * Groups of variable data to check against.
76
  }
77
 
78
  return array(
79
+ \T_DOUBLE_ARROW,
80
+ \T_CLOSE_SQUARE_BRACKET,
81
+ \T_CONSTANT_ENCAPSED_STRING,
82
+ \T_DOUBLE_QUOTED_STRING,
83
  );
 
84
  }
85
 
86
  /**
141
 
142
  $token = $this->tokens[ $stackPtr ];
143
 
144
+ if ( \T_CLOSE_SQUARE_BRACKET === $token['code'] ) {
145
+ $equal = $this->phpcsFile->findNext( \T_WHITESPACE, ( $stackPtr + 1 ), null, true );
146
+ if ( \T_EQUAL !== $this->tokens[ $equal ]['code'] ) {
147
  return; // This is not an assignment!
148
  }
149
  }
156
  * $foo = array( 'bar' => 'taz' );
157
  * $foo['bar'] = $taz;
158
  */
159
+ if ( \in_array( $token['code'], array( \T_CLOSE_SQUARE_BRACKET, \T_DOUBLE_ARROW ), true ) ) {
160
  $operator = $stackPtr; // T_DOUBLE_ARROW.
161
+ if ( \T_CLOSE_SQUARE_BRACKET === $token['code'] ) {
162
+ $operator = $this->phpcsFile->findNext( \T_EQUAL, ( $stackPtr + 1 ) );
163
  }
164
 
165
+ $keyIdx = $this->phpcsFile->findPrevious( array( \T_WHITESPACE, \T_CLOSE_SQUARE_BRACKET ), ( $operator - 1 ), null, true );
166
  if ( ! is_numeric( $this->tokens[ $keyIdx ]['content'] ) ) {
167
  $key = $this->strip_quotes( $this->tokens[ $keyIdx ]['content'] );
168
+ $valStart = $this->phpcsFile->findNext( array( \T_WHITESPACE ), ( $operator + 1 ), null, true );
169
+ $valEnd = $this->phpcsFile->findNext( array( \T_COMMA, \T_SEMICOLON ), ( $valStart + 1 ), null, false, null, true );
170
  $val = $this->phpcsFile->getTokensAsString( $valStart, ( $valEnd - $valStart ) );
171
  $val = $this->strip_quotes( $val );
172
  $inst[ $key ][] = array( $val, $token['line'] );
173
  }
174
+ } elseif ( \in_array( $token['code'], array( \T_CONSTANT_ENCAPSED_STRING, \T_DOUBLE_QUOTED_STRING ), true ) ) {
175
  // $foo = 'bar=taz&other=thing';
176
  if ( preg_match_all( '#(?:^|&)([a-z_]+)=([^&]*)#i', $this->strip_quotes( $token['content'] ), $matches ) <= 0 ) {
177
  return; // No assignments here, nothing to check.
197
  foreach ( $assignments as $occurance ) {
198
  list( $val, $line ) = $occurance;
199
 
200
+ if ( ! \in_array( $key, $group['keys'], true ) ) {
201
  continue;
202
  }
203
 
204
+ $output = \call_user_func( $callback, $key, $val, $line, $group );
205
 
206
  if ( ! isset( $output ) || false === $output ) {
207
  continue;
221
  }
222
  }
223
  }
224
+ }
 
225
 
226
  /**
227
  * Callback to process each confirmed key, to check value.
237
  */
238
  abstract public function callback( $key, $val, $line, $group );
239
 
240
+ }
vendor/wp-coding-standards/wpcs/WordPress/AbstractClassRestrictionsSniff.php CHANGED
@@ -69,12 +69,11 @@ abstract class AbstractClassRestrictionsSniff extends AbstractFunctionRestrictio
69
  }
70
 
71
  return array(
72
- T_DOUBLE_COLON,
73
- T_NEW,
74
- T_EXTENDS,
75
- T_IMPLEMENTS,
76
  );
77
-
78
  }
79
 
80
  /**
@@ -119,28 +118,28 @@ abstract class AbstractClassRestrictionsSniff extends AbstractFunctionRestrictio
119
  $token = $this->tokens[ $stackPtr ];
120
  $classname = '';
121
 
122
- if ( in_array( $token['code'], array( T_NEW, T_EXTENDS, T_IMPLEMENTS ), true ) ) {
123
- if ( T_NEW === $token['code'] ) {
124
- $nameEnd = ( $this->phpcsFile->findNext( array( T_OPEN_PARENTHESIS, T_WHITESPACE, T_SEMICOLON, T_OBJECT_OPERATOR ), ( $stackPtr + 2 ) ) - 1 );
125
  } else {
126
- $nameEnd = ( $this->phpcsFile->findNext( array( T_CLOSE_CURLY_BRACKET, T_WHITESPACE ), ( $stackPtr + 2 ) ) - 1 );
127
  }
128
 
129
  $length = ( $nameEnd - ( $stackPtr + 1 ) );
130
  $classname = $this->phpcsFile->getTokensAsString( ( $stackPtr + 2 ), $length );
131
 
132
- if ( T_NS_SEPARATOR !== $this->tokens[ ( $stackPtr + 2 ) ]['code'] ) {
133
  $classname = $this->get_namespaced_classname( $classname, ( $stackPtr - 1 ) );
134
  }
135
  }
136
 
137
- if ( T_DOUBLE_COLON === $token['code'] ) {
138
- $nameEnd = $this->phpcsFile->findPrevious( T_STRING, ( $stackPtr - 1 ) );
139
- $nameStart = ( $this->phpcsFile->findPrevious( array( T_STRING, T_NS_SEPARATOR, T_NAMESPACE ), ( $nameEnd - 1 ), null, true, null, true ) + 1 );
140
  $length = ( $nameEnd - ( $nameStart - 1 ) );
141
  $classname = $this->phpcsFile->getTokensAsString( $nameStart, $length );
142
 
143
- if ( T_NS_SEPARATOR !== $this->tokens[ $nameStart ]['code'] ) {
144
  $classname = $this->get_namespaced_classname( $classname, ( $nameStart - 1 ) );
145
  }
146
  }
@@ -151,14 +150,13 @@ abstract class AbstractClassRestrictionsSniff extends AbstractFunctionRestrictio
151
  }
152
 
153
  // Nothing to do if 'parent', 'self' or 'static'.
154
- if ( in_array( $classname, array( 'parent', 'self', 'static' ), true ) ) {
155
  return false;
156
  }
157
 
158
  $this->classname = $classname;
159
  return true;
160
-
161
- } // End is_targetted_token().
162
 
163
  /**
164
  * Verify if the current token is one of the targetted classes.
@@ -189,8 +187,7 @@ abstract class AbstractClassRestrictionsSniff extends AbstractFunctionRestrictio
189
  }
190
 
191
  return min( $skip_to );
192
-
193
- } // End is_targetted_token().
194
 
195
  /**
196
  * Prepare the class name for use in a regular expression.
@@ -227,7 +224,7 @@ abstract class AbstractClassRestrictionsSniff extends AbstractFunctionRestrictio
227
  $classname = substr( $classname, 10 );
228
  }
229
 
230
- $namespace_keyword = $this->phpcsFile->findPrevious( T_NAMESPACE, $search_from );
231
  if ( false === $namespace_keyword ) {
232
  // No namespace keyword found at all, so global namespace.
233
  $classname = '\\' . $classname;
@@ -245,4 +242,4 @@ abstract class AbstractClassRestrictionsSniff extends AbstractFunctionRestrictio
245
  return $classname;
246
  }
247
 
248
- } // End class.
69
  }
70
 
71
  return array(
72
+ \T_DOUBLE_COLON,
73
+ \T_NEW,
74
+ \T_EXTENDS,
75
+ \T_IMPLEMENTS,
76
  );
 
77
  }
78
 
79
  /**
118
  $token = $this->tokens[ $stackPtr ];
119
  $classname = '';
120
 
121
+ if ( \in_array( $token['code'], array( \T_NEW, \T_EXTENDS, \T_IMPLEMENTS ), true ) ) {
122
+ if ( \T_NEW === $token['code'] ) {
123
+ $nameEnd = ( $this->phpcsFile->findNext( array( \T_OPEN_PARENTHESIS, \T_WHITESPACE, \T_SEMICOLON, \T_OBJECT_OPERATOR ), ( $stackPtr + 2 ) ) - 1 );
124
  } else {
125
+ $nameEnd = ( $this->phpcsFile->findNext( array( \T_CLOSE_CURLY_BRACKET, \T_WHITESPACE ), ( $stackPtr + 2 ) ) - 1 );
126
  }
127
 
128
  $length = ( $nameEnd - ( $stackPtr + 1 ) );
129
  $classname = $this->phpcsFile->getTokensAsString( ( $stackPtr + 2 ), $length );
130
 
131
+ if ( \T_NS_SEPARATOR !== $this->tokens[ ( $stackPtr + 2 ) ]['code'] ) {
132
  $classname = $this->get_namespaced_classname( $classname, ( $stackPtr - 1 ) );
133
  }
134
  }
135
 
136
+ if ( \T_DOUBLE_COLON === $token['code'] ) {
137
+ $nameEnd = $this->phpcsFile->findPrevious( \T_STRING, ( $stackPtr - 1 ) );
138
+ $nameStart = ( $this->phpcsFile->findPrevious( array( \T_STRING, \T_NS_SEPARATOR, \T_NAMESPACE ), ( $nameEnd - 1 ), null, true, null, true ) + 1 );
139
  $length = ( $nameEnd - ( $nameStart - 1 ) );
140
  $classname = $this->phpcsFile->getTokensAsString( $nameStart, $length );
141
 
142
+ if ( \T_NS_SEPARATOR !== $this->tokens[ $nameStart ]['code'] ) {
143
  $classname = $this->get_namespaced_classname( $classname, ( $nameStart - 1 ) );
144
  }
145
  }
150
  }
151
 
152
  // Nothing to do if 'parent', 'self' or 'static'.
153
+ if ( \in_array( $classname, array( 'parent', 'self', 'static' ), true ) ) {
154
  return false;
155
  }
156
 
157
  $this->classname = $classname;
158
  return true;
159
+ }
 
160
 
161
  /**
162
  * Verify if the current token is one of the targetted classes.
187
  }
188
 
189
  return min( $skip_to );
190
+ }
 
191
 
192
  /**
193
  * Prepare the class name for use in a regular expression.
224
  $classname = substr( $classname, 10 );
225
  }
226
 
227
+ $namespace_keyword = $this->phpcsFile->findPrevious( \T_NAMESPACE, $search_from );
228
  if ( false === $namespace_keyword ) {
229
  // No namespace keyword found at all, so global namespace.
230
  $classname = '\\' . $classname;
242
  return $classname;
243
  }
244
 
245
+ }
vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionParameterSniff.php CHANGED
@@ -109,4 +109,4 @@ abstract class AbstractFunctionParameterSniff extends AbstractFunctionRestrictio
109
  return;
110
  }
111
 
112
- } // End class.
109
  return;
110
  }
111
 
112
+ }
vendor/wp-coding-standards/wpcs/WordPress/AbstractFunctionRestrictionsSniff.php CHANGED
@@ -31,9 +31,13 @@ abstract class AbstractFunctionRestrictionsSniff extends Sniff {
31
  *
32
  * Example: 'switch_to_blog,user_meta'
33
  *
34
- * @var string Comma-delimited group list.
 
 
 
 
35
  */
36
- public $exclude = '';
37
 
38
  /**
39
  * Groups of function data to check against.
@@ -118,7 +122,7 @@ abstract class AbstractFunctionRestrictionsSniff extends Sniff {
118
  }
119
 
120
  return array(
121
- T_STRING,
122
  );
123
  }
124
 
@@ -161,7 +165,7 @@ abstract class AbstractFunctionRestrictionsSniff extends Sniff {
161
  }
162
 
163
  // Create one "super-regex" to allow for initial filtering.
164
- $all_items = call_user_func_array( 'array_merge', $all_items );
165
  $all_items = implode( '|', array_unique( $all_items ) );
166
  $this->prelim_check_regex = sprintf( $this->regex_pattern, $all_items );
167
 
@@ -195,8 +199,7 @@ abstract class AbstractFunctionRestrictionsSniff extends Sniff {
195
  if ( true === $this->is_targetted_token( $stackPtr ) ) {
196
  return $this->check_for_matches( $stackPtr );
197
  }
198
-
199
- } // End process_token().
200
 
201
  /**
202
  * Verify is the current token is a function call.
@@ -210,15 +213,17 @@ abstract class AbstractFunctionRestrictionsSniff extends Sniff {
210
  public function is_targetted_token( $stackPtr ) {
211
 
212
  // Exclude function definitions, class methods, and namespaced calls.
213
- if ( T_STRING === $this->tokens[ $stackPtr ]['code'] && isset( $this->tokens[ ( $stackPtr - 1 ) ] ) ) {
214
  $prev = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
215
 
216
  if ( false !== $prev ) {
217
  // Skip sniffing if calling a same-named method, or on function definitions.
218
  $skipped = array(
219
- T_FUNCTION => T_FUNCTION,
220
- T_DOUBLE_COLON => T_DOUBLE_COLON,
221
- T_OBJECT_OPERATOR => T_OBJECT_OPERATOR,
 
 
222
  );
223
 
224
  if ( isset( $skipped[ $this->tokens[ $prev ]['code'] ] ) ) {
@@ -226,9 +231,9 @@ abstract class AbstractFunctionRestrictionsSniff extends Sniff {
226
  }
227
 
228
  // Skip namespaced functions, ie: \foo\bar() not \bar().
229
- if ( T_NS_SEPARATOR === $this->tokens[ $prev ]['code'] ) {
230
  $pprev = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $prev - 1 ), null, true );
231
- if ( false !== $pprev && T_STRING === $this->tokens[ $pprev ]['code'] ) {
232
  return false;
233
  }
234
  }
@@ -238,8 +243,7 @@ abstract class AbstractFunctionRestrictionsSniff extends Sniff {
238
  }
239
 
240
  return false;
241
-
242
- } // End is_targetted_token().
243
 
244
  /**
245
  * Verify if the current token is one of the targetted functions.
@@ -275,8 +279,7 @@ abstract class AbstractFunctionRestrictionsSniff extends Sniff {
275
  }
276
 
277
  return min( $skip_to );
278
-
279
- } // End check_for_matches().
280
 
281
  /**
282
  * Process a matched token.
@@ -301,7 +304,7 @@ abstract class AbstractFunctionRestrictionsSniff extends Sniff {
301
  );
302
 
303
  return;
304
- } // End process_matched_token().
305
 
306
  /**
307
  * Prepare the function name for use in a regular expression.
@@ -316,11 +319,11 @@ abstract class AbstractFunctionRestrictionsSniff extends Sniff {
316
  * @return string Regex escaped function name.
317
  */
318
  protected function prepare_name_for_regex( $function ) {
319
- $function = str_replace( array( '.*', '*' ), '#', $function ); // Replace wildcards with placeholder.
320
  $function = preg_quote( $function, '`' );
321
- $function = str_replace( '#', '.*', $function ); // Replace placeholder with regex wildcard.
322
 
323
  return $function;
324
  }
325
 
326
- } // End class.
31
  *
32
  * Example: 'switch_to_blog,user_meta'
33
  *
34
+ * @since 0.3.0
35
+ * @since 1.0.0 This property now expects to be passed an array.
36
+ * Previously a comma-delimited string was expected.
37
+ *
38
+ * @var array
39
  */
40
+ public $exclude = array();
41
 
42
  /**
43
  * Groups of function data to check against.
122
  }
123
 
124
  return array(
125
+ \T_STRING,
126
  );
127
  }
128
 
165
  }
166
 
167
  // Create one "super-regex" to allow for initial filtering.
168
+ $all_items = \call_user_func_array( 'array_merge', $all_items );
169
  $all_items = implode( '|', array_unique( $all_items ) );
170
  $this->prelim_check_regex = sprintf( $this->regex_pattern, $all_items );
171
 
199
  if ( true === $this->is_targetted_token( $stackPtr ) ) {
200
  return $this->check_for_matches( $stackPtr );
201
  }
202
+ }
 
203
 
204
  /**
205
  * Verify is the current token is a function call.
213
  public function is_targetted_token( $stackPtr ) {
214
 
215
  // Exclude function definitions, class methods, and namespaced calls.
216
+ if ( \T_STRING === $this->tokens[ $stackPtr ]['code'] && isset( $this->tokens[ ( $stackPtr - 1 ) ] ) ) {
217
  $prev = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
218
 
219
  if ( false !== $prev ) {
220
  // Skip sniffing if calling a same-named method, or on function definitions.
221
  $skipped = array(
222
+ \T_FUNCTION => \T_FUNCTION,
223
+ \T_CLASS => \T_CLASS,
224
+ \T_AS => \T_AS, // Use declaration alias.
225
+ \T_DOUBLE_COLON => \T_DOUBLE_COLON,
226
+ \T_OBJECT_OPERATOR => \T_OBJECT_OPERATOR,
227
  );
228
 
229
  if ( isset( $skipped[ $this->tokens[ $prev ]['code'] ] ) ) {
231
  }
232
 
233
  // Skip namespaced functions, ie: \foo\bar() not \bar().
234
+ if ( \T_NS_SEPARATOR === $this->tokens[ $prev ]['code'] ) {
235
  $pprev = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $prev - 1 ), null, true );
236
+ if ( false !== $pprev && \T_STRING === $this->tokens[ $pprev ]['code'] ) {
237
  return false;
238
  }
239
  }
243
  }
244
 
245
  return false;
246
+ }
 
247
 
248
  /**
249
  * Verify if the current token is one of the targetted functions.
279
  }
280
 
281
  return min( $skip_to );
282
+ }
 
283
 
284
  /**
285
  * Process a matched token.
304
  );
305
 
306
  return;
307
+ }
308
 
309
  /**
310
  * Prepare the function name for use in a regular expression.
319
  * @return string Regex escaped function name.
320
  */
321
  protected function prepare_name_for_regex( $function ) {
322
+ $function = str_replace( array( '.*', '*' ), '@@', $function ); // Replace wildcards with placeholder.
323
  $function = preg_quote( $function, '`' );
324
+ $function = str_replace( '@@', '.*', $function ); // Replace placeholder with regex wildcard.
325
 
326
  return $function;
327
  }
328
 
329
+ }
vendor/wp-coding-standards/wpcs/WordPress/AbstractVariableRestrictionsSniff.php CHANGED
@@ -22,6 +22,8 @@ use WordPress\Sniff;
22
  * `WordPress_Sniffs_Variables_VariableRestrictionsSniff` to
23
  * `WordPress_AbstractVariableRestrictionsSniff`.
24
  * @since 0.11.0 Extends the WordPress_Sniff class.
 
 
25
  */
26
  abstract class AbstractVariableRestrictionsSniff extends Sniff {
27
 
@@ -30,9 +32,13 @@ abstract class AbstractVariableRestrictionsSniff extends Sniff {
30
  *
31
  * Example: 'foo,bar'
32
  *
33
- * @var string Comma-delimited group list.
 
 
 
 
34
  */
35
- public $exclude = '';
36
 
37
  /**
38
  * Groups of variable data to check against.
@@ -73,14 +79,13 @@ abstract class AbstractVariableRestrictionsSniff extends Sniff {
73
  }
74
 
75
  return array(
76
- T_VARIABLE,
77
- T_OBJECT_OPERATOR,
78
- T_DOUBLE_COLON,
79
- T_OPEN_SQUARE_BRACKET,
80
- T_DOUBLE_QUOTED_STRING,
81
- T_HEREDOC,
82
  );
83
-
84
  }
85
 
86
  /**
@@ -144,10 +149,10 @@ abstract class AbstractVariableRestrictionsSniff extends Sniff {
144
  }
145
 
146
  // Check if it is a function not a variable.
147
- if ( in_array( $token['code'], array( T_OBJECT_OPERATOR, T_DOUBLE_COLON ), true ) ) { // This only works for object vars and array members.
148
- $method = $this->phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
149
- $possible_parenthesis = $this->phpcsFile->findNext( T_WHITESPACE, ( $method + 1 ), null, true );
150
- if ( T_OPEN_PARENTHESIS === $this->tokens[ $possible_parenthesis ]['code'] ) {
151
  return; // So .. it is a function after all !
152
  }
153
  }
@@ -161,28 +166,28 @@ abstract class AbstractVariableRestrictionsSniff extends Sniff {
161
  $patterns = array();
162
 
163
  // Simple variable.
164
- if ( in_array( $token['code'], array( T_VARIABLE, T_DOUBLE_QUOTED_STRING, T_HEREDOC ), true ) && ! empty( $group['variables'] ) ) {
165
  $patterns = array_merge( $patterns, $group['variables'] );
166
  $var = $token['content'];
167
 
168
  }
169
 
170
- if ( in_array( $token['code'], array( T_OBJECT_OPERATOR, T_DOUBLE_COLON, T_DOUBLE_QUOTED_STRING, T_HEREDOC ), true ) && ! empty( $group['object_vars'] ) ) {
171
  // Object var, ex: $foo->bar / $foo::bar / Foo::bar / Foo::$bar .
172
  $patterns = array_merge( $patterns, $group['object_vars'] );
173
 
174
- $owner = $this->phpcsFile->findPrevious( array( T_VARIABLE, T_STRING ), $stackPtr );
175
- $child = $this->phpcsFile->findNext( array( T_STRING, T_VAR, T_VARIABLE ), $stackPtr );
176
  $var = implode( '', array( $this->tokens[ $owner ]['content'], $token['content'], $this->tokens[ $child ]['content'] ) );
177
 
178
  }
179
 
180
- if ( in_array( $token['code'], array( T_OPEN_SQUARE_BRACKET, T_DOUBLE_QUOTED_STRING, T_HEREDOC ), true ) && ! empty( $group['array_members'] ) ) {
181
  // Array members.
182
  $patterns = array_merge( $patterns, $group['array_members'] );
183
 
184
  if ( isset( $token['bracket_closer'] ) ) {
185
- $owner = $this->phpcsFile->findPrevious( T_VARIABLE, $stackPtr );
186
  $inside = $this->phpcsFile->getTokensAsString( $stackPtr, ( $token['bracket_closer'] - $stackPtr + 1 ) );
187
  $var = implode( '', array( $this->tokens[ $owner ]['content'], $inside ) );
188
  }
@@ -194,9 +199,9 @@ abstract class AbstractVariableRestrictionsSniff extends Sniff {
194
 
195
  $patterns = array_map( array( $this, 'test_patterns' ), $patterns );
196
  $pattern = implode( '|', $patterns );
197
- $delim = ( T_OPEN_SQUARE_BRACKET !== $token['code'] && T_HEREDOC !== $token['code'] ) ? '\b' : '';
198
 
199
- if ( T_DOUBLE_QUOTED_STRING === $token['code'] || T_HEREDOC === $token['code'] ) {
200
  $var = $token['content'];
201
  }
202
 
@@ -213,10 +218,8 @@ abstract class AbstractVariableRestrictionsSniff extends Sniff {
213
  );
214
 
215
  return; // Show one error only.
216
-
217
  }
218
-
219
- } // End process_token().
220
 
221
  /**
222
  * Transform a wildcard pattern to a usable regex pattern.
@@ -234,4 +237,4 @@ abstract class AbstractVariableRestrictionsSniff extends Sniff {
234
  return $pattern;
235
  }
236
 
237
- } // End class.
22
  * `WordPress_Sniffs_Variables_VariableRestrictionsSniff` to
23
  * `WordPress_AbstractVariableRestrictionsSniff`.
24
  * @since 0.11.0 Extends the WordPress_Sniff class.
25
+ *
26
+ * @deprecated 1.0.0 All sniffs depending on this class were deprecated.
27
  */
28
  abstract class AbstractVariableRestrictionsSniff extends Sniff {
29
 
32
  *
33
  * Example: 'foo,bar'
34
  *
35
+ * @since 0.3.0
36
+ * @since 1.0.0 This property now expects to be passed an array.
37
+ * Previously a comma-delimited string was expected.
38
+ *
39
+ * @var array
40
  */
41
+ public $exclude = array();
42
 
43
  /**
44
  * Groups of variable data to check against.
79
  }
80
 
81
  return array(
82
+ \T_VARIABLE,
83
+ \T_OBJECT_OPERATOR,
84
+ \T_DOUBLE_COLON,
85
+ \T_OPEN_SQUARE_BRACKET,
86
+ \T_DOUBLE_QUOTED_STRING,
87
+ \T_HEREDOC,
88
  );
 
89
  }
90
 
91
  /**
149
  }
150
 
151
  // Check if it is a function not a variable.
152
+ if ( \in_array( $token['code'], array( \T_OBJECT_OPERATOR, \T_DOUBLE_COLON ), true ) ) { // This only works for object vars and array members.
153
+ $method = $this->phpcsFile->findNext( \T_WHITESPACE, ( $stackPtr + 1 ), null, true );
154
+ $possible_parenthesis = $this->phpcsFile->findNext( \T_WHITESPACE, ( $method + 1 ), null, true );
155
+ if ( \T_OPEN_PARENTHESIS === $this->tokens[ $possible_parenthesis ]['code'] ) {
156
  return; // So .. it is a function after all !
157
  }
158
  }
166
  $patterns = array();
167
 
168
  // Simple variable.
169
+ if ( \in_array( $token['code'], array( \T_VARIABLE, \T_DOUBLE_QUOTED_STRING, \T_HEREDOC ), true ) && ! empty( $group['variables'] ) ) {
170
  $patterns = array_merge( $patterns, $group['variables'] );
171
  $var = $token['content'];
172
 
173
  }
174
 
175
+ if ( \in_array( $token['code'], array( \T_OBJECT_OPERATOR, \T_DOUBLE_COLON, \T_DOUBLE_QUOTED_STRING, \T_HEREDOC ), true ) && ! empty( $group['object_vars'] ) ) {
176
  // Object var, ex: $foo->bar / $foo::bar / Foo::bar / Foo::$bar .
177
  $patterns = array_merge( $patterns, $group['object_vars'] );
178
 
179
+ $owner = $this->phpcsFile->findPrevious( array( \T_VARIABLE, \T_STRING ), $stackPtr );
180
+ $child = $this->phpcsFile->findNext( array( \T_STRING, \T_VARIABLE ), $stackPtr );
181
  $var = implode( '', array( $this->tokens[ $owner ]['content'], $token['content'], $this->tokens[ $child ]['content'] ) );
182
 
183
  }
184
 
185
+ if ( \in_array( $token['code'], array( \T_OPEN_SQUARE_BRACKET, \T_DOUBLE_QUOTED_STRING, \T_HEREDOC ), true ) && ! empty( $group['array_members'] ) ) {
186
  // Array members.
187
  $patterns = array_merge( $patterns, $group['array_members'] );
188
 
189
  if ( isset( $token['bracket_closer'] ) ) {
190
+ $owner = $this->phpcsFile->findPrevious( \T_VARIABLE, $stackPtr );
191
  $inside = $this->phpcsFile->getTokensAsString( $stackPtr, ( $token['bracket_closer'] - $stackPtr + 1 ) );
192
  $var = implode( '', array( $this->tokens[ $owner ]['content'], $inside ) );
193
  }
199
 
200
  $patterns = array_map( array( $this, 'test_patterns' ), $patterns );
201
  $pattern = implode( '|', $patterns );
202
+ $delim = ( \T_OPEN_SQUARE_BRACKET !== $token['code'] && \T_HEREDOC !== $token['code'] ) ? '\b' : '';
203
 
204
+ if ( \T_DOUBLE_QUOTED_STRING === $token['code'] || \T_HEREDOC === $token['code'] ) {
205
  $var = $token['content'];
206
  }
207
 
218
  );
219
 
220
  return; // Show one error only.
 
221
  }
222
+ }
 
223
 
224
  /**
225
  * Transform a wildcard pattern to a usable regex pattern.
237
  return $pattern;
238
  }
239
 
240
+ }
vendor/wp-coding-standards/wpcs/WordPress/PHPCSAliases.php CHANGED
@@ -23,7 +23,7 @@
23
  * external PHPCS standards creating cross-version compatibility in the same
24
  * manner.}}
25
  */
26
- if ( ! defined( 'WPCS_PHPCS_ALIASES_SET' ) ) {
27
  // PHPCS base classes/interface.
28
  if ( ! interface_exists( '\PHP_CodeSniffer_Sniff' ) ) {
29
  class_alias( 'PHP_CodeSniffer\Sniffs\Sniff', '\PHP_CodeSniffer_Sniff' );
@@ -61,21 +61,23 @@ if ( ! defined( 'WPCS_PHPCS_ALIASES_SET' ) ) {
61
  * @link https://github.com/squizlabs/PHP_CodeSniffer/issues/1564
62
  * @link https://github.com/squizlabs/PHP_CodeSniffer/issues/1591
63
  */
64
- spl_autoload_register( function ( $class ) {
65
- // Only try & load our own classes.
66
- if ( stripos( $class, 'WordPress' ) !== 0 ) {
67
- return;
68
- }
 
69
 
70
- // PHPCS handles the Test and Sniff classes without problem.
71
- if ( stripos( $class, '\Tests\\' ) !== false || stripos( $class, '\Sniffs\\' ) !== false ) {
72
- return;
73
- }
74
 
75
- $file = dirname( __DIR__ ) . DIRECTORY_SEPARATOR . strtr( $class, '\\', DIRECTORY_SEPARATOR ) . '.php';
76
 
77
- if ( file_exists( $file ) ) {
78
- include_once $file;
 
79
  }
80
- } );
81
  }
23
  * external PHPCS standards creating cross-version compatibility in the same
24
  * manner.}}
25
  */
26
+ if ( ! \defined( 'WPCS_PHPCS_ALIASES_SET' ) ) {
27
  // PHPCS base classes/interface.
28
  if ( ! interface_exists( '\PHP_CodeSniffer_Sniff' ) ) {
29
  class_alias( 'PHP_CodeSniffer\Sniffs\Sniff', '\PHP_CodeSniffer_Sniff' );
61
  * @link https://github.com/squizlabs/PHP_CodeSniffer/issues/1564
62
  * @link https://github.com/squizlabs/PHP_CodeSniffer/issues/1591
63
  */
64
+ spl_autoload_register(
65
+ function ( $class ) {
66
+ // Only try & load our own classes.
67
+ if ( stripos( $class, 'WordPress' ) !== 0 ) {
68
+ return;
69
+ }
70
 
71
+ // PHPCS handles the Test and Sniff classes without problem.
72
+ if ( stripos( $class, '\Tests\\' ) !== false || stripos( $class, '\Sniffs\\' ) !== false ) {
73
+ return;
74
+ }
75
 
76
+ $file = dirname( __DIR__ ) . DIRECTORY_SEPARATOR . strtr( $class, '\\', DIRECTORY_SEPARATOR ) . '.php';
77
 
78
+ if ( file_exists( $file ) ) {
79
+ include_once $file;
80
+ }
81
  }
82
+ );
83
  }
vendor/wp-coding-standards/wpcs/WordPress/PHPCSHelper.php CHANGED
@@ -33,7 +33,7 @@ class PHPCSHelper {
33
  * @return string
34
  */
35
  public static function get_version() {
36
- if ( defined( '\PHP_CodeSniffer\Config::VERSION' ) ) {
37
  // PHPCS 3.x.
38
  return \PHP_CodeSniffer\Config::VERSION;
39
  } else {
33
  * @return string
34
  */
35
  public static function get_version() {
36
+ if ( \defined( '\PHP_CodeSniffer\Config::VERSION' ) ) {
37
  // PHPCS 3.x.
38
  return \PHP_CodeSniffer\Config::VERSION;
39
  } else {
vendor/wp-coding-standards/wpcs/WordPress/Sniff.php CHANGED
@@ -47,8 +47,9 @@ abstract class Sniff implements PHPCS_Sniff {
47
  /**
48
  * Minimum supported WordPress version.
49
  *
50
- * Currently used by the `WordPress.WP.DeprecatedClasses`,
51
- * `WordPress.WP.DeprecatedFunctions` and the `WordPress.WP.DeprecatedParameter` sniff.
 
52
  *
53
  * These sniffs will throw an error when usage of a deprecated class/function/parameter
54
  * is detected if the class/function/parameter was deprecated before the minimum
@@ -76,9 +77,12 @@ abstract class Sniff implements PHPCS_Sniff {
76
  *
77
  * @since 0.14.0 Previously the individual sniffs each contained this property.
78
  *
 
 
 
79
  * @var string WordPress version.
80
  */
81
- public $minimum_supported_version = '4.5';
82
 
83
  /**
84
  * Custom list of classes which test classes can extend.
@@ -86,7 +90,7 @@ abstract class Sniff implements PHPCS_Sniff {
86
  * This property allows end-users to add to the $test_class_whitelist via their ruleset.
87
  * This property will need to be set for each sniff which uses the
88
  * `is_test_class()` method.
89
- * Currently the method is used by the `WordPress.Variables.GlobalVariables`,
90
  * `WordPress.NamingConventions.PrefixAllGlobals` and the `WordPress.Files.Filename` sniffs.
91
  *
92
  * Example usage:
@@ -172,7 +176,6 @@ abstract class Sniff implements PHPCS_Sniff {
172
  'bloginfo' => true,
173
  'body_class' => true,
174
  'calendar_week_mod' => true,
175
- 'cancel_comment_reply_link' => true,
176
  'category_description' => true,
177
  'checked' => true,
178
  'comment_author_email_link' => true,
@@ -213,11 +216,8 @@ abstract class Sniff implements PHPCS_Sniff {
213
  'get_attachment_link' => true,
214
  'get_avatar' => true,
215
  'get_bookmark_field' => true,
216
- 'get_bookmark' => true,
217
  'get_calendar' => true,
218
  'get_comment_author_link' => true,
219
- 'get_comment_date' => true,
220
- 'get_comment_time' => true,
221
  'get_current_blog_id' => true,
222
  'get_delete_post_link' => true,
223
  'get_footer' => true,
@@ -225,7 +225,6 @@ abstract class Sniff implements PHPCS_Sniff {
225
  'get_search_form' => true,
226
  'get_search_query' => true,
227
  'get_sidebar' => true,
228
- 'get_template_part' => true,
229
  'get_the_author_link' => true,
230
  'get_the_author' => true,
231
  'get_the_date' => true,
@@ -233,21 +232,19 @@ abstract class Sniff implements PHPCS_Sniff {
233
  'get_the_post_thumbnail' => true,
234
  'get_the_term_list' => true,
235
  'get_the_title' => true,
236
- 'has_post_thumbnail' => true,
237
- 'is_attachment' => true,
238
  'next_comments_link' => true,
239
  'next_image_link' => true,
240
  'next_post_link' => true,
241
  'next_posts_link' => true,
242
  'paginate_comments_links' => true,
243
  'permalink_anchor' => true,
244
- 'post_password_required' => true,
245
  'post_type_archive_title' => true,
246
  'posts_nav_link' => true,
247
  'previous_comments_link' => true,
248
  'previous_image_link' => true,
249
  'previous_post_link' => true,
250
  'previous_posts_link' => true,
 
251
  'selected' => true,
252
  'single_cat_title' => true,
253
  'single_month_title' => true,
@@ -290,7 +287,6 @@ abstract class Sniff implements PHPCS_Sniff {
290
  'the_title' => true,
291
  'vip_powered_wpcom' => true,
292
  'walk_nav_menu_tree' => true,
293
- 'wp_attachment_is_image' => true,
294
  'wp_dropdown_categories' => true,
295
  'wp_dropdown_users' => true,
296
  'wp_enqueue_script' => true,
@@ -393,6 +389,19 @@ abstract class Sniff implements PHPCS_Sniff {
393
  'sanitize_key' => true,
394
  );
395
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  /**
397
  * Functions that format strings.
398
  *
@@ -435,10 +444,6 @@ abstract class Sniff implements PHPCS_Sniff {
435
  '_doing_it_wrong' => true,
436
  '_e' => true,
437
  '_ex' => true,
438
- 'die' => true,
439
- 'echo' => true,
440
- 'exit' => true,
441
- 'print' => true,
442
  'printf' => true,
443
  'trigger_error' => true,
444
  'user_error' => true,
@@ -850,6 +855,32 @@ abstract class Sniff implements PHPCS_Sniff {
850
  'PHPUnit\Framework\TestCase' => true,
851
  );
852
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
853
  /**
854
  * The current file being sniffed.
855
  *
@@ -915,7 +946,7 @@ abstract class Sniff implements PHPCS_Sniff {
915
  /**
916
  * Strip quotes surrounding an arbitrary string.
917
  *
918
- * Intended for use with the content of a T_CONSTANT_ENCAPSED_STRING / T_DOUBLE_QUOTED_STRING.
919
  *
920
  * @since 0.11.0
921
  *
@@ -993,7 +1024,7 @@ abstract class Sniff implements PHPCS_Sniff {
993
  $method .= 'Warning';
994
  }
995
 
996
- return call_user_func( array( $this->phpcsFile, $method ), $message, $stackPtr, $code, $data, $severity );
997
  }
998
 
999
  /**
@@ -1047,12 +1078,12 @@ abstract class Sniff implements PHPCS_Sniff {
1047
  $base = array_filter( $base );
1048
  }
1049
 
1050
- if ( empty( $custom ) || ( ! is_array( $custom ) && ! is_string( $custom ) ) ) {
1051
  return $base;
1052
  }
1053
 
1054
  // Allow for a comma delimited list.
1055
- if ( is_string( $custom ) ) {
1056
  $custom = explode( ',', $custom );
1057
  }
1058
 
@@ -1111,7 +1142,7 @@ abstract class Sniff implements PHPCS_Sniff {
1111
  protected function get_wp_version_from_cl() {
1112
  $cl_supported_version = trim( PHPCSHelper::get_config_data( 'minimum_supported_wp_version' ) );
1113
  if ( ! empty( $cl_supported_version )
1114
- && filter_var( $cl_supported_version, FILTER_VALIDATE_FLOAT ) !== false
1115
  ) {
1116
  $this->minimum_supported_version = $cl_supported_version;
1117
  }
@@ -1151,19 +1182,22 @@ abstract class Sniff implements PHPCS_Sniff {
1151
  $regex = '#\b' . preg_quote( $comment, '#' ) . '\b#i';
1152
 
1153
  // There is a findEndOfStatement() method, but it considers more tokens than
1154
- // we need to here.
1155
- $end_of_statement = $this->phpcsFile->findNext( array( T_CLOSE_TAG, T_SEMICOLON ), $stackPtr );
1156
 
1157
  if ( false !== $end_of_statement ) {
1158
  // If the statement was ended by a semicolon, check if there is a whitelist comment directly after it.
1159
- if ( T_SEMICOLON === $this->tokens[ $end_of_statement ]['code'] ) {
1160
- $lastPtr = $this->phpcsFile->findNext( T_WHITESPACE, ( $end_of_statement + 1 ), null, true );
1161
- } elseif ( T_CLOSE_TAG === $this->tokens[ $end_of_statement ]['code'] ) {
1162
  // If the semicolon was left out and it was terminated by an ending tag, we need to look backwards.
1163
- $lastPtr = $this->phpcsFile->findPrevious( T_WHITESPACE, ( $end_of_statement - 1 ), null, true );
1164
  }
1165
 
1166
- if ( T_COMMENT === $this->tokens[ $lastPtr ]['code']
 
 
 
1167
  && $this->tokens[ $lastPtr ]['line'] === $this->tokens[ $end_of_statement ]['line']
1168
  && preg_match( $regex, $this->tokens[ $lastPtr ]['content'] ) === 1
1169
  ) {
@@ -1174,9 +1208,12 @@ abstract class Sniff implements PHPCS_Sniff {
1174
  // No whitelist comment found so far. Check at the end of the stackPtr line.
1175
  // Note: a T_COMMENT includes the new line character, so may be the last token on the line!
1176
  $end_of_line = $this->get_last_ptr_on_line( $stackPtr );
1177
- $lastPtr = $this->phpcsFile->findPrevious( T_WHITESPACE, $end_of_line, null, true );
1178
 
1179
- if ( T_COMMENT === $this->tokens[ $lastPtr ]['code']
 
 
 
1180
  && $this->tokens[ $lastPtr ]['line'] === $this->tokens[ $stackPtr ]['line']
1181
  && preg_match( $regex, $this->tokens[ $lastPtr ]['content'] ) === 1
1182
  ) {
@@ -1190,10 +1227,11 @@ abstract class Sniff implements PHPCS_Sniff {
1190
  * Check if a token is used within a unit test.
1191
  *
1192
  * Unit test methods are identified as such:
1193
- * - Method name starts with `test_`.
1194
- * - Method is within a unit test class.
1195
  *
1196
  * @since 0.11.0
 
1197
  *
1198
  * @param int $stackPtr The position of the token to be examined.
1199
  *
@@ -1201,24 +1239,40 @@ abstract class Sniff implements PHPCS_Sniff {
1201
  */
1202
  protected function is_token_in_test_method( $stackPtr ) {
1203
  // Is the token inside of a function definition ?
1204
- $functionToken = $this->phpcsFile->getCondition( $stackPtr, T_FUNCTION );
1205
  if ( false === $functionToken ) {
 
1206
  return false;
1207
  }
1208
 
1209
- // Is this a method inside of a class or a trait ?
1210
- $classToken = $this->phpcsFile->getCondition( $functionToken, T_CLASS );
1211
- $traitToken = $this->phpcsFile->getCondition( $functionToken, T_TRAIT );
1212
- if ( false === $classToken && false === $traitToken ) {
1213
- return false;
1214
- }
 
 
 
 
 
 
 
 
 
 
 
 
1215
 
1216
- $structureToken = $classToken;
1217
- if ( false !== $traitToken ) {
1218
- $structureToken = $traitToken;
 
 
 
1219
  }
1220
 
1221
- return $this->is_test_class( $structureToken );
1222
  }
1223
 
1224
  /**
@@ -1229,6 +1283,7 @@ abstract class Sniff implements PHPCS_Sniff {
1229
  * or a custom whitelisted unit test class.
1230
  *
1231
  * @since 0.12.0 Split off from the `is_token_in_test_method()` method.
 
1232
  *
1233
  * @param int $stackPtr The position of the token to be examined.
1234
  * This should be a class, anonymous class or trait token.
@@ -1238,7 +1293,7 @@ abstract class Sniff implements PHPCS_Sniff {
1238
  protected function is_test_class( $stackPtr ) {
1239
 
1240
  if ( ! isset( $this->tokens[ $stackPtr ] )
1241
- || in_array( $this->tokens[ $stackPtr ]['type'], array( 'T_CLASS', 'T_ANON_CLASS', 'T_TRAIT' ), true ) === false
1242
  ) {
1243
  return false;
1244
  }
@@ -1249,18 +1304,46 @@ abstract class Sniff implements PHPCS_Sniff {
1249
  $this->test_class_whitelist
1250
  );
1251
 
 
 
 
 
 
 
 
 
1252
  // Is the class/trait one of the whitelisted test classes ?
 
1253
  $className = $this->phpcsFile->getDeclarationName( $stackPtr );
1254
- if ( isset( $whitelist[ $className ] ) ) {
 
 
 
 
1255
  return true;
1256
  }
1257
 
1258
  // Does the class/trait extend one of the whitelisted test classes ?
1259
  $extendedClassName = $this->phpcsFile->findExtendedClassName( $stackPtr );
1260
- if ( isset( $whitelist[ $extendedClassName ] ) ) {
 
 
 
 
 
 
 
 
1261
  return true;
1262
  }
1263
 
 
 
 
 
 
 
 
1264
  return false;
1265
  }
1266
 
@@ -1283,8 +1366,8 @@ abstract class Sniff implements PHPCS_Sniff {
1283
  protected function is_assignment( $stackPtr ) {
1284
 
1285
  static $valid = array(
1286
- T_VARIABLE => true,
1287
- T_CLOSE_SQUARE_BRACKET => true,
1288
  );
1289
 
1290
  // Must be a variable, constant or closing square bracket (see below).
@@ -1312,7 +1395,7 @@ abstract class Sniff implements PHPCS_Sniff {
1312
  }
1313
 
1314
  // Check if this is an array assignment, e.g., `$var['key'] = 'val';` .
1315
- if ( T_OPEN_SQUARE_BRACKET === $this->tokens[ $next_non_empty ]['code'] ) {
1316
  return $this->is_assignment( $this->tokens[ $next_non_empty ]['bracket_closer'] );
1317
  }
1318
 
@@ -1349,11 +1432,11 @@ abstract class Sniff implements PHPCS_Sniff {
1349
  $tokens = $this->phpcsFile->getTokens();
1350
 
1351
  // If we're in a function, only look inside of it.
1352
- $f = $this->phpcsFile->getCondition( $stackPtr, T_FUNCTION );
1353
  if ( false !== $f ) {
1354
  $start = $tokens[ $f ]['scope_opener'];
1355
  } else {
1356
- $f = $this->phpcsFile->getCondition( $stackPtr, T_CLOSURE );
1357
  if ( false !== $f ) {
1358
  $start = $tokens[ $f ]['scope_opener'];
1359
  }
@@ -1402,7 +1485,7 @@ abstract class Sniff implements PHPCS_Sniff {
1402
  for ( $i = $start; $i < $end; $i++ ) {
1403
 
1404
  // If this isn't a function name, skip it.
1405
- if ( T_STRING !== $tokens[ $i ]['code'] ) {
1406
  continue;
1407
  }
1408
 
@@ -1434,11 +1517,13 @@ abstract class Sniff implements PHPCS_Sniff {
1434
  return false;
1435
  }
1436
 
1437
- end( $this->tokens[ $stackPtr ]['nested_parenthesis'] );
1438
- $open_parenthesis = key( $this->tokens[ $stackPtr ]['nested_parenthesis'] );
1439
- reset( $this->tokens[ $stackPtr ]['nested_parenthesis'] );
1440
 
1441
- return in_array( $this->tokens[ ( $open_parenthesis - 1 ) ]['code'], array( T_ISSET, T_EMPTY ), true );
 
 
 
 
1442
  }
1443
 
1444
  /**
@@ -1471,7 +1556,7 @@ abstract class Sniff implements PHPCS_Sniff {
1471
 
1472
  // The only parentheses should belong to the sanitizing function. If there's
1473
  // more than one set, this isn't *only* sanitization.
1474
- return ( count( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) === 1 );
1475
  }
1476
 
1477
  /**
@@ -1493,8 +1578,12 @@ abstract class Sniff implements PHPCS_Sniff {
1493
  true
1494
  );
1495
 
 
 
 
 
1496
  // Check if it is a safe cast.
1497
- return in_array( $this->tokens[ $prev ]['code'], array( T_INT_CAST, T_DOUBLE_CAST, T_BOOL_CAST ), true );
1498
  }
1499
 
1500
  /**
@@ -1524,17 +1613,18 @@ abstract class Sniff implements PHPCS_Sniff {
1524
  }
1525
 
1526
  // Get the function that it's in.
1527
- $function_closer = end( $this->tokens[ $stackPtr ]['nested_parenthesis'] );
1528
- $function_opener = key( $this->tokens[ $stackPtr ]['nested_parenthesis'] );
1529
- $function = $this->tokens[ ( $function_opener - 1 ) ];
 
1530
 
1531
  // If it is just being unset, the value isn't used at all, so it's safe.
1532
- if ( T_UNSET === $function['code'] ) {
1533
  return true;
1534
  }
1535
 
1536
  // If this isn't a call to a function, it sure isn't sanitizing function.
1537
- if ( T_STRING !== $function['code'] ) {
1538
  if ( $require_unslash ) {
1539
  $this->add_unslash_error( $stackPtr );
1540
  }
@@ -1547,14 +1637,14 @@ abstract class Sniff implements PHPCS_Sniff {
1547
  if ( 'wp_unslash' === $functionName ) {
1548
 
1549
  $is_unslashed = true;
1550
- $function_closer = prev( $this->tokens[ $stackPtr ]['nested_parenthesis'] );
1551
 
1552
  // If there is no other function being used, this value is unsanitized.
1553
  if ( ! $function_closer ) {
1554
  return false;
1555
  }
1556
 
1557
- $function_opener = key( $this->tokens[ $stackPtr ]['nested_parenthesis'] );
1558
  $functionName = $this->tokens[ ( $function_opener - 1 ) ]['content'];
1559
 
1560
  } else {
@@ -1580,7 +1670,7 @@ abstract class Sniff implements PHPCS_Sniff {
1580
  true
1581
  );
1582
 
1583
- if ( false !== $first_non_empty && T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $first_non_empty ]['code'] ) {
1584
  $functionName = $this->strip_quotes( $this->tokens[ $first_non_empty ]['content'] );
1585
  }
1586
  }
@@ -1638,7 +1728,7 @@ abstract class Sniff implements PHPCS_Sniff {
1638
  );
1639
 
1640
  // If it isn't a bracket, this isn't an array-access.
1641
- if ( false === $open_bracket || T_OPEN_SQUARE_BRACKET !== $this->tokens[ $open_bracket ]['code'] ) {
1642
  return false;
1643
  }
1644
 
@@ -1719,14 +1809,14 @@ abstract class Sniff implements PHPCS_Sniff {
1719
  $scope_start = 0;
1720
 
1721
  // Check if we are in a function.
1722
- $function = $this->phpcsFile->getCondition( $stackPtr, T_FUNCTION );
1723
 
1724
  // If so, we check only within the function, otherwise the whole file.
1725
  if ( false !== $function ) {
1726
  $scope_start = $this->tokens[ $function ]['scope_opener'];
1727
  } else {
1728
  // Check if we are in a closure.
1729
- $closure = $this->phpcsFile->getCondition( $stackPtr, T_CLOSURE );
1730
 
1731
  // If so, we check only within the closure.
1732
  if ( false !== $closure ) {
@@ -1738,25 +1828,28 @@ abstract class Sniff implements PHPCS_Sniff {
1738
 
1739
  }
1740
 
 
 
1741
  for ( $i = ( $scope_start + 1 ); $i < $scope_end; $i++ ) {
1742
 
1743
- if ( ! in_array( $this->tokens[ $i ]['code'], array( T_ISSET, T_EMPTY, T_UNSET ), true ) ) {
1744
  continue;
1745
  }
1746
 
1747
- $issetOpener = $this->phpcsFile->findNext( T_OPEN_PARENTHESIS, $i );
1748
  $issetCloser = $this->tokens[ $issetOpener ]['parenthesis_closer'];
1749
 
1750
  // Look for this variable. We purposely stomp $i from the parent loop.
1751
  for ( $i = ( $issetOpener + 1 ); $i < $issetCloser; $i++ ) {
1752
 
1753
- if ( T_VARIABLE !== $this->tokens[ $i ]['code'] ) {
1754
  continue;
1755
  }
1756
 
1757
  // If we're checking for a specific array key (ex: 'hello' in
1758
- // $_POST['hello']), that must match too.
1759
- if ( isset( $array_key ) && $this->get_array_access_key( $i ) !== $array_key ) {
 
1760
  continue;
1761
  }
1762
 
@@ -1784,11 +1877,12 @@ abstract class Sniff implements PHPCS_Sniff {
1784
 
1785
  // We first check if this is a switch statement (switch ( $var )).
1786
  if ( isset( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) ) {
1787
- $close_parenthesis = end( $this->tokens[ $stackPtr ]['nested_parenthesis'] );
 
1788
 
1789
  if (
1790
  isset( $this->tokens[ $close_parenthesis ]['parenthesis_owner'] )
1791
- && T_SWITCH === $this->tokens[ $this->tokens[ $close_parenthesis ]['parenthesis_owner'] ]['code']
1792
  ) {
1793
  return true;
1794
  }
@@ -1816,7 +1910,7 @@ abstract class Sniff implements PHPCS_Sniff {
1816
  );
1817
 
1818
  // This might be an opening square bracket in the case of arrays ($var['a']).
1819
- while ( T_OPEN_SQUARE_BRACKET === $this->tokens[ $next_token ]['code'] ) {
1820
 
1821
  $next_token = $this->phpcsFile->findNext(
1822
  Tokens::$emptyTokens,
@@ -1854,9 +1948,9 @@ abstract class Sniff implements PHPCS_Sniff {
1854
  protected function get_use_type( $stackPtr ) {
1855
 
1856
  // USE keywords inside closures.
1857
- $next = $this->phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), null, true );
1858
 
1859
- if ( T_OPEN_PARENTHESIS === $this->tokens[ $next ]['code'] ) {
1860
  return 'closure';
1861
  }
1862
 
@@ -1866,7 +1960,7 @@ abstract class Sniff implements PHPCS_Sniff {
1866
  'T_ANON_CLASS' => true,
1867
  'T_TRAIT' => true,
1868
  );
1869
- if ( true === $this->valid_direct_scope( $stackPtr, $valid_scopes ) ) {
1870
  return 'trait';
1871
  }
1872
 
@@ -1881,15 +1975,15 @@ abstract class Sniff implements PHPCS_Sniff {
1881
  *
1882
  * @since 0.9.0
1883
  *
1884
- * @param string $string A T_DOUBLE_QUOTED_STRING or T_HEREDOC token.
1885
  *
1886
  * @return array Variable names (without '$' sigil).
1887
  */
1888
  protected function get_interpolated_variables( $string ) {
1889
  $variables = array();
1890
- if ( preg_match_all( '/(?P<backslashes>\\\\*)\$(?P<symbol>\w+)/', $string, $match_sets, PREG_SET_ORDER ) ) {
1891
  foreach ( $match_sets as $matches ) {
1892
- if ( ! isset( $matches['backslashes'] ) || ( strlen( $matches['backslashes'] ) % 2 ) === 0 ) {
1893
  $variables[] = $matches['symbol'];
1894
  }
1895
  }
@@ -1900,7 +1994,7 @@ abstract class Sniff implements PHPCS_Sniff {
1900
  /**
1901
  * Strip variables from an arbitrary double quoted/heredoc string.
1902
  *
1903
- * Intended for use with the content of a T_DOUBLE_QUOTED_STRING or T_HEREDOC token.
1904
  *
1905
  * @since 0.14.0
1906
  *
@@ -1925,8 +2019,8 @@ abstract class Sniff implements PHPCS_Sniff {
1925
  * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer, it
1926
  * will detect whether the array has values or is empty.
1927
  *
1928
- * @link https://github.com/wimg/PHPCompatibility/issues/120
1929
- * @link https://github.com/wimg/PHPCompatibility/issues/152
1930
  *
1931
  * @since 0.11.0
1932
  *
@@ -1942,7 +2036,7 @@ abstract class Sniff implements PHPCS_Sniff {
1942
  }
1943
 
1944
  // Is this one of the tokens this function handles ?
1945
- if ( false === in_array( $this->tokens[ $stackPtr ]['code'], array( T_STRING, T_ARRAY, T_OPEN_SHORT_ARRAY ), true ) ) {
1946
  return false;
1947
  }
1948
 
@@ -1964,7 +2058,7 @@ abstract class Sniff implements PHPCS_Sniff {
1964
 
1965
  // Deal with function calls & long arrays.
1966
  // Next non-empty token should be the open parenthesis.
1967
- if ( false === $next_non_empty && T_OPEN_PARENTHESIS !== $this->tokens[ $next_non_empty ]['code'] ) {
1968
  return false;
1969
  }
1970
 
@@ -1992,9 +2086,9 @@ abstract class Sniff implements PHPCS_Sniff {
1992
  * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer,
1993
  * it will return the number of values in the array.
1994
  *
1995
- * @link https://github.com/wimg/PHPCompatibility/issues/111
1996
- * @link https://github.com/wimg/PHPCompatibility/issues/114
1997
- * @link https://github.com/wimg/PHPCompatibility/issues/151
1998
  *
1999
  * @since 0.11.0
2000
  *
@@ -2007,7 +2101,7 @@ abstract class Sniff implements PHPCS_Sniff {
2007
  return 0;
2008
  }
2009
 
2010
- return count( $this->get_function_call_parameters( $stackPtr ) );
2011
  }
2012
 
2013
  /**
@@ -2024,7 +2118,7 @@ abstract class Sniff implements PHPCS_Sniff {
2024
  * @param int $stackPtr The position of the function call token.
2025
  *
2026
  * @return array Multi-dimentional array with parameter details or
2027
- * empty array if no parameter are found.
2028
  *
2029
  * @type int $position 1-based index position of the parameter. {
2030
  * @type int $start Stack pointer for the start of the parameter.
@@ -2057,14 +2151,14 @@ abstract class Sniff implements PHPCS_Sniff {
2057
 
2058
  // Which nesting level is the one we are interested in ?
2059
  if ( isset( $this->tokens[ $opener ]['nested_parenthesis'] ) ) {
2060
- $nestedParenthesisCount += count( $this->tokens[ $opener ]['nested_parenthesis'] );
2061
  }
2062
 
2063
  $parameters = array();
2064
  $next_comma = $opener;
2065
  $param_start = ( $opener + 1 );
2066
  $cnt = 1;
2067
- while ( $next_comma = $this->phpcsFile->findNext( array( T_COMMA, $this->tokens[ $closer ]['code'], T_OPEN_SHORT_ARRAY ), ( $next_comma + 1 ), ( $closer + 1 ) ) ) {
2068
  // Ignore anything within short array definition brackets.
2069
  if ( 'T_OPEN_SHORT_ARRAY' === $this->tokens[ $next_comma ]['type']
2070
  && ( isset( $this->tokens[ $next_comma ]['bracket_opener'] )
@@ -2076,10 +2170,21 @@ abstract class Sniff implements PHPCS_Sniff {
2076
  continue;
2077
  }
2078
 
 
 
 
 
 
 
 
 
 
 
 
2079
  // Ignore comma's at a lower nesting level.
2080
- if ( T_COMMA === $this->tokens[ $next_comma ]['code']
2081
  && isset( $this->tokens[ $next_comma ]['nested_parenthesis'] )
2082
- && count( $this->tokens[ $next_comma ]['nested_parenthesis'] ) !== $nestedParenthesisCount
2083
  ) {
2084
  continue;
2085
  }
@@ -2153,7 +2258,7 @@ abstract class Sniff implements PHPCS_Sniff {
2153
  /*
2154
  * Determine the array opener & closer.
2155
  */
2156
- if ( T_ARRAY === $this->tokens[ $stackPtr ]['code'] ) {
2157
  if ( isset( $this->tokens[ $stackPtr ]['parenthesis_opener'] ) ) {
2158
  $opener = $this->tokens[ $stackPtr ]['parenthesis_opener'];
2159
 
@@ -2199,7 +2304,7 @@ abstract class Sniff implements PHPCS_Sniff {
2199
 
2200
  // Check for scoped namespace {}.
2201
  if ( ! empty( $this->tokens[ $stackPtr ]['conditions'] ) ) {
2202
- $namespacePtr = $this->phpcsFile->getCondition( $stackPtr, T_NAMESPACE );
2203
  if ( false !== $namespacePtr ) {
2204
  $namespace = $this->get_declared_namespace_name( $namespacePtr );
2205
  if ( false !== $namespace ) {
@@ -2222,7 +2327,7 @@ abstract class Sniff implements PHPCS_Sniff {
2222
  $previousNSToken = $stackPtr;
2223
  $namespace = false;
2224
  do {
2225
- $previousNSToken = $this->phpcsFile->findPrevious( T_NAMESPACE, ( $previousNSToken - 1 ) );
2226
 
2227
  // Stop if we encounter a scoped namespace declaration as we already know we're not in one.
2228
  if ( ! empty( $this->tokens[ $previousNSToken ]['scope_condition'] )
@@ -2264,33 +2369,35 @@ abstract class Sniff implements PHPCS_Sniff {
2264
  return false;
2265
  }
2266
 
2267
- if ( T_NAMESPACE !== $this->tokens[ $stackPtr ]['code'] ) {
2268
  return false;
2269
  }
2270
 
2271
- if ( T_NS_SEPARATOR === $this->tokens[ ( $stackPtr + 1 ) ]['code'] ) {
 
2272
  // Not a namespace declaration, but use of, i.e. `namespace\someFunction();`.
2273
  return false;
2274
  }
2275
 
2276
- $nextToken = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
2277
- if ( T_OPEN_CURLY_BRACKET === $this->tokens[ $nextToken ]['code'] ) {
2278
  // Declaration for global namespace when using multiple namespaces in a file.
2279
  // I.e.: `namespace {}`.
2280
  return '';
2281
  }
2282
 
2283
  // Ok, this should be a namespace declaration, so get all the parts together.
2284
- $validTokens = array(
2285
- T_STRING => true,
2286
- T_NS_SEPARATOR => true,
2287
- T_WHITESPACE => true,
2288
  );
 
2289
 
2290
  $namespaceName = '';
2291
  while ( isset( $validTokens[ $this->tokens[ $nextToken ]['code'] ] ) ) {
2292
- $namespaceName .= trim( $this->tokens[ $nextToken ]['content'] );
2293
- $nextToken++;
 
 
2294
  }
2295
 
2296
  return $namespaceName;
@@ -2304,6 +2411,7 @@ abstract class Sniff implements PHPCS_Sniff {
2304
  * originally created.
2305
  * @since 0.13.0 The $stackPtr parameter is now optional. Either that or the
2306
  * $content parameter has to be passed.
 
2307
  *
2308
  * @param string $tag_name The name of the HTML tag without brackets. So if
2309
  * searching for '<span...', this would be 'span'.
@@ -2340,7 +2448,7 @@ abstract class Sniff implements PHPCS_Sniff {
2340
  * @return bool
2341
  */
2342
  public function is_class_constant( $stackPtr ) {
2343
- if ( ! isset( $this->tokens[ $stackPtr ] ) || T_CONST !== $this->tokens[ $stackPtr ]['code'] ) {
2344
  return false;
2345
  }
2346
 
@@ -2351,7 +2459,7 @@ abstract class Sniff implements PHPCS_Sniff {
2351
  'T_INTERFACE' => true,
2352
  );
2353
 
2354
- return $this->valid_direct_scope( $stackPtr, $valid_scopes );
2355
  }
2356
 
2357
  /**
@@ -2364,7 +2472,7 @@ abstract class Sniff implements PHPCS_Sniff {
2364
  * @return bool
2365
  */
2366
  public function is_class_property( $stackPtr ) {
2367
- if ( ! isset( $this->tokens[ $stackPtr ] ) || T_VARIABLE !== $this->tokens[ $stackPtr ]['code'] ) {
2368
  return false;
2369
  }
2370
 
@@ -2375,10 +2483,20 @@ abstract class Sniff implements PHPCS_Sniff {
2375
  'T_TRAIT' => true,
2376
  );
2377
 
2378
- if ( $this->valid_direct_scope( $stackPtr, $valid_scopes ) ) {
 
2379
  // Make sure it's not a method parameter.
2380
  if ( empty( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) ) {
2381
  return true;
 
 
 
 
 
 
 
 
 
2382
  }
2383
  }
2384
 
@@ -2399,7 +2517,7 @@ abstract class Sniff implements PHPCS_Sniff {
2399
  * to allow for newer token types.
2400
  * Value is irrelevant.
2401
  *
2402
- * @return bool
2403
  */
2404
  protected function valid_direct_scope( $stackPtr, array $valid_scopes ) {
2405
  if ( empty( $this->tokens[ $stackPtr ]['conditions'] ) ) {
@@ -2416,7 +2534,11 @@ abstract class Sniff implements PHPCS_Sniff {
2416
  return false;
2417
  }
2418
 
2419
- return isset( $valid_scopes[ $this->tokens[ $ptr ]['type'] ] );
 
 
 
 
2420
  }
2421
 
2422
  /**
@@ -2442,15 +2564,15 @@ abstract class Sniff implements PHPCS_Sniff {
2442
  protected function is_wpdb_method_call( $stackPtr, $target_methods ) {
2443
 
2444
  // Check for wpdb.
2445
- if ( ( T_VARIABLE === $this->tokens[ $stackPtr ]['code'] && '$wpdb' !== $this->tokens[ $stackPtr ]['content'] )
2446
- || ( T_STRING === $this->tokens[ $stackPtr ]['code'] && 'wpdb' !== $this->tokens[ $stackPtr ]['content'] )
2447
  ) {
2448
  return false;
2449
  }
2450
 
2451
  // Check that this is a method call.
2452
  $is_object_call = $this->phpcsFile->findNext(
2453
- array( T_OBJECT_OPERATOR, T_DOUBLE_COLON ),
2454
  ( $stackPtr + 1 ),
2455
  null,
2456
  false,
@@ -2461,17 +2583,17 @@ abstract class Sniff implements PHPCS_Sniff {
2461
  return false;
2462
  }
2463
 
2464
- $methodPtr = $this->phpcsFile->findNext( T_WHITESPACE, ( $is_object_call + 1 ), null, true, null, true );
2465
  if ( false === $methodPtr ) {
2466
  return false;
2467
  }
2468
 
2469
- if ( T_STRING === $this->tokens[ $methodPtr ]['code'] && property_exists( $this, 'methodPtr' ) ) {
2470
  $this->methodPtr = $methodPtr;
2471
  }
2472
 
2473
  // Find the opening parenthesis.
2474
- $opening_paren = $this->phpcsFile->findNext( T_WHITESPACE, ( $methodPtr + 1 ), null, true, null, true );
2475
 
2476
  if ( false === $opening_paren ) {
2477
  return false;
@@ -2481,7 +2603,7 @@ abstract class Sniff implements PHPCS_Sniff {
2481
  $this->i = $opening_paren;
2482
  }
2483
 
2484
- if ( T_OPEN_PARENTHESIS !== $this->tokens[ $opening_paren ]['code']
2485
  || ! isset( $this->tokens[ $opening_paren ]['parenthesis_closer'] )
2486
  ) {
2487
  return false;
@@ -2495,7 +2617,7 @@ abstract class Sniff implements PHPCS_Sniff {
2495
  // Find the end of the first parameter.
2496
  $end = $this->phpcsFile->findEndOfStatement( $opening_paren + 1 );
2497
 
2498
- if ( T_COMMA !== $this->tokens[ $end ]['code'] ) {
2499
  ++$end;
2500
  }
2501
 
@@ -2504,6 +2626,147 @@ abstract class Sniff implements PHPCS_Sniff {
2504
  }
2505
 
2506
  return true;
2507
- } // End is_wpdb_method_call().
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2508
 
2509
  }
47
  /**
48
  * Minimum supported WordPress version.
49
  *
50
+ * Currently used by the `WordPress.WP.AlternativeFunctions`,
51
+ * `WordPress.WP.DeprecatedClasses`, `WordPress.WP.DeprecatedFunctions`
52
+ * and the `WordPress.WP.DeprecatedParameter` sniff.
53
  *
54
  * These sniffs will throw an error when usage of a deprecated class/function/parameter
55
  * is detected if the class/function/parameter was deprecated before the minimum
77
  *
78
  * @since 0.14.0 Previously the individual sniffs each contained this property.
79
  *
80
+ * @internal When the value of this property is changed, it will also need
81
+ * to be changed in the `WP/AlternativeFunctionsUnitTest.inc` file.
82
+ *
83
  * @var string WordPress version.
84
  */
85
+ public $minimum_supported_version = '4.6';
86
 
87
  /**
88
  * Custom list of classes which test classes can extend.
90
  * This property allows end-users to add to the $test_class_whitelist via their ruleset.
91
  * This property will need to be set for each sniff which uses the
92
  * `is_test_class()` method.
93
+ * Currently the method is used by the `WordPress.WP.GlobalVariablesOverride`,
94
  * `WordPress.NamingConventions.PrefixAllGlobals` and the `WordPress.Files.Filename` sniffs.
95
  *
96
  * Example usage:
176
  'bloginfo' => true,
177
  'body_class' => true,
178
  'calendar_week_mod' => true,
 
179
  'category_description' => true,
180
  'checked' => true,
181
  'comment_author_email_link' => true,
216
  'get_attachment_link' => true,
217
  'get_avatar' => true,
218
  'get_bookmark_field' => true,
 
219
  'get_calendar' => true,
220
  'get_comment_author_link' => true,
 
 
221
  'get_current_blog_id' => true,
222
  'get_delete_post_link' => true,
223
  'get_footer' => true,
225
  'get_search_form' => true,
226
  'get_search_query' => true,
227
  'get_sidebar' => true,
 
228
  'get_the_author_link' => true,
229
  'get_the_author' => true,
230
  'get_the_date' => true,
232
  'get_the_post_thumbnail' => true,
233
  'get_the_term_list' => true,
234
  'get_the_title' => true,
 
 
235
  'next_comments_link' => true,
236
  'next_image_link' => true,
237
  'next_post_link' => true,
238
  'next_posts_link' => true,
239
  'paginate_comments_links' => true,
240
  'permalink_anchor' => true,
 
241
  'post_type_archive_title' => true,
242
  'posts_nav_link' => true,
243
  'previous_comments_link' => true,
244
  'previous_image_link' => true,
245
  'previous_post_link' => true,
246
  'previous_posts_link' => true,
247
+ 'readonly' => true,
248
  'selected' => true,
249
  'single_cat_title' => true,
250
  'single_month_title' => true,
287
  'the_title' => true,
288
  'vip_powered_wpcom' => true,
289
  'walk_nav_menu_tree' => true,
 
290
  'wp_dropdown_categories' => true,
291
  'wp_dropdown_users' => true,
292
  'wp_enqueue_script' => true,
389
  'sanitize_key' => true,
390
  );
391
 
392
+ /**
393
+ * Token which when they preceed code indicate the value is safely casted.
394
+ *
395
+ * @since 1.1.0
396
+ *
397
+ * @var array
398
+ */
399
+ protected $safe_casts = array(
400
+ \T_INT_CAST => true,
401
+ \T_DOUBLE_CAST => true,
402
+ \T_BOOL_CAST => true,
403
+ );
404
+
405
  /**
406
  * Functions that format strings.
407
  *
444
  '_doing_it_wrong' => true,
445
  '_e' => true,
446
  '_ex' => true,
 
 
 
 
447
  'printf' => true,
448
  'trigger_error' => true,
449
  'user_error' => true,
855
  'PHPUnit\Framework\TestCase' => true,
856
  );
857
 
858
+ /**
859
+ * The token "type" values for the PHPCS 3.2+ whitelist comments.
860
+ *
861
+ * PHPCS cross-version compatibility layer to allow sniffs to
862
+ * allow for the new PHPCS annotation comments without breaking in older
863
+ * PHPCS versions.
864
+ *
865
+ * @internal Can be replaced with using the PHPCS native Token::$phpcsCommentTokens
866
+ * array once the minimum WPCS requirement for PHPCS has gone up
867
+ * to PHPCS 3.2.3.
868
+ * Note: The PHPCS native property uses the constants/ token "code",
869
+ * so code referring to this property will need to be adjusted when
870
+ * the property is removed.
871
+ *
872
+ * @since 1.0.0
873
+ *
874
+ * @var array
875
+ */
876
+ protected $phpcsCommentTokens = array(
877
+ 'T_PHPCS_ENABLE' => true,
878
+ 'T_PHPCS_DISABLE' => true,
879
+ 'T_PHPCS_SET' => true,
880
+ 'T_PHPCS_IGNORE' => true,
881
+ 'T_PHPCS_IGNORE_FILE' => true,
882
+ );
883
+
884
  /**
885
  * The current file being sniffed.
886
  *
946
  /**
947
  * Strip quotes surrounding an arbitrary string.
948
  *
949
+ * Intended for use with the contents of a T_CONSTANT_ENCAPSED_STRING / T_DOUBLE_QUOTED_STRING.
950
  *
951
  * @since 0.11.0
952
  *
1024
  $method .= 'Warning';
1025
  }
1026
 
1027
+ return \call_user_func( array( $this->phpcsFile, $method ), $message, $stackPtr, $code, $data, $severity );
1028
  }
1029
 
1030
  /**
1078
  $base = array_filter( $base );
1079
  }
1080
 
1081
+ if ( empty( $custom ) || ( ! \is_array( $custom ) && ! \is_string( $custom ) ) ) {
1082
  return $base;
1083
  }
1084
 
1085
  // Allow for a comma delimited list.
1086
+ if ( \is_string( $custom ) ) {
1087
  $custom = explode( ',', $custom );
1088
  }
1089
 
1142
  protected function get_wp_version_from_cl() {
1143
  $cl_supported_version = trim( PHPCSHelper::get_config_data( 'minimum_supported_wp_version' ) );
1144
  if ( ! empty( $cl_supported_version )
1145
+ && filter_var( $cl_supported_version, \FILTER_VALIDATE_FLOAT ) !== false
1146
  ) {
1147
  $this->minimum_supported_version = $cl_supported_version;
1148
  }
1182
  $regex = '#\b' . preg_quote( $comment, '#' ) . '\b#i';
1183
 
1184
  // There is a findEndOfStatement() method, but it considers more tokens than
1185
+ // we need to consider here.
1186
+ $end_of_statement = $this->phpcsFile->findNext( array( \T_CLOSE_TAG, \T_SEMICOLON ), $stackPtr );
1187
 
1188
  if ( false !== $end_of_statement ) {
1189
  // If the statement was ended by a semicolon, check if there is a whitelist comment directly after it.
1190
+ if ( \T_SEMICOLON === $this->tokens[ $end_of_statement ]['code'] ) {
1191
+ $lastPtr = $this->phpcsFile->findNext( \T_WHITESPACE, ( $end_of_statement + 1 ), null, true );
1192
+ } elseif ( \T_CLOSE_TAG === $this->tokens[ $end_of_statement ]['code'] ) {
1193
  // If the semicolon was left out and it was terminated by an ending tag, we need to look backwards.
1194
+ $lastPtr = $this->phpcsFile->findPrevious( \T_WHITESPACE, ( $end_of_statement - 1 ), null, true );
1195
  }
1196
 
1197
+ if ( ( ( \T_COMMENT === $this->tokens[ $lastPtr ]['code']
1198
+ && strpos( $this->tokens[ $lastPtr ]['content'], '@codingStandardsChangeSetting' ) === false )
1199
+ || ( isset( $this->phpcsCommentTokens[ $this->tokens[ $lastPtr ]['type'] ] )
1200
+ && 'T_PHPCS_SET' !== $this->tokens[ $lastPtr ]['type'] ) )
1201
  && $this->tokens[ $lastPtr ]['line'] === $this->tokens[ $end_of_statement ]['line']
1202
  && preg_match( $regex, $this->tokens[ $lastPtr ]['content'] ) === 1
1203
  ) {
1208
  // No whitelist comment found so far. Check at the end of the stackPtr line.
1209
  // Note: a T_COMMENT includes the new line character, so may be the last token on the line!
1210
  $end_of_line = $this->get_last_ptr_on_line( $stackPtr );
1211
+ $lastPtr = $this->phpcsFile->findPrevious( \T_WHITESPACE, $end_of_line, null, true );
1212
 
1213
+ if ( ( ( \T_COMMENT === $this->tokens[ $lastPtr ]['code']
1214
+ && strpos( $this->tokens[ $lastPtr ]['content'], '@codingStandardsChangeSetting' ) === false )
1215
+ || ( isset( $this->phpcsCommentTokens[ $this->tokens[ $lastPtr ]['type'] ] )
1216
+ && 'T_PHPCS_SET' !== $this->tokens[ $lastPtr ]['type'] ) )
1217
  && $this->tokens[ $lastPtr ]['line'] === $this->tokens[ $stackPtr ]['line']
1218
  && preg_match( $regex, $this->tokens[ $lastPtr ]['content'] ) === 1
1219
  ) {
1227
  * Check if a token is used within a unit test.
1228
  *
1229
  * Unit test methods are identified as such:
1230
+ * - Method is within a known unit test class;
1231
+ * - or Method is within a class/trait which extends a known unit test class.
1232
  *
1233
  * @since 0.11.0
1234
+ * @since 1.1.0 Supports anonymous test classes and improved handling of nested scopes.
1235
  *
1236
  * @param int $stackPtr The position of the token to be examined.
1237
  *
1239
  */
1240
  protected function is_token_in_test_method( $stackPtr ) {
1241
  // Is the token inside of a function definition ?
1242
+ $functionToken = $this->phpcsFile->getCondition( $stackPtr, \T_FUNCTION );
1243
  if ( false === $functionToken ) {
1244
+ // No conditions or no function condition.
1245
  return false;
1246
  }
1247
 
1248
+ /*
1249
+ * Is this a method inside of a class or a trait ? If so, it is a test class/trait ?
1250
+ *
1251
+ * {@internal Once the minimum supported PHPCS version has gone up to 3.1.0, the
1252
+ * local array here can be replace with Tokens::$ooScopeTokens.}}
1253
+ */
1254
+ $oo_tokens = array(
1255
+ \T_CLASS => true,
1256
+ \T_TRAIT => true,
1257
+ \T_ANON_CLASS => true,
1258
+ );
1259
+ $conditions = $this->tokens[ $stackPtr ]['conditions'];
1260
+
1261
+ foreach ( $conditions as $token => $condition ) {
1262
+ if ( $token === $functionToken ) {
1263
+ // Only examine the conditions the function is nested in, not those nested within the function.
1264
+ break;
1265
+ }
1266
 
1267
+ if ( isset( $oo_tokens[ $condition ] ) ) {
1268
+ $is_test_class = $this->is_test_class( $token );
1269
+ if ( true === $is_test_class ) {
1270
+ return true;
1271
+ }
1272
+ }
1273
  }
1274
 
1275
+ return false;
1276
  }
1277
 
1278
  /**
1283
  * or a custom whitelisted unit test class.
1284
  *
1285
  * @since 0.12.0 Split off from the `is_token_in_test_method()` method.
1286
+ * @since 1.0.0 Improved recognition of namespaced class names.
1287
  *
1288
  * @param int $stackPtr The position of the token to be examined.
1289
  * This should be a class, anonymous class or trait token.
1293
  protected function is_test_class( $stackPtr ) {
1294
 
1295
  if ( ! isset( $this->tokens[ $stackPtr ] )
1296
+ || \in_array( $this->tokens[ $stackPtr ]['type'], array( 'T_CLASS', 'T_ANON_CLASS', 'T_TRAIT' ), true ) === false
1297
  ) {
1298
  return false;
1299
  }
1304
  $this->test_class_whitelist
1305
  );
1306
 
1307
+ /*
1308
+ * Show some tolerance for user input.
1309
+ * The custom test class names should be passed as FQN without a prefixing `\`.
1310
+ */
1311
+ foreach ( $whitelist as $k => $v ) {
1312
+ $whitelist[ $k ] = ltrim( $v, '\\' );
1313
+ }
1314
+
1315
  // Is the class/trait one of the whitelisted test classes ?
1316
+ $namespace = $this->determine_namespace( $stackPtr );
1317
  $className = $this->phpcsFile->getDeclarationName( $stackPtr );
1318
+ if ( '' !== $namespace ) {
1319
+ if ( isset( $whitelist[ $namespace . '\\' . $className ] ) ) {
1320
+ return true;
1321
+ }
1322
+ } elseif ( isset( $whitelist[ $className ] ) ) {
1323
  return true;
1324
  }
1325
 
1326
  // Does the class/trait extend one of the whitelisted test classes ?
1327
  $extendedClassName = $this->phpcsFile->findExtendedClassName( $stackPtr );
1328
+ if ( '\\' === $extendedClassName[0] ) {
1329
+ if ( isset( $whitelist[ substr( $extendedClassName, 1 ) ] ) ) {
1330
+ return true;
1331
+ }
1332
+ } elseif ( '' !== $namespace ) {
1333
+ if ( isset( $whitelist[ $namespace . '\\' . $extendedClassName ] ) ) {
1334
+ return true;
1335
+ }
1336
+ } elseif ( isset( $whitelist[ $extendedClassName ] ) ) {
1337
  return true;
1338
  }
1339
 
1340
+ /*
1341
+ * Not examining imported classes via `use` statements as with the variety of syntaxes,
1342
+ * this would get very complicated.
1343
+ * After all, users can add an `<exclude-pattern>` for a particular sniff to their
1344
+ * custom ruleset to selectively exclude the test directory.
1345
+ */
1346
+
1347
  return false;
1348
  }
1349
 
1366
  protected function is_assignment( $stackPtr ) {
1367
 
1368
  static $valid = array(
1369
+ \T_VARIABLE => true,
1370
+ \T_CLOSE_SQUARE_BRACKET => true,
1371
  );
1372
 
1373
  // Must be a variable, constant or closing square bracket (see below).
1395
  }
1396
 
1397
  // Check if this is an array assignment, e.g., `$var['key'] = 'val';` .
1398
+ if ( \T_OPEN_SQUARE_BRACKET === $this->tokens[ $next_non_empty ]['code'] ) {
1399
  return $this->is_assignment( $this->tokens[ $next_non_empty ]['bracket_closer'] );
1400
  }
1401
 
1432
  $tokens = $this->phpcsFile->getTokens();
1433
 
1434
  // If we're in a function, only look inside of it.
1435
+ $f = $this->phpcsFile->getCondition( $stackPtr, \T_FUNCTION );
1436
  if ( false !== $f ) {
1437
  $start = $tokens[ $f ]['scope_opener'];
1438
  } else {
1439
+ $f = $this->phpcsFile->getCondition( $stackPtr, \T_CLOSURE );
1440
  if ( false !== $f ) {
1441
  $start = $tokens[ $f ]['scope_opener'];
1442
  }
1485
  for ( $i = $start; $i < $end; $i++ ) {
1486
 
1487
  // If this isn't a function name, skip it.
1488
+ if ( \T_STRING !== $tokens[ $i ]['code'] ) {
1489
  continue;
1490
  }
1491
 
1517
  return false;
1518
  }
1519
 
1520
+ $nested_parenthesis = $this->tokens[ $stackPtr ]['nested_parenthesis'];
 
 
1521
 
1522
+ end( $nested_parenthesis );
1523
+ $open_parenthesis = key( $nested_parenthesis );
1524
+
1525
+ $previous_non_empty = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $open_parenthesis - 1 ), null, true, null, true );
1526
+ return in_array( $this->tokens[ $previous_non_empty ]['code'], array( \T_ISSET, \T_EMPTY ), true );
1527
  }
1528
 
1529
  /**
1556
 
1557
  // The only parentheses should belong to the sanitizing function. If there's
1558
  // more than one set, this isn't *only* sanitization.
1559
+ return ( \count( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) === 1 );
1560
  }
1561
 
1562
  /**
1578
  true
1579
  );
1580
 
1581
+ if ( false === $prev ) {
1582
+ return false;
1583
+ }
1584
+
1585
  // Check if it is a safe cast.
1586
+ return isset( $this->safe_casts[ $this->tokens[ $prev ]['code'] ] );
1587
  }
1588
 
1589
  /**
1613
  }
1614
 
1615
  // Get the function that it's in.
1616
+ $nested_parenthesis = $this->tokens[ $stackPtr ]['nested_parenthesis'];
1617
+ $function_closer = end( $nested_parenthesis );
1618
+ $function_opener = key( $nested_parenthesis );
1619
+ $function = $this->tokens[ ( $function_opener - 1 ) ];
1620
 
1621
  // If it is just being unset, the value isn't used at all, so it's safe.
1622
+ if ( \T_UNSET === $function['code'] ) {
1623
  return true;
1624
  }
1625
 
1626
  // If this isn't a call to a function, it sure isn't sanitizing function.
1627
+ if ( \T_STRING !== $function['code'] ) {
1628
  if ( $require_unslash ) {
1629
  $this->add_unslash_error( $stackPtr );
1630
  }
1637
  if ( 'wp_unslash' === $functionName ) {
1638
 
1639
  $is_unslashed = true;
1640
+ $function_closer = prev( $nested_parenthesis );
1641
 
1642
  // If there is no other function being used, this value is unsanitized.
1643
  if ( ! $function_closer ) {
1644
  return false;
1645
  }
1646
 
1647
+ $function_opener = key( $nested_parenthesis );
1648
  $functionName = $this->tokens[ ( $function_opener - 1 ) ]['content'];
1649
 
1650
  } else {
1670
  true
1671
  );
1672
 
1673
+ if ( false !== $first_non_empty && \T_CONSTANT_ENCAPSED_STRING === $this->tokens[ $first_non_empty ]['code'] ) {
1674
  $functionName = $this->strip_quotes( $this->tokens[ $first_non_empty ]['content'] );
1675
  }
1676
  }
1728
  );
1729
 
1730
  // If it isn't a bracket, this isn't an array-access.
1731
+ if ( false === $open_bracket || \T_OPEN_SQUARE_BRACKET !== $this->tokens[ $open_bracket ]['code'] ) {
1732
  return false;
1733
  }
1734
 
1809
  $scope_start = 0;
1810
 
1811
  // Check if we are in a function.
1812
+ $function = $this->phpcsFile->getCondition( $stackPtr, \T_FUNCTION );
1813
 
1814
  // If so, we check only within the function, otherwise the whole file.
1815
  if ( false !== $function ) {
1816
  $scope_start = $this->tokens[ $function ]['scope_opener'];
1817
  } else {
1818
  // Check if we are in a closure.
1819
+ $closure = $this->phpcsFile->getCondition( $stackPtr, \T_CLOSURE );
1820
 
1821
  // If so, we check only within the closure.
1822
  if ( false !== $closure ) {
1828
 
1829
  }
1830
 
1831
+ $bare_array_key = $this->strip_quotes( $array_key );
1832
+
1833
  for ( $i = ( $scope_start + 1 ); $i < $scope_end; $i++ ) {
1834
 
1835
+ if ( ! \in_array( $this->tokens[ $i ]['code'], array( \T_ISSET, \T_EMPTY, \T_UNSET ), true ) ) {
1836
  continue;
1837
  }
1838
 
1839
+ $issetOpener = $this->phpcsFile->findNext( \T_OPEN_PARENTHESIS, $i );
1840
  $issetCloser = $this->tokens[ $issetOpener ]['parenthesis_closer'];
1841
 
1842
  // Look for this variable. We purposely stomp $i from the parent loop.
1843
  for ( $i = ( $issetOpener + 1 ); $i < $issetCloser; $i++ ) {
1844
 
1845
+ if ( \T_VARIABLE !== $this->tokens[ $i ]['code'] ) {
1846
  continue;
1847
  }
1848
 
1849
  // If we're checking for a specific array key (ex: 'hello' in
1850
+ // $_POST['hello']), that must match too. Quote-style, however, doesn't matter.
1851
+ if ( isset( $array_key )
1852
+ && $this->strip_quotes( $this->get_array_access_key( $i ) ) !== $bare_array_key ) {
1853
  continue;
1854
  }
1855
 
1877
 
1878
  // We first check if this is a switch statement (switch ( $var )).
1879
  if ( isset( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) ) {
1880
+ $nested_parenthesis = $this->tokens[ $stackPtr ]['nested_parenthesis'];
1881
+ $close_parenthesis = end( $nested_parenthesis );
1882
 
1883
  if (
1884
  isset( $this->tokens[ $close_parenthesis ]['parenthesis_owner'] )
1885
+ && \T_SWITCH === $this->tokens[ $this->tokens[ $close_parenthesis ]['parenthesis_owner'] ]['code']
1886
  ) {
1887
  return true;
1888
  }
1910
  );
1911
 
1912
  // This might be an opening square bracket in the case of arrays ($var['a']).
1913
+ while ( \T_OPEN_SQUARE_BRACKET === $this->tokens[ $next_token ]['code'] ) {
1914
 
1915
  $next_token = $this->phpcsFile->findNext(
1916
  Tokens::$emptyTokens,
1948
  protected function get_use_type( $stackPtr ) {
1949
 
1950
  // USE keywords inside closures.
1951
+ $next = $this->phpcsFile->findNext( \T_WHITESPACE, ( $stackPtr + 1 ), null, true );
1952
 
1953
+ if ( \T_OPEN_PARENTHESIS === $this->tokens[ $next ]['code'] ) {
1954
  return 'closure';
1955
  }
1956
 
1960
  'T_ANON_CLASS' => true,
1961
  'T_TRAIT' => true,
1962
  );
1963
+ if ( false !== $this->valid_direct_scope( $stackPtr, $valid_scopes ) ) {
1964
  return 'trait';
1965
  }
1966
 
1975
  *
1976
  * @since 0.9.0
1977
  *
1978
+ * @param string $string The contents of a T_DOUBLE_QUOTED_STRING or T_HEREDOC token.
1979
  *
1980
  * @return array Variable names (without '$' sigil).
1981
  */
1982
  protected function get_interpolated_variables( $string ) {
1983
  $variables = array();
1984
+ if ( preg_match_all( '/(?P<backslashes>\\\\*)\$(?P<symbol>\w+)/', $string, $match_sets, \PREG_SET_ORDER ) ) {
1985
  foreach ( $match_sets as $matches ) {
1986
+ if ( ! isset( $matches['backslashes'] ) || ( \strlen( $matches['backslashes'] ) % 2 ) === 0 ) {
1987
  $variables[] = $matches['symbol'];
1988
  }
1989
  }
1994
  /**
1995
  * Strip variables from an arbitrary double quoted/heredoc string.
1996
  *
1997
+ * Intended for use with the contents of a T_DOUBLE_QUOTED_STRING or T_HEREDOC token.
1998
  *
1999
  * @since 0.14.0
2000
  *
2019
  * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer, it
2020
  * will detect whether the array has values or is empty.
2021
  *
2022
+ * @link https://github.com/PHPCompatibility/PHPCompatibility/issues/120
2023
+ * @link https://github.com/PHPCompatibility/PHPCompatibility/issues/152
2024
  *
2025
  * @since 0.11.0
2026
  *
2036
  }
2037
 
2038
  // Is this one of the tokens this function handles ?
2039
+ if ( false === \in_array( $this->tokens[ $stackPtr ]['code'], array( \T_STRING, \T_ARRAY, \T_OPEN_SHORT_ARRAY ), true ) ) {
2040
  return false;
2041
  }
2042
 
2058
 
2059
  // Deal with function calls & long arrays.
2060
  // Next non-empty token should be the open parenthesis.
2061
+ if ( false === $next_non_empty && \T_OPEN_PARENTHESIS !== $this->tokens[ $next_non_empty ]['code'] ) {
2062
  return false;
2063
  }
2064
 
2086
  * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer,
2087
  * it will return the number of values in the array.
2088
  *
2089
+ * @link https://github.com/PHPCompatibility/PHPCompatibility/issues/111
2090
+ * @link https://github.com/PHPCompatibility/PHPCompatibility/issues/114
2091
+ * @link https://github.com/PHPCompatibility/PHPCompatibility/issues/151
2092
  *
2093
  * @since 0.11.0
2094
  *
2101
  return 0;
2102
  }
2103
 
2104
+ return \count( $this->get_function_call_parameters( $stackPtr ) );
2105
  }
2106
 
2107
  /**
2118
  * @param int $stackPtr The position of the function call token.
2119
  *
2120
  * @return array Multi-dimentional array with parameter details or
2121
+ * empty array if no parameters are found.
2122
  *
2123
  * @type int $position 1-based index position of the parameter. {
2124
  * @type int $start Stack pointer for the start of the parameter.
2151
 
2152
  // Which nesting level is the one we are interested in ?
2153
  if ( isset( $this->tokens[ $opener ]['nested_parenthesis'] ) ) {
2154
+ $nestedParenthesisCount += \count( $this->tokens[ $opener ]['nested_parenthesis'] );
2155
  }
2156
 
2157
  $parameters = array();
2158
  $next_comma = $opener;
2159
  $param_start = ( $opener + 1 );
2160
  $cnt = 1;
2161
+ while ( $next_comma = $this->phpcsFile->findNext( array( \T_COMMA, $this->tokens[ $closer ]['code'], \T_OPEN_SHORT_ARRAY, \T_CLOSURE ), ( $next_comma + 1 ), ( $closer + 1 ) ) ) {
2162
  // Ignore anything within short array definition brackets.
2163
  if ( 'T_OPEN_SHORT_ARRAY' === $this->tokens[ $next_comma ]['type']
2164
  && ( isset( $this->tokens[ $next_comma ]['bracket_opener'] )
2170
  continue;
2171
  }
2172
 
2173
+ // Skip past closures passed as function parameters.
2174
+ if ( 'T_CLOSURE' === $this->tokens[ $next_comma ]['type']
2175
+ && ( isset( $this->tokens[ $next_comma ]['scope_condition'] )
2176
+ && $this->tokens[ $next_comma ]['scope_condition'] === $next_comma )
2177
+ && isset( $this->tokens[ $next_comma ]['scope_closer'] )
2178
+ ) {
2179
+ // Skip forward to the end of the closure declaration.
2180
+ $next_comma = $this->tokens[ $next_comma ]['scope_closer'];
2181
+ continue;
2182
+ }
2183
+
2184
  // Ignore comma's at a lower nesting level.
2185
+ if ( \T_COMMA === $this->tokens[ $next_comma ]['code']
2186
  && isset( $this->tokens[ $next_comma ]['nested_parenthesis'] )
2187
+ && \count( $this->tokens[ $next_comma ]['nested_parenthesis'] ) !== $nestedParenthesisCount
2188
  ) {
2189
  continue;
2190
  }
2258
  /*
2259
  * Determine the array opener & closer.
2260
  */
2261
+ if ( \T_ARRAY === $this->tokens[ $stackPtr ]['code'] ) {
2262
  if ( isset( $this->tokens[ $stackPtr ]['parenthesis_opener'] ) ) {
2263
  $opener = $this->tokens[ $stackPtr ]['parenthesis_opener'];
2264
 
2304
 
2305
  // Check for scoped namespace {}.
2306
  if ( ! empty( $this->tokens[ $stackPtr ]['conditions'] ) ) {
2307
+ $namespacePtr = $this->phpcsFile->getCondition( $stackPtr, \T_NAMESPACE );
2308
  if ( false !== $namespacePtr ) {
2309
  $namespace = $this->get_declared_namespace_name( $namespacePtr );
2310
  if ( false !== $namespace ) {
2327
  $previousNSToken = $stackPtr;
2328
  $namespace = false;
2329
  do {
2330
+ $previousNSToken = $this->phpcsFile->findPrevious( \T_NAMESPACE, ( $previousNSToken - 1 ) );
2331
 
2332
  // Stop if we encounter a scoped namespace declaration as we already know we're not in one.
2333
  if ( ! empty( $this->tokens[ $previousNSToken ]['scope_condition'] )
2369
  return false;
2370
  }
2371
 
2372
+ if ( \T_NAMESPACE !== $this->tokens[ $stackPtr ]['code'] ) {
2373
  return false;
2374
  }
2375
 
2376
+ $nextToken = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true, null, true );
2377
+ if ( \T_NS_SEPARATOR === $this->tokens[ $nextToken ]['code'] ) {
2378
  // Not a namespace declaration, but use of, i.e. `namespace\someFunction();`.
2379
  return false;
2380
  }
2381
 
2382
+ if ( \T_OPEN_CURLY_BRACKET === $this->tokens[ $nextToken ]['code'] ) {
 
2383
  // Declaration for global namespace when using multiple namespaces in a file.
2384
  // I.e.: `namespace {}`.
2385
  return '';
2386
  }
2387
 
2388
  // Ok, this should be a namespace declaration, so get all the parts together.
2389
+ $acceptedTokens = array(
2390
+ \T_STRING => true,
2391
+ \T_NS_SEPARATOR => true,
 
2392
  );
2393
+ $validTokens = $acceptedTokens + Tokens::$emptyTokens;
2394
 
2395
  $namespaceName = '';
2396
  while ( isset( $validTokens[ $this->tokens[ $nextToken ]['code'] ] ) ) {
2397
+ if ( isset( $acceptedTokens[ $this->tokens[ $nextToken ]['code'] ] ) ) {
2398
+ $namespaceName .= trim( $this->tokens[ $nextToken ]['content'] );
2399
+ }
2400
+ ++$nextToken;
2401
  }
2402
 
2403
  return $namespaceName;
2411
  * originally created.
2412
  * @since 0.13.0 The $stackPtr parameter is now optional. Either that or the
2413
  * $content parameter has to be passed.
2414
+ * @deprecated 1.0.0 This method is only used by deprecated sniffs.
2415
  *
2416
  * @param string $tag_name The name of the HTML tag without brackets. So if
2417
  * searching for '<span...', this would be 'span'.
2448
  * @return bool
2449
  */
2450
  public function is_class_constant( $stackPtr ) {
2451
+ if ( ! isset( $this->tokens[ $stackPtr ] ) || \T_CONST !== $this->tokens[ $stackPtr ]['code'] ) {
2452
  return false;
2453
  }
2454
 
2459
  'T_INTERFACE' => true,
2460
  );
2461
 
2462
+ return is_int( $this->valid_direct_scope( $stackPtr, $valid_scopes ) );
2463
  }
2464
 
2465
  /**
2472
  * @return bool
2473
  */
2474
  public function is_class_property( $stackPtr ) {
2475
+ if ( ! isset( $this->tokens[ $stackPtr ] ) || \T_VARIABLE !== $this->tokens[ $stackPtr ]['code'] ) {
2476
  return false;
2477
  }
2478
 
2483
  'T_TRAIT' => true,
2484
  );
2485
 
2486
+ $scopePtr = $this->valid_direct_scope( $stackPtr, $valid_scopes );
2487
+ if ( false !== $scopePtr ) {
2488
  // Make sure it's not a method parameter.
2489
  if ( empty( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) ) {
2490
  return true;
2491
+ } else {
2492
+ $parenthesis = array_keys( $this->tokens[ $stackPtr ]['nested_parenthesis'] );
2493
+ $deepest_open = array_pop( $parenthesis );
2494
+ if ( $deepest_open < $scopePtr
2495
+ || isset( $this->tokens[ $deepest_open ]['parenthesis_owner'] ) === false
2496
+ || T_FUNCTION !== $this->tokens[ $this->tokens[ $deepest_open ]['parenthesis_owner'] ]['code']
2497
+ ) {
2498
+ return true;
2499
+ }
2500
  }
2501
  }
2502
 
2517
  * to allow for newer token types.
2518
  * Value is irrelevant.
2519
  *
2520
+ * @return int|bool StackPtr to the scope if valid, false otherwise.
2521
  */
2522
  protected function valid_direct_scope( $stackPtr, array $valid_scopes ) {
2523
  if ( empty( $this->tokens[ $stackPtr ]['conditions'] ) ) {
2534
  return false;
2535
  }
2536
 
2537
+ if ( isset( $valid_scopes[ $this->tokens[ $ptr ]['type'] ] ) ) {
2538
+ return $ptr;
2539
+ }
2540
+
2541
+ return false;
2542
  }
2543
 
2544
  /**
2564
  protected function is_wpdb_method_call( $stackPtr, $target_methods ) {
2565
 
2566
  // Check for wpdb.
2567
+ if ( ( \T_VARIABLE === $this->tokens[ $stackPtr ]['code'] && '$wpdb' !== $this->tokens[ $stackPtr ]['content'] )
2568
+ || ( \T_STRING === $this->tokens[ $stackPtr ]['code'] && 'wpdb' !== $this->tokens[ $stackPtr ]['content'] )
2569
  ) {
2570
  return false;
2571
  }
2572
 
2573
  // Check that this is a method call.
2574
  $is_object_call = $this->phpcsFile->findNext(
2575
+ array( \T_OBJECT_OPERATOR, \T_DOUBLE_COLON ),
2576
  ( $stackPtr + 1 ),
2577
  null,
2578
  false,
2583
  return false;
2584
  }
2585
 
2586
+ $methodPtr = $this->phpcsFile->findNext( \T_WHITESPACE, ( $is_object_call + 1 ), null, true, null, true );
2587
  if ( false === $methodPtr ) {
2588
  return false;
2589
  }
2590
 
2591
+ if ( \T_STRING === $this->tokens[ $methodPtr ]['code'] && property_exists( $this, 'methodPtr' ) ) {
2592
  $this->methodPtr = $methodPtr;
2593
  }
2594
 
2595
  // Find the opening parenthesis.
2596
+ $opening_paren = $this->phpcsFile->findNext( \T_WHITESPACE, ( $methodPtr + 1 ), null, true, null, true );
2597
 
2598
  if ( false === $opening_paren ) {
2599
  return false;
2603
  $this->i = $opening_paren;
2604
  }
2605
 
2606
+ if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $opening_paren ]['code']
2607
  || ! isset( $this->tokens[ $opening_paren ]['parenthesis_closer'] )
2608
  ) {
2609
  return false;
2617
  // Find the end of the first parameter.
2618
  $end = $this->phpcsFile->findEndOfStatement( $opening_paren + 1 );
2619
 
2620
+ if ( \T_COMMA !== $this->tokens[ $end ]['code'] ) {
2621
  ++$end;
2622
  }
2623
 
2626
  }
2627
 
2628
  return true;
2629
+ }
2630
+
2631
+ /**
2632
+ * Determine whether an arbitrary T_STRING token is the use of a global constant.
2633
+ *
2634
+ * @since 1.0.0
2635
+ *
2636
+ * @param int $stackPtr The position of the function call token.
2637
+ *
2638
+ * @return bool
2639
+ */
2640
+ public function is_use_of_global_constant( $stackPtr ) {
2641
+ // Check for the existence of the token.
2642
+ if ( ! isset( $this->tokens[ $stackPtr ] ) ) {
2643
+ return false;
2644
+ }
2645
+
2646
+ // Is this one of the tokens this function handles ?
2647
+ if ( \T_STRING !== $this->tokens[ $stackPtr ]['code'] ) {
2648
+ return false;
2649
+ }
2650
+
2651
+ $next = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $stackPtr + 1 ), null, true );
2652
+ if ( false !== $next
2653
+ && ( \T_OPEN_PARENTHESIS === $this->tokens[ $next ]['code']
2654
+ || \T_DOUBLE_COLON === $this->tokens[ $next ]['code'] )
2655
+ ) {
2656
+ // Function call or declaration.
2657
+ return false;
2658
+ }
2659
+
2660
+ // Array of tokens which if found preceding the $stackPtr indicate that a T_STRING is not a global constant.
2661
+ $tokens_to_ignore = array(
2662
+ 'T_NAMESPACE' => true,
2663
+ 'T_USE' => true,
2664
+ 'T_CLASS' => true,
2665
+ 'T_TRAIT' => true,
2666
+ 'T_INTERFACE' => true,
2667
+ 'T_EXTENDS' => true,
2668
+ 'T_IMPLEMENTS' => true,
2669
+ 'T_NEW' => true,
2670
+ 'T_FUNCTION' => true,
2671
+ 'T_DOUBLE_COLON' => true,
2672
+ 'T_OBJECT_OPERATOR' => true,
2673
+ 'T_INSTANCEOF' => true,
2674
+ 'T_INSTEADOF' => true,
2675
+ 'T_GOTO' => true,
2676
+ 'T_AS' => true,
2677
+ 'T_PUBLIC' => true,
2678
+ 'T_PROTECTED' => true,
2679
+ 'T_PRIVATE' => true,
2680
+ );
2681
+
2682
+ $prev = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
2683
+ if ( false !== $prev
2684
+ && isset( $tokens_to_ignore[ $this->tokens[ $prev ]['type'] ] )
2685
+ ) {
2686
+ // Not the use of a constant.
2687
+ return false;
2688
+ }
2689
+
2690
+ if ( false !== $prev
2691
+ && \T_NS_SEPARATOR === $this->tokens[ $prev ]['code']
2692
+ && \T_STRING === $this->tokens[ ( $prev - 1 ) ]['code']
2693
+ ) {
2694
+ // Namespaced constant of the same name.
2695
+ return false;
2696
+ }
2697
+
2698
+ if ( false !== $prev
2699
+ && \T_CONST === $this->tokens[ $prev ]['code']
2700
+ && $this->is_class_constant( $prev )
2701
+ ) {
2702
+ // Class constant declaration of the same name.
2703
+ return false;
2704
+ }
2705
+
2706
+ /*
2707
+ * Deal with a number of variations of use statements.
2708
+ */
2709
+ for ( $i = $stackPtr; $i > 0; $i-- ) {
2710
+ if ( $this->tokens[ $i ]['line'] !== $this->tokens[ $stackPtr ]['line'] ) {
2711
+ break;
2712
+ }
2713
+ }
2714
+
2715
+ $firstOnLine = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
2716
+ if ( false !== $firstOnLine && \T_USE === $this->tokens[ $firstOnLine ]['code'] ) {
2717
+ $nextOnLine = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $firstOnLine + 1 ), null, true );
2718
+ if ( false !== $nextOnLine ) {
2719
+ if ( \T_STRING === $this->tokens[ $nextOnLine ]['code']
2720
+ && 'const' === $this->tokens[ $nextOnLine ]['content']
2721
+ ) {
2722
+ $hasNsSep = $this->phpcsFile->findNext( \T_NS_SEPARATOR, ( $nextOnLine + 1 ), $stackPtr );
2723
+ if ( false !== $hasNsSep ) {
2724
+ // Namespaced const (group) use statement.
2725
+ return false;
2726
+ }
2727
+ } else {
2728
+ // Not a const use statement.
2729
+ return false;
2730
+ }
2731
+ }
2732
+ }
2733
+
2734
+ return true;
2735
+ }
2736
+
2737
+ /**
2738
+ * Determine if a variable is in the `as $key => $value` part of a foreach condition.
2739
+ *
2740
+ * @since 1.0.0
2741
+ * @since 1.1.0 Moved from the PrefixAllGlobals sniff to the Sniff base class.
2742
+ *
2743
+ * @param int $stackPtr Pointer to the variable.
2744
+ *
2745
+ * @return bool True if it is. False otherwise.
2746
+ */
2747
+ protected function is_foreach_as( $stackPtr ) {
2748
+ if ( ! isset( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) ) {
2749
+ return false;
2750
+ }
2751
+
2752
+ $nested_parenthesis = $this->tokens[ $stackPtr ]['nested_parenthesis'];
2753
+ $close_parenthesis = end( $nested_parenthesis );
2754
+ $open_parenthesis = key( $nested_parenthesis );
2755
+ if ( ! isset( $this->tokens[ $close_parenthesis ]['parenthesis_owner'] ) ) {
2756
+ return false;
2757
+ }
2758
+
2759
+ if ( \T_FOREACH !== $this->tokens[ $this->tokens[ $close_parenthesis ]['parenthesis_owner'] ]['code'] ) {
2760
+ return false;
2761
+ }
2762
+
2763
+ $as_ptr = $this->phpcsFile->findNext( \T_AS, ( $open_parenthesis + 1 ), $close_parenthesis );
2764
+ if ( false === $as_ptr ) {
2765
+ // Should never happen.
2766
+ return false;
2767
+ }
2768
+
2769
+ return ( $stackPtr > $as_ptr );
2770
+ }
2771
 
2772
  }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayAssignmentRestrictionsSniff.php CHANGED
@@ -61,4 +61,4 @@ class ArrayAssignmentRestrictionsSniff extends AbstractArrayAssignmentRestrictio
61
  return true;
62
  }
63
 
64
- } // End class.
61
  return true;
62
  }
63
 
64
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayDeclarationSniff.php CHANGED
@@ -58,4 +58,4 @@ class ArrayDeclarationSniff {
58
  */
59
  public function process( File $phpcsFile, $stackPtr ) {}
60
 
61
- } // End class.
58
  */
59
  public function process( File $phpcsFile, $stackPtr ) {}
60
 
61
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayDeclarationSpacingSniff.php CHANGED
@@ -62,8 +62,8 @@ class ArrayDeclarationSpacingSniff extends Sniff {
62
  * @var array
63
  */
64
  private $targets = array(
65
- T_ARRAY => T_ARRAY,
66
- T_OPEN_SHORT_ARRAY => T_OPEN_SHORT_ARRAY,
67
  );
68
 
69
  /**
@@ -104,13 +104,13 @@ class ArrayDeclarationSpacingSniff extends Sniff {
104
  /*
105
  * Long arrays only: Check for space between the array keyword and the open parenthesis.
106
  */
107
- if ( T_ARRAY === $this->tokens[ $stackPtr ]['code'] ) {
108
 
109
  if ( ( $stackPtr + 1 ) !== $opener ) {
110
  $error = 'There must be no space between the "array" keyword and the opening parenthesis';
111
  $error_code = 'SpaceAfterKeyword';
112
 
113
- $nextNonWhitespace = $this->phpcsFile->findNext( T_WHITESPACE, ( $stackPtr + 1 ), ( $opener + 1 ), true );
114
  if ( $nextNonWhitespace !== $opener ) {
115
  // Don't auto-fix: Something other than whitespace found between keyword and open parenthesis.
116
  $this->phpcsFile->addError( $error, $stackPtr, $error_code );
@@ -134,7 +134,7 @@ class ArrayDeclarationSpacingSniff extends Sniff {
134
  /*
135
  * Check for empty arrays.
136
  */
137
- $nextNonWhitespace = $this->phpcsFile->findNext( T_WHITESPACE, ( $opener + 1 ), ( $closer + 1 ), true );
138
  if ( $nextNonWhitespace === $closer ) {
139
 
140
  if ( ( $opener + 1 ) !== $closer ) {
@@ -183,7 +183,7 @@ class ArrayDeclarationSpacingSniff extends Sniff {
183
  /*
184
  * Check that associative arrays are always multi-line.
185
  */
186
- $array_has_keys = $this->phpcsFile->findNext( T_DOUBLE_ARROW, $opener, $closer );
187
  if ( false !== $array_has_keys ) {
188
 
189
  $array_items = $this->get_function_call_parameters( $stackPtr );
@@ -191,7 +191,7 @@ class ArrayDeclarationSpacingSniff extends Sniff {
191
  if ( ( false === $this->allow_single_item_single_line_associative_arrays
192
  && ! empty( $array_items ) )
193
  || ( true === $this->allow_single_item_single_line_associative_arrays
194
- && count( $array_items ) > 1 )
195
  ) {
196
  /*
197
  * Make sure the double arrow is for *this* array, not for a nested one.
@@ -199,7 +199,7 @@ class ArrayDeclarationSpacingSniff extends Sniff {
199
  $array_has_keys = false; // Reset before doing more detailed check.
200
  foreach ( $array_items as $item ) {
201
  for ( $ptr = $item['start']; $ptr <= $item['end']; $ptr++ ) {
202
- if ( T_DOUBLE_ARROW === $this->tokens[ $ptr ]['code'] ) {
203
  $array_has_keys = true;
204
  break 2;
205
  }
@@ -251,7 +251,7 @@ class ArrayDeclarationSpacingSniff extends Sniff {
251
  }
252
 
253
  if ( $item['start'] <= ( $first_non_empty - 1 )
254
- && T_WHITESPACE === $this->tokens[ ( $first_non_empty - 1 ) ]['code']
255
  ) {
256
  // Remove whitespace which would otherwise becoming trailing
257
  // (as it gives problems with the fixed file).
@@ -273,7 +273,7 @@ class ArrayDeclarationSpacingSniff extends Sniff {
273
  /*
274
  * Check that there is a single space after the array opener and before the array closer.
275
  */
276
- if ( T_WHITESPACE !== $this->tokens[ ( $opener + 1 ) ]['code'] ) {
277
 
278
  $fix = $this->phpcsFile->addFixableError(
279
  'Missing space after array opener.',
@@ -290,7 +290,7 @@ class ArrayDeclarationSpacingSniff extends Sniff {
290
  'Expected 1 space after array opener, found %s.',
291
  $opener,
292
  'SpaceAfterArrayOpener',
293
- array( strlen( $this->tokens[ ( $opener + 1 ) ]['content'] ) )
294
  );
295
 
296
  if ( true === $fix ) {
@@ -298,7 +298,7 @@ class ArrayDeclarationSpacingSniff extends Sniff {
298
  }
299
  }
300
 
301
- if ( T_WHITESPACE !== $this->tokens[ ( $closer - 1 ) ]['code'] ) {
302
 
303
  $fix = $this->phpcsFile->addFixableError(
304
  'Missing space before array closer.',
@@ -315,7 +315,7 @@ class ArrayDeclarationSpacingSniff extends Sniff {
315
  'Expected 1 space before array closer, found %s.',
316
  $closer,
317
  'SpaceBeforeArrayCloser',
318
- array( strlen( $this->tokens[ ( $closer - 1 ) ]['content'] ) )
319
  );
320
 
321
  if ( true === $fix ) {
@@ -340,7 +340,7 @@ class ArrayDeclarationSpacingSniff extends Sniff {
340
  /*
341
  * Check that the closing bracket is on a new line.
342
  */
343
- $last_content = $this->phpcsFile->findPrevious( T_WHITESPACE, ( $closer - 1 ), $opener, true );
344
  if ( false !== $last_content
345
  && $this->tokens[ $last_content ]['line'] === $this->tokens[ $closer ]['line']
346
  ) {
@@ -353,7 +353,7 @@ class ArrayDeclarationSpacingSniff extends Sniff {
353
  $this->phpcsFile->fixer->beginChangeset();
354
 
355
  if ( $last_content < ( $closer - 1 )
356
- && T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code']
357
  ) {
358
  // Remove whitespace which would otherwise becoming trailing
359
  // (as it gives problems with the fixed file).
@@ -376,16 +376,18 @@ class ArrayDeclarationSpacingSniff extends Sniff {
376
 
377
  // Find the line on which the item starts.
378
  $first_content = $this->phpcsFile->findNext(
379
- array( T_WHITESPACE, T_DOC_COMMENT_WHITESPACE ),
380
  $item['start'],
381
  $end_of_this_item,
382
  true
383
  );
384
 
385
  // Ignore comments after array items if the next real content starts on a new line.
386
- if ( T_COMMENT === $this->tokens[ $first_content ]['code'] ) {
 
 
387
  $next = $this->phpcsFile->findNext(
388
- array( T_WHITESPACE, T_DOC_COMMENT_WHITESPACE ),
389
  ( $first_content + 1 ),
390
  $end_of_this_item,
391
  true
@@ -421,7 +423,7 @@ class ArrayDeclarationSpacingSniff extends Sniff {
421
  $this->phpcsFile->fixer->beginChangeset();
422
 
423
  if ( $item['start'] <= ( $first_content - 1 )
424
- && T_WHITESPACE === $this->tokens[ ( $first_content - 1 ) ]['code']
425
  ) {
426
  // Remove whitespace which would otherwise becoming trailing
427
  // (as it gives problems with the fixed file).
@@ -437,4 +439,4 @@ class ArrayDeclarationSpacingSniff extends Sniff {
437
  }
438
  }
439
 
440
- } // End class.
62
  * @var array
63
  */
64
  private $targets = array(
65
+ \T_ARRAY => \T_ARRAY,
66
+ \T_OPEN_SHORT_ARRAY => \T_OPEN_SHORT_ARRAY,
67
  );
68
 
69
  /**
104
  /*
105
  * Long arrays only: Check for space between the array keyword and the open parenthesis.
106
  */
107
+ if ( \T_ARRAY === $this->tokens[ $stackPtr ]['code'] ) {
108
 
109
  if ( ( $stackPtr + 1 ) !== $opener ) {
110
  $error = 'There must be no space between the "array" keyword and the opening parenthesis';
111
  $error_code = 'SpaceAfterKeyword';
112
 
113
+ $nextNonWhitespace = $this->phpcsFile->findNext( \T_WHITESPACE, ( $stackPtr + 1 ), ( $opener + 1 ), true );
114
  if ( $nextNonWhitespace !== $opener ) {
115
  // Don't auto-fix: Something other than whitespace found between keyword and open parenthesis.
116
  $this->phpcsFile->addError( $error, $stackPtr, $error_code );
134
  /*
135
  * Check for empty arrays.
136
  */
137
+ $nextNonWhitespace = $this->phpcsFile->findNext( \T_WHITESPACE, ( $opener + 1 ), ( $closer + 1 ), true );
138
  if ( $nextNonWhitespace === $closer ) {
139
 
140
  if ( ( $opener + 1 ) !== $closer ) {
183
  /*
184
  * Check that associative arrays are always multi-line.
185
  */
186
+ $array_has_keys = $this->phpcsFile->findNext( \T_DOUBLE_ARROW, $opener, $closer );
187
  if ( false !== $array_has_keys ) {
188
 
189
  $array_items = $this->get_function_call_parameters( $stackPtr );
191
  if ( ( false === $this->allow_single_item_single_line_associative_arrays
192
  && ! empty( $array_items ) )
193
  || ( true === $this->allow_single_item_single_line_associative_arrays
194
+ && \count( $array_items ) > 1 )
195
  ) {
196
  /*
197
  * Make sure the double arrow is for *this* array, not for a nested one.
199
  $array_has_keys = false; // Reset before doing more detailed check.
200
  foreach ( $array_items as $item ) {
201
  for ( $ptr = $item['start']; $ptr <= $item['end']; $ptr++ ) {
202
+ if ( \T_DOUBLE_ARROW === $this->tokens[ $ptr ]['code'] ) {
203
  $array_has_keys = true;
204
  break 2;
205
  }
251
  }
252
 
253
  if ( $item['start'] <= ( $first_non_empty - 1 )
254
+ && \T_WHITESPACE === $this->tokens[ ( $first_non_empty - 1 ) ]['code']
255
  ) {
256
  // Remove whitespace which would otherwise becoming trailing
257
  // (as it gives problems with the fixed file).
273
  /*
274
  * Check that there is a single space after the array opener and before the array closer.
275
  */
276
+ if ( \T_WHITESPACE !== $this->tokens[ ( $opener + 1 ) ]['code'] ) {
277
 
278
  $fix = $this->phpcsFile->addFixableError(
279
  'Missing space after array opener.',
290
  'Expected 1 space after array opener, found %s.',
291
  $opener,
292
  'SpaceAfterArrayOpener',
293
+ array( \strlen( $this->tokens[ ( $opener + 1 ) ]['content'] ) )
294
  );
295
 
296
  if ( true === $fix ) {
298
  }
299
  }
300
 
301
+ if ( \T_WHITESPACE !== $this->tokens[ ( $closer - 1 ) ]['code'] ) {
302
 
303
  $fix = $this->phpcsFile->addFixableError(
304
  'Missing space before array closer.',
315
  'Expected 1 space before array closer, found %s.',
316
  $closer,
317
  'SpaceBeforeArrayCloser',
318
+ array( \strlen( $this->tokens[ ( $closer - 1 ) ]['content'] ) )
319
  );
320
 
321
  if ( true === $fix ) {
340
  /*
341
  * Check that the closing bracket is on a new line.
342
  */
343
+ $last_content = $this->phpcsFile->findPrevious( \T_WHITESPACE, ( $closer - 1 ), $opener, true );
344
  if ( false !== $last_content
345
  && $this->tokens[ $last_content ]['line'] === $this->tokens[ $closer ]['line']
346
  ) {
353
  $this->phpcsFile->fixer->beginChangeset();
354
 
355
  if ( $last_content < ( $closer - 1 )
356
+ && \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code']
357
  ) {
358
  // Remove whitespace which would otherwise becoming trailing
359
  // (as it gives problems with the fixed file).
376
 
377
  // Find the line on which the item starts.
378
  $first_content = $this->phpcsFile->findNext(
379
+ array( \T_WHITESPACE, \T_DOC_COMMENT_WHITESPACE ),
380
  $item['start'],
381
  $end_of_this_item,
382
  true
383
  );
384
 
385
  // Ignore comments after array items if the next real content starts on a new line.
386
+ if ( \T_COMMENT === $this->tokens[ $first_content ]['code']
387
+ || isset( $this->phpcsCommentTokens[ $this->tokens[ $first_content ]['type'] ] )
388
+ ) {
389
  $next = $this->phpcsFile->findNext(
390
+ array( \T_WHITESPACE, \T_DOC_COMMENT_WHITESPACE ),
391
  ( $first_content + 1 ),
392
  $end_of_this_item,
393
  true
423
  $this->phpcsFile->fixer->beginChangeset();
424
 
425
  if ( $item['start'] <= ( $first_content - 1 )
426
+ && \T_WHITESPACE === $this->tokens[ ( $first_content - 1 ) ]['code']
427
  ) {
428
  // Remove whitespace which would otherwise becoming trailing
429
  // (as it gives problems with the fixed file).
439
  }
440
  }
441
 
442
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayIndentationSniff.php CHANGED
@@ -59,7 +59,6 @@ class ArrayIndentationSniff extends Sniff {
59
  */
60
  private $ignore_tokens = array();
61
 
62
-
63
  /**
64
  * Returns an array of tokens this test wants to listen for.
65
  *
@@ -72,12 +71,12 @@ class ArrayIndentationSniff extends Sniff {
72
  * Existing heredoc, nowdoc and inline HTML indentation should be respected at all times.
73
  */
74
  $this->ignore_tokens = Tokens::$heredocTokens;
75
- unset( $this->ignore_tokens[ T_START_HEREDOC ], $this->ignore_tokens[ T_START_NOWDOC ] );
76
- $this->ignore_tokens[ T_INLINE_HTML ] = T_INLINE_HTML;
77
 
78
  return array(
79
- T_ARRAY,
80
- T_OPEN_SHORT_ARRAY,
81
  );
82
  }
83
 
@@ -126,7 +125,7 @@ class ArrayIndentationSniff extends Sniff {
126
  * nothing or only indentation whitespace before it.
127
  */
128
  if ( 0 === $closer_line_spaces
129
- || ( T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code']
130
  && 1 === $this->tokens[ ( $closer - 1 ) ]['column'] )
131
  ) {
132
  $this->add_array_alignment_error(
@@ -173,7 +172,7 @@ class ArrayIndentationSniff extends Sniff {
173
 
174
  // Find the line on which the item starts.
175
  $first_content = $this->phpcsFile->findNext(
176
- array( T_WHITESPACE, T_DOC_COMMENT_WHITESPACE ),
177
  $item['start'],
178
  $end_of_this_item,
179
  true
@@ -181,11 +180,11 @@ class ArrayIndentationSniff extends Sniff {
181
 
182
  // Deal with trailing comments.
183
  if ( false !== $first_content
184
- && T_COMMENT === $this->tokens[ $first_content ]['code']
185
  && $this->tokens[ $first_content ]['line'] === $this->tokens[ $end_of_previous_item ]['line']
186
  ) {
187
  $first_content = $this->phpcsFile->findNext(
188
- array( T_WHITESPACE, T_DOC_COMMENT_WHITESPACE ),
189
  ( $first_content + 1 ),
190
  $end_of_this_item,
191
  true
@@ -201,7 +200,7 @@ class ArrayIndentationSniff extends Sniff {
201
  // That is handled by the ArrayDeclarationSpacingSniff.
202
  if ( $this->tokens[ $first_content ]['line'] === $this->tokens[ $end_of_previous_item ]['line']
203
  || ( 1 !== $this->tokens[ $first_content ]['column']
204
- && T_WHITESPACE !== $this->tokens[ ( $first_content - 1 ) ]['code'] )
205
  ) {
206
  return $closer;
207
  }
@@ -248,7 +247,7 @@ class ArrayIndentationSniff extends Sniff {
248
  }
249
 
250
  $first_content_on_line2 = $this->phpcsFile->findNext(
251
- array( T_WHITESPACE, T_DOC_COMMENT_WHITESPACE ),
252
  $ptr,
253
  $end_of_this_item,
254
  true
@@ -262,7 +261,7 @@ class ArrayIndentationSniff extends Sniff {
262
  * so check its placement.
263
  */
264
  if ( $this->tokens[ $item['end'] ]['line'] !== $this->tokens[ $end_of_this_item ]['line']
265
- && T_COMMA === $this->tokens[ $end_of_this_item ]['code']
266
  && ( $this->tokens[ $end_of_this_item ]['column'] - 1 ) !== $expected_spaces
267
  ) {
268
  $this->add_array_alignment_error(
@@ -305,7 +304,7 @@ class ArrayIndentationSniff extends Sniff {
305
 
306
  // Fix second line for the array item.
307
  if ( 1 === $this->tokens[ $first_content_on_line2 ]['column']
308
- && T_COMMENT === $this->tokens[ $first_content_on_line2 ]['code']
309
  ) {
310
  $actual_comment = ltrim( $this->tokens[ $first_content_on_line2 ]['content'] );
311
  $replacement = $expected_indent_on_line2 . $actual_comment;
@@ -328,7 +327,7 @@ class ArrayIndentationSniff extends Sniff {
328
  }
329
 
330
  $first_content_on_line = $this->phpcsFile->findNext(
331
- array( T_WHITESPACE, T_DOC_COMMENT_WHITESPACE ),
332
  $i,
333
  $end_of_this_item,
334
  true
@@ -351,7 +350,7 @@ class ArrayIndentationSniff extends Sniff {
351
 
352
  if ( $found_spaces_on_line !== $expected_spaces_on_line ) {
353
  if ( 1 === $this->tokens[ $first_content_on_line ]['column']
354
- && T_COMMENT === $this->tokens[ $first_content_on_line ]['code']
355
  ) {
356
  $actual_comment = ltrim( $this->tokens[ $first_content_on_line ]['content'] );
357
  $replacement = $expected_indent_on_line . $actual_comment;
@@ -371,7 +370,7 @@ class ArrayIndentationSniff extends Sniff {
371
  * Check the placement of the comma after the array item as it might be on a line by itself.
372
  */
373
  if ( $this->tokens[ $item['end'] ]['line'] !== $this->tokens[ $end_of_this_item ]['line']
374
- && T_COMMA === $this->tokens[ $end_of_this_item ]['code']
375
  && ( $this->tokens[ $end_of_this_item ]['column'] - 1 ) !== $expected_spaces
376
  ) {
377
  $this->add_array_alignment_error(
@@ -390,9 +389,7 @@ class ArrayIndentationSniff extends Sniff {
390
 
391
  $end_of_previous_item = $end_of_this_item;
392
  }
393
-
394
- } // End process_token().
395
-
396
 
397
  /**
398
  * Should the token be ignored ?
@@ -411,13 +408,26 @@ class ArrayIndentationSniff extends Sniff {
411
  return true;
412
  }
413
 
414
- // If it's a subsequent line of a multi-line sting, it will not start with a quote character.
415
- if ( ( T_CONSTANT_ENCAPSED_STRING === $token_code
416
- || T_DOUBLE_QUOTED_STRING === $token_code )
417
- && "'" !== $this->tokens[ $ptr ]['content'][0]
418
- && '"' !== $this->tokens[ $ptr ]['content'][0]
 
419
  ) {
420
- return true;
 
 
 
 
 
 
 
 
 
 
 
 
421
  }
422
 
423
  return false;
@@ -441,8 +451,8 @@ class ArrayIndentationSniff extends Sniff {
441
 
442
  $whitespace = '';
443
 
444
- if ( T_WHITESPACE === $this->tokens[ $ptr ]['code']
445
- || T_DOC_COMMENT_WHITESPACE === $this->tokens[ $ptr ]['code']
446
  ) {
447
  return $this->tokens[ $ptr ]['length'];
448
  }
@@ -454,13 +464,13 @@ class ArrayIndentationSniff extends Sniff {
454
  * First/Single line is tokenized as T_WHITESPACE + T_COMMENT
455
  * Subsequent lines are tokenized as T_COMMENT including the indentation whitespace.
456
  */
457
- if ( T_COMMENT === $this->tokens[ $ptr ]['code'] ) {
458
  $content = $this->tokens[ $ptr ]['content'];
459
  $actual_comment = ltrim( $content );
460
  $whitespace = str_replace( $actual_comment, '', $content );
461
  }
462
 
463
- return strlen( $whitespace );
464
  }
465
 
466
  /**
@@ -521,4 +531,4 @@ class ArrayIndentationSniff extends Sniff {
521
  }
522
  }
523
 
524
- } // End class.
59
  */
60
  private $ignore_tokens = array();
61
 
 
62
  /**
63
  * Returns an array of tokens this test wants to listen for.
64
  *
71
  * Existing heredoc, nowdoc and inline HTML indentation should be respected at all times.
72
  */
73
  $this->ignore_tokens = Tokens::$heredocTokens;
74
+ unset( $this->ignore_tokens[ \T_START_HEREDOC ], $this->ignore_tokens[ \T_START_NOWDOC ] );
75
+ $this->ignore_tokens[ \T_INLINE_HTML ] = \T_INLINE_HTML;
76
 
77
  return array(
78
+ \T_ARRAY,
79
+ \T_OPEN_SHORT_ARRAY,
80
  );
81
  }
82
 
125
  * nothing or only indentation whitespace before it.
126
  */
127
  if ( 0 === $closer_line_spaces
128
+ || ( \T_WHITESPACE === $this->tokens[ ( $closer - 1 ) ]['code']
129
  && 1 === $this->tokens[ ( $closer - 1 ) ]['column'] )
130
  ) {
131
  $this->add_array_alignment_error(
172
 
173
  // Find the line on which the item starts.
174
  $first_content = $this->phpcsFile->findNext(
175
+ array( \T_WHITESPACE, \T_DOC_COMMENT_WHITESPACE ),
176
  $item['start'],
177
  $end_of_this_item,
178
  true
180
 
181
  // Deal with trailing comments.
182
  if ( false !== $first_content
183
+ && \T_COMMENT === $this->tokens[ $first_content ]['code']
184
  && $this->tokens[ $first_content ]['line'] === $this->tokens[ $end_of_previous_item ]['line']
185
  ) {
186
  $first_content = $this->phpcsFile->findNext(
187
+ array( \T_WHITESPACE, \T_DOC_COMMENT_WHITESPACE, \T_COMMENT ),
188
  ( $first_content + 1 ),
189
  $end_of_this_item,
190
  true
200
  // That is handled by the ArrayDeclarationSpacingSniff.
201
  if ( $this->tokens[ $first_content ]['line'] === $this->tokens[ $end_of_previous_item ]['line']
202
  || ( 1 !== $this->tokens[ $first_content ]['column']
203
+ && \T_WHITESPACE !== $this->tokens[ ( $first_content - 1 ) ]['code'] )
204
  ) {
205
  return $closer;
206
  }
247
  }
248
 
249
  $first_content_on_line2 = $this->phpcsFile->findNext(
250
+ array( \T_WHITESPACE, \T_DOC_COMMENT_WHITESPACE ),
251
  $ptr,
252
  $end_of_this_item,
253
  true
261
  * so check its placement.
262
  */
263
  if ( $this->tokens[ $item['end'] ]['line'] !== $this->tokens[ $end_of_this_item ]['line']
264
+ && \T_COMMA === $this->tokens[ $end_of_this_item ]['code']
265
  && ( $this->tokens[ $end_of_this_item ]['column'] - 1 ) !== $expected_spaces
266
  ) {
267
  $this->add_array_alignment_error(
304
 
305
  // Fix second line for the array item.
306
  if ( 1 === $this->tokens[ $first_content_on_line2 ]['column']
307
+ && \T_COMMENT === $this->tokens[ $first_content_on_line2 ]['code']
308
  ) {
309
  $actual_comment = ltrim( $this->tokens[ $first_content_on_line2 ]['content'] );
310
  $replacement = $expected_indent_on_line2 . $actual_comment;
327
  }
328
 
329
  $first_content_on_line = $this->phpcsFile->findNext(
330
+ array( \T_WHITESPACE, \T_DOC_COMMENT_WHITESPACE ),
331
  $i,
332
  $end_of_this_item,
333
  true
350
 
351
  if ( $found_spaces_on_line !== $expected_spaces_on_line ) {
352
  if ( 1 === $this->tokens[ $first_content_on_line ]['column']
353
+ && \T_COMMENT === $this->tokens[ $first_content_on_line ]['code']
354
  ) {
355
  $actual_comment = ltrim( $this->tokens[ $first_content_on_line ]['content'] );
356
  $replacement = $expected_indent_on_line . $actual_comment;
370
  * Check the placement of the comma after the array item as it might be on a line by itself.
371
  */
372
  if ( $this->tokens[ $item['end'] ]['line'] !== $this->tokens[ $end_of_this_item ]['line']
373
+ && \T_COMMA === $this->tokens[ $end_of_this_item ]['code']
374
  && ( $this->tokens[ $end_of_this_item ]['column'] - 1 ) !== $expected_spaces
375
  ) {
376
  $this->add_array_alignment_error(
389
 
390
  $end_of_previous_item = $end_of_this_item;
391
  }
392
+ }
 
 
393
 
394
  /**
395
  * Should the token be ignored ?
408
  return true;
409
  }
410
 
411
+ /*
412
+ * If it's a subsequent line of a multi-line sting, it will not start with a quote
413
+ * character, nor just *be* a quote character.
414
+ */
415
+ if ( \T_CONSTANT_ENCAPSED_STRING === $token_code
416
+ || \T_DOUBLE_QUOTED_STRING === $token_code
417
  ) {
418
+ // Deal with closing quote of a multi-line string being on its own line.
419
+ if ( "'" === $this->tokens[ $ptr ]['content']
420
+ || '"' === $this->tokens[ $ptr ]['content']
421
+ ) {
422
+ return true;
423
+ }
424
+
425
+ // Deal with subsequent lines of a multi-line string where the token is broken up per line.
426
+ if ( "'" !== $this->tokens[ $ptr ]['content'][0]
427
+ && '"' !== $this->tokens[ $ptr ]['content'][0]
428
+ ) {
429
+ return true;
430
+ }
431
  }
432
 
433
  return false;
451
 
452
  $whitespace = '';
453
 
454
+ if ( \T_WHITESPACE === $this->tokens[ $ptr ]['code']
455
+ || \T_DOC_COMMENT_WHITESPACE === $this->tokens[ $ptr ]['code']
456
  ) {
457
  return $this->tokens[ $ptr ]['length'];
458
  }
464
  * First/Single line is tokenized as T_WHITESPACE + T_COMMENT
465
  * Subsequent lines are tokenized as T_COMMENT including the indentation whitespace.
466
  */
467
+ if ( \T_COMMENT === $this->tokens[ $ptr ]['code'] ) {
468
  $content = $this->tokens[ $ptr ]['content'];
469
  $actual_comment = ltrim( $content );
470
  $whitespace = str_replace( $actual_comment, '', $content );
471
  }
472
 
473
+ return \strlen( $whitespace );
474
  }
475
 
476
  /**
531
  }
532
  }
533
 
534
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/ArrayKeySpacingRestrictionsSniff.php CHANGED
@@ -14,7 +14,7 @@ use WordPress\Sniff;
14
  /**
15
  * Check for proper spacing in array key references.
16
  *
17
- * @link http://make.wordpress.org/core/handbook/coding-standards/php/#space-usage
18
  *
19
  * @package WPCS\WordPressCodingStandards
20
  *
@@ -32,9 +32,8 @@ class ArrayKeySpacingRestrictionsSniff extends Sniff {
32
  */
33
  public function register() {
34
  return array(
35
- T_OPEN_SQUARE_BRACKET,
36
  );
37
-
38
  }
39
 
40
  /**
@@ -53,14 +52,14 @@ class ArrayKeySpacingRestrictionsSniff extends Sniff {
53
  }
54
 
55
  $need_spaces = $this->phpcsFile->findNext(
56
- array( T_CONSTANT_ENCAPSED_STRING, T_LNUMBER, T_WHITESPACE, T_MINUS ),
57
  ( $stackPtr + 1 ),
58
  $token['bracket_closer'],
59
  true
60
  );
61
 
62
- $spaced1 = ( T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ]['code'] );
63
- $spaced2 = ( T_WHITESPACE === $this->tokens[ ( $token['bracket_closer'] - 1 ) ]['code'] );
64
 
65
  // It should have spaces unless if it only has strings or numbers as the key.
66
  if ( false !== $need_spaces && ! ( $spaced1 && $spaced2 ) ) {
@@ -86,7 +85,6 @@ class ArrayKeySpacingRestrictionsSniff extends Sniff {
86
  }
87
  }
88
  }
 
89
 
90
- } // End process().
91
-
92
- } // End class.
14
  /**
15
  * Check for proper spacing in array key references.
16
  *
17
+ * @link https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#space-usage
18
  *
19
  * @package WPCS\WordPressCodingStandards
20
  *
32
  */
33
  public function register() {
34
  return array(
35
+ \T_OPEN_SQUARE_BRACKET,
36
  );
 
37
  }
38
 
39
  /**
52
  }
53
 
54
  $need_spaces = $this->phpcsFile->findNext(
55
+ array( \T_CONSTANT_ENCAPSED_STRING, \T_LNUMBER, \T_WHITESPACE, \T_MINUS ),
56
  ( $stackPtr + 1 ),
57
  $token['bracket_closer'],
58
  true
59
  );
60
 
61
+ $spaced1 = ( \T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ]['code'] );
62
+ $spaced2 = ( \T_WHITESPACE === $this->tokens[ ( $token['bracket_closer'] - 1 ) ]['code'] );
63
 
64
  // It should have spaces unless if it only has strings or numbers as the key.
65
  if ( false !== $need_spaces && ! ( $spaced1 && $spaced2 ) ) {
85
  }
86
  }
87
  }
88
+ }
89
 
90
+ }
 
 
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/CommaAfterArrayItemSniff.php CHANGED
@@ -38,8 +38,8 @@ class CommaAfterArrayItemSniff extends Sniff {
38
  */
39
  public function register() {
40
  return array(
41
- T_ARRAY,
42
- T_OPEN_SHORT_ARRAY,
43
  );
44
  }
45
 
@@ -80,13 +80,13 @@ class CommaAfterArrayItemSniff extends Sniff {
80
  return;
81
  }
82
 
83
- $array_item_count = count( $array_items );
84
 
85
  // Note: $item_index is 1-based and the array items are split on the commas!
86
  foreach ( $array_items as $item_index => $item ) {
87
  $maybe_comma = ( $item['end'] + 1 );
88
  $is_comma = false;
89
- if ( isset( $this->tokens[ $maybe_comma ] ) && T_COMMA === $this->tokens[ $maybe_comma ]['code'] ) {
90
  $is_comma = true;
91
  }
92
 
@@ -162,13 +162,15 @@ class CommaAfterArrayItemSniff extends Sniff {
162
  $spaces = 0;
163
  for ( $i = $item['end']; $i > $last_content; $i-- ) {
164
 
165
- if ( T_WHITESPACE === $this->tokens[ $i ]['code'] ) {
166
  if ( $this->tokens[ $i ]['content'] === $this->phpcsFile->eolChar ) {
167
  $newlines++;
168
  } else {
169
  $spaces += $this->tokens[ $i ]['length'];
170
  }
171
- } elseif ( T_COMMENT === $this->tokens[ $i ]['code'] ) {
 
 
172
  break;
173
  }
174
  }
@@ -196,10 +198,12 @@ class CommaAfterArrayItemSniff extends Sniff {
196
  $this->phpcsFile->fixer->beginChangeset();
197
  for ( $i = $item['end']; $i > $last_content; $i-- ) {
198
 
199
- if ( T_WHITESPACE === $this->tokens[ $i ]['code'] ) {
200
  $this->phpcsFile->fixer->replaceToken( $i, '' );
201
 
202
- } elseif ( T_COMMENT === $this->tokens[ $i ]['code'] ) {
 
 
203
  // We need to move the comma to before the comment.
204
  $this->phpcsFile->fixer->addContent( $last_content, ',' );
205
  $this->phpcsFile->fixer->replaceToken( $maybe_comma, '' );
@@ -227,14 +231,14 @@ class CommaAfterArrayItemSniff extends Sniff {
227
  */
228
  $next_token = $this->tokens[ ( $maybe_comma + 1 ) ];
229
 
230
- if ( T_WHITESPACE === $next_token['code'] ) {
231
 
232
  if ( false === $single_line && $this->phpcsFile->eolChar === $next_token['content'] ) {
233
  continue;
234
  }
235
 
236
  $next_non_whitespace = $this->phpcsFile->findNext(
237
- T_WHITESPACE,
238
  ( $maybe_comma + 1 ),
239
  $closer,
240
  true
@@ -243,7 +247,8 @@ class CommaAfterArrayItemSniff extends Sniff {
243
  if ( false === $next_non_whitespace
244
  || ( false === $single_line
245
  && $this->tokens[ $next_non_whitespace ]['line'] === $this->tokens[ $maybe_comma ]['line']
246
- && T_COMMENT === $this->tokens[ $next_non_whitespace ]['code'] )
 
247
  ) {
248
  continue;
249
  }
@@ -283,4 +288,4 @@ class CommaAfterArrayItemSniff extends Sniff {
283
  }
284
  }
285
 
286
- } // End class.
38
  */
39
  public function register() {
40
  return array(
41
+ \T_ARRAY,
42
+ \T_OPEN_SHORT_ARRAY,
43
  );
44
  }
45
 
80
  return;
81
  }
82
 
83
+ $array_item_count = \count( $array_items );
84
 
85
  // Note: $item_index is 1-based and the array items are split on the commas!
86
  foreach ( $array_items as $item_index => $item ) {
87
  $maybe_comma = ( $item['end'] + 1 );
88
  $is_comma = false;
89
+ if ( isset( $this->tokens[ $maybe_comma ] ) && \T_COMMA === $this->tokens[ $maybe_comma ]['code'] ) {
90
  $is_comma = true;
91
  }
92
 
162
  $spaces = 0;
163
  for ( $i = $item['end']; $i > $last_content; $i-- ) {
164
 
165
+ if ( \T_WHITESPACE === $this->tokens[ $i ]['code'] ) {
166
  if ( $this->tokens[ $i ]['content'] === $this->phpcsFile->eolChar ) {
167
  $newlines++;
168
  } else {
169
  $spaces += $this->tokens[ $i ]['length'];
170
  }
171
+ } elseif ( \T_COMMENT === $this->tokens[ $i ]['code']
172
+ || isset( $this->phpcsCommentTokens[ $this->tokens[ $i ]['type'] ] )
173
+ ) {
174
  break;
175
  }
176
  }
198
  $this->phpcsFile->fixer->beginChangeset();
199
  for ( $i = $item['end']; $i > $last_content; $i-- ) {
200
 
201
+ if ( \T_WHITESPACE === $this->tokens[ $i ]['code'] ) {
202
  $this->phpcsFile->fixer->replaceToken( $i, '' );
203
 
204
+ } elseif ( \T_COMMENT === $this->tokens[ $i ]['code']
205
+ || isset( $this->phpcsCommentTokens[ $this->tokens[ $i ]['type'] ] )
206
+ ) {
207
  // We need to move the comma to before the comment.
208
  $this->phpcsFile->fixer->addContent( $last_content, ',' );
209
  $this->phpcsFile->fixer->replaceToken( $maybe_comma, '' );
231
  */
232
  $next_token = $this->tokens[ ( $maybe_comma + 1 ) ];
233
 
234
+ if ( \T_WHITESPACE === $next_token['code'] ) {
235
 
236
  if ( false === $single_line && $this->phpcsFile->eolChar === $next_token['content'] ) {
237
  continue;
238
  }
239
 
240
  $next_non_whitespace = $this->phpcsFile->findNext(
241
+ \T_WHITESPACE,
242
  ( $maybe_comma + 1 ),
243
  $closer,
244
  true
247
  if ( false === $next_non_whitespace
248
  || ( false === $single_line
249
  && $this->tokens[ $next_non_whitespace ]['line'] === $this->tokens[ $maybe_comma ]['line']
250
+ && ( \T_COMMENT === $this->tokens[ $next_non_whitespace ]['code']
251
+ || isset( $this->phpcsCommentTokens[ $this->tokens[ $next_non_whitespace ]['type'] ] ) ) )
252
  ) {
253
  continue;
254
  }
288
  }
289
  }
290
 
291
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Arrays/MultipleStatementAlignmentSniff.php CHANGED
@@ -148,8 +148,8 @@ class MultipleStatementAlignmentSniff extends Sniff {
148
  */
149
  public function register() {
150
  return array(
151
- T_ARRAY,
152
- T_OPEN_SHORT_ARRAY,
153
  );
154
  }
155
 
@@ -216,13 +216,13 @@ class MultipleStatementAlignmentSniff extends Sniff {
216
  * Just find and fix them all.
217
  */
218
  $next_arrow = $this->phpcsFile->findNext(
219
- T_DOUBLE_ARROW,
220
  ( $opener + 1 ),
221
  $closer
222
  );
223
 
224
  while ( false !== $next_arrow ) {
225
- if ( T_WHITESPACE === $this->tokens[ ( $next_arrow - 1 ) ]['code'] ) {
226
  $space_length = $this->tokens[ ( $next_arrow - 1 ) ]['length'];
227
  if ( 1 !== $space_length ) {
228
  $error = 'Expected 1 space between "%s" and double arrow; %s found';
@@ -240,7 +240,7 @@ class MultipleStatementAlignmentSniff extends Sniff {
240
 
241
  // Find the position of the next double arrow.
242
  $next_arrow = $this->phpcsFile->findNext(
243
- T_DOUBLE_ARROW,
244
  ( $next_arrow + 1 ),
245
  $closer
246
  );
@@ -282,7 +282,7 @@ class MultipleStatementAlignmentSniff extends Sniff {
282
  $index_end_cols = array(); // Keep track of the end column position of index keys.
283
  $double_arrow_cols = array(); // Keep track of arrow column position and count.
284
  $multi_line_count = 0;
285
- $total_items = count( $items );
286
 
287
  foreach ( $items as $key => $item ) {
288
  if ( strpos( $item['raw'], '=>' ) === false ) {
@@ -293,7 +293,7 @@ class MultipleStatementAlignmentSniff extends Sniff {
293
 
294
  // Find the position of the first double arrow.
295
  $double_arrow = $this->phpcsFile->findNext(
296
- T_DOUBLE_ARROW,
297
  $item['start'],
298
  ( $item['end'] + 1 )
299
  );
@@ -319,7 +319,7 @@ class MultipleStatementAlignmentSniff extends Sniff {
319
 
320
  // Find the end of the array key.
321
  $last_index_token = $this->phpcsFile->findPrevious(
322
- T_WHITESPACE,
323
  ( $double_arrow - 1 ),
324
  $item['start'],
325
  true
@@ -424,11 +424,11 @@ class MultipleStatementAlignmentSniff extends Sniff {
424
  * If the alignment does not have to be exact, see if a majority
425
  * group of the arrows is already at an acceptable position.
426
  */
427
- arsort( $double_arrow_cols, SORT_NUMERIC );
428
  reset( $double_arrow_cols );
429
  $count = current( $double_arrow_cols );
430
 
431
- if ( $count > 1 || ( 1 === $count && count( $items ) === 1 ) ) {
432
  // Allow for several groups of arrows having the same $count.
433
  $filtered_double_arrow_cols = array_keys( $double_arrow_cols, $count, true );
434
 
@@ -453,7 +453,7 @@ class MultipleStatementAlignmentSniff extends Sniff {
453
  continue;
454
  }
455
 
456
- if ( T_WHITESPACE !== $this->tokens[ ( $item['operatorPtr'] - 1 ) ]['code'] ) {
457
  $before = 0;
458
  } else {
459
  if ( $this->tokens[ $item['last_index_token'] ]['line'] !== $this->tokens[ $item['operatorPtr'] ]['line'] ) {
@@ -562,7 +562,7 @@ class MultipleStatementAlignmentSniff extends Sniff {
562
  }
563
  }
564
  }
565
- } // End process_multi_line_array().
566
 
567
  /**
568
  * Validate that a valid value has been received for the alignMultilineItems property.
@@ -584,7 +584,7 @@ class MultipleStatementAlignmentSniff extends Sniff {
584
  $operator = $matches[1];
585
  $number = (int) $matches[2];
586
 
587
- if ( in_array( $operator, array( '<', '<=', '>', '>=', '==', '=', '!=', '<>' ), true ) === true
588
  && ( $number >= 0 && $number <= 100 )
589
  ) {
590
  $this->alignMultilineItems = $alignMultilineItems;
@@ -606,4 +606,4 @@ class MultipleStatementAlignmentSniff extends Sniff {
606
  $this->alignMultilineItems = 'always';
607
  }
608
 
609
- } // End class.
148
  */
149
  public function register() {
150
  return array(
151
+ \T_ARRAY,
152
+ \T_OPEN_SHORT_ARRAY,
153
  );
154
  }
155
 
216
  * Just find and fix them all.
217
  */
218
  $next_arrow = $this->phpcsFile->findNext(
219
+ \T_DOUBLE_ARROW,
220
  ( $opener + 1 ),
221
  $closer
222
  );
223
 
224
  while ( false !== $next_arrow ) {
225
+ if ( \T_WHITESPACE === $this->tokens[ ( $next_arrow - 1 ) ]['code'] ) {
226
  $space_length = $this->tokens[ ( $next_arrow - 1 ) ]['length'];
227
  if ( 1 !== $space_length ) {
228
  $error = 'Expected 1 space between "%s" and double arrow; %s found';
240
 
241
  // Find the position of the next double arrow.
242
  $next_arrow = $this->phpcsFile->findNext(
243
+ \T_DOUBLE_ARROW,
244
  ( $next_arrow + 1 ),
245
  $closer
246
  );
282
  $index_end_cols = array(); // Keep track of the end column position of index keys.
283
  $double_arrow_cols = array(); // Keep track of arrow column position and count.
284
  $multi_line_count = 0;
285
+ $total_items = \count( $items );
286
 
287
  foreach ( $items as $key => $item ) {
288
  if ( strpos( $item['raw'], '=>' ) === false ) {
293
 
294
  // Find the position of the first double arrow.
295
  $double_arrow = $this->phpcsFile->findNext(
296
+ \T_DOUBLE_ARROW,
297
  $item['start'],
298
  ( $item['end'] + 1 )
299
  );
319
 
320
  // Find the end of the array key.
321
  $last_index_token = $this->phpcsFile->findPrevious(
322
+ \T_WHITESPACE,
323
  ( $double_arrow - 1 ),
324
  $item['start'],
325
  true
424
  * If the alignment does not have to be exact, see if a majority
425
  * group of the arrows is already at an acceptable position.
426
  */
427
+ arsort( $double_arrow_cols, \SORT_NUMERIC );
428
  reset( $double_arrow_cols );
429
  $count = current( $double_arrow_cols );
430
 
431
+ if ( $count > 1 || ( 1 === $count && \count( $items ) === 1 ) ) {
432
  // Allow for several groups of arrows having the same $count.
433
  $filtered_double_arrow_cols = array_keys( $double_arrow_cols, $count, true );
434
 
453
  continue;
454
  }
455
 
456
+ if ( \T_WHITESPACE !== $this->tokens[ ( $item['operatorPtr'] - 1 ) ]['code'] ) {
457
  $before = 0;
458
  } else {
459
  if ( $this->tokens[ $item['last_index_token'] ]['line'] !== $this->tokens[ $item['operatorPtr'] ]['line'] ) {
562
  }
563
  }
564
  }
565
+ }
566
 
567
  /**
568
  * Validate that a valid value has been received for the alignMultilineItems property.
584
  $operator = $matches[1];
585
  $number = (int) $matches[2];
586
 
587
+ if ( \in_array( $operator, array( '<', '<=', '>', '>=', '==', '=', '!=', '<>' ), true ) === true
588
  && ( $number >= 0 && $number <= 100 )
589
  ) {
590
  $this->alignMultilineItems = $alignMultilineItems;
606
  $this->alignMultilineItems = 'always';
607
  }
608
 
609
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CSRF/NonceVerificationSniff.php CHANGED
@@ -20,184 +20,56 @@ use WordPress\Sniff;
20
  *
21
  * @since 0.5.0
22
  * @since 0.13.0 Class name changed: this class is now namespaced.
 
 
 
23
  */
24
- class NonceVerificationSniff extends Sniff {
25
 
26
  /**
27
- * Superglobals to notify about when not accompanied by an nonce check.
28
- *
29
- * A value of `true` results in an error. A value of `false` in a warning.
30
  *
31
- * @since 0.12.0
32
  *
33
  * @var array
34
  */
35
- protected $superglobals = array(
36
- '$_POST' => true,
37
- '$_FILE' => true,
38
- '$_GET' => false,
39
- '$_REQUEST' => false,
40
  );
41
 
42
  /**
43
- * Superglobals to give an error for when not accompanied by an nonce check.
44
- *
45
- * @since 0.5.0
46
- * @since 0.11.0 Changed visibility from public to protected.
47
- *
48
- * @deprecated 0.12.0 Replaced by $superglobals property.
49
- *
50
- * @var array
51
- */
52
- protected $errorForSuperGlobals = array();
53
-
54
- /**
55
- * Superglobals to give a warning for when not accompanied by an nonce check.
56
  *
57
- * If the variable is also in the error list, that takes precedence.
58
- *
59
- * @since 0.5.0
60
- * @since 0.11.0 Changed visibility from public to protected.
61
- *
62
- * @deprecated 0.12.0 Replaced by $superglobals property.
63
- *
64
- * @var array
65
- */
66
- protected $warnForSuperGlobals = array();
67
-
68
- /**
69
- * Custom list of functions which verify nonces.
70
- *
71
- * @since 0.5.0
72
- *
73
- * @var string|string[]
74
- */
75
- public $customNonceVerificationFunctions = array();
76
-
77
- /**
78
- * Custom list of functions that sanitize the values passed to them.
79
- *
80
- * @since 0.11.0
81
- *
82
- * @var string|string[]
83
- */
84
- public $customSanitizingFunctions = array();
85
-
86
- /**
87
- * Custom sanitizing functions that implicitly unslash the values passed to them.
88
- *
89
- * @since 0.11.0
90
- *
91
- * @var string|string[]
92
- */
93
- public $customUnslashingSanitizingFunctions = array();
94
-
95
- /**
96
- * Cache of previously added custom functions.
97
- *
98
- * Prevents having to do the same merges over and over again.
99
- *
100
- * @since 0.5.0
101
- * @since 0.11.0 - Changed from public static to protected non-static.
102
- * - Changed the format from simple bool to array.
103
- *
104
- * @var array
105
- */
106
- protected $addedCustomFunctions = array(
107
- 'nonce' => null,
108
- 'sanitize' => null,
109
- 'unslashsanitize' => null,
110
- );
111
-
112
- /**
113
- * Returns an array of tokens this test wants to listen for.
114
- *
115
- * @return array
116
- */
117
- public function register() {
118
-
119
- return array(
120
- T_VARIABLE,
121
- );
122
- }
123
-
124
- /**
125
- * Processes this test, when one of its tokens is encountered.
126
  *
127
  * @param int $stackPtr The position of the current token in the stack.
128
  *
129
- * @return void
130
  */
131
  public function process_token( $stackPtr ) {
132
-
133
- $instance = $this->tokens[ $stackPtr ];
134
-
135
- if ( ! isset( $this->superglobals[ $instance['content'] ] ) ) {
136
- return;
137
- }
138
-
139
- if ( $this->has_whitelist_comment( 'CSRF', $stackPtr ) ) {
140
- return;
141
- }
142
-
143
- if ( $this->is_assignment( $stackPtr ) ) {
144
- return;
145
- }
146
-
147
- $this->mergeFunctionLists();
148
-
149
- if ( $this->is_only_sanitized( $stackPtr ) ) {
150
- return;
151
- }
152
-
153
- if ( $this->has_nonce_check( $stackPtr ) ) {
154
- return;
155
- }
156
-
157
- // If we're still here, no nonce-verification function was found.
158
- $this->addMessage(
159
- 'Processing form data without nonce verification.',
160
- $stackPtr,
161
- $this->superglobals[ $instance['content'] ],
162
- 'NoNonceVerification'
163
- );
164
-
165
- } // End process_token().
166
-
167
- /**
168
- * Merge custom functions provided via a custom ruleset with the defaults, if we haven't already.
169
- *
170
- * @since 0.11.0 Split out from the `process()` method.
171
- *
172
- * @return void
173
- */
174
- protected function mergeFunctionLists() {
175
- if ( $this->customNonceVerificationFunctions !== $this->addedCustomFunctions['nonce'] ) {
176
- $this->nonceVerificationFunctions = $this->merge_custom_array(
177
- $this->customNonceVerificationFunctions,
178
- $this->nonceVerificationFunctions
179
  );
180
-
181
- $this->addedCustomFunctions['nonce'] = $this->customNonceVerificationFunctions;
182
  }
183
 
184
- if ( $this->customSanitizingFunctions !== $this->addedCustomFunctions['sanitize'] ) {
185
- $this->sanitizingFunctions = $this->merge_custom_array(
186
- $this->customSanitizingFunctions,
187
- $this->sanitizingFunctions
 
 
 
 
 
188
  );
189
-
190
- $this->addedCustomFunctions['sanitize'] = $this->customSanitizingFunctions;
191
  }
192
 
193
- if ( $this->customUnslashingSanitizingFunctions !== $this->addedCustomFunctions['unslashsanitize'] ) {
194
- $this->unslashingSanitizingFunctions = $this->merge_custom_array(
195
- $this->customUnslashingSanitizingFunctions,
196
- $this->unslashingSanitizingFunctions
197
- );
198
-
199
- $this->addedCustomFunctions['unslashsanitize'] = $this->customUnslashingSanitizingFunctions;
200
- }
201
  }
202
 
203
- } // End class.
20
  *
21
  * @since 0.5.0
22
  * @since 0.13.0 Class name changed: this class is now namespaced.
23
+ *
24
+ * @deprecated 1.0.0 This sniff has been moved to the `Security` category.
25
+ * This file remains for now to prevent BC breaks.
26
  */
27
+ class NonceVerificationSniff extends \WordPress\Sniffs\Security\NonceVerificationSniff {
28
 
29
  /**
30
+ * Keep track of whether the warnings have been thrown to prevent
31
+ * the messages being thrown for every token triggering the sniff.
 
32
  *
33
+ * @since 1.0.0
34
  *
35
  * @var array
36
  */
37
+ private $thrown = array(
38
+ 'DeprecatedSniff' => false,
39
+ 'FoundPropertyForDeprecatedSniff' => false,
 
 
40
  );
41
 
42
  /**
43
+ * Don't use.
 
 
 
 
 
 
 
 
 
 
 
 
44
  *
45
+ * @deprecated 1.0.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
  *
47
  * @param int $stackPtr The position of the current token in the stack.
48
  *
49
+ * @return void|int
50
  */
51
  public function process_token( $stackPtr ) {
52
+ if ( false === $this->thrown['DeprecatedSniff'] ) {
53
+ $this->thrown['DeprecatedSniff'] = $this->phpcsFile->addWarning(
54
+ 'The "WordPress.CSRF.NonceVerification" sniff has been renamed to "WordPress.Security.NonceVerification". Please update your custom ruleset.',
55
+ 0,
56
+ 'DeprecatedSniff'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  );
 
 
58
  }
59
 
60
+ if ( false === $this->thrown['FoundPropertyForDeprecatedSniff']
61
+ && ( ( array() !== $this->customNonceVerificationFunctions && $this->customNonceVerificationFunctions !== $this->addedCustomFunctions['nonce'] )
62
+ || ( array() !== $this->customSanitizingFunctions && $this->customSanitizingFunctions !== $this->addedCustomFunctions['sanitize'] )
63
+ || ( array() !== $this->customUnslashingSanitizingFunctions && $this->customUnslashingSanitizingFunctions !== $this->addedCustomFunctions['unslashsanitize'] ) )
64
+ ) {
65
+ $this->thrown['FoundPropertyForDeprecatedSniff'] = $this->phpcsFile->addWarning(
66
+ 'The "WordPress.CSRF.NonceVerification" sniff has been renamed to "WordPress.Security.NonceVerification". Please update your custom ruleset.',
67
+ 0,
68
+ 'FoundPropertyForDeprecatedSniff'
69
  );
 
 
70
  }
71
 
72
+ return parent::process_token( $stackPtr );
 
 
 
 
 
 
 
73
  }
74
 
75
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Classes/ClassInstantiationSniff.php CHANGED
@@ -59,26 +59,26 @@ class ClassInstantiationSniff extends Sniff {
59
  *
60
  * Currently does not account for classnames passed as a variable variable.
61
  */
62
- $this->classname_tokens = Tokens::$emptyTokens;
63
- $this->classname_tokens[ T_NS_SEPARATOR ] = T_NS_SEPARATOR;
64
- $this->classname_tokens[ T_STRING ] = T_STRING;
65
- $this->classname_tokens[ T_SELF ] = T_SELF;
66
- $this->classname_tokens[ T_STATIC ] = T_STATIC;
67
- $this->classname_tokens[ T_PARENT ] = T_PARENT;
68
- $this->classname_tokens[ T_ANON_CLASS ] = T_ANON_CLASS;
69
 
70
  // Classname in a variable.
71
- $this->classname_tokens[ T_VARIABLE ] = T_VARIABLE;
72
- $this->classname_tokens[ T_DOUBLE_COLON ] = T_DOUBLE_COLON;
73
- $this->classname_tokens[ T_OBJECT_OPERATOR ] = T_OBJECT_OPERATOR;
74
- $this->classname_tokens[ T_OPEN_SQUARE_BRACKET ] = T_OPEN_SQUARE_BRACKET;
75
- $this->classname_tokens[ T_CLOSE_SQUARE_BRACKET ] = T_CLOSE_SQUARE_BRACKET;
76
- $this->classname_tokens[ T_CONSTANT_ENCAPSED_STRING ] = T_CONSTANT_ENCAPSED_STRING;
77
- $this->classname_tokens[ T_LNUMBER ] = T_LNUMBER;
78
 
79
  return array(
80
- T_NEW,
81
- T_STRING, // JS.
82
  );
83
  }
84
 
@@ -91,9 +91,9 @@ class ClassInstantiationSniff extends Sniff {
91
  */
92
  public function process_token( $stackPtr ) {
93
  // Make sure we have the right token, JS vs PHP.
94
- if ( ( 'PHP' === $this->phpcsFile->tokenizerType && T_NEW !== $this->tokens[ $stackPtr ]['code'] )
95
  || ( 'JS' === $this->phpcsFile->tokenizerType
96
- && ( T_STRING !== $this->tokens[ $stackPtr ]['code']
97
  || 'new' !== strtolower( $this->tokens[ $stackPtr ]['content'] ) ) )
98
  ) {
99
  return;
@@ -152,12 +152,12 @@ class ClassInstantiationSniff extends Sniff {
152
  break;
153
  }
154
 
155
- if ( T_WHITESPACE !== $this->tokens[ $classname_ptr ]['code'] ) {
156
  $has_comment = true;
157
  }
158
  }
159
 
160
- if ( T_OPEN_PARENTHESIS !== $this->tokens[ $next_non_empty_after_class_name ]['code'] ) {
161
  $this->phpcsFile->recordMetric( $stackPtr, 'Object instantiation with parenthesis', 'no' );
162
 
163
  $fix = $this->phpcsFile->addFixableError(
@@ -193,12 +193,12 @@ class ClassInstantiationSniff extends Sniff {
193
  $this->phpcsFile->fixer->endChangeset();
194
  }
195
  } else {
196
- $fix = $this->phpcsFile->addError( $error, $next_non_empty_after_class_name, $error_code );
197
  }
198
  } else {
199
  $this->phpcsFile->recordMetric( $stackPtr, 'Space between classname and parenthesis', 0 );
200
  }
201
  }
202
- } // End process_token().
203
 
204
- } // End class.
59
  *
60
  * Currently does not account for classnames passed as a variable variable.
61
  */
62
+ $this->classname_tokens = Tokens::$emptyTokens;
63
+ $this->classname_tokens[ \T_NS_SEPARATOR ] = \T_NS_SEPARATOR;
64
+ $this->classname_tokens[ \T_STRING ] = \T_STRING;
65
+ $this->classname_tokens[ \T_SELF ] = \T_SELF;
66
+ $this->classname_tokens[ \T_STATIC ] = \T_STATIC;
67
+ $this->classname_tokens[ \T_PARENT ] = \T_PARENT;
68
+ $this->classname_tokens[ \T_ANON_CLASS ] = \T_ANON_CLASS;
69
 
70
  // Classname in a variable.
71
+ $this->classname_tokens[ \T_VARIABLE ] = \T_VARIABLE;
72
+ $this->classname_tokens[ \T_DOUBLE_COLON ] = \T_DOUBLE_COLON;
73
+ $this->classname_tokens[ \T_OBJECT_OPERATOR ] = \T_OBJECT_OPERATOR;
74
+ $this->classname_tokens[ \T_OPEN_SQUARE_BRACKET ] = \T_OPEN_SQUARE_BRACKET;
75
+ $this->classname_tokens[ \T_CLOSE_SQUARE_BRACKET ] = \T_CLOSE_SQUARE_BRACKET;
76
+ $this->classname_tokens[ \T_CONSTANT_ENCAPSED_STRING ] = \T_CONSTANT_ENCAPSED_STRING;
77
+ $this->classname_tokens[ \T_LNUMBER ] = \T_LNUMBER;
78
 
79
  return array(
80
+ \T_NEW,
81
+ \T_STRING, // JS.
82
  );
83
  }
84
 
91
  */
92
  public function process_token( $stackPtr ) {
93
  // Make sure we have the right token, JS vs PHP.
94
+ if ( ( 'PHP' === $this->phpcsFile->tokenizerType && \T_NEW !== $this->tokens[ $stackPtr ]['code'] )
95
  || ( 'JS' === $this->phpcsFile->tokenizerType
96
+ && ( \T_STRING !== $this->tokens[ $stackPtr ]['code']
97
  || 'new' !== strtolower( $this->tokens[ $stackPtr ]['content'] ) ) )
98
  ) {
99
  return;
152
  break;
153
  }
154
 
155
+ if ( \T_WHITESPACE !== $this->tokens[ $classname_ptr ]['code'] ) {
156
  $has_comment = true;
157
  }
158
  }
159
 
160
+ if ( \T_OPEN_PARENTHESIS !== $this->tokens[ $next_non_empty_after_class_name ]['code'] ) {
161
  $this->phpcsFile->recordMetric( $stackPtr, 'Object instantiation with parenthesis', 'no' );
162
 
163
  $fix = $this->phpcsFile->addFixableError(
193
  $this->phpcsFile->fixer->endChangeset();
194
  }
195
  } else {
196
+ $this->phpcsFile->addError( $error, $next_non_empty_after_class_name, $error_code );
197
  }
198
  } else {
199
  $this->phpcsFile->recordMetric( $stackPtr, 'Space between classname and parenthesis', 0 );
200
  }
201
  }
202
+ }
203
 
204
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CodeAnalysis/AssignmentInConditionSniff.php CHANGED
@@ -59,26 +59,25 @@ class AssignmentInConditionSniff extends Sniff {
59
  */
60
  public function register() {
61
  $this->assignment_tokens = Tokens::$assignmentTokens;
62
- unset( $this->assignment_tokens[ T_DOUBLE_ARROW ] );
63
 
64
- $starters = Tokens::$booleanOperators;
65
- $starters[ T_SEMICOLON ] = T_SEMICOLON;
66
- $starters[ T_OPEN_PARENTHESIS ] = T_OPEN_PARENTHESIS;
67
- $starters[ T_INLINE_ELSE ] = T_INLINE_ELSE;
68
 
69
  $this->condition_start_tokens = $starters;
70
 
71
  return array(
72
- T_IF,
73
- T_ELSEIF,
74
- T_FOR,
75
- T_SWITCH,
76
- T_CASE,
77
- T_WHILE,
78
- T_INLINE_THEN,
79
  );
80
-
81
- }//end register()
82
 
83
  /**
84
  * Processes this test, when one of its tokens is encountered.
@@ -94,18 +93,18 @@ class AssignmentInConditionSniff extends Sniff {
94
  $token = $this->tokens[ $stackPtr ];
95
 
96
  // Find the condition opener/closer.
97
- if ( T_FOR === $token['code'] ) {
98
  if ( isset( $token['parenthesis_opener'], $token['parenthesis_closer'] ) === false ) {
99
  return;
100
  }
101
 
102
- $semicolon = $this->phpcsFile->findNext( T_SEMICOLON, ( $token['parenthesis_opener'] + 1 ), $token['parenthesis_closer'] );
103
  if ( false === $semicolon ) {
104
  return;
105
  }
106
 
107
  $opener = $semicolon;
108
- $semicolon = $this->phpcsFile->findNext( T_SEMICOLON, ( $opener + 1 ), $token['parenthesis_closer'] );
109
  if ( false === $semicolon ) {
110
  return;
111
  }
@@ -113,7 +112,7 @@ class AssignmentInConditionSniff extends Sniff {
113
  $closer = $semicolon;
114
  unset( $semicolon );
115
 
116
- } elseif ( T_CASE === $token['code'] ) {
117
  if ( isset( $token['scope_opener'] ) === false ) {
118
  return;
119
  }
@@ -121,7 +120,7 @@ class AssignmentInConditionSniff extends Sniff {
121
  $opener = $stackPtr;
122
  $closer = $token['scope_opener'];
123
 
124
- } elseif ( T_INLINE_THEN === $token['code'] ) {
125
  // Check if the condition for the ternary is bracketed.
126
  $prev = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
127
  if ( false === $prev ) {
@@ -129,7 +128,7 @@ class AssignmentInConditionSniff extends Sniff {
129
  return;
130
  }
131
 
132
- if ( T_CLOSE_PARENTHESIS === $this->tokens[ $prev ]['code'] ) {
133
  if ( ! isset( $this->tokens[ $prev ]['parenthesis_opener'] ) ) {
134
  return;
135
  }
@@ -137,9 +136,24 @@ class AssignmentInConditionSniff extends Sniff {
137
  $opener = $this->tokens[ $prev ]['parenthesis_opener'];
138
  $closer = $prev;
139
  } elseif ( isset( $token['nested_parenthesis'] ) ) {
140
- end( $token['nested_parenthesis'] );
141
  $opener = key( $token['nested_parenthesis'] );
142
- $closer = $stackPtr;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  } else {
144
  // No parenthesis found, can't determine where the conditional part of the ternary starts.
145
  return;
@@ -179,23 +193,25 @@ class AssignmentInConditionSniff extends Sniff {
179
  }
180
 
181
  // If this is a variable or array, we've seen all we need to see.
182
- if ( T_VARIABLE === $this->tokens[ $i ]['code']
183
- || T_CLOSE_SQUARE_BRACKET === $this->tokens[ $i ]['code']
184
  ) {
185
  $hasVariable = true;
186
  break;
187
  }
188
 
189
  // If this is a function call or something, we are OK.
190
- if ( T_CLOSE_PARENTHESIS === $this->tokens[ $i ]['code'] ) {
191
  break;
192
  }
193
  }
194
 
195
  if ( true === $hasVariable ) {
196
  $errorCode = 'Found';
197
- if ( T_WHILE === $token['code'] ) {
198
  $errorCode = 'FoundInWhileCondition';
 
 
199
  }
200
 
201
  $this->phpcsFile->addWarning(
@@ -214,7 +230,6 @@ class AssignmentInConditionSniff extends Sniff {
214
  $startPos = $hasAssignment;
215
 
216
  } while ( $startPos < $closer );
217
-
218
  }
219
 
220
  }
59
  */
60
  public function register() {
61
  $this->assignment_tokens = Tokens::$assignmentTokens;
62
+ unset( $this->assignment_tokens[ \T_DOUBLE_ARROW ] );
63
 
64
+ $starters = Tokens::$booleanOperators;
65
+ $starters[ \T_SEMICOLON ] = \T_SEMICOLON;
66
+ $starters[ \T_OPEN_PARENTHESIS ] = \T_OPEN_PARENTHESIS;
67
+ $starters[ \T_INLINE_ELSE ] = \T_INLINE_ELSE;
68
 
69
  $this->condition_start_tokens = $starters;
70
 
71
  return array(
72
+ \T_IF,
73
+ \T_ELSEIF,
74
+ \T_FOR,
75
+ \T_SWITCH,
76
+ \T_CASE,
77
+ \T_WHILE,
78
+ \T_INLINE_THEN,
79
  );
80
+ }
 
81
 
82
  /**
83
  * Processes this test, when one of its tokens is encountered.
93
  $token = $this->tokens[ $stackPtr ];
94
 
95
  // Find the condition opener/closer.
96
+ if ( \T_FOR === $token['code'] ) {
97
  if ( isset( $token['parenthesis_opener'], $token['parenthesis_closer'] ) === false ) {
98
  return;
99
  }
100
 
101
+ $semicolon = $this->phpcsFile->findNext( \T_SEMICOLON, ( $token['parenthesis_opener'] + 1 ), $token['parenthesis_closer'] );
102
  if ( false === $semicolon ) {
103
  return;
104
  }
105
 
106
  $opener = $semicolon;
107
+ $semicolon = $this->phpcsFile->findNext( \T_SEMICOLON, ( $opener + 1 ), $token['parenthesis_closer'] );
108
  if ( false === $semicolon ) {
109
  return;
110
  }
112
  $closer = $semicolon;
113
  unset( $semicolon );
114
 
115
+ } elseif ( \T_CASE === $token['code'] ) {
116
  if ( isset( $token['scope_opener'] ) === false ) {
117
  return;
118
  }
120
  $opener = $stackPtr;
121
  $closer = $token['scope_opener'];
122
 
123
+ } elseif ( \T_INLINE_THEN === $token['code'] ) {
124
  // Check if the condition for the ternary is bracketed.
125
  $prev = $this->phpcsFile->findPrevious( Tokens::$emptyTokens, ( $stackPtr - 1 ), null, true );
126
  if ( false === $prev ) {
128
  return;
129
  }
130
 
131
+ if ( \T_CLOSE_PARENTHESIS === $this->tokens[ $prev ]['code'] ) {
132
  if ( ! isset( $this->tokens[ $prev ]['parenthesis_opener'] ) ) {
133
  return;
134
  }
136
  $opener = $this->tokens[ $prev ]['parenthesis_opener'];
137
  $closer = $prev;
138
  } elseif ( isset( $token['nested_parenthesis'] ) ) {
139
+ $closer = end( $token['nested_parenthesis'] );
140
  $opener = key( $token['nested_parenthesis'] );
141
+
142
+ $next_statement_closer = $this->phpcsFile->findEndOfStatement( $stackPtr, array( \T_COLON, \T_CLOSE_PARENTHESIS, \T_CLOSE_SQUARE_BRACKET ) );
143
+ if ( false !== $next_statement_closer && $next_statement_closer < $closer ) {
144
+ // Parentheses are unrelated to the ternary.
145
+ return;
146
+ }
147
+
148
+ $prev_statement_closer = $this->phpcsFile->findStartOfStatement( $stackPtr, array( \T_COLON, \T_OPEN_PARENTHESIS, \T_OPEN_SQUARE_BRACKET ) );
149
+ if ( false !== $prev_statement_closer && $opener < $prev_statement_closer ) {
150
+ // Parentheses are unrelated to the ternary.
151
+ return;
152
+ }
153
+
154
+ if ( $closer > $stackPtr ) {
155
+ $closer = $stackPtr;
156
+ }
157
  } else {
158
  // No parenthesis found, can't determine where the conditional part of the ternary starts.
159
  return;
193
  }
194
 
195
  // If this is a variable or array, we've seen all we need to see.
196
+ if ( \T_VARIABLE === $this->tokens[ $i ]['code']
197
+ || \T_CLOSE_SQUARE_BRACKET === $this->tokens[ $i ]['code']
198
  ) {
199
  $hasVariable = true;
200
  break;
201
  }
202
 
203
  // If this is a function call or something, we are OK.
204
+ if ( \T_CLOSE_PARENTHESIS === $this->tokens[ $i ]['code'] ) {
205
  break;
206
  }
207
  }
208
 
209
  if ( true === $hasVariable ) {
210
  $errorCode = 'Found';
211
+ if ( \T_WHILE === $token['code'] ) {
212
  $errorCode = 'FoundInWhileCondition';
213
+ } elseif ( \T_INLINE_THEN === $token['code'] ) {
214
+ $errorCode = 'FoundInTernaryCondition';
215
  }
216
 
217
  $this->phpcsFile->addWarning(
230
  $startPos = $hasAssignment;
231
 
232
  } while ( $startPos < $closer );
 
233
  }
234
 
235
  }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/CodeAnalysis/EmptyStatementSniff.php CHANGED
@@ -38,8 +38,8 @@ class EmptyStatementSniff extends Sniff {
38
  */
39
  public function register() {
40
  return array(
41
- T_SEMICOLON,
42
- T_CLOSE_TAG,
43
  );
44
  }
45
 
@@ -65,12 +65,24 @@ class EmptyStatementSniff extends Sniff {
65
  );
66
 
67
  if ( false === $prevNonEmpty
68
- || ( T_SEMICOLON !== $this->tokens[ $prevNonEmpty ]['code']
69
- && T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ]['code'] )
 
70
  ) {
71
  return;
72
  }
73
 
 
 
 
 
 
 
 
 
 
 
 
74
  $fix = $this->phpcsFile->addFixableWarning(
75
  'Empty PHP statement detected: superfluous semi-colon.',
76
  $stackPtr,
@@ -79,22 +91,24 @@ class EmptyStatementSniff extends Sniff {
79
  if ( true === $fix ) {
80
  $this->phpcsFile->fixer->beginChangeset();
81
 
82
- if ( T_OPEN_TAG === $this->tokens[ $prevNonEmpty ]['code'] ) {
 
 
83
  /*
84
  * Check for superfluous whitespace after the semi-colon which will be
85
  * removed as the `<?php ` open tag token already contains whitespace,
86
  * either a space or a new line and in case of a new line, the indentation
87
  * should be done via tabs, so spaces can be safely removed.
88
  */
89
- if ( T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ]['code'] ) {
90
  $replacement = str_replace( ' ', '', $this->tokens[ ( $stackPtr + 1 ) ]['content'] );
91
  $this->phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), $replacement );
92
  }
93
  }
94
 
95
  for ( $i = $stackPtr; $i > $prevNonEmpty; $i-- ) {
96
- if ( T_SEMICOLON !== $this->tokens[ $i ]['code']
97
- && T_WHITESPACE !== $this->tokens[ $i ]['code']
98
  ) {
99
  break;
100
  }
@@ -110,13 +124,16 @@ class EmptyStatementSniff extends Sniff {
110
  */
111
  case 'T_CLOSE_TAG':
112
  $prevNonEmpty = $this->phpcsFile->findPrevious(
113
- T_WHITESPACE,
114
  ( $stackPtr - 1 ),
115
  null,
116
  true
117
  );
118
 
119
- if ( false === $prevNonEmpty || T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ]['code'] ) {
 
 
 
120
  return;
121
  }
122
 
@@ -138,7 +155,6 @@ class EmptyStatementSniff extends Sniff {
138
  /* Deliberately left empty. */
139
  break;
140
  }
 
141
 
142
- } // End process_token().
143
-
144
- } // End class.
38
  */
39
  public function register() {
40
  return array(
41
+ \T_SEMICOLON,
42
+ \T_CLOSE_TAG,
43
  );
44
  }
45
 
65
  );
66
 
67
  if ( false === $prevNonEmpty
68
+ || ( \T_SEMICOLON !== $this->tokens[ $prevNonEmpty ]['code']
69
+ && \T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ]['code']
70
+ && \T_OPEN_TAG_WITH_ECHO !== $this->tokens[ $prevNonEmpty ]['code'] )
71
  ) {
72
  return;
73
  }
74
 
75
+ if ( isset( $this->tokens[ $stackPtr ]['nested_parenthesis'] ) ) {
76
+ $nested = $this->tokens[ $stackPtr ]['nested_parenthesis'];
77
+ $last_closer = array_pop( $nested );
78
+ if ( isset( $this->tokens[ $last_closer ]['parenthesis_owner'] )
79
+ && \T_FOR === $this->tokens[ $this->tokens[ $last_closer ]['parenthesis_owner'] ]['code']
80
+ ) {
81
+ // Empty for() condition.
82
+ return;
83
+ }
84
+ }
85
+
86
  $fix = $this->phpcsFile->addFixableWarning(
87
  'Empty PHP statement detected: superfluous semi-colon.',
88
  $stackPtr,
91
  if ( true === $fix ) {
92
  $this->phpcsFile->fixer->beginChangeset();
93
 
94
+ if ( \T_OPEN_TAG === $this->tokens[ $prevNonEmpty ]['code']
95
+ || \T_OPEN_TAG_WITH_ECHO === $this->tokens[ $prevNonEmpty ]['code']
96
+ ) {
97
  /*
98
  * Check for superfluous whitespace after the semi-colon which will be
99
  * removed as the `<?php ` open tag token already contains whitespace,
100
  * either a space or a new line and in case of a new line, the indentation
101
  * should be done via tabs, so spaces can be safely removed.
102
  */
103
+ if ( \T_WHITESPACE === $this->tokens[ ( $stackPtr + 1 ) ]['code'] ) {
104
  $replacement = str_replace( ' ', '', $this->tokens[ ( $stackPtr + 1 ) ]['content'] );
105
  $this->phpcsFile->fixer->replaceToken( ( $stackPtr + 1 ), $replacement );
106
  }
107
  }
108
 
109
  for ( $i = $stackPtr; $i > $prevNonEmpty; $i-- ) {
110
+ if ( \T_SEMICOLON !== $this->tokens[ $i ]['code']
111
+ && \T_WHITESPACE !== $this->tokens[ $i ]['code']
112
  ) {
113
  break;
114
  }
124
  */
125
  case 'T_CLOSE_TAG':
126
  $prevNonEmpty = $this->phpcsFile->findPrevious(
127
+ \T_WHITESPACE,
128
  ( $stackPtr - 1 ),
129
  null,
130
  true
131
  );
132
 
133
+ if ( false === $prevNonEmpty
134
+ || ( \T_OPEN_TAG !== $this->tokens[ $prevNonEmpty ]['code']
135
+ && \T_OPEN_TAG_WITH_ECHO !== $this->tokens[ $prevNonEmpty ]['code'] )
136
+ ) {
137
  return;
138
  }
139
 
155
  /* Deliberately left empty. */
156
  break;
157
  }
158
+ }
159
 
160
+ }
 
 
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/DirectDatabaseQuerySniff.php ADDED
@@ -0,0 +1,264 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WordPress Coding Standard.
4
+ *
5
+ * @package WPCS\WordPressCodingStandards
6
+ * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
7
+ * @license https://opensource.org/licenses/MIT MIT
8
+ */
9
+
10
+ namespace WordPress\Sniffs\DB;
11
+
12
+ use WordPress\Sniff;
13
+ use PHP_CodeSniffer_Tokens as Tokens;
14
+
15
+ /**
16
+ * Flag Database direct queries.
17
+ *
18
+ * @link https://vip.wordpress.com/documentation/vip-go/code-review-blockers-warnings-notices/#direct-database-queries
19
+ *
20
+ * @package WPCS\WordPressCodingStandards
21
+ *
22
+ * @since 0.3.0
23
+ * @since 0.6.0 Removed the add_unique_message() function as it is no longer needed.
24
+ * @since 0.11.0 This class now extends WordPress_Sniff.
25
+ * @since 0.13.0 Class name changed: this class is now namespaced.
26
+ * @since 1.0.0 This sniff has been moved from the `VIP` category to the `DB` category.
27
+ */
28
+ class DirectDatabaseQuerySniff extends Sniff {
29
+
30
+ /**
31
+ * List of custom cache get functions.
32
+ *
33
+ * @since 0.6.0
34
+ *
35
+ * @var string|string[]
36
+ */
37
+ public $customCacheGetFunctions = array();
38
+
39
+ /**
40
+ * List of custom cache set functions.
41
+ *
42
+ * @since 0.6.0
43
+ *
44
+ * @var string|string[]
45
+ */
46
+ public $customCacheSetFunctions = array();
47
+
48
+ /**
49
+ * List of custom cache delete functions.
50
+ *
51
+ * @since 0.6.0
52
+ *
53
+ * @var string|string[]
54
+ */
55
+ public $customCacheDeleteFunctions = array();
56
+
57
+ /**
58
+ * Cache of previously added custom functions.
59
+ *
60
+ * Prevents having to do the same merges over and over again.
61
+ *
62
+ * @since 0.11.0
63
+ *
64
+ * @var array
65
+ */
66
+ protected $addedCustomFunctions = array(
67
+ 'cacheget' => array(),
68
+ 'cacheset' => array(),
69
+ 'cachedelete' => array(),
70
+ );
71
+
72
+ /**
73
+ * The lists of $wpdb methods.
74
+ *
75
+ * @since 0.6.0
76
+ * @since 0.11.0 Changed from static to non-static.
77
+ *
78
+ * @var array[]
79
+ */
80
+ protected $methods = array(
81
+ 'cachable' => array(
82
+ 'delete' => true,
83
+ 'get_var' => true,
84
+ 'get_col' => true,
85
+ 'get_row' => true,
86
+ 'get_results' => true,
87
+ 'query' => true,
88
+ 'replace' => true,
89
+ 'update' => true,
90
+ ),
91
+ 'noncachable' => array(
92
+ 'insert' => true,
93
+ ),
94
+ );
95
+
96
+ /**
97
+ * Returns an array of tokens this test wants to listen for.
98
+ *
99
+ * @return array
100
+ */
101
+ public function register() {
102
+ return array(
103
+ \T_VARIABLE,
104
+ );
105
+ }
106
+
107
+ /**
108
+ * Processes this test, when one of its tokens is encountered.
109
+ *
110
+ * @param int $stackPtr The position of the current token in the stack.
111
+ *
112
+ * @return void
113
+ */
114
+ public function process_token( $stackPtr ) {
115
+
116
+ // Check for $wpdb variable.
117
+ if ( '$wpdb' !== $this->tokens[ $stackPtr ]['content'] ) {
118
+ return;
119
+ }
120
+
121
+ $is_object_call = $this->phpcsFile->findNext( \T_OBJECT_OPERATOR, ( $stackPtr + 1 ), null, false, null, true );
122
+ if ( false === $is_object_call ) {
123
+ return; // This is not a call to the wpdb object.
124
+ }
125
+
126
+ $methodPtr = $this->phpcsFile->findNext( array( \T_WHITESPACE ), ( $is_object_call + 1 ), null, true, null, true );
127
+ $method = $this->tokens[ $methodPtr ]['content'];
128
+
129
+ $this->mergeFunctionLists();
130
+
131
+ if ( ! isset( $this->methods['all'][ $method ] ) ) {
132
+ return;
133
+ }
134
+
135
+ $endOfStatement = $this->phpcsFile->findNext( \T_SEMICOLON, ( $stackPtr + 1 ), null, false, null, true );
136
+ $endOfLineComment = '';
137
+ for ( $i = ( $endOfStatement + 1 ); $i < $this->phpcsFile->numTokens; $i++ ) {
138
+
139
+ if ( $this->tokens[ $i ]['line'] !== $this->tokens[ $endOfStatement ]['line'] ) {
140
+ break;
141
+ }
142
+
143
+ if ( \T_COMMENT === $this->tokens[ $i ]['code'] ) {
144
+ $endOfLineComment .= $this->tokens[ $i ]['content'];
145
+ }
146
+ }
147
+
148
+ $whitelisted_db_call = false;
149
+ if ( preg_match( '/db call\W*(?:ok|pass|clear|whitelist)/i', $endOfLineComment ) ) {
150
+ $whitelisted_db_call = true;
151
+ }
152
+
153
+ // Check for Database Schema Changes.
154
+ for ( $_pos = ( $stackPtr + 1 ); $_pos < $endOfStatement; $_pos++ ) {
155
+ $_pos = $this->phpcsFile->findNext( Tokens::$textStringTokens, $_pos, $endOfStatement, false, null, true );
156
+ if ( false === $_pos ) {
157
+ break;
158
+ }
159
+
160
+ if ( preg_match( '#\b(?:ALTER|CREATE|DROP)\b#i', $this->tokens[ $_pos ]['content'] ) > 0 ) {
161
+ $this->phpcsFile->addWarning( 'Attempting a database schema change is discouraged.', $_pos, 'SchemaChange' );
162
+ }
163
+ }
164
+
165
+ // Flag instance if not whitelisted.
166
+ if ( ! $whitelisted_db_call ) {
167
+ $this->phpcsFile->addWarning( 'Usage of a direct database call is discouraged.', $stackPtr, 'DirectQuery' );
168
+ }
169
+
170
+ if ( ! isset( $this->methods['cachable'][ $method ] ) ) {
171
+ return $endOfStatement;
172
+ }
173
+
174
+ $whitelisted_cache = false;
175
+ $cached = false;
176
+ $wp_cache_get = false;
177
+ if ( preg_match( '/cache\s+(?:ok|pass|clear|whitelist)/i', $endOfLineComment ) ) {
178
+ $whitelisted_cache = true;
179
+ }
180
+ if ( ! $whitelisted_cache && ! empty( $this->tokens[ $stackPtr ]['conditions'] ) ) {
181
+ $scope_function = $this->phpcsFile->getCondition( $stackPtr, \T_FUNCTION );
182
+
183
+ if ( false === $scope_function ) {
184
+ $scope_function = $this->phpcsFile->getCondition( $stackPtr, \T_CLOSURE );
185
+ }
186
+
187
+ if ( false !== $scope_function ) {
188
+ $scopeStart = $this->tokens[ $scope_function ]['scope_opener'];
189
+ $scopeEnd = $this->tokens[ $scope_function ]['scope_closer'];
190
+
191
+ for ( $i = ( $scopeStart + 1 ); $i < $scopeEnd; $i++ ) {
192
+ if ( \T_STRING === $this->tokens[ $i ]['code'] ) {
193
+
194
+ if ( isset( $this->cacheDeleteFunctions[ $this->tokens[ $i ]['content'] ] ) ) {
195
+
196
+ if ( \in_array( $method, array( 'query', 'update', 'replace', 'delete' ), true ) ) {
197
+ $cached = true;
198
+ break;
199
+ }
200
+ } elseif ( isset( $this->cacheGetFunctions[ $this->tokens[ $i ]['content'] ] ) ) {
201
+
202
+ $wp_cache_get = true;
203
+
204
+ } elseif ( isset( $this->cacheSetFunctions[ $this->tokens[ $i ]['content'] ] ) ) {
205
+
206
+ if ( $wp_cache_get ) {
207
+ $cached = true;
208
+ break;
209
+ }
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+
216
+ if ( ! $cached && ! $whitelisted_cache ) {
217
+ $message = 'Direct database call without caching detected. Consider using wp_cache_get() / wp_cache_set() or wp_cache_delete().';
218
+ $this->phpcsFile->addWarning( $message, $stackPtr, 'NoCaching' );
219
+ }
220
+
221
+ return $endOfStatement;
222
+ }
223
+
224
+ /**
225
+ * Merge custom functions provided via a custom ruleset with the defaults, if we haven't already.
226
+ *
227
+ * @since 0.11.0 Split out from the `process()` method.
228
+ *
229
+ * @return void
230
+ */
231
+ protected function mergeFunctionLists() {
232
+ if ( ! isset( $this->methods['all'] ) ) {
233
+ $this->methods['all'] = array_merge( $this->methods['cachable'], $this->methods['noncachable'] );
234
+ }
235
+
236
+ if ( $this->customCacheGetFunctions !== $this->addedCustomFunctions['cacheget'] ) {
237
+ $this->cacheGetFunctions = $this->merge_custom_array(
238
+ $this->customCacheGetFunctions,
239
+ $this->cacheGetFunctions
240
+ );
241
+
242
+ $this->addedCustomFunctions['cacheget'] = $this->customCacheGetFunctions;
243
+ }
244
+
245
+ if ( $this->customCacheSetFunctions !== $this->addedCustomFunctions['cacheset'] ) {
246
+ $this->cacheSetFunctions = $this->merge_custom_array(
247
+ $this->customCacheSetFunctions,
248
+ $this->cacheSetFunctions
249
+ );
250
+
251
+ $this->addedCustomFunctions['cacheset'] = $this->customCacheSetFunctions;
252
+ }
253
+
254
+ if ( $this->customCacheDeleteFunctions !== $this->addedCustomFunctions['cachedelete'] ) {
255
+ $this->cacheDeleteFunctions = $this->merge_custom_array(
256
+ $this->customCacheDeleteFunctions,
257
+ $this->cacheDeleteFunctions
258
+ );
259
+
260
+ $this->addedCustomFunctions['cachedelete'] = $this->customCacheDeleteFunctions;
261
+ }
262
+ }
263
+
264
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/PreparedSQLPlaceholdersSniff.php CHANGED
@@ -154,8 +154,8 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
154
  */
155
  public function register() {
156
  return array(
157
- T_VARIABLE,
158
- T_STRING,
159
  );
160
  }
161
 
@@ -184,7 +184,7 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
184
  $variable_found = false;
185
  $sql_wildcard_found = false;
186
  $total_placeholders = 0;
187
- $total_parameters = count( $parameters );
188
  $valid_in_clauses = array(
189
  'uses_in' => 0,
190
  'implode_fill' => 0,
@@ -199,7 +199,7 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
199
  }
200
 
201
  if ( ! isset( Tokens::$textStringTokens[ $this->tokens[ $i ]['code'] ] ) ) {
202
- if ( T_VARIABLE === $this->tokens[ $i ]['code'] ) {
203
  if ( '$wpdb' !== $this->tokens[ $i ]['content'] ) {
204
  $variable_found = true;
205
  }
@@ -207,7 +207,7 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
207
  }
208
 
209
  // Detect a specific pattern for variable replacements in combination with `IN`.
210
- if ( T_STRING === $this->tokens[ $i ]['code'] ) {
211
 
212
  if ( 'sprintf' === strtolower( $this->tokens[ $i ]['content'] ) ) {
213
  $sprintf_parameters = $this->get_function_call_parameters( $i );
@@ -218,7 +218,7 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
218
  $skip_to = ( $last_param['end'] + 1 );
219
 
220
  $valid_in_clauses['implode_fill'] += $this->analyse_sprintf( $sprintf_parameters );
221
- $valid_in_clauses['adjustment_count'] += ( count( $sprintf_parameters ) - 1 );
222
  }
223
  unset( $sprintf_parameters, $last_param );
224
 
@@ -248,7 +248,7 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
248
  ++$valid_in_clauses['implode_fill'];
249
 
250
  $next = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
251
- if ( T_OPEN_PARENTHESIS === $this->tokens[ $next ]['code']
252
  && isset( $this->tokens[ $next ]['parenthesis_closer'] )
253
  ) {
254
  $skip_from = ( $i + 1 );
@@ -272,8 +272,8 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
272
  $regex_quote = $this->get_regex_quote_snippet( $content, $this->tokens[ $i ]['content'] );
273
  }
274
 
275
- if ( T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code']
276
- || T_HEREDOC === $this->tokens[ $i ]['code']
277
  ) {
278
  // Only interested in actual query text, so strip out variables.
279
  $stripped_content = $this->strip_interpolated_variables( $content );
@@ -355,7 +355,7 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
355
  * Don't throw `UnescapedLiteral`, `UnsupportedPlaceholder` or `QuotedPlaceholder`
356
  * for this part of the SQL query.
357
  */
358
- $content = preg_replace( '`' . preg_quote( $match ) . '`', '', $content, 1 );
359
  }
360
  }
361
  }
@@ -503,14 +503,14 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
503
  );
504
 
505
  if ( false !== $next
506
- && ( T_ARRAY === $this->tokens[ $next ]['code']
507
- || T_OPEN_SHORT_ARRAY === $this->tokens[ $next ]['code'] )
508
  ) {
509
  $replacements = $this->get_function_call_parameters( $next );
510
  }
511
  }
512
 
513
- $total_replacements = count( $replacements );
514
  $total_placeholders -= $valid_in_clauses['adjustment_count'];
515
 
516
  // Bow out when `IN` clauses have been used which appear to be correct.
@@ -594,7 +594,7 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
594
  $sprintf_param['end'],
595
  true
596
  );
597
- if ( T_STRING === $this->tokens[ $implode ]['code']
598
  && 'implode' === strtolower( $this->tokens[ $implode ]['content'] )
599
  ) {
600
  if ( $this->analyse_implode( $implode ) === true ) {
@@ -624,7 +624,7 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
624
  protected function analyse_implode( $implode_token ) {
625
  $implode_params = $this->get_function_call_parameters( $implode_token );
626
 
627
- if ( empty( $implode_params ) || count( $implode_params ) !== 2 ) {
628
  return false;
629
  }
630
 
@@ -643,7 +643,7 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
643
  true
644
  );
645
 
646
- if ( T_STRING !== $this->tokens[ $array_fill ]['code']
647
  || 'array_fill' !== strtolower( $this->tokens[ $array_fill ]['content'] )
648
  ) {
649
  return false;
@@ -651,7 +651,7 @@ class PreparedSQLPlaceholdersSniff extends Sniff {
651
 
652
  $array_fill_params = $this->get_function_call_parameters( $array_fill );
653
 
654
- if ( empty( $array_fill_params ) || count( $array_fill_params ) !== 3 ) {
655
  return false;
656
  }
657
 
154
  */
155
  public function register() {
156
  return array(
157
+ \T_VARIABLE,
158
+ \T_STRING,
159
  );
160
  }
161
 
184
  $variable_found = false;
185
  $sql_wildcard_found = false;
186
  $total_placeholders = 0;
187
+ $total_parameters = \count( $parameters );
188
  $valid_in_clauses = array(
189
  'uses_in' => 0,
190
  'implode_fill' => 0,
199
  }
200
 
201
  if ( ! isset( Tokens::$textStringTokens[ $this->tokens[ $i ]['code'] ] ) ) {
202
+ if ( \T_VARIABLE === $this->tokens[ $i ]['code'] ) {
203
  if ( '$wpdb' !== $this->tokens[ $i ]['content'] ) {
204
  $variable_found = true;
205
  }
207
  }
208
 
209
  // Detect a specific pattern for variable replacements in combination with `IN`.
210
+ if ( \T_STRING === $this->tokens[ $i ]['code'] ) {
211
 
212
  if ( 'sprintf' === strtolower( $this->tokens[ $i ]['content'] ) ) {
213
  $sprintf_parameters = $this->get_function_call_parameters( $i );
218
  $skip_to = ( $last_param['end'] + 1 );
219
 
220
  $valid_in_clauses['implode_fill'] += $this->analyse_sprintf( $sprintf_parameters );
221
+ $valid_in_clauses['adjustment_count'] += ( \count( $sprintf_parameters ) - 1 );
222
  }
223
  unset( $sprintf_parameters, $last_param );
224
 
248
  ++$valid_in_clauses['implode_fill'];
249
 
250
  $next = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $i + 1 ), null, true );
251
+ if ( \T_OPEN_PARENTHESIS === $this->tokens[ $next ]['code']
252
  && isset( $this->tokens[ $next ]['parenthesis_closer'] )
253
  ) {
254
  $skip_from = ( $i + 1 );
272
  $regex_quote = $this->get_regex_quote_snippet( $content, $this->tokens[ $i ]['content'] );
273
  }
274
 
275
+ if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $i ]['code']
276
+ || \T_HEREDOC === $this->tokens[ $i ]['code']
277
  ) {
278
  // Only interested in actual query text, so strip out variables.
279
  $stripped_content = $this->strip_interpolated_variables( $content );
355
  * Don't throw `UnescapedLiteral`, `UnsupportedPlaceholder` or `QuotedPlaceholder`
356
  * for this part of the SQL query.
357
  */
358
+ $content = preg_replace( '`' . preg_quote( $match, '`' ) . '`', '', $content, 1 );
359
  }
360
  }
361
  }
503
  );
504
 
505
  if ( false !== $next
506
+ && ( \T_ARRAY === $this->tokens[ $next ]['code']
507
+ || \T_OPEN_SHORT_ARRAY === $this->tokens[ $next ]['code'] )
508
  ) {
509
  $replacements = $this->get_function_call_parameters( $next );
510
  }
511
  }
512
 
513
+ $total_replacements = \count( $replacements );
514
  $total_placeholders -= $valid_in_clauses['adjustment_count'];
515
 
516
  // Bow out when `IN` clauses have been used which appear to be correct.
594
  $sprintf_param['end'],
595
  true
596
  );
597
+ if ( \T_STRING === $this->tokens[ $implode ]['code']
598
  && 'implode' === strtolower( $this->tokens[ $implode ]['content'] )
599
  ) {
600
  if ( $this->analyse_implode( $implode ) === true ) {
624
  protected function analyse_implode( $implode_token ) {
625
  $implode_params = $this->get_function_call_parameters( $implode_token );
626
 
627
+ if ( empty( $implode_params ) || \count( $implode_params ) !== 2 ) {
628
  return false;
629
  }
630
 
643
  true
644
  );
645
 
646
+ if ( \T_STRING !== $this->tokens[ $array_fill ]['code']
647
  || 'array_fill' !== strtolower( $this->tokens[ $array_fill ]['content'] )
648
  ) {
649
  return false;
651
 
652
  $array_fill_params = $this->get_function_call_parameters( $array_fill );
653
 
654
+ if ( empty( $array_fill_params ) || \count( $array_fill_params ) !== 3 ) {
655
  return false;
656
  }
657
 
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/PreparedSQLSniff.php ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WordPress Coding Standard.
4
+ *
5
+ * @package WPCS\WordPressCodingStandards
6
+ * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
7
+ * @license https://opensource.org/licenses/MIT MIT
8
+ */
9
+
10
+ namespace WordPress\Sniffs\DB;
11
+
12
+ use WordPress\Sniff;
13
+ use PHP_CodeSniffer_Tokens as Tokens;
14
+
15
+ /**
16
+ * Sniff for prepared SQL.
17
+ *
18
+ * Makes sure that variables aren't directly interpolated into SQL statements.
19
+ *
20
+ * @link https://make.wordpress.org/core/handbook/best-practices/coding-standards/php/#formatting-sql-statements
21
+ *
22
+ * @package WPCS\WordPressCodingStandards
23
+ *
24
+ * @since 0.8.0
25
+ * @since 0.13.0 Class name changed: this class is now namespaced.
26
+ * @since 1.0.0 This sniff has been moved from the `WP` category to the `DB` category.
27
+ */
28
+ class PreparedSQLSniff extends Sniff {
29
+
30
+ /**
31
+ * The lists of $wpdb methods.
32
+ *
33
+ * @since 0.8.0
34
+ * @since 0.11.0 Changed from static to non-static.
35
+ *
36
+ * @var array
37
+ */
38
+ protected $methods = array(
39
+ 'get_var' => true,
40
+ 'get_col' => true,
41
+ 'get_row' => true,
42
+ 'get_results' => true,
43
+ 'prepare' => true,
44
+ 'query' => true,
45
+ );
46
+
47
+ /**
48
+ * Tokens that we don't flag when they are found in a $wpdb method call.
49
+ *
50
+ * @since 0.9.0
51
+ *
52
+ * @var array
53
+ */
54
+ protected $ignored_tokens = array(
55
+ \T_OBJECT_OPERATOR => true,
56
+ \T_OPEN_PARENTHESIS => true,
57
+ \T_CLOSE_PARENTHESIS => true,
58
+ \T_STRING_CONCAT => true,
59
+ \T_CONSTANT_ENCAPSED_STRING => true,
60
+ \T_OPEN_SQUARE_BRACKET => true,
61
+ \T_CLOSE_SQUARE_BRACKET => true,
62
+ \T_COMMA => true,
63
+ \T_LNUMBER => true,
64
+ \T_START_HEREDOC => true,
65
+ \T_END_HEREDOC => true,
66
+ \T_START_NOWDOC => true,
67
+ \T_NOWDOC => true,
68
+ \T_END_NOWDOC => true,
69
+ \T_INT_CAST => true,
70
+ \T_DOUBLE_CAST => true,
71
+ \T_BOOL_CAST => true,
72
+ );
73
+
74
+ /**
75
+ * A loop pointer.
76
+ *
77
+ * It is a property so that we can access it in all of our methods.
78
+ *
79
+ * @since 0.9.0
80
+ *
81
+ * @var int
82
+ */
83
+ protected $i;
84
+
85
+ /**
86
+ * The loop end marker.
87
+ *
88
+ * It is a property so that we can access it in all of our methods.
89
+ *
90
+ * @since 0.9.0
91
+ *
92
+ * @var int
93
+ */
94
+ protected $end;
95
+
96
+ /**
97
+ * Returns an array of tokens this test wants to listen for.
98
+ *
99
+ * @since 0.8.0
100
+ *
101
+ * @return array
102
+ */
103
+ public function register() {
104
+
105
+ $this->ignored_tokens = $this->ignored_tokens + Tokens::$emptyTokens;
106
+
107
+ return array(
108
+ \T_VARIABLE,
109
+ \T_STRING,
110
+ );
111
+ }
112
+
113
+ /**
114
+ * Processes this test, when one of its tokens is encountered.
115
+ *
116
+ * @since 0.8.0
117
+ *
118
+ * @param int $stackPtr The position of the current token in the stack.
119
+ *
120
+ * @return int|void Integer stack pointer to skip forward or void to continue
121
+ * normal file processing.
122
+ */
123
+ public function process_token( $stackPtr ) {
124
+
125
+ if ( ! $this->is_wpdb_method_call( $stackPtr, $this->methods ) ) {
126
+ return;
127
+ }
128
+
129
+ if ( $this->has_whitelist_comment( 'unprepared SQL', $stackPtr ) ) {
130
+ return;
131
+ }
132
+
133
+ for ( $this->i; $this->i < $this->end; $this->i++ ) {
134
+
135
+ if ( isset( $this->ignored_tokens[ $this->tokens[ $this->i ]['code'] ] ) ) {
136
+ continue;
137
+ }
138
+
139
+ if ( \T_DOUBLE_QUOTED_STRING === $this->tokens[ $this->i ]['code']
140
+ || \T_HEREDOC === $this->tokens[ $this->i ]['code']
141
+ ) {
142
+
143
+ $bad_variables = array_filter(
144
+ $this->get_interpolated_variables( $this->tokens[ $this->i ]['content'] ),
145
+ function ( $symbol ) {
146
+ return ( 'wpdb' !== $symbol );
147
+ }
148
+ );
149
+
150
+ foreach ( $bad_variables as $bad_variable ) {
151
+ $this->phpcsFile->addError(
152
+ 'Use placeholders and $wpdb->prepare(); found interpolated variable $%s at %s',
153
+ $this->i,
154
+ 'NotPrepared',
155
+ array(
156
+ $bad_variable,
157
+ $this->tokens[ $this->i ]['content'],
158
+ )
159
+ );
160
+ }
161
+ continue;
162
+ }
163
+
164
+ if ( \T_VARIABLE === $this->tokens[ $this->i ]['code'] ) {
165
+ if ( '$wpdb' === $this->tokens[ $this->i ]['content'] ) {
166
+ $this->is_wpdb_method_call( $this->i, $this->methods );
167
+ continue;
168
+ }
169
+
170
+ if ( $this->is_safe_casted( $this->i ) ) {
171
+ continue;
172
+ }
173
+ }
174
+
175
+ if ( \T_STRING === $this->tokens[ $this->i ]['code'] ) {
176
+
177
+ if (
178
+ isset( $this->SQLEscapingFunctions[ $this->tokens[ $this->i ]['content'] ] )
179
+ || isset( $this->SQLAutoEscapedFunctions[ $this->tokens[ $this->i ]['content'] ] )
180
+ ) {
181
+
182
+ // Find the opening parenthesis.
183
+ $opening_paren = $this->phpcsFile->findNext( Tokens::$emptyTokens, ( $this->i + 1 ), null, true, null, true );
184
+
185
+ if ( false !== $opening_paren
186
+ && \T_OPEN_PARENTHESIS === $this->tokens[ $opening_paren ]['code']
187
+ && isset( $this->tokens[ $opening_paren ]['parenthesis_closer'] )
188
+ ) {
189
+ // Skip past the end of the function.
190
+ $this->i = $this->tokens[ $opening_paren ]['parenthesis_closer'];
191
+ continue;
192
+ }
193
+ } elseif ( isset( $this->formattingFunctions[ $this->tokens[ $this->i ]['content'] ] ) ) {
194
+ continue;
195
+ }
196
+ }
197
+
198
+ $this->phpcsFile->addError(
199
+ 'Use placeholders and $wpdb->prepare(); found %s',
200
+ $this->i,
201
+ 'NotPrepared',
202
+ array( $this->tokens[ $this->i ]['content'] )
203
+ );
204
+ }
205
+
206
+ return $this->end;
207
+ }
208
+
209
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedClassesSniff.php CHANGED
@@ -57,4 +57,4 @@ class RestrictedClassesSniff extends AbstractClassRestrictionsSniff {
57
  );
58
  }
59
 
60
- } // End class.
57
  );
58
  }
59
 
60
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/RestrictedFunctionsSniff.php CHANGED
@@ -60,8 +60,7 @@ class RestrictedFunctionsSniff extends AbstractFunctionRestrictionsSniff {
60
  'mysql_to_rfc3339' => true,
61
  ),
62
  ),
63
-
64
  );
65
  }
66
 
67
- } // End class.
60
  'mysql_to_rfc3339' => true,
61
  ),
62
  ),
 
63
  );
64
  }
65
 
66
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/DB/SlowDBQuerySniff.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WordPress Coding Standard.
4
+ *
5
+ * @package WPCS\WordPressCodingStandards
6
+ * @link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards
7
+ * @license https://opensource.org/licenses/MIT MIT
8
+ */
9
+
10
+ namespace WordPress\Sniffs\DB;
11
+
12
+ use WordPress\AbstractArrayAssignmentRestrictionsSniff;
13
+
14
+ /**
15
+ * Flag potentially slow queries.
16
+ *
17
+ * @link https://vip.wordpress.com/documentation/vip-go/code-review-blockers-warnings-notices/#uncached-pageload
18
+ *
19
+ * @package WPCS\WordPressCodingStandards
20
+ *
21
+ * @since 0.3.0
22
+ * @since 0.12.0 Introduced new and more intuitively named 'slow query' whitelist
23
+ * comment, replacing the 'tax_query' whitelist comment which is now
24
+ * deprecated.
25
+ * @since 0.13.0 Class name changed: this class is now namespaced.
26
+ * @since 1.0.0 This sniff has been moved from the `VIP` category to the `DB` category.
27
+ */
28
+ class SlowDBQuerySniff extends AbstractArrayAssignmentRestrictionsSniff {
29
+
30
+ /**
31
+ * Groups of variables to restrict.
32
+ *
33
+ * @return array
34
+ */
35
+ public function getGroups() {
36
+ return array(
37
+ 'slow_db_query' => array(
38
+ 'type' => 'warning',
39
+ 'message' => 'Detected usage of %s, possible slow query.',
40
+ 'keys' => array(
41
+ 'tax_query',
42
+ 'meta_query',
43
+ 'meta_key',
44
+ 'meta_value',
45
+ ),
46
+ ),
47
+ );
48
+ }
49
+
50
+ /**
51
+ * Processes this test, when one of its tokens is encountered.
52
+ *
53
+ * @since 0.10.0
54
+ *
55
+ * @param int $stackPtr The position of the current token in the stack.
56
+ *
57
+ * @return int|void Integer stack pointer to skip forward or void to continue
58
+ * normal file processing.
59
+ */
60
+ public function process_token( $stackPtr ) {
61
+
62
+ if ( $this->has_whitelist_comment( 'slow query', $stackPtr ) ) {
63
+ return;
64
+ }
65
+
66
+ if ( $this->has_whitelist_comment( 'tax_query', $stackPtr ) ) {
67
+ /*
68
+ * Only throw the warning about a deprecated comment when the sniff would otherwise
69
+ * have been triggered on the array key.
70
+ */
71
+ if ( \in_array( $this->tokens[ $stackPtr ]['code'], array( \T_CONSTANT_ENCAPSED_STRING, \T_DOUBLE_QUOTED_STRING ), true ) ) {
72
+ $this->phpcsFile->addWarning(
73
+ 'The "tax_query" whitelist comment is deprecated in favor of the "slow query" whitelist comment.',
74
+ $stackPtr,
75
+ 'DeprecatedWhitelistFlagFound'
76
+ );
77
+ }
78
+
79
+ return;
80
+ }
81
+
82
+ return parent::process_token( $stackPtr );
83
+ }
84
+
85
+ /**
86
+ * Callback to process each confirmed key, to check value.
87
+ * This must be extended to add the logic to check assignment value.
88
+ *
89
+ * @param string $key Array index / key.
90
+ * @param mixed $val Assigned value.
91
+ * @param int $line Token line.
92
+ * @param array $group Group definition.
93
+ * @return mixed FALSE if no match, TRUE if matches, STRING if matches
94
+ * with custom error message passed to ->process().
95
+ */
96
+ public function callback( $key, $val, $line, $group ) {
97
+ return true;
98
+ }
99
+
100
+ }
vendor/wp-coding-standards/wpcs/WordPress/Sniffs/Files/FileNameSniff.php CHANGED
@@ -118,11 +118,14 @@ class FileNameSniff extends Sniff {
118
  * @return array
119
  */
120
  public function register() {
121
- if ( defined( '\PHP_CODESNIFFER_IN_TESTS' ) ) {
122
  $this->class_exceptions = array_merge( $this->class_exceptions, $this->unittest_class_exceptions );
123
  }
124
 
125
- return array( T_OPEN_TAG );
 
 
 
126
  }
127
 
128
  /**
@@ -141,6 +144,31 @@ class FileNameSniff extends Sniff {
141
  return;
142
  }
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  $fileName = basename( $file );
145
  $expected = strtolower( str_replace( '_', '-', $fileName ) );
146
 
@@ -162,7 +190,7 @@ class FileNameSniff extends Sniff {
162
  * the file name reflects the class name.
163
  */
164
  if ( true === $this->strict_class_file_names ) {
165
- $has_class = $this->phpcsFile->findNext( T_CLASS, $stackPtr );
166
  if ( false !== $has_class && false === $this->
118
  * @return array
119
  */
120
  public function register() {
121
+ if ( \defined( '\PHP_CODESNIFFER_IN_TESTS' ) ) {
122
  $this->class_exceptions = array_merge( $this->class_exceptions, $this->unittest_class_exceptions );
123
  }
124
 
125
+ return array(
126
+ \T_OPEN_TAG,
127
+ \T_OPEN_TAG_WITH_ECHO,
128
+ );
129
  }
130
 
131
  /**
144
  return;
145
  }
146
 
147
+ // Respect phpcs:disable comments as long as they are not accompanied by an enable (PHPCS 3.2+).
148
+ if ( \defined( '\T_PHPCS_DISABLE' ) && \defined( '\T_PHPCS_ENABLE' ) ) {
149
+ $i = -1;
150
+ while ( $i = $this->phpcsFile->findNext( \T_PHPCS_DISABLE, ( $i + 1 ) ) ) {
151
+ if ( empty( $this->tokens[ $i ]['sniffCodes'] )
152
+ || isset( $this->tokens[ $i ]['sniffCodes']['WordPress'] )
153
+ || isset( $this->tokens[ $i ]['sniffCodes']['WordPress.Files'] )
154
+ || isset( $this->tokens[ $i ]['sniffCodes']['WordPress.Files.FileName'] )
155
+ ) {
156
+ do {
157
+ $i = $this->phpcsFile->findNext( \T_PHPCS_ENABLE, ( $i + 1 ) );
158
+ } while ( false !== $i
159
+ && ! empty( $this->tokens[ $i ]['sniffCodes'] )
160
+ && ! isset( $this->tokens[ $i ]['sniffCodes']['WordPress'] )
161
+ && ! isset( $this->tokens[ $i ]['sniffCodes']['WordPress.Files'] )
162
+ && ! isset( $this->tokens[ $i ]['sniffCodes']['WordPress.Files.FileName'] ) );
163
+
164
+ if ( false === $i ) {
165
+ // The entire (rest of the) file is disabled.
166
+ return;
167
+ }
168
+ }
169
+ }
170
+ }
171
+
172
  $fileName = basename( $file );
173
  $expected = strtolower( str_replace( '_', '-', $fileName ) );
174
 
190
  * the file name reflects the class name.
191
  */
192
  if ( true === $this->strict_class_file_names ) {
193
+ $has_class = $this->phpcsFile->findNext( \T_CLASS, $stackPtr );
194
  if ( false !== $has_class && false === $this->