PHP Compatibility Checker - Version 1.4.1

Version Description

  • Updated PHP_CodeSniffer to fix a security advisory.
  • Whitelisted a number of plugins.
Download this release

Release Info

Developer wpengine
Plugin Icon 128x128 PHP Compatibility Checker
Version 1.4.1
Comparing to
See all releases

Code changes from version 1.4.0 to 1.4.1

Files changed (195) hide show
  1. readme.txt +8 -8
  2. src/wpephpcompat.php +3 -0
  3. vendor/autoload.php +2 -2
  4. vendor/composer/ClassLoader.php +38 -10
  5. vendor/composer/LICENSE +1 -1
  6. vendor/composer/autoload_classmap.php +3 -0
  7. vendor/composer/autoload_namespaces.php +1 -0
  8. vendor/composer/autoload_real.php +24 -17
  9. vendor/composer/installed.json +175 -84
  10. vendor/squizlabs/php_codesniffer/CONTRIBUTING.md +1 -1
  11. vendor/squizlabs/php_codesniffer/CodeSniffer.php +37 -16
  12. vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php +62 -8
  13. vendor/squizlabs/php_codesniffer/CodeSniffer/File.php +124 -30
  14. vendor/squizlabs/php_codesniffer/CodeSniffer/Fixer.php +10 -3
  15. vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Gitblame.php +1 -27
  16. vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Hgblame.php +0 -8
  17. vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Notifysend.php +2 -2
  18. vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Svnblame.php +0 -8
  19. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractScopeSniff.php +2 -2
  20. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractVariableSniff.php +2 -1
  21. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php +1 -1
  22. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php +4 -1
  23. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php +0 -6
  24. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +76 -15
  25. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/CSSLintSniff.php +1 -1
  26. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php +3 -2
  27. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php +4 -1
  28. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php +5 -5
  29. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php +1 -1
  30. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php +1 -1
  31. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php +7 -1
  32. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php +5 -2
  33. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +1 -1
  34. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php +8 -2
  35. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +26 -9
  36. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php +1 -1
  37. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php +2 -2
  38. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php +3 -3
  39. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php +1 -1
  40. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +7 -0
  41. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php +13 -2
  42. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php +5 -2
  43. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/SyntaxSniff.php +24 -11
  44. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +49 -12
  45. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php +2 -6
  46. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php +76 -27
  47. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php +23 -18
  48. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php +47 -6
  49. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php +9 -0
  50. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php +22 -34
  51. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php +1 -0
  52. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php +3 -3
  53. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php +1 -1
  54. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniff.php +156 -41
  55. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php +7 -3
  56. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php +27 -55
  57. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php +65 -36
  58. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php +10 -6
  59. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/EmptyNonVariableSniff.php +5 -2
  60. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueOutsideLoopSniff.php +9 -12
  61. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php +20 -12
  62. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php +1 -5
  63. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php +5 -2
  64. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php +5 -1
  65. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenGlobalVariableVariableSniff.php +26 -6
  66. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsDeclaredSniff.php +20 -17
  67. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php +5 -4
  68. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNamesSniff.php +26 -9
  69. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php +5 -2
  70. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php +5 -1
  71. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/InternalInterfacesSniff.php +11 -10
  72. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/LateStaticBindingSniff.php +10 -4
  73. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/LongArraysSniff.php +10 -12
  74. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/MbstringReplaceEModifierSniff.php +18 -9
  75. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewAnonymousClassesSniff.php +5 -1
  76. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewClassesSniff.php +22 -32
  77. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewClosureSniff.php +5 -1
  78. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewConstVisibilitySniff.php +1 -1
  79. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewExecutionDirectivesSniff.php +112 -47
  80. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewFunctionArrayDereferencingSniff.php +5 -1
  81. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewFunctionParametersSniff.php +86 -41
  82. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewFunctionsSniff.php +26 -43
  83. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewGroupUseDeclarationsSniff.php +28 -4
  84. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewHashAlgorithmsSniff.php +16 -43
  85. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewIniDirectivesSniff.php +109 -27
  86. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewInterfacesSniff.php +38 -48
  87. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewKeywordsSniff.php +60 -28
  88. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewLanguageConstructsSniff.php +55 -29
  89. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewMagicMethodsSniff.php +79 -17
  90. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewScalarReturnTypeDeclarationsSniff.php +22 -32
  91. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewScalarTypeDeclarationsSniff.php +33 -34
  92. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NonStaticMagicMethodsSniff.php +9 -8
  93. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php +5 -3
  94. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/PregReplaceEModifierSniff.php +57 -12
  95. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedAlternativePHPTagsSniff.php +6 -2
  96. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedExtensionsSniff.php +78 -254
  97. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedFunctionParametersSniff.php +96 -66
  98. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedGlobalVariablesSniff.php +36 -41
  99. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedHashAlgorithmsSniff.php +16 -64
  100. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RequiredOptionalFunctionParametersSniff.php +120 -24
  101. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/TernaryOperatorsSniff.php +5 -2
  102. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ValidIntegersSniff.php +19 -18
  103. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php +14 -1
  104. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php +1 -1
  105. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php +8 -2
  106. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php +51 -5
  107. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php +11 -36
  108. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php +19 -3
  109. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php +19 -19
  110. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php +7 -7
  111. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php +16 -6
  112. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php +1 -0
  113. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php +1 -0
  114. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +242 -148
  115. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php +12 -3
  116. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php +20 -19
  117. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php +18 -9
  118. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php +61 -23
  119. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Debug/JSLintSniff.php +4 -1
  120. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php +1 -1
  121. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php +43 -36
  122. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php +5 -4
  123. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php +1 -1
  124. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php +1 -1
  125. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php +1 -1
  126. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php +1 -1
  127. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php +4 -1
  128. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php +5 -0
  129. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php +7 -2
  130. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php +1 -1
  131. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php +19 -1
  132. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php +4 -2
  133. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php +5 -1
  134. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php +1 -1
  135. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php +57 -3
  136. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php +6 -1
  137. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php +1 -1
  138. vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php +1 -1
  139. vendor/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/CSS.php +25 -0
  140. vendor/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/Comment.php +4 -0
  141. vendor/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/JS.php +26 -6
  142. vendor/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/PHP.php +174 -71
  143. vendor/squizlabs/php_codesniffer/CodeSniffer/Tokens.php +24 -13
  144. vendor/squizlabs/php_codesniffer/README.md +1 -1
  145. vendor/squizlabs/php_codesniffer/scripts/phpcs-svn-pre-commit +1 -1
  146. vendor/wimg/php-compatibility/Sniff.php +156 -41
  147. vendor/wimg/php-compatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php +7 -3
  148. vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php +27 -55
  149. vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php +65 -36
  150. vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php +10 -6
  151. vendor/wimg/php-compatibility/Sniffs/PHP/EmptyNonVariableSniff.php +5 -2
  152. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenBreakContinueOutsideLoopSniff.php +9 -12
  153. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php +20 -12
  154. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php +1 -5
  155. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php +5 -2
  156. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php +5 -1
  157. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenGlobalVariableVariableSniff.php +26 -6
  158. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNamesAsDeclaredSniff.php +20 -17
  159. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php +5 -4
  160. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNamesSniff.php +26 -9
  161. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php +5 -2
  162. vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php +5 -1
  163. vendor/wimg/php-compatibility/Sniffs/PHP/InternalInterfacesSniff.php +11 -10
  164. vendor/wimg/php-compatibility/Sniffs/PHP/LateStaticBindingSniff.php +10 -4
  165. vendor/wimg/php-compatibility/Sniffs/PHP/LongArraysSniff.php +10 -12
  166. vendor/wimg/php-compatibility/Sniffs/PHP/MbstringReplaceEModifierSniff.php +18 -9
  167. vendor/wimg/php-compatibility/Sniffs/PHP/NewAnonymousClassesSniff.php +5 -1
  168. vendor/wimg/php-compatibility/Sniffs/PHP/NewClassesSniff.php +22 -32
  169. vendor/wimg/php-compatibility/Sniffs/PHP/NewClosureSniff.php +5 -1
  170. vendor/wimg/php-compatibility/Sniffs/PHP/NewConstVisibilitySniff.php +1 -1
  171. vendor/wimg/php-compatibility/Sniffs/PHP/NewExecutionDirectivesSniff.php +112 -47
  172. vendor/wimg/php-compatibility/Sniffs/PHP/NewFunctionArrayDereferencingSniff.php +5 -1
  173. vendor/wimg/php-compatibility/Sniffs/PHP/NewFunctionParametersSniff.php +86 -41
  174. vendor/wimg/php-compatibility/Sniffs/PHP/NewFunctionsSniff.php +26 -43
  175. vendor/wimg/php-compatibility/Sniffs/PHP/NewGroupUseDeclarationsSniff.php +28 -4
  176. vendor/wimg/php-compatibility/Sniffs/PHP/NewHashAlgorithmsSniff.php +16 -43
  177. vendor/wimg/php-compatibility/Sniffs/PHP/NewIniDirectivesSniff.php +109 -27
  178. vendor/wimg/php-compatibility/Sniffs/PHP/NewInterfacesSniff.php +38 -48
  179. vendor/wimg/php-compatibility/Sniffs/PHP/NewKeywordsSniff.php +60 -28
  180. vendor/wimg/php-compatibility/Sniffs/PHP/NewLanguageConstructsSniff.php +55 -29
  181. vendor/wimg/php-compatibility/Sniffs/PHP/NewMagicMethodsSniff.php +79 -17
  182. vendor/wimg/php-compatibility/Sniffs/PHP/NewScalarReturnTypeDeclarationsSniff.php +22 -32
  183. vendor/wimg/php-compatibility/Sniffs/PHP/NewScalarTypeDeclarationsSniff.php +33 -34
  184. vendor/wimg/php-compatibility/Sniffs/PHP/NonStaticMagicMethodsSniff.php +9 -8
  185. vendor/wimg/php-compatibility/Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php +5 -3
  186. vendor/wimg/php-compatibility/Sniffs/PHP/PregReplaceEModifierSniff.php +57 -12
  187. vendor/wimg/php-compatibility/Sniffs/PHP/RemovedAlternativePHPTagsSniff.php +6 -2
  188. vendor/wimg/php-compatibility/Sniffs/PHP/RemovedExtensionsSniff.php +78 -254
  189. vendor/wimg/php-compatibility/Sniffs/PHP/RemovedFunctionParametersSniff.php +96 -66
  190. vendor/wimg/php-compatibility/Sniffs/PHP/RemovedGlobalVariablesSniff.php +36 -41
  191. vendor/wimg/php-compatibility/Sniffs/PHP/RemovedHashAlgorithmsSniff.php +16 -64
  192. vendor/wimg/php-compatibility/Sniffs/PHP/RequiredOptionalFunctionParametersSniff.php +120 -24
  193. vendor/wimg/php-compatibility/Sniffs/PHP/TernaryOperatorsSniff.php +5 -2
  194. vendor/wimg/php-compatibility/Sniffs/PHP/ValidIntegersSniff.php +19 -18
  195. wpengine-phpcompat.php +1 -1
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wpengine, octalmage, stevenkword, Taylor4484, pross, jcross
3
  Tags: php 7, php 5.5, php, version, compatibility, checker, wp engine, wpe, wpengine
4
  Requires at least: 3.5
5
  Tested up to: 4.7.2
6
- Stable tag: 1.4.0
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -114,6 +114,10 @@ To disclose security issues for this plugin please email WordPress@wpengine.com
114
 
115
  == Changelog ==
116
 
 
 
 
 
117
  = 1.4.0 =
118
  - Updated UX for viewing PHP errors to be more intuitive and require less scrolling.
119
  - Added links for non-technical users who need assistance from developers to fix PHP errors or to test their site in PHP 7 enabled hosting environments.
@@ -187,10 +191,6 @@ To disclose security issues for this plugin please email WordPress@wpengine.com
187
 
188
  == Upgrade Notice ==
189
 
190
- = 1.4.0 =
191
- - Updated UX for viewing PHP errors to be more intuitive and require less scrolling.
192
- - Added links for non-technical users who need assistance from developers to fix PHP errors or to test their site in PHP 7 enabled hosting environments.
193
-
194
- = 1.3.2 =
195
- - Added a "Clean up" button and uninstall.php.
196
- - Added phpcompat_phpversions filter.
3
  Tags: php 7, php 5.5, php, version, compatibility, checker, wp engine, wpe, wpengine
4
  Requires at least: 3.5
5
  Tested up to: 4.7.2
6
+ Stable tag: 1.4.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
114
 
115
  == Changelog ==
116
 
117
+ = 1.4.1 =
118
+ - Updated PHP_CodeSniffer to fix a security advisory.
119
+ - Whitelisted a number of plugins.
120
+
121
  = 1.4.0 =
122
  - Updated UX for viewing PHP errors to be more intuitive and require less scrolling.
123
  - Added links for non-technical users who need assistance from developers to fix PHP errors or to test their site in PHP 7 enabled hosting environments.
191
 
192
  == Upgrade Notice ==
193
 
194
+ = 1.4.1 =
195
+ - Updated PHP_CodeSniffer to fix a security advisory.
196
+ - Whitelisted a number of plugins.
 
 
 
 
src/wpephpcompat.php CHANGED
@@ -84,6 +84,9 @@ class WPEPHPCompat {
84
  '*/comment-mail/*' => '7.0', // https://wordpress.org/support/topic/false-positive-comment-mail/
85
  '*/social-networks-auto-poster-facebook-twitter-g/*' => '7.0', // https://wordpress.org/plugins/social-networks-auto-poster-facebook-twitter-g/
86
  '*/mailpoet/*' => '7.0', // https://wordpress.org/support/topic/false-positive-mailpoet-3-not-compatible-with-php7/
 
 
 
87
  );
88
 
89
  /**
84
  '*/comment-mail/*' => '7.0', // https://wordpress.org/support/topic/false-positive-comment-mail/
85
  '*/social-networks-auto-poster-facebook-twitter-g/*' => '7.0', // https://wordpress.org/plugins/social-networks-auto-poster-facebook-twitter-g/
86
  '*/mailpoet/*' => '7.0', // https://wordpress.org/support/topic/false-positive-mailpoet-3-not-compatible-with-php7/
87
+ '*/give/*' => '7.0', // https://github.com/wpengine/phpcompat/issues/148
88
+ '*/woocommerce-pdf-invoices-packing-slips/*' => '7.0', // https://github.com/wpengine/phpcompat/issues/160
89
+ '*/iwp-client/*' => '7.0', // https://wordpress.org/support/topic/iwp-client-and-php-7-compatibility/
90
  );
91
 
92
  /**
vendor/autoload.php CHANGED
@@ -2,6 +2,6 @@
2
 
3
  // autoload.php @generated by Composer
4
 
5
- require_once __DIR__ . '/composer' . '/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit40c259fa07cfee03e82e5f3d5fc304cc::getLoader();
2
 
3
  // autoload.php @generated by Composer
4
 
5
+ require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit2a60b911d59581b77bf10bbf0aa9965f::getLoader();
vendor/composer/ClassLoader.php CHANGED
@@ -53,8 +53,9 @@ class ClassLoader
53
 
54
  private $useIncludePath = false;
55
  private $classMap = array();
56
-
57
  private $classMapAuthoritative = false;
 
 
58
 
59
  public function getPrefixes()
60
  {
@@ -271,6 +272,26 @@ class ClassLoader
271
  return $this->classMapAuthoritative;
272
  }
273
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  /**
275
  * Registers this instance as an autoloader.
276
  *
@@ -313,29 +334,34 @@ class ClassLoader
313
  */
314
  public function findFile($class)
315
  {
316
- // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731
317
- if ('\\' == $class[0]) {
318
- $class = substr($class, 1);
319
- }
320
-
321
  // class map lookup
322
  if (isset($this->classMap[$class])) {
323
  return $this->classMap[$class];
324
  }
325
- if ($this->classMapAuthoritative) {
326
  return false;
327
  }
 
 
 
 
 
 
328
 
329
  $file = $this->findFileWithExtension($class, '.php');
330
 
331
  // Search for Hack files if we are running on HHVM
332
- if ($file === null && defined('HHVM_VERSION')) {
333
  $file = $this->findFileWithExtension($class, '.hh');
334
  }
335
 
336
- if ($file === null) {
 
 
 
 
337
  // Remember that this class does not exist.
338
- return $this->classMap[$class] = false;
339
  }
340
 
341
  return $file;
@@ -399,6 +425,8 @@ class ClassLoader
399
  if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
400
  return $file;
401
  }
 
 
402
  }
403
  }
404
 
53
 
54
  private $useIncludePath = false;
55
  private $classMap = array();
 
56
  private $classMapAuthoritative = false;
57
+ private $missingClasses = array();
58
+ private $apcuPrefix;
59
 
60
  public function getPrefixes()
61
  {
272
  return $this->classMapAuthoritative;
273
  }
274
 
275
+ /**
276
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
277
+ *
278
+ * @param string|null $apcuPrefix
279
+ */
280
+ public function setApcuPrefix($apcuPrefix)
281
+ {
282
+ $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
283
+ }
284
+
285
+ /**
286
+ * The APCu prefix in use, or null if APCu caching is not enabled.
287
+ *
288
+ * @return string|null
289
+ */
290
+ public function getApcuPrefix()
291
+ {
292
+ return $this->apcuPrefix;
293
+ }
294
+
295
  /**
296
  * Registers this instance as an autoloader.
297
  *
334
  */
335
  public function findFile($class)
336
  {
 
 
 
 
 
337
  // class map lookup
338
  if (isset($this->classMap[$class])) {
339
  return $this->classMap[$class];
340
  }
341
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
342
  return false;
343
  }
344
+ if (null !== $this->apcuPrefix) {
345
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
346
+ if ($hit) {
347
+ return $file;
348
+ }
349
+ }
350
 
351
  $file = $this->findFileWithExtension($class, '.php');
352
 
353
  // Search for Hack files if we are running on HHVM
354
+ if (false === $file && defined('HHVM_VERSION')) {
355
  $file = $this->findFileWithExtension($class, '.hh');
356
  }
357
 
358
+ if (null !== $this->apcuPrefix) {
359
+ apcu_add($this->apcuPrefix.$class, $file);
360
+ }
361
+
362
+ if (false === $file) {
363
  // Remember that this class does not exist.
364
+ $this->missingClasses[$class] = true;
365
  }
366
 
367
  return $file;
425
  if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
426
  return $file;
427
  }
428
+
429
+ return false;
430
  }
431
  }
432
 
vendor/composer/LICENSE CHANGED
@@ -1,5 +1,5 @@
1
 
2
- Copyright (c) 2015 Nils Adermann, Jordi Boggiano
3
 
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
  of this software and associated documentation files (the "Software"), to deal
1
 
2
+ Copyright (c) Nils Adermann, Jordi Boggiano
3
 
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
5
  of this software and associated documentation files (the "Software"), to deal
vendor/composer/autoload_classmap.php CHANGED
@@ -9,6 +9,7 @@ return array(
9
  'Generic_Sniffs_Arrays_DisallowLongArraySyntaxSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php',
10
  'Generic_Sniffs_Arrays_DisallowShortArraySyntaxSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php',
11
  'Generic_Sniffs_Classes_DuplicateClassNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php',
 
12
  'Generic_Sniffs_CodeAnalysis_EmptyStatementSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php',
13
  'Generic_Sniffs_CodeAnalysis_ForLoopShouldBeWhileLoopSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php',
14
  'Generic_Sniffs_CodeAnalysis_ForLoopWithTestFunctionCallSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php',
@@ -48,9 +49,11 @@ return array(
48
  'Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php',
49
  'Generic_Sniffs_NamingConventions_ConstructorNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php',
50
  'Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php',
 
51
  'Generic_Sniffs_PHP_CharacterBeforePHPOpeningTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php',
52
  'Generic_Sniffs_PHP_ClosingPHPTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php',
53
  'Generic_Sniffs_PHP_DeprecatedFunctionsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php',
 
54
  'Generic_Sniffs_PHP_DisallowShortOpenTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php',
55
  'Generic_Sniffs_PHP_ForbiddenFunctionsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php',
56
  'Generic_Sniffs_PHP_LowerCaseConstantSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php',
9
  'Generic_Sniffs_Arrays_DisallowLongArraySyntaxSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php',
10
  'Generic_Sniffs_Arrays_DisallowShortArraySyntaxSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php',
11
  'Generic_Sniffs_Classes_DuplicateClassNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php',
12
+ 'Generic_Sniffs_Classes_OpeningBraceSameLineSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php',
13
  'Generic_Sniffs_CodeAnalysis_EmptyStatementSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php',
14
  'Generic_Sniffs_CodeAnalysis_ForLoopShouldBeWhileLoopSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php',
15
  'Generic_Sniffs_CodeAnalysis_ForLoopWithTestFunctionCallSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php',
49
  'Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php',
50
  'Generic_Sniffs_NamingConventions_ConstructorNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php',
51
  'Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php',
52
+ 'Generic_Sniffs_PHP_BacktickOperatorSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php',
53
  'Generic_Sniffs_PHP_CharacterBeforePHPOpeningTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php',
54
  'Generic_Sniffs_PHP_ClosingPHPTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php',
55
  'Generic_Sniffs_PHP_DeprecatedFunctionsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php',
56
+ 'Generic_Sniffs_PHP_DisallowAlternativePHPTagsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php',
57
  'Generic_Sniffs_PHP_DisallowShortOpenTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php',
58
  'Generic_Sniffs_PHP_ForbiddenFunctionsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php',
59
  'Generic_Sniffs_PHP_LowerCaseConstantSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php',
vendor/composer/autoload_namespaces.php CHANGED
@@ -7,4 +7,5 @@ $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
  'SimplyAdmire\\ComposerPlugins' => array($vendorDir . '/simplyadmire/composer-plugins'),
 
10
  );
7
 
8
  return array(
9
  'SimplyAdmire\\ComposerPlugins' => array($vendorDir . '/simplyadmire/composer-plugins'),
10
+ '' => array($vendorDir . '/neronmoon/scriptsdev/src'),
11
  );
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit40c259fa07cfee03e82e5f3d5fc304cc
6
  {
7
  private static $loader;
8
 
@@ -19,23 +19,30 @@ class ComposerAutoloaderInit40c259fa07cfee03e82e5f3d5fc304cc
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit40c259fa07cfee03e82e5f3d5fc304cc', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit40c259fa07cfee03e82e5f3d5fc304cc', 'loadClassLoader'));
25
-
26
- $map = require __DIR__ . '/autoload_namespaces.php';
27
- foreach ($map as $namespace => $path) {
28
- $loader->set($namespace, $path);
29
- }
30
-
31
- $map = require __DIR__ . '/autoload_psr4.php';
32
- foreach ($map as $namespace => $path) {
33
- $loader->setPsr4($namespace, $path);
34
- }
35
-
36
- $classMap = require __DIR__ . '/autoload_classmap.php';
37
- if ($classMap) {
38
- $loader->addClassMap($classMap);
 
 
 
 
 
 
 
39
  }
40
 
41
  $loader->register(true);
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit2a60b911d59581b77bf10bbf0aa9965f
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit2a60b911d59581b77bf10bbf0aa9965f', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit2a60b911d59581b77bf10bbf0aa9965f', '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\ComposerStaticInit2a60b911d59581b77bf10bbf0aa9965f::getInitializer($loader));
31
+ } else {
32
+ $map = require __DIR__ . '/autoload_namespaces.php';
33
+ foreach ($map as $namespace => $path) {
34
+ $loader->set($namespace, $path);
35
+ }
36
+
37
+ $map = require __DIR__ . '/autoload_psr4.php';
38
+ foreach ($map as $namespace => $path) {
39
+ $loader->setPsr4($namespace, $path);
40
+ }
41
+
42
+ $classMap = require __DIR__ . '/autoload_classmap.php';
43
+ if ($classMap) {
44
+ $loader->addClassMap($classMap);
45
+ }
46
  }
47
 
48
  $loader->register(true);
vendor/composer/installed.json CHANGED
@@ -1,17 +1,173 @@
1
  [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  {
3
  "name": "squizlabs/php_codesniffer",
4
- "version": "2.6.2",
5
- "version_normalized": "2.6.2.0",
6
  "source": {
7
  "type": "git",
8
  "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
9
- "reference": "4edb770cb853def6e60c93abb088ad5ac2010c83"
10
  },
11
  "dist": {
12
  "type": "zip",
13
- "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4edb770cb853def6e60c93abb088ad5ac2010c83",
14
- "reference": "4edb770cb853def6e60c93abb088ad5ac2010c83",
15
  "shasum": ""
16
  },
17
  "require": {
@@ -23,7 +179,7 @@
23
  "require-dev": {
24
  "phpunit/phpunit": "~4.0"
25
  },
26
- "time": "2016-07-13 23:29:13",
27
  "bin": [
28
  "scripts/phpcs",
29
  "scripts/phpcbf"
@@ -80,106 +236,41 @@
80
  ]
81
  },
82
  {
83
- "name": "simplyadmire/composer-plugins",
84
  "version": "dev-master",
85
  "version_normalized": "9999999-dev",
86
  "source": {
87
  "type": "git",
88
- "url": "https://github.com/SimplyAdmire/ComposerPlugins.git",
89
- "reference": "d8380f670694c1c2330b22591ca74adc82cffe19"
90
  },
91
  "dist": {
92
  "type": "zip",
93
- "url": "https://api.github.com/repos/SimplyAdmire/ComposerPlugins/zipball/d8380f670694c1c2330b22591ca74adc82cffe19",
94
- "reference": "d8380f670694c1c2330b22591ca74adc82cffe19",
95
  "shasum": ""
96
  },
97
  "require": {
98
- "composer-plugin-api": "^1.0",
99
- "squizlabs/php_codesniffer": "*"
100
- },
101
- "time": "2016-05-12 11:58:38",
102
- "type": "composer-plugin",
103
- "extra": {
104
- "class": [
105
- "SimplyAdmire\\ComposerPlugins\\PhpCodesnifferStandardInstallerPlugin"
106
- ]
107
  },
 
 
108
  "installation-source": "source",
109
- "autoload": {
110
- "psr-0": {
111
- "SimplyAdmire\\ComposerPlugins": ""
112
- }
113
- },
114
  "notification-url": "https://packagist.org/downloads/",
115
  "license": [
116
- "LGPL-3.0+"
117
  ],
118
  "authors": [
119
  {
120
- "name": "Rens Admiraal",
121
- "email": "rens@simplyadmire.com",
122
- "role": "lead"
123
  }
124
  ],
125
- "description": "Composer plugin for installing PHP_CodeSniffer standards",
126
  "keywords": [
127
- "PHP_CodeSniffer",
128
- "TYPO3 CMS",
129
- "TYPO3 Flow",
130
- "TYPO3 Neos",
131
  "phpcs",
132
  "standards",
133
- "typo3"
134
- ]
135
- },
136
- {
137
- "name": "wimg/php-compatibility",
138
- "version": "dev-master",
139
- "version_normalized": "9999999-dev",
140
- "source": {
141
- "type": "git",
142
- "url": "https://github.com/wimg/PHPCompatibility.git",
143
- "reference": "a3263259daa3629d174d1ac25657466222d6607e"
144
- },
145
- "dist": {
146
- "type": "zip",
147
- "url": "https://api.github.com/repos/wimg/PHPCompatibility/zipball/a3263259daa3629d174d1ac25657466222d6607e",
148
- "reference": "a3263259daa3629d174d1ac25657466222d6607e",
149
- "shasum": ""
150
- },
151
- "require": {
152
- "ext-tokenizer": "*",
153
- "php": ">=5.1.2",
154
- "squizlabs/php_codesniffer": "~2.0"
155
- },
156
- "require-dev": {
157
- "satooshi/php-coveralls": "dev-master"
158
- },
159
- "time": "2016-10-30 14:34:26",
160
- "type": "phpcodesniffer-standard",
161
- "installation-source": "source",
162
- "autoload": {
163
- "psr-4": {
164
- "PHPCompatibility\\": ""
165
- }
166
- },
167
- "notification-url": "https://packagist.org/downloads/",
168
- "license": [
169
- "LGPL-3.0"
170
- ],
171
- "authors": [
172
- {
173
- "name": "Wim Godden",
174
- "role": "lead"
175
- }
176
- ],
177
- "description": "This is a set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.",
178
- "homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
179
- "keywords": [
180
- "compatibility",
181
- "phpcs",
182
- "standards"
183
  ]
184
  }
185
  ]
1
  [
2
+ {
3
+ "name": "simplyadmire/composer-plugins",
4
+ "version": "dev-master",
5
+ "version_normalized": "9999999-dev",
6
+ "source": {
7
+ "type": "git",
8
+ "url": "https://github.com/SimplyAdmire/ComposerPlugins.git",
9
+ "reference": "d8380f670694c1c2330b22591ca74adc82cffe19"
10
+ },
11
+ "dist": {
12
+ "type": "zip",
13
+ "url": "https://api.github.com/repos/SimplyAdmire/ComposerPlugins/zipball/d8380f670694c1c2330b22591ca74adc82cffe19",
14
+ "reference": "d8380f670694c1c2330b22591ca74adc82cffe19",
15
+ "shasum": ""
16
+ },
17
+ "require": {
18
+ "composer-plugin-api": "^1.0",
19
+ "squizlabs/php_codesniffer": "*"
20
+ },
21
+ "time": "2016-05-12T11:58:38+00:00",
22
+ "type": "composer-plugin",
23
+ "extra": {
24
+ "class": [
25
+ "SimplyAdmire\\ComposerPlugins\\PhpCodesnifferStandardInstallerPlugin"
26
+ ]
27
+ },
28
+ "installation-source": "source",
29
+ "autoload": {
30
+ "psr-0": {
31
+ "SimplyAdmire\\ComposerPlugins": ""
32
+ }
33
+ },
34
+ "notification-url": "https://packagist.org/downloads/",
35
+ "license": [
36
+ "LGPL-3.0+"
37
+ ],
38
+ "authors": [
39
+ {
40
+ "name": "Rens Admiraal",
41
+ "email": "rens@simplyadmire.com",
42
+ "role": "lead"
43
+ }
44
+ ],
45
+ "description": "Composer plugin for installing PHP_CodeSniffer standards",
46
+ "keywords": [
47
+ "PHP_CodeSniffer",
48
+ "TYPO3 CMS",
49
+ "TYPO3 Flow",
50
+ "TYPO3 Neos",
51
+ "phpcs",
52
+ "standards",
53
+ "typo3"
54
+ ],
55
+ "abandoned": true
56
+ },
57
+ {
58
+ "name": "wimg/php-compatibility",
59
+ "version": "dev-master",
60
+ "version_normalized": "9999999-dev",
61
+ "source": {
62
+ "type": "git",
63
+ "url": "https://github.com/wimg/PHPCompatibility.git",
64
+ "reference": "4853c6da08a6cb0f53029170e93c97120a6a2335"
65
+ },
66
+ "dist": {
67
+ "type": "zip",
68
+ "url": "https://api.github.com/repos/wimg/PHPCompatibility/zipball/4853c6da08a6cb0f53029170e93c97120a6a2335",
69
+ "reference": "4853c6da08a6cb0f53029170e93c97120a6a2335",
70
+ "shasum": ""
71
+ },
72
+ "require": {
73
+ "ext-tokenizer": "*",
74
+ "php": ">=5.1.2",
75
+ "squizlabs/php_codesniffer": "~2.0"
76
+ },
77
+ "require-dev": {
78
+ "satooshi/php-coveralls": "dev-master"
79
+ },
80
+ "time": "2017-01-03T20:31:50+00:00",
81
+ "type": "phpcodesniffer-standard",
82
+ "installation-source": "source",
83
+ "autoload": {
84
+ "psr-4": {
85
+ "PHPCompatibility\\": ""
86
+ }
87
+ },
88
+ "notification-url": "https://packagist.org/downloads/",
89
+ "license": [
90
+ "LGPL-3.0"
91
+ ],
92
+ "authors": [
93
+ {
94
+ "name": "Wim Godden",
95
+ "role": "lead"
96
+ }
97
+ ],
98
+ "description": "This is a set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.",
99
+ "homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
100
+ "keywords": [
101
+ "compatibility",
102
+ "phpcs",
103
+ "standards"
104
+ ]
105
+ },
106
+ {
107
+ "name": "neronmoon/scriptsdev",
108
+ "version": "v0.1.0",
109
+ "version_normalized": "0.1.0.0",
110
+ "source": {
111
+ "type": "git",
112
+ "url": "https://github.com/neronmoon/scriptsdev.git",
113
+ "reference": "ab5cec346cab353500b957de8c7e6548961d35fe"
114
+ },
115
+ "dist": {
116
+ "type": "zip",
117
+ "url": "https://api.github.com/repos/neronmoon/scriptsdev/zipball/ab5cec346cab353500b957de8c7e6548961d35fe",
118
+ "reference": "ab5cec346cab353500b957de8c7e6548961d35fe",
119
+ "shasum": ""
120
+ },
121
+ "require": {
122
+ "composer-plugin-api": "^1.0"
123
+ },
124
+ "require-dev": {
125
+ "composer/composer": "~1.0@dev"
126
+ },
127
+ "time": "2015-11-12T17:00:24+00:00",
128
+ "type": "composer-plugin",
129
+ "extra": {
130
+ "class": "\\Plugin"
131
+ },
132
+ "installation-source": "dist",
133
+ "autoload": {
134
+ "psr-0": {
135
+ "": "src/"
136
+ }
137
+ },
138
+ "notification-url": "https://packagist.org/downloads/",
139
+ "license": [
140
+ "MIT"
141
+ ],
142
+ "authors": [
143
+ {
144
+ "name": "Vitaliy Krasnoperov",
145
+ "email": "alistar.neron@gmail.com"
146
+ }
147
+ ],
148
+ "description": "Scripts-dev behaviour for Composer",
149
+ "homepage": "https://github.com/neronmoon/scriptsdev",
150
+ "keywords": [
151
+ "commands",
152
+ "commands execution",
153
+ "composer",
154
+ "dev",
155
+ "scripts"
156
+ ]
157
+ },
158
  {
159
  "name": "squizlabs/php_codesniffer",
160
+ "version": "2.8.1",
161
+ "version_normalized": "2.8.1.0",
162
  "source": {
163
  "type": "git",
164
  "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
165
+ "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d"
166
  },
167
  "dist": {
168
  "type": "zip",
169
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d",
170
+ "reference": "d7cf0d894e8aa4c73712ee4a331cc1eaa37cdc7d",
171
  "shasum": ""
172
  },
173
  "require": {
179
  "require-dev": {
180
  "phpunit/phpunit": "~4.0"
181
  },
182
+ "time": "2017-03-01T22:17:45+00:00",
183
  "bin": [
184
  "scripts/phpcs",
185
  "scripts/phpcbf"
236
  ]
237
  },
238
  {
239
+ "name": "wp-coding-standards/wpcs",
240
  "version": "dev-master",
241
  "version_normalized": "9999999-dev",
242
  "source": {
243
  "type": "git",
244
+ "url": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git",
245
+ "reference": "b39490465f6fd7375743a395019cd597e12119c9"
246
  },
247
  "dist": {
248
  "type": "zip",
249
+ "url": "https://api.github.com/repos/WordPress-Coding-Standards/WordPress-Coding-Standards/zipball/b39490465f6fd7375743a395019cd597e12119c9",
250
+ "reference": "b39490465f6fd7375743a395019cd597e12119c9",
251
  "shasum": ""
252
  },
253
  "require": {
254
+ "squizlabs/php_codesniffer": "^2.6"
 
 
 
 
 
 
 
 
255
  },
256
+ "time": "2016-08-29T20:04:47+00:00",
257
+ "type": "library",
258
  "installation-source": "source",
 
 
 
 
 
259
  "notification-url": "https://packagist.org/downloads/",
260
  "license": [
261
+ "MIT"
262
  ],
263
  "authors": [
264
  {
265
+ "name": "Contributors",
266
+ "homepage": "https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/graphs/contributors"
 
267
  }
268
  ],
269
+ "description": "PHP_CodeSniffer rules (sniffs) to enforce WordPress coding conventions",
270
  "keywords": [
 
 
 
 
271
  "phpcs",
272
  "standards",
273
+ "wordpress"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  ]
275
  }
276
  ]
vendor/squizlabs/php_codesniffer/CONTRIBUTING.md CHANGED
@@ -4,7 +4,7 @@ Contributing
4
  Before you contribute code to PHP\_CodeSniffer, please make sure it conforms to the PHPCS coding standard and that the PHP\_CodeSniffer unit tests still pass. The easiest way to contribute is to work on a checkout of the repository, or your own fork, rather than an installed PEAR version. If you do this, you can run the following commands to check if everything is ready to submit:
5
 
6
  cd PHP_CodeSniffer
7
- php scripts/phpcs . --standard=PHPCS -np
8
 
9
  Which should give you no output, indicating that there are no coding standard errors. And then:
10
 
4
  Before you contribute code to PHP\_CodeSniffer, please make sure it conforms to the PHPCS coding standard and that the PHP\_CodeSniffer unit tests still pass. The easiest way to contribute is to work on a checkout of the repository, or your own fork, rather than an installed PEAR version. If you do this, you can run the following commands to check if everything is ready to submit:
5
 
6
  cd PHP_CodeSniffer
7
+ php scripts/phpcs
8
 
9
  Which should give you no output, indicating that there are no coding standard errors. And then:
10
 
vendor/squizlabs/php_codesniffer/CodeSniffer.php CHANGED
@@ -73,7 +73,7 @@ class PHP_CodeSniffer
73
  *
74
  * @var string
75
  */
76
- const VERSION = '2.6.2';
77
 
78
  /**
79
  * Package stability; either stable, beta or alpha.
@@ -533,13 +533,13 @@ class PHP_CodeSniffer
533
  // be detected properly for files created on a Mac with the /r line ending.
534
  ini_set('auto_detect_line_endings', true);
535
 
536
- $sniffs = array();
537
- foreach ($standards as $standard) {
538
- $installed = $this->getInstalledStandardPath($standard);
539
  if ($installed !== null) {
540
  $standard = $installed;
541
  } else {
542
- $standard = self::realpath($standard);
543
  if (is_dir($standard) === true
544
  && is_file(self::realpath($standard.DIRECTORY_SEPARATOR.'ruleset.xml')) === true
545
  ) {
@@ -547,20 +547,37 @@ class PHP_CodeSniffer
547
  }
548
  }
549
 
550
- if (PHP_CODESNIFFER_VERBOSITY === 1) {
551
- $ruleset = simplexml_load_file($standard);
552
- if ($ruleset !== false) {
553
- $standardName = (string) $ruleset['name'];
 
 
 
 
 
 
 
 
 
 
554
  }
555
 
556
- echo "Registering sniffs in the $standardName standard... ";
557
- if (count($standards) > 1 || PHP_CODESNIFFER_VERBOSITY > 2) {
558
- echo PHP_EOL;
 
 
 
 
 
 
 
559
  }
560
- }
561
 
562
- $sniffs = array_merge($sniffs, $this->processRuleset($standard));
563
- }//end foreach
 
564
 
565
  $sniffRestrictions = array();
566
  foreach ($restrictions as $sniffCode) {
@@ -711,7 +728,7 @@ class PHP_CodeSniffer
711
  echo "Processing ruleset $rulesetPath".PHP_EOL;
712
  }
713
 
714
- $ruleset = simplexml_load_file($rulesetPath);
715
  if ($ruleset === false) {
716
  throw new PHP_CodeSniffer_Exception("Ruleset $rulesetPath is not valid");
717
  }
@@ -2093,13 +2110,17 @@ class PHP_CodeSniffer
2093
  $lowerVarType = strtolower($varType);
2094
  switch ($lowerVarType) {
2095
  case 'bool':
 
2096
  return 'boolean';
2097
  case 'double':
2098
  case 'real':
 
2099
  return 'float';
2100
  case 'int':
 
2101
  return 'integer';
2102
  case 'array()':
 
2103
  return 'array';
2104
  }//end switch
2105
 
73
  *
74
  * @var string
75
  */
76
+ const VERSION = '2.8.1';
77
 
78
  /**
79
  * Package stability; either stable, beta or alpha.
533
  // be detected properly for files created on a Mac with the /r line ending.
534
  ini_set('auto_detect_line_endings', true);
535
 
536
+ if (defined('PHP_CODESNIFFER_IN_TESTS') === true && empty($restrictions) === false) {
537
+ // Should be one standard and one sniff being tested at a time.
538
+ $installed = $this->getInstalledStandardPath($standards[0]);
539
  if ($installed !== null) {
540
  $standard = $installed;
541
  } else {
542
+ $standard = self::realpath($standards[0]);
543
  if (is_dir($standard) === true
544
  && is_file(self::realpath($standard.DIRECTORY_SEPARATOR.'ruleset.xml')) === true
545
  ) {
547
  }
548
  }
549
 
550
+ $sniffs = $this->_expandRulesetReference($restrictions[0], dirname($standard));
551
+ } else {
552
+ $sniffs = array();
553
+ foreach ($standards as $standard) {
554
+ $installed = $this->getInstalledStandardPath($standard);
555
+ if ($installed !== null) {
556
+ $standard = $installed;
557
+ } else {
558
+ $standard = self::realpath($standard);
559
+ if (is_dir($standard) === true
560
+ && is_file(self::realpath($standard.DIRECTORY_SEPARATOR.'ruleset.xml')) === true
561
+ ) {
562
+ $standard = self::realpath($standard.DIRECTORY_SEPARATOR.'ruleset.xml');
563
+ }
564
  }
565
 
566
+ if (PHP_CODESNIFFER_VERBOSITY === 1) {
567
+ $ruleset = simplexml_load_string(file_get_contents($standard));
568
+ if ($ruleset !== false) {
569
+ $standardName = (string) $ruleset['name'];
570
+ }
571
+
572
+ echo "Registering sniffs in the $standardName standard... ";
573
+ if (count($standards) > 1 || PHP_CODESNIFFER_VERBOSITY > 2) {
574
+ echo PHP_EOL;
575
+ }
576
  }
 
577
 
578
+ $sniffs = array_merge($sniffs, $this->processRuleset($standard));
579
+ }//end foreach
580
+ }//end if
581
 
582
  $sniffRestrictions = array();
583
  foreach ($restrictions as $sniffCode) {
728
  echo "Processing ruleset $rulesetPath".PHP_EOL;
729
  }
730
 
731
+ $ruleset = simplexml_load_string(file_get_contents($rulesetPath));
732
  if ($ruleset === false) {
733
  throw new PHP_CodeSniffer_Exception("Ruleset $rulesetPath is not valid");
734
  }
2110
  $lowerVarType = strtolower($varType);
2111
  switch ($lowerVarType) {
2112
  case 'bool':
2113
+ case 'boolean':
2114
  return 'boolean';
2115
  case 'double':
2116
  case 'real':
2117
+ case 'float':
2118
  return 'float';
2119
  case 'int':
2120
+ case 'integer':
2121
  return 'integer';
2122
  case 'array()':
2123
+ case 'array':
2124
  return 'array';
2125
  }//end switch
2126
 
vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php CHANGED
@@ -14,8 +14,15 @@
14
 
15
  error_reporting(E_ALL | E_STRICT);
16
 
 
 
 
 
 
 
 
17
  // Make sure that we autoload all dependencies if running via Composer.
18
- if (version_compare(PHP_VERSION, '5.3.2', '>=') === true) {
19
  if (file_exists($a = dirname(__FILE__).'/../../../autoload.php') === true) {
20
  include_once $a;
21
  } else if (file_exists($a = dirname(__FILE__).'/../vendor/autoload.php') === true) {
@@ -245,7 +252,7 @@ class PHP_CodeSniffer_CLI
245
  public function checkRequirements()
246
  {
247
  // Check the PHP version.
248
- if (version_compare(PHP_VERSION, '5.1.2', '<') === true) {
249
  echo 'ERROR: PHP_CodeSniffer requires PHP version 5.1.2 or greater.'.PHP_EOL;
250
  exit(2);
251
  }
@@ -399,7 +406,7 @@ class PHP_CodeSniffer_CLI
399
  $handle = fopen('php://stdin', 'r');
400
  if (stream_set_blocking($handle, false) === true) {
401
  $fileContents = '';
402
- while (($line = fgets(STDIN)) !== false) {
403
  $fileContents .= $line;
404
  usleep(10);
405
  }
@@ -426,7 +433,10 @@ class PHP_CodeSniffer_CLI
426
  public function setCommandLineValues($args)
427
  {
428
  if (defined('PHP_CODESNIFFER_IN_TESTS') === true) {
429
- $this->values = array('stdin' => null);
 
 
 
430
  } else if (empty($this->values) === true) {
431
  $this->values = $this->getDefaults();
432
  }
@@ -674,6 +684,33 @@ class PHP_CodeSniffer_CLI
674
 
675
  $this->values['bootstrap'][] = $path;
676
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
677
  } else if (substr($arg, 0, 11) === 'stdin-path=') {
678
  $this->values['stdinPath'] = PHP_CodeSniffer::realpath(substr($arg, 11));
679
 
@@ -699,7 +736,13 @@ class PHP_CodeSniffer_CLI
699
  // Passed report file is a file in the current directory.
700
  $this->values['reportFile'] = getcwd().'/'.basename($this->values['reportFile']);
701
  } else {
702
- $dir = PHP_CodeSniffer::realpath(getcwd().'/'.$dir);
 
 
 
 
 
 
703
  if ($dir !== false) {
704
  // Report file path is relative.
705
  $this->values['reportFile'] = $dir.'/'.basename($this->values['reportFile']);
@@ -734,7 +777,13 @@ class PHP_CodeSniffer_CLI
734
  // Passed report file is a filename in the current directory.
735
  $output = getcwd().'/'.basename($output);
736
  } else {
737
- $dir = PHP_CodeSniffer::realpath(getcwd().'/'.$dir);
 
 
 
 
 
 
738
  if ($dir !== false) {
739
  // Report file path is relative.
740
  $output = $dir.'/'.basename($output);
@@ -964,6 +1013,7 @@ class PHP_CodeSniffer_CLI
964
  $this->printUsage();
965
  exit(2);
966
  } else {
 
967
  $phpcs->processFile('STDIN', $fileContents);
968
  }
969
  }
@@ -1256,7 +1306,8 @@ class PHP_CodeSniffer_CLI
1256
  echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
1257
  echo ' [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL;
1258
  echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>] [--encoding=<encoding>]'.PHP_EOL;
1259
- echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--bootstrap=<bootstrap>] <file> ...'.PHP_EOL;
 
1260
  echo ' Set runtime value (see --config-set) '.PHP_EOL;
1261
  echo ' -n Do not print warnings (shortcut for --warning-severity=0)'.PHP_EOL;
1262
  echo ' -w Print both warnings and errors (this is the default)'.PHP_EOL;
@@ -1274,6 +1325,7 @@ class PHP_CodeSniffer_CLI
1274
  echo ' --colors Use colors in output'.PHP_EOL;
1275
  echo ' --no-colors Do not use colors in output (this is the default)'.PHP_EOL;
1276
  echo ' <file> One or more files and/or directories to check'.PHP_EOL;
 
1277
  echo ' <stdinPath> If processing STDIN, the file path that STDIN will be processed as '.PHP_EOL;
1278
  echo ' <bootstrap> A comma separated list of files to run before processing starts'.PHP_EOL;
1279
  echo ' <encoding> The encoding of the files being checked (default is iso-8859-1)'.PHP_EOL;
@@ -1311,7 +1363,8 @@ class PHP_CodeSniffer_CLI
1311
  echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>] [--suffix=<suffix>]'.PHP_EOL;
1312
  echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
1313
  echo ' [--tab-width=<tabWidth>] [--encoding=<encoding>]'.PHP_EOL;
1314
- echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--bootstrap=<bootstrap>] <file> ...'.PHP_EOL;
 
1315
  echo ' -n Do not fix warnings (shortcut for --warning-severity=0)'.PHP_EOL;
1316
  echo ' -w Fix both warnings and errors (on by default)'.PHP_EOL;
1317
  echo ' -l Local directory only, no recursion'.PHP_EOL;
@@ -1321,6 +1374,7 @@ class PHP_CodeSniffer_CLI
1321
  echo ' --version Print version information'.PHP_EOL;
1322
  echo ' --no-patch Do not make use of the "diff" or "patch" programs'.PHP_EOL;
1323
  echo ' <file> One or more files and/or directories to fix'.PHP_EOL;
 
1324
  echo ' <stdinPath> If processing STDIN, the file path that STDIN will be processed as '.PHP_EOL;
1325
  echo ' <bootstrap> A comma separated list of files to run before processing starts'.PHP_EOL;
1326
  echo ' <encoding> The encoding of the files being fixed (default is iso-8859-1)'.PHP_EOL;
14
 
15
  error_reporting(E_ALL | E_STRICT);
16
 
17
+ // Make sure version id constant is available.
18
+ if (defined('PHP_VERSION_ID') === false) {
19
+ $version = explode('.', PHP_VERSION);
20
+ define('PHP_VERSION_ID', (int) (($version[0] * 10000) + ($version[1] * 100) + $version[2]));
21
+ unset($version);
22
+ }
23
+
24
  // Make sure that we autoload all dependencies if running via Composer.
25
+ if (PHP_VERSION_ID >= 50302) {
26
  if (file_exists($a = dirname(__FILE__).'/../../../autoload.php') === true) {
27
  include_once $a;
28
  } else if (file_exists($a = dirname(__FILE__).'/../vendor/autoload.php') === true) {
252
  public function checkRequirements()
253
  {
254
  // Check the PHP version.
255
+ if (PHP_VERSION_ID < 50102) {
256
  echo 'ERROR: PHP_CodeSniffer requires PHP version 5.1.2 or greater.'.PHP_EOL;
257
  exit(2);
258
  }
406
  $handle = fopen('php://stdin', 'r');
407
  if (stream_set_blocking($handle, false) === true) {
408
  $fileContents = '';
409
+ while (($line = fgets($handle)) !== false) {
410
  $fileContents .= $line;
411
  usleep(10);
412
  }
433
  public function setCommandLineValues($args)
434
  {
435
  if (defined('PHP_CODESNIFFER_IN_TESTS') === true) {
436
+ $this->values = array(
437
+ 'stdin' => null,
438
+ 'quiet' => true,
439
+ );
440
  } else if (empty($this->values) === true) {
441
  $this->values = $this->getDefaults();
442
  }
684
 
685
  $this->values['bootstrap'][] = $path;
686
  }
687
+ } else if (substr($arg, 0, 10) === 'file-list=') {
688
+ $fileList = substr($arg, 10);
689
+ $path = PHP_CodeSniffer::realpath($fileList);
690
+ if ($path === false) {
691
+ echo 'ERROR: The specified file list "'.$file.'" does not exist'.PHP_EOL.PHP_EOL;
692
+ $this->printUsage();
693
+ exit(2);
694
+ }
695
+
696
+ $files = file($path);
697
+ foreach ($files as $inputFile) {
698
+ $inputFile = trim($inputFile);
699
+
700
+ // Skip empty lines.
701
+ if ($inputFile === '') {
702
+ continue;
703
+ }
704
+
705
+ $realFile = PHP_CodeSniffer::realpath($inputFile);
706
+ if ($realFile === false) {
707
+ echo 'ERROR: The specified file "'.$inputFile.'" does not exist'.PHP_EOL.PHP_EOL;
708
+ $this->printUsage();
709
+ exit(2);
710
+ }
711
+
712
+ $this->values['files'][] = $realFile;
713
+ }
714
  } else if (substr($arg, 0, 11) === 'stdin-path=') {
715
  $this->values['stdinPath'] = PHP_CodeSniffer::realpath(substr($arg, 11));
716
 
736
  // Passed report file is a file in the current directory.
737
  $this->values['reportFile'] = getcwd().'/'.basename($this->values['reportFile']);
738
  } else {
739
+ if ($dir{0} === '/') {
740
+ // An absolute path.
741
+ $dir = PHP_CodeSniffer::realpath($dir);
742
+ } else {
743
+ $dir = PHP_CodeSniffer::realpath(getcwd().'/'.$dir);
744
+ }
745
+
746
  if ($dir !== false) {
747
  // Report file path is relative.
748
  $this->values['reportFile'] = $dir.'/'.basename($this->values['reportFile']);
777
  // Passed report file is a filename in the current directory.
778
  $output = getcwd().'/'.basename($output);
779
  } else {
780
+ if ($dir{0} === '/') {
781
+ // An absolute path.
782
+ $dir = PHP_CodeSniffer::realpath($dir);
783
+ } else {
784
+ $dir = PHP_CodeSniffer::realpath(getcwd().'/'.$dir);
785
+ }
786
+
787
  if ($dir !== false) {
788
  // Report file path is relative.
789
  $output = $dir.'/'.basename($output);
1013
  $this->printUsage();
1014
  exit(2);
1015
  } else {
1016
+ $this->values['stdin'] = $fileContents;
1017
  $phpcs->processFile('STDIN', $fileContents);
1018
  }
1019
  }
1306
  echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
1307
  echo ' [--runtime-set key value] [--config-set key value] [--config-delete key] [--config-show]'.PHP_EOL;
1308
  echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>] [--encoding=<encoding>]'.PHP_EOL;
1309
+ echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--bootstrap=<bootstrap>]'.PHP_EOL;
1310
+ echo ' [--file-list=<fileList>] <file> ...'.PHP_EOL;
1311
  echo ' Set runtime value (see --config-set) '.PHP_EOL;
1312
  echo ' -n Do not print warnings (shortcut for --warning-severity=0)'.PHP_EOL;
1313
  echo ' -w Print both warnings and errors (this is the default)'.PHP_EOL;
1325
  echo ' --colors Use colors in output'.PHP_EOL;
1326
  echo ' --no-colors Do not use colors in output (this is the default)'.PHP_EOL;
1327
  echo ' <file> One or more files and/or directories to check'.PHP_EOL;
1328
+ echo ' <fileList> A file containing a list of files and/or directories to check (one per line)'.PHP_EOL;
1329
  echo ' <stdinPath> If processing STDIN, the file path that STDIN will be processed as '.PHP_EOL;
1330
  echo ' <bootstrap> A comma separated list of files to run before processing starts'.PHP_EOL;
1331
  echo ' <encoding> The encoding of the files being checked (default is iso-8859-1)'.PHP_EOL;
1363
  echo ' [--standard=<standard>] [--sniffs=<sniffs>] [--exclude=<sniffs>] [--suffix=<suffix>]'.PHP_EOL;
1364
  echo ' [--severity=<severity>] [--error-severity=<severity>] [--warning-severity=<severity>]'.PHP_EOL;
1365
  echo ' [--tab-width=<tabWidth>] [--encoding=<encoding>]'.PHP_EOL;
1366
+ echo ' [--extensions=<extensions>] [--ignore=<patterns>] [--bootstrap=<bootstrap>]'.PHP_EOL;
1367
+ echo ' [--file-list=<fileList>] <file> ...'.PHP_EOL;
1368
  echo ' -n Do not fix warnings (shortcut for --warning-severity=0)'.PHP_EOL;
1369
  echo ' -w Fix both warnings and errors (on by default)'.PHP_EOL;
1370
  echo ' -l Local directory only, no recursion'.PHP_EOL;
1374
  echo ' --version Print version information'.PHP_EOL;
1375
  echo ' --no-patch Do not make use of the "diff" or "patch" programs'.PHP_EOL;
1376
  echo ' <file> One or more files and/or directories to fix'.PHP_EOL;
1377
+ echo ' <fileList> A file containing a list of files and/or directories to fix (one per line)'.PHP_EOL;
1378
  echo ' <stdinPath> If processing STDIN, the file path that STDIN will be processed as '.PHP_EOL;
1379
  echo ' <bootstrap> A comma separated list of files to run before processing starts'.PHP_EOL;
1380
  echo ' <encoding> The encoding of the files being fixed (default is iso-8859-1)'.PHP_EOL;
vendor/squizlabs/php_codesniffer/CodeSniffer/File.php CHANGED
@@ -507,8 +507,11 @@ class PHP_CodeSniffer_File
507
  if (count($parts) >= 3
508
  && isset($this->phpcs->sniffCodes[$parts[0]]) === true
509
  ) {
510
- $listenerClass = $this->phpcs->sniffCodes[$parts[0]];
511
- $this->phpcs->setSniffProperty($listenerClass, $parts[1], $parts[2]);
 
 
 
512
  }
513
  }//end if
514
  }//end if
@@ -599,7 +602,10 @@ class PHP_CodeSniffer_File
599
  // If short open tags are off but the file being checked uses
600
  // short open tags, the whole content will be inline HTML
601
  // and nothing will be checked. So try and handle this case.
602
- if ($foundCode === false && $this->tokenizerType === 'PHP') {
 
 
 
603
  $shortTags = (bool) ini_get('short_open_tag');
604
  if ($shortTags === false) {
605
  $error = 'No PHP code was found in this file and short open tags are not allowed by this install of PHP. This file may be using short open tags but PHP does not allow them.';
@@ -1939,7 +1945,9 @@ class PHP_CodeSniffer_File
1939
  // scope tokens. E.g., if (1) 1; 1 ? (1 ? 1 : 1) : 1;
1940
  // If an IF statement below this one has an opener but no
1941
  // keyword, the opener will be incorrectly assigned to this IF statement.
1942
- if (($currType === T_IF || $currType === T_ELSE)
 
 
1943
  && $opener === null
1944
  && $tokens[$i]['code'] === T_SEMICOLON
1945
  ) {
@@ -2642,25 +2650,23 @@ class PHP_CodeSniffer_File
2642
 
2643
 
2644
  /**
2645
- * Returns the declaration names for T_CLASS, T_INTERFACE and T_FUNCTION tokens.
2646
  *
2647
  * @param int $stackPtr The position of the declaration token which
2648
  * declared the class, interface or function.
2649
  *
2650
  * @return string|null The name of the class, interface or function.
2651
- * or NULL if the function is a closure.
2652
  * @throws PHP_CodeSniffer_Exception If the specified token is not of type
2653
- * T_FUNCTION, T_CLASS or T_INTERFACE.
 
2654
  */
2655
  public function getDeclarationName($stackPtr)
2656
  {
2657
  $tokenCode = $this->_tokens[$stackPtr]['code'];
2658
- if ($tokenCode !== T_FUNCTION
2659
- && $tokenCode !== T_CLASS
2660
- && $tokenCode !== T_INTERFACE
2661
- && $tokenCode !== T_TRAIT
2662
- ) {
2663
- throw new PHP_CodeSniffer_Exception('Token type "'.$this->_tokens[$stackPtr]['type'].'" is not T_FUNCTION, T_CLASS, T_INTERFACE or T_TRAIT');
2664
  }
2665
 
2666
  if ($tokenCode === T_FUNCTION
@@ -2669,6 +2675,14 @@ class PHP_CodeSniffer_File
2669
  return null;
2670
  }
2671
 
 
 
 
 
 
 
 
 
2672
  $content = null;
2673
  for ($i = $stackPtr; $i < $this->numTokens; $i++) {
2674
  if ($this->_tokens[$i]['code'] === T_STRING) {
@@ -2728,32 +2742,37 @@ class PHP_CodeSniffer_File
2728
 
2729
 
2730
  /**
2731
- * Returns the method parameters for the specified T_FUNCTION token.
2732
  *
2733
  * Each parameter is in the following format:
2734
  *
2735
  * <code>
2736
  * 0 => array(
 
2737
  * 'name' => '$var', // The variable name.
2738
- * 'pass_by_reference' => false, // Passed by reference.
2739
- * 'type_hint' => string, // Type hint for array or custom type
 
 
2740
  * )
2741
  * </code>
2742
  *
2743
  * Parameters with default values have an additional array index of
2744
  * 'default' with the value of the default as a string.
2745
  *
2746
- * @param int $stackPtr The position in the stack of the T_FUNCTION token
2747
  * to acquire the parameters for.
2748
  *
2749
  * @return array
2750
  * @throws PHP_CodeSniffer_Exception If the specified $stackPtr is not of
2751
- * type T_FUNCTION.
2752
  */
2753
  public function getMethodParameters($stackPtr)
2754
  {
2755
- if ($this->_tokens[$stackPtr]['code'] !== T_FUNCTION) {
2756
- throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_FUNCTION');
 
 
2757
  }
2758
 
2759
  $opener = $this->_tokens[$stackPtr]['parenthesis_opener'];
@@ -2761,13 +2780,15 @@ class PHP_CodeSniffer_File
2761
 
2762
  $vars = array();
2763
  $currVar = null;
 
2764
  $defaultStart = null;
2765
  $paramCount = 0;
2766
  $passByReference = false;
2767
  $variableLength = false;
2768
  $typeHint = '';
 
2769
 
2770
- for ($i = ($opener + 1); $i <= $closer; $i++) {
2771
  // Check to see if this token has a parenthesis or bracket opener. If it does
2772
  // it's likely to be an array which might have arguments in it. This
2773
  // could cause problems in our parsing below, so lets just skip to the
@@ -2798,7 +2819,15 @@ class PHP_CodeSniffer_File
2798
  break;
2799
  case T_ARRAY_HINT:
2800
  case T_CALLABLE:
2801
- $typeHint = $this->_tokens[$i]['content'];
 
 
 
 
 
 
 
 
2802
  break;
2803
  case T_STRING:
2804
  // This is a string, so it may be a type hint, but it could
@@ -2835,6 +2864,12 @@ class PHP_CodeSniffer_File
2835
  $typeHint .= $this->_tokens[$i]['content'];
2836
  }
2837
  break;
 
 
 
 
 
 
2838
  case T_CLOSE_PARENTHESIS:
2839
  case T_COMMA:
2840
  // If it's null, then there must be no parameters for this
@@ -2843,26 +2878,27 @@ class PHP_CodeSniffer_File
2843
  continue;
2844
  }
2845
 
2846
- $vars[$paramCount] = array();
2847
- $vars[$paramCount]['name'] = $this->_tokens[$currVar]['content'];
 
 
2848
 
2849
  if ($defaultStart !== null) {
2850
- $vars[$paramCount]['default']
2851
- = $this->getTokensAsString(
2852
- $defaultStart,
2853
- ($i - $defaultStart)
2854
- );
2855
  }
2856
 
2857
  $vars[$paramCount]['pass_by_reference'] = $passByReference;
2858
  $vars[$paramCount]['variable_length'] = $variableLength;
2859
  $vars[$paramCount]['type_hint'] = $typeHint;
 
2860
 
2861
  // Reset the vars, as we are about to process the next parameter.
2862
  $defaultStart = null;
 
2863
  $passByReference = false;
2864
  $variableLength = false;
2865
  $typeHint = '';
 
2866
 
2867
  $paramCount++;
2868
  break;
@@ -2997,6 +3033,7 @@ class PHP_CodeSniffer_File
2997
  $ptr = array_pop($conditions);
2998
  if (isset($this->_tokens[$ptr]) === false
2999
  || ($this->_tokens[$ptr]['code'] !== T_CLASS
 
3000
  && $this->_tokens[$ptr]['code'] !== T_TRAIT)
3001
  ) {
3002
  if (isset($this->_tokens[$ptr]) === true
@@ -3500,6 +3537,7 @@ class PHP_CodeSniffer_File
3500
  if ($this->_tokens[$i]['code'] === T_CLOSE_PARENTHESIS
3501
  || $this->_tokens[$i]['code'] === T_CLOSE_SQUARE_BRACKET
3502
  || $this->_tokens[$i]['code'] === T_CLOSE_CURLY_BRACKET
 
3503
  || $this->_tokens[$i]['code'] === T_OPEN_TAG
3504
  || $this->_tokens[$i]['code'] === T_CLOSE_TAG
3505
  ) {
@@ -3679,7 +3717,9 @@ class PHP_CodeSniffer_File
3679
  return false;
3680
  }
3681
 
3682
- if ($this->_tokens[$stackPtr]['code'] !== T_CLASS) {
 
 
3683
  return false;
3684
  }
3685
 
@@ -3712,4 +3752,58 @@ class PHP_CodeSniffer_File
3712
  }//end findExtendedClassName()
3713
 
3714
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3715
  }//end class
507
  if (count($parts) >= 3
508
  && isset($this->phpcs->sniffCodes[$parts[0]]) === true
509
  ) {
510
+ $listenerCode = array_shift($parts);
511
+ $propertyCode = array_shift($parts);
512
+ $propertyValue = rtrim(implode(' ', $parts), " */\r\n");
513
+ $listenerClass = $this->phpcs->sniffCodes[$listenerCode];
514
+ $this->phpcs->setSniffProperty($listenerClass, $propertyCode, $propertyValue);
515
  }
516
  }//end if
517
  }//end if
602
  // If short open tags are off but the file being checked uses
603
  // short open tags, the whole content will be inline HTML
604
  // and nothing will be checked. So try and handle this case.
605
+ // We don't show this error for STDIN because we can't be sure the content
606
+ // actually came directly from the user. It could be something like
607
+ // refs from a Git pre-push hook.
608
+ if ($foundCode === false && $this->tokenizerType === 'PHP' && $this->_file !== 'STDIN') {
609
  $shortTags = (bool) ini_get('short_open_tag');
610
  if ($shortTags === false) {
611
  $error = 'No PHP code was found in this file and short open tags are not allowed by this install of PHP. This file may be using short open tags but PHP does not allow them.';
1945
  // scope tokens. E.g., if (1) 1; 1 ? (1 ? 1 : 1) : 1;
1946
  // If an IF statement below this one has an opener but no
1947
  // keyword, the opener will be incorrectly assigned to this IF statement.
1948
+ // The same case also applies to USE statements, which don't have to have
1949
+ // openers, so a following USE statement can cause an incorrect brace match.
1950
+ if (($currType === T_IF || $currType === T_ELSE || $currType === T_USE)
1951
  && $opener === null
1952
  && $tokens[$i]['code'] === T_SEMICOLON
1953
  ) {
2650
 
2651
 
2652
  /**
2653
+ * Returns the declaration names for classes, interfaces, and functions.
2654
  *
2655
  * @param int $stackPtr The position of the declaration token which
2656
  * declared the class, interface or function.
2657
  *
2658
  * @return string|null The name of the class, interface or function.
2659
+ * or NULL if the function or class is anonymous.
2660
  * @throws PHP_CodeSniffer_Exception If the specified token is not of type
2661
+ * T_FUNCTION, T_CLASS, T_ANON_CLASS,
2662
+ * or T_INTERFACE.
2663
  */
2664
  public function getDeclarationName($stackPtr)
2665
  {
2666
  $tokenCode = $this->_tokens[$stackPtr]['code'];
2667
+
2668
+ if ($tokenCode === T_ANON_CLASS) {
2669
+ return null;
 
 
 
2670
  }
2671
 
2672
  if ($tokenCode === T_FUNCTION
2675
  return null;
2676
  }
2677
 
2678
+ if ($tokenCode !== T_FUNCTION
2679
+ && $tokenCode !== T_CLASS
2680
+ && $tokenCode !== T_INTERFACE
2681
+ && $tokenCode !== T_TRAIT
2682
+ ) {
2683
+ throw new PHP_CodeSniffer_Exception('Token type "'.$this->_tokens[$stackPtr]['type'].'" is not T_FUNCTION, T_CLASS, T_INTERFACE or T_TRAIT');
2684
+ }
2685
+
2686
  $content = null;
2687
  for ($i = $stackPtr; $i < $this->numTokens; $i++) {
2688
  if ($this->_tokens[$i]['code'] === T_STRING) {
2742
 
2743
 
2744
  /**
2745
+ * Returns the method parameters for the specified function token.
2746
  *
2747
  * Each parameter is in the following format:
2748
  *
2749
  * <code>
2750
  * 0 => array(
2751
+ * 'token' => int, // The position of the var in the token stack.
2752
  * 'name' => '$var', // The variable name.
2753
+ * 'content' => string, // The full content of the variable definition.
2754
+ * 'pass_by_reference' => boolean, // Is the variable passed by reference?
2755
+ * 'type_hint' => string, // The type hint for the variable.
2756
+ * 'nullable_type' => boolean, // Is the variable using a nullable type?
2757
  * )
2758
  * </code>
2759
  *
2760
  * Parameters with default values have an additional array index of
2761
  * 'default' with the value of the default as a string.
2762
  *
2763
+ * @param int $stackPtr The position in the stack of the function token
2764
  * to acquire the parameters for.
2765
  *
2766
  * @return array
2767
  * @throws PHP_CodeSniffer_Exception If the specified $stackPtr is not of
2768
+ * type T_FUNCTION or T_CLOSURE.
2769
  */
2770
  public function getMethodParameters($stackPtr)
2771
  {
2772
+ if ($this->_tokens[$stackPtr]['code'] !== T_FUNCTION
2773
+ && $this->_tokens[$stackPtr]['code'] !== T_CLOSURE
2774
+ ) {
2775
+ throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_FUNCTION or T_CLOSURE');
2776
  }
2777
 
2778
  $opener = $this->_tokens[$stackPtr]['parenthesis_opener'];
2780
 
2781
  $vars = array();
2782
  $currVar = null;
2783
+ $paramStart = ($opener + 1);
2784
  $defaultStart = null;
2785
  $paramCount = 0;
2786
  $passByReference = false;
2787
  $variableLength = false;
2788
  $typeHint = '';
2789
+ $nullableType = false;
2790
 
2791
+ for ($i = $paramStart; $i <= $closer; $i++) {
2792
  // Check to see if this token has a parenthesis or bracket opener. If it does
2793
  // it's likely to be an array which might have arguments in it. This
2794
  // could cause problems in our parsing below, so lets just skip to the
2819
  break;
2820
  case T_ARRAY_HINT:
2821
  case T_CALLABLE:
2822
+ $typeHint .= $this->_tokens[$i]['content'];
2823
+ break;
2824
+ case T_SELF:
2825
+ case T_PARENT:
2826
+ case T_STATIC:
2827
+ // Self is valid, the others invalid, but were probably intended as type hints.
2828
+ if (isset($defaultStart) === false) {
2829
+ $typeHint .= $this->_tokens[$i]['content'];
2830
+ }
2831
  break;
2832
  case T_STRING:
2833
  // This is a string, so it may be a type hint, but it could
2864
  $typeHint .= $this->_tokens[$i]['content'];
2865
  }
2866
  break;
2867
+ case T_NULLABLE:
2868
+ if ($defaultStart === null) {
2869
+ $nullableType = true;
2870
+ $typeHint .= $this->_tokens[$i]['content'];
2871
+ }
2872
+ break;
2873
  case T_CLOSE_PARENTHESIS:
2874
  case T_COMMA:
2875
  // If it's null, then there must be no parameters for this
2878
  continue;
2879
  }
2880
 
2881
+ $vars[$paramCount] = array();
2882
+ $vars[$paramCount]['token'] = $currVar;
2883
+ $vars[$paramCount]['name'] = $this->_tokens[$currVar]['content'];
2884
+ $vars[$paramCount]['content'] = trim($this->getTokensAsString($paramStart, ($i - $paramStart)));
2885
 
2886
  if ($defaultStart !== null) {
2887
+ $vars[$paramCount]['default'] = trim($this->getTokensAsString($defaultStart, ($i - $defaultStart)));
 
 
 
 
2888
  }
2889
 
2890
  $vars[$paramCount]['pass_by_reference'] = $passByReference;
2891
  $vars[$paramCount]['variable_length'] = $variableLength;
2892
  $vars[$paramCount]['type_hint'] = $typeHint;
2893
+ $vars[$paramCount]['nullable_type'] = $nullableType;
2894
 
2895
  // Reset the vars, as we are about to process the next parameter.
2896
  $defaultStart = null;
2897
+ $paramStart = ($i + 1);
2898
  $passByReference = false;
2899
  $variableLength = false;
2900
  $typeHint = '';
2901
+ $nullableType = false;
2902
 
2903
  $paramCount++;
2904
  break;
3033
  $ptr = array_pop($conditions);
3034
  if (isset($this->_tokens[$ptr]) === false
3035
  || ($this->_tokens[$ptr]['code'] !== T_CLASS
3036
+ && $this->_tokens[$ptr]['code'] !== T_ANON_CLASS
3037
  && $this->_tokens[$ptr]['code'] !== T_TRAIT)
3038
  ) {
3039
  if (isset($this->_tokens[$ptr]) === true
3537
  if ($this->_tokens[$i]['code'] === T_CLOSE_PARENTHESIS
3538
  || $this->_tokens[$i]['code'] === T_CLOSE_SQUARE_BRACKET
3539
  || $this->_tokens[$i]['code'] === T_CLOSE_CURLY_BRACKET
3540
+ || $this->_tokens[$i]['code'] === T_CLOSE_SHORT_ARRAY
3541
  || $this->_tokens[$i]['code'] === T_OPEN_TAG
3542
  || $this->_tokens[$i]['code'] === T_CLOSE_TAG
3543
  ) {
3717
  return false;
3718
  }
3719
 
3720
+ if ($this->_tokens[$stackPtr]['code'] !== T_CLASS
3721
+ && $this->_tokens[$stackPtr]['code'] !== T_ANON_CLASS
3722
+ ) {
3723
  return false;
3724
  }
3725
 
3752
  }//end findExtendedClassName()
3753
 
3754
 
3755
+ /**
3756
+ * Returns the name(s) of the interface(s) that the specified class implements.
3757
+ *
3758
+ * Returns FALSE on error or if there are no implemented interface names.
3759
+ *
3760
+ * @param int $stackPtr The stack position of the class.
3761
+ *
3762
+ * @return array|false
3763
+ */
3764
+ public function findImplementedInterfaceNames($stackPtr)
3765
+ {
3766
+ // Check for the existence of the token.
3767
+ if (isset($this->_tokens[$stackPtr]) === false) {
3768
+ return false;
3769
+ }
3770
+
3771
+ if ($this->_tokens[$stackPtr]['code'] !== T_CLASS
3772
+ && $this->_tokens[$stackPtr]['code'] !== T_ANON_CLASS
3773
+ ) {
3774
+ return false;
3775
+ }
3776
+
3777
+ if (isset($this->_tokens[$stackPtr]['scope_closer']) === false) {
3778
+ return false;
3779
+ }
3780
+
3781
+ $classOpenerIndex = $this->_tokens[$stackPtr]['scope_opener'];
3782
+ $implementsIndex = $this->findNext(T_IMPLEMENTS, $stackPtr, $classOpenerIndex);
3783
+ if ($implementsIndex === false) {
3784
+ return false;
3785
+ }
3786
+
3787
+ $find = array(
3788
+ T_NS_SEPARATOR,
3789
+ T_STRING,
3790
+ T_WHITESPACE,
3791
+ T_COMMA,
3792
+ );
3793
+
3794
+ $end = $this->findNext($find, ($implementsIndex + 1), ($classOpenerIndex + 1), true);
3795
+ $name = $this->getTokensAsString(($implementsIndex + 1), ($end - $implementsIndex - 1));
3796
+ $name = trim($name);
3797
+
3798
+ if ($name === '') {
3799
+ return false;
3800
+ } else {
3801
+ $names = explode(',', $name);
3802
+ $names = array_map('trim', $names);
3803
+ return $names;
3804
+ }
3805
+
3806
+ }//end findImplementedInterfaceNames()
3807
+
3808
+
3809
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Fixer.php CHANGED
@@ -243,8 +243,13 @@ class PHP_CodeSniffer_Fixer
243
  $filePath = $this->_currentFile->getFilename();
244
  }
245
 
246
- $cwd = getcwd().DIRECTORY_SEPARATOR;
247
- $filename = str_replace($cwd, '', $filePath);
 
 
 
 
 
248
  $contents = $this->getContents();
249
 
250
  if (function_exists('sys_get_temp_dir') === true) {
@@ -261,7 +266,9 @@ class PHP_CodeSniffer_Fixer
261
 
262
  // We must use something like shell_exec() because whitespace at the end
263
  // of lines is critical to diff files.
264
- $cmd = "diff -u -L\"$filename\" -LPHP_CodeSniffer \"$filename\" \"$tempName\"";
 
 
265
  $diff = shell_exec($cmd);
266
 
267
  fclose($fixedFile);
243
  $filePath = $this->_currentFile->getFilename();
244
  }
245
 
246
+ $cwd = getcwd().DIRECTORY_SEPARATOR;
247
+ if (strpos($filePath, $cwd) === 0) {
248
+ $filename = substr($filePath, strlen($cwd));
249
+ } else {
250
+ $filename = $filePath;
251
+ }
252
+
253
  $contents = $this->getContents();
254
 
255
  if (function_exists('sys_get_temp_dir') === true) {
266
 
267
  // We must use something like shell_exec() because whitespace at the end
268
  // of lines is critical to diff files.
269
+ $filename = escapeshellarg($filename);
270
+ $cmd = "diff -u -L$filename -LPHP_CodeSniffer $filename \"$tempName\"";
271
+
272
  $diff = shell_exec($cmd);
273
 
274
  fclose($fixedFile);
vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Gitblame.php CHANGED
@@ -83,29 +83,7 @@ class PHP_CodeSniffer_Reports_Gitblame extends PHP_CodeSniffer_Reports_VersionCo
83
  {
84
  $cwd = getcwd();
85
 
86
- if (PHP_CODESNIFFER_VERBOSITY > 0) {
87
- echo 'Getting GIT blame info for '.basename($filename).'... ';
88
- }
89
-
90
- $fileParts = explode(DIRECTORY_SEPARATOR, $filename);
91
- $found = false;
92
- $location = '';
93
- while (empty($fileParts) === false) {
94
- array_pop($fileParts);
95
- $location = implode($fileParts, DIRECTORY_SEPARATOR);
96
- if (is_dir($location.DIRECTORY_SEPARATOR.'.git') === true) {
97
- $found = true;
98
- break;
99
- }
100
- }
101
-
102
- if ($found === true) {
103
- chdir($location);
104
- } else {
105
- echo 'ERROR: Could not locate .git directory '.PHP_EOL.PHP_EOL;
106
- exit(2);
107
- }
108
-
109
  $command = 'git blame --date=short "'.$filename.'" 2>&1';
110
  $handle = popen($command, 'r');
111
  if ($handle === false) {
@@ -116,10 +94,6 @@ class PHP_CodeSniffer_Reports_Gitblame extends PHP_CodeSniffer_Reports_VersionCo
116
  $rawContent = stream_get_contents($handle);
117
  fclose($handle);
118
 
119
- if (PHP_CODESNIFFER_VERBOSITY > 0) {
120
- echo 'DONE'.PHP_EOL;
121
- }
122
-
123
  $blames = explode("\n", $rawContent);
124
  chdir($cwd);
125
 
83
  {
84
  $cwd = getcwd();
85
 
86
+ chdir(dirname($filename));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  $command = 'git blame --date=short "'.$filename.'" 2>&1';
88
  $handle = popen($command, 'r');
89
  if ($handle === false) {
94
  $rawContent = stream_get_contents($handle);
95
  fclose($handle);
96
 
 
 
 
 
97
  $blames = explode("\n", $rawContent);
98
  chdir($cwd);
99
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Hgblame.php CHANGED
@@ -84,10 +84,6 @@ class PHP_CodeSniffer_Reports_Hgblame extends PHP_CodeSniffer_Reports_VersionCon
84
  {
85
  $cwd = getcwd();
86
 
87
- if (PHP_CODESNIFFER_VERBOSITY > 0) {
88
- echo 'Getting MERCURIAL blame info for '.basename($filename).'... ';
89
- }
90
-
91
  $fileParts = explode(DIRECTORY_SEPARATOR, $filename);
92
  $found = false;
93
  $location = '';
@@ -117,10 +113,6 @@ class PHP_CodeSniffer_Reports_Hgblame extends PHP_CodeSniffer_Reports_VersionCon
117
  $rawContent = stream_get_contents($handle);
118
  fclose($handle);
119
 
120
- if (PHP_CODESNIFFER_VERBOSITY > 0) {
121
- echo 'DONE'.PHP_EOL;
122
- }
123
-
124
  $blames = explode("\n", $rawContent);
125
  chdir($cwd);
126
 
84
  {
85
  $cwd = getcwd();
86
 
 
 
 
 
87
  $fileParts = explode(DIRECTORY_SEPARATOR, $filename);
88
  $found = false;
89
  $location = '';
113
  $rawContent = stream_get_contents($handle);
114
  fclose($handle);
115
 
 
 
 
 
116
  $blames = explode("\n", $rawContent);
117
  chdir($cwd);
118
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Notifysend.php CHANGED
@@ -82,7 +82,7 @@ class PHP_CodeSniffer_Reports_Notifysend implements PHP_CodeSniffer_Report
82
  {
83
  $path = PHP_CodeSniffer::getConfigData('notifysend_path');
84
  if ($path !== null) {
85
- $this->path = $path;
86
  }
87
 
88
  $timeout = PHP_CodeSniffer::getConfigData('notifysend_timeout');
@@ -246,7 +246,7 @@ class PHP_CodeSniffer_Reports_Notifysend implements PHP_CodeSniffer_Report
246
  */
247
  protected function getBasicCommand()
248
  {
249
- $cmd = escapeshellcmd($this->path);
250
  $cmd .= ' --category dev.validate';
251
  $cmd .= ' -h int:transient:1';
252
  $cmd .= ' -t '.(int) $this->timeout;
82
  {
83
  $path = PHP_CodeSniffer::getConfigData('notifysend_path');
84
  if ($path !== null) {
85
+ $this->path = escapeshellcmd($path);
86
  }
87
 
88
  $timeout = PHP_CodeSniffer::getConfigData('notifysend_timeout');
246
  */
247
  protected function getBasicCommand()
248
  {
249
+ $cmd = $this->path;
250
  $cmd .= ' --category dev.validate';
251
  $cmd .= ' -h int:transient:1';
252
  $cmd .= ' -t '.(int) $this->timeout;
vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Svnblame.php CHANGED
@@ -70,10 +70,6 @@ class PHP_CodeSniffer_Reports_Svnblame extends PHP_CodeSniffer_Reports_VersionCo
70
  */
71
  protected function getBlameContent($filename)
72
  {
73
- if (PHP_CODESNIFFER_VERBOSITY > 0) {
74
- echo 'Getting SVN blame info for '.basename($filename).'... ';
75
- }
76
-
77
  $command = 'svn blame "'.$filename.'" 2>&1';
78
  $handle = popen($command, 'r');
79
  if ($handle === false) {
@@ -84,10 +80,6 @@ class PHP_CodeSniffer_Reports_Svnblame extends PHP_CodeSniffer_Reports_VersionCo
84
  $rawContent = stream_get_contents($handle);
85
  fclose($handle);
86
 
87
- if (PHP_CODESNIFFER_VERBOSITY > 0) {
88
- echo 'DONE'.PHP_EOL;
89
- }
90
-
91
  $blames = explode("\n", $rawContent);
92
 
93
  return $blames;
70
  */
71
  protected function getBlameContent($filename)
72
  {
 
 
 
 
73
  $command = 'svn blame "'.$filename.'" 2>&1';
74
  $handle = popen($command, 'r');
75
  if ($handle === false) {
80
  $rawContent = stream_get_contents($handle);
81
  fclose($handle);
82
 
 
 
 
 
83
  $blames = explode("\n", $rawContent);
84
 
85
  return $blames;
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractScopeSniff.php CHANGED
@@ -101,7 +101,7 @@ abstract class PHP_CodeSniffer_Standards_AbstractScopeSniff implements PHP_CodeS
101
  $invalidScopeTokens = array_intersect($scopeTokens, $tokens);
102
  if (empty($invalidScopeTokens) === false) {
103
  $invalid = implode(', ', $invalidScopeTokens);
104
- $error = "Scope tokens [$invalid] cant be in the tokens array";
105
  throw new PHP_CodeSniffer_Exception($error);
106
  }
107
 
@@ -179,7 +179,7 @@ abstract class PHP_CodeSniffer_Standards_AbstractScopeSniff implements PHP_CodeS
179
 
180
 
181
  /**
182
- * Processes a token that is found within the scope that this test is
183
  * listening to.
184
  *
185
  * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
101
  $invalidScopeTokens = array_intersect($scopeTokens, $tokens);
102
  if (empty($invalidScopeTokens) === false) {
103
  $invalid = implode(', ', $invalidScopeTokens);
104
+ $error = "Scope tokens [$invalid] can't be in the tokens array";
105
  throw new PHP_CodeSniffer_Exception($error);
106
  }
107
 
179
 
180
 
181
  /**
182
+ * Processes a token that is found outside the scope that this test is
183
  * listening to.
184
  *
185
  * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractVariableSniff.php CHANGED
@@ -22,7 +22,7 @@ if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false
22
  * A class to find T_VARIABLE tokens.
23
  *
24
  * This class can distinguish between normal T_VARIABLE tokens, and those tokens
25
- * that represent class members. If a class member is encountered, then then
26
  * processMemberVar method is called so the extending class can process it. If
27
  * the token is found to be a normal T_VARIABLE token, then processVariable is
28
  * called.
@@ -68,6 +68,7 @@ abstract class PHP_CodeSniffer_Standards_AbstractVariableSniff extends PHP_CodeS
68
  {
69
  $scopes = array(
70
  T_CLASS,
 
71
  T_TRAIT,
72
  T_INTERFACE,
73
  );
22
  * A class to find T_VARIABLE tokens.
23
  *
24
  * This class can distinguish between normal T_VARIABLE tokens, and those tokens
25
+ * that represent class members. If a class member is encountered, then the
26
  * processMemberVar method is called so the extending class can process it. If
27
  * the token is found to be a normal T_VARIABLE token, then processVariable is
28
  * called.
68
  {
69
  $scopes = array(
70
  T_CLASS,
71
+ T_ANON_CLASS,
72
  T_TRAIT,
73
  T_INTERFACE,
74
  );
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php CHANGED
@@ -31,7 +31,7 @@ class Generic_Sniffs_Classes_DuplicateClassNameSniff implements PHP_CodeSniffer_
31
  *
32
  * @var array
33
  */
34
- public $foundClasses = array();
35
 
36
 
37
  /**
31
  *
32
  * @var array
33
  */
34
+ protected $foundClasses = array();
35
 
36
 
37
  /**
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php CHANGED
@@ -42,7 +42,10 @@ class Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff implements PHP_Co
42
  */
43
  public function register()
44
  {
45
- return array(T_FUNCTION);
 
 
 
46
 
47
  }//end register()
48
 
42
  */
43
  public function register()
44
  {
45
+ return array(
46
+ T_FUNCTION,
47
+ T_CLOSURE,
48
+ );
49
 
50
  }//end register()
51
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php CHANGED
@@ -124,12 +124,6 @@ class Generic_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_Co
124
  return;
125
  }
126
 
127
- $validParameterTypes = array(
128
- T_VARIABLE,
129
- T_LNUMBER,
130
- T_CONSTANT_ENCAPSED_STRING,
131
- );
132
-
133
  $parameters = array('');
134
  $parenthesisCount = 1;
135
  $count = count($tokens);
124
  return;
125
  }
126
 
 
 
 
 
 
 
127
  $parameters = array('');
128
  $parenthesisCount = 1;
129
  $count = count($tokens);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php CHANGED
@@ -179,7 +179,7 @@ class Generic_Sniffs_ControlStructures_InlineControlStructureSniff implements PH
179
  if (isset($tokens[$end]['scope_opener']) === true) {
180
  $type = $tokens[$end]['code'];
181
  $end = $tokens[$end]['scope_closer'];
182
- if ($type === T_DO || $type === T_IF || $type === T_ELSEIF) {
183
  $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($end + 1), null, true);
184
  if ($next === false) {
185
  break;
@@ -200,43 +200,104 @@ class Generic_Sniffs_ControlStructures_InlineControlStructureSniff implements PH
200
  if ($type === T_DO && $nextType === T_WHILE) {
201
  $end = $phpcsFile->findNext(T_SEMICOLON, ($next + 1));
202
  }
 
 
 
 
 
203
  }//end if
204
 
205
- break;
 
 
 
 
206
  }//end if
207
 
 
 
 
 
 
 
208
  if ($tokens[$end]['code'] !== T_WHITESPACE) {
209
  $lastNonEmpty = $end;
210
  }
211
  }//end for
212
 
213
- $next = $phpcsFile->findNext(T_WHITESPACE, ($closer + 1), ($end + 1), true);
 
 
 
 
214
 
215
- // Account for a comment on the end of the line.
216
- for ($endLine = $end; $endLine < $phpcsFile->numTokens; $endLine++) {
217
- if (isset($tokens[($endLine + 1)]) === false
218
- || $tokens[$endLine]['line'] !== $tokens[($endLine + 1)]['line']
219
- ) {
220
- break;
 
 
 
 
 
221
  }
222
- }
223
 
224
- if ($tokens[$endLine]['code'] !== T_COMMENT) {
 
 
 
 
225
  $endLine = $end;
226
  }
227
 
228
  if ($next !== $end) {
229
  if ($endLine !== $end) {
230
- $phpcsFile->fixer->addContent($endLine, '}');
 
231
  } else {
 
 
 
232
  if ($tokens[$end]['code'] !== T_SEMICOLON
233
  && $tokens[$end]['code'] !== T_CLOSE_CURLY_BRACKET
234
  ) {
235
- $phpcsFile->fixer->addContent($end, ';');
236
  }
237
-
238
- $phpcsFile->fixer->addContent($end, ' }');
239
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  } else {
241
  if ($endLine !== $end) {
242
  $phpcsFile->fixer->replaceToken($end, '');
179
  if (isset($tokens[$end]['scope_opener']) === true) {
180
  $type = $tokens[$end]['code'];
181
  $end = $tokens[$end]['scope_closer'];
182
+ if ($type === T_DO || $type === T_IF || $type === T_ELSEIF || $type === T_TRY) {
183
  $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($end + 1), null, true);
184
  if ($next === false) {
185
  break;
200
  if ($type === T_DO && $nextType === T_WHILE) {
201
  $end = $phpcsFile->findNext(T_SEMICOLON, ($next + 1));
202
  }
203
+
204
+ // Account for TRY... CATCH statements.
205
+ if ($type === T_TRY && $nextType === T_CATCH) {
206
+ $end = $tokens[$next]['scope_closer'];
207
+ }
208
  }//end if
209
 
210
+ if ($tokens[$end]['code'] !== T_END_HEREDOC
211
+ && $tokens[$end]['code'] !== T_END_NOWDOC
212
+ ) {
213
+ break;
214
+ }
215
  }//end if
216
 
217
+ if (isset($tokens[$end]['parenthesis_closer']) === true) {
218
+ $end = $tokens[$end]['parenthesis_closer'];
219
+ $lastNonEmpty = $end;
220
+ continue;
221
+ }
222
+
223
  if ($tokens[$end]['code'] !== T_WHITESPACE) {
224
  $lastNonEmpty = $end;
225
  }
226
  }//end for
227
 
228
+ if ($end === $phpcsFile->numTokens) {
229
+ $end = $lastNonEmpty;
230
+ }
231
+
232
+ $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($end + 1), null, true);
233
 
234
+ if ($next === false || $tokens[$next]['line'] !== $tokens[$end]['line']) {
235
+ // Looks for completely empty statements.
236
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($closer + 1), ($end + 1), true);
237
+
238
+ // Account for a comment on the end of the line.
239
+ for ($endLine = $end; $endLine < $phpcsFile->numTokens; $endLine++) {
240
+ if (isset($tokens[($endLine + 1)]) === false
241
+ || $tokens[$endLine]['line'] !== $tokens[($endLine + 1)]['line']
242
+ ) {
243
+ break;
244
+ }
245
  }
 
246
 
247
+ if ($tokens[$endLine]['code'] !== T_COMMENT) {
248
+ $endLine = $end;
249
+ }
250
+ } else {
251
+ $next = ($end + 1);
252
  $endLine = $end;
253
  }
254
 
255
  if ($next !== $end) {
256
  if ($endLine !== $end) {
257
+ $endToken = $endLine;
258
+ $addedContent = '';
259
  } else {
260
+ $endToken = $end;
261
+ $addedContent = $phpcsFile->eolChar;
262
+
263
  if ($tokens[$end]['code'] !== T_SEMICOLON
264
  && $tokens[$end]['code'] !== T_CLOSE_CURLY_BRACKET
265
  ) {
266
+ $phpcsFile->fixer->addContent($end, '; ');
267
  }
 
 
268
  }
269
+
270
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($endToken + 1), null, true);
271
+ if ($next !== false
272
+ && ($tokens[$next]['code'] === T_ELSE
273
+ || $tokens[$next]['code'] === T_ELSEIF)
274
+ ) {
275
+ $phpcsFile->fixer->addContentBefore($next, '} ');
276
+ } else {
277
+ $indent = '';
278
+ for ($first = $stackPtr; $first > 0; $first--) {
279
+ if ($first === 1
280
+ || $tokens[($first - 1)]['line'] !== $tokens[$first]['line']
281
+ ) {
282
+ break;
283
+ }
284
+ }
285
+
286
+ if ($tokens[$first]['code'] === T_WHITESPACE) {
287
+ $indent = $tokens[$first]['content'];
288
+ } else if ($tokens[$first]['code'] === T_INLINE_HTML
289
+ || $tokens[$first]['code'] === T_OPEN_TAG
290
+ ) {
291
+ $addedContent = '';
292
+ }
293
+
294
+ $addedContent .= $indent.'}';
295
+ if ($next !== false && $tokens[$endToken]['code'] === T_COMMENT) {
296
+ $addedContent .= $phpcsFile->eolChar;
297
+ }
298
+
299
+ $phpcsFile->fixer->addContent($endToken, $addedContent);
300
+ }//end if
301
  } else {
302
  if ($endLine !== $end) {
303
  $phpcsFile->fixer->replaceToken($end, '');
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/CSSLintSniff.php CHANGED
@@ -66,7 +66,7 @@ class Generic_Sniffs_Debug_CSSLintSniff implements PHP_CodeSniffer_Sniff
66
  return;
67
  }
68
 
69
- $cmd = $csslintPath.' '.escapeshellarg($fileName);
70
  exec($cmd, $output, $retval);
71
 
72
  if (is_array($output) === false) {
66
  return;
67
  }
68
 
69
+ $cmd = escapeshellcmd($csslintPath).' '.escapeshellarg($fileName).' 2>&1';
70
  exec($cmd, $output, $retval);
71
 
72
  if (is_array($output) === false) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php CHANGED
@@ -83,8 +83,9 @@ class Generic_Sniffs_Debug_ClosureLinterSniff implements PHP_CodeSniffer_Sniff
83
  return;
84
  }
85
 
86
- $cmd = "$lintPath --nosummary --notime --unix_mode \"$fileName\"";
87
- $msg = exec($cmd, $output, $retval);
 
88
 
89
  if (is_array($output) === false) {
90
  return;
83
  return;
84
  }
85
 
86
+ $lintPath = escapeshellcmd($lintPath);
87
+ $cmd = '$lintPath --nosummary --notime --unix_mode '.escapeshellarg($fileName);
88
+ $msg = exec($cmd, $output, $retval);
89
 
90
  if (is_array($output) === false) {
91
  return;
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php CHANGED
@@ -70,7 +70,10 @@ class Generic_Sniffs_Debug_JSHintSniff implements PHP_CodeSniffer_Sniff
70
  return;
71
  }
72
 
73
- $cmd = "$rhinoPath \"$jshintPath\" \"$fileName\"";
 
 
 
74
  $msg = exec($cmd, $output, $retval);
75
 
76
  if (is_array($output) === true) {
70
  return;
71
  }
72
 
73
+ $rhinoPath = escapeshellcmd($rhinoPath);
74
+ $jshintPath = escapeshellcmd($jshintPath);
75
+
76
+ $cmd = "$rhinoPath \"$jshintPath\" ".escapeshellarg($fileName);
77
  $msg = exec($cmd, $output, $retval);
78
 
79
  if (is_array($output) === true) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php CHANGED
@@ -37,11 +37,11 @@ class Generic_Sniffs_Files_ByteOrderMarkSniff implements PHP_CodeSniffer_Sniff
37
  *
38
  * @var array
39
  */
40
- public $bomDefinitions = array(
41
- 'UTF-8' => 'efbbbf',
42
- 'UTF-16 (BE)' => 'feff',
43
- 'UTF-16 (LE)' => 'fffe',
44
- );
45
 
46
 
47
  /**
37
  *
38
  * @var array
39
  */
40
+ protected $bomDefinitions = array(
41
+ 'UTF-8' => 'efbbbf',
42
+ 'UTF-16 (BE)' => 'feff',
43
+ 'UTF-16 (LE)' => 'fffe',
44
+ );
45
 
46
 
47
  /**
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php CHANGED
@@ -67,7 +67,7 @@ class Generic_Sniffs_Files_EndFileNewlineSniff implements PHP_CodeSniffer_Sniff
67
  $tokens = $phpcsFile->getTokens();
68
  $stackPtr = ($phpcsFile->numTokens - 1);
69
 
70
- if ($phpcsFile->tokenizerType !== 'PHP') {
71
  $stackPtr--;
72
  }
73
 
67
  $tokens = $phpcsFile->getTokens();
68
  $stackPtr = ($phpcsFile->numTokens - 1);
69
 
70
+ if ($tokens[$stackPtr]['content'] === '') {
71
  $stackPtr--;
72
  }
73
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php CHANGED
@@ -67,7 +67,7 @@ class Generic_Sniffs_Files_EndFileNoNewlineSniff implements PHP_CodeSniffer_Snif
67
  $tokens = $phpcsFile->getTokens();
68
  $stackPtr = ($phpcsFile->numTokens - 1);
69
 
70
- if ($phpcsFile->tokenizerType !== 'PHP') {
71
  $stackPtr--;
72
  }
73
 
67
  $tokens = $phpcsFile->getTokens();
68
  $stackPtr = ($phpcsFile->numTokens - 1);
69
 
70
+ if ($tokens[$stackPtr]['content'] === '') {
71
  $stackPtr--;
72
  }
73
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php CHANGED
@@ -129,7 +129,13 @@ class Generic_Sniffs_Files_LineEndingsSniff implements PHP_CodeSniffer_Sniff
129
  || $tokens[($i + 1)]['line'] > $tokens[$i]['line']
130
  ) {
131
  // Token is the last on a line.
132
- $newContent = rtrim($tokens[$i]['content'], "\r\n");
 
 
 
 
 
 
133
  $newContent .= $eolChar;
134
  $phpcsFile->fixer->replaceToken($i, $newContent);
135
  }
129
  || $tokens[($i + 1)]['line'] > $tokens[$i]['line']
130
  ) {
131
  // Token is the last on a line.
132
+ if (isset($tokens[$i]['orig_content']) === true) {
133
+ $tokenContent = $tokens[$i]['orig_content'];
134
+ } else {
135
+ $tokenContent = $tokens[$i]['content'];
136
+ }
137
+
138
+ $newContent = rtrim($tokenContent, "\r\n");
139
  $newContent .= $eolChar;
140
  $phpcsFile->fixer->replaceToken($i, $newContent);
141
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php CHANGED
@@ -54,8 +54,11 @@ class Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff implements PHP_C
54
  {
55
  $tokens = $phpcsFile->getTokens();
56
 
57
- $prev = $phpcsFile->findPrevious(array(T_SEMICOLON, T_OPEN_TAG), ($stackPtr - 1));
58
- if ($prev === false || $tokens[$prev]['code'] === T_OPEN_TAG) {
 
 
 
59
  $phpcsFile->recordMetric($stackPtr, 'Multiple statements on same line', 'no');
60
  return;
61
  }
54
  {
55
  $tokens = $phpcsFile->getTokens();
56
 
57
+ $prev = $phpcsFile->findPrevious(array(T_SEMICOLON, T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO), ($stackPtr - 1));
58
+ if ($prev === false
59
+ || $tokens[$prev]['code'] === T_OPEN_TAG
60
+ || $tokens[$prev]['code'] === T_OPEN_TAG_WITH_ECHO
61
+ ) {
62
  $phpcsFile->recordMetric($stackPtr, 'Multiple statements on same line', 'no');
63
  return;
64
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php CHANGED
@@ -128,7 +128,7 @@ class Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff implements PHP_C
128
  for ($assign = $stackPtr; $assign < $phpcsFile->numTokens; $assign++) {
129
  if (isset($find[$tokens[$assign]['code']]) === false) {
130
  // A blank line indicates that the assignment block has ended.
131
- if (isset(PHP_CodeSniffer_tokens::$emptyTokens[$tokens[$assign]['code']]) === false) {
132
  if (($tokens[$assign]['line'] - $tokens[$lastCode]['line']) > 1) {
133
  break;
134
  }
128
  for ($assign = $stackPtr; $assign < $phpcsFile->numTokens; $assign++) {
129
  if (isset($find[$tokens[$assign]['code']]) === false) {
130
  // A blank line indicates that the assignment block has ended.
131
+ if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$assign]['code']]) === false) {
132
  if (($tokens[$assign]['line'] - $tokens[$lastCode]['line']) > 1) {
133
  break;
134
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php CHANGED
@@ -38,7 +38,12 @@ class Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff implements PHP_C
38
  */
39
  public function register()
40
  {
41
- return array(T_STRING);
 
 
 
 
 
42
 
43
  }//end register()
44
 
@@ -111,7 +116,8 @@ class Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff implements PHP_C
111
 
112
  if ($tokens[$nextSeparator]['code'] === T_COMMA) {
113
  if ($tokens[($nextSeparator - 1)]['code'] === T_WHITESPACE) {
114
- if (isset(PHP_CodeSniffer_Tokens::$heredocTokens[$tokens[($nextSeparator - 2)]['code']]) === false) {
 
115
  $error = 'Space found before comma in function call';
116
  $fix = $phpcsFile->addFixableError($error, $nextSeparator, 'SpaceBeforeComma');
117
  if ($fix === true) {
38
  */
39
  public function register()
40
  {
41
+ $tokens = PHP_CodeSniffer_Tokens::$functionNameTokens;
42
+
43
+ // For calling closures.
44
+ $tokens[] = T_VARIABLE;
45
+
46
+ return $tokens;
47
 
48
  }//end register()
49
 
116
 
117
  if ($tokens[$nextSeparator]['code'] === T_COMMA) {
118
  if ($tokens[($nextSeparator - 1)]['code'] === T_WHITESPACE) {
119
+ $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextSeparator - 2), null, true);
120
+ if (isset(PHP_CodeSniffer_Tokens::$heredocTokens[$tokens[$prev]['code']]) === false) {
121
  $error = 'Space found before comma in function call';
122
  $fix = $phpcsFile->addFixableError($error, $nextSeparator, 'SpaceBeforeComma');
123
  if ($fix === true) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php CHANGED
@@ -111,9 +111,26 @@ class Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff impleme
111
  $phpcsFile->fixer->beginChangeset();
112
  $phpcsFile->fixer->addContent($prev, ' {');
113
  $phpcsFile->fixer->replaceToken($openingBrace, '');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  $phpcsFile->fixer->endChangeset();
115
- }
116
- }
117
 
118
  $phpcsFile->recordMetric($stackPtr, 'Function opening brace placement', 'same line');
119
 
@@ -136,23 +153,23 @@ class Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff impleme
136
  return;
137
  }
138
 
139
- if ($tokens[($closeBracket + 1)]['code'] !== T_WHITESPACE) {
140
  $length = 0;
141
- } else if ($tokens[($closeBracket + 1)]['content'] === "\t") {
142
  $length = '\t';
143
  } else {
144
- $length = strlen($tokens[($closeBracket + 1)]['content']);
145
  }
146
 
147
  if ($length !== 1) {
148
- $error = 'Expected 1 space after closing parenthesis; found %s';
149
  $data = array($length);
150
- $fix = $phpcsFile->addFixableError($error, $closeBracket, 'SpaceAfterBracket', $data);
151
  if ($fix === true) {
152
  if ($length === 0 || $length === '\t') {
153
- $phpcsFile->fixer->addContent($closeBracket, ' ');
154
  } else {
155
- $phpcsFile->fixer->replaceToken(($closeBracket + 1), ' ');
156
  }
157
  }
158
  }
111
  $phpcsFile->fixer->beginChangeset();
112
  $phpcsFile->fixer->addContent($prev, ' {');
113
  $phpcsFile->fixer->replaceToken($openingBrace, '');
114
+ if ($tokens[($openingBrace + 1)]['code'] === T_WHITESPACE
115
+ && $tokens[($openingBrace + 2)]['line'] > $tokens[$openingBrace]['line']
116
+ ) {
117
+ // Brace is followed by a new line, so remove it to ensure we don't
118
+ // leave behind a blank line at the top of the block.
119
+ $phpcsFile->fixer->replaceToken(($openingBrace + 1), '');
120
+
121
+ if ($tokens[($openingBrace - 1)]['code'] === T_WHITESPACE
122
+ && $tokens[($openingBrace - 1)]['line'] === $tokens[$openingBrace]['line']
123
+ && $tokens[($openingBrace - 2)]['line'] < $tokens[$openingBrace]['line']
124
+ ) {
125
+ // Brace is preceeded by indent, so remove it to ensure we don't
126
+ // leave behind more indent than is required for the first line.
127
+ $phpcsFile->fixer->replaceToken(($openingBrace - 1), '');
128
+ }
129
+ }
130
+
131
  $phpcsFile->fixer->endChangeset();
132
+ }//end if
133
+ }//end if
134
 
135
  $phpcsFile->recordMetric($stackPtr, 'Function opening brace placement', 'same line');
136
 
153
  return;
154
  }
155
 
156
+ if ($tokens[($openingBrace - 1)]['code'] !== T_WHITESPACE) {
157
  $length = 0;
158
+ } else if ($tokens[($openingBrace - 1)]['content'] === "\t") {
159
  $length = '\t';
160
  } else {
161
+ $length = strlen($tokens[($openingBrace - 1)]['content']);
162
  }
163
 
164
  if ($length !== 1) {
165
+ $error = 'Expected 1 space before opening brace; found %s';
166
  $data = array($length);
167
+ $fix = $phpcsFile->addFixableError($error, $closeBracket, 'SpaceBeforeBrace', $data);
168
  if ($fix === true) {
169
  if ($length === 0 || $length === '\t') {
170
+ $phpcsFile->fixer->addContentBefore($openingBrace, ' ');
171
  } else {
172
+ $phpcsFile->fixer->replaceToken(($openingBrace - 1), ' ');
173
  }
174
  }
175
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php CHANGED
@@ -40,7 +40,7 @@ class Generic_Sniffs_Metrics_CyclomaticComplexitySniff implements PHP_CodeSniffe
40
  public $complexity = 10;
41
 
42
  /**
43
- * A complexity higer than this value will throw an error.
44
  *
45
  * @var int
46
  */
40
  public $complexity = 10;
41
 
42
  /**
43
+ * A complexity higher than this value will throw an error.
44
  *
45
  * @var int
46
  */
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php CHANGED
@@ -29,14 +29,14 @@ class Generic_Sniffs_Metrics_NestingLevelSniff implements PHP_CodeSniffer_Sniff
29
  {
30
 
31
  /**
32
- * A nesting level than this value will throw a warning.
33
  *
34
  * @var int
35
  */
36
  public $nestingLevel = 5;
37
 
38
  /**
39
- * A nesting level than this value will throw an error.
40
  *
41
  * @var int
42
  */
29
  {
30
 
31
  /**
32
+ * A nesting level higher than this value will throw a warning.
33
  *
34
  * @var int
35
  */
36
  public $nestingLevel = 5;
37
 
38
  /**
39
+ * A nesting level higher than this value will throw an error.
40
  *
41
  * @var int
42
  */
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php CHANGED
@@ -99,7 +99,7 @@ class Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff extends PHP_Co
99
  */
100
  public function __construct()
101
  {
102
- parent::__construct(array(T_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION), true);
103
 
104
  }//end __construct()
105
 
@@ -126,7 +126,7 @@ class Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff extends PHP_Co
126
  $errorData = array($className.'::'.$methodName);
127
 
128
  // Is this a magic method. i.e., is prefixed with "__" ?
129
- if (preg_match('|^__|', $methodName) !== 0) {
130
  $magicPart = strtolower(substr($methodName, 2));
131
  if (isset($this->magicMethods[$magicPart]) === false
132
  && isset($this->methodsDoubleUnderscore[$magicPart]) === false
@@ -194,7 +194,7 @@ class Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff extends PHP_Co
194
  $errorData = array($functionName);
195
 
196
  // Is this a magic function. i.e., it is prefixed with "__".
197
- if (preg_match('|^__|', $functionName) !== 0) {
198
  $magicPart = strtolower(substr($functionName, 2));
199
  if (isset($this->magicFunctions[$magicPart]) === false) {
200
  $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
99
  */
100
  public function __construct()
101
  {
102
+ parent::__construct(array(T_CLASS, T_ANON_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION), true);
103
 
104
  }//end __construct()
105
 
126
  $errorData = array($className.'::'.$methodName);
127
 
128
  // Is this a magic method. i.e., is prefixed with "__" ?
129
+ if (preg_match('|^__[^_]|', $methodName) !== 0) {
130
  $magicPart = strtolower(substr($methodName, 2));
131
  if (isset($this->magicMethods[$magicPart]) === false
132
  && isset($this->methodsDoubleUnderscore[$magicPart]) === false
194
  $errorData = array($functionName);
195
 
196
  // Is this a magic function. i.e., it is prefixed with "__".
197
+ if (preg_match('|^__[^_]|', $functionName) !== 0) {
198
  $magicPart = strtolower(substr($functionName, 2));
199
  if (isset($this->magicFunctions[$magicPart]) === false) {
200
  $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php CHANGED
@@ -54,7 +54,7 @@ class Generic_Sniffs_NamingConventions_ConstructorNameSniff extends PHP_CodeSnif
54
  */
55
  public function __construct()
56
  {
57
- parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION), true);
58
 
59
  }//end __construct()
60
 
54
  */
55
  public function __construct()
56
  {
57
+ parent::__construct(array(T_CLASS, T_ANON_CLASS, T_INTERFACE), array(T_FUNCTION), true);
58
 
59
  }//end __construct()
60
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php CHANGED
@@ -157,6 +157,13 @@ class Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff implements PHP
157
  $constName = substr($constName, ($splitPos + 2));
158
  }
159
 
 
 
 
 
 
 
 
160
  if (strtoupper($constName) !== $constName) {
161
  if (strtolower($constName) === $constName) {
162
  $phpcsFile->recordMetric($stackPtr, 'Constant name case', 'lower');
157
  $constName = substr($constName, ($splitPos + 2));
158
  }
159
 
160
+ // Strip namesspace from constant like /foo/bar/CONSTANT.
161
+ $splitPos = strrpos($constName, '\\');
162
+ if ($splitPos !== false) {
163
+ $prefix = substr($constName, 0, ($splitPos + 1));
164
+ $constName = substr($constName, ($splitPos + 1));
165
+ }
166
+
167
  if (strtoupper($constName) !== $constName) {
168
  if (strtolower($constName) === $constName) {
169
  $phpcsFile->recordMetric($stackPtr, 'Constant name case', 'lower');
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php CHANGED
@@ -63,7 +63,11 @@ class Generic_Sniffs_PHP_DisallowShortOpenTagSniff implements PHP_CodeSniffer_Sn
63
  if ($openTag['content'] === '<?') {
64
  $error = 'Short PHP opening tag used; expected "<?php" but found "%s"';
65
  $data = array($openTag['content']);
66
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
 
 
 
 
67
  $phpcsFile->recordMetric($stackPtr, 'PHP short open tag used', 'yes');
68
  } else {
69
  $phpcsFile->recordMetric($stackPtr, 'PHP short open tag used', 'no');
@@ -77,7 +81,14 @@ class Generic_Sniffs_PHP_DisallowShortOpenTagSniff implements PHP_CodeSniffer_Sn
77
  $openTag['content'],
78
  $nextVar['content'],
79
  );
80
- $phpcsFile->addError($error, $stackPtr, 'EchoFound', $data);
 
 
 
 
 
 
 
81
  }
82
 
83
  }//end process()
63
  if ($openTag['content'] === '<?') {
64
  $error = 'Short PHP opening tag used; expected "<?php" but found "%s"';
65
  $data = array($openTag['content']);
66
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data);
67
+ if ($fix === true) {
68
+ $phpcsFile->fixer->replaceToken($stackPtr, '<?php');
69
+ }
70
+
71
  $phpcsFile->recordMetric($stackPtr, 'PHP short open tag used', 'yes');
72
  } else {
73
  $phpcsFile->recordMetric($stackPtr, 'PHP short open tag used', 'no');
81
  $openTag['content'],
82
  $nextVar['content'],
83
  );
84
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'EchoFound', $data);
85
+ if ($fix === true) {
86
+ if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
87
+ $phpcsFile->fixer->replaceToken($stackPtr, '<?php echo ');
88
+ } else {
89
+ $phpcsFile->fixer->replaceToken($stackPtr, '<?php echo');
90
+ }
91
+ }
92
  }
93
 
94
  }//end process()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php CHANGED
@@ -102,6 +102,9 @@ class Generic_Sniffs_PHP_ForbiddenFunctionsSniff implements PHP_CodeSniffer_Snif
102
  }
103
  }
104
 
 
 
 
105
  return array_unique($register);
106
 
107
  }//end register()
@@ -188,7 +191,7 @@ class Generic_Sniffs_PHP_ForbiddenFunctionsSniff implements PHP_CodeSniffer_Snif
188
  }
189
  }//end if
190
 
191
- $this->addError($phpcsFile, $stackPtr, $function, $pattern);
192
 
193
  }//end process()
194
 
@@ -217,7 +220,7 @@ class Generic_Sniffs_PHP_ForbiddenFunctionsSniff implements PHP_CodeSniffer_Snif
217
  }
218
 
219
  if ($pattern === null) {
220
- $pattern = $function;
221
  }
222
 
223
  if ($this->forbiddenFunctions[$pattern] !== null
102
  }
103
  }
104
 
105
+ $this->forbiddenFunctionNames = array_map('strtolower', $this->forbiddenFunctionNames);
106
+ $this->forbiddenFunctions = array_combine($this->forbiddenFunctionNames, $this->forbiddenFunctions);
107
+
108
  return array_unique($register);
109
 
110
  }//end register()
191
  }
192
  }//end if
193
 
194
+ $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['content'], $pattern);
195
 
196
  }//end process()
197
 
220
  }
221
 
222
  if ($pattern === null) {
223
+ $pattern = strtolower($function);
224
  }
225
 
226
  if ($this->forbiddenFunctions[$pattern] !== null
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/SyntaxSniff.php CHANGED
@@ -30,6 +30,13 @@
30
  class Generic_Sniffs_PHP_SyntaxSniff implements PHP_CodeSniffer_Sniff
31
  {
32
 
 
 
 
 
 
 
 
33
 
34
  /**
35
  * Returns an array of tokens this test wants to listen for.
@@ -54,22 +61,28 @@ class Generic_Sniffs_PHP_SyntaxSniff implements PHP_CodeSniffer_Sniff
54
  */
55
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
  {
57
- $phpPath = PHP_CodeSniffer::getConfigData('php_path');
58
- if ($phpPath === null) {
59
- // PHP_BINARY is available in PHP 5.4+.
60
- if (defined('PHP_BINARY') === true) {
61
- $phpPath = PHP_BINARY;
62
- } else {
63
- return;
 
 
64
  }
65
  }
66
 
67
- $fileName = $phpcsFile->getFilename();
68
- $cmd = "$phpPath -l \"$fileName\" 2>&1";
69
- $output = shell_exec($cmd);
 
 
 
70
 
 
71
  $matches = array();
72
- if (preg_match('/^.*error:(.*) in .* on line ([0-9]+)/', trim($output), $matches) === 1) {
73
  $error = trim($matches[1]);
74
  $line = (int) $matches[2];
75
  $phpcsFile->addErrorOnLine("PHP syntax error: $error", $line, 'PHPSyntax');
30
  class Generic_Sniffs_PHP_SyntaxSniff implements PHP_CodeSniffer_Sniff
31
  {
32
 
33
+ /**
34
+ * The path to the PHP version we are checking with.
35
+ *
36
+ * @var string
37
+ */
38
+ private $_phpPath = null;
39
+
40
 
41
  /**
42
  * Returns an array of tokens this test wants to listen for.
61
  */
62
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
63
  {
64
+ if ($this->_phpPath === null) {
65
+ $this->_phpPath = PHP_CodeSniffer::getConfigData('php_path');
66
+ if ($this->_phpPath === null) {
67
+ // PHP_BINARY is available in PHP 5.4+.
68
+ if (defined('PHP_BINARY') === true) {
69
+ $this->_phpPath = PHP_BINARY;
70
+ } else {
71
+ return;
72
+ }
73
  }
74
  }
75
 
76
+ $fileName = escapeshellarg($phpcsFile->getFilename());
77
+ if (defined('HHVM_VERSION') === false) {
78
+ $cmd = escapeshellcmd($this->_phpPath)." -l -d error_prepend_string='' $fileName 2>&1";
79
+ } else {
80
+ $cmd = escapeshellcmd($this->_phpPath)." -l $fileName 2>&1";
81
+ }
82
 
83
+ $output = shell_exec($cmd);
84
  $matches = array();
85
+ if (preg_match('/^.*error:(.*) in .* on line ([0-9]+)/m', trim($output), $matches) === 1) {
86
  $error = trim($matches[1]);
87
  $line = (int) $matches[2];
88
  $phpcsFile->addErrorOnLine("PHP syntax error: $error", $line, 'PHPSyntax');
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php CHANGED
@@ -236,9 +236,7 @@ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Snif
236
  && $tokens[$checkToken]['code'] === T_CLOSE_PARENTHESIS
237
  && isset($tokens[$checkToken]['parenthesis_opener']) === true)
238
  || ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS
239
- && isset($tokens[$i]['parenthesis_opener']) === true
240
- && isset($tokens[$i]['parenthesis_owner']) === true
241
- && $tokens[$tokens[$i]['parenthesis_owner']]['code'] === T_ARRAY)
242
  ) {
243
  if ($checkToken !== null) {
244
  $parenCloser = $checkToken;
@@ -296,7 +294,26 @@ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Snif
296
 
297
  $exact = false;
298
 
299
- if ($condition > 0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
300
  && isset($tokens[$condition]['scope_opener']) === true
301
  && isset($setIndents[$tokens[$condition]['scope_opener']]) === true
302
  ) {
@@ -789,11 +806,27 @@ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Snif
789
  $checkIndent = (int) (ceil($checkIndent / $this->indent) * $this->indent);
790
  }
791
 
792
- // Check the line indent.
 
 
 
 
 
 
793
  if ($checkIndent === null) {
794
  $checkIndent = $currentIndent;
795
  }
796
 
 
 
 
 
 
 
 
 
 
 
797
  $adjusted = false;
798
  if ($checkToken !== null
799
  && isset($this->_ignoreIndentationTokens[$tokens[$checkToken]['code']]) === false
@@ -962,13 +995,14 @@ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Snif
962
  continue;
963
  }//end if
964
 
965
- // Closures set the indent based on their own indent level.
966
- if ($tokens[$i]['code'] === T_CLOSURE) {
967
  $closer = $tokens[$i]['scope_closer'];
968
  if ($tokens[$i]['line'] === $tokens[$closer]['line']) {
969
  if ($this->_debug === true) {
 
970
  $line = $tokens[$i]['line'];
971
- echo "* ignoring single-line closure on line $line".PHP_EOL;
972
  }
973
 
974
  $i = $closer;
@@ -976,8 +1010,9 @@ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Snif
976
  }
977
 
978
  if ($this->_debug === true) {
 
979
  $line = $tokens[$i]['line'];
980
- echo "Open closure on line $line".PHP_EOL;
981
  }
982
 
983
  $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $i, true);
@@ -1078,14 +1113,16 @@ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Snif
1078
  continue;
1079
  }//end if
1080
 
1081
- // Closing a closure.
1082
  if (isset($tokens[$i]['scope_condition']) === true
1083
  && $tokens[$i]['scope_closer'] === $i
1084
- && $tokens[$tokens[$i]['scope_condition']]['code'] === T_CLOSURE
 
1085
  ) {
1086
  if ($this->_debug === true) {
 
1087
  $line = $tokens[$i]['line'];
1088
- echo "Close closure on line $line".PHP_EOL;
1089
  }
1090
 
1091
  $prev = false;
236
  && $tokens[$checkToken]['code'] === T_CLOSE_PARENTHESIS
237
  && isset($tokens[$checkToken]['parenthesis_opener']) === true)
238
  || ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS
239
+ && isset($tokens[$i]['parenthesis_opener']) === true)
 
 
240
  ) {
241
  if ($checkToken !== null) {
242
  $parenCloser = $checkToken;
294
 
295
  $exact = false;
296
 
297
+ $lastOpenTagConditions = array_keys($tokens[$lastOpenTag]['conditions']);
298
+ $lastOpenTagCondition = array_pop($lastOpenTagConditions);
299
+
300
+ if ($condition > 0 && $lastOpenTagCondition === $condition) {
301
+ if ($this->_debug === true) {
302
+ echo "\t* open tag is inside condition; using open tag *".PHP_EOL;
303
+ }
304
+
305
+ $checkIndent = ($tokens[$lastOpenTag]['column'] - 1);
306
+ if (isset($adjustments[$condition]) === true) {
307
+ $checkIndent += $adjustments[$condition];
308
+ }
309
+
310
+ $currentIndent = $checkIndent;
311
+
312
+ if ($this->_debug === true) {
313
+ $type = $tokens[$lastOpenTag]['type'];
314
+ echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $lastOpenTag ($type)".PHP_EOL;
315
+ }
316
+ } else if ($condition > 0
317
  && isset($tokens[$condition]['scope_opener']) === true
318
  && isset($setIndents[$tokens[$condition]['scope_opener']]) === true
319
  ) {
806
  $checkIndent = (int) (ceil($checkIndent / $this->indent) * $this->indent);
807
  }
808
 
809
+ // Special case for ELSE statements that are not on the same
810
+ // line as the previous IF statements closing brace. They still need
811
+ // to have the same indent or it will break code after the block.
812
+ if ($checkToken !== null && $tokens[$checkToken]['code'] === T_ELSE) {
813
+ $exact = true;
814
+ }
815
+
816
  if ($checkIndent === null) {
817
  $checkIndent = $currentIndent;
818
  }
819
 
820
+ /*
821
+ The indent of the line is checked by the following IF block.
822
+
823
+ Up until now, we've just been figuring out what the indent
824
+ of this line should be.
825
+
826
+ After this IF block, we adjust the indent again for
827
+ the checking of future line.
828
+ */
829
+
830
  $adjusted = false;
831
  if ($checkToken !== null
832
  && isset($this->_ignoreIndentationTokens[$tokens[$checkToken]['code']]) === false
995
  continue;
996
  }//end if
997
 
998
+ // Anon classes and functions set the indent based on their own indent level.
999
+ if ($tokens[$i]['code'] === T_CLOSURE || $tokens[$i]['code'] === T_ANON_CLASS) {
1000
  $closer = $tokens[$i]['scope_closer'];
1001
  if ($tokens[$i]['line'] === $tokens[$closer]['line']) {
1002
  if ($this->_debug === true) {
1003
+ $type = str_replace('_', ' ', strtolower(substr($tokens[$i]['type'], 2)));
1004
  $line = $tokens[$i]['line'];
1005
+ echo "* ignoring single-line $type on line $line".PHP_EOL;
1006
  }
1007
 
1008
  $i = $closer;
1010
  }
1011
 
1012
  if ($this->_debug === true) {
1013
+ $type = str_replace('_', ' ', strtolower(substr($tokens[$i]['type'], 2)));
1014
  $line = $tokens[$i]['line'];
1015
+ echo "Open $type on line $line".PHP_EOL;
1016
  }
1017
 
1018
  $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $i, true);
1113
  continue;
1114
  }//end if
1115
 
1116
+ // Closing an anon class or function.
1117
  if (isset($tokens[$i]['scope_condition']) === true
1118
  && $tokens[$i]['scope_closer'] === $i
1119
+ && ($tokens[$tokens[$i]['scope_condition']]['code'] === T_CLOSURE
1120
+ || $tokens[$tokens[$i]['scope_condition']]['code'] === T_ANON_CLASS)
1121
  ) {
1122
  if ($this->_debug === true) {
1123
+ $type = str_replace('_', ' ', strtolower(substr($tokens[$tokens[$i]['scope_condition']]['type'], 2)));
1124
  $line = $tokens[$i]['line'];
1125
+ echo "Close $type on line $line".PHP_EOL;
1126
  }
1127
 
1128
  $prev = false;
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php CHANGED
@@ -172,10 +172,6 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
172
  T_ABSTRACT,
173
  T_CONST,
174
  T_PROPERTY,
175
- T_INCLUDE,
176
- T_INCLUDE_ONCE,
177
- T_REQUIRE,
178
- T_REQUIRE_ONCE,
179
  );
180
 
181
  if (in_array($tokens[$nextToken]['code'], $ignore) === true) {
@@ -502,13 +498,13 @@ class PEAR_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
502
  $matches = array();
503
  if (preg_match('/^([0-9]{4})((.{1})([0-9]{4}))? (.+)$/', $content, $matches) !== 0) {
504
  // Check earliest-latest year order.
505
- if ($matches[3] !== '') {
506
  if ($matches[3] !== '-') {
507
  $error = 'A hyphen must be used between the earliest and latest year';
508
  $phpcsFile->addError($error, $tag, 'CopyrightHyphen');
509
  }
510
 
511
- if ($matches[4] !== '' && $matches[4] < $matches[1]) {
512
  $error = "Invalid year span \"$matches[1]$matches[3]$matches[4]\" found; consider \"$matches[4]-$matches[1]\" instead";
513
  $phpcsFile->addWarning($error, $tag, 'InvalidCopyright');
514
  }
172
  T_ABSTRACT,
173
  T_CONST,
174
  T_PROPERTY,
 
 
 
 
175
  );
176
 
177
  if (in_array($tokens[$nextToken]['code'], $ignore) === true) {
498
  $matches = array();
499
  if (preg_match('/^([0-9]{4})((.{1})([0-9]{4}))? (.+)$/', $content, $matches) !== 0) {
500
  // Check earliest-latest year order.
501
+ if ($matches[3] !== '' && $matches[3] !== null) {
502
  if ($matches[3] !== '-') {
503
  $error = 'A hyphen must be used between the earliest and latest year';
504
  $phpcsFile->addError($error, $tag, 'CopyrightHyphen');
505
  }
506
 
507
+ if ($matches[4] !== '' && $matches[4] !== null && $matches[4] < $matches[1]) {
508
  $error = "Invalid year span \"$matches[1]$matches[3]$matches[4]\" found; consider \"$matches[4]-$matches[1]\" instead";
509
  $phpcsFile->addWarning($error, $tag, 'InvalidCopyright');
510
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php CHANGED
@@ -218,21 +218,24 @@ class PEAR_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sni
218
  continue;
219
  }
220
 
221
- $type = '';
222
- $typeSpace = 0;
223
- $var = '';
224
- $varSpace = 0;
225
- $comment = '';
 
226
  if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) {
227
  $matches = array();
228
  preg_match('/([^$&.]+)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches);
229
 
230
- $typeLen = strlen($matches[1]);
231
- $type = trim($matches[1]);
232
- $typeSpace = ($typeLen - strlen($type));
233
- $typeLen = strlen($type);
234
- if ($typeLen > $maxType) {
235
- $maxType = $typeLen;
 
 
236
  }
237
 
238
  if (isset($matches[2]) === true) {
@@ -255,13 +258,14 @@ class PEAR_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sni
255
 
256
  for ($i = ($tag + 3); $i < $end; $i++) {
257
  if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING) {
258
- $comment .= ' '.$tokens[$i]['content'];
 
259
  }
260
  }
261
  } else {
262
  $error = 'Missing parameter comment';
263
  $phpcsFile->addError($error, $tag, 'MissingParamComment');
264
- }
265
  } else {
266
  $error = 'Missing parameter name';
267
  $phpcsFile->addError($error, $tag, 'MissingParamName');
@@ -272,12 +276,13 @@ class PEAR_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sni
272
  }//end if
273
 
274
  $params[] = array(
275
- 'tag' => $tag,
276
- 'type' => $type,
277
- 'var' => $var,
278
- 'comment' => $comment,
279
- 'type_space' => $typeSpace,
280
- 'var_space' => $varSpace,
 
281
  );
282
  }//end foreach
283
 
@@ -310,14 +315,36 @@ class PEAR_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sni
310
 
311
  $fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamType', $data);
312
  if ($fix === true) {
 
 
313
  $content = $param['type'];
314
  $content .= str_repeat(' ', $spaces);
315
  $content .= $param['var'];
316
  $content .= str_repeat(' ', $param['var_space']);
317
- $content .= $param['comment'];
318
- $phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content);
319
- }
320
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
 
322
  // Make sure the param name is correct.
323
  if (isset($realParams[$pos]) === true) {
@@ -360,14 +387,36 @@ class PEAR_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sni
360
 
361
  $fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamName', $data);
362
  if ($fix === true) {
 
 
363
  $content = $param['type'];
364
  $content .= str_repeat(' ', $param['type_space']);
365
  $content .= $param['var'];
366
  $content .= str_repeat(' ', $spaces);
367
- $content .= $param['comment'];
368
- $phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content);
369
- }
370
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
371
  }//end foreach
372
 
373
  $realNames = array();
218
  continue;
219
  }
220
 
221
+ $type = '';
222
+ $typeSpace = 0;
223
+ $var = '';
224
+ $varSpace = 0;
225
+ $comment = '';
226
+ $commentEnd = 0;
227
  if ($tokens[($tag + 2)]['code'] === T_DOC_COMMENT_STRING) {
228
  $matches = array();
229
  preg_match('/([^$&.]+)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches);
230
 
231
+ if (empty($matches) === false) {
232
+ $typeLen = strlen($matches[1]);
233
+ $type = trim($matches[1]);
234
+ $typeSpace = ($typeLen - strlen($type));
235
+ $typeLen = strlen($type);
236
+ if ($typeLen > $maxType) {
237
+ $maxType = $typeLen;
238
+ }
239
  }
240
 
241
  if (isset($matches[2]) === true) {
258
 
259
  for ($i = ($tag + 3); $i < $end; $i++) {
260
  if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING) {
261
+ $comment .= ' '.$tokens[$i]['content'];
262
+ $commentEnd = $i;
263
  }
264
  }
265
  } else {
266
  $error = 'Missing parameter comment';
267
  $phpcsFile->addError($error, $tag, 'MissingParamComment');
268
+ }//end if
269
  } else {
270
  $error = 'Missing parameter name';
271
  $phpcsFile->addError($error, $tag, 'MissingParamName');
276
  }//end if
277
 
278
  $params[] = array(
279
+ 'tag' => $tag,
280
+ 'type' => $type,
281
+ 'var' => $var,
282
+ 'comment' => $comment,
283
+ 'comment_end' => $commentEnd,
284
+ 'type_space' => $typeSpace,
285
+ 'var_space' => $varSpace,
286
  );
287
  }//end foreach
288
 
315
 
316
  $fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamType', $data);
317
  if ($fix === true) {
318
+ $commentToken = ($param['tag'] + 2);
319
+
320
  $content = $param['type'];
321
  $content .= str_repeat(' ', $spaces);
322
  $content .= $param['var'];
323
  $content .= str_repeat(' ', $param['var_space']);
324
+
325
+ $wrapLength = ($tokens[$commentToken]['length'] - $param['type_space'] - $param['var_space'] - strlen($param['type']) - strlen($param['var'])
326
+ );
327
+
328
+ $star = $phpcsFile->findPrevious(T_DOC_COMMENT_STAR, $param['tag']);
329
+ $spaceLength = (strlen($content) + $tokens[($commentToken - 1)]['length'] + $tokens[($commentToken - 2)]['length']
330
+ );
331
+
332
+ $padding = str_repeat(' ', ($tokens[$star]['column'] - 1));
333
+ $padding .= '* ';
334
+ $padding .= str_repeat(' ', $spaceLength);
335
+
336
+ $content .= wordwrap(
337
+ $param['comment'],
338
+ $wrapLength,
339
+ $phpcsFile->eolChar.$padding
340
+ );
341
+
342
+ $phpcsFile->fixer->replaceToken($commentToken, $content);
343
+ for ($i = ($commentToken + 1); $i <= $param['comment_end']; $i++) {
344
+ $phpcsFile->fixer->replaceToken($i, '');
345
+ }
346
+ }//end if
347
+ }//end if
348
 
349
  // Make sure the param name is correct.
350
  if (isset($realParams[$pos]) === true) {
387
 
388
  $fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamName', $data);
389
  if ($fix === true) {
390
+ $commentToken = ($param['tag'] + 2);
391
+
392
  $content = $param['type'];
393
  $content .= str_repeat(' ', $param['type_space']);
394
  $content .= $param['var'];
395
  $content .= str_repeat(' ', $spaces);
396
+
397
+ $wrapLength = ($tokens[$commentToken]['length'] - $param['type_space'] - $param['var_space'] - strlen($param['type']) - strlen($param['var'])
398
+ );
399
+
400
+ $star = $phpcsFile->findPrevious(T_DOC_COMMENT_STAR, $param['tag']);
401
+ $spaceLength = (strlen($content) + $tokens[($commentToken - 1)]['length'] + $tokens[($commentToken - 2)]['length']
402
+ );
403
+
404
+ $padding = str_repeat(' ', ($tokens[$star]['column'] - 1));
405
+ $padding .= '* ';
406
+ $padding .= str_repeat(' ', $spaceLength);
407
+
408
+ $content .= wordwrap(
409
+ $param['comment'],
410
+ $wrapLength,
411
+ $phpcsFile->eolChar.$padding
412
+ );
413
+
414
+ $phpcsFile->fixer->replaceToken($commentToken, $content);
415
+ for ($i = ($commentToken + 1); $i <= $param['comment_end']; $i++) {
416
+ $phpcsFile->fixer->replaceToken($i, '');
417
+ }
418
+ }//end if
419
+ }//end if
420
  }//end foreach
421
 
422
  $realNames = array();
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php CHANGED
@@ -119,28 +119,33 @@ class PEAR_Sniffs_ControlStructures_MultiLineConditionSniff implements PHP_CodeS
119
  // and start with an operator, unless the line is inside a
120
  // function call, in which case it is ignored.
121
  $prevLine = $tokens[$openBracket]['line'];
122
- for ($i = ($openBracket + 1); $i < $closeBracket; $i++) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
123
  if ($tokens[$i]['line'] !== $prevLine) {
124
  if ($tokens[$i]['line'] === $tokens[$closeBracket]['line']) {
125
  $next = $phpcsFile->findNext(T_WHITESPACE, $i, null, true);
126
  if ($next !== $closeBracket) {
127
- // Closing bracket is on the same line as a condition.
128
- $error = 'Closing parenthesis of a multi-line IF statement must be on a new line';
129
- $fix = $phpcsFile->addFixableError($error, $closeBracket, 'CloseBracketNewLine');
130
- if ($fix === true) {
131
- // Account for a comment at the end of the line.
132
- $next = $phpcsFile->findNext(T_WHITESPACE, ($closeBracket + 1), null, true);
133
- if ($tokens[$next]['code'] !== T_COMMENT) {
134
- $phpcsFile->fixer->addNewlineBefore($closeBracket);
135
- } else {
136
- $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true);
137
- $phpcsFile->fixer->beginChangeset();
138
- $phpcsFile->fixer->replaceToken($closeBracket, '');
139
- $phpcsFile->fixer->addContentBefore($next, ')');
140
- $phpcsFile->fixer->endChangeset();
141
- }
142
- }
143
-
144
  $expectedIndent = ($statementIndent + $this->indent);
145
  } else {
146
  // Closing brace needs to be indented to the same level
119
  // and start with an operator, unless the line is inside a
120
  // function call, in which case it is ignored.
121
  $prevLine = $tokens[$openBracket]['line'];
122
+ for ($i = ($openBracket + 1); $i <= $closeBracket; $i++) {
123
+ if ($i === $closeBracket && $tokens[$openBracket]['line'] !== $tokens[$i]['line']) {
124
+ $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($i - 1), null, true);
125
+ if ($tokens[$prev]['line'] === $tokens[$i]['line']) {
126
+ // Closing bracket is on the same line as a condition.
127
+ $error = 'Closing parenthesis of a multi-line IF statement must be on a new line';
128
+ $fix = $phpcsFile->addFixableError($error, $closeBracket, 'CloseBracketNewLine');
129
+ if ($fix === true) {
130
+ // Account for a comment at the end of the line.
131
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($closeBracket + 1), null, true);
132
+ if ($tokens[$next]['code'] !== T_COMMENT) {
133
+ $phpcsFile->fixer->addNewlineBefore($closeBracket);
134
+ } else {
135
+ $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true);
136
+ $phpcsFile->fixer->beginChangeset();
137
+ $phpcsFile->fixer->replaceToken($closeBracket, '');
138
+ $phpcsFile->fixer->addContentBefore($next, ')');
139
+ $phpcsFile->fixer->endChangeset();
140
+ }
141
+ }
142
+ }
143
+ }//end if
144
+
145
  if ($tokens[$i]['line'] !== $prevLine) {
146
  if ($tokens[$i]['line'] === $tokens[$closeBracket]['line']) {
147
  $next = $phpcsFile->findNext(T_WHITESPACE, $i, null, true);
148
  if ($next !== $closeBracket) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  $expectedIndent = ($statementIndent + $this->indent);
150
  } else {
151
  // Closing brace needs to be indented to the same level
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php CHANGED
@@ -242,7 +242,7 @@ class PEAR_Sniffs_Functions_FunctionCallSignatureSniff implements PHP_CodeSniffe
242
 
243
  // Checking this: $value = my_function(...[*]).
244
  $spaceBeforeClose = 0;
245
- $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($closer - 1), $openBracket, true);
246
  if ($tokens[$prev]['code'] === T_END_HEREDOC || $tokens[$prev]['code'] === T_END_NOWDOC) {
247
  // Need a newline after these tokens, so ignore this rule.
248
  return;
@@ -263,13 +263,48 @@ class PEAR_Sniffs_Functions_FunctionCallSignatureSniff implements PHP_CodeSniffe
263
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeCloseBracket', $data);
264
  if ($fix === true) {
265
  $padding = str_repeat(' ', $this->requiredSpacesBeforeClose);
 
266
  if ($spaceBeforeClose === 0) {
267
  $phpcsFile->fixer->addContentBefore($closer, $padding);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
268
  } else {
269
  $phpcsFile->fixer->replaceToken(($closer - 1), $padding);
270
- }
271
- }
272
- }
273
 
274
  }//end processSingleLineCall()
275
 
@@ -432,8 +467,14 @@ class PEAR_Sniffs_Functions_FunctionCallSignatureSniff implements PHP_CodeSniffe
432
  if ($tokens[$i]['code'] === T_COMMENT
433
  && $tokens[($i - 1)]['code'] === T_COMMENT
434
  ) {
435
- $trimmed = ltrim($tokens[$i]['content']);
436
- $foundIndent = (strlen($tokens[$i]['content']) - strlen($trimmed));
 
 
 
 
 
 
437
  } else {
438
  $foundIndent = 0;
439
  }
242
 
243
  // Checking this: $value = my_function(...[*]).
244
  $spaceBeforeClose = 0;
245
+ $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($closer - 1), $openBracket, true);
246
  if ($tokens[$prev]['code'] === T_END_HEREDOC || $tokens[$prev]['code'] === T_END_NOWDOC) {
247
  // Need a newline after these tokens, so ignore this rule.
248
  return;
263
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceBeforeCloseBracket', $data);
264
  if ($fix === true) {
265
  $padding = str_repeat(' ', $this->requiredSpacesBeforeClose);
266
+
267
  if ($spaceBeforeClose === 0) {
268
  $phpcsFile->fixer->addContentBefore($closer, $padding);
269
+ } else if ($spaceBeforeClose === 'newline') {
270
+ $phpcsFile->fixer->beginChangeset();
271
+
272
+ $closingContent = ')';
273
+
274
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($closer + 1), null, true);
275
+ if ($tokens[$next]['code'] === T_SEMICOLON) {
276
+ $closingContent .= ';';
277
+ for ($i = ($closer + 1); $i <= $next; $i++) {
278
+ $phpcsFile->fixer->replaceToken($i, '');
279
+ }
280
+ }
281
+
282
+ // We want to jump over any whitespace or inline comment and
283
+ // move the closing parenthesis after any other token.
284
+ $prev = ($closer - 1);
285
+ while (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$prev]['code']]) === true) {
286
+ if (($tokens[$prev]['code'] === T_COMMENT)
287
+ && (strpos($tokens[$prev]['content'], '*/') !== false)
288
+ ) {
289
+ break;
290
+ }
291
+
292
+ $prev--;
293
+ }
294
+
295
+ $phpcsFile->fixer->addContent($prev, $padding.$closingContent);
296
+
297
+ $prevNonWhitespace = $phpcsFile->findPrevious(T_WHITESPACE, ($closer - 1), null, true);
298
+ for ($i = ($prevNonWhitespace + 1); $i <= $closer; $i++) {
299
+ $phpcsFile->fixer->replaceToken($i, '');
300
+ }
301
+
302
+ $phpcsFile->fixer->endChangeset();
303
  } else {
304
  $phpcsFile->fixer->replaceToken(($closer - 1), $padding);
305
+ }//end if
306
+ }//end if
307
+ }//end if
308
 
309
  }//end processSingleLineCall()
310
 
467
  if ($tokens[$i]['code'] === T_COMMENT
468
  && $tokens[($i - 1)]['code'] === T_COMMENT
469
  ) {
470
+ $trimmedLength = strlen(ltrim($tokens[$i]['content']));
471
+ if ($trimmedLength === 0) {
472
+ // This is a blank comment line, so indenting it is
473
+ // pointless.
474
+ continue;
475
+ }
476
+
477
+ $foundIndent = (strlen($tokens[$i]['content']) - $trimmedLength);
478
  } else {
479
  $foundIndent = 0;
480
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php CHANGED
@@ -346,6 +346,15 @@ class PEAR_Sniffs_Functions_FunctionDeclarationSniff implements PHP_CodeSniffer_
346
  // We changed lines, so this should be a whitespace indent token.
347
  if ($tokens[$i]['code'] !== T_WHITESPACE) {
348
  $foundIndent = 0;
 
 
 
 
 
 
 
 
 
349
  } else {
350
  $foundIndent = strlen($tokens[$i]['content']);
351
  }
346
  // We changed lines, so this should be a whitespace indent token.
347
  if ($tokens[$i]['code'] !== T_WHITESPACE) {
348
  $foundIndent = 0;
349
+ } else if ($tokens[$i]['line'] !== $tokens[($i + 1)]['line']) {
350
+ // This is an empty line, so don't check the indent.
351
+ $foundIndent = $expectedIndent;
352
+
353
+ $error = 'Blank lines are not allowed in a multi-line function declaration';
354
+ $fix = $phpcsFile->addFixableError($error, $i, 'EmptyLine');
355
+ if ($fix === true) {
356
+ $phpcsFile->fixer->replaceToken($i, '');
357
+ }
358
  } else {
359
  $foundIndent = strlen($tokens[$i]['content']);
360
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php CHANGED
@@ -39,7 +39,10 @@ class PEAR_Sniffs_Functions_ValidDefaultValueSniff implements PHP_CodeSniffer_Sn
39
  */
40
  public function register()
41
  {
42
- return array(T_FUNCTION);
 
 
 
43
 
44
  }//end register()
45
 
@@ -64,47 +67,32 @@ class PEAR_Sniffs_Functions_ValidDefaultValueSniff implements PHP_CodeSniffer_Sn
64
  // If there is a value without a default after this, it is an error.
65
  $defaultFound = false;
66
 
67
- $nextArg = $argStart;
68
- while (($nextArg = $phpcsFile->findNext(T_VARIABLE, ($nextArg + 1), $argEnd)) !== false) {
69
- if ($tokens[($nextArg - 1)]['code'] === T_ELLIPSIS) {
70
  continue;
71
  }
72
 
73
- $argHasDefault = self::_argHasDefault($phpcsFile, $nextArg);
74
- if ($argHasDefault === false && $defaultFound === true) {
75
- $error = 'Arguments with default values must be at the end of the argument list';
76
- $phpcsFile->addError($error, $nextArg, 'NotAtEnd');
77
- return;
 
 
 
 
 
78
  }
79
 
80
- if ($argHasDefault === true) {
81
- $defaultFound = true;
 
 
82
  }
83
- }
84
 
85
  }//end process()
86
 
87
 
88
- /**
89
- * Returns true if the passed argument has a default value.
90
- *
91
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
92
- * @param int $argPtr The position of the argument
93
- * in the stack.
94
- *
95
- * @return bool
96
- */
97
- private static function _argHasDefault(PHP_CodeSniffer_File $phpcsFile, $argPtr)
98
- {
99
- $tokens = $phpcsFile->getTokens();
100
- $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($argPtr + 1), null, true);
101
- if ($tokens[$nextToken]['code'] !== T_EQUAL) {
102
- return false;
103
- }
104
-
105
- return true;
106
-
107
- }//end _argHasDefault()
108
-
109
-
110
  }//end class
39
  */
40
  public function register()
41
  {
42
+ return array(
43
+ T_FUNCTION,
44
+ T_CLOSURE,
45
+ );
46
 
47
  }//end register()
48
 
67
  // If there is a value without a default after this, it is an error.
68
  $defaultFound = false;
69
 
70
+ $params = $phpcsFile->getMethodParameters($stackPtr);
71
+ foreach ($params as $param) {
72
+ if ($param['variable_length'] === true) {
73
  continue;
74
  }
75
 
76
+ if (array_key_exists('default', $param) === true) {
77
+ $defaultFound = true;
78
+ // Check if the arg is type hinted and using NULL for the default.
79
+ // This does not make the argument optional - it just allows NULL
80
+ // to be passed in.
81
+ if ($param['type_hint'] !== '' && strtolower($param['default']) === 'null') {
82
+ $defaultFound = false;
83
+ }
84
+
85
+ continue;
86
  }
87
 
88
+ if ($defaultFound === true) {
89
+ $error = 'Arguments with default values must be at the end of the argument list';
90
+ $phpcsFile->addError($error, $param['token'], 'NotAtEnd');
91
+ return;
92
  }
93
+ }//end foreach
94
 
95
  }//end process()
96
 
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php CHANGED
@@ -42,6 +42,7 @@ class PEAR_Sniffs_NamingConventions_ValidClassNameSniff implements PHP_CodeSniff
42
  return array(
43
  T_CLASS,
44
  T_INTERFACE,
 
45
  );
46
 
47
  }//end register()
42
  return array(
43
  T_CLASS,
44
  T_INTERFACE,
45
+ T_TRAIT,
46
  );
47
 
48
  }//end register()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php CHANGED
@@ -71,7 +71,7 @@ class PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff extends PHP_CodeSniff
71
  */
72
  public function __construct()
73
  {
74
- parent::__construct(array(T_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION), true);
75
 
76
  }//end __construct()
77
 
@@ -98,7 +98,7 @@ class PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff extends PHP_CodeSniff
98
  $errorData = array($className.'::'.$methodName);
99
 
100
  // Is this a magic method. i.e., is prefixed with "__" ?
101
- if (preg_match('|^__|', $methodName) !== 0) {
102
  $magicPart = strtolower(substr($methodName, 2));
103
  if (isset($this->magicMethods[$magicPart]) === false) {
104
  $error = 'Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
@@ -205,7 +205,7 @@ class PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff extends PHP_CodeSniff
205
  $errorData = array($functionName);
206
 
207
  // Is this a magic function. i.e., it is prefixed with "__".
208
- if (preg_match('|^__|', $functionName) !== 0) {
209
  $magicPart = strtolower(substr($functionName, 2));
210
  if (isset($this->magicFunctions[$magicPart]) === false) {
211
  $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
71
  */
72
  public function __construct()
73
  {
74
+ parent::__construct(array(T_CLASS, T_ANON_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION), true);
75
 
76
  }//end __construct()
77
 
98
  $errorData = array($className.'::'.$methodName);
99
 
100
  // Is this a magic method. i.e., is prefixed with "__" ?
101
+ if (preg_match('|^__[^_]|', $methodName) !== 0) {
102
  $magicPart = strtolower(substr($methodName, 2));
103
  if (isset($this->magicMethods[$magicPart]) === false) {
104
  $error = 'Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
205
  $errorData = array($functionName);
206
 
207
  // Is this a magic function. i.e., it is prefixed with "__".
208
+ if (preg_match('|^__[^_]|', $functionName) !== 0) {
209
  $magicPart = strtolower(substr($functionName, 2));
210
  if (isset($this->magicFunctions[$magicPart]) === false) {
211
  $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php CHANGED
@@ -177,7 +177,7 @@ class PEAR_Sniffs_WhiteSpace_ScopeClosingBraceSniff implements PHP_CodeSniffer_S
177
  }
178
  }//end if
179
 
180
- if ($fix === true && $phpcsFile->fixer->enabled === true) {
181
  $spaces = str_repeat(' ', $expectedIndent);
182
  if ($braceIndent === 0) {
183
  $phpcsFile->fixer->addContentBefore($lineStart, $spaces);
177
  }
178
  }//end if
179
 
180
+ if ($fix === true) {
181
  $spaces = str_repeat(' ', $expectedIndent);
182
  if ($braceIndent === 0) {
183
  $phpcsFile->fixer->addContentBefore($lineStart, $spaces);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniff.php CHANGED
@@ -22,6 +22,8 @@
22
  abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
23
  {
24
 
 
 
25
  /**
26
  * List of functions using hash algorithm as parameter (always the first parameter).
27
  *
@@ -40,6 +42,20 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
40
  );
41
 
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  /* The testVersion configuration variable may be in any of the following formats:
44
  * 1) Omitted/empty, in which case no version is specified. This effectively
45
  * disables all the checks provided by this standard.
@@ -127,10 +143,51 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
127
  }//end supportsBelow()
128
 
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  /**
131
  * Strip quotes surrounding an arbitrary string.
132
  *
133
- * Intended for use with the content of a T_CONSTANT_ENCAPSED_STRING.
134
  *
135
  * @param string $string The raw string.
136
  *
@@ -141,6 +198,39 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
141
  }
142
 
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  /**
145
  * Returns the name(s) of the interface(s) that the specified class implements.
146
  *
@@ -211,6 +301,9 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
211
  * Expects to be passed the T_STRING stack pointer for the function call.
212
  * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
213
  *
 
 
 
214
  * @link https://github.com/wimg/PHPCompatibility/issues/120
215
  * @link https://github.com/wimg/PHPCompatibility/issues/152
216
  *
@@ -228,24 +321,42 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
228
  return false;
229
  }
230
 
231
- if ($tokens[$stackPtr]['code'] !== T_STRING) {
 
232
  return false;
233
  }
234
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  // Next non-empty token should be the open parenthesis.
236
- $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
237
- if ($openParenthesis === false || $tokens[$openParenthesis]['code'] !== T_OPEN_PARENTHESIS) {
238
  return false;
239
  }
240
 
241
- if (isset($tokens[$openParenthesis]['parenthesis_closer']) === false) {
242
  return false;
243
  }
244
 
245
- $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
246
- $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $openParenthesis + 1, $closeParenthesis + 1, true);
247
 
248
- if ($nextNonEmpty === $closeParenthesis) {
249
  // No parameters.
250
  return false;
251
  }
@@ -260,6 +371,9 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
260
  * Expects to be passed the T_STRING stack pointer for the function call.
261
  * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
262
  *
 
 
 
263
  * @link https://github.com/wimg/PHPCompatibility/issues/111
264
  * @link https://github.com/wimg/PHPCompatibility/issues/114
265
  * @link https://github.com/wimg/PHPCompatibility/issues/151
@@ -289,6 +403,9 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
289
  * pointer and raw parameter value for all parameters. Index will be 1-based.
290
  * If no parameters are found, will return an empty array.
291
  *
 
 
 
292
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
293
  * @param int $stackPtr The position of the function call token.
294
  *
@@ -300,23 +417,34 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
300
  return array();
301
  }
302
 
303
- // Ok, we know we have a T_STRING with parameters and valid open & close parenthesis.
 
304
  $tokens = $phpcsFile->getTokens();
305
 
306
- $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
307
- $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
 
 
 
 
 
 
 
 
 
 
 
308
 
309
  // Which nesting level is the one we are interested in ?
310
- $nestedParenthesisCount = 1;
311
- if (isset($tokens[$openParenthesis]['nested_parenthesis'])) {
312
- $nestedParenthesisCount = count($tokens[$openParenthesis]['nested_parenthesis']) + 1;
313
  }
314
 
315
  $parameters = array();
316
- $nextComma = $openParenthesis;
317
- $paramStart = $openParenthesis + 1;
318
  $cnt = 1;
319
- while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS, T_OPEN_SHORT_ARRAY), $nextComma + 1, $closeParenthesis + 1)) {
320
  // Ignore anything within short array definition brackets.
321
  if (
322
  $tokens[$nextComma]['type'] === 'T_OPEN_SHORT_ARRAY'
@@ -341,8 +469,8 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
341
  continue;
342
  }
343
 
344
- // Ignore closing parenthesis if not 'ours'.
345
- if ($tokens[$nextComma]['type'] === 'T_CLOSE_PARENTHESIS' && $nextComma !== $closeParenthesis) {
346
  continue;
347
  }
348
 
@@ -354,7 +482,7 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
354
  // Check if there are more tokens before the closing parenthesis.
355
  // Prevents code like the following from setting a third parameter:
356
  // functionCall( $param1, $param2, );
357
- $hasNextParam = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $nextComma + 1, $closeParenthesis, true, null, true);
358
  if ($hasNextParam === false) {
359
  break;
360
  }
@@ -434,24 +562,7 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
434
  return true;
435
  }
436
 
437
- if (is_int($validScopes)) {
438
- // Received an integer, so cast to array.
439
- $validScopes = (array) $validScopes;
440
- }
441
-
442
- if (empty($validScopes) || is_array($validScopes) === false) {
443
- // No valid scope types received, so will not comply.
444
- return false;
445
- }
446
-
447
- // Check for required scope types.
448
- foreach ($tokens[$stackPtr]['conditions'] as $pointer => $tokenCode) {
449
- if (in_array($tokenCode, $validScopes, true)) {
450
- return true;
451
- }
452
- }
453
-
454
- return false;
455
  }
456
 
457
 
@@ -469,12 +580,16 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
469
  public function inClassScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $strict = true)
470
  {
471
  $validScopes = array(T_CLASS);
 
 
 
 
472
  if ($strict === false) {
473
  $validScopes[] = T_INTERFACE;
474
  $validScopes[] = T_TRAIT;
475
  }
476
 
477
- return $this->tokenHasScope($phpcsFile, $stackPtr, $validScopes);
478
  }
479
 
480
 
@@ -509,7 +624,7 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
509
 
510
  // PHPCS 2.0.
511
  if ($isLowPHPCS === false) {
512
- return $this->tokenHasScope($phpcsFile, $stackPtr, T_USE);
513
  } else {
514
  // PHPCS 1.x.
515
  $tokens = $phpcsFile->getTokens();
@@ -1058,7 +1173,7 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
1058
  }
1059
 
1060
  /**
1061
- * Algorithm is a T_CONSTANT_ENCAPSED_STRING, so we need to remove the quotes.
1062
  */
1063
  $algo = strtolower(trim($algoParam['raw']));
1064
  $algo = $this->stripQuotes($algo);
22
  abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
23
  {
24
 
25
+ const REGEX_COMPLEX_VARS = '`(?:(\{)?(?<!\\\\)\$)?(\{)?(?<!\\\\)\$(\{)?(?P<varname>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(?:->\$?(?P>varname)|\[[^\]]+\]|::\$?(?P>varname)|\([^\)]*\))*(?(3)\}|)(?(2)\}|)(?(1)\}|)`';
26
+
27
  /**
28
  * List of functions using hash algorithm as parameter (always the first parameter).
29
  *
42
  );
43
 
44
 
45
+ /**
46
+ * List of functions which take an ini directive as parameter (always the first parameter).
47
+ *
48
+ * Used by the new/removed ini directives sniffs.
49
+ * Key is the function name, value is the 1-based parameter position in the function call.
50
+ *
51
+ * @var array
52
+ */
53
+ protected $iniFunctions = array(
54
+ 'ini_get' => 1,
55
+ 'ini_set' => 1,
56
+ );
57
+
58
+
59
  /* The testVersion configuration variable may be in any of the following formats:
60
  * 1) Omitted/empty, in which case no version is specified. This effectively
61
  * disables all the checks provided by this standard.
143
  }//end supportsBelow()
144
 
145
 
146
+ /**
147
+ * Add a PHPCS message to the output stack as either a warning or an error.
148
+ *
149
+ * @param PHP_CodeSniffer_File $phpcsFile The file the message applies to.
150
+ * @param string $message The message.
151
+ * @param int $stackPtr The position of the token
152
+ * the message relates to.
153
+ * @param bool $isError Whether to report the message as an
154
+ * 'error' or 'warning'.
155
+ * Defaults to true (error).
156
+ * @param string $code The error code for the message.
157
+ * Defaults to 'Found'.
158
+ * @param array $data Optional input for the data replacements.
159
+ *
160
+ * @return void
161
+ */
162
+ public function addMessage($phpcsFile, $message, $stackPtr, $isError, $code = 'Found', $data = array())
163
+ {
164
+ if ($isError === true) {
165
+ $phpcsFile->addError($message, $stackPtr, $code, $data);
166
+ } else {
167
+ $phpcsFile->addWarning($message, $stackPtr, $code, $data);
168
+ }
169
+ }
170
+
171
+
172
+ /**
173
+ * Convert an arbitrary string to an alphanumeric string with underscores.
174
+ *
175
+ * Pre-empt issues with arbitrary strings being used as error codes in XML and PHP.
176
+ *
177
+ * @param string $baseString Arbitrary string.
178
+ *
179
+ * @return string
180
+ */
181
+ public function stringToErrorCode($baseString)
182
+ {
183
+ return preg_replace('`[^a-z0-9_]`i', '_', strtolower($baseString));
184
+ }
185
+
186
+
187
  /**
188
  * Strip quotes surrounding an arbitrary string.
189
  *
190
+ * Intended for use with the content of a T_CONSTANT_ENCAPSED_STRING / T_DOUBLE_QUOTED_STRING.
191
  *
192
  * @param string $string The raw string.
193
  *
198
  }
199
 
200
 
201
+ /**
202
+ * Strip variables from an arbitrary double quoted string.
203
+ *
204
+ * Intended for use with the content of a T_DOUBLE_QUOTED_STRING.
205
+ *
206
+ * @param string $string The raw string.
207
+ *
208
+ * @return string String without variables in it.
209
+ */
210
+ public function stripVariables($string) {
211
+ if (strpos($string, '$') === false) {
212
+ return $string;
213
+ }
214
+
215
+ return preg_replace( self::REGEX_COMPLEX_VARS, '', $string );
216
+ }
217
+
218
+
219
+ /**
220
+ * Make all top level array keys in an array lowercase.
221
+ *
222
+ * @param array $array Initial array.
223
+ *
224
+ * @return array Same array, but with all lowercase top level keys.
225
+ */
226
+ public function arrayKeysToLowercase($array)
227
+ {
228
+ $keys = array_keys($array);
229
+ $keys = array_map('strtolower', $keys);
230
+ return array_combine($keys, $array);
231
+ }
232
+
233
+
234
  /**
235
  * Returns the name(s) of the interface(s) that the specified class implements.
236
  *
301
  * Expects to be passed the T_STRING stack pointer for the function call.
302
  * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
303
  *
304
+ * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer, it
305
+ * will detect whether the array has values or is empty.
306
+ *
307
  * @link https://github.com/wimg/PHPCompatibility/issues/120
308
  * @link https://github.com/wimg/PHPCompatibility/issues/152
309
  *
321
  return false;
322
  }
323
 
324
+ // Is this one of the tokens this function handles ?
325
+ if (in_array($tokens[$stackPtr]['code'], array(T_STRING, T_ARRAY, T_OPEN_SHORT_ARRAY), true) === false) {
326
  return false;
327
  }
328
 
329
+ $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
330
+
331
+ // Deal with short array syntax.
332
+ if ($tokens[$stackPtr]['code'] === T_OPEN_SHORT_ARRAY) {
333
+ if (isset($tokens[$stackPtr]['bracket_closer']) === false) {
334
+ return false;
335
+ }
336
+
337
+ if ($nextNonEmpty === $tokens[$stackPtr]['bracket_closer']) {
338
+ // No parameters.
339
+ return false;
340
+ }
341
+ else {
342
+ return true;
343
+ }
344
+ }
345
+
346
+ // Deal with function calls & long arrays.
347
  // Next non-empty token should be the open parenthesis.
348
+ if ($nextNonEmpty === false && $tokens[$nextNonEmpty]['code'] !== T_OPEN_PARENTHESIS) {
 
349
  return false;
350
  }
351
 
352
+ if (isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false) {
353
  return false;
354
  }
355
 
356
+ $closeParenthesis = $tokens[$nextNonEmpty]['parenthesis_closer'];
357
+ $nextNextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $nextNonEmpty + 1, $closeParenthesis + 1, true);
358
 
359
+ if ($nextNextNonEmpty === $closeParenthesis) {
360
  // No parameters.
361
  return false;
362
  }
371
  * Expects to be passed the T_STRING stack pointer for the function call.
372
  * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
373
  *
374
+ * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer,
375
+ * it will return the number of values in the array.
376
+ *
377
  * @link https://github.com/wimg/PHPCompatibility/issues/111
378
  * @link https://github.com/wimg/PHPCompatibility/issues/114
379
  * @link https://github.com/wimg/PHPCompatibility/issues/151
403
  * pointer and raw parameter value for all parameters. Index will be 1-based.
404
  * If no parameters are found, will return an empty array.
405
  *
406
+ * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer,
407
+ * it will tokenize the values / key/value pairs contained in the array call.
408
+ *
409
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
410
  * @param int $stackPtr The position of the function call token.
411
  *
417
  return array();
418
  }
419
 
420
+ // Ok, we know we have a T_STRING, T_ARRAY or T_OPEN_SHORT_ARRAY with parameters
421
+ // and valid open & close brackets/parenthesis.
422
  $tokens = $phpcsFile->getTokens();
423
 
424
+ // Mark the beginning and end tokens.
425
+ if ($tokens[$stackPtr]['code'] === T_OPEN_SHORT_ARRAY) {
426
+ $opener = $stackPtr;
427
+ $closer = $tokens[$stackPtr]['bracket_closer'];
428
+
429
+ $nestedParenthesisCount = 0;
430
+ }
431
+ else {
432
+ $opener = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
433
+ $closer = $tokens[$opener]['parenthesis_closer'];
434
+
435
+ $nestedParenthesisCount = 1;
436
+ }
437
 
438
  // Which nesting level is the one we are interested in ?
439
+ if (isset($tokens[$opener]['nested_parenthesis'])) {
440
+ $nestedParenthesisCount += count($tokens[$opener]['nested_parenthesis']);
 
441
  }
442
 
443
  $parameters = array();
444
+ $nextComma = $opener;
445
+ $paramStart = $opener + 1;
446
  $cnt = 1;
447
+ while ($nextComma = $phpcsFile->findNext(array(T_COMMA, $tokens[$closer]['code'], T_OPEN_SHORT_ARRAY), $nextComma + 1, $closer + 1)) {
448
  // Ignore anything within short array definition brackets.
449
  if (
450
  $tokens[$nextComma]['type'] === 'T_OPEN_SHORT_ARRAY'
469
  continue;
470
  }
471
 
472
+ // Ignore closing parenthesis/bracket if not 'ours'.
473
+ if ($tokens[$nextComma]['type'] === $tokens[$closer]['type'] && $nextComma !== $closer) {
474
  continue;
475
  }
476
 
482
  // Check if there are more tokens before the closing parenthesis.
483
  // Prevents code like the following from setting a third parameter:
484
  // functionCall( $param1, $param2, );
485
+ $hasNextParam = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $nextComma + 1, $closer, true, null, true);
486
  if ($hasNextParam === false) {
487
  break;
488
  }
562
  return true;
563
  }
564
 
565
+ return $phpcsFile->hasCondition($stackPtr, $validScopes);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
566
  }
567
 
568
 
580
  public function inClassScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $strict = true)
581
  {
582
  $validScopes = array(T_CLASS);
583
+ if (defined('T_ANON_CLASS') === true) {
584
+ $validScopes[] = T_ANON_CLASS;
585
+ }
586
+
587
  if ($strict === false) {
588
  $validScopes[] = T_INTERFACE;
589
  $validScopes[] = T_TRAIT;
590
  }
591
 
592
+ return $phpcsFile->hasCondition($stackPtr, $validScopes);
593
  }
594
 
595
 
624
 
625
  // PHPCS 2.0.
626
  if ($isLowPHPCS === false) {
627
+ return $phpcsFile->hasCondition($stackPtr, T_USE);
628
  } else {
629
  // PHPCS 1.x.
630
  $tokens = $phpcsFile->getTokens();
1173
  }
1174
 
1175
  /**
1176
+ * Algorithm is a text string, so we need to remove the quotes.
1177
  */
1178
  $algo = strtolower(trim($algoParam['raw']));
1179
  $algo = $this->stripQuotes($algo);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php CHANGED
@@ -63,8 +63,8 @@ class PHPCompatibility_Sniffs_PHP_ConstantArraysUsingDefineSniff extends PHPComp
63
  return;
64
  }
65
 
66
- $function = strtolower($tokens[$stackPtr]['content']);
67
- if ($function !== 'define') {
68
  return;
69
  }
70
 
@@ -75,7 +75,11 @@ class PHPCompatibility_Sniffs_PHP_ConstantArraysUsingDefineSniff extends PHPComp
75
 
76
  $array = $phpcsFile->findNext(array(T_ARRAY, T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1));
77
  if ($array !== false) {
78
- $phpcsFile->addError('Constant arrays using define are not allowed in PHP 5.6 or earlier', $array);
 
 
 
 
79
  }
80
  }
81
  }
63
  return;
64
  }
65
 
66
+ $functionLc = strtolower($tokens[$stackPtr]['content']);
67
+ if ($functionLc !== 'define') {
68
  return;
69
  }
70
 
75
 
76
  $array = $phpcsFile->findNext(array(T_ARRAY, T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1));
77
  if ($array !== false) {
78
+ $phpcsFile->addError(
79
+ 'Constant arrays using define are not allowed in PHP 5.6 or earlier',
80
+ $array,
81
+ 'Found'
82
+ );
83
  }
84
  }
85
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php CHANGED
@@ -16,7 +16,7 @@
16
  * @package PHPCompatibility
17
  * @author Wim Godden <wim.godden@cu.be>
18
  */
19
- class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibility_Sniff
20
  {
21
  /**
22
  * A list of deprecated and removed functions with their alternatives.
@@ -757,14 +757,6 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
757
  ),
758
  );
759
 
760
- /**
761
- * List of just the function names.
762
- *
763
- * Will be set automatically in the register() method.
764
- *
765
- * @var array
766
- */
767
- protected $removedFunctionNames = array();
768
 
769
  /**
770
  * Returns an array of tokens this test wants to listen for.
@@ -773,9 +765,8 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
773
  */
774
  public function register()
775
  {
776
- // Everyone has had a chance to figure out what removed functions
777
- // they want to check for, so now we can cache out the list.
778
- $this->removedFunctionNames = array_keys($this->removedFunctions);
779
 
780
  return array(T_STRING);
781
 
@@ -810,63 +801,44 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
810
  return;
811
  }
812
 
813
- $function = strtolower($tokens[$stackPtr]['content']);
 
814
 
815
- if (in_array($function, $this->removedFunctionNames) === false) {
816
  return;
817
  }
818
 
819
- $this->addError($phpcsFile, $stackPtr, $function);
 
 
 
 
820
 
821
  }//end process()
822
 
 
823
  /**
824
- * Generates the error or warning for this sniff.
825
  *
826
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
827
- * @param int $stackPtr The position of the function
828
- * in the token array.
829
- * @param string $function The name of the function.
830
  *
831
- * @return void
832
  */
833
- protected function addError($phpcsFile, $stackPtr, $function)
834
  {
835
- $error = '';
 
836
 
837
- $isError = false;
838
- $previousVersionStatus = null;
839
- foreach ($this->removedFunctions[$function] as $version => $removed) {
840
- if ($this->supportsAbove($version)) {
841
- if ($version != 'alternative') {
842
- if ($previousVersionStatus !== $removed) {
843
- $previousVersionStatus = $removed;
844
- if ($removed === true) {
845
- $isError = true;
846
- $error .= 'removed';
847
- } else {
848
- $error .= 'deprecated';
849
- }
850
- $error .= ' since PHP ' . $version . ' and ';
851
- }
852
- }
853
- }
854
- }
855
- if (strlen($error) > 0) {
856
- $error = 'Function ' . $function . '() is ' . $error;
857
- $error = substr($error, 0, strlen($error) - 5);
858
-
859
- if ($this->removedFunctions[$function]['alternative'] !== null) {
860
- $error .= '; use ' . $this->removedFunctions[$function]['alternative'] . ' instead';
861
- }
862
 
863
- if ($isError === true) {
864
- $phpcsFile->addError($error, $stackPtr);
865
- } else {
866
- $phpcsFile->addWarning($error, $stackPtr);
867
- }
868
- }
 
 
 
869
 
870
- }//end addError()
871
 
872
  }//end class
16
  * @package PHPCompatibility
17
  * @author Wim Godden <wim.godden@cu.be>
18
  */
19
+ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibility_AbstractRemovedFeatureSniff
20
  {
21
  /**
22
  * A list of deprecated and removed functions with their alternatives.
757
  ),
758
  );
759
 
 
 
 
 
 
 
 
 
760
 
761
  /**
762
  * Returns an array of tokens this test wants to listen for.
765
  */
766
  public function register()
767
  {
768
+ // Handle case-insensitivity of function names.
769
+ $this->removedFunctions = $this->arrayKeysToLowercase($this->removedFunctions);
 
770
 
771
  return array(T_STRING);
772
 
801
  return;
802
  }
803
 
804
+ $function = $tokens[$stackPtr]['content'];
805
+ $functionLc = strtolower($function);
806
 
807
+ if (isset($this->removedFunctions[$functionLc]) === false) {
808
  return;
809
  }
810
 
811
+ $itemInfo = array(
812
+ 'name' => $function,
813
+ 'nameLc' => $functionLc,
814
+ );
815
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
816
 
817
  }//end process()
818
 
819
+
820
  /**
821
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
822
  *
823
+ * @param array $itemInfo Base information about the item.
 
 
 
824
  *
825
+ * @return array Version and other information about the item.
826
  */
827
+ public function getItemArray(array $itemInfo)
828
  {
829
+ return $this->removedFunctions[$itemInfo['nameLc']];
830
+ }
831
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
832
 
833
+ /**
834
+ * Get the error message template for this sniff.
835
+ *
836
+ * @return string
837
+ */
838
+ protected function getErrorMsgTemplate()
839
+ {
840
+ return 'Function %s() is ';
841
+ }
842
 
 
843
 
844
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php CHANGED
@@ -20,13 +20,13 @@
20
  * @author Wim Godden <wim.godden@cu.be>
21
  * @copyright 2012 Cu.be Solutions bvba
22
  */
23
- class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompatibility_Sniff
24
  {
25
  /**
26
  * A list of deprecated INI directives.
27
  *
28
- * version => false means the directive was deprecated in that version.
29
- * version => true means it was removed in that version.
30
  *
31
  * @var array(string)
32
  */
@@ -225,8 +225,6 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
225
  {
226
  $tokens = $phpcsFile->getTokens();
227
 
228
- $isError = false;
229
-
230
  $ignore = array(
231
  T_DOUBLE_COLON,
232
  T_OBJECT_OPERATOR,
@@ -240,12 +238,12 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
240
  return;
241
  }
242
 
243
- $function = strtolower($tokens[$stackPtr]['content']);
244
- if ($function !== 'ini_get' && $function !== 'ini_set') {
245
  return;
246
  }
247
 
248
- $iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 1);
249
  if ($iniToken === false) {
250
  return;
251
  }
@@ -255,38 +253,69 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
255
  return;
256
  }
257
 
258
- $error = '';
 
 
 
 
259
 
260
- foreach ($this->deprecatedIniDirectives[$filteredToken] as $version => $removed)
261
- {
262
- if ($version !== 'alternative') {
263
- if ($this->supportsAbove($version)) {
264
- if ($removed === true) {
265
- $isError = ($function !== 'ini_get') ? true : false;
266
- $error .= " removed";
267
- } else {
268
- $isError = false;
269
- $error .= " deprecated";
270
- }
271
- $error .= " since PHP " . $version . " and";
272
- }
273
- }
274
- }
275
 
276
- if (strlen($error) > 0) {
277
- $error = "INI directive '" . $filteredToken . "' is" . $error;
278
- $error = substr($error, 0, strlen($error) - 4) . ".";
279
- if (isset($this->deprecatedIniDirectives[$filteredToken]['alternative'])) {
280
- $error .= " Use '" . $this->deprecatedIniDirectives[$filteredToken]['alternative'] . "' instead.";
281
- }
282
 
283
- if ($isError === true) {
284
- $phpcsFile->addError($error, $iniToken['end']);
285
- } else {
286
- $phpcsFile->addWarning($error, $iniToken['end']);
287
- }
 
 
 
 
 
 
 
 
 
 
288
  }
289
 
290
- }//end process()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
 
292
  }//end class
20
  * @author Wim Godden <wim.godden@cu.be>
21
  * @copyright 2012 Cu.be Solutions bvba
22
  */
23
+ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompatibility_AbstractRemovedFeatureSniff
24
  {
25
  /**
26
  * A list of deprecated INI directives.
27
  *
28
+ * The array lists : version number with false (deprecated) and true (removed).
29
+ * If's sufficient to list the first version where the ini directive was deprecated/removed.
30
  *
31
  * @var array(string)
32
  */
225
  {
226
  $tokens = $phpcsFile->getTokens();
227
 
 
 
228
  $ignore = array(
229
  T_DOUBLE_COLON,
230
  T_OBJECT_OPERATOR,
238
  return;
239
  }
240
 
241
+ $functionLc = strtolower($tokens[$stackPtr]['content']);
242
+ if (isset($this->iniFunctions[$functionLc]) === false) {
243
  return;
244
  }
245
 
246
+ $iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, $this->iniFunctions[$functionLc]);
247
  if ($iniToken === false) {
248
  return;
249
  }
253
  return;
254
  }
255
 
256
+ $itemInfo = array(
257
+ 'name' => $filteredToken,
258
+ 'functionLc' => $functionLc,
259
+ );
260
+ $this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo);
261
 
262
+ }//end process()
263
+
264
+
265
+ /**
266
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
267
+ *
268
+ * @param array $itemInfo Base information about the item.
269
+ *
270
+ * @return array Version and other information about the item.
271
+ */
272
+ public function getItemArray(array $itemInfo)
273
+ {
274
+ return $this->deprecatedIniDirectives[$itemInfo['name']];
275
+ }
 
276
 
 
 
 
 
 
 
277
 
278
+ /**
279
+ * Retrieve the relevant detail (version) information for use in an error message.
280
+ *
281
+ * @param array $itemArray Version and other information about the item.
282
+ * @param array $itemInfo Base information about the item.
283
+ *
284
+ * @return array
285
+ */
286
+ public function getErrorInfo(array $itemArray, array $itemInfo)
287
+ {
288
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
289
+
290
+ // Lower error level to warning if the function used was ini_get.
291
+ if ($errorInfo['error'] === true && $itemInfo['functionLc'] === 'ini_get') {
292
+ $errorInfo['error'] = false;
293
  }
294
 
295
+ return $errorInfo;
296
+ }
297
+
298
+
299
+ /**
300
+ * Get the error message template for this sniff.
301
+ *
302
+ * @return string
303
+ */
304
+ protected function getErrorMsgTemplate()
305
+ {
306
+ return "INI directive '%s' is ";
307
+ }
308
+
309
+
310
+ /**
311
+ * Get the error message template for suggesting an alternative for a specific sniff.
312
+ *
313
+ * @return string
314
+ */
315
+ protected function getAlternativeOptionTemplate()
316
+ {
317
+ return str_replace("%s", "'%s'", parent::getAlternativeOptionTemplate());
318
+ }
319
+
320
 
321
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php CHANGED
@@ -50,13 +50,17 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedNewReferenceSniff extends PHPCompati
50
  if ($this->supportsAbove('5.3')) {
51
  $tokens = $phpcsFile->getTokens();
52
  if ($tokens[$stackPtr - 1]['type'] == 'T_BITWISE_AND' || $tokens[$stackPtr - 2]['type'] == 'T_BITWISE_AND') {
53
- if ($this->supportsAbove('7.0')) {
54
- $error = 'Assigning the return value of new by reference is deprecated in PHP 5.3 and forbidden in PHP 7.0';
55
- $phpcsFile->addError($error, $stackPtr);
56
- } else {
57
- $error = 'Assigning the return value of new by reference is deprecated in PHP 5.3';
58
- $phpcsFile->addWarning($error, $stackPtr);
 
 
59
  }
 
 
60
  }
61
  }
62
 
50
  if ($this->supportsAbove('5.3')) {
51
  $tokens = $phpcsFile->getTokens();
52
  if ($tokens[$stackPtr - 1]['type'] == 'T_BITWISE_AND' || $tokens[$stackPtr - 2]['type'] == 'T_BITWISE_AND') {
53
+ $error = 'Assigning the return value of new by reference is deprecated in PHP 5.3';
54
+ $isError = false;
55
+ $errorCode = 'Deprecated';
56
+
57
+ if ($this->supportsAbove('7.0') === true) {
58
+ $error .= ' and forbidden in PHP 7.0';
59
+ $isError = true;
60
+ $errorCode = 'Forbidden';
61
  }
62
+
63
+ $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode);
64
  }
65
  }
66
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/EmptyNonVariableSniff.php CHANGED
@@ -147,7 +147,10 @@ class PHPCompatibility_Sniffs_PHP_EmptyNonVariableSniff extends PHPCompatibility
147
  */
148
  protected function addError($phpcsFile, $stackPtr)
149
  {
150
- $error = 'Only variables can be passed to empty() prior to PHP 5.5.';
151
- $phpcsFile->addError($error, $stackPtr, 'Found');
 
 
 
152
  }
153
  }
147
  */
148
  protected function addError($phpcsFile, $stackPtr)
149
  {
150
+ $phpcsFile->addError(
151
+ 'Only variables can be passed to empty() prior to PHP 5.5.',
152
+ $stackPtr,
153
+ 'Found'
154
+ );
155
  }
156
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueOutsideLoopSniff.php CHANGED
@@ -90,21 +90,18 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueOutsideLoopSniff extends
90
  }
91
 
92
  // If we're still here, no valid loop structure container has been found, so throw an error.
93
- $error = "Using '%s' outside of a loop or switch structure is invalid";
94
- $isError = false;
95
- $data = array(
96
- $token['content'],
97
- );
98
  if ($this->supportsAbove('7.0')) {
99
- $isError = true;
100
- $error .= ' and will throw a fatal error since PHP 7.0';
 
101
  }
102
 
103
- if ($isError === true) {
104
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
105
- } else {
106
- $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
107
- }
108
 
109
  }//end process()
110
 
90
  }
91
 
92
  // If we're still here, no valid loop structure container has been found, so throw an error.
93
+ $error = "Using '%s' outside of a loop or switch structure is invalid";
94
+ $isError = false;
95
+ $errorCode = 'Found';
96
+ $data = array($token['content']);
97
+
98
  if ($this->supportsAbove('7.0')) {
99
+ $error .= ' and will throw a fatal error since PHP 7.0';
100
+ $isError = true;
101
+ $errorCode = 'FatalError';
102
  }
103
 
104
+ $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
 
 
 
 
105
 
106
  }//end process()
107
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php CHANGED
@@ -24,8 +24,17 @@
24
  */
25
  class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueVariableArgumentsSniff extends PHPCompatibility_Sniff
26
  {
27
- const ERROR_TYPE_VARIABLE = 'a variable argument';
28
- const ERROR_TYPE_ZERO = '0 as an argument';
 
 
 
 
 
 
 
 
 
29
 
30
  /**
31
  * Returns an array of tokens this test wants to listen for.
@@ -55,7 +64,6 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueVariableArgumentsSniff e
55
 
56
  $tokens = $phpcsFile->getTokens();
57
  $nextSemicolonToken = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr), null, false);
58
- $isError = false;
59
  $errorType = '';
60
  for ($curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++) {
61
  if ($tokens[$curToken]['type'] === 'T_STRING') {
@@ -63,26 +71,26 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueVariableArgumentsSniff e
63
  // is an opening parenthesis then it's a function call.
64
  $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $curToken + 1, null, true);
65
  if ($tokens[$openBracket]['code'] === T_OPEN_PARENTHESIS) {
66
- $isError = true;
67
- $errorType = self::ERROR_TYPE_VARIABLE;
68
  break;
69
  }
70
  }
71
  else if (in_array($tokens[$curToken]['type'], array('T_VARIABLE', 'T_FUNCTION', 'T_CLOSURE'), true)) {
72
- $isError = true;
73
- $errorType = self::ERROR_TYPE_VARIABLE;
74
  break;
75
  }
76
  else if ($tokens[$curToken]['type'] === 'T_LNUMBER' && $tokens[$curToken]['content'] === '0') {
77
- $isError = true;
78
- $errorType = self::ERROR_TYPE_ZERO;
79
  break;
80
  }
81
  }
82
 
83
- if ($isError === true && !empty($errorType)) {
84
- $error = 'Using ' . $errorType . ' on break or continue is forbidden since PHP 5.4';
85
- $phpcsFile->addError($error, $stackPtr);
 
 
 
86
  }
87
 
88
  }//end process()
24
  */
25
  class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueVariableArgumentsSniff extends PHPCompatibility_Sniff
26
  {
27
+ /**
28
+ * Error types this sniff handles for forbidden break/continue arguments.
29
+ *
30
+ * Array key is the error code. Array value will be used as part of the error message.
31
+ *
32
+ * @var array
33
+ */
34
+ private $errorTypes = array(
35
+ 'variableArgument' => 'a variable argument',
36
+ 'zeroArgument' => '0 as an argument',
37
+ );
38
 
39
  /**
40
  * Returns an array of tokens this test wants to listen for.
64
 
65
  $tokens = $phpcsFile->getTokens();
66
  $nextSemicolonToken = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr), null, false);
 
67
  $errorType = '';
68
  for ($curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++) {
69
  if ($tokens[$curToken]['type'] === 'T_STRING') {
71
  // is an opening parenthesis then it's a function call.
72
  $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $curToken + 1, null, true);
73
  if ($tokens[$openBracket]['code'] === T_OPEN_PARENTHESIS) {
74
+ $errorType = 'variableArgument';
 
75
  break;
76
  }
77
  }
78
  else if (in_array($tokens[$curToken]['type'], array('T_VARIABLE', 'T_FUNCTION', 'T_CLOSURE'), true)) {
79
+ $errorType = 'variableArgument';
 
80
  break;
81
  }
82
  else if ($tokens[$curToken]['type'] === 'T_LNUMBER' && $tokens[$curToken]['content'] === '0') {
83
+ $errorType = 'zeroArgument';
 
84
  break;
85
  }
86
  }
87
 
88
+ if ($errorType !== '') {
89
+ $error = 'Using %s on break or continue is forbidden since PHP 5.4';
90
+ $errorCode = $errorType.'Found';
91
+ $data = array($this->errorTypes[$errorType]);
92
+
93
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
94
  }
95
 
96
  }//end process()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php CHANGED
@@ -117,11 +117,7 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenCallTimePassByReferenceSniff extends
117
  $errorCode = 'NotAllowed';
118
  }
119
 
120
- if ($isError === true) {
121
- $phpcsFile->addError($error, $parameter['start'], $errorCode);
122
- } else {
123
- $phpcsFile->addWarning($error, $parameter['start'], $errorCode);
124
- }
125
  }
126
  }
127
  }//end process()
117
  $errorCode = 'NotAllowed';
118
  }
119
 
120
+ $this->addMessage($phpcsFile, $error, $parameter['start'], $isError, $errorCode);
 
 
 
 
121
  }
122
  }
123
  }//end process()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php CHANGED
@@ -81,8 +81,11 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenEmptyListAssignmentSniff extends PHPC
81
  }
82
 
83
  if ($error === true) {
84
- $error = 'Empty list() assignments are not allowed since PHP 7.0';
85
- $phpcsFile->addError($error, $stackPtr);
 
 
 
86
  }
87
  }
88
  }
81
  }
82
 
83
  if ($error === true) {
84
+ $phpcsFile->addError(
85
+ 'Empty list() assignments are not allowed since PHP 7.0',
86
+ $stackPtr,
87
+ 'Found'
88
+ );
89
  }
90
  }
91
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php CHANGED
@@ -69,7 +69,11 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenFunctionParametersWithSameNameSniff e
69
  }
70
 
71
  if (count($paramNames) != count(array_unique($paramNames))) {
72
- $phpcsFile->addError('Functions can not have multiple parameters with the same name since PHP 7.0', $stackPtr);
 
 
 
 
73
  }
74
 
75
  }//end process()
69
  }
70
 
71
  if (count($paramNames) != count(array_unique($paramNames))) {
72
+ $phpcsFile->addError(
73
+ 'Functions can not have multiple parameters with the same name since PHP 7.0',
74
+ $stackPtr,
75
+ 'Found'
76
+ );
77
  }
78
 
79
  }//end process()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenGlobalVariableVariableSniff.php CHANGED
@@ -44,15 +44,35 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenGlobalVariableVariableSniff extends P
44
  */
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
- if ($this->supportsAbove('7.0')) {
48
- $tokens = $phpcsFile->getTokens();
 
49
 
50
- $variable = $phpcsFile->findNext(T_VARIABLE, $stackPtr, $stackPtr + 4, false);
 
 
 
 
 
51
 
52
- if (isset($tokens[$variable - 1]) && $tokens[$variable - 1]['type'] == 'T_DOLLAR') {
53
- $error = 'Global with variable variables is not allowed since PHP 7.0';
54
- $phpcsFile->addError($error, $stackPtr);
 
 
 
 
 
 
55
  }
 
 
 
 
 
 
 
 
56
  }
57
  }
58
  }
44
  */
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
+ if ($this->supportsAbove('7.0') === false) {
48
+ return;
49
+ }
50
 
51
+ $tokens = $phpcsFile->getTokens();
52
+ $endOfStatement = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1));
53
+ if ($endOfStatement === false) {
54
+ // No semi-colon - live coding.
55
+ return;
56
+ }
57
 
58
+ for ($ptr = ($stackPtr + 1); $ptr <= $endOfStatement; $ptr++) {
59
+ $variable = $phpcsFile->findNext(T_VARIABLE, $ptr, $endOfStatement, false, null, true);
60
+ if ($variable !== false && (isset($tokens[$variable - 1]) && $tokens[$variable - 1]['type'] === 'T_DOLLAR')) {
61
+ $phpcsFile->addError(
62
+ 'Global with variable variables is not allowed since PHP 7.0',
63
+ $stackPtr,
64
+ 'Found'
65
+ );
66
+ return;
67
  }
68
+
69
+ // Move the stack pointer forward to the next variable for multi-variable statements.
70
+ $nextComma = $phpcsFile->findNext(T_COMMA, $ptr, $endOfStatement, false, null, true);
71
+ if ($nextComma === false) {
72
+ break;
73
+ }
74
+
75
+ $ptr = $nextComma;
76
  }
77
  }
78
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsDeclaredSniff.php CHANGED
@@ -53,6 +53,8 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsDeclaredSniff extends PHPCompa
53
  'object' => '7.0',
54
  'mixed' => '7.0',
55
  'numeric' => '7.0',
 
 
56
  );
57
 
58
 
@@ -141,23 +143,23 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsDeclaredSniff extends PHPCompa
141
 
142
  $nextNonEmptyCode = $tokens[$nextNonEmpty]['code'];
143
 
144
- if ($nextNonEmptyCode !== T_STRING && isset($this->forbiddenTokens[$nextNonEmptyCode]) === true) {
145
  $name = $tokens[$nextNonEmpty]['content'];
146
  $nameLc = strtolower($tokens[$nextNonEmpty]['content']);
147
  } else if ($nextNonEmptyCode === T_STRING) {
148
- $endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON, T_OPEN_CURLY_BRACKET), ($stackPtr + 1));
149
-
150
- do {
151
- $nextNonEmptyLc = strtolower($tokens[$nextNonEmpty]['content']);
152
-
153
- if (isset($this->forbiddenNames[$nextNonEmptyLc]) === true) {
154
- $name = $tokens[$nextNonEmpty]['content'];
155
- $nameLc = $nextNonEmptyLc;
156
- break;
157
- }
158
-
159
- $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextNonEmpty + 1), $endOfStatement, true);
160
- } while ($nextNonEmpty !== false);
161
  }
162
  unset($nextNonEmptyCode, $nextNonEmptyLc, $endOfStatement);
163
  }
@@ -169,14 +171,15 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsDeclaredSniff extends PHPCompa
169
  // Still here, so this is one of the reserved words.
170
  $version = $this->forbiddenNames[$nameLc];
171
  if ($this->supportsAbove($version) === true) {
172
- $error = "'%s' is a reserved keyword as of PHP version %s and cannot be used to name a class, interface or trait or as part of a namespace (%s)";
173
- $data = array(
 
174
  $nameLc,
175
  $version,
176
  $tokens[$stackPtr]['type'],
177
  );
178
 
179
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
180
  }
181
  }//end process()
182
 
53
  'object' => '7.0',
54
  'mixed' => '7.0',
55
  'numeric' => '7.0',
56
+ 'iterable' => '7.1',
57
+ 'void' => '7.1',
58
  );
59
 
60
 
143
 
144
  $nextNonEmptyCode = $tokens[$nextNonEmpty]['code'];
145
 
146
+ if ($nextNonEmptyCode !== T_STRING && isset($this->forbiddenTokens[$nextNonEmptyCode]) === true) {
147
  $name = $tokens[$nextNonEmpty]['content'];
148
  $nameLc = strtolower($tokens[$nextNonEmpty]['content']);
149
  } else if ($nextNonEmptyCode === T_STRING) {
150
+ $endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON, T_OPEN_CURLY_BRACKET), ($stackPtr + 1));
151
+
152
+ do {
153
+ $nextNonEmptyLc = strtolower($tokens[$nextNonEmpty]['content']);
154
+
155
+ if (isset($this->forbiddenNames[$nextNonEmptyLc]) === true) {
156
+ $name = $tokens[$nextNonEmpty]['content'];
157
+ $nameLc = $nextNonEmptyLc;
158
+ break;
159
+ }
160
+
161
+ $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextNonEmpty + 1), $endOfStatement, true);
162
+ } while ($nextNonEmpty !== false);
163
  }
164
  unset($nextNonEmptyCode, $nextNonEmptyLc, $endOfStatement);
165
  }
171
  // Still here, so this is one of the reserved words.
172
  $version = $this->forbiddenNames[$nameLc];
173
  if ($this->supportsAbove($version) === true) {
174
+ $error = "'%s' is a reserved keyword as of PHP version %s and cannot be used to name a class, interface or trait or as part of a namespace (%s)";
175
+ $errorCode = $this->stringToErrorCode($nameLc).'Found';
176
+ $data = array(
177
  $nameLc,
178
  $version,
179
  $tokens[$stackPtr]['type'],
180
  );
181
 
182
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
183
  }
184
  }//end process()
185
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php CHANGED
@@ -34,7 +34,6 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff extends
34
  T_ABSTRACT => '5.0',
35
  T_CALLABLE => '5.4',
36
  T_CATCH => '5.0',
37
- T_CLONE => '5.0',
38
  T_FINAL => '5.0',
39
  T_FINALLY => '5.5',
40
  T_GOTO => '5.3',
@@ -138,13 +137,15 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff extends
138
  }
139
 
140
  if ($this->supportsAbove($version)) {
141
- $error = "'%s' is a reserved keyword introduced in PHP version %s and cannot be invoked as a function (%s)";
142
- $data = array(
 
143
  $tokenContentLc,
144
  $version,
145
  $tokens[$stackPtr]['type'],
146
  );
147
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
 
148
  }
149
  }//end process()
150
 
34
  T_ABSTRACT => '5.0',
35
  T_CALLABLE => '5.4',
36
  T_CATCH => '5.0',
 
37
  T_FINAL => '5.0',
38
  T_FINALLY => '5.5',
39
  T_GOTO => '5.3',
137
  }
138
 
139
  if ($this->supportsAbove($version)) {
140
+ $error = "'%s' is a reserved keyword introduced in PHP version %s and cannot be invoked as a function (%s)";
141
+ $errorCode = $this->stringToErrorCode($tokenContentLc).'Found';
142
+ $data = array(
143
  $tokenContentLc,
144
  $version,
145
  $tokens[$stackPtr]['type'],
146
  );
147
+
148
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
149
  }
150
  }//end process()
151
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNamesSniff.php CHANGED
@@ -228,18 +228,17 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesSniff extends PHPCompatibility_S
228
  $prevNonEmpty = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
229
  if ($prevNonEmpty !== false
230
  && $tokens[$prevNonEmpty]['type'] === 'T_NEW'
231
- && $tokens[$stackPtr]['type'] === 'T_ANON_CLASS'
232
  ) {
233
  return;
234
  }
235
 
236
  if ($this->supportsAbove($this->invalidNames[$nextContentLc])) {
237
- $error = "Function name, class name, namespace name or constant name can not be reserved keyword '%s' (since version %s)";
238
  $data = array(
239
  $tokens[$nextNonEmpty]['content'],
240
  $this->invalidNames[$nextContentLc],
241
  );
242
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
243
  }
244
 
245
  }//end processNonString()
@@ -277,20 +276,38 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesSniff extends PHPCompatibility_S
277
  return;
278
  }
279
 
280
- $defineName = strtolower($firstParam['raw']);
281
- $defineName = $this->stripQuotes($defineName);
282
 
283
- if (isset($this->invalidNames[$defineName]) && $this->supportsAbove($this->invalidNames[$defineName])) {
284
- $error = "Function name, class name, namespace name or constant name can not be reserved keyword '%s' (since PHP version %s)";
285
  $data = array(
286
  $defineName,
287
- $this->invalidNames[$defineName],
288
  );
289
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
290
  }
291
  }//end processString()
292
 
293
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  /**
295
  * Check if the current token code is for a token which can be considered
296
  * the end of a (partial) use statement.
228
  $prevNonEmpty = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
229
  if ($prevNonEmpty !== false
230
  && $tokens[$prevNonEmpty]['type'] === 'T_NEW'
231
+ && ($tokens[$stackPtr]['type'] === 'T_ANON_CLASS' || $tokens[$stackPtr]['type'] === 'T_CLASS')
232
  ) {
233
  return;
234
  }
235
 
236
  if ($this->supportsAbove($this->invalidNames[$nextContentLc])) {
 
237
  $data = array(
238
  $tokens[$nextNonEmpty]['content'],
239
  $this->invalidNames[$nextContentLc],
240
  );
241
+ $this->addError($phpcsFile, $stackPtr, $tokens[$nextNonEmpty]['content'], $data);
242
  }
243
 
244
  }//end processNonString()
276
  return;
277
  }
278
 
279
+ $defineName = $this->stripQuotes($firstParam['raw']);
280
+ $defineNameLc = strtolower($defineName);
281
 
282
+ if (isset($this->invalidNames[$defineNameLc]) && $this->supportsAbove($this->invalidNames[$defineNameLc])) {
 
283
  $data = array(
284
  $defineName,
285
+ $this->invalidNames[$defineNameLc],
286
  );
287
+ $this->addError($phpcsFile, $stackPtr, $defineNameLc, $data);
288
  }
289
  }//end processString()
290
 
291
 
292
+ /**
293
+ * Add the error message.
294
+ *
295
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
296
+ * @param int $stackPtr The position of the current token in the
297
+ * stack passed in $tokens.
298
+ * @param string $content The token content found.
299
+ * @param array $data The data to pass into the error message.
300
+ *
301
+ * @return void
302
+ */
303
+ protected function addError($phpcsFile, $stackPtr, $content, $data)
304
+ {
305
+ $error = "Function name, class name, namespace name or constant name can not be reserved keyword '%s' (since version %s)";
306
+ $errorCode = $this->stringToErrorCode($content).'Found';
307
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
308
+ }
309
+
310
+
311
  /**
312
  * Check if the current token code is for a token which can be considered
313
  * the end of a (partial) use statement.
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php CHANGED
@@ -57,8 +57,11 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshiftSniff extends PHPComp
57
  return;
58
  }
59
 
60
- $error = 'Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0';
61
- $phpcsFile->addError($error, $hasMinusSign);
 
 
 
62
 
63
  }//end process()
64
 
57
  return;
58
  }
59
 
60
+ $phpcsFile->addError(
61
+ 'Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0',
62
+ $hasMinusSign,
63
+ 'Found'
64
+ );
65
 
66
  }//end process()
67
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php CHANGED
@@ -65,7 +65,11 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenSwitchWithMultipleDefaultBlocksSniff
65
  }
66
 
67
  if ($defaultCount > 1) {
68
- $phpcsFile->addError('Switch statements can not have multiple default blocks since PHP 7.0', $stackPtr);
 
 
 
 
69
  }
70
  }//end process()
71
 
65
  }
66
 
67
  if ($defaultCount > 1) {
68
+ $phpcsFile->addError(
69
+ 'Switch statements can not have multiple default blocks since PHP 7.0',
70
+ $stackPtr,
71
+ 'Found'
72
+ );
73
  }
74
  }//end process()
75
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/InternalInterfacesSniff.php CHANGED
@@ -40,10 +40,8 @@ class PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff extends PHPCompatibili
40
  */
41
  public function register()
42
  {
43
- // Handle case-insensitivity of class names.
44
- $keys = array_keys( $this->internalInterfaces );
45
- $keys = array_map( 'strtolower', $keys );
46
- $this->internalInterfaces = array_combine( $keys, $this->internalInterfaces );
47
 
48
  return array(T_CLASS);
49
 
@@ -68,17 +66,20 @@ class PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff extends PHPCompatibili
68
  }
69
 
70
  foreach ($interfaces as $interface) {
71
- $lcInterface = strtolower($interface);
72
- if (isset($this->internalInterfaces[$lcInterface]) === true) {
73
- $error = 'The interface %s %s';
74
- $data = array(
 
75
  $interface,
76
- $this->internalInterfaces[$lcInterface],
77
  );
78
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
 
79
  }
80
  }
81
 
82
  }//end process()
83
 
 
84
  }//end class
40
  */
41
  public function register()
42
  {
43
+ // Handle case-insensitivity of interface names.
44
+ $this->internalInterfaces = $this->arrayKeysToLowercase($this->internalInterfaces);
 
 
45
 
46
  return array(T_CLASS);
47
 
66
  }
67
 
68
  foreach ($interfaces as $interface) {
69
+ $interfaceLc = strtolower($interface);
70
+ if (isset($this->internalInterfaces[$interfaceLc]) === true) {
71
+ $error = 'The interface %s %s';
72
+ $errorCode = $this->stringToErrorCode($interfaceLc).'Found';
73
+ $data = array(
74
  $interface,
75
+ $this->internalInterfaces[$interfaceLc],
76
  );
77
+
78
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
79
  }
80
  }
81
 
82
  }//end process()
83
 
84
+
85
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/LateStaticBindingSniff.php CHANGED
@@ -52,13 +52,19 @@ class PHPCompatibility_Sniffs_PHP_LateStaticBindingSniff extends PHPCompatibilit
52
  $inClass = $this->inClassScope($phpcsFile, $stackPtr, false);
53
 
54
  if ($inClass === true && $this->supportsBelow('5.2') === true) {
55
- $error = 'Late static binding is not supported in PHP 5.2 or earlier.';
56
- $phpcsFile->addError($error, $stackPtr, 'Found');
 
 
 
57
  }
58
 
59
  if ($inClass === false) {
60
- $error = 'Late static binding is not supported outside of class scope.';
61
- $phpcsFile->addError($error, $stackPtr, 'OutsideClassScope');
 
 
 
62
  }
63
 
64
  }//end process()
52
  $inClass = $this->inClassScope($phpcsFile, $stackPtr, false);
53
 
54
  if ($inClass === true && $this->supportsBelow('5.2') === true) {
55
+ $phpcsFile->addError(
56
+ 'Late static binding is not supported in PHP 5.2 or earlier.',
57
+ $stackPtr,
58
+ 'Found'
59
+ );
60
  }
61
 
62
  if ($inClass === false) {
63
+ $phpcsFile->addError(
64
+ 'Late static binding is not supported outside of class scope.',
65
+ $stackPtr,
66
+ 'OutsideClassScope'
67
+ );
68
  }
69
 
70
  }//end process()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/LongArraysSniff.php CHANGED
@@ -64,10 +64,11 @@ class PHPCompatibility_Sniffs_PHP_LongArraysSniff extends PHPCompatibility_Sniff
64
  return;
65
  }
66
 
67
- $tokens = $phpcsFile->getTokens();
 
68
 
69
  // Check if the variable name is in our blacklist.
70
- if (in_array(substr($tokens[$stackPtr]['content'], 1), $this->deprecated, true) === false) {
71
  return;
72
  }
73
 
@@ -100,17 +101,14 @@ class PHPCompatibility_Sniffs_PHP_LongArraysSniff extends PHPCompatibility_Sniff
100
  }
101
 
102
  // Still here, so throw an error/warning.
103
- $error = "The use of long predefined variables has been deprecated in 5.3%s; Found '%s'";
104
- $isError = $this->supportsAbove('5.4');
105
- $data = array(
106
- ($isError ? ' and removed in 5.4' : ''),
107
- $tokens[$stackPtr]['content']
 
108
  );
109
 
110
- if ($isError === true) {
111
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
112
- } else {
113
- $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
114
- }
115
  }
116
  }
64
  return;
65
  }
66
 
67
+ $tokens = $phpcsFile->getTokens();
68
+ $varName = substr($tokens[$stackPtr]['content'], 1);
69
 
70
  // Check if the variable name is in our blacklist.
71
+ if (in_array($varName, $this->deprecated, true) === false) {
72
  return;
73
  }
74
 
101
  }
102
 
103
  // Still here, so throw an error/warning.
104
+ $error = "The use of long predefined variables has been deprecated in PHP 5.3%s; Found '%s'";
105
+ $isError = $this->supportsAbove('5.4');
106
+ $errorCode = $this->stringToErrorCode($varName).'Found';
107
+ $data = array(
108
+ (($isError === true) ? ' and removed in PHP 5.4' : ''),
109
+ $tokens[$stackPtr]['content'],
110
  );
111
 
112
+ $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
 
 
 
 
113
  }
114
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/MbstringReplaceEModifierSniff.php CHANGED
@@ -73,21 +73,30 @@ class PHPCompatibility_Sniffs_PHP_MbstringReplaceEModifierSniff extends PHPCompa
73
  return;
74
  }
75
 
76
- $stringToken = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $optionsParam['start'], $optionsParam['end'] + 1);
77
  if ($stringToken === false) {
78
  // No string token found in the options parameter, so skip it (e.g. variable passed in).
79
  return;
80
  }
81
 
 
 
82
  /**
83
- * Get the content of any string tokens in the options parameter and remove the quotes.
84
  */
85
- $options = $this->stripQuotes($tokens[$stringToken]['content']);
86
- if ($stringToken !== $optionsParam['end']) {
87
- while ($stringToken = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stringToken + 1, $optionsParam['end'] + 1)) {
88
- if ($tokens[$stringToken]['code'] === T_CONSTANT_ENCAPSED_STRING) {
89
- $options .= $this->stripQuotes($tokens[$stringToken]['content']);
90
- }
 
 
 
 
 
 
 
91
  }
92
  }
93
 
@@ -99,7 +108,7 @@ class PHPCompatibility_Sniffs_PHP_MbstringReplaceEModifierSniff extends PHPCompa
99
  $error .= ' Use mb_ereg_replace_callback() instead (PHP 5.4.1+).';
100
  }
101
 
102
- $phpcsFile->addWarning($error, $stackPtr, 'Found');
103
  }
104
 
105
  }//end process()
73
  return;
74
  }
75
 
76
+ $stringToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$stringTokens, $optionsParam['start'], $optionsParam['end'] + 1);
77
  if ($stringToken === false) {
78
  // No string token found in the options parameter, so skip it (e.g. variable passed in).
79
  return;
80
  }
81
 
82
+ $options = '';
83
+
84
  /**
85
+ * Get the content of any string tokens in the options parameter and remove the quotes and variables.
86
  */
87
+ for ($i = $stringToken; $i <= $optionsParam['end']; $i++) {
88
+ if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens, true) === false) {
89
+ continue;
90
+ }
91
+
92
+ $content = $this->stripQuotes($tokens[$i]['content']);
93
+ if ($tokens[$i]['code'] === T_DOUBLE_QUOTED_STRING) {
94
+ $content = $this->stripVariables($content);
95
+ }
96
+ $content = trim($content);
97
+
98
+ if (empty($content) === false) {
99
+ $options .= $content;
100
  }
101
  }
102
 
108
  $error .= ' Use mb_ereg_replace_callback() instead (PHP 5.4.1+).';
109
  }
110
 
111
+ $phpcsFile->addWarning($error, $stackPtr, 'Deprecated');
112
  }
113
 
114
  }//end process()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewAnonymousClassesSniff.php CHANGED
@@ -56,7 +56,11 @@ class PHPCompatibility_Sniffs_PHP_NewAnonymousClassesSniff extends PHPCompatibil
56
  return;
57
  }
58
 
59
- $phpcsFile->addError('Anonymous classes are not supported in PHP 5.6 or earlier', $stackPtr);
 
 
 
 
60
 
61
  }//end process()
62
 
56
  return;
57
  }
58
 
59
+ $phpcsFile->addError(
60
+ 'Anonymous classes are not supported in PHP 5.6 or earlier',
61
+ $stackPtr,
62
+ 'Found'
63
+ );
64
 
65
  }//end process()
66
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewClassesSniff.php CHANGED
@@ -19,7 +19,7 @@
19
  * @version 1.0.0
20
  * @copyright 2013 Cu.be Solutions bvba
21
  */
22
- class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
23
  {
24
 
25
  /**
@@ -194,9 +194,7 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
194
  public function register()
195
  {
196
  // Handle case-insensitivity of class names.
197
- $keys = array_keys( $this->newClasses );
198
- $keys = array_map( 'strtolower', $keys );
199
- $this->newClasses = array_combine( $keys, $this->newClasses );
200
 
201
  return array(
202
  T_NEW,
@@ -246,45 +244,37 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
246
  return;
247
  }
248
 
249
- $this->addError($phpcsFile, $stackPtr, $className);
 
 
 
 
250
 
251
  }//end process()
252
 
253
 
254
  /**
255
- * Generates the error or warning for this sniff.
256
  *
257
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
258
- * @param int $stackPtr The position of the function
259
- * in the token array.
260
- * @param string $className The name of the class.
261
  *
262
- * @return void
263
  */
264
- protected function addError($phpcsFile, $stackPtr, $className)
265
  {
266
- $error = '';
267
- $isError = false;
268
- $classNameLc = strtolower($className);
269
 
270
- foreach ($this->newClasses[$classNameLc] as $version => $present) {
271
- if ($this->supportsBelow($version)) {
272
- if ($present === false) {
273
- $isError = true;
274
- $error .= 'not present in PHP version ' . $version . ' or earlier';
275
- }
276
- }
277
- }
278
- if (strlen($error) > 0) {
279
- $error = 'The built-in class ' . $className . ' is ' . $error;
280
 
281
- if ($isError === true) {
282
- $phpcsFile->addError($error, $stackPtr);
283
- } else {
284
- $phpcsFile->addWarning($error, $stackPtr);
285
- }
286
- }
 
 
 
287
 
288
- }//end addError()
289
 
290
  }//end class
19
  * @version 1.0.0
20
  * @copyright 2013 Cu.be Solutions bvba
21
  */
22
+ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_AbstractNewFeatureSniff
23
  {
24
 
25
  /**
194
  public function register()
195
  {
196
  // Handle case-insensitivity of class names.
197
+ $this->newClasses = $this->arrayKeysToLowercase($this->newClasses);
 
 
198
 
199
  return array(
200
  T_NEW,
244
  return;
245
  }
246
 
247
+ $itemInfo = array(
248
+ 'name' => $className,
249
+ 'nameLc' => $classNameLc,
250
+ );
251
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
252
 
253
  }//end process()
254
 
255
 
256
  /**
257
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
258
  *
259
+ * @param array $itemInfo Base information about the item.
 
 
 
260
  *
261
+ * @return array Version and other information about the item.
262
  */
263
+ public function getItemArray(array $itemInfo)
264
  {
265
+ return $this->newClasses[$itemInfo['nameLc']];
266
+ }
 
267
 
 
 
 
 
 
 
 
 
 
 
268
 
269
+ /**
270
+ * Get the error message template for this sniff.
271
+ *
272
+ * @return string
273
+ */
274
+ protected function getErrorMsgTemplate()
275
+ {
276
+ return 'The built-in class '.parent::getErrorMsgTemplate();
277
+ }
278
 
 
279
 
280
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewClosureSniff.php CHANGED
@@ -45,7 +45,11 @@ class PHPCompatibility_Sniffs_PHP_NewClosureSniff extends PHPCompatibility_Sniff
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
  if ($this->supportsBelow('5.2')) {
48
- $phpcsFile->addError('Closures / anonymous functions are not available in PHP 5.2 or earlier', $stackPtr);
 
 
 
 
49
  }
50
  }//end process()
51
 
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
  if ($this->supportsBelow('5.2')) {
48
+ $phpcsFile->addError(
49
+ 'Closures / anonymous functions are not available in PHP 5.2 or earlier',
50
+ $stackPtr,
51
+ 'Found'
52
+ );
53
  }
54
  }//end process()
55
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewConstVisibilitySniff.php CHANGED
@@ -59,8 +59,8 @@ class PHPCompatibility_Sniffs_PHP_NewConstVisibilitySniff extends PHPCompatibili
59
  if ($this->tokenHasScope($phpcsFile, $stackPtr, array(T_CLASS, T_INTERFACE)) === true && $this->supportsBelow('7.0') === true) {
60
  $error = 'Visibility indicators for class constants are not supported in PHP 7.0 or earlier. Found "%s const"';
61
  $data = array($tokens[$prevToken]['content']);
62
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
63
 
 
64
  }
65
 
66
  }//end process()
59
  if ($this->tokenHasScope($phpcsFile, $stackPtr, array(T_CLASS, T_INTERFACE)) === true && $this->supportsBelow('7.0') === true) {
60
  $error = 'Visibility indicators for class constants are not supported in PHP 7.0 or earlier. Found "%s const"';
61
  $data = array($tokens[$prevToken]['content']);
 
62
 
63
+ $phpcsFile->addError($error, $stackPtr, 'Found', $data);
64
  }
65
 
66
  }//end process()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewExecutionDirectivesSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompatibility_Sniff
18
  {
19
 
20
  /**
@@ -111,11 +111,15 @@ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompati
111
  implode(', ', array_keys($this->newDirectives)),
112
  $directiveContent,
113
  );
 
114
  $phpcsFile->addError($error, $stackPtr, 'InvalidDirectiveFound', $data);
115
  }
116
  else {
117
  // Check for valid directive for version.
118
- $this->maybeAddError($phpcsFile, $stackPtr, $directiveContent);
 
 
 
119
 
120
  // Check for valid directive value.
121
  $valuePtr = $phpcsFile->findNext($this->ignoreTokens, $directivePtr + 1, $closeParenthesis, true);
@@ -130,57 +134,115 @@ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompati
130
 
131
 
132
  /**
133
- * Generates a error or warning for this sniff.
134
  *
135
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
136
- * @param int $stackPtr The position of the declare statement
137
- * in the token array.
138
- * @param string $directive The directive.
139
  *
140
- * @return void
141
  */
142
- protected function maybeAddError($phpcsFile, $stackPtr, $directive)
143
  {
144
- $isError = false;
145
- $notInVersion = '';
146
- $conditionalVersion = '';
147
- foreach ($this->newDirectives[$directive] as $version => $present) {
148
- if (strpos($version, 'valid_') === false && $this->supportsBelow($version)) {
149
- if ($present === false) {
150
- $isError = true;
151
- $notInVersion = $version;
152
- }
153
- else if (is_string($present)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  // We cannot test for compilation option (ok, except by scraping the output of phpinfo...).
155
- $conditionalVersion = $version;
 
156
  }
157
  }
158
  }
159
- if ($notInVersion !== '' || $conditionalVersion !== '') {
160
- if ($isError === true && $notInVersion !== '') {
161
- $error = 'Directive %s is not present in PHP version %s or earlier';
162
- $errorCode = $directive . 'Found';
163
- $data = array(
164
- $directive,
165
- $notInVersion,
166
- );
167
-
168
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
169
- }
170
- else if($conditionalVersion !== '') {
171
- $error = 'Directive %s is present in PHP version %s but will be disregarded unless PHP is compiled with %s';
172
- $errorCode = $directive . 'Found';
173
- $data = array(
174
- $directive,
175
- $conditionalVersion,
176
- $this->newDirectives[$directive][$conditionalVersion],
177
- );
178
-
179
- $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
180
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  }
182
 
183
- }//end maybeAddError()
184
 
185
 
186
  /**
@@ -198,7 +260,7 @@ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompati
198
  $tokens = $phpcsFile->getTokens();
199
 
200
  $value = $tokens[$stackPtr]['content'];
201
- if ($tokens[$stackPtr]['code'] === T_CONSTANT_ENCAPSED_STRING) {
202
  $value = $this->stripQuotes($value);
203
  }
204
 
@@ -216,12 +278,14 @@ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompati
216
  }
217
 
218
  if ($isError === true) {
219
- $error = 'The execution directive %s does not seem to have a valid value. Please review. Found: %s';
220
- $data = array(
 
221
  $directive,
222
  $value,
223
  );
224
- $phpcsFile->addWarning($error, $stackPtr, 'InvalidDirectiveValueFound', $data);
 
225
  }
226
  }// addErrorOnInvalidValue()
227
 
@@ -270,4 +334,5 @@ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompati
270
  }
271
  }
272
 
 
273
  }//end class
14
  * @package PHPCompatibility
15
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompatibility_AbstractNewFeatureSniff
18
  {
19
 
20
  /**
111
  implode(', ', array_keys($this->newDirectives)),
112
  $directiveContent,
113
  );
114
+
115
  $phpcsFile->addError($error, $stackPtr, 'InvalidDirectiveFound', $data);
116
  }
117
  else {
118
  // Check for valid directive for version.
119
+ $itemInfo = array(
120
+ 'name' => $directiveContent,
121
+ );
122
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
123
 
124
  // Check for valid directive value.
125
  $valuePtr = $phpcsFile->findNext($this->ignoreTokens, $directivePtr + 1, $closeParenthesis, true);
134
 
135
 
136
  /**
137
+ * Determine whether an error/warning should be thrown for an item based on collected information.
138
  *
139
+ * @param array $errorInfo Detail information about an item.
 
 
 
140
  *
141
+ * @return bool
142
  */
143
+ protected function shouldThrowError(array $errorInfo)
144
  {
145
+ return ($errorInfo['not_in_version'] !== '' || $errorInfo['conditional_version'] !== '');
146
+ }
147
+
148
+
149
+ /**
150
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
151
+ *
152
+ * @param array $itemInfo Base information about the item.
153
+ *
154
+ * @return array Version and other information about the item.
155
+ */
156
+ public function getItemArray(array $itemInfo)
157
+ {
158
+ return $this->newDirectives[$itemInfo['name']];
159
+ }
160
+
161
+
162
+ /**
163
+ * Get an array of the non-PHP-version array keys used in a sub-array.
164
+ *
165
+ * @return array
166
+ */
167
+ protected function getNonVersionArrayKeys()
168
+ {
169
+ return array(
170
+ 'valid_value_callback',
171
+ 'valid_values',
172
+ );
173
+ }
174
+
175
+
176
+ /**
177
+ * Retrieve the relevant detail (version) information for use in an error message.
178
+ *
179
+ * @param array $itemArray Version and other information about the item.
180
+ * @param array $itemInfo Base information about the item.
181
+ *
182
+ * @return array
183
+ */
184
+ public function getErrorInfo(array $itemArray, array $itemInfo)
185
+ {
186
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
187
+ $errorInfo['conditional_version'] = '';
188
+ $errorInfo['condition'] = '';
189
+
190
+ $versionArray = $this->getVersionArray($itemArray);
191
+
192
+ if (empty($versionArray) === false) {
193
+ foreach ($versionArray as $version => $present) {
194
+ if (is_string($present) === true && $this->supportsBelow($version) === true) {
195
  // We cannot test for compilation option (ok, except by scraping the output of phpinfo...).
196
+ $errorInfo['conditional_version'] = $version;
197
+ $errorInfo['condition'] = $present;
198
  }
199
  }
200
  }
201
+
202
+ return $errorInfo;
203
+ }
204
+
205
+
206
+ /**
207
+ * Get the error message template for this sniff.
208
+ *
209
+ * @return string
210
+ */
211
+ protected function getErrorMsgTemplate()
212
+ {
213
+ return 'Directive '.parent::getErrorMsgTemplate();
214
+ }
215
+
216
+
217
+ /**
218
+ * Generates the error or warning for this item.
219
+ *
220
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
221
+ * @param int $stackPtr The position of the relevant token in
222
+ * the stack.
223
+ * @param array $itemInfo Base information about the item.
224
+ * @param array $errorInfo Array with detail (version) information
225
+ * relevant to the item.
226
+ *
227
+ * @return void
228
+ */
229
+ public function addError(PHP_CodeSniffer_File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
230
+ {
231
+ if ($errorInfo['not_in_version'] !== '') {
232
+ parent::addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo);
233
+ } else if ($errorInfo['conditional_version'] !== '') {
234
+ $error = 'Directive %s is present in PHP version %s but will be disregarded unless PHP is compiled with %s';
235
+ $errorCode = $this->stringToErrorCode($itemInfo['name']).'WithConditionFound';
236
+ $data = array(
237
+ $itemInfo['name'],
238
+ $errorInfo['conditional_version'],
239
+ $errorInfo['condition'],
240
+ );
241
+
242
+ $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
243
  }
244
 
245
+ }//end addError()
246
 
247
 
248
  /**
260
  $tokens = $phpcsFile->getTokens();
261
 
262
  $value = $tokens[$stackPtr]['content'];
263
+ if (in_array($tokens[$stackPtr]['code'], PHP_CodeSniffer_Tokens::$stringTokens, true) === true) {
264
  $value = $this->stripQuotes($value);
265
  }
266
 
278
  }
279
 
280
  if ($isError === true) {
281
+ $error = 'The execution directive %s does not seem to have a valid value. Please review. Found: %s';
282
+ $errorCode = $this->stringToErrorCode($directive).'InvalidValueFound';
283
+ $data = array(
284
  $directive,
285
  $value,
286
  );
287
+
288
+ $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
289
  }
290
  }// addErrorOnInvalidValue()
291
 
334
  }
335
  }
336
 
337
+
338
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewFunctionArrayDereferencingSniff.php CHANGED
@@ -75,7 +75,11 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionArrayDereferencingSniff extends PHP
75
  $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
76
  $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($closeParenthesis + 1), null, true, null, true);
77
  if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['type'] === 'T_OPEN_SQUARE_BRACKET') {
78
- $phpcsFile->addError('Function array dereferencing is not present in PHP version 5.3 or earlier', $nextNonEmpty);
 
 
 
 
79
  }
80
 
81
  }//end process()
75
  $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
76
  $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($closeParenthesis + 1), null, true, null, true);
77
  if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['type'] === 'T_OPEN_SQUARE_BRACKET') {
78
+ $phpcsFile->addError(
79
+ 'Function array dereferencing is not present in PHP version 5.3 or earlier',
80
+ $nextNonEmpty,
81
+ 'Found'
82
+ );
83
  }
84
 
85
  }//end process()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewFunctionParametersSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatibility_Sniff
18
  {
19
  /**
20
  * A list of new functions, not present in older versions.
@@ -730,13 +730,6 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
730
  );
731
 
732
 
733
- /**
734
- *
735
- * @var array
736
- */
737
- private $newFunctionParametersNames;
738
-
739
-
740
  /**
741
  * Returns an array of tokens this test wants to listen for.
742
  *
@@ -744,9 +737,8 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
744
  */
745
  public function register()
746
  {
747
- // Everyone has had a chance to figure out what functions
748
- // they want to check for, so now we can cache out the list.
749
- $this->newFunctionParametersNames = array_keys($this->newFunctionParameters);
750
 
751
  return array(T_STRING);
752
  }//end register()
@@ -777,9 +769,10 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
777
  return;
778
  }
779
 
780
- $function = strtolower($tokens[$stackPtr]['content']);
 
781
 
782
- if (in_array($function, $this->newFunctionParametersNames) === false) {
783
  return;
784
  }
785
 
@@ -792,9 +785,14 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
792
  $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
793
  $parameterOffsetFound = $parameterCount - 1;
794
 
795
- foreach($this->newFunctionParameters[$function] as $offset => $parameterDetails) {
796
  if ($offset <= $parameterOffsetFound) {
797
- $this->addError($phpcsFile, $openParenthesis, $function, $offset);
 
 
 
 
 
798
  }
799
  }
800
 
@@ -802,39 +800,86 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
802
 
803
 
804
  /**
805
- * Generates the error or warning for this sniff.
806
  *
807
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
808
- * @param int $stackPtr The position of the function
809
- * in the token array.
810
- * @param string $function The name of the function.
811
- * @param int $parameterLocation The parameter position within the function call.
812
  *
813
- * @return void
814
  */
815
- protected function addError($phpcsFile, $stackPtr, $function, $parameterLocation)
816
  {
817
- $error = '';
 
818
 
819
- $isError = false;
820
- foreach ($this->newFunctionParameters[$function][$parameterLocation] as $version => $present) {
821
- if ($version != 'name' && $present === false && $this->supportsBelow($version)) {
822
- $isError = true;
823
- $error .= 'in PHP version ' . $version . ' or earlier';
824
- break;
825
- }
826
- }
827
 
828
- if (strlen($error) > 0) {
829
- $error = 'The function ' . $function . ' does not have a parameter "' . $this->newFunctionParameters[$function][$parameterLocation]['name'] . '" ' . $error;
 
 
 
 
 
 
 
830
 
831
- if ($isError === true) {
832
- $phpcsFile->addError($error, $stackPtr);
833
- } else {
834
- $phpcsFile->addWarning($error, $stackPtr);
835
- }
836
- }
837
 
838
- }//end addError()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
839
 
840
  }//end class
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatibility_AbstractNewFeatureSniff
18
  {
19
  /**
20
  * A list of new functions, not present in older versions.
730
  );
731
 
732
 
 
 
 
 
 
 
 
733
  /**
734
  * Returns an array of tokens this test wants to listen for.
735
  *
737
  */
738
  public function register()
739
  {
740
+ // Handle case-insensitivity of function names.
741
+ $this->newFunctionParameters = $this->arrayKeysToLowercase($this->newFunctionParameters);
 
742
 
743
  return array(T_STRING);
744
  }//end register()
769
  return;
770
  }
771
 
772
+ $function = $tokens[$stackPtr]['content'];
773
+ $functionLc = strtolower($function);
774
 
775
+ if (isset($this->newFunctionParameters[$functionLc]) === false) {
776
  return;
777
  }
778
 
785
  $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
786
  $parameterOffsetFound = $parameterCount - 1;
787
 
788
+ foreach($this->newFunctionParameters[$functionLc] as $offset => $parameterDetails) {
789
  if ($offset <= $parameterOffsetFound) {
790
+ $itemInfo = array(
791
+ 'name' => $function,
792
+ 'nameLc' => $functionLc,
793
+ 'offset' => $offset,
794
+ );
795
+ $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
796
  }
797
  }
798
 
800
 
801
 
802
  /**
803
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
804
  *
805
+ * @param array $itemInfo Base information about the item.
 
 
 
 
806
  *
807
+ * @return array Version and other information about the item.
808
  */
809
+ public function getItemArray(array $itemInfo)
810
  {
811
+ return $this->newFunctionParameters[$itemInfo['nameLc']][$itemInfo['offset']];
812
+ }
813
 
 
 
 
 
 
 
 
 
814
 
815
+ /**
816
+ * Get an array of the non-PHP-version array keys used in a sub-array.
817
+ *
818
+ * @return array
819
+ */
820
+ protected function getNonVersionArrayKeys()
821
+ {
822
+ return array('name');
823
+ }
824
 
 
 
 
 
 
 
825
 
826
+ /**
827
+ * Retrieve the relevant detail (version) information for use in an error message.
828
+ *
829
+ * @param array $itemArray Version and other information about the item.
830
+ * @param array $itemInfo Base information about the item.
831
+ *
832
+ * @return array
833
+ */
834
+ public function getErrorInfo(array $itemArray, array $itemInfo)
835
+ {
836
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
837
+ $errorInfo['paramName'] = $itemArray['name'];
838
+
839
+ return $errorInfo;
840
+ }
841
+
842
+
843
+ /**
844
+ * Get the item name to be used for the creation of the error code.
845
+ *
846
+ * @param array $itemInfo Base information about the item.
847
+ * @param array $errorInfo Detail information about an item.
848
+ *
849
+ * @return string
850
+ */
851
+ protected function getItemName(array $itemInfo, array $errorInfo)
852
+ {
853
+ return $itemInfo['name'].'_'.$errorInfo['paramName'];
854
+ }
855
+
856
+
857
+ /**
858
+ * Get the error message template for this sniff.
859
+ *
860
+ * @return string
861
+ */
862
+ protected function getErrorMsgTemplate()
863
+ {
864
+ return 'The function %s() does not have a parameter "%s" in PHP version %s or earlier';
865
+ }
866
+
867
+
868
+ /**
869
+ * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
870
+ *
871
+ * @param array $data The error data array which was created.
872
+ * @param array $itemInfo Base information about the item this error message applied to.
873
+ * @param array $errorInfo Detail information about an item this error message applied to.
874
+ *
875
+ * @return array
876
+ */
877
+ protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
878
+ {
879
+ array_shift($data);
880
+ array_unshift($data, $itemInfo['name'], $errorInfo['paramName']);
881
+ return $data;
882
+ }
883
+
884
 
885
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewFunctionsSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sniff
18
  {
19
  /**
20
  * A list of new functions, not present in older versions.
@@ -1242,13 +1242,6 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1242
  );
1243
 
1244
 
1245
- /**
1246
- *
1247
- * @var array
1248
- */
1249
- private $newFunctionNames;
1250
-
1251
-
1252
  /**
1253
  * Returns an array of tokens this test wants to listen for.
1254
  *
@@ -1256,11 +1249,8 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1256
  */
1257
  public function register()
1258
  {
1259
- // Everyone has had a chance to figure out what new functions
1260
- // they want to check for, so now we can cache out the list.
1261
- $this->newFunctionNames = array_keys($this->newFunctions);
1262
- $this->newFunctionNames = array_map('strtolower', $this->newFunctionNames);
1263
- $this->newFunctions = array_combine($this->newFunctionNames, $this->newFunctions);
1264
 
1265
  return array(T_STRING);
1266
 
@@ -1296,51 +1286,44 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1296
  return;
1297
  }
1298
 
1299
- $function = strtolower($tokens[$stackPtr]['content']);
 
1300
 
1301
- if (in_array($function, $this->newFunctionNames) === false) {
1302
  return;
1303
  }
1304
 
1305
- $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['content']);
 
 
 
 
1306
 
1307
  }//end process()
1308
 
1309
 
1310
  /**
1311
- * Generates the error or warning for this sniff.
1312
  *
1313
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
1314
- * @param int $stackPtr The position of the function
1315
- * in the token array.
1316
- * @param string $function The name of the function.
1317
  *
1318
- * @return void
1319
  */
1320
- protected function addError($phpcsFile, $stackPtr, $function)
1321
  {
1322
- $functionLc = strtolower($function);
1323
- $error = '';
1324
 
1325
- $isError = false;
1326
- foreach ($this->newFunctions[$functionLc] as $version => $present) {
1327
- if ($this->supportsBelow($version)) {
1328
- if ($present === false) {
1329
- $isError = true;
1330
- $error .= 'not present in PHP version ' . $version . ' or earlier';
1331
- }
1332
- }
1333
- }
1334
- if (strlen($error) > 0) {
1335
- $error = 'The function ' . $function . ' is ' . $error;
1336
 
1337
- if ($isError === true) {
1338
- $phpcsFile->addError($error, $stackPtr);
1339
- } else {
1340
- $phpcsFile->addWarning($error, $stackPtr);
1341
- }
1342
- }
 
 
 
1343
 
1344
- }//end addError()
1345
 
1346
  }//end class
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_AbstractNewFeatureSniff
18
  {
19
  /**
20
  * A list of new functions, not present in older versions.
1242
  );
1243
 
1244
 
 
 
 
 
 
 
 
1245
  /**
1246
  * Returns an array of tokens this test wants to listen for.
1247
  *
1249
  */
1250
  public function register()
1251
  {
1252
+ // Handle case-insensitivity of function names.
1253
+ $this->newFunctions = $this->arrayKeysToLowercase($this->newFunctions);
 
 
 
1254
 
1255
  return array(T_STRING);
1256
 
1286
  return;
1287
  }
1288
 
1289
+ $function = $tokens[$stackPtr]['content'];
1290
+ $functionLc = strtolower($function);
1291
 
1292
+ if (isset($this->newFunctions[$functionLc]) === false) {
1293
  return;
1294
  }
1295
 
1296
+ $itemInfo = array(
1297
+ 'name' => $function,
1298
+ 'nameLc' => $functionLc,
1299
+ );
1300
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
1301
 
1302
  }//end process()
1303
 
1304
 
1305
  /**
1306
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
1307
  *
1308
+ * @param array $itemInfo Base information about the item.
 
 
 
1309
  *
1310
+ * @return array Version and other information about the item.
1311
  */
1312
+ public function getItemArray(array $itemInfo)
1313
  {
1314
+ return $this->newFunctions[$itemInfo['nameLc']];
1315
+ }
1316
 
 
 
 
 
 
 
 
 
 
 
 
1317
 
1318
+ /**
1319
+ * Get the error message template for this sniff.
1320
+ *
1321
+ * @return string
1322
+ */
1323
+ protected function getErrorMsgTemplate()
1324
+ {
1325
+ return 'The function %s() is not present in PHP version %s or earlier';
1326
+ }
1327
 
 
1328
 
1329
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewGroupUseDeclarationsSniff.php CHANGED
@@ -25,10 +25,10 @@ class PHPCompatibility_Sniffs_PHP_NewGroupUseDeclarationsSniff extends PHPCompat
25
  */
26
  public function register()
27
  {
28
- if (version_compare(PHP_CodeSniffer::VERSION, '2.3.4') >= 0) {
29
  return array(T_OPEN_USE_GROUP);
30
  } else {
31
- return array();
32
  }
33
  }//end register()
34
 
@@ -44,8 +44,32 @@ class PHPCompatibility_Sniffs_PHP_NewGroupUseDeclarationsSniff extends PHPCompat
44
  */
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
- if ($this->supportsBelow('5.6')) {
48
- $phpcsFile->addError('Group use declarations are not allowed in PHP 5.6 or earlier', $stackPtr);
49
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }//end process()
51
  }//end class
25
  */
26
  public function register()
27
  {
28
+ if (defined('T_OPEN_USE_GROUP')) {
29
  return array(T_OPEN_USE_GROUP);
30
  } else {
31
+ return array(T_USE);
32
  }
33
  }//end register()
34
 
44
  */
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
+ if ($this->supportsBelow('5.6') === false) {
48
+ return;
49
  }
50
+
51
+ $tokens = $phpcsFile->getTokens();
52
+ $token = $tokens[$stackPtr];
53
+
54
+ // Deal with PHPCS pre-2.6.0.
55
+ if ($token['code'] === T_USE) {
56
+ $hasCurlyBrace = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1), null, false, null, true);
57
+ if ($hasCurlyBrace === false) {
58
+ return;
59
+ }
60
+
61
+ $prevToken = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($hasCurlyBrace - 1), null, true);
62
+ if ($prevToken === false || $tokens[$prevToken]['code'] !== T_NS_SEPARATOR) {
63
+ return;
64
+ }
65
+ }
66
+
67
+ // Still here ? In that case, it is a group use statement.
68
+ $phpcsFile->addError(
69
+ 'Group use declarations are not allowed in PHP 5.6 or earlier',
70
+ $stackPtr,
71
+ 'Found'
72
+ );
73
+
74
  }//end process()
75
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewHashAlgorithmsSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_NewHashAlgorithmsSniff extends PHPCompatibility_Sniff
18
  {
19
  /**
20
  * A list of new hash algorithms, not present in older versions.
@@ -106,63 +106,36 @@ class PHPCompatibility_Sniffs_PHP_NewHashAlgorithmsSniff extends PHPCompatibilit
106
  }
107
 
108
  // Check if the algorithm used is new.
109
- $errorInfo = $this->getErrorInfo($algo);
110
-
111
- if ($errorInfo['not_in_version'] !== '') {
112
- $this->addError($phpcsFile, $stackPtr, $algo, $errorInfo);
113
- }
114
 
115
  }//end process()
116
 
117
 
118
  /**
119
- * Retrieve the relevant (version) information for the error message.
120
  *
121
- * @param string $algorithm The name of the algorithm.
122
  *
123
- * @return array
124
  */
125
- protected function getErrorInfo($algorithm)
126
  {
127
- $errorInfo = array(
128
- 'not_in_version' => '',
129
- );
130
-
131
- foreach ($this->newAlgorithms[$algorithm] as $version => $present) {
132
- if ($present === false && $this->supportsBelow($version)) {
133
- $errorInfo['not_in_version'] = $version;
134
- }
135
- }
136
-
137
- return $errorInfo;
138
-
139
- }//end getErrorInfo()
140
 
141
 
142
  /**
143
- * Generates the error or warning for this sniff.
144
- *
145
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
146
- * @param int $stackPtr The position of the function
147
- * in the token array.
148
- * @param string $algorithm The name of the algorithm.
149
- * @param array $errorInfo Array with details about the versions
150
- * in which the algorithm was deprecated
151
- * and/or removed.
152
  *
153
- * @return void
154
  */
155
- protected function addError($phpcsFile, $stackPtr, $algorithm, $errorInfo)
156
  {
157
- $error = 'The %s hash algorithm is not present in PHP version %s or earlier ';
158
- $errorCode = $algorithm . 'Found';
159
- $data = array(
160
- $algorithm,
161
- $errorInfo['not_in_version'],
162
- );
163
-
164
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
165
 
166
- }//end addError()
167
 
168
  }//end class
14
  * @package PHPCompatibility
15
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_NewHashAlgorithmsSniff extends PHPCompatibility_AbstractNewFeatureSniff
18
  {
19
  /**
20
  * A list of new hash algorithms, not present in older versions.
106
  }
107
 
108
  // Check if the algorithm used is new.
109
+ $itemInfo = array(
110
+ 'name' => $algo,
111
+ );
112
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
 
113
 
114
  }//end process()
115
 
116
 
117
  /**
118
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
119
  *
120
+ * @param array $itemInfo Base information about the item.
121
  *
122
+ * @return array Version and other information about the item.
123
  */
124
+ public function getItemArray(array $itemInfo)
125
  {
126
+ return $this->newAlgorithms[$itemInfo['name']];
127
+ }
 
 
 
 
 
 
 
 
 
 
 
128
 
129
 
130
  /**
131
+ * Get the error message template for this sniff.
 
 
 
 
 
 
 
 
132
  *
133
+ * @return string
134
  */
135
+ protected function getErrorMsgTemplate()
136
  {
137
+ return 'The %s hash algorithm is not present in PHP version %s or earlier';
138
+ }
 
 
 
 
 
 
139
 
 
140
 
141
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewIniDirectivesSniff.php CHANGED
@@ -20,11 +20,14 @@
20
  * @author Wim Godden <wim.godden@cu.be>
21
  * @copyright 2013 Cu.be Solutions bvba
22
  */
23
- class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility_Sniff
24
  {
25
  /**
26
  * A list of new INI directives
27
  *
 
 
 
28
  * @var array(string)
29
  */
30
  protected $newIniDirectives = array(
@@ -496,12 +499,12 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
496
  return;
497
  }
498
 
499
- $function = strtolower($tokens[$stackPtr]['content']);
500
- if ($function != 'ini_get' && $function != 'ini_set') {
501
  return;
502
  }
503
 
504
- $iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 1);
505
  if ($iniToken === false) {
506
  return;
507
  }
@@ -511,33 +514,112 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
511
  return;
512
  }
513
 
514
- $notInVersion = '';
515
- foreach ($this->newIniDirectives[$filteredToken] as $version => $present) {
516
- if ($version !== 'alternative' && $present === false && $this->supportsBelow($version)) {
517
- $notInVersion = $version;
518
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  }
520
 
521
- if ($notInVersion !== '') {
522
- $error = "INI directive '%s' is not present in PHP version %s or earlier";
523
- $isError = ($function !== 'ini_get') ? true : false;
524
- $data = array(
525
- $filteredToken,
526
- $notInVersion
527
- );
528
- if (isset($this->newIniDirectives[$filteredToken]['alternative'])) {
529
- $error .= ". This directive was previously called '%s'.";
530
- $data[] = $this->newIniDirectives[$filteredToken]['alternative'];
531
- }
532
-
533
- if ($isError === true) {
534
- $phpcsFile->addError($error, $iniToken['end'], 'Found', $data);
535
- } else {
536
- $phpcsFile->addWarning($error, $iniToken['end'], 'Found', $data);
537
- }
538
  }
539
 
540
- }//end process()
 
541
 
542
 
543
  }//end class
20
  * @author Wim Godden <wim.godden@cu.be>
21
  * @copyright 2013 Cu.be Solutions bvba
22
  */
23
+ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility_AbstractNewFeatureSniff
24
  {
25
  /**
26
  * A list of new INI directives
27
  *
28
+ * The array lists : version number with false (not present) or true (present).
29
+ * If's sufficient to list the first version where the ini directive appears.
30
+ *
31
  * @var array(string)
32
  */
33
  protected $newIniDirectives = array(
499
  return;
500
  }
501
 
502
+ $functionLc = strtolower($tokens[$stackPtr]['content']);
503
+ if (isset($this->iniFunctions[$functionLc]) === false) {
504
  return;
505
  }
506
 
507
+ $iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, $this->iniFunctions[$functionLc]);
508
  if ($iniToken === false) {
509
  return;
510
  }
514
  return;
515
  }
516
 
517
+ $itemInfo = array(
518
+ 'name' => $filteredToken,
519
+ 'functionLc' => $functionLc,
520
+ );
521
+ $this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo);
522
+
523
+ }//end process()
524
+
525
+
526
+ /**
527
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
528
+ *
529
+ * @param array $itemInfo Base information about the item.
530
+ *
531
+ * @return array Version and other information about the item.
532
+ */
533
+ public function getItemArray(array $itemInfo)
534
+ {
535
+ return $this->newIniDirectives[$itemInfo['name']];
536
+ }
537
+
538
+
539
+ /**
540
+ * Get an array of the non-PHP-version array keys used in a sub-array.
541
+ *
542
+ * @return array
543
+ */
544
+ protected function getNonVersionArrayKeys()
545
+ {
546
+ return array('alternative');
547
+ }
548
+
549
+
550
+ /**
551
+ * Retrieve the relevant detail (version) information for use in an error message.
552
+ *
553
+ * @param array $itemArray Version and other information about the item.
554
+ * @param array $itemInfo Base information about the item.
555
+ *
556
+ * @return array
557
+ */
558
+ public function getErrorInfo(array $itemArray, array $itemInfo)
559
+ {
560
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
561
+ $errorInfo['alternative'] = '';
562
+
563
+ if (isset($itemArray['alternative']) === true) {
564
+ $errorInfo['alternative'] = $itemArray['alternative'];
565
+ }
566
+
567
+ // Lower error level to warning if the function used was ini_get.
568
+ if ($errorInfo['error'] === true && $itemInfo['functionLc'] === 'ini_get') {
569
+ $errorInfo['error'] = false;
570
+ }
571
+
572
+ return $errorInfo;
573
+ }
574
+
575
+
576
+ /**
577
+ * Get the error message template for this sniff.
578
+ *
579
+ * @return string
580
+ */
581
+ protected function getErrorMsgTemplate()
582
+ {
583
+ return "INI directive '%s' is not present in PHP version %s or earlier";
584
+ }
585
+
586
+
587
+ /**
588
+ * Allow for concrete child classes to filter the error message before it's passed to PHPCS.
589
+ *
590
+ * @param string $error The error message which was created.
591
+ * @param array $itemInfo Base information about the item this error message applied to.
592
+ * @param array $errorInfo Detail information about an item this error message applied to.
593
+ *
594
+ * @return string
595
+ */
596
+ protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
597
+ {
598
+ if ($errorInfo['alternative'] !== '') {
599
+ $error .= ". This directive was previously called '%s'.";
600
  }
601
 
602
+ return $error;
603
+ }
604
+
605
+
606
+ /**
607
+ * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
608
+ *
609
+ * @param array $data The error data array which was created.
610
+ * @param array $itemInfo Base information about the item this error message applied to.
611
+ * @param array $errorInfo Detail information about an item this error message applied to.
612
+ *
613
+ * @return array
614
+ */
615
+ protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
616
+ {
617
+ if ($errorInfo['alternative'] !== '') {
618
+ $data[] = $errorInfo['alternative'];
619
  }
620
 
621
+ return $data;
622
+ }
623
 
624
 
625
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewInterfacesSniff.php CHANGED
@@ -16,7 +16,7 @@
16
  * @package PHPCompatibility
17
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
  */
19
- class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_Sniff
20
  {
21
 
22
  /**
@@ -87,14 +87,9 @@ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_Sn
87
  */
88
  public function register()
89
  {
90
- // Handle case-insensitivity of class names.
91
- $keys = array_keys( $this->newInterfaces );
92
- $keys = array_map( 'strtolower', $keys );
93
- $this->newInterfaces = array_combine( $keys, $this->newInterfaces );
94
-
95
- $keys = array_keys( $this->unsupportedMethods );
96
- $keys = array_map( 'strtolower', $keys );
97
- $this->unsupportedMethods = array_combine( $keys, $this->unsupportedMethods );
98
 
99
  return array(T_CLASS);
100
 
@@ -127,27 +122,35 @@ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_Sn
127
  }
128
 
129
  foreach ($interfaces as $interface) {
130
- $lcInterface = strtolower($interface);
131
- if (isset($this->newInterfaces[$lcInterface]) === true) {
132
- $this->addError($phpcsFile, $stackPtr, $interface);
 
 
 
 
 
133
  }
134
 
135
- if ($checkMethods === true && isset($this->unsupportedMethods[$lcInterface]) === true) {
136
  $nextFunc = $stackPtr;
137
  while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
138
- $funcName = strtolower($phpcsFile->getDeclarationName($nextFunc));
139
- if ($funcName === '') {
 
140
  continue;
141
  }
142
 
143
- if (isset($this->unsupportedMethods[$lcInterface][$funcName]) === true) {
144
- $error = 'Classes that implement interface %s do not support the method %s(). See %s';
145
- $data = array(
 
146
  $interface,
147
  $funcName,
148
- $this->unsupportedMethods[$lcInterface][$funcName],
149
  );
150
- $phpcsFile->addError($error, $nextFunc, 'UnsupportedMethod', $data);
 
151
  }
152
  }
153
  }
@@ -157,40 +160,27 @@ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_Sn
157
 
158
 
159
  /**
160
- * Generates the error or warning for this sniff.
161
  *
162
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
163
- * @param int $stackPtr The position of the function
164
- * in the token array.
165
- * @param string $interface The name of the interface.
166
  *
167
- * @return void
168
  */
169
- protected function addError($phpcsFile, $stackPtr, $interface)
170
  {
171
- $interfaceLc = strtolower($interface);
172
- $error = '';
173
-
174
- $isError = false;
175
- foreach ($this->newInterfaces[$interfaceLc] as $version => $present) {
176
- if ($this->supportsBelow($version)) {
177
- if ($present === false) {
178
- $isError = true;
179
- $error .= 'not present in PHP version ' . $version . ' or earlier';
180
- }
181
- }
182
- }
183
 
184
- if (strlen($error) > 0) {
185
- $error = 'The built-in interface ' . $interface . ' is ' . $error;
186
 
187
- if ($isError === true) {
188
- $phpcsFile->addError($error, $stackPtr);
189
- } else {
190
- $phpcsFile->addWarning($error, $stackPtr);
191
- }
192
- }
 
 
 
193
 
194
- }//end addError()
195
 
196
  }//end class
16
  * @package PHPCompatibility
17
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
  */
19
+ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_AbstractNewFeatureSniff
20
  {
21
 
22
  /**
87
  */
88
  public function register()
89
  {
90
+ // Handle case-insensitivity of interface names.
91
+ $this->newInterfaces = $this->arrayKeysToLowercase($this->newInterfaces);
92
+ $this->unsupportedMethods = $this->arrayKeysToLowercase($this->unsupportedMethods);
 
 
 
 
 
93
 
94
  return array(T_CLASS);
95
 
122
  }
123
 
124
  foreach ($interfaces as $interface) {
125
+ $interfaceLc = strtolower($interface);
126
+
127
+ if (isset($this->newInterfaces[$interfaceLc]) === true) {
128
+ $itemInfo = array(
129
+ 'name' => $interface,
130
+ 'nameLc' => $interfaceLc,
131
+ );
132
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
133
  }
134
 
135
+ if ($checkMethods === true && isset($this->unsupportedMethods[$interfaceLc]) === true) {
136
  $nextFunc = $stackPtr;
137
  while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
138
+ $funcName = $phpcsFile->getDeclarationName($nextFunc);
139
+ $funcNameLc = strtolower($funcName);
140
+ if ($funcNameLc === '') {
141
  continue;
142
  }
143
 
144
+ if (isset($this->unsupportedMethods[$interfaceLc][$funcNameLc]) === true) {
145
+ $error = 'Classes that implement interface %s do not support the method %s(). See %s';
146
+ $errorCode = $this->stringToErrorCode($interface).'UnsupportedMethod';
147
+ $data = array(
148
  $interface,
149
  $funcName,
150
+ $this->unsupportedMethods[$interfaceLc][$funcNameLc],
151
  );
152
+
153
+ $phpcsFile->addError($error, $nextFunc, $errorCode, $data);
154
  }
155
  }
156
  }
160
 
161
 
162
  /**
163
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
164
  *
165
+ * @param array $itemInfo Base information about the item.
 
 
 
166
  *
167
+ * @return array Version and other information about the item.
168
  */
169
+ public function getItemArray(array $itemInfo)
170
  {
171
+ return $this->newInterfaces[$itemInfo['nameLc']];
172
+ }
 
 
 
 
 
 
 
 
 
 
173
 
 
 
174
 
175
+ /**
176
+ * Get the error message template for this sniff.
177
+ *
178
+ * @return string
179
+ */
180
+ protected function getErrorMsgTemplate()
181
+ {
182
+ return 'The built-in interface '.parent::getErrorMsgTemplate();
183
+ }
184
 
 
185
 
186
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewKeywordsSniff.php CHANGED
@@ -19,7 +19,7 @@
19
  * @version 1.0.0
20
  * @copyright 2013 Cu.be Solutions bvba
21
  */
22
- class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Sniff
23
  {
24
 
25
  /**
@@ -45,7 +45,7 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
45
  '5.2' => false,
46
  '5.3' => true,
47
  'description' => '"const" keyword',
48
- 'condition' => array(T_CLASS), // Keyword is only new when not in class context.
49
  ),
50
  'T_CALLABLE' => array(
51
  '5.3' => false,
@@ -218,43 +218,75 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
218
  }
219
  }
220
 
221
- $this->addError($phpcsFile, $stackPtr, $tokenType);
 
 
 
222
  }
 
223
  }//end process()
224
 
225
 
226
  /**
227
- * Generates the error or warning for this sniff.
228
  *
229
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
230
- * @param int $stackPtr The position of the function
231
- * in the token array.
232
- * @param string $keywordName The name of the keyword.
233
  *
234
- * @return void
235
  */
236
- protected function addError($phpcsFile, $stackPtr, $keywordName)
237
  {
238
- $notInVersion = '';
239
- foreach ($this->newKeywords[$keywordName] as $version => $present) {
240
- if (in_array($version, array('condition', 'description', 'content'), true)) {
241
- continue;
242
- }
243
 
244
- if ($present === false && $this->supportsBelow($version)) {
245
- $notInVersion = $version;
246
- }
247
- }
248
 
249
- if ($notInVersion !== '') {
250
- $error = '%s is not present in PHP version %s or earlier';
251
- $data = array(
252
- $this->newKeywords[$keywordName]['description'],
253
- $notInVersion,
254
- );
255
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
256
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
 
258
- }//end addError()
259
 
260
  }//end class
19
  * @version 1.0.0
20
  * @copyright 2013 Cu.be Solutions bvba
21
  */
22
+ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_AbstractNewFeatureSniff
23
  {
24
 
25
  /**
45
  '5.2' => false,
46
  '5.3' => true,
47
  'description' => '"const" keyword',
48
+ 'condition' => array(T_CLASS, T_INTERFACE), // Keyword is only new when not in class context.
49
  ),
50
  'T_CALLABLE' => array(
51
  '5.3' => false,
218
  }
219
  }
220
 
221
+ $itemInfo = array(
222
+ 'name' => $tokenType,
223
+ );
224
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
225
  }
226
+
227
  }//end process()
228
 
229
 
230
  /**
231
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
232
  *
233
+ * @param array $itemInfo Base information about the item.
 
 
 
234
  *
235
+ * @return array Version and other information about the item.
236
  */
237
+ public function getItemArray(array $itemInfo)
238
  {
239
+ return $this->newKeywords[$itemInfo['name']];
240
+ }
 
 
 
241
 
 
 
 
 
242
 
243
+ /**
244
+ * Get an array of the non-PHP-version array keys used in a sub-array.
245
+ *
246
+ * @return array
247
+ */
248
+ protected function getNonVersionArrayKeys()
249
+ {
250
+ return array(
251
+ 'description',
252
+ 'condition',
253
+ 'content',
254
+ );
255
+ }
256
+
257
+
258
+ /**
259
+ * Retrieve the relevant detail (version) information for use in an error message.
260
+ *
261
+ * @param array $itemArray Version and other information about the item.
262
+ * @param array $itemInfo Base information about the item.
263
+ *
264
+ * @return array
265
+ */
266
+ public function getErrorInfo(array $itemArray, array $itemInfo)
267
+ {
268
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
269
+ $errorInfo['description'] = $itemArray['description'];
270
+
271
+ return $errorInfo;
272
+
273
+ }
274
+
275
+
276
+ /**
277
+ * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
278
+ *
279
+ * @param array $data The error data array which was created.
280
+ * @param array $itemInfo Base information about the item this error message applied to.
281
+ * @param array $errorInfo Detail information about an item this error message applied to.
282
+ *
283
+ * @return array
284
+ */
285
+ protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
286
+ {
287
+ $data[0] = $errorInfo['description'];
288
+ return $data;
289
+ }
290
 
 
291
 
292
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewLanguageConstructsSniff.php CHANGED
@@ -19,7 +19,7 @@
19
  * @version 1.0.0
20
  * @copyright 2013 Cu.be Solutions bvba
21
  */
22
- class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatibility_Sniff
23
  {
24
 
25
  /**
@@ -159,44 +159,70 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib
159
  return;
160
  }
161
 
162
- $this->addError($phpcsFile, $stackPtr, $tokenType);
 
 
 
163
 
164
  }//end process()
165
 
166
 
167
  /**
168
- * Generates the error or warning for this sniff.
169
  *
170
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
171
- * @param int $stackPtr The position of the function
172
- * in the token array.
173
- * @param string $keywordName The name of the keyword.
174
  *
175
- * @return void
176
  */
177
- protected function addError($phpcsFile, $stackPtr, $keywordName)
178
  {
179
- $error = '';
180
-
181
- $isError = false;
182
- foreach ($this->newConstructs[$keywordName] as $version => $present) {
183
- if ($this->supportsBelow($version)) {
184
- if ($present === false) {
185
- $isError = true;
186
- $error .= 'not present in PHP version ' . $version . ' or earlier';
187
- }
188
- }
189
- }
190
- if (strlen($error) > 0) {
191
- $error = $this->newConstructs[$keywordName]['description'] . ' is ' . $error;
192
 
193
- if ($isError === true) {
194
- $phpcsFile->addError($error, $stackPtr);
195
- } else {
196
- $phpcsFile->addWarning($error, $stackPtr);
197
- }
198
- }
199
 
200
- }//end addError()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
 
202
  }//end class
19
  * @version 1.0.0
20
  * @copyright 2013 Cu.be Solutions bvba
21
  */
22
+ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatibility_AbstractNewFeatureSniff
23
  {
24
 
25
  /**
159
  return;
160
  }
161
 
162
+ $itemInfo = array(
163
+ 'name' => $tokenType,
164
+ );
165
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
166
 
167
  }//end process()
168
 
169
 
170
  /**
171
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
172
  *
173
+ * @param array $itemInfo Base information about the item.
 
 
 
174
  *
175
+ * @return array Version and other information about the item.
176
  */
177
+ public function getItemArray(array $itemInfo)
178
  {
179
+ return $this->newConstructs[$itemInfo['name']];
180
+ }
 
 
 
 
 
 
 
 
 
 
 
181
 
 
 
 
 
 
 
182
 
183
+ /**
184
+ * Get an array of the non-PHP-version array keys used in a sub-array.
185
+ *
186
+ * @return array
187
+ */
188
+ protected function getNonVersionArrayKeys()
189
+ {
190
+ return array('description');
191
+ }
192
+
193
+
194
+ /**
195
+ * Retrieve the relevant detail (version) information for use in an error message.
196
+ *
197
+ * @param array $itemArray Version and other information about the item.
198
+ * @param array $itemInfo Base information about the item.
199
+ *
200
+ * @return array
201
+ */
202
+ public function getErrorInfo(array $itemArray, array $itemInfo)
203
+ {
204
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
205
+ $errorInfo['description'] = $itemArray['description'];
206
+
207
+ return $errorInfo;
208
+
209
+ }
210
+
211
+
212
+ /**
213
+ * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
214
+ *
215
+ * @param array $data The error data array which was created.
216
+ * @param array $itemInfo Base information about the item this error message applied to.
217
+ * @param array $errorInfo Detail information about an item this error message applied to.
218
+ *
219
+ * @return array
220
+ */
221
+ protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
222
+ {
223
+ $data[0] = $errorInfo['description'];
224
+ return $data;
225
+ }
226
+
227
 
228
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewMagicMethodsSniff.php CHANGED
@@ -16,7 +16,7 @@
16
  * @package PHPCompatibility
17
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
  */
19
- class PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff extends PHPCompatibility_Sniff
20
  {
21
 
22
  /**
@@ -105,27 +105,89 @@ class PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff extends PHPCompatibility_
105
  return;
106
  }
107
 
108
- $lastVersionBelow = '';
109
- foreach ($this->newMagicMethods[$functionNameLc] as $version => $magic) {
110
- if ($version !== 'message' && $magic === false && $this->supportsBelow($version)) {
111
- $lastVersionBelow = $version;
112
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
114
 
115
- if ($lastVersionBelow !== '') {
116
- $error = 'The method %s() was not magical in PHP version %s and earlier. The associated magic functionality will not be invoked.';
117
- if (empty($this->newMagicMethods[$functionNameLc]['message']) === false) {
118
- $error = $this->newMagicMethods[$functionNameLc]['message'];
119
- }
120
 
121
- $data = array(
122
- $functionName,
123
- $lastVersionBelow,
124
- );
125
 
126
- $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  }
128
 
129
- }//end process()
 
 
130
 
131
  }//end class
16
  * @package PHPCompatibility
17
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
  */
19
+ class PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff extends PHPCompatibility_AbstractNewFeatureSniff
20
  {
21
 
22
  /**
105
  return;
106
  }
107
 
108
+ $itemInfo = array(
109
+ 'name' => $functionName,
110
+ 'nameLc' => $functionNameLc,
111
+ );
112
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
113
+
114
+ }//end process()
115
+
116
+
117
+ /**
118
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
119
+ *
120
+ * @param array $itemInfo Base information about the item.
121
+ *
122
+ * @return array Version and other information about the item.
123
+ */
124
+ public function getItemArray(array $itemInfo)
125
+ {
126
+ return $this->newMagicMethods[$itemInfo['nameLc']];
127
+ }
128
+
129
+
130
+ /**
131
+ * Get an array of the non-PHP-version array keys used in a sub-array.
132
+ *
133
+ * @return array
134
+ */
135
+ protected function getNonVersionArrayKeys()
136
+ {
137
+ return array('message');
138
+ }
139
+
140
+
141
+ /**
142
+ * Retrieve the relevant detail (version) information for use in an error message.
143
+ *
144
+ * @param array $itemArray Version and other information about the item.
145
+ * @param array $itemInfo Base information about the item.
146
+ *
147
+ * @return array
148
+ */
149
+ public function getErrorInfo(array $itemArray, array $itemInfo)
150
+ {
151
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
152
+ $errorInfo['error'] = false; // Warning, not error.
153
+ $errorInfo['message'] = '';
154
+
155
+ if (empty($itemArray['message']) === false) {
156
+ $errorInfo['message'] = $itemArray['message'];
157
  }
158
 
159
+ return $errorInfo;
160
+ }
 
 
 
161
 
 
 
 
 
162
 
163
+ /**
164
+ * Get the error message template for this sniff.
165
+ *
166
+ * @return string
167
+ */
168
+ protected function getErrorMsgTemplate()
169
+ {
170
+ return 'The method %s() was not magical in PHP version %s and earlier. The associated magic functionality will not be invoked.';
171
+ }
172
+
173
+
174
+ /**
175
+ * Allow for concrete child classes to filter the error message before it's passed to PHPCS.
176
+ *
177
+ * @param string $error The error message which was created.
178
+ * @param array $itemInfo Base information about the item this error message applied to.
179
+ * @param array $errorInfo Detail information about an item this error message applied to.
180
+ *
181
+ * @return string
182
+ */
183
+ protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
184
+ {
185
+ if ($errorInfo['message'] !== '') {
186
+ $error = $errorInfo['message'];
187
  }
188
 
189
+ return $error;
190
+ }
191
+
192
 
193
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewScalarReturnTypeDeclarationsSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends PHPCompatibility_Sniff
18
  {
19
 
20
  /**
@@ -77,48 +77,38 @@ class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends P
77
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
78
  {
79
  $tokens = $phpcsFile->getTokens();
80
- if (in_array($tokens[$stackPtr]['content'], array_keys($this->newTypes))) {
81
- $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['content']);
 
 
 
 
82
  }
83
  }//end process()
84
 
85
 
86
  /**
87
- * Generates the error or warning for this sniff.
88
  *
89
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
90
- * @param int $stackPtr The position of the function
91
- * in the token array.
92
- * @param string $typeName The type.
93
  *
94
- * @return void
95
  */
96
- protected function addError($phpcsFile, $stackPtr, $typeName)
97
  {
98
- $error = '';
 
99
 
100
- $isError = false;
101
- foreach ($this->newTypes[$typeName] as $version => $present) {
102
- if ($this->supportsBelow($version)) {
103
- if ($present === false) {
104
- $isError = true;
105
- $error .= 'not present in PHP version ' . $version . ' or earlier';
106
- }
107
- }
108
- }
109
- if (strlen($error) > 0) {
110
- $error = '%s return type is ' . $error;
111
- $data = array(
112
- $typeName,
113
- );
114
 
115
- if ($isError === true) {
116
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
117
- } else {
118
- $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
119
- }
120
- }
 
 
 
121
 
122
- }//end addError()
123
 
124
  }//end class
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends PHPCompatibility_AbstractNewFeatureSniff
18
  {
19
 
20
  /**
77
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
78
  {
79
  $tokens = $phpcsFile->getTokens();
80
+
81
+ if (isset($this->newTypes[$tokens[$stackPtr]['content']]) === true) {
82
+ $itemInfo = array(
83
+ 'name' => $tokens[$stackPtr]['content'],
84
+ );
85
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
86
  }
87
  }//end process()
88
 
89
 
90
  /**
91
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
92
  *
93
+ * @param array $itemInfo Base information about the item.
 
 
 
94
  *
95
+ * @return array Version and other information about the item.
96
  */
97
+ public function getItemArray(array $itemInfo)
98
  {
99
+ return $this->newTypes[$itemInfo['name']];
100
+ }
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
+ /**
104
+ * Get the error message template for this sniff.
105
+ *
106
+ * @return string
107
+ */
108
+ protected function getErrorMsgTemplate()
109
+ {
110
+ return '%s return type is not present in PHP version %s or earlier';
111
+ }
112
 
 
113
 
114
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NewScalarTypeDeclarationsSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPCompatibility_Sniff
18
  {
19
 
20
  /**
@@ -108,24 +108,34 @@ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPComp
108
  }
109
 
110
  if ($supportsPHP4 === true) {
111
- $error = 'Type hints were not present in PHP 4.4 or earlier.';
112
- $phpcsFile->addError($error, $stackPtr, 'TypeHintFound');
 
 
 
113
  }
114
  else if (isset($this->newTypes[$param['type_hint']])) {
115
- $this->addError($phpcsFile, $stackPtr, $param['type_hint']);
 
 
 
116
  }
117
  else if (isset($this->invalidTypes[$param['type_hint']])) {
118
  $error = "'%s' is not a valid type declaration. Did you mean %s ?";
119
- $data = array(
120
  $param['type_hint'],
121
  $this->invalidTypes[$param['type_hint']],
122
  );
 
123
  $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHintFound', $data);
124
  }
125
  else if ($param['type_hint'] === 'self') {
126
  if ($this->inClassScope($phpcsFile, $stackPtr) === false) {
127
- $error = "'self' type cannot be used outside of class scope";
128
- $phpcsFile->addError($error, $stackPtr, 'SelfOutsideClassScopeFound');
 
 
 
129
  }
130
  }
131
  }
@@ -133,38 +143,27 @@ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPComp
133
 
134
 
135
  /**
136
- * Generates the error or warning for this sniff.
137
  *
138
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
139
- * @param int $stackPtr The position of the function
140
- * in the token array.
141
- * @param string $typeName The type.
142
  *
143
- * @return void
144
  */
145
- protected function addError($phpcsFile, $stackPtr, $typeName)
146
  {
147
- $error = '';
148
-
149
- $isError = false;
150
- foreach ($this->newTypes[$typeName] as $version => $present) {
151
- if ($this->supportsBelow($version)) {
152
- if ($present === false) {
153
- $isError = true;
154
- $error .= 'not present in PHP version ' . $version . ' or earlier';
155
- }
156
- }
157
- }
158
- if (strlen($error) > 0) {
159
- $error = "'{$typeName}' type declaration is " . $error;
160
 
161
- if ($isError === true) {
162
- $phpcsFile->addError($error, $stackPtr);
163
- } else {
164
- $phpcsFile->addWarning($error, $stackPtr);
165
- }
166
- }
167
 
168
- }//end addError()
 
 
 
 
 
 
 
 
 
169
 
170
  }//end class
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPCompatibility_AbstractNewFeatureSniff
18
  {
19
 
20
  /**
108
  }
109
 
110
  if ($supportsPHP4 === true) {
111
+ $phpcsFile->addError(
112
+ 'Type hints were not present in PHP 4.4 or earlier.',
113
+ $stackPtr,
114
+ 'TypeHintFound'
115
+ );
116
  }
117
  else if (isset($this->newTypes[$param['type_hint']])) {
118
+ $itemInfo = array(
119
+ 'name' => $param['type_hint'],
120
+ );
121
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
122
  }
123
  else if (isset($this->invalidTypes[$param['type_hint']])) {
124
  $error = "'%s' is not a valid type declaration. Did you mean %s ?";
125
+ $data = array(
126
  $param['type_hint'],
127
  $this->invalidTypes[$param['type_hint']],
128
  );
129
+
130
  $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHintFound', $data);
131
  }
132
  else if ($param['type_hint'] === 'self') {
133
  if ($this->inClassScope($phpcsFile, $stackPtr) === false) {
134
+ $phpcsFile->addError(
135
+ "'self' type cannot be used outside of class scope",
136
+ $stackPtr,
137
+ 'SelfOutsideClassScopeFound'
138
+ );
139
  }
140
  }
141
  }
143
 
144
 
145
  /**
146
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
147
  *
148
+ * @param array $itemInfo Base information about the item.
 
 
 
149
  *
150
+ * @return array Version and other information about the item.
151
  */
152
+ public function getItemArray(array $itemInfo)
153
  {
154
+ return $this->newTypes[$itemInfo['name']];
155
+ }
 
 
 
 
 
 
 
 
 
 
 
156
 
 
 
 
 
 
 
157
 
158
+ /**
159
+ * Get the error message template for this sniff.
160
+ *
161
+ * @return string
162
+ */
163
+ protected function getErrorMsgTemplate()
164
+ {
165
+ return "'%s' type declaration is not present in PHP version %s or earlier";
166
+ }
167
+
168
 
169
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/NonStaticMagicMethodsSniff.php CHANGED
@@ -129,28 +129,29 @@ class PHPCompatibility_Sniffs_PHP_NonStaticMagicMethodsSniff extends PHPCompatib
129
  }
130
 
131
  $methodProperties = $phpcsFile->getMethodProperties($functionToken);
 
132
 
133
  if (isset($this->magicMethods[$methodNameLc]['visibility']) && $this->magicMethods[$methodNameLc]['visibility'] !== $methodProperties['scope']) {
134
- $error = 'Visibility for magic method %s must be %s. Found: %s';
135
- $data = array(
 
136
  $methodName,
137
  $this->magicMethods[$methodNameLc]['visibility'],
138
  $methodProperties['scope'],
139
  );
140
 
141
- $phpcsFile->addError($error, $functionToken, 'MethodVisibility', $data);
142
  }
143
 
144
  if (isset($this->magicMethods[$methodNameLc]['static']) && $this->magicMethods[$methodNameLc]['static'] !== $methodProperties['is_static']) {
145
  $error = 'Magic method %s cannot be defined as static.';
146
- $errorCode = 'MethodStatic';
 
 
147
  if ( $this->magicMethods[$methodNameLc]['static'] === true ) {
148
  $error = 'Magic method %s must be defined as static.';
149
- $errorCode = 'MethodNonStatic';
150
  }
151
- $data = array(
152
- $methodName,
153
- );
154
 
155
  $phpcsFile->addError($error, $functionToken, $errorCode, $data);
156
  }
129
  }
130
 
131
  $methodProperties = $phpcsFile->getMethodProperties($functionToken);
132
+ $errorCodeBase = $this->stringToErrorCode($methodNameLc);
133
 
134
  if (isset($this->magicMethods[$methodNameLc]['visibility']) && $this->magicMethods[$methodNameLc]['visibility'] !== $methodProperties['scope']) {
135
+ $error = 'Visibility for magic method %s must be %s. Found: %s';
136
+ $errorCode = $errorCodeBase.'MethodVisibility';
137
+ $data = array(
138
  $methodName,
139
  $this->magicMethods[$methodNameLc]['visibility'],
140
  $methodProperties['scope'],
141
  );
142
 
143
+ $phpcsFile->addError($error, $functionToken, $errorCode, $data);
144
  }
145
 
146
  if (isset($this->magicMethods[$methodNameLc]['static']) && $this->magicMethods[$methodNameLc]['static'] !== $methodProperties['is_static']) {
147
  $error = 'Magic method %s cannot be defined as static.';
148
+ $errorCode = $errorCodeBase.'MethodStatic';
149
+ $data = array($methodName);
150
+
151
  if ( $this->magicMethods[$methodNameLc]['static'] === true ) {
152
  $error = 'Magic method %s must be defined as static.';
153
+ $errorCode = $errorCodeBase.'MethodNonStatic';
154
  }
 
 
 
155
 
156
  $phpcsFile->addError($error, $functionToken, $errorCode, $data);
157
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php CHANGED
@@ -60,9 +60,11 @@ class PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff extends PHPCo
60
 
61
  foreach ($parameters as $param) {
62
  if (in_array($param['name'], $this->superglobals, true)) {
63
- $error = 'Parameter shadowing super global (%s) causes fatal error since PHP 5.4';
64
- $data = array($param['name']);
65
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
 
 
66
  }
67
  }
68
  }
60
 
61
  foreach ($parameters as $param) {
62
  if (in_array($param['name'], $this->superglobals, true)) {
63
+ $error = 'Parameter shadowing super global (%s) causes fatal error since PHP 5.4';
64
+ $errorCode = $this->stringToErrorCode(substr($param['name'], 1)).'Found';
65
+ $data = array($param['name']);
66
+
67
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
68
  }
69
  }
70
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/PregReplaceEModifierSniff.php CHANGED
@@ -78,20 +78,63 @@ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibi
78
  return;
79
  }
80
 
81
- // Get the first parameter in the function call as that should contain the regex.
82
  $firstParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 1);
83
  if ($firstParam === false) {
84
  return;
85
  }
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  /*
88
- * The first parameter might be build up of a combination of strings,
89
- * variables and function calls. We are only concerned with the strings.
90
  */
91
  $regex = '';
92
- for ($i = $firstParam['start']; $i <= $firstParam['end']; $i++ ) {
93
  if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens, true) === true) {
94
- $regex .= $this->stripQuotes($tokens[$i]['content']);
 
 
 
 
 
95
  }
96
  }
97
  // Deal with multi-line regexes which were broken up in several string tokens.
@@ -103,6 +146,13 @@ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibi
103
  }
104
 
105
  $regexFirstChar = substr($regex, 0, 1);
 
 
 
 
 
 
 
106
  if (isset($this->doublesSeparators[$regexFirstChar])) {
107
  $regexEndPos = strrpos($regex, $this->doublesSeparators[$regexFirstChar]);
108
  }
@@ -125,14 +175,9 @@ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibi
125
  $errorCode = 'Removed';
126
  }
127
 
128
- if ($isError === true) {
129
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
130
- } else {
131
- $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
132
- }
133
  }
134
  }
135
-
136
- }//end process()
137
 
138
  }//end class
78
  return;
79
  }
80
 
81
+ // Get the first parameter in the function call as that should contain the regex(es).
82
  $firstParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 1);
83
  if ($firstParam === false) {
84
  return;
85
  }
86
 
87
+ // Differentiate between an array of patterns passed and a single pattern.
88
+ $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $firstParam['start'], ($firstParam['end'] +1), true);
89
+ if ($nextNonEmpty !== false && ($tokens[$nextNonEmpty]['code'] === T_ARRAY || $tokens[$nextNonEmpty]['code'] === T_OPEN_SHORT_ARRAY)) {
90
+ $arrayValues = $this->getFunctionCallParameters($phpcsFile, $nextNonEmpty);
91
+ foreach ($arrayValues as $value) {
92
+ $hasKey = $phpcsFile->findNext(T_DOUBLE_ARROW, $value['start'], ($value['end'] + 1));
93
+ if ($hasKey !== false) {
94
+ $value['start'] = ($hasKey + 1);
95
+ $value['raw'] = trim($phpcsFile->getTokensAsString($value['start'], (($value['end'] + 1) - $value['start'])));
96
+ }
97
+
98
+ $this->processRegexPattern($value, $phpcsFile, $value['end'], $functionName);
99
+ }
100
+ }
101
+ else {
102
+ $this->processRegexPattern($firstParam, $phpcsFile, $stackPtr, $functionName);
103
+ }
104
+
105
+ }//end process()
106
+
107
+
108
+ /**
109
+ * Analyse a potential regex pattern for usage of the /e modifier.
110
+ *
111
+ * @param array $pattern Array containing the start and end token
112
+ * pointer of the potential regex pattern and
113
+ * the raw string value of the pattern.
114
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
115
+ * @param int $stackPtr The position of the current token in the
116
+ * stack passed in $tokens.
117
+ * @param string $functionName The function which contained the pattern.
118
+ *
119
+ * @return void
120
+ */
121
+ protected function processRegexPattern($pattern, $phpcsFile, $stackPtr, $functionName)
122
+ {
123
+ $tokens = $phpcsFile->getTokens();
124
+
125
  /*
126
+ * The pattern might be build up of a combination of strings, variables
127
+ * and function calls. We are only concerned with the strings.
128
  */
129
  $regex = '';
130
+ for ($i = $pattern['start']; $i <= $pattern['end']; $i++ ) {
131
  if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens, true) === true) {
132
+ $content = $this->stripQuotes($tokens[$i]['content']);
133
+ if ($tokens[$i]['code'] === T_DOUBLE_QUOTED_STRING) {
134
+ $content = $this->stripVariables($content);
135
+ }
136
+
137
+ $regex .= trim($content);
138
  }
139
  }
140
  // Deal with multi-line regexes which were broken up in several string tokens.
146
  }
147
 
148
  $regexFirstChar = substr($regex, 0, 1);
149
+
150
+ // Make sure that the character identified as the delimiter is valid.
151
+ // Otherwise, it is a false positive caused by the string concatenation.
152
+ if (preg_match('`[a-z0-9\\\\ ]`i', $regexFirstChar) === 1) {
153
+ return;
154
+ }
155
+
156
  if (isset($this->doublesSeparators[$regexFirstChar])) {
157
  $regexEndPos = strrpos($regex, $this->doublesSeparators[$regexFirstChar]);
158
  }
175
  $errorCode = 'Removed';
176
  }
177
 
178
+ $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
 
 
 
 
179
  }
180
  }
181
+ }//end processRegexPattern()
 
182
 
183
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedAlternativePHPTagsSniff.php CHANGED
@@ -111,8 +111,12 @@ class PHPCompatibility_Sniffs_PHP_RemovedAlternativePHPTagsSniff extends PHPComp
111
  }
112
 
113
  if (isset($errorCode, $data)) {
114
- $error = '%s style opening tags have been removed in PHP 7.0. Found "%s"';
115
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
 
 
 
 
116
  return;
117
  }
118
 
111
  }
112
 
113
  if (isset($errorCode, $data)) {
114
+ $phpcsFile->addError(
115
+ '%s style opening tags have been removed in PHP 7.0. Found "%s"',
116
+ $stackPtr,
117
+ $errorCode,
118
+ $data
119
+ );
120
  return;
121
  }
122
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedExtensionsSniff.php CHANGED
@@ -20,7 +20,7 @@
20
  * @author Wim Godden <wim.godden@cu.be>
21
  * @copyright 2012 Cu.be Solutions bvba
22
  */
23
- class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibility_Sniff
24
  {
25
  /**
26
  * A list of functions to whitelist, if any.
@@ -41,308 +41,130 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
41
 
42
  /**
43
  * A list of removed extensions with their alternative, if any
44
- * Array codes : 0 = removed/unavailable, -1 = deprecated, 1 = active
 
 
45
  *
46
  * @var array(string|null)
47
  */
48
  protected $removedExtensions = array(
49
  'activescript' => array(
50
- '5.0' => 1,
51
- '5.1' => 0,
52
- '5.2' => 0,
53
- '5.3' => 0,
54
- '5.4' => 0,
55
- '5.5' => 0,
56
- '5.6' => 0,
57
- '7.0' => 0,
58
  'alternative' => 'pecl/activescript'
59
  ),
60
  'cpdf' => array(
61
- '5.0' => 1,
62
- '5.1' => 0,
63
- '5.2' => 0,
64
- '5.3' => 0,
65
- '5.4' => 0,
66
- '5.5' => 0,
67
- '5.6' => 0,
68
- '7.0' => 0,
69
  'alternative' => 'pecl/pdflib'
70
  ),
71
  'dbase' => array(
72
- '5.0' => 1,
73
- '5.1' => 1,
74
- '5.2' => 1,
75
- '5.3' => 0,
76
- '5.4' => 0,
77
- '5.5' => 0,
78
- '5.6' => 0,
79
- '7.0' => 0,
80
  'alternative' => null
81
  ),
82
  'dbx' => array(
83
- '5.0' => 1,
84
- '5.1' => 0,
85
- '5.2' => 0,
86
- '5.3' => 0,
87
- '5.4' => 0,
88
- '5.5' => 0,
89
- '5.6' => 0,
90
- '7.0' => 0,
91
  'alternative' => 'pecl/dbx'
92
  ),
93
  'dio' => array(
94
- '5.0' => 1,
95
- '5.1' => 0,
96
- '5.2' => 0,
97
- '5.3' => 0,
98
- '5.4' => 0,
99
- '5.5' => 0,
100
- '5.6' => 0,
101
- '7.0' => 0,
102
  'alternative' => 'pecl/dio'
103
  ),
104
  'ereg' => array(
105
- '5.0' => 1,
106
- '5.1' => 1,
107
- '5.2' => 1,
108
- '5.3' => -1,
109
- '5.4' => -1,
110
- '5.5' => -1,
111
- '5.6' => -1,
112
- '7.0' => 0,
113
  'alternative' => 'pcre'
114
  ),
115
  'fam' => array(
116
- '5.0' => 1,
117
- '5.1' => 0,
118
- '5.2' => 0,
119
- '5.3' => 0,
120
- '5.4' => 0,
121
- '5.5' => 0,
122
- '5.6' => 0,
123
- '7.0' => 0,
124
  'alternative' => null
125
  ),
126
  'fbsql' => array(
127
- '5.0' => 1,
128
- '5.1' => 1,
129
- '5.2' => 1,
130
- '5.3' => 0,
131
- '5.4' => 0,
132
- '5.5' => 0,
133
- '5.6' => 0,
134
- '7.0' => 0,
135
  'alternative' => null
136
  ),
137
  'fdf' => array(
138
- '5.0' => 1,
139
- '5.1' => 1,
140
- '5.2' => 1,
141
- '5.3' => 0,
142
- '5.4' => 0,
143
- '5.5' => 0,
144
- '5.6' => 0,
145
- '7.0' => 0,
146
  'alternative' => 'pecl/fdf'
147
  ),
148
  'filepro' => array(
149
- '5.0' => 1,
150
- '5.1' => 1,
151
- '5.2' => 0,
152
- '5.3' => 0,
153
- '5.4' => 0,
154
- '5.5' => 0,
155
- '5.6' => 0,
156
- '7.0' => 0,
157
  'alternative' => null
158
  ),
159
  'hw_api' => array(
160
- '5.0' => 1,
161
- '5.1' => 1,
162
- '5.2' => 0,
163
- '5.3' => 0,
164
- '5.4' => 0,
165
- '5.5' => 0,
166
- '5.6' => 0,
167
- '7.0' => 0,
168
  'alternative' => null
169
  ),
170
  'ingres' => array(
171
- '5.0' => 1,
172
- '5.1' => 0,
173
- '5.2' => 0,
174
- '5.3' => 0,
175
- '5.4' => 0,
176
- '5.5' => 0,
177
- '5.6' => 0,
178
- '7.0' => 0,
179
  'alternative' => 'pecl/ingres'
180
  ),
181
  'ircg' => array(
182
- '5.0' => 1,
183
- '5.1' => 0,
184
- '5.2' => 0,
185
- '5.3' => 0,
186
- '5.4' => 0,
187
- '5.5' => 0,
188
- '5.6' => 0,
189
- '7.0' => 0,
190
  'alternative' => null
191
  ),
192
  'mcrypt' => array(
193
- '7.0' => 1,
194
- '7.1' => -1,
195
  'alternative' => 'openssl (preferred) or pecl/mcrypt once available'
196
  ),
197
  'mcve' => array(
198
- '5.0' => 1,
199
- '5.1' => 0,
200
- '5.2' => 0,
201
- '5.3' => 0,
202
- '5.4' => 0,
203
- '5.5' => 0,
204
- '5.6' => 0,
205
- '7.0' => 0,
206
  'alternative' => 'pecl/mvce'
207
  ),
208
  'ming' => array(
209
- '5.0' => 1,
210
- '5.1' => 1,
211
- '5.2' => 1,
212
- '5.3' => 0,
213
- '5.4' => 0,
214
- '5.5' => 0,
215
- '5.6' => 0,
216
- '7.0' => 0,
217
  'alternative' => 'pecl/ming'
218
  ),
219
  'mnogosearch' => array(
220
- '5.0' => 1,
221
- '5.1' => 0,
222
- '5.2' => 0,
223
- '5.3' => 0,
224
- '5.4' => 0,
225
- '5.5' => 0,
226
- '5.6' => 0,
227
- '7.0' => 0,
228
  'alternative' => null
229
  ),
230
  'msql' => array(
231
- '5.0' => 1,
232
- '5.1' => 1,
233
- '5.2' => 1,
234
- '5.3' => 0,
235
- '5.4' => 0,
236
- '5.5' => 0,
237
- '5.6' => 0,
238
- '7.0' => 0,
239
  'alternative' => null
240
  ),
241
  'mssql' => array(
242
- '7.0' => 0,
243
  'alternative' => null
244
  ),
245
  'mysql_' => array(
246
- '5.0' => 1,
247
- '5.1' => 1,
248
- '5.2' => 1,
249
- '5.3' => 1,
250
- '5.4' => 1,
251
- '5.5' => -1,
252
- '5.6' => -1,
253
- '7.0' => 0,
254
  'alternative' => 'mysqli',
255
  ),
256
  'ncurses' => array(
257
- '5.0' => 1,
258
- '5.1' => 1,
259
- '5.2' => 1,
260
- '5.3' => 0,
261
- '5.4' => 0,
262
- '5.5' => 0,
263
- '5.6' => 0,
264
- '7.0' => 0,
265
  'alternative' => 'pecl/ncurses'
266
  ),
267
  'oracle' => array(
268
- '5.0' => 1,
269
- '5.1' => 0,
270
- '5.2' => 0,
271
- '5.3' => 0,
272
- '5.4' => 0,
273
- '5.5' => 0,
274
- '5.6' => 0,
275
- '7.0' => 0,
276
  'alternative' => 'oci8 or pdo_oci'
277
  ),
278
  'ovrimos' => array(
279
- '5.0' => 1,
280
- '5.1' => 0,
281
- '5.2' => 0,
282
- '5.3' => 0,
283
- '5.4' => 0,
284
- '5.5' => 0,
285
- '5.6' => 0,
286
- '7.0' => 0,
287
  'alternative' => null
288
  ),
289
  'pfpro' => array(
290
- '5.0' => 1,
291
- '5.1' => 1,
292
- '5.2' => 1,
293
- '5.3' => 0,
294
- '5.4' => 0,
295
- '5.5' => 0,
296
- '5.6' => 0,
297
- '7.0' => 0,
298
  'alternative' => null
299
  ),
300
  'sqlite' => array(
301
- '5.0' => 1,
302
- '5.1' => 1,
303
- '5.2' => 1,
304
- '5.3' => 1,
305
- '5.4' => 0,
306
- '5.5' => 0,
307
- '5.6' => 0,
308
- '7.0' => 0,
309
  'alternative' => null
310
  ),
311
- 'sybase' => array(
312
- '5.0' => 1,
313
- '5.1' => 1,
314
- '5.2' => 1,
315
- '5.3' => 0,
316
- '5.4' => 0,
317
- '5.5' => 0,
318
- '5.6' => 0,
319
- '7.0' => 0,
320
- 'alternative' => 'sybase_ct'
321
- ),
322
  'sybase_ct' => array(
323
- '7.0' => 0,
324
  'alternative' => null
325
  ),
 
 
 
 
326
  'w32api' => array(
327
- '5.0' => 1,
328
- '5.1' => 0,
329
- '5.2' => 0,
330
- '5.3' => 0,
331
- '5.4' => 0,
332
- '5.5' => 0,
333
- '5.6' => 0,
334
- '7.0' => 0,
335
  'alternative' => 'pecl/ffi'
336
  ),
337
  'yp' => array(
338
- '5.0' => 1,
339
- '5.1' => 0,
340
- '5.2' => 0,
341
- '5.3' => 0,
342
- '5.4' => 0,
343
- '5.5' => 0,
344
- '5.6' => 0,
345
- '7.0' => 0,
346
  'alternative' => null
347
  ),
348
  );
@@ -354,6 +176,9 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
354
  */
355
  public function register()
356
  {
 
 
 
357
  return array(T_STRING);
358
 
359
  }//end register()
@@ -403,53 +228,27 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
403
  return;
404
  }
405
 
406
- if($this->isWhiteListed(strtolower($tokens[$stackPtr]['content'])) === true){
 
 
 
407
  // Function is whitelisted.
408
  return;
409
  }
410
 
411
  foreach ($this->removedExtensions as $extension => $versionList) {
412
- if (strpos(strtolower($tokens[$stackPtr]['content']), strtolower($extension)) === 0) {
413
- $error = '';
414
- $isErrored = false;
415
- $isDeprecated = false;
416
- foreach ($versionList as $version => $status) {
417
- if ($version != 'alternative') {
418
- if ($status == -1 || $status == 0) {
419
- if ($this->supportsAbove($version)) {
420
- switch ($status) {
421
- case -1:
422
- if($isDeprecated === false ) {
423
- $error .= 'deprecated since PHP ' . $version . ' and ';
424
- $isDeprecated = true;
425
- }
426
- break;
427
- case 0:
428
- $isErrored = true;
429
- $error .= 'removed since PHP ' . $version . ' and ';
430
- break 2;
431
- }
432
- }
433
- }
434
- }
435
- }
436
- if (strlen($error) > 0) {
437
- $error = "Extension '" . $extension . "' is " . $error;
438
- $error = substr($error, 0, strlen($error) - 5);
439
- if (!is_null($versionList['alternative'])) {
440
- $error .= ' - use ' . $versionList['alternative'] . ' instead.';
441
- }
442
- if ($isErrored === true) {
443
- $phpcsFile->addError($error, $stackPtr);
444
- } else {
445
- $phpcsFile->addWarning($error, $stackPtr);
446
- }
447
- }
448
  }
449
  }
450
 
451
  }//end process()
452
 
 
453
  /**
454
  * Is the current function being checked whitelisted ?
455
  *
@@ -481,4 +280,29 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
481
 
482
  }//end isWhiteListed()
483
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
  }//end class
20
  * @author Wim Godden <wim.godden@cu.be>
21
  * @copyright 2012 Cu.be Solutions bvba
22
  */
23
+ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibility_AbstractRemovedFeatureSniff
24
  {
25
  /**
26
  * A list of functions to whitelist, if any.
41
 
42
  /**
43
  * A list of removed extensions with their alternative, if any
44
+ *
45
+ * The array lists : version number with false (deprecated) and true (removed).
46
+ * If's sufficient to list the first version where the extension was deprecated/removed.
47
  *
48
  * @var array(string|null)
49
  */
50
  protected $removedExtensions = array(
51
  'activescript' => array(
52
+ '5.1' => true,
 
 
 
 
 
 
 
53
  'alternative' => 'pecl/activescript'
54
  ),
55
  'cpdf' => array(
56
+ '5.1' => true,
 
 
 
 
 
 
 
57
  'alternative' => 'pecl/pdflib'
58
  ),
59
  'dbase' => array(
60
+ '5.3' => true,
 
 
 
 
 
 
 
61
  'alternative' => null
62
  ),
63
  'dbx' => array(
64
+ '5.1' => true,
 
 
 
 
 
 
 
65
  'alternative' => 'pecl/dbx'
66
  ),
67
  'dio' => array(
68
+ '5.1' => true,
 
 
 
 
 
 
 
69
  'alternative' => 'pecl/dio'
70
  ),
71
  'ereg' => array(
72
+ '5.3' => false,
73
+ '7.0' => true,
 
 
 
 
 
 
74
  'alternative' => 'pcre'
75
  ),
76
  'fam' => array(
77
+ '5.1' => true,
 
 
 
 
 
 
 
78
  'alternative' => null
79
  ),
80
  'fbsql' => array(
81
+ '5.3' => true,
 
 
 
 
 
 
 
82
  'alternative' => null
83
  ),
84
  'fdf' => array(
85
+ '5.3' => true,
 
 
 
 
 
 
 
86
  'alternative' => 'pecl/fdf'
87
  ),
88
  'filepro' => array(
89
+ '5.2' => true,
 
 
 
 
 
 
 
90
  'alternative' => null
91
  ),
92
  'hw_api' => array(
93
+ '5.2' => true,
 
 
 
 
 
 
 
94
  'alternative' => null
95
  ),
96
  'ingres' => array(
97
+ '5.1' => true,
 
 
 
 
 
 
 
98
  'alternative' => 'pecl/ingres'
99
  ),
100
  'ircg' => array(
101
+ '5.1' => true,
 
 
 
 
 
 
 
102
  'alternative' => null
103
  ),
104
  'mcrypt' => array(
105
+ '7.1' => false,
 
106
  'alternative' => 'openssl (preferred) or pecl/mcrypt once available'
107
  ),
108
  'mcve' => array(
109
+ '5.1' => true,
 
 
 
 
 
 
 
110
  'alternative' => 'pecl/mvce'
111
  ),
112
  'ming' => array(
113
+ '5.3' => true,
 
 
 
 
 
 
 
114
  'alternative' => 'pecl/ming'
115
  ),
116
  'mnogosearch' => array(
117
+ '5.1' => true,
 
 
 
 
 
 
 
118
  'alternative' => null
119
  ),
120
  'msql' => array(
121
+ '5.3' => true,
 
 
 
 
 
 
 
122
  'alternative' => null
123
  ),
124
  'mssql' => array(
125
+ '7.0' => true,
126
  'alternative' => null
127
  ),
128
  'mysql_' => array(
129
+ '5.5' => false,
130
+ '7.0' => true,
 
 
 
 
 
 
131
  'alternative' => 'mysqli',
132
  ),
133
  'ncurses' => array(
134
+ '5.3' => true,
 
 
 
 
 
 
 
135
  'alternative' => 'pecl/ncurses'
136
  ),
137
  'oracle' => array(
138
+ '5.1' => true,
 
 
 
 
 
 
 
139
  'alternative' => 'oci8 or pdo_oci'
140
  ),
141
  'ovrimos' => array(
142
+ '5.1' => true,
 
 
 
 
 
 
 
143
  'alternative' => null
144
  ),
145
  'pfpro' => array(
146
+ '5.3' => true,
 
 
 
 
 
 
 
147
  'alternative' => null
148
  ),
149
  'sqlite' => array(
150
+ '5.4' => true,
 
 
 
 
 
 
 
151
  'alternative' => null
152
  ),
153
+ // Has to be before `sybase` as otherwise it will never match.
 
 
 
 
 
 
 
 
 
 
154
  'sybase_ct' => array(
155
+ '7.0' => true,
156
  'alternative' => null
157
  ),
158
+ 'sybase' => array(
159
+ '5.3' => true,
160
+ 'alternative' => 'sybase_ct'
161
+ ),
162
  'w32api' => array(
163
+ '5.1' => true,
 
 
 
 
 
 
 
164
  'alternative' => 'pecl/ffi'
165
  ),
166
  'yp' => array(
167
+ '5.1' => true,
 
 
 
 
 
 
 
168
  'alternative' => null
169
  ),
170
  );
176
  */
177
  public function register()
178
  {
179
+ // Handle case-insensitivity of function names.
180
+ $this->removedExtensions = $this->arrayKeysToLowercase($this->removedExtensions);
181
+
182
  return array(T_STRING);
183
 
184
  }//end register()
228
  return;
229
  }
230
 
231
+ $function = $tokens[$stackPtr]['content'];
232
+ $functionLc = strtolower($function);
233
+
234
+ if($this->isWhiteListed($functionLc) === true){
235
  // Function is whitelisted.
236
  return;
237
  }
238
 
239
  foreach ($this->removedExtensions as $extension => $versionList) {
240
+ if (strpos($functionLc, $extension) === 0) {
241
+ $itemInfo = array(
242
+ 'name' => $extension,
243
+ );
244
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
245
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  }
247
  }
248
 
249
  }//end process()
250
 
251
+
252
  /**
253
  * Is the current function being checked whitelisted ?
254
  *
280
 
281
  }//end isWhiteListed()
282
 
283
+
284
+ /**
285
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
286
+ *
287
+ * @param array $itemInfo Base information about the item.
288
+ *
289
+ * @return array Version and other information about the item.
290
+ */
291
+ public function getItemArray(array $itemInfo)
292
+ {
293
+ return $this->removedExtensions[$itemInfo['name']];
294
+ }
295
+
296
+
297
+ /**
298
+ * Get the error message template for this sniff.
299
+ *
300
+ * @return string
301
+ */
302
+ protected function getErrorMsgTemplate()
303
+ {
304
+ return "Extension '%s' is ";
305
+ }
306
+
307
+
308
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedFunctionParametersSniff.php CHANGED
@@ -14,14 +14,14 @@
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPCompatibility_Sniff
18
  {
19
  /**
20
  * A list of removed function parameters, which were present in older versions.
21
  *
22
- * The array lists : version number with true (deprecated) and false (removed).
23
  * The index is the location of the parameter in the parameter list, starting at 0 !
24
- * If's sufficient to list the first version where the function was deprecated/removed.
25
  *
26
  * @var array
27
  */
@@ -29,39 +29,32 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
29
  'gmmktime' => array(
30
  6 => array(
31
  'name' => 'is_dst',
32
- '5.1' => true, // deprecated
33
- '7.0' => false,
34
  ),
35
  ),
36
  'ldap_first_attribute' => array(
37
  2 => array(
38
  'name' => 'ber_identifier',
39
- '5.2.4' => false,
40
  ),
41
  ),
42
  'ldap_next_attribute' => array(
43
  2 => array(
44
  'name' => 'ber_identifier',
45
- '5.2.4' => false,
46
  ),
47
  ),
48
  'mktime' => array(
49
  6 => array(
50
  'name' => 'is_dst',
51
- '5.1' => true, // deprecated
52
- '7.0' => false,
53
  ),
54
  ),
55
  );
56
 
57
 
58
- /**
59
- *
60
- * @var array
61
- */
62
- private $removedFunctionParametersNames;
63
-
64
-
65
  /**
66
  * Returns an array of tokens this test wants to listen for.
67
  *
@@ -69,9 +62,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
69
  */
70
  public function register()
71
  {
72
- // Everyone has had a chance to figure out what removed function parameters
73
- // they want to check for, so now we can cache out the list.
74
- $this->removedFunctionParametersNames = array_keys($this->removedFunctionParameters);
75
 
76
  return array(T_STRING);
77
  }//end register()
@@ -102,9 +94,10 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
102
  return;
103
  }
104
 
105
- $function = strtolower($tokens[$stackPtr]['content']);
 
106
 
107
- if (in_array($function, $this->removedFunctionParametersNames) === false) {
108
  return;
109
  }
110
 
@@ -117,9 +110,14 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
117
  $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
118
  $parameterOffsetFound = $parameterCount - 1;
119
 
120
- foreach($this->removedFunctionParameters[$function] as $offset => $parameterDetails) {
121
  if ($offset <= $parameterOffsetFound) {
122
- $this->addError($phpcsFile, $openParenthesis, $function, $offset);
 
 
 
 
 
123
  }
124
  }
125
 
@@ -127,54 +125,86 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
127
 
128
 
129
  /**
130
- * Generates the error or warning for this sniff.
131
  *
132
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
133
- * @param int $stackPtr The position of the function
134
- * in the token array.
135
- * @param string $function The name of the function.
136
- * @param int $parameterLocation The parameter position within the function call.
137
  *
138
- * @return void
139
  */
140
- protected function addError($phpcsFile, $stackPtr, $function, $parameterLocation)
141
  {
142
- $error = '';
143
-
144
- $isError = false;
145
- $previousStatus = null;
146
- foreach ($this->removedFunctionParameters[$function][$parameterLocation] as $version => $present) {
147
- if ($version != 'name' && $this->supportsAbove($version)) {
148
-
149
- if ($previousStatus !== $present) {
150
- $previousStatus = $present;
151
- if ($present === false) {
152
- $isError = true;
153
- $error .= 'removed';
154
- } else {
155
- $error .= 'deprecated';
156
- }
157
- $error .= ' in PHP version ' . $version . ' and ';
158
- }
159
- }
160
- }
161
 
162
- if (strlen($error) > 0) {
163
- $error = 'The "%s" parameter for function %s was ' . $error;
164
- $error = substr($error, 0, strlen($error) - 5);
165
- $errorCode = 'RemovedParameter';
166
- $data = array(
167
- $this->removedFunctionParameters[$function][$parameterLocation]['name'],
168
- $function,
169
- );
170
-
171
- if ($isError === true) {
172
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
173
- } else {
174
- $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
175
- }
176
- }
177
 
178
- }//end addError()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
 
180
  }//end class
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPCompatibility_AbstractRemovedFeatureSniff
18
  {
19
  /**
20
  * A list of removed function parameters, which were present in older versions.
21
  *
22
+ * The array lists : version number with false (deprecated) and true (removed).
23
  * The index is the location of the parameter in the parameter list, starting at 0 !
24
+ * If's sufficient to list the first version where the function parameter was deprecated/removed.
25
  *
26
  * @var array
27
  */
29
  'gmmktime' => array(
30
  6 => array(
31
  'name' => 'is_dst',
32
+ '5.1' => false, // deprecated
33
+ '7.0' => true,
34
  ),
35
  ),
36
  'ldap_first_attribute' => array(
37
  2 => array(
38
  'name' => 'ber_identifier',
39
+ '5.2.4' => true,
40
  ),
41
  ),
42
  'ldap_next_attribute' => array(
43
  2 => array(
44
  'name' => 'ber_identifier',
45
+ '5.2.4' => true,
46
  ),
47
  ),
48
  'mktime' => array(
49
  6 => array(
50
  'name' => 'is_dst',
51
+ '5.1' => false, // deprecated
52
+ '7.0' => true,
53
  ),
54
  ),
55
  );
56
 
57
 
 
 
 
 
 
 
 
58
  /**
59
  * Returns an array of tokens this test wants to listen for.
60
  *
62
  */
63
  public function register()
64
  {
65
+ // Handle case-insensitivity of function names.
66
+ $this->removedFunctionParameters = $this->arrayKeysToLowercase($this->removedFunctionParameters);
 
67
 
68
  return array(T_STRING);
69
  }//end register()
94
  return;
95
  }
96
 
97
+ $function = $tokens[$stackPtr]['content'];
98
+ $functionLc = strtolower($function);
99
 
100
+ if (isset($this->removedFunctionParameters[$functionLc]) === false) {
101
  return;
102
  }
103
 
110
  $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
111
  $parameterOffsetFound = $parameterCount - 1;
112
 
113
+ foreach($this->removedFunctionParameters[$functionLc] as $offset => $parameterDetails) {
114
  if ($offset <= $parameterOffsetFound) {
115
+ $itemInfo = array(
116
+ 'name' => $function,
117
+ 'nameLc' => $functionLc,
118
+ 'offset' => $offset,
119
+ );
120
+ $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
121
  }
122
  }
123
 
125
 
126
 
127
  /**
128
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
129
  *
130
+ * @param array $itemInfo Base information about the item.
 
 
 
 
131
  *
132
+ * @return array Version and other information about the item.
133
  */
134
+ public function getItemArray(array $itemInfo)
135
  {
136
+ return $this->removedFunctionParameters[$itemInfo['nameLc']][$itemInfo['offset']];
137
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
+ /**
141
+ * Get an array of the non-PHP-version array keys used in a sub-array.
142
+ *
143
+ * @return array
144
+ */
145
+ protected function getNonVersionArrayKeys()
146
+ {
147
+ return array('name');
148
+ }
149
+
150
+
151
+ /**
152
+ * Retrieve the relevant detail (version) information for use in an error message.
153
+ *
154
+ * @param array $itemArray Version and other information about the item.
155
+ * @param array $itemInfo Base information about the item.
156
+ *
157
+ * @return array
158
+ */
159
+ public function getErrorInfo(array $itemArray, array $itemInfo)
160
+ {
161
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
162
+ $errorInfo['paramName'] = $itemArray['name'];
163
+
164
+ return $errorInfo;
165
+ }
166
+
167
+
168
+ /**
169
+ * Get the item name to be used for the creation of the error code.
170
+ *
171
+ * @param array $itemInfo Base information about the item.
172
+ * @param array $errorInfo Detail information about an item.
173
+ *
174
+ * @return string
175
+ */
176
+ protected function getItemName(array $itemInfo, array $errorInfo)
177
+ {
178
+ return $itemInfo['name'].'_'.$errorInfo['paramName'];
179
+ }
180
+
181
+
182
+ /**
183
+ * Get the error message template for this sniff.
184
+ *
185
+ * @return string
186
+ */
187
+ protected function getErrorMsgTemplate()
188
+ {
189
+ return 'The "%s" parameter for function %s() is ';
190
+ }
191
+
192
+
193
+ /**
194
+ * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
195
+ *
196
+ * @param array $data The error data array which was created.
197
+ * @param array $itemInfo Base information about the item this error message applied to.
198
+ * @param array $errorInfo Detail information about an item this error message applied to.
199
+ *
200
+ * @return array
201
+ */
202
+ protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
203
+ {
204
+ array_shift($data);
205
+ array_unshift($data, $errorInfo['paramName'], $itemInfo['name']);
206
+ return $data;
207
+ }
208
+
209
 
210
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedGlobalVariablesSniff.php CHANGED
@@ -16,20 +16,21 @@
16
  * @package PHPCompatibility
17
  * @author Wim Godden <wim.godden@cu.be>
18
  */
19
- class PHPCompatibility_Sniffs_PHP_RemovedGlobalVariablesSniff extends PHPCompatibility_Sniff
20
  {
21
 
22
  /**
23
- * A list of removed global variables with their alternative, if any
24
- * Array codes : 0 = removed/unavailable, -1 = deprecated, 1 = active
 
 
25
  *
26
  * @var array(string|null)
27
  */
28
  protected $removedGlobalVariables = array(
29
  'HTTP_RAW_POST_DATA' => array(
30
- '5.5' => 1,
31
- '5.6' => -1,
32
- '7.0' => 0,
33
  'alternative' => 'php://input'
34
  ),
35
  );
@@ -63,42 +64,36 @@ class PHPCompatibility_Sniffs_PHP_RemovedGlobalVariablesSniff extends PHPCompati
63
  return;
64
  }
65
 
66
- $versionList = $this->removedGlobalVariables[$varName];
67
-
68
- $error = '';
69
- $isError = false;
70
- foreach ($versionList as $version => $status) {
71
- if ($version !== 'alternative' && ($status === -1 || $status === 0)) {
72
- if ($this->supportsAbove($version)) {
73
- switch ($status) {
74
- case -1:
75
- $error .= 'deprecated since PHP ' . $version . ' and ';
76
- break;
77
- case 0:
78
- $isError = true;
79
- $error .= 'removed since PHP ' . $version . ' and ';
80
- break 2;
81
- }
82
- }
83
- }
84
- }
85
- if (strlen($error) > 0) {
86
- $error = "Global variable '%s' is " . $error;
87
- $error = substr($error, 0, strlen($error) - 5);
88
- $data = array(
89
- $tokens[$stackPtr]['content']
90
- );
91
- if (isset($versionList['alternative'])) {
92
- $error .= ' - use %s instead.';
93
- $data[] = $versionList['alternative'];
94
- }
95
- if ($isError === true) {
96
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
97
- } else {
98
- $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
99
- }
100
- }
101
 
102
  }//end process()
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  }//end class
16
  * @package PHPCompatibility
17
  * @author Wim Godden <wim.godden@cu.be>
18
  */
19
+ class PHPCompatibility_Sniffs_PHP_RemovedGlobalVariablesSniff extends PHPCompatibility_AbstractRemovedFeatureSniff
20
  {
21
 
22
  /**
23
+ * A list of removed global variables with their alternative, if any.
24
+ *
25
+ * The array lists : version number with false (deprecated) and true (removed).
26
+ * If's sufficient to list the first version where the variable was deprecated/removed.
27
  *
28
  * @var array(string|null)
29
  */
30
  protected $removedGlobalVariables = array(
31
  'HTTP_RAW_POST_DATA' => array(
32
+ '5.6' => false,
33
+ '7.0' => true,
 
34
  'alternative' => 'php://input'
35
  ),
36
  );
64
  return;
65
  }
66
 
67
+ $itemInfo = array(
68
+ 'name' => $varName,
69
+ );
70
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  }//end process()
73
 
74
+
75
+ /**
76
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
77
+ *
78
+ * @param array $itemInfo Base information about the item.
79
+ *
80
+ * @return array Version and other information about the item.
81
+ */
82
+ public function getItemArray(array $itemInfo)
83
+ {
84
+ return $this->removedGlobalVariables[$itemInfo['name']];
85
+ }
86
+
87
+
88
+ /**
89
+ * Get the error message template for this sniff.
90
+ *
91
+ * @return string
92
+ */
93
+ protected function getErrorMsgTemplate()
94
+ {
95
+ return "Global variable '\$%s' is ";
96
+ }
97
+
98
+
99
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RemovedHashAlgorithmsSniff.php CHANGED
@@ -22,7 +22,7 @@
22
  * @author Wim Godden <wim.godden@cu.be>
23
  * @copyright 2012 Cu.be Solutions bvba
24
  */
25
- class PHPCompatibility_Sniffs_PHP_RemovedHashAlgorithmsSniff extends PHPCompatibility_Sniff
26
  {
27
 
28
  /**
@@ -75,84 +75,36 @@ class PHPCompatibility_Sniffs_PHP_RemovedHashAlgorithmsSniff extends PHPCompatib
75
  return;
76
  }
77
 
78
- // Check if the algorithm used is deprecated or removed.
79
- $errorInfo = $this->getErrorInfo($algo);
80
-
81
- if ($errorInfo['deprecated'] !== '' || $errorInfo['removed'] !== '') {
82
- $this->addError($phpcsFile, $stackPtr, $algo, $errorInfo);
83
- }
84
 
85
  }//end process()
86
 
87
 
88
  /**
89
- * Retrieve the relevant (version) information for the error message.
90
  *
91
- * @param string $algorithm The name of the algorithm.
92
  *
93
- * @return array
94
  */
95
- protected function getErrorInfo($algorithm)
96
  {
97
- $errorInfo = array(
98
- 'deprecated' => '',
99
- 'removed' => '',
100
- 'error' => false,
101
- );
102
-
103
- foreach ($this->removedAlgorithms[$algorithm] as $version => $removed) {
104
- if ($this->supportsAbove($version)) {
105
- if ($removed === true && $errorInfo['removed'] === '') {
106
- $errorInfo['removed'] = $version;
107
- $errorInfo['error'] = true;
108
- } elseif ($errorInfo['deprecated'] === '') {
109
- $errorInfo['deprecated'] = $version;
110
- }
111
- }
112
- }
113
-
114
- return $errorInfo;
115
-
116
- }//end getErrorInfo()
117
 
118
 
119
  /**
120
- * Generates the error or warning for this sniff.
121
  *
122
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
123
- * @param int $stackPtr The position of the function
124
- * in the token array.
125
- * @param string $algorithm The name of the algorithm.
126
- * @param array $errorInfo Array with details about the versions
127
- * in which the algorithm was deprecated
128
- * and/or removed.
129
- *
130
- * @return void
131
  */
132
- protected function addError($phpcsFile, $stackPtr, $algorithm, $errorInfo)
133
  {
134
- $error = 'The %s hash algorithm is ';
135
- $errorCode = $algorithm . 'Found';
136
- $data = array($algorithm);
137
-
138
- if ($errorInfo['deprecated'] !== '') {
139
- $error .= 'deprecated since PHP version %s and ';
140
- $data[] = $errorInfo['deprecated'];
141
- }
142
- if ($errorInfo['removed'] !== '') {
143
- $error .= 'removed since PHP version %s and ';
144
- $data[] = $errorInfo['removed'];
145
- }
146
-
147
- // Remove the last 'and' from the message.
148
- $error = substr($error, 0, strlen($error) - 5);
149
-
150
- if ($errorInfo['error'] === true) {
151
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
152
- } else {
153
- $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
154
- }
155
 
156
- }//end addError()
157
 
158
  }//end class
22
  * @author Wim Godden <wim.godden@cu.be>
23
  * @copyright 2012 Cu.be Solutions bvba
24
  */
25
+ class PHPCompatibility_Sniffs_PHP_RemovedHashAlgorithmsSniff extends PHPCompatibility_AbstractRemovedFeatureSniff
26
  {
27
 
28
  /**
75
  return;
76
  }
77
 
78
+ $itemInfo = array(
79
+ 'name' => $algo,
80
+ );
81
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
 
 
82
 
83
  }//end process()
84
 
85
 
86
  /**
87
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
88
  *
89
+ * @param array $itemInfo Base information about the item.
90
  *
91
+ * @return array Version and other information about the item.
92
  */
93
+ public function getItemArray(array $itemInfo)
94
  {
95
+ return $this->removedAlgorithms[$itemInfo['name']];
96
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
 
99
  /**
100
+ * Get the error message template for this sniff.
101
  *
102
+ * @return string
 
 
 
 
 
 
 
 
103
  */
104
+ protected function getErrorMsgTemplate()
105
  {
106
+ return 'The %s hash algorithm is ';
107
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
 
109
 
110
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/RequiredOptionalFunctionParametersSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff extends PHPCompatibility_Sniff
18
  {
19
 
20
  /**
@@ -52,6 +52,9 @@ class PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff extend
52
  */
53
  public function register()
54
  {
 
 
 
55
  return array(T_STRING);
56
  }//end register()
57
 
@@ -81,9 +84,10 @@ class PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff extend
81
  return;
82
  }
83
 
84
- $function = strtolower($tokens[$stackPtr]['content']);
 
85
 
86
- if (isset($this->functionParameters[$function]) === false) {
87
  return;
88
  }
89
 
@@ -95,32 +99,124 @@ class PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff extend
95
  // If the parameter count returned > 0, we know there will be valid open parenthesis.
96
  $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
97
  $parameterOffsetFound = $parameterCount - 1;
98
- $requiredVersion = null;
99
- $parameterName = null;
100
 
101
- foreach($this->functionParameters[$function] as $offset => $parameterDetails) {
102
  if ($offset > $parameterOffsetFound) {
103
- foreach ($parameterDetails as $version => $present) {
104
- if ($version !== 'name' && $present === true && $this->supportsBelow($version)) {
105
- $requiredVersion = $version;
106
- $parameterName = $parameterDetails['name'];
107
- }
108
- }
109
  }
110
  }
111
-
112
- if (isset($requiredVersion, $parameterName)) {
113
-
114
- $error = 'The "%s" parameter for function %s is missing, but was required for PHP version %s and lower';
115
- $errorCode = 'MissingRequiredParameter';
116
- $data = array(
117
- $parameterName,
118
- $function,
119
- $requiredVersion,
120
- );
121
- $phpcsFile->addError($error, $openParenthesis, $errorCode, $data);
122
- }
123
 
124
  }//end process()
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  }//end class
14
  * @package PHPCompatibility
15
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff extends PHPCompatibility_AbstractComplexVersionSniff
18
  {
19
 
20
  /**
52
  */
53
  public function register()
54
  {
55
+ // Handle case-insensitivity of function names.
56
+ $this->functionParameters = $this->arrayKeysToLowercase($this->functionParameters);
57
+
58
  return array(T_STRING);
59
  }//end register()
60
 
84
  return;
85
  }
86
 
87
+ $function = $tokens[$stackPtr]['content'];
88
+ $functionLc = strtolower($function);
89
 
90
+ if (isset($this->functionParameters[$functionLc]) === false) {
91
  return;
92
  }
93
 
99
  // If the parameter count returned > 0, we know there will be valid open parenthesis.
100
  $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
101
  $parameterOffsetFound = $parameterCount - 1;
 
 
102
 
103
+ foreach($this->functionParameters[$functionLc] as $offset => $parameterDetails) {
104
  if ($offset > $parameterOffsetFound) {
105
+ $itemInfo = array(
106
+ 'name' => $function,
107
+ 'nameLc' => $functionLc,
108
+ 'offset' => $offset,
109
+ );
110
+ $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
111
  }
112
  }
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
  }//end process()
115
 
116
+
117
+ /**
118
+ * Determine whether an error/warning should be thrown for an item based on collected information.
119
+ *
120
+ * @param array $errorInfo Detail information about an item.
121
+ *
122
+ * @return bool
123
+ */
124
+ protected function shouldThrowError(array $errorInfo)
125
+ {
126
+ return ($errorInfo['requiredVersion'] !== '');
127
+ }
128
+
129
+
130
+ /**
131
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
132
+ *
133
+ * @param array $itemInfo Base information about the item.
134
+ *
135
+ * @return array Version and other information about the item.
136
+ */
137
+ public function getItemArray(array $itemInfo)
138
+ {
139
+ return $this->functionParameters[$itemInfo['nameLc']][$itemInfo['offset']];
140
+ }
141
+
142
+
143
+ /**
144
+ * Get an array of the non-PHP-version array keys used in a sub-array.
145
+ *
146
+ * @return array
147
+ */
148
+ protected function getNonVersionArrayKeys()
149
+ {
150
+ return array('name');
151
+ }
152
+
153
+
154
+ /**
155
+ * Retrieve the relevant detail (version) information for use in an error message.
156
+ *
157
+ * @param array $itemArray Version and other information about the item.
158
+ * @param array $itemInfo Base information about the item.
159
+ *
160
+ * @return array
161
+ */
162
+ public function getErrorInfo(array $itemArray, array $itemInfo)
163
+ {
164
+ $errorInfo = array(
165
+ 'paramName' => '',
166
+ 'requiredVersion' => '',
167
+ );
168
+
169
+ $versionArray = $this->getVersionArray($itemArray);
170
+
171
+ foreach ($versionArray as $version => $required) {
172
+ if ($version !== 'name' && $required === true && $this->supportsBelow($version) === true) {
173
+ $errorInfo['requiredVersion'] = $version;
174
+ }
175
+ }
176
+
177
+ $errorInfo['paramName'] = $itemArray['name'];
178
+
179
+ return $errorInfo;
180
+
181
+ }//end getErrorInfo()
182
+
183
+
184
+ /**
185
+ * Get the error message template for this sniff.
186
+ *
187
+ * @return string
188
+ */
189
+ protected function getErrorMsgTemplate()
190
+ {
191
+ return 'The "%s" parameter for function %s is missing, but was required for PHP version %s and lower';
192
+ }
193
+
194
+
195
+ /**
196
+ * Generates the error or warning for this item.
197
+ *
198
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
199
+ * @param int $stackPtr The position of the relevant token in
200
+ * the stack.
201
+ * @param array $itemInfo Base information about the item.
202
+ * @param array $errorInfo Array with detail (version) information
203
+ * relevant to the item.
204
+ *
205
+ * @return void
206
+ */
207
+ public function addError(PHP_CodeSniffer_File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
208
+ {
209
+ $error = $this->getErrorMsgTemplate();
210
+ $errorCode = $this->stringToErrorCode($itemInfo['name'].'_'.$errorInfo['paramName']).'Missing';
211
+ $data = array(
212
+ $errorInfo['paramName'],
213
+ $itemInfo['name'],
214
+ $errorInfo['requiredVersion'],
215
+ );
216
+
217
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
218
+
219
+ }//end addError()
220
+
221
+
222
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/TernaryOperatorsSniff.php CHANGED
@@ -59,8 +59,11 @@ class PHPCompatibility_Sniffs_PHP_TernaryOperatorsSniff extends PHPCompatibility
59
  ($stackPtr + 1), null, true);
60
 
61
  if ($next !== false && $tokens[$next]['code'] === T_INLINE_ELSE) {
62
- $error = 'Middle may not be omitted from ternary operators in PHP < 5.3';
63
- $phpcsFile->addError($error, $stackPtr);
 
 
 
64
  }
65
  }
66
  }
59
  ($stackPtr + 1), null, true);
60
 
61
  if ($next !== false && $tokens[$next]['code'] === T_INLINE_ELSE) {
62
+ $phpcsFile->addError(
63
+ 'Middle may not be omitted from ternary operators in PHP < 5.3',
64
+ $stackPtr,
65
+ 'MiddleMissing'
66
+ );
67
  }
68
  }
69
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility/Sniffs/PHP/ValidIntegersSniff.php CHANGED
@@ -69,29 +69,30 @@ class PHPCompatibility_Sniffs_PHP_ValidIntegersSniff extends PHPCompatibility_Sn
69
  return;
70
  }
71
 
72
- $data = array( $token['content'] );
73
- if ($this->isInvalidOctalInteger($tokens, $stackPtr) === true) {
74
- $error = 'Invalid octal integer detected. Prior to PHP 7 this would lead to a truncated number. From PHP 7 onwards this causes a parse error. Found: %s';
75
- $isError = $this->supportsAbove('7.0');
76
-
77
- if ($isError === true) {
78
- $phpcsFile->addError($error, $stackPtr, 'InvalidOctalIntegerFound', $data);
79
- } else {
80
- $phpcsFile->addWarning($error, $stackPtr, 'InvalidOctalIntegerFound', $data);
81
- }
82
 
 
 
 
 
 
 
 
 
 
83
  return;
84
  }
85
 
86
  if ($this->isHexidecimalNumericString($tokens, $stackPtr) === true) {
87
- $error = 'The behaviour of hexadecimal numeric strings was inconsistent prior to PHP 7 and support has been removed in PHP 7. Found: %s';
88
- $isError = $this->supportsAbove('7.0');
89
-
90
- if ($isError === true) {
91
- $phpcsFile->addError($error, $stackPtr, 'HexNumericStringFound', $data);
92
- } else {
93
- $phpcsFile->addWarning($error, $stackPtr, 'HexNumericStringFound', $data);
94
- }
95
  return;
96
  }
97
 
69
  return;
70
  }
71
 
72
+ $isError = $this->supportsAbove('7.0');
73
+ $data = array( $token['content'] );
 
 
 
 
 
 
 
 
74
 
75
+ if ($this->isInvalidOctalInteger($tokens, $stackPtr) === true) {
76
+ $this->addMessage(
77
+ $phpcsFile,
78
+ 'Invalid octal integer detected. Prior to PHP 7 this would lead to a truncated number. From PHP 7 onwards this causes a parse error. Found: %s',
79
+ $stackPtr,
80
+ $isError,
81
+ 'InvalidOctalIntegerFound',
82
+ $data
83
+ );
84
  return;
85
  }
86
 
87
  if ($this->isHexidecimalNumericString($tokens, $stackPtr) === true) {
88
+ $this->addMessage(
89
+ $phpcsFile,
90
+ 'The behaviour of hexadecimal numeric strings was inconsistent prior to PHP 7 and support has been removed in PHP 7. Found: %s',
91
+ $stackPtr,
92
+ $isError,
93
+ 'HexNumericStringFound',
94
+ $data
95
+ );
96
  return;
97
  }
98
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php CHANGED
@@ -27,6 +27,12 @@
27
  */
28
  class PSR1_Sniffs_Classes_ClassDeclarationSniff implements PHP_CodeSniffer_Sniff
29
  {
 
 
 
 
 
 
30
 
31
 
32
  /**
@@ -56,6 +62,13 @@ class PSR1_Sniffs_Classes_ClassDeclarationSniff implements PHP_CodeSniffer_Sniff
56
  */
57
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
58
  {
 
 
 
 
 
 
 
59
  $tokens = $phpcsFile->getTokens();
60
  if (isset($tokens[$stackPtr]['scope_closer']) === false) {
61
  return;
@@ -72,7 +85,7 @@ class PSR1_Sniffs_Classes_ClassDeclarationSniff implements PHP_CodeSniffer_Sniff
72
  $phpcsFile->recordMetric($stackPtr, 'One class per file', 'yes');
73
  }
74
 
75
- if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
76
  $namespace = $phpcsFile->findNext(array(T_NAMESPACE, T_CLASS, T_INTERFACE, T_TRAIT), 0);
77
  if ($tokens[$namespace]['code'] !== T_NAMESPACE) {
78
  $error = 'Each %s must be in a namespace of at least one level (a top-level vendor name)';
27
  */
28
  class PSR1_Sniffs_Classes_ClassDeclarationSniff implements PHP_CodeSniffer_Sniff
29
  {
30
+ /**
31
+ * The current PHP version.
32
+ *
33
+ * @var integer
34
+ */
35
+ private $_phpVersion = null;
36
 
37
 
38
  /**
62
  */
63
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
64
  {
65
+ if ($this->_phpVersion === null) {
66
+ $this->_phpVersion = PHP_CodeSniffer::getConfigData('php_version');
67
+ if ($this->_phpVersion === null) {
68
+ $this->_phpVersion = PHP_VERSION_ID;
69
+ }
70
+ }
71
+
72
  $tokens = $phpcsFile->getTokens();
73
  if (isset($tokens[$stackPtr]['scope_closer']) === false) {
74
  return;
85
  $phpcsFile->recordMetric($stackPtr, 'One class per file', 'yes');
86
  }
87
 
88
+ if ($this->_phpVersion >= 50300) {
89
  $namespace = $phpcsFile->findNext(array(T_NAMESPACE, T_CLASS, T_INTERFACE, T_TRAIT), 0);
90
  if ($tokens[$namespace]['code'] !== T_NAMESPACE) {
91
  $error = 'Each %s must be in a namespace of at least one level (a top-level vendor name)';
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php CHANGED
@@ -52,7 +52,7 @@ class PSR1_Sniffs_Methods_CamelCapsMethodNameSniff extends Generic_Sniffs_Naming
52
  }
53
 
54
  // Ignore magic methods.
55
- if (preg_match('|^__|', $methodName) !== 0) {
56
  $magicPart = strtolower(substr($methodName, 2));
57
  if (isset($this->magicMethods[$magicPart]) === true
58
  || isset($this->methodsDoubleUnderscore[$magicPart]) === true
52
  }
53
 
54
  // Ignore magic methods.
55
+ if (preg_match('|^__[^_]|', $methodName) !== 0) {
56
  $magicPart = strtolower(substr($methodName, 2));
57
  if (isset($this->magicMethods[$magicPart]) === true
58
  || isset($this->methodsDoubleUnderscore[$magicPart]) === true
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php CHANGED
@@ -60,6 +60,10 @@ class PSR2_Sniffs_Files_EndFileNewlineSniff implements PHP_CodeSniffer_Sniff
60
  $tokens = $phpcsFile->getTokens();
61
  $lastToken = ($phpcsFile->numTokens - 1);
62
 
 
 
 
 
63
  // Hard-coding the expected \n in this sniff as it is PSR-2 specific and
64
  // PSR-2 enforces the use of unix style newlines.
65
  if (substr($tokens[$lastToken]['content'], -1) !== "\n") {
@@ -75,8 +79,10 @@ class PSR2_Sniffs_Files_EndFileNewlineSniff implements PHP_CodeSniffer_Sniff
75
 
76
  // Go looking for the last non-empty line.
77
  $lastLine = $tokens[$lastToken]['line'];
78
- if ($tokens[$lastToken]['code'] === T_WHITESPACE) {
79
- $lastCode = $phpcsFile->findPrevious(T_WHITESPACE, ($lastToken - 1), null, true);
 
 
80
  } else {
81
  $lastCode = $lastToken;
82
  }
60
  $tokens = $phpcsFile->getTokens();
61
  $lastToken = ($phpcsFile->numTokens - 1);
62
 
63
+ if ($tokens[$lastToken]['content'] === '') {
64
+ $lastToken--;
65
+ }
66
+
67
  // Hard-coding the expected \n in this sniff as it is PSR-2 specific and
68
  // PSR-2 enforces the use of unix style newlines.
69
  if (substr($tokens[$lastToken]['content'], -1) !== "\n") {
79
 
80
  // Go looking for the last non-empty line.
81
  $lastLine = $tokens[$lastToken]['line'];
82
+ if ($tokens[$lastToken]['code'] === T_WHITESPACE
83
+ || $tokens[$lastToken]['code'] === T_DOC_COMMENT_WHITESPACE
84
+ ) {
85
+ $lastCode = $phpcsFile->findPrevious(array(T_WHITESPACE, T_DOC_COMMENT_WHITESPACE), ($lastToken - 1), null, true);
86
  } else {
87
  $lastCode = $lastToken;
88
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php CHANGED
@@ -68,14 +68,60 @@ class PSR2_Sniffs_Namespaces_UseDeclarationSniff implements PHP_CodeSniffer_Snif
68
  }
69
 
70
  // Only one USE declaration allowed per statement.
71
- $next = $phpcsFile->findNext(array(T_COMMA, T_SEMICOLON), ($stackPtr + 1));
72
- if ($tokens[$next]['code'] === T_COMMA) {
73
  $error = 'There must be one USE keyword per declaration';
74
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'MultipleDeclarations');
75
  if ($fix === true) {
76
- $phpcsFile->fixer->replaceToken($next, ';'.$phpcsFile->eolChar.'use ');
77
- }
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  // Make sure this USE comes after the first namespace declaration.
81
  $prev = $phpcsFile->findPrevious(T_NAMESPACE, ($stackPtr - 1));
68
  }
69
 
70
  // Only one USE declaration allowed per statement.
71
+ $next = $phpcsFile->findNext(array(T_COMMA, T_SEMICOLON, T_OPEN_USE_GROUP), ($stackPtr + 1));
72
+ if ($tokens[$next]['code'] !== T_SEMICOLON) {
73
  $error = 'There must be one USE keyword per declaration';
74
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'MultipleDeclarations');
75
  if ($fix === true) {
76
+ if ($tokens[$next]['code'] === T_COMMA) {
77
+ $phpcsFile->fixer->replaceToken($next, ';'.$phpcsFile->eolChar.'use ');
78
+ } else {
79
+ $baseUse = rtrim($phpcsFile->getTokensAsString($stackPtr, ($next - $stackPtr)));
80
+ $closingCurly = $phpcsFile->findNext(T_CLOSE_USE_GROUP, ($next + 1));
81
+
82
+ $phpcsFile->fixer->beginChangeset();
83
+
84
+ // Remove base use statement.
85
+ for ($i = $stackPtr; $i <= $next; $i++) {
86
+ $phpcsFile->fixer->replaceToken($i, '');
87
+ }
88
+
89
+ // Convert grouped use statements into full use statements.
90
+ do {
91
+ $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), $closingCurly, true);
92
+
93
+ $whitespace = $phpcsFile->findPrevious(T_WHITESPACE, ($next - 1), null, true);
94
+ for ($i = ($whitespace + 1); $i < $next; $i++) {
95
+ $phpcsFile->fixer->replaceToken($i, '');
96
+ }
97
+
98
+ if ($tokens[$next]['code'] === T_CONST || $tokens[$next]['code'] === T_FUNCTION) {
99
+ $phpcsFile->fixer->addContentBefore($next, 'use ');
100
+ $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), $closingCurly, true);
101
+ $phpcsFile->fixer->addContentBefore($next, str_replace('use ', '', $baseUse));
102
+ } else {
103
+ $phpcsFile->fixer->addContentBefore($next, $baseUse);
104
+ }
105
+
106
+ $next = $phpcsFile->findNext(T_COMMA, ($next + 1), $closingCurly);
107
+ if ($next !== false) {
108
+ $phpcsFile->fixer->replaceToken($next, ';'.$phpcsFile->eolChar);
109
+ }
110
+ } while ($next !== false);
111
+
112
+ $phpcsFile->fixer->replaceToken($closingCurly, '');
113
+
114
+ // Remove any trailing whitespace.
115
+ $next = $phpcsFile->findNext(T_SEMICOLON, $closingCurly);
116
+ $whitespace = $phpcsFile->findPrevious(T_WHITESPACE, ($closingCurly - 1), null, true);
117
+ for ($i = ($whitespace + 1); $i < $next; $i++) {
118
+ $phpcsFile->fixer->replaceToken($i, '');
119
+ }
120
+
121
+ $phpcsFile->fixer->endChangeset();
122
+ }//end if
123
+ }//end if
124
+ }//end if
125
 
126
  // Make sure this USE comes after the first namespace declaration.
127
  $prev = $phpcsFile->findPrevious(T_NAMESPACE, ($stackPtr - 1));
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php CHANGED
@@ -344,7 +344,6 @@ class Squiz_Sniffs_Arrays_ArrayDeclarationSniff implements PHP_CodeSniffer_Sniff
344
  }
345
  }//end if
346
 
347
- $nextToken = $stackPtr;
348
  $keyUsed = false;
349
  $singleUsed = false;
350
  $indices = array();
@@ -367,49 +366,25 @@ class Squiz_Sniffs_Arrays_ArrayDeclarationSniff implements PHP_CodeSniffer_Sniff
367
  continue;
368
  }
369
 
370
- if ($tokens[$nextToken]['code'] === T_ARRAY) {
371
- // Let subsequent calls of this test handle nested arrays.
372
- if ($tokens[$lastToken]['code'] !== T_DOUBLE_ARROW) {
373
- $indices[] = array('value' => $nextToken);
374
- $lastToken = $nextToken;
375
- }
376
-
377
- $nextToken = $tokens[$tokens[$nextToken]['parenthesis_opener']]['parenthesis_closer'];
378
- $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true);
379
- if ($tokens[$nextToken]['code'] !== T_COMMA) {
380
- $nextToken--;
381
- } else {
382
- $lastToken = $nextToken;
383
- }
384
-
385
- continue;
386
- }
387
-
388
- if ($tokens[$nextToken]['code'] === T_OPEN_SHORT_ARRAY) {
389
  // Let subsequent calls of this test handle nested arrays.
390
  if ($tokens[$lastToken]['code'] !== T_DOUBLE_ARROW) {
391
  $indices[] = array('value' => $nextToken);
392
  $lastToken = $nextToken;
393
  }
394
 
395
- $nextToken = $tokens[$nextToken]['bracket_closer'];
396
- $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true);
397
- if ($tokens[$nextToken]['code'] !== T_COMMA) {
398
- $nextToken--;
399
  } else {
400
- $lastToken = $nextToken;
 
401
  }
402
 
403
- continue;
404
- }
405
-
406
- if ($tokens[$nextToken]['code'] === T_CLOSURE) {
407
- if ($tokens[$lastToken]['code'] !== T_DOUBLE_ARROW) {
408
- $indices[] = array('value' => $nextToken);
409
- $lastToken = $nextToken;
410
- }
411
-
412
- $nextToken = $tokens[$nextToken]['scope_closer'];
413
  $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true);
414
  if ($tokens[$nextToken]['code'] !== T_COMMA) {
415
  $nextToken--;
@@ -418,7 +393,7 @@ class Squiz_Sniffs_Arrays_ArrayDeclarationSniff implements PHP_CodeSniffer_Sniff
418
  }
419
 
420
  continue;
421
- }
422
 
423
  if ($tokens[$nextToken]['code'] !== T_DOUBLE_ARROW
424
  && $tokens[$nextToken]['code'] !== T_COMMA
344
  }
345
  }//end if
346
 
 
347
  $keyUsed = false;
348
  $singleUsed = false;
349
  $indices = array();
366
  continue;
367
  }
368
 
369
+ if ($tokens[$nextToken]['code'] === T_ARRAY
370
+ || $tokens[$nextToken]['code'] === T_OPEN_SHORT_ARRAY
371
+ || $tokens[$nextToken]['code'] === T_CLOSURE
372
+ ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
  // Let subsequent calls of this test handle nested arrays.
374
  if ($tokens[$lastToken]['code'] !== T_DOUBLE_ARROW) {
375
  $indices[] = array('value' => $nextToken);
376
  $lastToken = $nextToken;
377
  }
378
 
379
+ if ($tokens[$nextToken]['code'] === T_ARRAY) {
380
+ $nextToken = $tokens[$tokens[$nextToken]['parenthesis_opener']]['parenthesis_closer'];
381
+ } else if ($tokens[$nextToken]['code'] === T_OPEN_SHORT_ARRAY) {
382
+ $nextToken = $tokens[$nextToken]['bracket_closer'];
383
  } else {
384
+ // T_CLOSURE.
385
+ $nextToken = $tokens[$nextToken]['scope_closer'];
386
  }
387
 
 
 
 
 
 
 
 
 
 
 
388
  $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true);
389
  if ($tokens[$nextToken]['code'] !== T_COMMA) {
390
  $nextToken--;
393
  }
394
 
395
  continue;
396
+ }//end if
397
 
398
  if ($tokens[$nextToken]['code'] !== T_DOUBLE_ARROW
399
  && $tokens[$nextToken]['code'] !== T_COMMA
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php CHANGED
@@ -69,8 +69,13 @@ class Squiz_Sniffs_CSS_DuplicateClassDefinitionSniff implements PHP_CodeSniffer_
69
  return;
70
  }
71
 
 
 
 
 
72
  $find = array(
73
  T_CLOSE_CURLY_BRACKET,
 
74
  T_COMMENT,
75
  T_OPEN_TAG,
76
  );
@@ -78,6 +83,14 @@ class Squiz_Sniffs_CSS_DuplicateClassDefinitionSniff implements PHP_CodeSniffer_
78
  while ($next !== false) {
79
  $prev = $phpcsFile->findPrevious($find, ($next - 1));
80
 
 
 
 
 
 
 
 
 
81
  // Create a sorted name for the class so we can compare classes
82
  // even when the individual names are all over the place.
83
  $name = '';
@@ -94,13 +107,16 @@ class Squiz_Sniffs_CSS_DuplicateClassDefinitionSniff implements PHP_CodeSniffer_
94
  sort($names);
95
  $name = implode(',', $names);
96
 
97
- if (isset($classNames[$name]) === true) {
98
- $first = $classNames[$name];
 
 
 
99
  $error = 'Duplicate class definition found; first defined on line %s';
100
  $data = array($tokens[$first]['line']);
101
  $phpcsFile->addError($error, $next, 'Found', $data);
102
  } else {
103
- $classNames[$name] = $next;
104
  }
105
 
106
  $next = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($next + 1));
69
  return;
70
  }
71
 
72
+ // Save the class names in a "scope",
73
+ // to prevent false positives with @media blocks.
74
+ $scope = 'main';
75
+
76
  $find = array(
77
  T_CLOSE_CURLY_BRACKET,
78
+ T_OPEN_CURLY_BRACKET,
79
  T_COMMENT,
80
  T_OPEN_TAG,
81
  );
83
  while ($next !== false) {
84
  $prev = $phpcsFile->findPrevious($find, ($next - 1));
85
 
86
+ // Check if an inner block was closed.
87
+ $beforePrev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($prev - 1), null, true);
88
+ if ($beforePrev !== false
89
+ && $tokens[$beforePrev]['code'] === T_CLOSE_CURLY_BRACKET
90
+ ) {
91
+ $scope = 'main';
92
+ }
93
+
94
  // Create a sorted name for the class so we can compare classes
95
  // even when the individual names are all over the place.
96
  $name = '';
107
  sort($names);
108
  $name = implode(',', $names);
109
 
110
+ if ($name{0} === '@') {
111
+ // Media block has its own "scope".
112
+ $scope = $name;
113
+ } else if (isset($classNames[$scope][$name]) === true) {
114
+ $first = $classNames[$scope][$name];
115
  $error = 'Duplicate class definition found; first defined on line %s';
116
  $data = array($tokens[$first]['line']);
117
  $phpcsFile->addError($error, $next, 'Found', $data);
118
  } else {
119
+ $classNames[$scope][$name] = $next;
120
  }
121
 
122
  $next = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($next + 1));
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php CHANGED
@@ -43,25 +43,25 @@ class Squiz_Sniffs_CSS_NamedColoursSniff implements PHP_CodeSniffer_Sniff
43
  *
44
  * @var array
45
  */
46
- public $colourNames = array(
47
- 'aqua' => 'aqua',
48
- 'black' => 'black',
49
- 'blue' => 'blue',
50
- 'fuchsia' => 'fuchsia',
51
- 'gray' => 'gray',
52
- 'green' => 'green',
53
- 'lime' => 'lime',
54
- 'maroon' => 'maroon',
55
- 'navy' => 'navy',
56
- 'olive' => 'olive',
57
- 'orange' => 'orange',
58
- 'purple' => 'purple',
59
- 'red' => 'red',
60
- 'silver' => 'silver',
61
- 'teal' => 'teal',
62
- 'white' => 'white',
63
- 'yellow' => 'yellow',
64
- );
65
 
66
 
67
  /**
43
  *
44
  * @var array
45
  */
46
+ protected $colourNames = array(
47
+ 'aqua' => 'aqua',
48
+ 'black' => 'black',
49
+ 'blue' => 'blue',
50
+ 'fuchsia' => 'fuchsia',
51
+ 'gray' => 'gray',
52
+ 'green' => 'green',
53
+ 'lime' => 'lime',
54
+ 'maroon' => 'maroon',
55
+ 'navy' => 'navy',
56
+ 'olive' => 'olive',
57
+ 'orange' => 'orange',
58
+ 'purple' => 'purple',
59
+ 'red' => 'red',
60
+ 'silver' => 'silver',
61
+ 'teal' => 'teal',
62
+ 'white' => 'white',
63
+ 'yellow' => 'yellow',
64
+ );
65
 
66
 
67
  /**
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php CHANGED
@@ -43,13 +43,13 @@ class Squiz_Sniffs_CSS_ShorthandSizeSniff implements PHP_CodeSniffer_Sniff
43
  *
44
  * @var array
45
  */
46
- public $excludeStyles = array(
47
- 'background-position' => 'background-position',
48
- 'box-shadow' => 'box-shadow',
49
- 'transform-origin' => 'transform-origin',
50
- '-webkit-transform-origin' => '-webkit-transform-origin',
51
- '-ms-transform-origin' => '-ms-transform-origin',
52
- );
53
 
54
 
55
  /**
43
  *
44
  * @var array
45
  */
46
+ protected $excludeStyles = array(
47
+ 'background-position' => 'background-position',
48
+ 'box-shadow' => 'box-shadow',
49
+ 'transform-origin' => 'transform-origin',
50
+ '-webkit-transform-origin' => '-webkit-transform-origin',
51
+ '-ms-transform-origin' => '-ms-transform-origin',
52
+ );
53
 
54
 
55
  /**
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php CHANGED
@@ -66,20 +66,30 @@ class Squiz_Sniffs_Classes_SelfMemberReferenceSniff extends PHP_CodeSniffer_Stan
66
 
67
  $calledClassName = ($stackPtr - 1);
68
  if ($tokens[$calledClassName]['code'] === T_SELF) {
69
- if (strtolower($tokens[$calledClassName]['content']) !== $tokens[$calledClassName]['content']) {
70
  $error = 'Must use "self::" for local static member reference; found "%s::"';
71
  $data = array($tokens[$calledClassName]['content']);
72
- $phpcsFile->addError($error, $calledClassName, 'IncorrectCase', $data);
 
 
 
 
73
  return;
74
  }
75
  } else if ($tokens[$calledClassName]['code'] === T_STRING) {
76
  // If the class is called with a namespace prefix, build fully qualified
77
  // namespace calls for both current scope class and requested class.
78
  if ($tokens[($calledClassName - 1)]['code'] === T_NS_SEPARATOR) {
79
- $declarationName = $this->getDeclarationNameWithNamespace($tokens, $calledClassName);
80
- $declarationName = substr($declarationName, 1);
81
- $fullQualifiedClassName = $this->getNamespaceOfScope($phpcsFile, $currScope);
82
- $fullQualifiedClassName .= '\\'.$phpcsFile->getDeclarationName($currScope);
 
 
 
 
 
 
83
  } else {
84
  $declarationName = $phpcsFile->getDeclarationName($currScope);
85
  $fullQualifiedClassName = $tokens[$calledClassName]['content'];
66
 
67
  $calledClassName = ($stackPtr - 1);
68
  if ($tokens[$calledClassName]['code'] === T_SELF) {
69
+ if ($tokens[$calledClassName]['content'] !== 'self') {
70
  $error = 'Must use "self::" for local static member reference; found "%s::"';
71
  $data = array($tokens[$calledClassName]['content']);
72
+ $fix = $phpcsFile->addFixableError($error, $calledClassName, 'IncorrectCase', $data);
73
+ if ($fix === true) {
74
+ $phpcsFile->fixer->replaceToken($calledClassName, 'self');
75
+ }
76
+
77
  return;
78
  }
79
  } else if ($tokens[$calledClassName]['code'] === T_STRING) {
80
  // If the class is called with a namespace prefix, build fully qualified
81
  // namespace calls for both current scope class and requested class.
82
  if ($tokens[($calledClassName - 1)]['code'] === T_NS_SEPARATOR) {
83
+ $declarationName = $this->getDeclarationNameWithNamespace($tokens, $calledClassName);
84
+ $declarationName = substr($declarationName, 1);
85
+ $fullQualifiedClassName = $this->getNamespaceOfScope($phpcsFile, $currScope);
86
+ if ($fullQualifiedClassName === '\\') {
87
+ $fullQualifiedClassName = '';
88
+ } else {
89
+ $fullQualifiedClassName .= '\\';
90
+ }
91
+
92
+ $fullQualifiedClassName .= $phpcsFile->getDeclarationName($currScope);
93
  } else {
94
  $declarationName = $phpcsFile->getDeclarationName($currScope);
95
  $fullQualifiedClassName = $tokens[$calledClassName]['content'];
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php CHANGED
@@ -41,6 +41,7 @@ class Squiz_Sniffs_Classes_ValidClassNameSniff implements PHP_CodeSniffer_Sniff
41
  return array(
42
  T_CLASS,
43
  T_INTERFACE,
 
44
  );
45
 
46
  }//end register()
41
  return array(
42
  T_CLASS,
43
  T_INTERFACE,
44
+ T_TRAIT,
45
  );
46
 
47
  }//end register()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php CHANGED
@@ -87,6 +87,7 @@ class Squiz_Sniffs_Commenting_DocCommentAlignmentSniff implements PHP_CodeSniffe
87
  T_PROPERTY => true,
88
  T_OBJECT => true,
89
  T_PROTOTYPE => true,
 
90
  );
91
 
92
  if (isset($ignore[$tokens[$nextToken]['code']]) === false) {
87
  T_PROPERTY => true,
88
  T_OBJECT => true,
89
  T_PROTOTYPE => true,
90
+ T_VAR => true,
91
  );
92
 
93
  if (isset($ignore[$tokens[$nextToken]['code']]) === false) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php CHANGED
@@ -32,6 +32,13 @@ if (class_exists('PEAR_Sniffs_Commenting_FunctionCommentSniff', true) === false)
32
  class Squiz_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commenting_FunctionCommentSniff
33
  {
34
 
 
 
 
 
 
 
 
35
 
36
  /**
37
  * Process the return comment of this function comment.
@@ -74,8 +81,16 @@ class Squiz_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commentin
74
  $error = 'Return type missing for @return tag in function comment';
75
  $phpcsFile->addError($error, $return, 'MissingReturnType');
76
  } else {
 
 
 
 
 
 
 
 
77
  // Check return type (can be multiple, separated by '|').
78
- $typeNames = explode('|', $content);
79
  $suggestedNames = array();
80
  foreach ($typeNames as $i => $typeName) {
81
  $suggestedName = PHP_CodeSniffer::suggestType($typeName);
@@ -85,30 +100,33 @@ class Squiz_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commentin
85
  }
86
 
87
  $suggestedType = implode('|', $suggestedNames);
88
- if ($content !== $suggestedType) {
89
  $error = 'Expected "%s" but found "%s" for function return type';
90
  $data = array(
91
  $suggestedType,
92
- $content,
93
  );
94
  $fix = $phpcsFile->addFixableError($error, $return, 'InvalidReturn', $data);
95
  if ($fix === true) {
96
- $phpcsFile->fixer->replaceToken(($return + 2), $suggestedType);
 
 
 
 
 
 
97
  }
98
  }
99
 
100
- // Support both a return type and a description. The return type
101
- // is anything up to the first space.
102
- $returnParts = explode(' ', $content, 2);
103
- $returnType = $returnParts[0];
104
-
105
  // If the return type is void, make sure there is
106
  // no return statement in the function.
107
  if ($returnType === 'void') {
108
  if (isset($tokens[$stackPtr]['scope_closer']) === true) {
109
  $endToken = $tokens[$stackPtr]['scope_closer'];
110
  for ($returnToken = $stackPtr; $returnToken < $endToken; $returnToken++) {
111
- if ($tokens[$returnToken]['code'] === T_CLOSURE) {
 
 
112
  $returnToken = $tokens[$returnToken]['scope_closer'];
113
  continue;
114
  }
@@ -130,7 +148,7 @@ class Squiz_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commentin
130
  }
131
  }
132
  }//end if
133
- } else if ($returnType !== 'mixed') {
134
  // If return type is not void, there needs to be a return statement
135
  // somewhere in the function that returns something.
136
  if (isset($tokens[$stackPtr]['scope_closer']) === true) {
@@ -238,6 +256,13 @@ class Squiz_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commentin
238
  */
239
  protected function processParams(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $commentStart)
240
  {
 
 
 
 
 
 
 
241
  $tokens = $phpcsFile->getTokens();
242
 
243
  $params = array();
@@ -258,12 +283,14 @@ class Squiz_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commentin
258
  $matches = array();
259
  preg_match('/([^$&.]+)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches);
260
 
261
- $typeLen = strlen($matches[1]);
262
- $type = trim($matches[1]);
263
- $typeSpace = ($typeLen - strlen($type));
264
- $typeLen = strlen($type);
265
- if ($typeLen > $maxType) {
266
- $maxType = $typeLen;
 
 
267
  }
268
 
269
  if (isset($matches[2]) === true) {
@@ -347,117 +374,100 @@ class Squiz_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commentin
347
  }
348
 
349
  // Check the param type value.
350
- $typeNames = explode('|', $param['type']);
 
 
351
  foreach ($typeNames as $typeName) {
352
- $suggestedName = PHP_CodeSniffer::suggestType($typeName);
353
- if ($typeName !== $suggestedName) {
354
- $error = 'Expected "%s" but found "%s" for parameter type';
355
- $data = array(
356
- $suggestedName,
357
- $typeName,
358
- );
359
 
360
- $fix = $phpcsFile->addFixableError($error, $param['tag'], 'IncorrectParamVarName', $data);
361
- if ($fix === true) {
362
- $content = $suggestedName;
363
- $content .= str_repeat(' ', $param['type_space']);
364
- $content .= $param['var'];
365
- $content .= str_repeat(' ', $param['var_space']);
366
- if (isset($param['commentLines'][0]) === true) {
367
- $content .= $param['commentLines'][0]['comment'];
368
- }
369
 
370
- $phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content);
371
- }
372
- } else if (count($typeNames) === 1) {
373
- // Check type hint for array and custom type.
374
- $suggestedTypeHint = '';
375
- if (strpos($suggestedName, 'array') !== false || substr($suggestedName, -2) === '[]') {
376
- $suggestedTypeHint = 'array';
377
- } else if (strpos($suggestedName, 'callable') !== false) {
378
- $suggestedTypeHint = 'callable';
379
- } else if (strpos($suggestedName, 'callback') !== false) {
380
- $suggestedTypeHint = 'callable';
381
- } else if (in_array($typeName, PHP_CodeSniffer::$allowedTypes) === false) {
382
- $suggestedTypeHint = $suggestedName;
383
- } else if (version_compare(PHP_VERSION, '7.0.0') >= 0) {
384
- if ($typeName === 'string') {
385
- $suggestedTypeHint = 'string';
386
- } else if ($typeName === 'int' || $typeName === 'integer') {
387
- $suggestedTypeHint = 'int';
388
- } else if ($typeName === 'float') {
389
- $suggestedTypeHint = 'float';
390
- } else if ($typeName === 'bool' || $typeName === 'boolean') {
391
- $suggestedTypeHint = 'bool';
392
- }
393
  }
 
394
 
395
- if ($suggestedTypeHint !== '' && isset($realParams[$pos]) === true) {
396
- $typeHint = $realParams[$pos]['type_hint'];
397
- if ($typeHint === '') {
398
- $error = 'Type hint "%s" missing for %s';
399
- $data = array(
400
- $suggestedTypeHint,
401
- $param['var'],
402
- );
403
-
404
- $errorCode = 'TypeHintMissing';
405
- if ($suggestedTypeHint === 'string'
406
- || $suggestedTypeHint === 'int'
407
- || $suggestedTypeHint === 'float'
408
- || $suggestedTypeHint === 'bool'
409
- ) {
410
- $errorCode = 'Scalar'.$errorCode;
411
- }
412
-
413
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
414
- } else if ($typeHint !== substr($suggestedTypeHint, (strlen($typeHint) * -1))) {
415
- $error = 'Expected type hint "%s"; found "%s" for %s';
416
- $data = array(
417
- $suggestedTypeHint,
418
- $typeHint,
419
- $param['var'],
420
- );
421
- $phpcsFile->addError($error, $stackPtr, 'IncorrectTypeHint', $data);
422
- }//end if
423
- } else if ($suggestedTypeHint === '' && isset($realParams[$pos]) === true) {
424
- $typeHint = $realParams[$pos]['type_hint'];
425
- if ($typeHint !== '') {
426
- $error = 'Unknown type hint "%s" found for %s';
427
- $data = array(
428
- $typeHint,
429
- $param['var'],
430
- );
431
- $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHint', $data);
432
  }
 
 
 
 
 
 
 
 
 
 
433
  }//end if
 
 
 
 
 
 
 
 
 
 
434
  }//end if
435
  }//end foreach
436
 
437
- if ($param['var'] === '') {
438
- continue;
439
- }
440
-
441
- $foundParams[] = $param['var'];
442
-
443
- // Check number of spaces after the type.
444
- $spaces = ($maxType - strlen($param['type']) + 1);
445
- if ($param['type_space'] !== $spaces) {
446
- $error = 'Expected %s spaces after parameter type; %s found';
447
  $data = array(
448
- $spaces,
449
- $param['type_space'],
450
  );
451
 
452
- $fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamType', $data);
453
  if ($fix === true) {
454
  $phpcsFile->fixer->beginChangeset();
455
 
456
- $content = $param['type'];
457
- $content .= str_repeat(' ', $spaces);
458
  $content .= $param['var'];
459
  $content .= str_repeat(' ', $param['var_space']);
460
- $content .= $param['commentLines'][0]['comment'];
 
 
 
461
  $phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content);
462
 
463
  // Fix up the indent of additional comment lines.
@@ -468,7 +478,8 @@ class Squiz_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commentin
468
  continue;
469
  }
470
 
471
- $newIndent = ($param['commentLines'][$lineNum]['indent'] + $spaces - $param['type_space']);
 
472
  $phpcsFile->fixer->replaceToken(
473
  ($param['commentLines'][$lineNum]['token'] - 1),
474
  str_repeat(' ', $newIndent)
@@ -479,6 +490,15 @@ class Squiz_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commentin
479
  }//end if
480
  }//end if
481
 
 
 
 
 
 
 
 
 
 
482
  // Make sure the param name is correct.
483
  if (isset($realParams[$pos]) === true) {
484
  $realName = $realParams[$pos]['name'];
@@ -510,43 +530,7 @@ class Squiz_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commentin
510
  }
511
 
512
  // Check number of spaces after the var name.
513
- $spaces = ($maxVar - strlen($param['var']) + 1);
514
- if ($param['var_space'] !== $spaces) {
515
- $error = 'Expected %s spaces after parameter name; %s found';
516
- $data = array(
517
- $spaces,
518
- $param['var_space'],
519
- );
520
-
521
- $fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamName', $data);
522
- if ($fix === true) {
523
- $phpcsFile->fixer->beginChangeset();
524
-
525
- $content = $param['type'];
526
- $content .= str_repeat(' ', $param['type_space']);
527
- $content .= $param['var'];
528
- $content .= str_repeat(' ', $spaces);
529
- $content .= $param['commentLines'][0]['comment'];
530
- $phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content);
531
-
532
- // Fix up the indent of additional comment lines.
533
- foreach ($param['commentLines'] as $lineNum => $line) {
534
- if ($lineNum === 0
535
- || $param['commentLines'][$lineNum]['indent'] === 0
536
- ) {
537
- continue;
538
- }
539
-
540
- $newIndent = ($param['commentLines'][$lineNum]['indent'] + $spaces - $param['var_space']);
541
- $phpcsFile->fixer->replaceToken(
542
- ($param['commentLines'][$lineNum]['token'] - 1),
543
- str_repeat(' ', $newIndent)
544
- );
545
- }
546
-
547
- $phpcsFile->fixer->endChangeset();
548
- }//end if
549
- }//end if
550
 
551
  // Param comments must start with a capital letter and end with the full stop.
552
  if (preg_match('/^(\p{Ll}|\P{L})/u', $param['comment']) === 1) {
@@ -577,4 +561,114 @@ class Squiz_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commentin
577
  }//end processParams()
578
 
579
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
580
  }//end class
32
  class Squiz_Sniffs_Commenting_FunctionCommentSniff extends PEAR_Sniffs_Commenting_FunctionCommentSniff
33
  {
34
 
35
+ /**
36
+ * The current PHP version.
37
+ *
38
+ * @var integer
39
+ */
40
+ private $_phpVersion = null;
41
+
42
 
43
  /**
44
  * Process the return comment of this function comment.
81
  $error = 'Return type missing for @return tag in function comment';
82
  $phpcsFile->addError($error, $return, 'MissingReturnType');
83
  } else {
84
+ // Support both a return type and a description.
85
+ $split = preg_match('`^((?:\|?(?:array\([^\)]*\)|[\\\\a-z0-9\[\]]+))*)( .*)?`i', $content, $returnParts);
86
+ if (isset($returnParts[1]) === false) {
87
+ return;
88
+ }
89
+
90
+ $returnType = $returnParts[1];
91
+
92
  // Check return type (can be multiple, separated by '|').
93
+ $typeNames = explode('|', $returnType);
94
  $suggestedNames = array();
95
  foreach ($typeNames as $i => $typeName) {
96
  $suggestedName = PHP_CodeSniffer::suggestType($typeName);
100
  }
101
 
102
  $suggestedType = implode('|', $suggestedNames);
103
+ if ($returnType !== $suggestedType) {
104
  $error = 'Expected "%s" but found "%s" for function return type';
105
  $data = array(
106
  $suggestedType,
107
+ $returnType,
108
  );
109
  $fix = $phpcsFile->addFixableError($error, $return, 'InvalidReturn', $data);
110
  if ($fix === true) {
111
+ $replacement = $suggestedType;
112
+ if (empty($returnParts[2]) === false) {
113
+ $replacement .= $returnParts[2];
114
+ }
115
+
116
+ $phpcsFile->fixer->replaceToken(($return + 2), $replacement);
117
+ unset($replacement);
118
  }
119
  }
120
 
 
 
 
 
 
121
  // If the return type is void, make sure there is
122
  // no return statement in the function.
123
  if ($returnType === 'void') {
124
  if (isset($tokens[$stackPtr]['scope_closer']) === true) {
125
  $endToken = $tokens[$stackPtr]['scope_closer'];
126
  for ($returnToken = $stackPtr; $returnToken < $endToken; $returnToken++) {
127
+ if ($tokens[$returnToken]['code'] === T_CLOSURE
128
+ || $tokens[$returnToken]['code'] === T_ANON_CLASS
129
+ ) {
130
  $returnToken = $tokens[$returnToken]['scope_closer'];
131
  continue;
132
  }
148
  }
149
  }
150
  }//end if
151
+ } else if ($returnType !== 'mixed' && in_array('void', $typeNames, true) === false) {
152
  // If return type is not void, there needs to be a return statement
153
  // somewhere in the function that returns something.
154
  if (isset($tokens[$stackPtr]['scope_closer']) === true) {
256
  */
257
  protected function processParams(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $commentStart)
258
  {
259
+ if ($this->_phpVersion === null) {
260
+ $this->_phpVersion = PHP_CodeSniffer::getConfigData('php_version');
261
+ if ($this->_phpVersion === null) {
262
+ $this->_phpVersion = PHP_VERSION_ID;
263
+ }
264
+ }
265
+
266
  $tokens = $phpcsFile->getTokens();
267
 
268
  $params = array();
283
  $matches = array();
284
  preg_match('/([^$&.]+)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches);
285
 
286
+ if (empty($matches) === false) {
287
+ $typeLen = strlen($matches[1]);
288
+ $type = trim($matches[1]);
289
+ $typeSpace = ($typeLen - strlen($type));
290
+ $typeLen = strlen($type);
291
+ if ($typeLen > $maxType) {
292
+ $maxType = $typeLen;
293
+ }
294
  }
295
 
296
  if (isset($matches[2]) === true) {
374
  }
375
 
376
  // Check the param type value.
377
+ $typeNames = explode('|', $param['type']);
378
+ $suggestedTypeNames = array();
379
+
380
  foreach ($typeNames as $typeName) {
381
+ $suggestedName = PHP_CodeSniffer::suggestType($typeName);
382
+ $suggestedTypeNames[] = $suggestedName;
 
 
 
 
 
383
 
384
+ if (count($typeNames) > 1) {
385
+ continue;
386
+ }
 
 
 
 
 
 
387
 
388
+ // Check type hint for array and custom type.
389
+ $suggestedTypeHint = '';
390
+ if (strpos($suggestedName, 'array') !== false || substr($suggestedName, -2) === '[]') {
391
+ $suggestedTypeHint = 'array';
392
+ } else if (strpos($suggestedName, 'callable') !== false) {
393
+ $suggestedTypeHint = 'callable';
394
+ } else if (strpos($suggestedName, 'callback') !== false) {
395
+ $suggestedTypeHint = 'callable';
396
+ } else if (in_array($typeName, PHP_CodeSniffer::$allowedTypes) === false) {
397
+ $suggestedTypeHint = $suggestedName;
398
+ } else if ($this->_phpVersion >= 70000) {
399
+ if ($typeName === 'string') {
400
+ $suggestedTypeHint = 'string';
401
+ } else if ($typeName === 'int' || $typeName === 'integer') {
402
+ $suggestedTypeHint = 'int';
403
+ } else if ($typeName === 'float') {
404
+ $suggestedTypeHint = 'float';
405
+ } else if ($typeName === 'bool' || $typeName === 'boolean') {
406
+ $suggestedTypeHint = 'bool';
 
 
 
 
407
  }
408
+ }
409
 
410
+ if ($suggestedTypeHint !== '' && isset($realParams[$pos]) === true) {
411
+ $typeHint = $realParams[$pos]['type_hint'];
412
+ if ($typeHint === '') {
413
+ $error = 'Type hint "%s" missing for %s';
414
+ $data = array(
415
+ $suggestedTypeHint,
416
+ $param['var'],
417
+ );
418
+
419
+ $errorCode = 'TypeHintMissing';
420
+ if ($suggestedTypeHint === 'string'
421
+ || $suggestedTypeHint === 'int'
422
+ || $suggestedTypeHint === 'float'
423
+ || $suggestedTypeHint === 'bool'
424
+ ) {
425
+ $errorCode = 'Scalar'.$errorCode;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
426
  }
427
+
428
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
429
+ } else if ($typeHint !== substr($suggestedTypeHint, (strlen($typeHint) * -1))) {
430
+ $error = 'Expected type hint "%s"; found "%s" for %s';
431
+ $data = array(
432
+ $suggestedTypeHint,
433
+ $typeHint,
434
+ $param['var'],
435
+ );
436
+ $phpcsFile->addError($error, $stackPtr, 'IncorrectTypeHint', $data);
437
  }//end if
438
+ } else if ($suggestedTypeHint === '' && isset($realParams[$pos]) === true) {
439
+ $typeHint = $realParams[$pos]['type_hint'];
440
+ if ($typeHint !== '') {
441
+ $error = 'Unknown type hint "%s" found for %s';
442
+ $data = array(
443
+ $typeHint,
444
+ $param['var'],
445
+ );
446
+ $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHint', $data);
447
+ }
448
  }//end if
449
  }//end foreach
450
 
451
+ $suggestedType = implode($suggestedTypeNames, '|');
452
+ if ($param['type'] !== $suggestedType) {
453
+ $error = 'Expected "%s" but found "%s" for parameter type';
 
 
 
 
 
 
 
454
  $data = array(
455
+ $suggestedType,
456
+ $param['type'],
457
  );
458
 
459
+ $fix = $phpcsFile->addFixableError($error, $param['tag'], 'IncorrectParamVarName', $data);
460
  if ($fix === true) {
461
  $phpcsFile->fixer->beginChangeset();
462
 
463
+ $content = $suggestedType;
464
+ $content .= str_repeat(' ', $param['type_space']);
465
  $content .= $param['var'];
466
  $content .= str_repeat(' ', $param['var_space']);
467
+ if (isset($param['commentLines'][0]) === true) {
468
+ $content .= $param['commentLines'][0]['comment'];
469
+ }
470
+
471
  $phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content);
472
 
473
  // Fix up the indent of additional comment lines.
478
  continue;
479
  }
480
 
481
+ $diff = (strlen($param['type']) - strlen($suggestedType));
482
+ $newIndent = ($param['commentLines'][$lineNum]['indent'] - $diff);
483
  $phpcsFile->fixer->replaceToken(
484
  ($param['commentLines'][$lineNum]['token'] - 1),
485
  str_repeat(' ', $newIndent)
490
  }//end if
491
  }//end if
492
 
493
+ if ($param['var'] === '') {
494
+ continue;
495
+ }
496
+
497
+ $foundParams[] = $param['var'];
498
+
499
+ // Check number of spaces after the type.
500
+ $this->checkSpacingAfterParamType($phpcsFile, $param, $maxType);
501
+
502
  // Make sure the param name is correct.
503
  if (isset($realParams[$pos]) === true) {
504
  $realName = $realParams[$pos]['name'];
530
  }
531
 
532
  // Check number of spaces after the var name.
533
+ $this->checkSpacingAfterParamName($phpcsFile, $param, $maxVar);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
534
 
535
  // Param comments must start with a capital letter and end with the full stop.
536
  if (preg_match('/^(\p{Ll}|\P{L})/u', $param['comment']) === 1) {
561
  }//end processParams()
562
 
563
 
564
+ /**
565
+ * Check the spacing after the type of a parameter.
566
+ *
567
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
568
+ * @param array $param The parameter to be checked.
569
+ * @param int $maxType The maxlength of the longest parameter type.
570
+ * @param int $spacing The number of spaces to add after the type.
571
+ *
572
+ * @return void
573
+ */
574
+ protected function checkSpacingAfterParamType(PHP_CodeSniffer_File $phpcsFile, $param, $maxType, $spacing = 1)
575
+ {
576
+ // Check number of spaces after the type.
577
+ $spaces = ($maxType - strlen($param['type']) + $spacing);
578
+ if ($param['type_space'] !== $spaces) {
579
+ $error = 'Expected %s spaces after parameter type; %s found';
580
+ $data = array(
581
+ $spaces,
582
+ $param['type_space'],
583
+ );
584
+
585
+ $fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamType', $data);
586
+ if ($fix === true) {
587
+ $phpcsFile->fixer->beginChangeset();
588
+
589
+ $content = $param['type'];
590
+ $content .= str_repeat(' ', $spaces);
591
+ $content .= $param['var'];
592
+ $content .= str_repeat(' ', $param['var_space']);
593
+ $content .= $param['commentLines'][0]['comment'];
594
+ $phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content);
595
+
596
+ // Fix up the indent of additional comment lines.
597
+ foreach ($param['commentLines'] as $lineNum => $line) {
598
+ if ($lineNum === 0
599
+ || $param['commentLines'][$lineNum]['indent'] === 0
600
+ ) {
601
+ continue;
602
+ }
603
+
604
+ $diff = ($param['type_space'] - $spaces);
605
+ $newIndent = ($param['commentLines'][$lineNum]['indent'] - $diff);
606
+ $phpcsFile->fixer->replaceToken(
607
+ ($param['commentLines'][$lineNum]['token'] - 1),
608
+ str_repeat(' ', $newIndent)
609
+ );
610
+ }
611
+
612
+ $phpcsFile->fixer->endChangeset();
613
+ }//end if
614
+ }//end if
615
+
616
+ }//end checkSpacingAfterParamType()
617
+
618
+
619
+ /**
620
+ * Check the spacing after the name of a parameter.
621
+ *
622
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
623
+ * @param array $param The parameter to be checked.
624
+ * @param int $maxVar The maxlength of the longest parameter name.
625
+ * @param int $spacing The number of spaces to add after the type.
626
+ *
627
+ * @return void
628
+ */
629
+ protected function checkSpacingAfterParamName(PHP_CodeSniffer_File $phpcsFile, $param, $maxVar, $spacing = 1)
630
+ {
631
+ // Check number of spaces after the var name.
632
+ $spaces = ($maxVar - strlen($param['var']) + $spacing);
633
+ if ($param['var_space'] !== $spaces) {
634
+ $error = 'Expected %s spaces after parameter name; %s found';
635
+ $data = array(
636
+ $spaces,
637
+ $param['var_space'],
638
+ );
639
+
640
+ $fix = $phpcsFile->addFixableError($error, $param['tag'], 'SpacingAfterParamName', $data);
641
+ if ($fix === true) {
642
+ $phpcsFile->fixer->beginChangeset();
643
+
644
+ $content = $param['type'];
645
+ $content .= str_repeat(' ', $param['type_space']);
646
+ $content .= $param['var'];
647
+ $content .= str_repeat(' ', $spaces);
648
+ $content .= $param['commentLines'][0]['comment'];
649
+ $phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content);
650
+
651
+ // Fix up the indent of additional comment lines.
652
+ foreach ($param['commentLines'] as $lineNum => $line) {
653
+ if ($lineNum === 0
654
+ || $param['commentLines'][$lineNum]['indent'] === 0
655
+ ) {
656
+ continue;
657
+ }
658
+
659
+ $diff = ($param['var_space'] - $spaces);
660
+ $newIndent = ($param['commentLines'][$lineNum]['indent'] - $diff);
661
+ $phpcsFile->fixer->replaceToken(
662
+ ($param['commentLines'][$lineNum]['token'] - 1),
663
+ str_repeat(' ', $newIndent)
664
+ );
665
+ }
666
+
667
+ $phpcsFile->fixer->endChangeset();
668
+ }//end if
669
+ }//end if
670
+
671
+ }//end checkSpacingAfterParamName()
672
+
673
+
674
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php CHANGED
@@ -59,7 +59,16 @@ class Squiz_Sniffs_Commenting_LongConditionClosingCommentSniff implements PHP_Co
59
  *
60
  * @var int
61
  */
62
- protected $lineLimit = 20;
 
 
 
 
 
 
 
 
 
63
 
64
 
65
  /**
@@ -102,7 +111,7 @@ class Squiz_Sniffs_Commenting_LongConditionClosingCommentSniff implements PHP_Co
102
  }
103
 
104
  if ($startCondition['code'] === T_IF) {
105
- // If this is actually and ELSE IF, skip it as the brace
106
  // will be checked by the original IF.
107
  $else = $phpcsFile->findPrevious(T_WHITESPACE, ($tokens[$stackPtr]['scope_condition'] - 1), null, true);
108
  if ($tokens[$else]['code'] === T_ELSE) {
@@ -158,7 +167,7 @@ class Squiz_Sniffs_Commenting_LongConditionClosingCommentSniff implements PHP_Co
158
 
159
  $lineDifference = ($endBrace['line'] - $startBrace['line']);
160
 
161
- $expected = '//end '.$startCondition['content'];
162
  $comment = $phpcsFile->findNext(array(T_COMMENT), $stackPtr, null, false);
163
 
164
  if (($comment === false) || ($tokens[$comment]['line'] !== $endBrace['line'])) {
59
  *
60
  * @var int
61
  */
62
+ public $lineLimit = 20;
63
+
64
+ /**
65
+ * The format the end comment should be in.
66
+ *
67
+ * The placeholder %s will be replaced with the type of condition opener.
68
+ *
69
+ * @var string
70
+ */
71
+ public $commentFormat = '//end %s';
72
 
73
 
74
  /**
111
  }
112
 
113
  if ($startCondition['code'] === T_IF) {
114
+ // If this is actually an ELSE IF, skip it as the brace
115
  // will be checked by the original IF.
116
  $else = $phpcsFile->findPrevious(T_WHITESPACE, ($tokens[$stackPtr]['scope_condition'] - 1), null, true);
117
  if ($tokens[$else]['code'] === T_ELSE) {
167
 
168
  $lineDifference = ($endBrace['line'] - $startBrace['line']);
169
 
170
+ $expected = sprintf($this->commentFormat, $startCondition['content']);
171
  $comment = $phpcsFile->findNext(array(T_COMMENT), $stackPtr, null, false);
172
 
173
  if (($comment === false) || ($tokens[$comment]['line'] !== $endBrace['line'])) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php CHANGED
@@ -45,14 +45,21 @@ class Squiz_Sniffs_Commenting_VariableCommentSniff extends PHP_CodeSniffer_Stand
45
  */
46
  public function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
47
  {
48
- $tokens = $phpcsFile->getTokens();
49
- $commentToken = array(
50
- T_COMMENT,
51
- T_DOC_COMMENT_CLOSE_TAG,
52
- );
53
-
54
- $commentEnd = $phpcsFile->findPrevious($commentToken, $stackPtr);
55
- if ($commentEnd === false) {
 
 
 
 
 
 
 
56
  $phpcsFile->addError('Missing member variable doc comment', $stackPtr, 'Missing');
57
  return;
58
  }
@@ -60,16 +67,6 @@ class Squiz_Sniffs_Commenting_VariableCommentSniff extends PHP_CodeSniffer_Stand
60
  if ($tokens[$commentEnd]['code'] === T_COMMENT) {
61
  $phpcsFile->addError('You must use "/**" style comments for a member variable comment', $stackPtr, 'WrongStyle');
62
  return;
63
- } else if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG) {
64
- $phpcsFile->addError('Missing member variable doc comment', $stackPtr, 'Missing');
65
- return;
66
- } else {
67
- // Make sure the comment we have found belongs to us.
68
- $commentFor = $phpcsFile->findNext(array(T_VARIABLE, T_CLASS, T_INTERFACE), ($commentEnd + 1));
69
- if ($commentFor !== $stackPtr) {
70
- $phpcsFile->addError('Missing member variable doc comment', $stackPtr, 'Missing');
71
- return;
72
- }
73
  }
74
 
75
  $commentStart = $tokens[$commentEnd]['comment_opener'];
@@ -126,7 +123,11 @@ class Squiz_Sniffs_Commenting_VariableCommentSniff extends PHP_CodeSniffer_Stand
126
  $suggestedType,
127
  $varType,
128
  );
129
- $phpcsFile->addError($error, ($foundVar + 2), 'IncorrectVarType', $data);
 
 
 
 
130
  }
131
 
132
  }//end processMemberVar()
45
  */
46
  public function processMemberVar(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
47
  {
48
+ $tokens = $phpcsFile->getTokens();
49
+ $ignore = array(
50
+ T_PUBLIC,
51
+ T_PRIVATE,
52
+ T_PROTECTED,
53
+ T_VAR,
54
+ T_STATIC,
55
+ T_WHITESPACE,
56
+ );
57
+
58
+ $commentEnd = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
59
+ if ($commentEnd === false
60
+ || ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG
61
+ && $tokens[$commentEnd]['code'] !== T_COMMENT)
62
+ ) {
63
  $phpcsFile->addError('Missing member variable doc comment', $stackPtr, 'Missing');
64
  return;
65
  }
67
  if ($tokens[$commentEnd]['code'] === T_COMMENT) {
68
  $phpcsFile->addError('You must use "/**" style comments for a member variable comment', $stackPtr, 'WrongStyle');
69
  return;
 
 
 
 
 
 
 
 
 
 
70
  }
71
 
72
  $commentStart = $tokens[$commentEnd]['comment_opener'];
123
  $suggestedType,
124
  $varType,
125
  );
126
+
127
+ $fix = $phpcsFile->addFixableError($error, ($foundVar + 2), 'IncorrectVarType', $data);
128
+ if ($fix === true) {
129
+ $phpcsFile->fixer->replaceToken(($foundVar + 2), $suggestedType);
130
+ }
131
  }
132
 
133
  }//end processMemberVar()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php CHANGED
@@ -128,21 +128,30 @@ class Squiz_Sniffs_ControlStructures_ControlSignatureSniff implements PHP_CodeSn
128
  $phpcsFile->fixer->addContent($closer, ' ');
129
  } else {
130
  $phpcsFile->fixer->beginChangeset();
131
- $phpcsFile->fixer->addContent($closer, ' '.$tokens[$opener]['content']);
132
- $phpcsFile->fixer->replaceToken($opener, '');
133
-
134
- if ($tokens[$opener]['line'] !== $tokens[$closer]['line']) {
135
- $next = $phpcsFile->findNext(T_WHITESPACE, ($opener + 1), null, true);
136
- if ($tokens[$next]['line'] !== $tokens[$opener]['line']) {
137
- for ($i = ($opener + 1); $i < $next; $i++) {
138
  $phpcsFile->fixer->replaceToken($i, '');
139
  }
140
  }
 
 
 
 
 
 
 
 
 
 
 
 
141
  }
142
 
143
  $phpcsFile->fixer->endChangeset();
144
- }
145
- }
146
  }//end if
147
  }//end if
148
 
128
  $phpcsFile->fixer->addContent($closer, ' ');
129
  } else {
130
  $phpcsFile->fixer->beginChangeset();
131
+ if (trim($content) === '') {
132
+ $phpcsFile->fixer->addContent($closer, ' ');
133
+ if ($found !== 0) {
134
+ for ($i = ($closer + 1); $i < $opener; $i++) {
 
 
 
135
  $phpcsFile->fixer->replaceToken($i, '');
136
  }
137
  }
138
+ } else {
139
+ $phpcsFile->fixer->addContent($closer, ' '.$tokens[$opener]['content']);
140
+ $phpcsFile->fixer->replaceToken($opener, '');
141
+
142
+ if ($tokens[$opener]['line'] !== $tokens[$closer]['line']) {
143
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($opener + 1), null, true);
144
+ if ($tokens[$next]['line'] !== $tokens[$opener]['line']) {
145
+ for ($i = ($opener + 1); $i < $next; $i++) {
146
+ $phpcsFile->fixer->replaceToken($i, '');
147
+ }
148
+ }
149
+ }
150
  }
151
 
152
  $phpcsFile->fixer->endChangeset();
153
+ }//end if
154
+ }//end if
155
  }//end if
156
  }//end if
157
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php CHANGED
@@ -86,40 +86,78 @@ class Squiz_Sniffs_ControlStructures_InlineIfDeclarationSniff implements PHP_Cod
86
  if ($tokens[$contentBefore]['code'] !== T_CLOSE_PARENTHESIS) {
87
  $error = 'Inline shorthand IF statement requires brackets around comparison';
88
  $phpcsFile->addError($error, $stackPtr, 'NoBrackets');
89
- return;
90
  }
91
 
92
  $spaceBefore = ($tokens[$stackPtr]['column'] - ($tokens[$contentBefore]['column'] + $tokens[$contentBefore]['length']));
93
  if ($spaceBefore !== 1) {
94
  $error = 'Inline shorthand IF statement requires 1 space before THEN; %s found';
95
  $data = array($spaceBefore);
96
- $phpcsFile->addError($error, $stackPtr, 'SpacingBeforeThen', $data);
97
- }
98
-
99
- $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$stackPtr]['column'] + 1));
100
- if ($spaceAfter !== 1) {
101
- $error = 'Inline shorthand IF statement requires 1 space after THEN; %s found';
102
- $data = array($spaceAfter);
103
- $phpcsFile->addError($error, $stackPtr, 'SpacingAfterThen', $data);
104
- }
105
-
106
- // Make sure the ELSE has the correct spacing.
107
- $inlineElse = $phpcsFile->findNext(T_INLINE_ELSE, ($stackPtr + 1), $statementEnd, false);
108
- $contentBefore = $phpcsFile->findPrevious(T_WHITESPACE, ($inlineElse - 1), null, true);
109
- $contentAfter = $phpcsFile->findNext(T_WHITESPACE, ($inlineElse + 1), null, true);
110
-
111
- $spaceBefore = ($tokens[$inlineElse]['column'] - ($tokens[$contentBefore]['column'] + $tokens[$contentBefore]['length']));
112
- if ($spaceBefore !== 1) {
113
- $error = 'Inline shorthand IF statement requires 1 space before ELSE; %s found';
114
- $data = array($spaceBefore);
115
- $phpcsFile->addError($error, $inlineElse, 'SpacingBeforeElse', $data);
116
  }
117
 
118
- $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$inlineElse]['column'] + 1));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  if ($spaceAfter !== 1) {
120
  $error = 'Inline shorthand IF statement requires 1 space after ELSE; %s found';
121
  $data = array($spaceAfter);
122
- $phpcsFile->addError($error, $inlineElse, 'SpacingAfterElse', $data);
 
 
 
 
 
123
  }
124
 
125
  }//end process()
86
  if ($tokens[$contentBefore]['code'] !== T_CLOSE_PARENTHESIS) {
87
  $error = 'Inline shorthand IF statement requires brackets around comparison';
88
  $phpcsFile->addError($error, $stackPtr, 'NoBrackets');
 
89
  }
90
 
91
  $spaceBefore = ($tokens[$stackPtr]['column'] - ($tokens[$contentBefore]['column'] + $tokens[$contentBefore]['length']));
92
  if ($spaceBefore !== 1) {
93
  $error = 'Inline shorthand IF statement requires 1 space before THEN; %s found';
94
  $data = array($spaceBefore);
95
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingBeforeThen', $data);
96
+ if ($fix === true) {
97
+ if ($spaceBefore === 0) {
98
+ $phpcsFile->fixer->addContentBefore($stackPtr, ' ');
99
+ } else {
100
+ $phpcsFile->fixer->replaceToken(($stackPtr - 1), ' ');
101
+ }
102
+ }
 
 
 
 
 
 
 
 
 
 
 
 
103
  }
104
 
105
+ // If there is no content between the ? and the : operators, then they are
106
+ // trying to replicate an elvis operator, even though PHP doesn't have one.
107
+ // In this case, we want no spaces between the two operators so ?: looks like
108
+ // an operator itself.
109
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
110
+ if ($tokens[$next]['code'] === T_INLINE_ELSE) {
111
+ $inlineElse = $next;
112
+ if ($inlineElse !== ($stackPtr + 1)) {
113
+ $error = 'Inline shorthand IF statement without THEN statement requires 0 spaces between THEN and ELSE';
114
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'ElvisSpacing');
115
+ if ($fix === true) {
116
+ $phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
117
+ }
118
+ }
119
+ } else {
120
+ $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$stackPtr]['column'] + 1));
121
+ if ($spaceAfter !== 1) {
122
+ $error = 'Inline shorthand IF statement requires 1 space after THEN; %s found';
123
+ $data = array($spaceAfter);
124
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpacingAfterThen', $data);
125
+ if ($spaceAfter === 0) {
126
+ $phpcsFile->fixer->addContent($stackPtr, ' ');
127
+ } else {
128
+ $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
129
+ }
130
+ }
131
+
132
+ // Make sure the ELSE has the correct spacing.
133
+ $inlineElse = $phpcsFile->findNext(T_INLINE_ELSE, ($stackPtr + 1), $statementEnd, false);
134
+ $contentBefore = $phpcsFile->findPrevious(T_WHITESPACE, ($inlineElse - 1), null, true);
135
+ $spaceBefore = ($tokens[$inlineElse]['column'] - ($tokens[$contentBefore]['column'] + $tokens[$contentBefore]['length']));
136
+ if ($spaceBefore !== 1) {
137
+ $error = 'Inline shorthand IF statement requires 1 space before ELSE; %s found';
138
+ $data = array($spaceBefore);
139
+ $fix = $phpcsFile->addFixableError($error, $inlineElse, 'SpacingBeforeElse', $data);
140
+ if ($fix === true) {
141
+ if ($spaceBefore === 0) {
142
+ $phpcsFile->fixer->addContentBefore($inlineElse, ' ');
143
+ } else {
144
+ $phpcsFile->fixer->replaceToken(($inlineElse - 1), ' ');
145
+ }
146
+ }
147
+ }
148
+ }//end if
149
+
150
+ $contentAfter = $phpcsFile->findNext(T_WHITESPACE, ($inlineElse + 1), null, true);
151
+ $spaceAfter = (($tokens[$contentAfter]['column']) - ($tokens[$inlineElse]['column'] + 1));
152
  if ($spaceAfter !== 1) {
153
  $error = 'Inline shorthand IF statement requires 1 space after ELSE; %s found';
154
  $data = array($spaceAfter);
155
+ $fix = $phpcsFile->addFixableError($error, $inlineElse, 'SpacingAfterElse', $data);
156
+ if ($spaceAfter === 0) {
157
+ $phpcsFile->fixer->addContent($inlineElse, ' ');
158
+ } else {
159
+ $phpcsFile->fixer->replaceToken(($inlineElse + 1), ' ');
160
+ }
161
  }
162
 
163
  }//end process()
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Debug/JSLintSniff.php CHANGED
@@ -68,7 +68,10 @@ class Squiz_Sniffs_Debug_JSLintSniff implements PHP_CodeSniffer_Sniff
68
  return;
69
  }
70
 
71
- $cmd = "$rhinoPath \"$jslintPath\" \"$fileName\"";
 
 
 
72
  $msg = exec($cmd, $output, $retval);
73
 
74
  if (is_array($output) === true) {
68
  return;
69
  }
70
 
71
+ $rhinoPath = escapeshellcmd($rhinoPath);
72
+ $jslintPath = escapeshellcmd($jslintPath);
73
+
74
+ $cmd = "$rhinoPath \"$jslintPath\" ".escapeshellarg($fileName);
75
  $msg = exec($cmd, $output, $retval);
76
 
77
  if (is_array($output) === true) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php CHANGED
@@ -66,7 +66,7 @@ class Squiz_Sniffs_Debug_JavaScriptLintSniff implements PHP_CodeSniffer_Sniff
66
  return;
67
  }
68
 
69
- $cmd = '"'.$jslPath.'" -nologo -nofilelisting -nocontext -nosummary -output-format __LINE__:__ERROR__ -process "'.$fileName.'"';
70
  $msg = exec($cmd, $output, $retval);
71
 
72
  // Variable $exitCode is the last line of $output if no error occurs, on
66
  return;
67
  }
68
 
69
+ $cmd = '"'.escapeshellcmd($jslPath).'" -nologo -nofilelisting -nocontext -nosummary -output-format __LINE__:__ERROR__ -process '.escapeshellarg($fileName);
70
  $msg = exec($cmd, $output, $retval);
71
 
72
  // Variable $exitCode is the last line of $output if no error occurs, on
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php CHANGED
@@ -109,6 +109,44 @@ class Squiz_Sniffs_Formatting_OperatorBracketSniff implements PHP_CodeSniffer_Sn
109
  }
110
  }//end if
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  $lastBracket = false;
113
  if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
114
  $parenthesis = array_reverse($tokens[$stackPtr]['nested_parenthesis'], true);
@@ -123,23 +161,8 @@ class Squiz_Sniffs_Formatting_OperatorBracketSniff implements PHP_CodeSniffer_Sn
123
  }
124
 
125
  if ($prevCode === T_STRING || $prevCode === T_SWITCH) {
126
- // We allow very simple operations to not be bracketed.
127
  // For example, ceil($one / $two).
128
- $allowed = array(
129
- T_VARIABLE,
130
- T_LNUMBER,
131
- T_DNUMBER,
132
- T_STRING,
133
- T_WHITESPACE,
134
- T_THIS,
135
- T_SELF,
136
- T_OBJECT_OPERATOR,
137
- T_DOUBLE_COLON,
138
- T_OPEN_SQUARE_BRACKET,
139
- T_CLOSE_SQUARE_BRACKET,
140
- T_MODULUS,
141
- );
142
-
143
  for ($prev = ($stackPtr - 1); $prev > $bracket; $prev--) {
144
  if (in_array($tokens[$prev]['code'], $allowed) === true) {
145
  continue;
@@ -197,25 +220,8 @@ class Squiz_Sniffs_Formatting_OperatorBracketSniff implements PHP_CodeSniffer_Sn
197
 
198
  if ($lastBracket === false) {
199
  // It is not in a bracketed statement at all.
200
- $previousToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true, null, true);
201
- if ($previousToken !== false) {
202
- // A list of tokens that indicate that the token is not
203
- // part of an arithmetic operation.
204
- $invalidTokens = array(
205
- T_COMMA,
206
- T_COLON,
207
- T_OPEN_PARENTHESIS,
208
- T_OPEN_SQUARE_BRACKET,
209
- T_OPEN_SHORT_ARRAY,
210
- T_CASE,
211
- );
212
-
213
- if (in_array($tokens[$previousToken]['code'], $invalidTokens) === false) {
214
- $this->addMissingBracketsError($phpcsFile, $stackPtr);
215
- }
216
-
217
- return;
218
- }
219
  } else if ($tokens[$lastBracket]['parenthesis_closer'] < $stackPtr) {
220
  // There are a set of brackets in front of it that don't include it.
221
  $this->addMissingBracketsError($phpcsFile, $stackPtr);
@@ -262,7 +268,7 @@ class Squiz_Sniffs_Formatting_OperatorBracketSniff implements PHP_CodeSniffer_Sn
262
  $error = 'Arithmetic operation must be bracketed';
263
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'MissingBrackets');
264
 
265
- if ($fix === false || $phpcsFile->fixer->enabled === false) {
266
  return;
267
  }
268
 
@@ -281,6 +287,7 @@ class Squiz_Sniffs_Formatting_OperatorBracketSniff implements PHP_CodeSniffer_Sn
281
  T_MODULUS => true,
282
  T_ISSET => true,
283
  T_ARRAY => true,
 
284
  );
285
 
286
  // Find the first token in the expression.
109
  }
110
  }//end if
111
 
112
+ $previousToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true, null, true);
113
+ if ($previousToken !== false) {
114
+ // A list of tokens that indicate that the token is not
115
+ // part of an arithmetic operation.
116
+ $invalidTokens = array(
117
+ T_COMMA,
118
+ T_COLON,
119
+ T_OPEN_PARENTHESIS,
120
+ T_OPEN_SQUARE_BRACKET,
121
+ T_OPEN_SHORT_ARRAY,
122
+ T_CASE,
123
+ );
124
+
125
+ if (in_array($tokens[$previousToken]['code'], $invalidTokens) === true) {
126
+ return;
127
+ }
128
+ }
129
+
130
+ // Tokens that are allowed inside a bracketed operation.
131
+ $allowed = array(
132
+ T_VARIABLE,
133
+ T_LNUMBER,
134
+ T_DNUMBER,
135
+ T_STRING,
136
+ T_WHITESPACE,
137
+ T_NS_SEPARATOR,
138
+ T_THIS,
139
+ T_SELF,
140
+ T_OBJECT_OPERATOR,
141
+ T_DOUBLE_COLON,
142
+ T_OPEN_SQUARE_BRACKET,
143
+ T_CLOSE_SQUARE_BRACKET,
144
+ T_MODULUS,
145
+ T_NONE,
146
+ );
147
+
148
+ $allowed += PHP_CodeSniffer_Tokens::$operators;
149
+
150
  $lastBracket = false;
151
  if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
152
  $parenthesis = array_reverse($tokens[$stackPtr]['nested_parenthesis'], true);
161
  }
162
 
163
  if ($prevCode === T_STRING || $prevCode === T_SWITCH) {
164
+ // We allow simple operations to not be bracketed.
165
  // For example, ceil($one / $two).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  for ($prev = ($stackPtr - 1); $prev > $bracket; $prev--) {
167
  if (in_array($tokens[$prev]['code'], $allowed) === true) {
168
  continue;
220
 
221
  if ($lastBracket === false) {
222
  // It is not in a bracketed statement at all.
223
+ $this->addMissingBracketsError($phpcsFile, $stackPtr);
224
+ return;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
  } else if ($tokens[$lastBracket]['parenthesis_closer'] < $stackPtr) {
226
  // There are a set of brackets in front of it that don't include it.
227
  $this->addMissingBracketsError($phpcsFile, $stackPtr);
268
  $error = 'Arithmetic operation must be bracketed';
269
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'MissingBrackets');
270
 
271
+ if ($fix === false) {
272
  return;
273
  }
274
 
287
  T_MODULUS => true,
288
  T_ISSET => true,
289
  T_ARRAY => true,
290
+ T_NONE => true,
291
  );
292
 
293
  // Find the first token in the expression.
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php CHANGED
@@ -198,13 +198,14 @@ class Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff implements
198
  }
199
  }
200
 
201
- // Take references into account when expecting the
202
- // location of whitespace.
203
  $checkToken = ($nextParam - 1);
204
- if ($tokens[$checkToken]['code'] === T_ELLIPSIS) {
205
- $checkToken--;
 
206
  }
207
 
 
 
208
  if ($phpcsFile->isReference($checkToken) === true) {
209
  $whitespace = ($checkToken - 1);
210
  } else {
198
  }
199
  }
200
 
 
 
201
  $checkToken = ($nextParam - 1);
202
+ $prev = $phpcsFile->findPrevious(T_WHITESPACE, $checkToken, null, true);
203
+ if ($tokens[$prev]['code'] === T_ELLIPSIS) {
204
+ $checkToken = ($prev - 1);
205
  }
206
 
207
+ // Take references into account when expecting the
208
+ // location of whitespace.
209
  if ($phpcsFile->isReference($checkToken) === true) {
210
  $whitespace = ($checkToken - 1);
211
  } else {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php CHANGED
@@ -16,7 +16,7 @@
16
  /**
17
  * Squiz_Sniffs_Functions_LowercaseFunctionKeywordsSniff.
18
  *
19
- * Ensures all class keywords are lowercase.
20
  *
21
  * @category PHP
22
  * @package PHP_CodeSniffer
16
  /**
17
  * Squiz_Sniffs_Functions_LowercaseFunctionKeywordsSniff.
18
  *
19
+ * Ensures all function keywords are lowercase.
20
  *
21
  * @category PHP
22
  * @package PHP_CodeSniffer
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php CHANGED
@@ -205,7 +205,7 @@ class Squiz_Sniffs_Functions_MultiLineFunctionDeclarationSniff extends PEAR_Snif
205
  }
206
 
207
  $next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true);
208
- if ($tokens[$next]['line'] !== ($tokens[$i]['line'] + 1)) {
209
  $error = 'Multi-line '.$type.' declarations must define one parameter per line';
210
  $fix = $phpcsFile->addFixableError($error, $next, $errorPrefix.'OneParamPerLine');
211
  if ($fix === true) {
205
  }
206
 
207
  $next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true);
208
+ if ($tokens[$next]['line'] === $tokens[$i]['line']) {
209
  $error = 'Multi-line '.$type.' declarations must define one parameter per line';
210
  $fix = $phpcsFile->addFixableError($error, $next, $errorPrefix.'OneParamPerLine');
211
  if ($fix === true) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php CHANGED
@@ -55,7 +55,7 @@ class Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff extends PEAR_Sniffs_
55
  $errorData = array($functionName);
56
 
57
  // Does this function claim to be magical?
58
- if (preg_match('|^__|', $functionName) !== 0) {
59
  $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
60
  $phpcsFile->addError($error, $stackPtr, 'DoubleUnderscore', $errorData);
61
  return;
55
  $errorData = array($functionName);
56
 
57
  // Does this function claim to be magical?
58
+ if (preg_match('|^__[^_]|', $functionName) !== 0) {
59
  $error = 'Function name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
60
  $phpcsFile->addError($error, $stackPtr, 'DoubleUnderscore', $errorData);
61
  return;
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php CHANGED
@@ -154,7 +154,7 @@ class Squiz_Sniffs_Operators_ComparisonOperatorUsageSniff implements PHP_CodeSni
154
 
155
  $start = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($i + 1), null, true);
156
  } else {
157
- if (isset($tokens[$stackPtr]['parenthesis_opener']) === false) {
158
  return;
159
  }
160
 
154
 
155
  $start = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($i + 1), null, true);
156
  } else {
157
+ if (isset($tokens[$end]['parenthesis_opener']) === false) {
158
  return;
159
  }
160
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php CHANGED
@@ -87,7 +87,10 @@ class Squiz_Sniffs_Operators_IncrementDecrementUsageSniff implements PHP_CodeSni
87
 
88
  // Work out where the variable is so we know where to
89
  // start looking for other operators.
90
- if ($tokens[($stackPtr - 1)]['code'] === T_VARIABLE) {
 
 
 
91
  $start = ($stackPtr + 1);
92
  } else {
93
  $start = ($stackPtr + 2);
87
 
88
  // Work out where the variable is so we know where to
89
  // start looking for other operators.
90
+ if ($tokens[($stackPtr - 1)]['code'] === T_VARIABLE
91
+ || ($tokens[($stackPtr - 1)]['code'] === T_STRING
92
+ && $tokens[($stackPtr - 2)]['code'] === T_OBJECT_OPERATOR)
93
+ ) {
94
  $start = ($stackPtr + 1);
95
  } else {
96
  $start = ($stackPtr + 2);
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php CHANGED
@@ -151,6 +151,11 @@ class Squiz_Sniffs_PHP_DisallowMultipleAssignmentsSniff implements PHP_CodeSniff
151
  return;
152
  }
153
 
 
 
 
 
 
154
  if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === false) {
155
  $prevLine = $tokens[$i]['line'];
156
  break;
151
  return;
152
  }
153
 
154
+ if ($tokens[$i]['code'] === T_OPEN_TAG) {
155
+ // We reached the end of the code block.
156
+ return;
157
+ }
158
+
159
  if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$i]['code']]) === false) {
160
  $prevLine = $tokens[$i]['line'];
161
  break;
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php CHANGED
@@ -355,13 +355,18 @@ class Squiz_Sniffs_PHP_EmbeddedPhpSniff implements PHP_CodeSniffer_Sniff
355
  }
356
 
357
  $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($closeTag - 1), $stackPtr, true);
358
- if ($tokens[$prev]['code'] !== T_SEMICOLON) {
 
 
 
 
 
359
  $error = 'Inline PHP statement must end with a semicolon';
360
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSemicolon');
361
  if ($fix === true) {
362
  $phpcsFile->fixer->addContent($prev, ';');
363
  }
364
- } else {
365
  $statementCount = 1;
366
  for ($i = ($stackPtr + 1); $i < $prev; $i++) {
367
  if ($tokens[$i]['code'] === T_SEMICOLON) {
355
  }
356
 
357
  $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($closeTag - 1), $stackPtr, true);
358
+ if ((isset($tokens[$prev]['scope_opener']) === false
359
+ || $tokens[$prev]['scope_opener'] !== $prev)
360
+ && (isset($tokens[$prev]['scope_closer']) === false
361
+ || $tokens[$prev]['scope_closer'] !== $prev)
362
+ && $tokens[$prev]['code'] !== T_SEMICOLON
363
+ ) {
364
  $error = 'Inline PHP statement must end with a semicolon';
365
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSemicolon');
366
  if ($fix === true) {
367
  $phpcsFile->fixer->addContent($prev, ';');
368
  }
369
+ } else if ($tokens[$prev]['code'] === T_SEMICOLON) {
370
  $statementCount = 1;
371
  for ($i = ($stackPtr + 1); $i < $prev; $i++) {
372
  if ($tokens[$i]['code'] === T_SEMICOLON) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php CHANGED
@@ -38,7 +38,7 @@ class Squiz_Sniffs_Scope_MethodScopeSniff extends PHP_CodeSniffer_Standards_Abst
38
  */
39
  public function __construct()
40
  {
41
- parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION));
42
 
43
  }//end __construct()
44
 
38
  */
39
  public function __construct()
40
  {
41
+ parent::__construct(array(T_CLASS, T_INTERFACE, T_TRAIT), array(T_FUNCTION));
42
 
43
  }//end __construct()
44
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php CHANGED
@@ -120,7 +120,16 @@ class Squiz_Sniffs_Strings_ConcatenationSpacingSniff implements PHP_CodeSniffer_
120
  $padding = str_repeat(' ', $this->spacing);
121
  if ($before !== 'newline' || $this->ignoreNewlines === false) {
122
  if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) {
 
123
  $phpcsFile->fixer->replaceToken(($stackPtr - 1), $padding);
 
 
 
 
 
 
 
 
124
  } else if ($this->spacing > 0) {
125
  $phpcsFile->fixer->addContent(($stackPtr - 1), $padding);
126
  }
@@ -128,12 +137,21 @@ class Squiz_Sniffs_Strings_ConcatenationSpacingSniff implements PHP_CodeSniffer_
128
 
129
  if ($after !== 'newline' || $this->ignoreNewlines === false) {
130
  if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
 
131
  $phpcsFile->fixer->replaceToken(($stackPtr + 1), $padding);
 
 
 
 
 
 
 
 
132
  } else if ($this->spacing > 0) {
133
  $phpcsFile->fixer->addContent($stackPtr, $padding);
134
  }
135
  }
136
- }
137
 
138
  }//end process()
139
 
120
  $padding = str_repeat(' ', $this->spacing);
121
  if ($before !== 'newline' || $this->ignoreNewlines === false) {
122
  if ($tokens[($stackPtr - 1)]['code'] === T_WHITESPACE) {
123
+ $phpcsFile->fixer->beginChangeset();
124
  $phpcsFile->fixer->replaceToken(($stackPtr - 1), $padding);
125
+ if ($this->spacing === 0
126
+ && ($tokens[($stackPtr - 2)]['code'] === T_LNUMBER
127
+ || $tokens[($stackPtr - 2)]['code'] === T_DNUMBER)
128
+ ) {
129
+ $phpcsFile->fixer->replaceToken(($stackPtr - 2), '('.$tokens[($stackPtr - 2)]['content'].')');
130
+ }
131
+
132
+ $phpcsFile->fixer->endChangeset();
133
  } else if ($this->spacing > 0) {
134
  $phpcsFile->fixer->addContent(($stackPtr - 1), $padding);
135
  }
137
 
138
  if ($after !== 'newline' || $this->ignoreNewlines === false) {
139
  if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
140
+ $phpcsFile->fixer->beginChangeset();
141
  $phpcsFile->fixer->replaceToken(($stackPtr + 1), $padding);
142
+ if ($this->spacing === 0
143
+ && ($tokens[($stackPtr + 2)]['code'] === T_LNUMBER
144
+ || $tokens[($stackPtr + 2)]['code'] === T_DNUMBER)
145
+ ) {
146
+ $phpcsFile->fixer->replaceToken(($stackPtr + 2), '('.$tokens[($stackPtr + 2)]['content'].')');
147
+ }
148
+
149
+ $phpcsFile->fixer->endChangeset();
150
  } else if ($this->spacing > 0) {
151
  $phpcsFile->fixer->addContent($stackPtr, $padding);
152
  }
153
  }
154
+ }//end if
155
 
156
  }//end process()
157
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php CHANGED
@@ -69,7 +69,9 @@ class Squiz_Sniffs_Strings_DoubleQuoteUsageSniff implements PHP_CodeSniffer_Snif
69
 
70
  $i = ($stackPtr + 1);
71
  if (isset($tokens[$i]) === true) {
72
- while ($tokens[$i]['code'] === $tokens[$stackPtr]['code']) {
 
 
73
  $workingString .= $tokens[$i]['content'];
74
  $lastStringToken = $i;
75
  $i++;
@@ -129,7 +131,7 @@ class Squiz_Sniffs_Strings_DoubleQuoteUsageSniff implements PHP_CodeSniffer_Snif
129
  }
130
 
131
  $error = 'String %s does not require double quotes; use single quotes instead';
132
- $data = array(str_replace("\n", '\n', $workingString));
133
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotRequired', $data);
134
 
135
  if ($fix === true) {
69
 
70
  $i = ($stackPtr + 1);
71
  if (isset($tokens[$i]) === true) {
72
+ while ($i < $phpcsFile->numTokens
73
+ && $tokens[$i]['code'] === $tokens[$stackPtr]['code']
74
+ ) {
75
  $workingString .= $tokens[$i]['content'];
76
  $lastStringToken = $i;
77
  $i++;
131
  }
132
 
133
  $error = 'String %s does not require double quotes; use single quotes instead';
134
+ $data = array(str_replace(array("\r", "\n"), array('\r', '\n'), $workingString));
135
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotRequired', $data);
136
 
137
  if ($fix === true) {
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php CHANGED
@@ -88,7 +88,11 @@ class Squiz_Sniffs_Strings_EchoedStringsSniff implements PHP_CodeSniffer_Sniff
88
  if ($fix === true) {
89
  $phpcsFile->fixer->beginChangeset();
90
  $phpcsFile->fixer->replaceToken($firstContent, '');
91
- $phpcsFile->fixer->replaceToken(($end - 1), '');
 
 
 
 
92
  $phpcsFile->fixer->endChangeset();
93
  }
94
  }
88
  if ($fix === true) {
89
  $phpcsFile->fixer->beginChangeset();
90
  $phpcsFile->fixer->replaceToken($firstContent, '');
91
+ if ($tokens[($firstContent - 1)]['code'] !== T_WHITESPACE) {
92
+ $phpcsFile->fixer->addContent(($firstContent - 1), ' ');
93
+ }
94
+
95
+ $phpcsFile->fixer->replaceToken($prev, '');
96
  $phpcsFile->fixer->endChangeset();
97
  }
98
  }
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php CHANGED
@@ -82,7 +82,7 @@ class Squiz_Sniffs_WhiteSpace_LanguageConstructSpacingSniff implements PHP_CodeS
82
  $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
83
  }
84
  }
85
- } else {
86
  $error = 'Language constructs must be followed by a single space; expected "%s" but found "%s"';
87
  $data = array(
88
  $tokens[$stackPtr]['content'].' '.$tokens[($stackPtr + 1)]['content'],
82
  $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
83
  }
84
  }
85
+ } else if ($tokens[($stackPtr + 1)]['code'] !== T_OPEN_PARENTHESIS) {
86
  $error = 'Language constructs must be followed by a single space; expected "%s" but found "%s"';
87
  $data = array(
88
  $tokens[$stackPtr]['content'].' '.$tokens[($stackPtr + 1)]['content'],
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php CHANGED
@@ -30,6 +30,13 @@
30
  class Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff implements PHP_CodeSniffer_Sniff
31
  {
32
 
 
 
 
 
 
 
 
33
 
34
  /**
35
  * Returns an array of tokens this test wants to listen for.
@@ -78,23 +85,70 @@ class Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff implements PHP_CodeSnif
78
  $phpcsFile->recordMetric($stackPtr, 'Spacing before object operator', $before);
79
  $phpcsFile->recordMetric($stackPtr, 'Spacing after object operator', $after);
80
 
81
- if ($before !== 0) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  $error = 'Space found before object operator';
83
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Before');
84
  if ($fix === true) {
85
  $phpcsFile->fixer->replaceToken(($stackPtr - 1), '');
86
  }
 
 
87
  }
88
 
89
- if ($after !== 0) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  $error = 'Space found after object operator';
91
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'After');
92
  if ($fix === true) {
93
  $phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
94
  }
 
 
95
  }
96
 
97
- }//end process()
 
 
98
 
99
 
100
  }//end class
30
  class Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff implements PHP_CodeSniffer_Sniff
31
  {
32
 
33
+ /**
34
+ * Allow newlines instead of spaces.
35
+ *
36
+ * @var boolean
37
+ */
38
+ public $ignoreNewlines = false;
39
+
40
 
41
  /**
42
  * Returns an array of tokens this test wants to listen for.
85
  $phpcsFile->recordMetric($stackPtr, 'Spacing before object operator', $before);
86
  $phpcsFile->recordMetric($stackPtr, 'Spacing after object operator', $after);
87
 
88
+ $this->checkSpacingBeforeOperator($phpcsFile, $stackPtr, $before);
89
+ $this->checkSpacingAfterOperator($phpcsFile, $stackPtr, $after);
90
+
91
+ }//end process()
92
+
93
+
94
+ /**
95
+ * Check the spacing before the operator.
96
+ *
97
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
98
+ * @param int $stackPtr The position of the current token
99
+ * in the stack passed in $tokens.
100
+ * @param mixed $before The number of spaces found before the
101
+ * operator or the string 'newline'.
102
+ *
103
+ * @return boolean true if there was no error, false otherwise.
104
+ */
105
+ protected function checkSpacingBeforeOperator(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $before)
106
+ {
107
+ if ($before !== 0
108
+ && ($before !== 'newline' || $this->ignoreNewlines === false)
109
+ ) {
110
  $error = 'Space found before object operator';
111
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Before');
112
  if ($fix === true) {
113
  $phpcsFile->fixer->replaceToken(($stackPtr - 1), '');
114
  }
115
+
116
+ return false;
117
  }
118
 
119
+ return true;
120
+
121
+ }//end checkSpacingBeforeOperator()
122
+
123
+
124
+ /**
125
+ * Check the spacing after the operator.
126
+ *
127
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
128
+ * @param int $stackPtr The position of the current token
129
+ * in the stack passed in $tokens.
130
+ * @param mixed $after The number of spaces found after the
131
+ * operator or the string 'newline'.
132
+ *
133
+ * @return boolean true if there was no error, false otherwise.
134
+ */
135
+ protected function checkSpacingAfterOperator(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $after)
136
+ {
137
+ if ($after !== 0
138
+ && ($after !== 'newline' || $this->ignoreNewlines === false)
139
+ ) {
140
  $error = 'Space found after object operator';
141
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'After');
142
  if ($fix === true) {
143
  $phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
144
  }
145
+
146
+ return false;
147
  }
148
 
149
+ return true;
150
+
151
+ }//end checkSpacingAfterOperator()
152
 
153
 
154
  }//end class
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php CHANGED
@@ -88,10 +88,15 @@ class Squiz_Sniffs_WhiteSpace_SemicolonSpacingSniff implements PHP_CodeSniffer_S
88
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Incorrect', $data);
89
  if ($fix === true) {
90
  $phpcsFile->fixer->beginChangeset();
91
- for ($i = ($stackPtr - 1); $i > $nonSpace; $i--) {
 
92
  $phpcsFile->fixer->replaceToken($i, '');
 
93
  }
94
 
 
 
 
95
  $phpcsFile->fixer->endChangeset();
96
  }
97
 
88
  $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Incorrect', $data);
89
  if ($fix === true) {
90
  $phpcsFile->fixer->beginChangeset();
91
+ $i = ($stackPtr - 1);
92
+ while (($tokens[$i]['code'] === T_WHITESPACE) && ($i > $nonSpace)) {
93
  $phpcsFile->fixer->replaceToken($i, '');
94
+ $i--;
95
  }
96
 
97
+ $phpcsFile->fixer->addContent($nonSpace, ';');
98
+ $phpcsFile->fixer->replaceToken($stackPtr, '');
99
+
100
  $phpcsFile->fixer->endChangeset();
101
  }
102
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php CHANGED
@@ -16,7 +16,7 @@
16
  /**
17
  * Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff.
18
  *
19
- * Checks that no whitespace proceeds the first content of the file, exists
20
  * after the last content of the file, resides after content on any line, or
21
  * are two empty lines in functions.
22
  *
16
  /**
17
  * Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff.
18
  *
19
+ * Checks that no whitespace preceeds the first content of the file, exists
20
  * after the last content of the file, resides after content on any line, or
21
  * are two empty lines in functions.
22
  *
vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php CHANGED
@@ -63,7 +63,7 @@ class Zend_Sniffs_Debug_CodeAnalyzerSniff implements PHP_CodeSniffer_Sniff
63
  // In the command, 2>&1 is important because the code analyzer sends its
64
  // findings to stderr. $output normally contains only stdout, so using 2>&1
65
  // will pipe even stderr to stdout.
66
- $cmd = $analyzerPath.' '.$fileName.' 2>&1';
67
 
68
  // There is the possibility to pass "--ide" as an option to the analyzer.
69
  // This would result in an output format which would be easier to parse.
63
  // In the command, 2>&1 is important because the code analyzer sends its
64
  // findings to stderr. $output normally contains only stdout, so using 2>&1
65
  // will pipe even stderr to stdout.
66
+ $cmd = escapeshellcmd($analyzerPath).' '.escapeshellarg($fileName).' 2>&1';
67
 
68
  // There is the possibility to pass "--ide" as an option to the analyzer.
69
  // This would result in an output format which would be easier to parse.
vendor/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/CSS.php CHANGED
@@ -89,6 +89,7 @@ class PHP_CodeSniffer_Tokenizers_CSS extends PHP_CodeSniffer_Tokenizers_PHP
89
  || $token['code'] === T_FOR
90
  || $token['code'] === T_FOREACH
91
  || $token['code'] === T_WHILE
 
92
  ) {
93
  $token['type'] = 'T_STRING';
94
  $token['code'] = T_STRING;
@@ -445,6 +446,30 @@ class PHP_CodeSniffer_Tokenizers_CSS extends PHP_CodeSniffer_Tokenizers_PHP
445
  echo "\t\t=> token content changed to: $content".PHP_EOL;
446
  }
447
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
448
  }//end if
449
 
450
  break;
89
  || $token['code'] === T_FOR
90
  || $token['code'] === T_FOREACH
91
  || $token['code'] === T_WHILE
92
+ || $token['code'] === T_DEC
93
  ) {
94
  $token['type'] = 'T_STRING';
95
  $token['code'] = T_STRING;
446
  echo "\t\t=> token content changed to: $content".PHP_EOL;
447
  }
448
  }
449
+ } else if ($finalTokens[$stackPtr]['content'][0] === '-'
450
+ && $finalTokens[($stackPtr + 1)]['code'] === T_STRING
451
+ ) {
452
+ if (isset($finalTokens[($stackPtr - 1)]) === true
453
+ && $finalTokens[($stackPtr - 1)]['code'] === T_STRING
454
+ ) {
455
+ $newContent = $finalTokens[($stackPtr - 1)]['content'].$finalTokens[$stackPtr]['content'].$finalTokens[($stackPtr + 1)]['content'];
456
+
457
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
458
+ echo "\t\t* token is a string joiner; ignoring this and previous token".PHP_EOL;
459
+ $old = PHP_CodeSniffer::prepareForOutput($finalTokens[($stackPtr + 1)]['content']);
460
+ $new = PHP_CodeSniffer::prepareForOutput($newContent);
461
+ echo "\t\t=> token ".($stackPtr + 1)." content changed from \"$old\" to \"$new\"".PHP_EOL;
462
+ }
463
+
464
+ $finalTokens[($stackPtr + 1)]['content'] = $newContent;
465
+ unset($finalTokens[$stackPtr]);
466
+ unset($finalTokens[($stackPtr - 1)]);
467
+ } else {
468
+ $newContent = $finalTokens[$stackPtr]['content'].$finalTokens[($stackPtr + 1)]['content'];
469
+
470
+ $finalTokens[($stackPtr + 1)]['content'] = $newContent;
471
+ unset($finalTokens[$stackPtr]);
472
+ }
473
  }//end if
474
 
475
  break;
vendor/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/Comment.php CHANGED
@@ -85,6 +85,10 @@ class PHP_CodeSniffer_Tokenizers_Comment
85
  'comment_opener' => $openPtr,
86
  );
87
 
 
 
 
 
88
  $string = rtrim($string, '/*');
89
 
90
  /*
85
  'comment_opener' => $openPtr,
86
  );
87
 
88
+ if ($closeTag['content'] === false) {
89
+ $closeTag['content'] = '';
90
+ }
91
+
92
  $string = rtrim($string, '/*');
93
 
94
  /*
vendor/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/JS.php CHANGED
@@ -202,8 +202,15 @@ class PHP_CodeSniffer_Tokenizers_JS
202
  ':' => 'T_COLON',
203
  '<' => 'T_LESS_THAN',
204
  '>' => 'T_GREATER_THAN',
 
 
 
 
 
 
205
  '<=' => 'T_IS_SMALLER_OR_EQUAL',
206
  '>=' => 'T_IS_GREATER_OR_EQUAL',
 
207
  '!' => 'T_BOOLEAN_NOT',
208
  '||' => 'T_BOOLEAN_OR',
209
  '&&' => 'T_BOOLEAN_AND',
@@ -250,10 +257,7 @@ class PHP_CodeSniffer_Tokenizers_JS
250
 
251
 
252
  /**
253
- * Creates an array of tokens when given some PHP code.
254
- *
255
- * Starts by using token_get_all() but does a lot of extra processing
256
- * to insert information about the context of the token.
257
  *
258
  * @param string $string The string to tokenize.
259
  * @param string $eolChar The EOL character to use for splitting strings.
@@ -519,7 +523,14 @@ class PHP_CodeSniffer_Tokenizers_JS
519
  echo "\t\t* look ahead found nothing *".PHP_EOL;
520
  }
521
 
522
- $value = $this->tokenValues[strtolower($buffer)];
 
 
 
 
 
 
 
523
  $tokens[] = array(
524
  'code' => constant($value),
525
  'type' => $value,
@@ -723,7 +734,12 @@ class PHP_CodeSniffer_Tokenizers_JS
723
  if ($token['code'] === T_COMMENT || $token['code'] === T_DOC_COMMENT) {
724
  $newContent = '';
725
  $tokenContent = $token['content'];
726
- $endContent = $this->commentTokens[$tokenContent];
 
 
 
 
 
727
  while ($tokenContent !== $endContent) {
728
  if ($endContent === null
729
  && strpos($tokenContent, $eolChar) !== false
@@ -881,6 +897,9 @@ class PHP_CodeSniffer_Tokenizers_JS
881
  {
882
  $beforeTokens = array(
883
  T_EQUAL => true,
 
 
 
884
  T_OPEN_PARENTHESIS => true,
885
  T_OPEN_SQUARE_BRACKET => true,
886
  T_RETURN => true,
@@ -1065,6 +1084,7 @@ class PHP_CodeSniffer_Tokenizers_JS
1065
  continue;
1066
  } else if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET
1067
  && isset($tokens[$i]['scope_condition']) === false
 
1068
  ) {
1069
  $classStack[] = $i;
1070
 
202
  ':' => 'T_COLON',
203
  '<' => 'T_LESS_THAN',
204
  '>' => 'T_GREATER_THAN',
205
+ '<<' => 'T_SL',
206
+ '>>' => 'T_SR',
207
+ '>>>' => 'T_ZSR',
208
+ '<<=' => 'T_SL_EQUAL',
209
+ '>>=' => 'T_SR_EQUAL',
210
+ '>>>=' => 'T_ZSR_EQUAL',
211
  '<=' => 'T_IS_SMALLER_OR_EQUAL',
212
  '>=' => 'T_IS_GREATER_OR_EQUAL',
213
+ '=>' => 'T_DOUBLE_ARROW',
214
  '!' => 'T_BOOLEAN_NOT',
215
  '||' => 'T_BOOLEAN_OR',
216
  '&&' => 'T_BOOLEAN_AND',
257
 
258
 
259
  /**
260
+ * Creates an array of tokens when given some JS code.
 
 
 
261
  *
262
  * @param string $string The string to tokenize.
263
  * @param string $eolChar The EOL character to use for splitting strings.
523
  echo "\t\t* look ahead found nothing *".PHP_EOL;
524
  }
525
 
526
+ $value = $this->tokenValues[strtolower($buffer)];
527
+
528
+ if ($value === 'T_FUNCTION' && $buffer !== 'function') {
529
+ // The function keyword needs to be all lowercase or else
530
+ // it is just a function called "Function".
531
+ $value = 'T_STRING';
532
+ }
533
+
534
  $tokens[] = array(
535
  'code' => constant($value),
536
  'type' => $value,
734
  if ($token['code'] === T_COMMENT || $token['code'] === T_DOC_COMMENT) {
735
  $newContent = '';
736
  $tokenContent = $token['content'];
737
+
738
+ $endContent = null;
739
+ if (isset($this->commentTokens[$tokenContent]) === true) {
740
+ $endContent = $this->commentTokens[$tokenContent];
741
+ }
742
+
743
  while ($tokenContent !== $endContent) {
744
  if ($endContent === null
745
  && strpos($tokenContent, $eolChar) !== false
897
  {
898
  $beforeTokens = array(
899
  T_EQUAL => true,
900
+ T_IS_NOT_EQUAL => true,
901
+ T_IS_IDENTICAL => true,
902
+ T_IS_NOT_IDENTICAL => true,
903
  T_OPEN_PARENTHESIS => true,
904
  T_OPEN_SQUARE_BRACKET => true,
905
  T_RETURN => true,
1084
  continue;
1085
  } else if ($tokens[$i]['code'] === T_OPEN_CURLY_BRACKET
1086
  && isset($tokens[$i]['scope_condition']) === false
1087
+ && isset($tokens[$i]['bracket_closer']) === true
1088
  ) {
1089
  $classStack[] = $i;
1090
 
vendor/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/PHP.php CHANGED
@@ -656,6 +656,42 @@ class PHP_CodeSniffer_Tokenizers_PHP
656
  continue;
657
  }
658
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
659
  /*
660
  Before PHP 7, the ?? operator was tokenized as
661
  T_INLINE_THEN followed by T_INLINE_THEN.
@@ -678,6 +714,86 @@ class PHP_CodeSniffer_Tokenizers_PHP
678
  continue;
679
  }
680
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
681
  /*
682
  Before PHP 7, the <=> operator was tokenized as
683
  T_IS_SMALLER_OR_EQUAL followed by T_GREATER_THAN.
@@ -708,6 +824,7 @@ class PHP_CodeSniffer_Tokenizers_PHP
708
  && $token[0] === T_STRING
709
  && strtolower($token[1]) === 'trait'
710
  && $tokens[($stackPtr - 1)][0] !== T_OBJECT_OPERATOR
 
711
  ) {
712
  $finalTokens[$newStackPtr] = array(
713
  'content' => $token[1],
@@ -875,14 +992,27 @@ class PHP_CodeSniffer_Tokenizers_PHP
875
  T_PAAMAYIM_NEKUDOTAYIM => true,
876
  );
877
  if (isset($context[$finalTokens[$lastNotEmptyToken]['code']]) === true) {
878
- $finalTokens[$newStackPtr] = array(
879
- 'content' => $token[1],
880
- 'code' => T_STRING,
881
- 'type' => 'T_STRING',
882
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
883
  $newStackPtr++;
884
  continue;
885
- }
886
  }//end if
887
 
888
  $newToken = null;
@@ -910,9 +1040,7 @@ class PHP_CodeSniffer_Tokenizers_PHP
910
 
911
  // Convert colons that are actually the ELSE component of an
912
  // inline IF statement.
913
- if ($newToken['code'] === T_INLINE_THEN) {
914
- $insideInlineIf[] = $stackPtr;
915
- } else if (empty($insideInlineIf) === false && $newToken['code'] === T_COLON) {
916
  array_pop($insideInlineIf);
917
  $newToken['code'] = T_INLINE_ELSE;
918
  $newToken['type'] = 'T_INLINE_ELSE';
@@ -923,7 +1051,6 @@ class PHP_CodeSniffer_Tokenizers_PHP
923
  // the parenthesis map clean, so let's tag these tokens as
924
  // T_ARRAY_HINT.
925
  if ($newToken['code'] === T_ARRAY) {
926
- // Recalculate number of tokens.
927
  for ($i = $stackPtr; $i < $numTokens; $i++) {
928
  if ($tokens[$i] === '(') {
929
  break;
@@ -946,7 +1073,8 @@ class PHP_CodeSniffer_Tokenizers_PHP
946
 
947
  // This is a special case for the PHP 5.5 classname::class syntax
948
  // where "class" should be T_STRING instead of T_CLASS.
949
- if ($newToken['code'] === T_CLASS
 
950
  && $finalTokens[($newStackPtr - 1)]['code'] === T_DOUBLE_COLON
951
  ) {
952
  $newToken['code'] = T_STRING;
@@ -1026,31 +1154,6 @@ class PHP_CodeSniffer_Tokenizers_PHP
1026
  }
1027
 
1028
  if ($tokens[$i]['code'] === T_FUNCTION) {
1029
- // Context sensitive keywords support.
1030
- for ($x = ($i + 1); $x < $numTokens; $x++) {
1031
- if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) {
1032
- // Non-whitespace content.
1033
- break;
1034
- }
1035
- }
1036
-
1037
- if ($x === $numTokens) {
1038
- // We got to the end without finding any more
1039
- // non-whitespace content.
1040
- continue;
1041
- }
1042
-
1043
- if (in_array($tokens[$x]['code'], array(T_STRING, T_OPEN_PARENTHESIS, T_BITWISE_AND), true) === false) {
1044
- if (PHP_CODESNIFFER_VERBOSITY > 1) {
1045
- $line = $tokens[$x]['line'];
1046
- $type = $tokens[$x]['type'];
1047
- echo "\t* token $x on line $line changed from $type to T_STRING".PHP_EOL;
1048
- }
1049
-
1050
- $tokens[$x]['code'] = T_STRING;
1051
- $tokens[$x]['type'] = 'T_STRING';
1052
- }
1053
-
1054
  /*
1055
  Detect functions that are actually closures and
1056
  assign them a different token.
@@ -1112,7 +1215,7 @@ class PHP_CodeSniffer_Tokenizers_PHP
1112
 
1113
  for ($x = ($tokenAfterReturnTypeHint - 1); $x > $i; $x--) {
1114
  if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) {
1115
- if (in_array($tokens[$x]['code'], array(T_STRING, T_ARRAY, T_CALLABLE, T_SELF, T_PARENT), true) === true) {
1116
  if (PHP_CODESNIFFER_VERBOSITY > 1) {
1117
  $line = $tokens[$x]['line'];
1118
  $type = $tokens[$x]['type'];
@@ -1166,25 +1269,47 @@ class PHP_CodeSniffer_Tokenizers_PHP
1166
 
1167
  continue;
1168
  } else if ($tokens[$i]['code'] === T_OPEN_SQUARE_BRACKET) {
 
 
 
 
1169
  // Unless there is a variable or a bracket before this token,
1170
  // it is the start of an array being defined using the short syntax.
 
 
 
 
 
 
 
 
 
1171
  for ($x = ($i - 1); $x > 0; $x--) {
1172
- if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) {
 
 
 
 
1173
  break;
1174
  }
1175
- }
1176
 
1177
- $allowed = array(
1178
- T_CLOSE_CURLY_BRACKET => T_CLOSE_CURLY_BRACKET,
1179
- T_CLOSE_SQUARE_BRACKET => T_CLOSE_SQUARE_BRACKET,
1180
- T_CLOSE_PARENTHESIS => T_CLOSE_PARENTHESIS,
1181
- T_VARIABLE => T_VARIABLE,
1182
- T_STRING => T_STRING,
1183
- );
1184
 
1185
- if (isset($allowed[$tokens[$x]['code']]) === false
1186
- && isset($tokens[$i]['bracket_closer']) === true
1187
- ) {
 
 
 
 
 
 
 
1188
  $tokens[$i]['code'] = T_OPEN_SHORT_ARRAY;
1189
  $tokens[$i]['type'] = 'T_OPEN_SHORT_ARRAY';
1190
 
@@ -1269,25 +1394,6 @@ class PHP_CodeSniffer_Tokenizers_PHP
1269
  echo "\t* token $x on line $line changed from $type to T_STRING".PHP_EOL;
1270
  }
1271
 
1272
- $tokens[$x]['code'] = T_STRING;
1273
- $tokens[$x]['type'] = 'T_STRING';
1274
- }
1275
- } else if ($tokens[$i]['code'] === T_PAAMAYIM_NEKUDOTAYIM) {
1276
- // Context sensitive keywords support.
1277
- for ($x = ($i + 1); $i < $numTokens; $x++) {
1278
- if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) {
1279
- // Non-whitespace content.
1280
- break;
1281
- }
1282
- }
1283
-
1284
- if (in_array($tokens[$x]['code'], array(T_STRING, T_VARIABLE, T_DOLLAR), true) === false) {
1285
- if (PHP_CODESNIFFER_VERBOSITY > 1) {
1286
- $line = $tokens[$x]['line'];
1287
- $type = $tokens[$x]['type'];
1288
- echo "\t* token $x on line $line changed from $type to T_STRING".PHP_EOL;
1289
- }
1290
-
1291
  $tokens[$x]['code'] = T_STRING;
1292
  $tokens[$x]['type'] = 'T_STRING';
1293
  }
@@ -1533,9 +1639,6 @@ class PHP_CodeSniffer_Tokenizers_PHP
1533
  case '.':
1534
  $newToken['type'] = 'T_STRING_CONCAT';
1535
  break;
1536
- case '?':
1537
- $newToken['type'] = 'T_INLINE_THEN';
1538
- break;
1539
  case ';':
1540
  $newToken['type'] = 'T_SEMICOLON';
1541
  break;
656
  continue;
657
  }
658
 
659
+ /*
660
+ Before PHP 7, the ??= operator was tokenized as
661
+ T_INLINE_THEN, T_INLINE_THEN, T_EQUAL.
662
+ Between PHP 7.0 and 7.2, the ??= operator was tokenized as
663
+ T_COALESCE, T_EQUAL.
664
+ So look for and combine these tokens in earlier versions.
665
+ */
666
+
667
+ if (($tokenIsArray === false
668
+ && $token[0] === '?'
669
+ && isset($tokens[($stackPtr + 1)]) === true
670
+ && $tokens[($stackPtr + 1)][0] === '?'
671
+ && isset($tokens[($stackPtr + 2)]) === true
672
+ && $tokens[($stackPtr + 2)][0] === '=')
673
+ || ($tokenIsArray === true
674
+ && $token[0] === T_COALESCE
675
+ && isset($tokens[($stackPtr + 1)]) === true
676
+ && $tokens[($stackPtr + 1)][0] === '=')
677
+ ) {
678
+ $newToken = array();
679
+ $newToken['code'] = T_COALESCE_EQUAL;
680
+ $newToken['type'] = 'T_COALESCE_EQUAL';
681
+ $newToken['content'] = '??=';
682
+ $finalTokens[$newStackPtr] = $newToken;
683
+
684
+ $newStackPtr++;
685
+ $stackPtr++;
686
+
687
+ if ($tokenIsArray === false) {
688
+ // Pre PHP 7.
689
+ $stackPtr++;
690
+ }
691
+
692
+ continue;
693
+ }
694
+
695
  /*
696
  Before PHP 7, the ?? operator was tokenized as
697
  T_INLINE_THEN followed by T_INLINE_THEN.
714
  continue;
715
  }
716
 
717
+ /*
718
+ Convert ? to T_NULLABLE OR T_INLINE_THEN
719
+ */
720
+
721
+ if ($tokenIsArray === false && $token[0] === '?') {
722
+ $newToken = array();
723
+ $newToken['content'] = '?';
724
+
725
+ for ($i = ($stackPtr - 1); $i >= 0; $i--) {
726
+ if (is_array($tokens[$i]) === true) {
727
+ $tokenType = $tokens[$i][0];
728
+ } else {
729
+ $tokenType = $tokens[$i];
730
+ }
731
+
732
+ if ($tokenType === T_FUNCTION) {
733
+ $newToken['code'] = T_NULLABLE;
734
+ $newToken['type'] = 'T_NULLABLE';
735
+ break;
736
+ } else if (in_array($tokenType, array(T_OPEN_TAG, T_OPEN_TAG_WITH_ECHO, '{', ';')) === true) {
737
+ $newToken['code'] = T_INLINE_THEN;
738
+ $newToken['type'] = 'T_INLINE_THEN';
739
+
740
+ $insideInlineIf[] = $stackPtr;
741
+ break;
742
+ }
743
+ }
744
+
745
+ $finalTokens[$newStackPtr] = $newToken;
746
+ $newStackPtr++;
747
+ continue;
748
+ }//end if
749
+
750
+ /*
751
+ Tokens after a double colon may be look like scope openers,
752
+ such as when writing code like Foo::NAMESPACE, but they are
753
+ only ever variables or strings.
754
+ */
755
+
756
+ if ($stackPtr > 1
757
+ && (is_array($tokens[($stackPtr - 1)]) === true
758
+ && $tokens[($stackPtr - 1)][0] === T_PAAMAYIM_NEKUDOTAYIM)
759
+ && $tokenIsArray === true
760
+ && $token[0] !== T_STRING
761
+ && $token[0] !== T_VARIABLE
762
+ && $token[0] !== T_DOLLAR
763
+ && isset(PHP_CodeSniffer_Tokens::$emptyTokens[$token[0]]) === false
764
+ ) {
765
+ $newToken = array();
766
+ $newToken['code'] = T_STRING;
767
+ $newToken['type'] = 'T_STRING';
768
+ $newToken['content'] = $token[1];
769
+ $finalTokens[$newStackPtr] = $newToken;
770
+
771
+ $newStackPtr++;
772
+ continue;
773
+ }
774
+
775
+ /*
776
+ The string-like token after a function keyword should always be
777
+ tokenized as T_STRING even if it appears to be a different token,
778
+ such as when writing code like: function default(): foo
779
+ so go forward and change the token type before it is processed.
780
+ */
781
+
782
+ if ($tokenIsArray === true && $token[0] === T_FUNCTION) {
783
+ for ($x = ($stackPtr + 1); $x < $numTokens; $x++) {
784
+ if (is_array($tokens[$x]) === false
785
+ || isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x][0]]) === false
786
+ ) {
787
+ // Non-empty content.
788
+ break;
789
+ }
790
+ }
791
+
792
+ if ($x < $numTokens && is_array($tokens[$x]) === true) {
793
+ $tokens[$x][0] = T_STRING;
794
+ }
795
+ }
796
+
797
  /*
798
  Before PHP 7, the <=> operator was tokenized as
799
  T_IS_SMALLER_OR_EQUAL followed by T_GREATER_THAN.
824
  && $token[0] === T_STRING
825
  && strtolower($token[1]) === 'trait'
826
  && $tokens[($stackPtr - 1)][0] !== T_OBJECT_OPERATOR
827
+ && $tokens[($stackPtr - 1)][0] !== T_PAAMAYIM_NEKUDOTAYIM
828
  ) {
829
  $finalTokens[$newStackPtr] = array(
830
  'content' => $token[1],
992
  T_PAAMAYIM_NEKUDOTAYIM => true,
993
  );
994
  if (isset($context[$finalTokens[$lastNotEmptyToken]['code']]) === true) {
995
+ // Special case for syntax like: return new self
996
+ // where self should not be a string.
997
+ if ($finalTokens[$lastNotEmptyToken]['code'] === T_NEW
998
+ && strtolower($token[1]) === 'self'
999
+ ) {
1000
+ $finalTokens[$newStackPtr] = array(
1001
+ 'content' => $token[1],
1002
+ 'code' => T_SELF,
1003
+ 'type' => 'T_SELF',
1004
+ );
1005
+ } else {
1006
+ $finalTokens[$newStackPtr] = array(
1007
+ 'content' => $token[1],
1008
+ 'code' => T_STRING,
1009
+ 'type' => 'T_STRING',
1010
+ );
1011
+ }
1012
+
1013
  $newStackPtr++;
1014
  continue;
1015
+ }//end if
1016
  }//end if
1017
 
1018
  $newToken = null;
1040
 
1041
  // Convert colons that are actually the ELSE component of an
1042
  // inline IF statement.
1043
+ if (empty($insideInlineIf) === false && $newToken['code'] === T_COLON) {
 
 
1044
  array_pop($insideInlineIf);
1045
  $newToken['code'] = T_INLINE_ELSE;
1046
  $newToken['type'] = 'T_INLINE_ELSE';
1051
  // the parenthesis map clean, so let's tag these tokens as
1052
  // T_ARRAY_HINT.
1053
  if ($newToken['code'] === T_ARRAY) {
 
1054
  for ($i = $stackPtr; $i < $numTokens; $i++) {
1055
  if ($tokens[$i] === '(') {
1056
  break;
1073
 
1074
  // This is a special case for the PHP 5.5 classname::class syntax
1075
  // where "class" should be T_STRING instead of T_CLASS.
1076
+ if (($newToken['code'] === T_CLASS
1077
+ || $newToken['code'] === T_FUNCTION)
1078
  && $finalTokens[($newStackPtr - 1)]['code'] === T_DOUBLE_COLON
1079
  ) {
1080
  $newToken['code'] = T_STRING;
1154
  }
1155
 
1156
  if ($tokens[$i]['code'] === T_FUNCTION) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1157
  /*
1158
  Detect functions that are actually closures and
1159
  assign them a different token.
1215
 
1216
  for ($x = ($tokenAfterReturnTypeHint - 1); $x > $i; $x--) {
1217
  if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) {
1218
+ if (in_array($tokens[$x]['code'], array(T_STRING, T_ARRAY, T_ARRAY_HINT, T_CALLABLE, T_SELF, T_PARENT), true) === true) {
1219
  if (PHP_CODESNIFFER_VERBOSITY > 1) {
1220
  $line = $tokens[$x]['line'];
1221
  $type = $tokens[$x]['type'];
1269
 
1270
  continue;
1271
  } else if ($tokens[$i]['code'] === T_OPEN_SQUARE_BRACKET) {
1272
+ if (isset($tokens[$i]['bracket_closer']) === false) {
1273
+ continue;
1274
+ }
1275
+
1276
  // Unless there is a variable or a bracket before this token,
1277
  // it is the start of an array being defined using the short syntax.
1278
+ $isShortArray = false;
1279
+ $allowed = array(
1280
+ T_CLOSE_SQUARE_BRACKET => T_CLOSE_SQUARE_BRACKET,
1281
+ T_CLOSE_PARENTHESIS => T_CLOSE_PARENTHESIS,
1282
+ T_VARIABLE => T_VARIABLE,
1283
+ T_OBJECT_OPERATOR => T_OBJECT_OPERATOR,
1284
+ T_STRING => T_STRING,
1285
+ );
1286
+
1287
  for ($x = ($i - 1); $x > 0; $x--) {
1288
+ // If we hit a scope opener, the statement has ended
1289
+ // without finding anything, so it's probably an array
1290
+ // using PHP 7.1 short list syntax.
1291
+ if (isset($tokens[$x]['scope_opener']) === true) {
1292
+ $isShortArray = true;
1293
  break;
1294
  }
 
1295
 
1296
+ if (isset($tokens[$x]['bracket_opener']) === true
1297
+ && $x > $tokens[$x]['bracket_opener']
1298
+ ) {
1299
+ $x = $tokens[$x]['bracket_opener'];
1300
+ continue;
1301
+ }
 
1302
 
1303
+ if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === false) {
1304
+ if (isset($allowed[$tokens[$x]['code']]) === false) {
1305
+ $isShortArray = true;
1306
+ }
1307
+
1308
+ break;
1309
+ }
1310
+ }//end for
1311
+
1312
+ if ($isShortArray === true) {
1313
  $tokens[$i]['code'] = T_OPEN_SHORT_ARRAY;
1314
  $tokens[$i]['type'] = 'T_OPEN_SHORT_ARRAY';
1315
 
1394
  echo "\t* token $x on line $line changed from $type to T_STRING".PHP_EOL;
1395
  }
1396
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1397
  $tokens[$x]['code'] = T_STRING;
1398
  $tokens[$x]['type'] = 'T_STRING';
1399
  }
1639
  case '.':
1640
  $newToken['type'] = 'T_STRING_CONCAT';
1641
  break;
 
 
 
1642
  case ';':
1643
  $newToken['type'] = 'T_SEMICOLON';
1644
  break;
vendor/squizlabs/php_codesniffer/CodeSniffer/Tokens.php CHANGED
@@ -22,6 +22,7 @@ define('T_CLOSE_SQUARE_BRACKET', 'PHPCS_T_CLOSE_SQUARE_BRACKET');
22
  define('T_OPEN_PARENTHESIS', 'PHPCS_T_OPEN_PARENTHESIS');
23
  define('T_CLOSE_PARENTHESIS', 'PHPCS_T_CLOSE_PARENTHESIS');
24
  define('T_COLON', 'PHPCS_T_COLON');
 
25
  define('T_STRING_CONCAT', 'PHPCS_T_STRING_CONCAT');
26
  define('T_INLINE_THEN', 'PHPCS_T_INLINE_THEN');
27
  define('T_INLINE_ELSE', 'PHPCS_T_INLINE_ELSE');
@@ -75,6 +76,8 @@ define('T_EMBEDDED_PHP', 'PHPCS_T_EMBEDDED_PHP');
75
  define('T_RETURN_TYPE', 'PHPCS_T_RETURN_TYPE');
76
  define('T_OPEN_USE_GROUP', 'PHPCS_T_OPEN_USE_GROUP');
77
  define('T_CLOSE_USE_GROUP', 'PHPCS_T_CLOSE_USE_GROUP');
 
 
78
 
79
  // Some PHP 5.3 tokens, replicated for lower versions.
80
  if (defined('T_NAMESPACE') === false) {
@@ -145,6 +148,10 @@ if (defined('T_COALESCE') === false) {
145
  define('T_COALESCE', 'PHPCS_T_COALESCE');
146
  }
147
 
 
 
 
 
148
  // Tokens used for parsing doc blocks.
149
  define('T_DOC_COMMENT_STAR', 'PHPCS_T_DOC_COMMENT_STAR');
150
  define('T_DOC_COMMENT_WHITESPACE', 'PHPCS_T_DOC_COMMENT_WHITESPACE');
@@ -220,6 +227,7 @@ final class PHP_CodeSniffer_Tokens
220
  T_POW => 5,
221
  T_SPACESHIP => 5,
222
  T_COALESCE => 5,
 
223
 
224
  T_SL => 5,
225
  T_SR => 5,
@@ -365,6 +373,7 @@ final class PHP_CodeSniffer_Tokens
365
  T_OPEN_PARENTHESIS => 1,
366
  T_CLOSE_PARENTHESIS => 1,
367
  T_COLON => 1,
 
368
  T_STRING_CONCAT => 1,
369
  T_INLINE_THEN => 1,
370
  T_INLINE_ELSE => 1,
@@ -381,6 +390,7 @@ final class PHP_CodeSniffer_Tokens
381
  T_POW => 2,
382
  T_SPACESHIP => 3,
383
  T_COALESCE => 2,
 
384
  T_BITWISE_AND => 1,
385
  T_BITWISE_OR => 1,
386
  T_BITWISE_XOR => 1,
@@ -565,19 +575,20 @@ final class PHP_CodeSniffer_Tokens
565
  * @var array(int)
566
  */
567
  public static $operators = array(
568
- T_MINUS => T_MINUS,
569
- T_PLUS => T_PLUS,
570
- T_MULTIPLY => T_MULTIPLY,
571
- T_DIVIDE => T_DIVIDE,
572
- T_MODULUS => T_MODULUS,
573
- T_POW => T_POW,
574
- T_SPACESHIP => T_SPACESHIP,
575
- T_COALESCE => T_COALESCE,
576
- T_BITWISE_AND => T_BITWISE_AND,
577
- T_BITWISE_OR => T_BITWISE_OR,
578
- T_BITWISE_XOR => T_BITWISE_XOR,
579
- T_SL => T_SL,
580
- T_SR => T_SR,
 
581
  );
582
 
583
  /**
22
  define('T_OPEN_PARENTHESIS', 'PHPCS_T_OPEN_PARENTHESIS');
23
  define('T_CLOSE_PARENTHESIS', 'PHPCS_T_CLOSE_PARENTHESIS');
24
  define('T_COLON', 'PHPCS_T_COLON');
25
+ define('T_NULLABLE', 'PHPCS_T_NULLABLE');
26
  define('T_STRING_CONCAT', 'PHPCS_T_STRING_CONCAT');
27
  define('T_INLINE_THEN', 'PHPCS_T_INLINE_THEN');
28
  define('T_INLINE_ELSE', 'PHPCS_T_INLINE_ELSE');
76
  define('T_RETURN_TYPE', 'PHPCS_T_RETURN_TYPE');
77
  define('T_OPEN_USE_GROUP', 'PHPCS_T_OPEN_USE_GROUP');
78
  define('T_CLOSE_USE_GROUP', 'PHPCS_T_CLOSE_USE_GROUP');
79
+ define('T_ZSR', 'PHPCS_T_ZSR');
80
+ define('T_ZSR_EQUAL', 'PHPCS_T_ZSR_EQUAL');
81
 
82
  // Some PHP 5.3 tokens, replicated for lower versions.
83
  if (defined('T_NAMESPACE') === false) {
148
  define('T_COALESCE', 'PHPCS_T_COALESCE');
149
  }
150
 
151
+ if (defined('T_COALESCE_EQUAL') === false) {
152
+ define('T_COALESCE_EQUAL', 'PHPCS_T_COALESCE_EQUAL');
153
+ }
154
+
155
  // Tokens used for parsing doc blocks.
156
  define('T_DOC_COMMENT_STAR', 'PHPCS_T_DOC_COMMENT_STAR');
157
  define('T_DOC_COMMENT_WHITESPACE', 'PHPCS_T_DOC_COMMENT_WHITESPACE');
227
  T_POW => 5,
228
  T_SPACESHIP => 5,
229
  T_COALESCE => 5,
230
+ T_COALESCE_EQUAL => 5,
231
 
232
  T_SL => 5,
233
  T_SR => 5,
373
  T_OPEN_PARENTHESIS => 1,
374
  T_CLOSE_PARENTHESIS => 1,
375
  T_COLON => 1,
376
+ T_NULLABLE => 1,
377
  T_STRING_CONCAT => 1,
378
  T_INLINE_THEN => 1,
379
  T_INLINE_ELSE => 1,
390
  T_POW => 2,
391
  T_SPACESHIP => 3,
392
  T_COALESCE => 2,
393
+ T_COALESCE_EQUAL => 3,
394
  T_BITWISE_AND => 1,
395
  T_BITWISE_OR => 1,
396
  T_BITWISE_XOR => 1,
575
  * @var array(int)
576
  */
577
  public static $operators = array(
578
+ T_MINUS => T_MINUS,
579
+ T_PLUS => T_PLUS,
580
+ T_MULTIPLY => T_MULTIPLY,
581
+ T_DIVIDE => T_DIVIDE,
582
+ T_MODULUS => T_MODULUS,
583
+ T_POW => T_POW,
584
+ T_SPACESHIP => T_SPACESHIP,
585
+ T_COALESCE => T_COALESCE,
586
+ T_COALESCE_EQUAL => T_COALESCE_EQUAL,
587
+ T_BITWISE_AND => T_BITWISE_AND,
588
+ T_BITWISE_OR => T_BITWISE_OR,
589
+ T_BITWISE_XOR => T_BITWISE_XOR,
590
+ T_SL => T_SL,
591
+ T_SR => T_SR,
592
  );
593
 
594
  /**
vendor/squizlabs/php_codesniffer/README.md CHANGED
@@ -33,7 +33,7 @@ If you prefer using [Composer](http://getcomposer.org/) you can easily install P
33
 
34
  composer global require "squizlabs/php_codesniffer=*"
35
 
36
- Make sure you have `~/.composer/vendor/bin/` in your PATH.
37
 
38
  Or alternatively, include a dependency for `squizlabs/php_codesniffer` in your `composer.json` file. For example:
39
 
33
 
34
  composer global require "squizlabs/php_codesniffer=*"
35
 
36
+ Make sure you have the composer bin dir in your PATH. The default value is `~/.composer/vendor/bin/`, but you can check the value that you need to use by running `composer global config bin-dir --absolute`.
37
 
38
  Or alternatively, include a dependency for `squizlabs/php_codesniffer` in your `composer.json` file. For example:
39
 
vendor/squizlabs/php_codesniffer/scripts/phpcs-svn-pre-commit CHANGED
@@ -1,4 +1,4 @@
1
- #!@php_bin@
2
  <?php
3
  /**
4
  * A commit hook for SVN.
1
+ #!/usr/bin/env php
2
  <?php
3
  /**
4
  * A commit hook for SVN.
vendor/wimg/php-compatibility/Sniff.php CHANGED
@@ -22,6 +22,8 @@
22
  abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
23
  {
24
 
 
 
25
  /**
26
  * List of functions using hash algorithm as parameter (always the first parameter).
27
  *
@@ -40,6 +42,20 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
40
  );
41
 
42
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  /* The testVersion configuration variable may be in any of the following formats:
44
  * 1) Omitted/empty, in which case no version is specified. This effectively
45
  * disables all the checks provided by this standard.
@@ -127,10 +143,51 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
127
  }//end supportsBelow()
128
 
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  /**
131
  * Strip quotes surrounding an arbitrary string.
132
  *
133
- * Intended for use with the content of a T_CONSTANT_ENCAPSED_STRING.
134
  *
135
  * @param string $string The raw string.
136
  *
@@ -141,6 +198,39 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
141
  }
142
 
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  /**
145
  * Returns the name(s) of the interface(s) that the specified class implements.
146
  *
@@ -211,6 +301,9 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
211
  * Expects to be passed the T_STRING stack pointer for the function call.
212
  * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
213
  *
 
 
 
214
  * @link https://github.com/wimg/PHPCompatibility/issues/120
215
  * @link https://github.com/wimg/PHPCompatibility/issues/152
216
  *
@@ -228,24 +321,42 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
228
  return false;
229
  }
230
 
231
- if ($tokens[$stackPtr]['code'] !== T_STRING) {
 
232
  return false;
233
  }
234
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
235
  // Next non-empty token should be the open parenthesis.
236
- $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
237
- if ($openParenthesis === false || $tokens[$openParenthesis]['code'] !== T_OPEN_PARENTHESIS) {
238
  return false;
239
  }
240
 
241
- if (isset($tokens[$openParenthesis]['parenthesis_closer']) === false) {
242
  return false;
243
  }
244
 
245
- $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
246
- $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $openParenthesis + 1, $closeParenthesis + 1, true);
247
 
248
- if ($nextNonEmpty === $closeParenthesis) {
249
  // No parameters.
250
  return false;
251
  }
@@ -260,6 +371,9 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
260
  * Expects to be passed the T_STRING stack pointer for the function call.
261
  * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
262
  *
 
 
 
263
  * @link https://github.com/wimg/PHPCompatibility/issues/111
264
  * @link https://github.com/wimg/PHPCompatibility/issues/114
265
  * @link https://github.com/wimg/PHPCompatibility/issues/151
@@ -289,6 +403,9 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
289
  * pointer and raw parameter value for all parameters. Index will be 1-based.
290
  * If no parameters are found, will return an empty array.
291
  *
 
 
 
292
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
293
  * @param int $stackPtr The position of the function call token.
294
  *
@@ -300,23 +417,34 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
300
  return array();
301
  }
302
 
303
- // Ok, we know we have a T_STRING with parameters and valid open & close parenthesis.
 
304
  $tokens = $phpcsFile->getTokens();
305
 
306
- $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
307
- $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
 
 
 
 
 
 
 
 
 
 
 
308
 
309
  // Which nesting level is the one we are interested in ?
310
- $nestedParenthesisCount = 1;
311
- if (isset($tokens[$openParenthesis]['nested_parenthesis'])) {
312
- $nestedParenthesisCount = count($tokens[$openParenthesis]['nested_parenthesis']) + 1;
313
  }
314
 
315
  $parameters = array();
316
- $nextComma = $openParenthesis;
317
- $paramStart = $openParenthesis + 1;
318
  $cnt = 1;
319
- while ($nextComma = $phpcsFile->findNext(array(T_COMMA, T_CLOSE_PARENTHESIS, T_OPEN_SHORT_ARRAY), $nextComma + 1, $closeParenthesis + 1)) {
320
  // Ignore anything within short array definition brackets.
321
  if (
322
  $tokens[$nextComma]['type'] === 'T_OPEN_SHORT_ARRAY'
@@ -341,8 +469,8 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
341
  continue;
342
  }
343
 
344
- // Ignore closing parenthesis if not 'ours'.
345
- if ($tokens[$nextComma]['type'] === 'T_CLOSE_PARENTHESIS' && $nextComma !== $closeParenthesis) {
346
  continue;
347
  }
348
 
@@ -354,7 +482,7 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
354
  // Check if there are more tokens before the closing parenthesis.
355
  // Prevents code like the following from setting a third parameter:
356
  // functionCall( $param1, $param2, );
357
- $hasNextParam = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $nextComma + 1, $closeParenthesis, true, null, true);
358
  if ($hasNextParam === false) {
359
  break;
360
  }
@@ -434,24 +562,7 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
434
  return true;
435
  }
436
 
437
- if (is_int($validScopes)) {
438
- // Received an integer, so cast to array.
439
- $validScopes = (array) $validScopes;
440
- }
441
-
442
- if (empty($validScopes) || is_array($validScopes) === false) {
443
- // No valid scope types received, so will not comply.
444
- return false;
445
- }
446
-
447
- // Check for required scope types.
448
- foreach ($tokens[$stackPtr]['conditions'] as $pointer => $tokenCode) {
449
- if (in_array($tokenCode, $validScopes, true)) {
450
- return true;
451
- }
452
- }
453
-
454
- return false;
455
  }
456
 
457
 
@@ -469,12 +580,16 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
469
  public function inClassScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $strict = true)
470
  {
471
  $validScopes = array(T_CLASS);
 
 
 
 
472
  if ($strict === false) {
473
  $validScopes[] = T_INTERFACE;
474
  $validScopes[] = T_TRAIT;
475
  }
476
 
477
- return $this->tokenHasScope($phpcsFile, $stackPtr, $validScopes);
478
  }
479
 
480
 
@@ -509,7 +624,7 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
509
 
510
  // PHPCS 2.0.
511
  if ($isLowPHPCS === false) {
512
- return $this->tokenHasScope($phpcsFile, $stackPtr, T_USE);
513
  } else {
514
  // PHPCS 1.x.
515
  $tokens = $phpcsFile->getTokens();
@@ -1058,7 +1173,7 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
1058
  }
1059
 
1060
  /**
1061
- * Algorithm is a T_CONSTANT_ENCAPSED_STRING, so we need to remove the quotes.
1062
  */
1063
  $algo = strtolower(trim($algoParam['raw']));
1064
  $algo = $this->stripQuotes($algo);
22
  abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff
23
  {
24
 
25
+ const REGEX_COMPLEX_VARS = '`(?:(\{)?(?<!\\\\)\$)?(\{)?(?<!\\\\)\$(\{)?(?P<varname>[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(?:->\$?(?P>varname)|\[[^\]]+\]|::\$?(?P>varname)|\([^\)]*\))*(?(3)\}|)(?(2)\}|)(?(1)\}|)`';
26
+
27
  /**
28
  * List of functions using hash algorithm as parameter (always the first parameter).
29
  *
42
  );
43
 
44
 
45
+ /**
46
+ * List of functions which take an ini directive as parameter (always the first parameter).
47
+ *
48
+ * Used by the new/removed ini directives sniffs.
49
+ * Key is the function name, value is the 1-based parameter position in the function call.
50
+ *
51
+ * @var array
52
+ */
53
+ protected $iniFunctions = array(
54
+ 'ini_get' => 1,
55
+ 'ini_set' => 1,
56
+ );
57
+
58
+
59
  /* The testVersion configuration variable may be in any of the following formats:
60
  * 1) Omitted/empty, in which case no version is specified. This effectively
61
  * disables all the checks provided by this standard.
143
  }//end supportsBelow()
144
 
145
 
146
+ /**
147
+ * Add a PHPCS message to the output stack as either a warning or an error.
148
+ *
149
+ * @param PHP_CodeSniffer_File $phpcsFile The file the message applies to.
150
+ * @param string $message The message.
151
+ * @param int $stackPtr The position of the token
152
+ * the message relates to.
153
+ * @param bool $isError Whether to report the message as an
154
+ * 'error' or 'warning'.
155
+ * Defaults to true (error).
156
+ * @param string $code The error code for the message.
157
+ * Defaults to 'Found'.
158
+ * @param array $data Optional input for the data replacements.
159
+ *
160
+ * @return void
161
+ */
162
+ public function addMessage($phpcsFile, $message, $stackPtr, $isError, $code = 'Found', $data = array())
163
+ {
164
+ if ($isError === true) {
165
+ $phpcsFile->addError($message, $stackPtr, $code, $data);
166
+ } else {
167
+ $phpcsFile->addWarning($message, $stackPtr, $code, $data);
168
+ }
169
+ }
170
+
171
+
172
+ /**
173
+ * Convert an arbitrary string to an alphanumeric string with underscores.
174
+ *
175
+ * Pre-empt issues with arbitrary strings being used as error codes in XML and PHP.
176
+ *
177
+ * @param string $baseString Arbitrary string.
178
+ *
179
+ * @return string
180
+ */
181
+ public function stringToErrorCode($baseString)
182
+ {
183
+ return preg_replace('`[^a-z0-9_]`i', '_', strtolower($baseString));
184
+ }
185
+
186
+
187
  /**
188
  * Strip quotes surrounding an arbitrary string.
189
  *
190
+ * Intended for use with the content of a T_CONSTANT_ENCAPSED_STRING / T_DOUBLE_QUOTED_STRING.
191
  *
192
  * @param string $string The raw string.
193
  *
198
  }
199
 
200
 
201
+ /**
202
+ * Strip variables from an arbitrary double quoted string.
203
+ *
204
+ * Intended for use with the content of a T_DOUBLE_QUOTED_STRING.
205
+ *
206
+ * @param string $string The raw string.
207
+ *
208
+ * @return string String without variables in it.
209
+ */
210
+ public function stripVariables($string) {
211
+ if (strpos($string, '$') === false) {
212
+ return $string;
213
+ }
214
+
215
+ return preg_replace( self::REGEX_COMPLEX_VARS, '', $string );
216
+ }
217
+
218
+
219
+ /**
220
+ * Make all top level array keys in an array lowercase.
221
+ *
222
+ * @param array $array Initial array.
223
+ *
224
+ * @return array Same array, but with all lowercase top level keys.
225
+ */
226
+ public function arrayKeysToLowercase($array)
227
+ {
228
+ $keys = array_keys($array);
229
+ $keys = array_map('strtolower', $keys);
230
+ return array_combine($keys, $array);
231
+ }
232
+
233
+
234
  /**
235
  * Returns the name(s) of the interface(s) that the specified class implements.
236
  *
301
  * Expects to be passed the T_STRING stack pointer for the function call.
302
  * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
303
  *
304
+ * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer, it
305
+ * will detect whether the array has values or is empty.
306
+ *
307
  * @link https://github.com/wimg/PHPCompatibility/issues/120
308
  * @link https://github.com/wimg/PHPCompatibility/issues/152
309
  *
321
  return false;
322
  }
323
 
324
+ // Is this one of the tokens this function handles ?
325
+ if (in_array($tokens[$stackPtr]['code'], array(T_STRING, T_ARRAY, T_OPEN_SHORT_ARRAY), true) === false) {
326
  return false;
327
  }
328
 
329
+ $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
330
+
331
+ // Deal with short array syntax.
332
+ if ($tokens[$stackPtr]['code'] === T_OPEN_SHORT_ARRAY) {
333
+ if (isset($tokens[$stackPtr]['bracket_closer']) === false) {
334
+ return false;
335
+ }
336
+
337
+ if ($nextNonEmpty === $tokens[$stackPtr]['bracket_closer']) {
338
+ // No parameters.
339
+ return false;
340
+ }
341
+ else {
342
+ return true;
343
+ }
344
+ }
345
+
346
+ // Deal with function calls & long arrays.
347
  // Next non-empty token should be the open parenthesis.
348
+ if ($nextNonEmpty === false && $tokens[$nextNonEmpty]['code'] !== T_OPEN_PARENTHESIS) {
 
349
  return false;
350
  }
351
 
352
+ if (isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false) {
353
  return false;
354
  }
355
 
356
+ $closeParenthesis = $tokens[$nextNonEmpty]['parenthesis_closer'];
357
+ $nextNextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $nextNonEmpty + 1, $closeParenthesis + 1, true);
358
 
359
+ if ($nextNextNonEmpty === $closeParenthesis) {
360
  // No parameters.
361
  return false;
362
  }
371
  * Expects to be passed the T_STRING stack pointer for the function call.
372
  * If passed a T_STRING which is *not* a function call, the behaviour is unreliable.
373
  *
374
+ * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer,
375
+ * it will return the number of values in the array.
376
+ *
377
  * @link https://github.com/wimg/PHPCompatibility/issues/111
378
  * @link https://github.com/wimg/PHPCompatibility/issues/114
379
  * @link https://github.com/wimg/PHPCompatibility/issues/151
403
  * pointer and raw parameter value for all parameters. Index will be 1-based.
404
  * If no parameters are found, will return an empty array.
405
  *
406
+ * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer,
407
+ * it will tokenize the values / key/value pairs contained in the array call.
408
+ *
409
  * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
410
  * @param int $stackPtr The position of the function call token.
411
  *
417
  return array();
418
  }
419
 
420
+ // Ok, we know we have a T_STRING, T_ARRAY or T_OPEN_SHORT_ARRAY with parameters
421
+ // and valid open & close brackets/parenthesis.
422
  $tokens = $phpcsFile->getTokens();
423
 
424
+ // Mark the beginning and end tokens.
425
+ if ($tokens[$stackPtr]['code'] === T_OPEN_SHORT_ARRAY) {
426
+ $opener = $stackPtr;
427
+ $closer = $tokens[$stackPtr]['bracket_closer'];
428
+
429
+ $nestedParenthesisCount = 0;
430
+ }
431
+ else {
432
+ $opener = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
433
+ $closer = $tokens[$opener]['parenthesis_closer'];
434
+
435
+ $nestedParenthesisCount = 1;
436
+ }
437
 
438
  // Which nesting level is the one we are interested in ?
439
+ if (isset($tokens[$opener]['nested_parenthesis'])) {
440
+ $nestedParenthesisCount += count($tokens[$opener]['nested_parenthesis']);
 
441
  }
442
 
443
  $parameters = array();
444
+ $nextComma = $opener;
445
+ $paramStart = $opener + 1;
446
  $cnt = 1;
447
+ while ($nextComma = $phpcsFile->findNext(array(T_COMMA, $tokens[$closer]['code'], T_OPEN_SHORT_ARRAY), $nextComma + 1, $closer + 1)) {
448
  // Ignore anything within short array definition brackets.
449
  if (
450
  $tokens[$nextComma]['type'] === 'T_OPEN_SHORT_ARRAY'
469
  continue;
470
  }
471
 
472
+ // Ignore closing parenthesis/bracket if not 'ours'.
473
+ if ($tokens[$nextComma]['type'] === $tokens[$closer]['type'] && $nextComma !== $closer) {
474
  continue;
475
  }
476
 
482
  // Check if there are more tokens before the closing parenthesis.
483
  // Prevents code like the following from setting a third parameter:
484
  // functionCall( $param1, $param2, );
485
+ $hasNextParam = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $nextComma + 1, $closer, true, null, true);
486
  if ($hasNextParam === false) {
487
  break;
488
  }
562
  return true;
563
  }
564
 
565
+ return $phpcsFile->hasCondition($stackPtr, $validScopes);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
566
  }
567
 
568
 
580
  public function inClassScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $strict = true)
581
  {
582
  $validScopes = array(T_CLASS);
583
+ if (defined('T_ANON_CLASS') === true) {
584
+ $validScopes[] = T_ANON_CLASS;
585
+ }
586
+
587
  if ($strict === false) {
588
  $validScopes[] = T_INTERFACE;
589
  $validScopes[] = T_TRAIT;
590
  }
591
 
592
+ return $phpcsFile->hasCondition($stackPtr, $validScopes);
593
  }
594
 
595
 
624
 
625
  // PHPCS 2.0.
626
  if ($isLowPHPCS === false) {
627
+ return $phpcsFile->hasCondition($stackPtr, T_USE);
628
  } else {
629
  // PHPCS 1.x.
630
  $tokens = $phpcsFile->getTokens();
1173
  }
1174
 
1175
  /**
1176
+ * Algorithm is a text string, so we need to remove the quotes.
1177
  */
1178
  $algo = strtolower(trim($algoParam['raw']));
1179
  $algo = $this->stripQuotes($algo);
vendor/wimg/php-compatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php CHANGED
@@ -63,8 +63,8 @@ class PHPCompatibility_Sniffs_PHP_ConstantArraysUsingDefineSniff extends PHPComp
63
  return;
64
  }
65
 
66
- $function = strtolower($tokens[$stackPtr]['content']);
67
- if ($function !== 'define') {
68
  return;
69
  }
70
 
@@ -75,7 +75,11 @@ class PHPCompatibility_Sniffs_PHP_ConstantArraysUsingDefineSniff extends PHPComp
75
 
76
  $array = $phpcsFile->findNext(array(T_ARRAY, T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1));
77
  if ($array !== false) {
78
- $phpcsFile->addError('Constant arrays using define are not allowed in PHP 5.6 or earlier', $array);
 
 
 
 
79
  }
80
  }
81
  }
63
  return;
64
  }
65
 
66
+ $functionLc = strtolower($tokens[$stackPtr]['content']);
67
+ if ($functionLc !== 'define') {
68
  return;
69
  }
70
 
75
 
76
  $array = $phpcsFile->findNext(array(T_ARRAY, T_OPEN_SHORT_ARRAY), $secondParam['start'], ($secondParam['end'] + 1));
77
  if ($array !== false) {
78
+ $phpcsFile->addError(
79
+ 'Constant arrays using define are not allowed in PHP 5.6 or earlier',
80
+ $array,
81
+ 'Found'
82
+ );
83
  }
84
  }
85
  }
vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php CHANGED
@@ -16,7 +16,7 @@
16
  * @package PHPCompatibility
17
  * @author Wim Godden <wim.godden@cu.be>
18
  */
19
- class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibility_Sniff
20
  {
21
  /**
22
  * A list of deprecated and removed functions with their alternatives.
@@ -757,14 +757,6 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
757
  ),
758
  );
759
 
760
- /**
761
- * List of just the function names.
762
- *
763
- * Will be set automatically in the register() method.
764
- *
765
- * @var array
766
- */
767
- protected $removedFunctionNames = array();
768
 
769
  /**
770
  * Returns an array of tokens this test wants to listen for.
@@ -773,9 +765,8 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
773
  */
774
  public function register()
775
  {
776
- // Everyone has had a chance to figure out what removed functions
777
- // they want to check for, so now we can cache out the list.
778
- $this->removedFunctionNames = array_keys($this->removedFunctions);
779
 
780
  return array(T_STRING);
781
 
@@ -810,63 +801,44 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil
810
  return;
811
  }
812
 
813
- $function = strtolower($tokens[$stackPtr]['content']);
 
814
 
815
- if (in_array($function, $this->removedFunctionNames) === false) {
816
  return;
817
  }
818
 
819
- $this->addError($phpcsFile, $stackPtr, $function);
 
 
 
 
820
 
821
  }//end process()
822
 
 
823
  /**
824
- * Generates the error or warning for this sniff.
825
  *
826
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
827
- * @param int $stackPtr The position of the function
828
- * in the token array.
829
- * @param string $function The name of the function.
830
  *
831
- * @return void
832
  */
833
- protected function addError($phpcsFile, $stackPtr, $function)
834
  {
835
- $error = '';
 
836
 
837
- $isError = false;
838
- $previousVersionStatus = null;
839
- foreach ($this->removedFunctions[$function] as $version => $removed) {
840
- if ($this->supportsAbove($version)) {
841
- if ($version != 'alternative') {
842
- if ($previousVersionStatus !== $removed) {
843
- $previousVersionStatus = $removed;
844
- if ($removed === true) {
845
- $isError = true;
846
- $error .= 'removed';
847
- } else {
848
- $error .= 'deprecated';
849
- }
850
- $error .= ' since PHP ' . $version . ' and ';
851
- }
852
- }
853
- }
854
- }
855
- if (strlen($error) > 0) {
856
- $error = 'Function ' . $function . '() is ' . $error;
857
- $error = substr($error, 0, strlen($error) - 5);
858
-
859
- if ($this->removedFunctions[$function]['alternative'] !== null) {
860
- $error .= '; use ' . $this->removedFunctions[$function]['alternative'] . ' instead';
861
- }
862
 
863
- if ($isError === true) {
864
- $phpcsFile->addError($error, $stackPtr);
865
- } else {
866
- $phpcsFile->addWarning($error, $stackPtr);
867
- }
868
- }
 
 
 
869
 
870
- }//end addError()
871
 
872
  }//end class
16
  * @package PHPCompatibility
17
  * @author Wim Godden <wim.godden@cu.be>
18
  */
19
+ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibility_AbstractRemovedFeatureSniff
20
  {
21
  /**
22
  * A list of deprecated and removed functions with their alternatives.
757
  ),
758
  );
759
 
 
 
 
 
 
 
 
 
760
 
761
  /**
762
  * Returns an array of tokens this test wants to listen for.
765
  */
766
  public function register()
767
  {
768
+ // Handle case-insensitivity of function names.
769
+ $this->removedFunctions = $this->arrayKeysToLowercase($this->removedFunctions);
 
770
 
771
  return array(T_STRING);
772
 
801
  return;
802
  }
803
 
804
+ $function = $tokens[$stackPtr]['content'];
805
+ $functionLc = strtolower($function);
806
 
807
+ if (isset($this->removedFunctions[$functionLc]) === false) {
808
  return;
809
  }
810
 
811
+ $itemInfo = array(
812
+ 'name' => $function,
813
+ 'nameLc' => $functionLc,
814
+ );
815
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
816
 
817
  }//end process()
818
 
819
+
820
  /**
821
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
822
  *
823
+ * @param array $itemInfo Base information about the item.
 
 
 
824
  *
825
+ * @return array Version and other information about the item.
826
  */
827
+ public function getItemArray(array $itemInfo)
828
  {
829
+ return $this->removedFunctions[$itemInfo['nameLc']];
830
+ }
831
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
832
 
833
+ /**
834
+ * Get the error message template for this sniff.
835
+ *
836
+ * @return string
837
+ */
838
+ protected function getErrorMsgTemplate()
839
+ {
840
+ return 'Function %s() is ';
841
+ }
842
 
 
843
 
844
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php CHANGED
@@ -20,13 +20,13 @@
20
  * @author Wim Godden <wim.godden@cu.be>
21
  * @copyright 2012 Cu.be Solutions bvba
22
  */
23
- class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompatibility_Sniff
24
  {
25
  /**
26
  * A list of deprecated INI directives.
27
  *
28
- * version => false means the directive was deprecated in that version.
29
- * version => true means it was removed in that version.
30
  *
31
  * @var array(string)
32
  */
@@ -225,8 +225,6 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
225
  {
226
  $tokens = $phpcsFile->getTokens();
227
 
228
- $isError = false;
229
-
230
  $ignore = array(
231
  T_DOUBLE_COLON,
232
  T_OBJECT_OPERATOR,
@@ -240,12 +238,12 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
240
  return;
241
  }
242
 
243
- $function = strtolower($tokens[$stackPtr]['content']);
244
- if ($function !== 'ini_get' && $function !== 'ini_set') {
245
  return;
246
  }
247
 
248
- $iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 1);
249
  if ($iniToken === false) {
250
  return;
251
  }
@@ -255,38 +253,69 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat
255
  return;
256
  }
257
 
258
- $error = '';
 
 
 
 
259
 
260
- foreach ($this->deprecatedIniDirectives[$filteredToken] as $version => $removed)
261
- {
262
- if ($version !== 'alternative') {
263
- if ($this->supportsAbove($version)) {
264
- if ($removed === true) {
265
- $isError = ($function !== 'ini_get') ? true : false;
266
- $error .= " removed";
267
- } else {
268
- $isError = false;
269
- $error .= " deprecated";
270
- }
271
- $error .= " since PHP " . $version . " and";
272
- }
273
- }
274
- }
275
 
276
- if (strlen($error) > 0) {
277
- $error = "INI directive '" . $filteredToken . "' is" . $error;
278
- $error = substr($error, 0, strlen($error) - 4) . ".";
279
- if (isset($this->deprecatedIniDirectives[$filteredToken]['alternative'])) {
280
- $error .= " Use '" . $this->deprecatedIniDirectives[$filteredToken]['alternative'] . "' instead.";
281
- }
282
 
283
- if ($isError === true) {
284
- $phpcsFile->addError($error, $iniToken['end']);
285
- } else {
286
- $phpcsFile->addWarning($error, $iniToken['end']);
287
- }
 
 
 
 
 
 
 
 
 
 
288
  }
289
 
290
- }//end process()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
 
292
  }//end class
20
  * @author Wim Godden <wim.godden@cu.be>
21
  * @copyright 2012 Cu.be Solutions bvba
22
  */
23
+ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompatibility_AbstractRemovedFeatureSniff
24
  {
25
  /**
26
  * A list of deprecated INI directives.
27
  *
28
+ * The array lists : version number with false (deprecated) and true (removed).
29
+ * If's sufficient to list the first version where the ini directive was deprecated/removed.
30
  *
31
  * @var array(string)
32
  */
225
  {
226
  $tokens = $phpcsFile->getTokens();
227
 
 
 
228
  $ignore = array(
229
  T_DOUBLE_COLON,
230
  T_OBJECT_OPERATOR,
238
  return;
239
  }
240
 
241
+ $functionLc = strtolower($tokens[$stackPtr]['content']);
242
+ if (isset($this->iniFunctions[$functionLc]) === false) {
243
  return;
244
  }
245
 
246
+ $iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, $this->iniFunctions[$functionLc]);
247
  if ($iniToken === false) {
248
  return;
249
  }
253
  return;
254
  }
255
 
256
+ $itemInfo = array(
257
+ 'name' => $filteredToken,
258
+ 'functionLc' => $functionLc,
259
+ );
260
+ $this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo);
261
 
262
+ }//end process()
263
+
264
+
265
+ /**
266
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
267
+ *
268
+ * @param array $itemInfo Base information about the item.
269
+ *
270
+ * @return array Version and other information about the item.
271
+ */
272
+ public function getItemArray(array $itemInfo)
273
+ {
274
+ return $this->deprecatedIniDirectives[$itemInfo['name']];
275
+ }
 
276
 
 
 
 
 
 
 
277
 
278
+ /**
279
+ * Retrieve the relevant detail (version) information for use in an error message.
280
+ *
281
+ * @param array $itemArray Version and other information about the item.
282
+ * @param array $itemInfo Base information about the item.
283
+ *
284
+ * @return array
285
+ */
286
+ public function getErrorInfo(array $itemArray, array $itemInfo)
287
+ {
288
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
289
+
290
+ // Lower error level to warning if the function used was ini_get.
291
+ if ($errorInfo['error'] === true && $itemInfo['functionLc'] === 'ini_get') {
292
+ $errorInfo['error'] = false;
293
  }
294
 
295
+ return $errorInfo;
296
+ }
297
+
298
+
299
+ /**
300
+ * Get the error message template for this sniff.
301
+ *
302
+ * @return string
303
+ */
304
+ protected function getErrorMsgTemplate()
305
+ {
306
+ return "INI directive '%s' is ";
307
+ }
308
+
309
+
310
+ /**
311
+ * Get the error message template for suggesting an alternative for a specific sniff.
312
+ *
313
+ * @return string
314
+ */
315
+ protected function getAlternativeOptionTemplate()
316
+ {
317
+ return str_replace("%s", "'%s'", parent::getAlternativeOptionTemplate());
318
+ }
319
+
320
 
321
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php CHANGED
@@ -50,13 +50,17 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedNewReferenceSniff extends PHPCompati
50
  if ($this->supportsAbove('5.3')) {
51
  $tokens = $phpcsFile->getTokens();
52
  if ($tokens[$stackPtr - 1]['type'] == 'T_BITWISE_AND' || $tokens[$stackPtr - 2]['type'] == 'T_BITWISE_AND') {
53
- if ($this->supportsAbove('7.0')) {
54
- $error = 'Assigning the return value of new by reference is deprecated in PHP 5.3 and forbidden in PHP 7.0';
55
- $phpcsFile->addError($error, $stackPtr);
56
- } else {
57
- $error = 'Assigning the return value of new by reference is deprecated in PHP 5.3';
58
- $phpcsFile->addWarning($error, $stackPtr);
 
 
59
  }
 
 
60
  }
61
  }
62
 
50
  if ($this->supportsAbove('5.3')) {
51
  $tokens = $phpcsFile->getTokens();
52
  if ($tokens[$stackPtr - 1]['type'] == 'T_BITWISE_AND' || $tokens[$stackPtr - 2]['type'] == 'T_BITWISE_AND') {
53
+ $error = 'Assigning the return value of new by reference is deprecated in PHP 5.3';
54
+ $isError = false;
55
+ $errorCode = 'Deprecated';
56
+
57
+ if ($this->supportsAbove('7.0') === true) {
58
+ $error .= ' and forbidden in PHP 7.0';
59
+ $isError = true;
60
+ $errorCode = 'Forbidden';
61
  }
62
+
63
+ $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode);
64
  }
65
  }
66
 
vendor/wimg/php-compatibility/Sniffs/PHP/EmptyNonVariableSniff.php CHANGED
@@ -147,7 +147,10 @@ class PHPCompatibility_Sniffs_PHP_EmptyNonVariableSniff extends PHPCompatibility
147
  */
148
  protected function addError($phpcsFile, $stackPtr)
149
  {
150
- $error = 'Only variables can be passed to empty() prior to PHP 5.5.';
151
- $phpcsFile->addError($error, $stackPtr, 'Found');
 
 
 
152
  }
153
  }
147
  */
148
  protected function addError($phpcsFile, $stackPtr)
149
  {
150
+ $phpcsFile->addError(
151
+ 'Only variables can be passed to empty() prior to PHP 5.5.',
152
+ $stackPtr,
153
+ 'Found'
154
+ );
155
  }
156
  }
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenBreakContinueOutsideLoopSniff.php CHANGED
@@ -90,21 +90,18 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueOutsideLoopSniff extends
90
  }
91
 
92
  // If we're still here, no valid loop structure container has been found, so throw an error.
93
- $error = "Using '%s' outside of a loop or switch structure is invalid";
94
- $isError = false;
95
- $data = array(
96
- $token['content'],
97
- );
98
  if ($this->supportsAbove('7.0')) {
99
- $isError = true;
100
- $error .= ' and will throw a fatal error since PHP 7.0';
 
101
  }
102
 
103
- if ($isError === true) {
104
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
105
- } else {
106
- $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
107
- }
108
 
109
  }//end process()
110
 
90
  }
91
 
92
  // If we're still here, no valid loop structure container has been found, so throw an error.
93
+ $error = "Using '%s' outside of a loop or switch structure is invalid";
94
+ $isError = false;
95
+ $errorCode = 'Found';
96
+ $data = array($token['content']);
97
+
98
  if ($this->supportsAbove('7.0')) {
99
+ $error .= ' and will throw a fatal error since PHP 7.0';
100
+ $isError = true;
101
+ $errorCode = 'FatalError';
102
  }
103
 
104
+ $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
 
 
 
 
105
 
106
  }//end process()
107
 
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php CHANGED
@@ -24,8 +24,17 @@
24
  */
25
  class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueVariableArgumentsSniff extends PHPCompatibility_Sniff
26
  {
27
- const ERROR_TYPE_VARIABLE = 'a variable argument';
28
- const ERROR_TYPE_ZERO = '0 as an argument';
 
 
 
 
 
 
 
 
 
29
 
30
  /**
31
  * Returns an array of tokens this test wants to listen for.
@@ -55,7 +64,6 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueVariableArgumentsSniff e
55
 
56
  $tokens = $phpcsFile->getTokens();
57
  $nextSemicolonToken = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr), null, false);
58
- $isError = false;
59
  $errorType = '';
60
  for ($curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++) {
61
  if ($tokens[$curToken]['type'] === 'T_STRING') {
@@ -63,26 +71,26 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueVariableArgumentsSniff e
63
  // is an opening parenthesis then it's a function call.
64
  $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $curToken + 1, null, true);
65
  if ($tokens[$openBracket]['code'] === T_OPEN_PARENTHESIS) {
66
- $isError = true;
67
- $errorType = self::ERROR_TYPE_VARIABLE;
68
  break;
69
  }
70
  }
71
  else if (in_array($tokens[$curToken]['type'], array('T_VARIABLE', 'T_FUNCTION', 'T_CLOSURE'), true)) {
72
- $isError = true;
73
- $errorType = self::ERROR_TYPE_VARIABLE;
74
  break;
75
  }
76
  else if ($tokens[$curToken]['type'] === 'T_LNUMBER' && $tokens[$curToken]['content'] === '0') {
77
- $isError = true;
78
- $errorType = self::ERROR_TYPE_ZERO;
79
  break;
80
  }
81
  }
82
 
83
- if ($isError === true && !empty($errorType)) {
84
- $error = 'Using ' . $errorType . ' on break or continue is forbidden since PHP 5.4';
85
- $phpcsFile->addError($error, $stackPtr);
 
 
 
86
  }
87
 
88
  }//end process()
24
  */
25
  class PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueVariableArgumentsSniff extends PHPCompatibility_Sniff
26
  {
27
+ /**
28
+ * Error types this sniff handles for forbidden break/continue arguments.
29
+ *
30
+ * Array key is the error code. Array value will be used as part of the error message.
31
+ *
32
+ * @var array
33
+ */
34
+ private $errorTypes = array(
35
+ 'variableArgument' => 'a variable argument',
36
+ 'zeroArgument' => '0 as an argument',
37
+ );
38
 
39
  /**
40
  * Returns an array of tokens this test wants to listen for.
64
 
65
  $tokens = $phpcsFile->getTokens();
66
  $nextSemicolonToken = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr), null, false);
 
67
  $errorType = '';
68
  for ($curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++) {
69
  if ($tokens[$curToken]['type'] === 'T_STRING') {
71
  // is an opening parenthesis then it's a function call.
72
  $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $curToken + 1, null, true);
73
  if ($tokens[$openBracket]['code'] === T_OPEN_PARENTHESIS) {
74
+ $errorType = 'variableArgument';
 
75
  break;
76
  }
77
  }
78
  else if (in_array($tokens[$curToken]['type'], array('T_VARIABLE', 'T_FUNCTION', 'T_CLOSURE'), true)) {
79
+ $errorType = 'variableArgument';
 
80
  break;
81
  }
82
  else if ($tokens[$curToken]['type'] === 'T_LNUMBER' && $tokens[$curToken]['content'] === '0') {
83
+ $errorType = 'zeroArgument';
 
84
  break;
85
  }
86
  }
87
 
88
+ if ($errorType !== '') {
89
+ $error = 'Using %s on break or continue is forbidden since PHP 5.4';
90
+ $errorCode = $errorType.'Found';
91
+ $data = array($this->errorTypes[$errorType]);
92
+
93
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
94
  }
95
 
96
  }//end process()
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php CHANGED
@@ -117,11 +117,7 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenCallTimePassByReferenceSniff extends
117
  $errorCode = 'NotAllowed';
118
  }
119
 
120
- if ($isError === true) {
121
- $phpcsFile->addError($error, $parameter['start'], $errorCode);
122
- } else {
123
- $phpcsFile->addWarning($error, $parameter['start'], $errorCode);
124
- }
125
  }
126
  }
127
  }//end process()
117
  $errorCode = 'NotAllowed';
118
  }
119
 
120
+ $this->addMessage($phpcsFile, $error, $parameter['start'], $isError, $errorCode);
 
 
 
 
121
  }
122
  }
123
  }//end process()
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php CHANGED
@@ -81,8 +81,11 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenEmptyListAssignmentSniff extends PHPC
81
  }
82
 
83
  if ($error === true) {
84
- $error = 'Empty list() assignments are not allowed since PHP 7.0';
85
- $phpcsFile->addError($error, $stackPtr);
 
 
 
86
  }
87
  }
88
  }
81
  }
82
 
83
  if ($error === true) {
84
+ $phpcsFile->addError(
85
+ 'Empty list() assignments are not allowed since PHP 7.0',
86
+ $stackPtr,
87
+ 'Found'
88
+ );
89
  }
90
  }
91
  }
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php CHANGED
@@ -69,7 +69,11 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenFunctionParametersWithSameNameSniff e
69
  }
70
 
71
  if (count($paramNames) != count(array_unique($paramNames))) {
72
- $phpcsFile->addError('Functions can not have multiple parameters with the same name since PHP 7.0', $stackPtr);
 
 
 
 
73
  }
74
 
75
  }//end process()
69
  }
70
 
71
  if (count($paramNames) != count(array_unique($paramNames))) {
72
+ $phpcsFile->addError(
73
+ 'Functions can not have multiple parameters with the same name since PHP 7.0',
74
+ $stackPtr,
75
+ 'Found'
76
+ );
77
  }
78
 
79
  }//end process()
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenGlobalVariableVariableSniff.php CHANGED
@@ -44,15 +44,35 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenGlobalVariableVariableSniff extends P
44
  */
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
- if ($this->supportsAbove('7.0')) {
48
- $tokens = $phpcsFile->getTokens();
 
49
 
50
- $variable = $phpcsFile->findNext(T_VARIABLE, $stackPtr, $stackPtr + 4, false);
 
 
 
 
 
51
 
52
- if (isset($tokens[$variable - 1]) && $tokens[$variable - 1]['type'] == 'T_DOLLAR') {
53
- $error = 'Global with variable variables is not allowed since PHP 7.0';
54
- $phpcsFile->addError($error, $stackPtr);
 
 
 
 
 
 
55
  }
 
 
 
 
 
 
 
 
56
  }
57
  }
58
  }
44
  */
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
+ if ($this->supportsAbove('7.0') === false) {
48
+ return;
49
+ }
50
 
51
+ $tokens = $phpcsFile->getTokens();
52
+ $endOfStatement = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1));
53
+ if ($endOfStatement === false) {
54
+ // No semi-colon - live coding.
55
+ return;
56
+ }
57
 
58
+ for ($ptr = ($stackPtr + 1); $ptr <= $endOfStatement; $ptr++) {
59
+ $variable = $phpcsFile->findNext(T_VARIABLE, $ptr, $endOfStatement, false, null, true);
60
+ if ($variable !== false && (isset($tokens[$variable - 1]) && $tokens[$variable - 1]['type'] === 'T_DOLLAR')) {
61
+ $phpcsFile->addError(
62
+ 'Global with variable variables is not allowed since PHP 7.0',
63
+ $stackPtr,
64
+ 'Found'
65
+ );
66
+ return;
67
  }
68
+
69
+ // Move the stack pointer forward to the next variable for multi-variable statements.
70
+ $nextComma = $phpcsFile->findNext(T_COMMA, $ptr, $endOfStatement, false, null, true);
71
+ if ($nextComma === false) {
72
+ break;
73
+ }
74
+
75
+ $ptr = $nextComma;
76
  }
77
  }
78
  }
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNamesAsDeclaredSniff.php CHANGED
@@ -53,6 +53,8 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsDeclaredSniff extends PHPCompa
53
  'object' => '7.0',
54
  'mixed' => '7.0',
55
  'numeric' => '7.0',
 
 
56
  );
57
 
58
 
@@ -141,23 +143,23 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsDeclaredSniff extends PHPCompa
141
 
142
  $nextNonEmptyCode = $tokens[$nextNonEmpty]['code'];
143
 
144
- if ($nextNonEmptyCode !== T_STRING && isset($this->forbiddenTokens[$nextNonEmptyCode]) === true) {
145
  $name = $tokens[$nextNonEmpty]['content'];
146
  $nameLc = strtolower($tokens[$nextNonEmpty]['content']);
147
  } else if ($nextNonEmptyCode === T_STRING) {
148
- $endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON, T_OPEN_CURLY_BRACKET), ($stackPtr + 1));
149
-
150
- do {
151
- $nextNonEmptyLc = strtolower($tokens[$nextNonEmpty]['content']);
152
-
153
- if (isset($this->forbiddenNames[$nextNonEmptyLc]) === true) {
154
- $name = $tokens[$nextNonEmpty]['content'];
155
- $nameLc = $nextNonEmptyLc;
156
- break;
157
- }
158
-
159
- $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextNonEmpty + 1), $endOfStatement, true);
160
- } while ($nextNonEmpty !== false);
161
  }
162
  unset($nextNonEmptyCode, $nextNonEmptyLc, $endOfStatement);
163
  }
@@ -169,14 +171,15 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsDeclaredSniff extends PHPCompa
169
  // Still here, so this is one of the reserved words.
170
  $version = $this->forbiddenNames[$nameLc];
171
  if ($this->supportsAbove($version) === true) {
172
- $error = "'%s' is a reserved keyword as of PHP version %s and cannot be used to name a class, interface or trait or as part of a namespace (%s)";
173
- $data = array(
 
174
  $nameLc,
175
  $version,
176
  $tokens[$stackPtr]['type'],
177
  );
178
 
179
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
180
  }
181
  }//end process()
182
 
53
  'object' => '7.0',
54
  'mixed' => '7.0',
55
  'numeric' => '7.0',
56
+ 'iterable' => '7.1',
57
+ 'void' => '7.1',
58
  );
59
 
60
 
143
 
144
  $nextNonEmptyCode = $tokens[$nextNonEmpty]['code'];
145
 
146
+ if ($nextNonEmptyCode !== T_STRING && isset($this->forbiddenTokens[$nextNonEmptyCode]) === true) {
147
  $name = $tokens[$nextNonEmpty]['content'];
148
  $nameLc = strtolower($tokens[$nextNonEmpty]['content']);
149
  } else if ($nextNonEmptyCode === T_STRING) {
150
+ $endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON, T_OPEN_CURLY_BRACKET), ($stackPtr + 1));
151
+
152
+ do {
153
+ $nextNonEmptyLc = strtolower($tokens[$nextNonEmpty]['content']);
154
+
155
+ if (isset($this->forbiddenNames[$nextNonEmptyLc]) === true) {
156
+ $name = $tokens[$nextNonEmpty]['content'];
157
+ $nameLc = $nextNonEmptyLc;
158
+ break;
159
+ }
160
+
161
+ $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextNonEmpty + 1), $endOfStatement, true);
162
+ } while ($nextNonEmpty !== false);
163
  }
164
  unset($nextNonEmptyCode, $nextNonEmptyLc, $endOfStatement);
165
  }
171
  // Still here, so this is one of the reserved words.
172
  $version = $this->forbiddenNames[$nameLc];
173
  if ($this->supportsAbove($version) === true) {
174
+ $error = "'%s' is a reserved keyword as of PHP version %s and cannot be used to name a class, interface or trait or as part of a namespace (%s)";
175
+ $errorCode = $this->stringToErrorCode($nameLc).'Found';
176
+ $data = array(
177
  $nameLc,
178
  $version,
179
  $tokens[$stackPtr]['type'],
180
  );
181
 
182
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
183
  }
184
  }//end process()
185
 
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php CHANGED
@@ -34,7 +34,6 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff extends
34
  T_ABSTRACT => '5.0',
35
  T_CALLABLE => '5.4',
36
  T_CATCH => '5.0',
37
- T_CLONE => '5.0',
38
  T_FINAL => '5.0',
39
  T_FINALLY => '5.5',
40
  T_GOTO => '5.3',
@@ -138,13 +137,15 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff extends
138
  }
139
 
140
  if ($this->supportsAbove($version)) {
141
- $error = "'%s' is a reserved keyword introduced in PHP version %s and cannot be invoked as a function (%s)";
142
- $data = array(
 
143
  $tokenContentLc,
144
  $version,
145
  $tokens[$stackPtr]['type'],
146
  );
147
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
 
148
  }
149
  }//end process()
150
 
34
  T_ABSTRACT => '5.0',
35
  T_CALLABLE => '5.4',
36
  T_CATCH => '5.0',
 
37
  T_FINAL => '5.0',
38
  T_FINALLY => '5.5',
39
  T_GOTO => '5.3',
137
  }
138
 
139
  if ($this->supportsAbove($version)) {
140
+ $error = "'%s' is a reserved keyword introduced in PHP version %s and cannot be invoked as a function (%s)";
141
+ $errorCode = $this->stringToErrorCode($tokenContentLc).'Found';
142
+ $data = array(
143
  $tokenContentLc,
144
  $version,
145
  $tokens[$stackPtr]['type'],
146
  );
147
+
148
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
149
  }
150
  }//end process()
151
 
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNamesSniff.php CHANGED
@@ -228,18 +228,17 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesSniff extends PHPCompatibility_S
228
  $prevNonEmpty = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
229
  if ($prevNonEmpty !== false
230
  && $tokens[$prevNonEmpty]['type'] === 'T_NEW'
231
- && $tokens[$stackPtr]['type'] === 'T_ANON_CLASS'
232
  ) {
233
  return;
234
  }
235
 
236
  if ($this->supportsAbove($this->invalidNames[$nextContentLc])) {
237
- $error = "Function name, class name, namespace name or constant name can not be reserved keyword '%s' (since version %s)";
238
  $data = array(
239
  $tokens[$nextNonEmpty]['content'],
240
  $this->invalidNames[$nextContentLc],
241
  );
242
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
243
  }
244
 
245
  }//end processNonString()
@@ -277,20 +276,38 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesSniff extends PHPCompatibility_S
277
  return;
278
  }
279
 
280
- $defineName = strtolower($firstParam['raw']);
281
- $defineName = $this->stripQuotes($defineName);
282
 
283
- if (isset($this->invalidNames[$defineName]) && $this->supportsAbove($this->invalidNames[$defineName])) {
284
- $error = "Function name, class name, namespace name or constant name can not be reserved keyword '%s' (since PHP version %s)";
285
  $data = array(
286
  $defineName,
287
- $this->invalidNames[$defineName],
288
  );
289
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
290
  }
291
  }//end processString()
292
 
293
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
  /**
295
  * Check if the current token code is for a token which can be considered
296
  * the end of a (partial) use statement.
228
  $prevNonEmpty = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
229
  if ($prevNonEmpty !== false
230
  && $tokens[$prevNonEmpty]['type'] === 'T_NEW'
231
+ && ($tokens[$stackPtr]['type'] === 'T_ANON_CLASS' || $tokens[$stackPtr]['type'] === 'T_CLASS')
232
  ) {
233
  return;
234
  }
235
 
236
  if ($this->supportsAbove($this->invalidNames[$nextContentLc])) {
 
237
  $data = array(
238
  $tokens[$nextNonEmpty]['content'],
239
  $this->invalidNames[$nextContentLc],
240
  );
241
+ $this->addError($phpcsFile, $stackPtr, $tokens[$nextNonEmpty]['content'], $data);
242
  }
243
 
244
  }//end processNonString()
276
  return;
277
  }
278
 
279
+ $defineName = $this->stripQuotes($firstParam['raw']);
280
+ $defineNameLc = strtolower($defineName);
281
 
282
+ if (isset($this->invalidNames[$defineNameLc]) && $this->supportsAbove($this->invalidNames[$defineNameLc])) {
 
283
  $data = array(
284
  $defineName,
285
+ $this->invalidNames[$defineNameLc],
286
  );
287
+ $this->addError($phpcsFile, $stackPtr, $defineNameLc, $data);
288
  }
289
  }//end processString()
290
 
291
 
292
+ /**
293
+ * Add the error message.
294
+ *
295
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
296
+ * @param int $stackPtr The position of the current token in the
297
+ * stack passed in $tokens.
298
+ * @param string $content The token content found.
299
+ * @param array $data The data to pass into the error message.
300
+ *
301
+ * @return void
302
+ */
303
+ protected function addError($phpcsFile, $stackPtr, $content, $data)
304
+ {
305
+ $error = "Function name, class name, namespace name or constant name can not be reserved keyword '%s' (since version %s)";
306
+ $errorCode = $this->stringToErrorCode($content).'Found';
307
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
308
+ }
309
+
310
+
311
  /**
312
  * Check if the current token code is for a token which can be considered
313
  * the end of a (partial) use statement.
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php CHANGED
@@ -57,8 +57,11 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshiftSniff extends PHPComp
57
  return;
58
  }
59
 
60
- $error = 'Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0';
61
- $phpcsFile->addError($error, $hasMinusSign);
 
 
 
62
 
63
  }//end process()
64
 
57
  return;
58
  }
59
 
60
+ $phpcsFile->addError(
61
+ 'Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0',
62
+ $hasMinusSign,
63
+ 'Found'
64
+ );
65
 
66
  }//end process()
67
 
vendor/wimg/php-compatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php CHANGED
@@ -65,7 +65,11 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenSwitchWithMultipleDefaultBlocksSniff
65
  }
66
 
67
  if ($defaultCount > 1) {
68
- $phpcsFile->addError('Switch statements can not have multiple default blocks since PHP 7.0', $stackPtr);
 
 
 
 
69
  }
70
  }//end process()
71
 
65
  }
66
 
67
  if ($defaultCount > 1) {
68
+ $phpcsFile->addError(
69
+ 'Switch statements can not have multiple default blocks since PHP 7.0',
70
+ $stackPtr,
71
+ 'Found'
72
+ );
73
  }
74
  }//end process()
75
 
vendor/wimg/php-compatibility/Sniffs/PHP/InternalInterfacesSniff.php CHANGED
@@ -40,10 +40,8 @@ class PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff extends PHPCompatibili
40
  */
41
  public function register()
42
  {
43
- // Handle case-insensitivity of class names.
44
- $keys = array_keys( $this->internalInterfaces );
45
- $keys = array_map( 'strtolower', $keys );
46
- $this->internalInterfaces = array_combine( $keys, $this->internalInterfaces );
47
 
48
  return array(T_CLASS);
49
 
@@ -68,17 +66,20 @@ class PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff extends PHPCompatibili
68
  }
69
 
70
  foreach ($interfaces as $interface) {
71
- $lcInterface = strtolower($interface);
72
- if (isset($this->internalInterfaces[$lcInterface]) === true) {
73
- $error = 'The interface %s %s';
74
- $data = array(
 
75
  $interface,
76
- $this->internalInterfaces[$lcInterface],
77
  );
78
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
 
79
  }
80
  }
81
 
82
  }//end process()
83
 
 
84
  }//end class
40
  */
41
  public function register()
42
  {
43
+ // Handle case-insensitivity of interface names.
44
+ $this->internalInterfaces = $this->arrayKeysToLowercase($this->internalInterfaces);
 
 
45
 
46
  return array(T_CLASS);
47
 
66
  }
67
 
68
  foreach ($interfaces as $interface) {
69
+ $interfaceLc = strtolower($interface);
70
+ if (isset($this->internalInterfaces[$interfaceLc]) === true) {
71
+ $error = 'The interface %s %s';
72
+ $errorCode = $this->stringToErrorCode($interfaceLc).'Found';
73
+ $data = array(
74
  $interface,
75
+ $this->internalInterfaces[$interfaceLc],
76
  );
77
+
78
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
79
  }
80
  }
81
 
82
  }//end process()
83
 
84
+
85
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/LateStaticBindingSniff.php CHANGED
@@ -52,13 +52,19 @@ class PHPCompatibility_Sniffs_PHP_LateStaticBindingSniff extends PHPCompatibilit
52
  $inClass = $this->inClassScope($phpcsFile, $stackPtr, false);
53
 
54
  if ($inClass === true && $this->supportsBelow('5.2') === true) {
55
- $error = 'Late static binding is not supported in PHP 5.2 or earlier.';
56
- $phpcsFile->addError($error, $stackPtr, 'Found');
 
 
 
57
  }
58
 
59
  if ($inClass === false) {
60
- $error = 'Late static binding is not supported outside of class scope.';
61
- $phpcsFile->addError($error, $stackPtr, 'OutsideClassScope');
 
 
 
62
  }
63
 
64
  }//end process()
52
  $inClass = $this->inClassScope($phpcsFile, $stackPtr, false);
53
 
54
  if ($inClass === true && $this->supportsBelow('5.2') === true) {
55
+ $phpcsFile->addError(
56
+ 'Late static binding is not supported in PHP 5.2 or earlier.',
57
+ $stackPtr,
58
+ 'Found'
59
+ );
60
  }
61
 
62
  if ($inClass === false) {
63
+ $phpcsFile->addError(
64
+ 'Late static binding is not supported outside of class scope.',
65
+ $stackPtr,
66
+ 'OutsideClassScope'
67
+ );
68
  }
69
 
70
  }//end process()
vendor/wimg/php-compatibility/Sniffs/PHP/LongArraysSniff.php CHANGED
@@ -64,10 +64,11 @@ class PHPCompatibility_Sniffs_PHP_LongArraysSniff extends PHPCompatibility_Sniff
64
  return;
65
  }
66
 
67
- $tokens = $phpcsFile->getTokens();
 
68
 
69
  // Check if the variable name is in our blacklist.
70
- if (in_array(substr($tokens[$stackPtr]['content'], 1), $this->deprecated, true) === false) {
71
  return;
72
  }
73
 
@@ -100,17 +101,14 @@ class PHPCompatibility_Sniffs_PHP_LongArraysSniff extends PHPCompatibility_Sniff
100
  }
101
 
102
  // Still here, so throw an error/warning.
103
- $error = "The use of long predefined variables has been deprecated in 5.3%s; Found '%s'";
104
- $isError = $this->supportsAbove('5.4');
105
- $data = array(
106
- ($isError ? ' and removed in 5.4' : ''),
107
- $tokens[$stackPtr]['content']
 
108
  );
109
 
110
- if ($isError === true) {
111
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
112
- } else {
113
- $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
114
- }
115
  }
116
  }
64
  return;
65
  }
66
 
67
+ $tokens = $phpcsFile->getTokens();
68
+ $varName = substr($tokens[$stackPtr]['content'], 1);
69
 
70
  // Check if the variable name is in our blacklist.
71
+ if (in_array($varName, $this->deprecated, true) === false) {
72
  return;
73
  }
74
 
101
  }
102
 
103
  // Still here, so throw an error/warning.
104
+ $error = "The use of long predefined variables has been deprecated in PHP 5.3%s; Found '%s'";
105
+ $isError = $this->supportsAbove('5.4');
106
+ $errorCode = $this->stringToErrorCode($varName).'Found';
107
+ $data = array(
108
+ (($isError === true) ? ' and removed in PHP 5.4' : ''),
109
+ $tokens[$stackPtr]['content'],
110
  );
111
 
112
+ $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
 
 
 
 
113
  }
114
  }
vendor/wimg/php-compatibility/Sniffs/PHP/MbstringReplaceEModifierSniff.php CHANGED
@@ -73,21 +73,30 @@ class PHPCompatibility_Sniffs_PHP_MbstringReplaceEModifierSniff extends PHPCompa
73
  return;
74
  }
75
 
76
- $stringToken = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $optionsParam['start'], $optionsParam['end'] + 1);
77
  if ($stringToken === false) {
78
  // No string token found in the options parameter, so skip it (e.g. variable passed in).
79
  return;
80
  }
81
 
 
 
82
  /**
83
- * Get the content of any string tokens in the options parameter and remove the quotes.
84
  */
85
- $options = $this->stripQuotes($tokens[$stringToken]['content']);
86
- if ($stringToken !== $optionsParam['end']) {
87
- while ($stringToken = $phpcsFile->findNext(T_CONSTANT_ENCAPSED_STRING, $stringToken + 1, $optionsParam['end'] + 1)) {
88
- if ($tokens[$stringToken]['code'] === T_CONSTANT_ENCAPSED_STRING) {
89
- $options .= $this->stripQuotes($tokens[$stringToken]['content']);
90
- }
 
 
 
 
 
 
 
91
  }
92
  }
93
 
@@ -99,7 +108,7 @@ class PHPCompatibility_Sniffs_PHP_MbstringReplaceEModifierSniff extends PHPCompa
99
  $error .= ' Use mb_ereg_replace_callback() instead (PHP 5.4.1+).';
100
  }
101
 
102
- $phpcsFile->addWarning($error, $stackPtr, 'Found');
103
  }
104
 
105
  }//end process()
73
  return;
74
  }
75
 
76
+ $stringToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$stringTokens, $optionsParam['start'], $optionsParam['end'] + 1);
77
  if ($stringToken === false) {
78
  // No string token found in the options parameter, so skip it (e.g. variable passed in).
79
  return;
80
  }
81
 
82
+ $options = '';
83
+
84
  /**
85
+ * Get the content of any string tokens in the options parameter and remove the quotes and variables.
86
  */
87
+ for ($i = $stringToken; $i <= $optionsParam['end']; $i++) {
88
+ if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens, true) === false) {
89
+ continue;
90
+ }
91
+
92
+ $content = $this->stripQuotes($tokens[$i]['content']);
93
+ if ($tokens[$i]['code'] === T_DOUBLE_QUOTED_STRING) {
94
+ $content = $this->stripVariables($content);
95
+ }
96
+ $content = trim($content);
97
+
98
+ if (empty($content) === false) {
99
+ $options .= $content;
100
  }
101
  }
102
 
108
  $error .= ' Use mb_ereg_replace_callback() instead (PHP 5.4.1+).';
109
  }
110
 
111
+ $phpcsFile->addWarning($error, $stackPtr, 'Deprecated');
112
  }
113
 
114
  }//end process()
vendor/wimg/php-compatibility/Sniffs/PHP/NewAnonymousClassesSniff.php CHANGED
@@ -56,7 +56,11 @@ class PHPCompatibility_Sniffs_PHP_NewAnonymousClassesSniff extends PHPCompatibil
56
  return;
57
  }
58
 
59
- $phpcsFile->addError('Anonymous classes are not supported in PHP 5.6 or earlier', $stackPtr);
 
 
 
 
60
 
61
  }//end process()
62
 
56
  return;
57
  }
58
 
59
+ $phpcsFile->addError(
60
+ 'Anonymous classes are not supported in PHP 5.6 or earlier',
61
+ $stackPtr,
62
+ 'Found'
63
+ );
64
 
65
  }//end process()
66
 
vendor/wimg/php-compatibility/Sniffs/PHP/NewClassesSniff.php CHANGED
@@ -19,7 +19,7 @@
19
  * @version 1.0.0
20
  * @copyright 2013 Cu.be Solutions bvba
21
  */
22
- class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
23
  {
24
 
25
  /**
@@ -194,9 +194,7 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
194
  public function register()
195
  {
196
  // Handle case-insensitivity of class names.
197
- $keys = array_keys( $this->newClasses );
198
- $keys = array_map( 'strtolower', $keys );
199
- $this->newClasses = array_combine( $keys, $this->newClasses );
200
 
201
  return array(
202
  T_NEW,
@@ -246,45 +244,37 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Sniff
246
  return;
247
  }
248
 
249
- $this->addError($phpcsFile, $stackPtr, $className);
 
 
 
 
250
 
251
  }//end process()
252
 
253
 
254
  /**
255
- * Generates the error or warning for this sniff.
256
  *
257
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
258
- * @param int $stackPtr The position of the function
259
- * in the token array.
260
- * @param string $className The name of the class.
261
  *
262
- * @return void
263
  */
264
- protected function addError($phpcsFile, $stackPtr, $className)
265
  {
266
- $error = '';
267
- $isError = false;
268
- $classNameLc = strtolower($className);
269
 
270
- foreach ($this->newClasses[$classNameLc] as $version => $present) {
271
- if ($this->supportsBelow($version)) {
272
- if ($present === false) {
273
- $isError = true;
274
- $error .= 'not present in PHP version ' . $version . ' or earlier';
275
- }
276
- }
277
- }
278
- if (strlen($error) > 0) {
279
- $error = 'The built-in class ' . $className . ' is ' . $error;
280
 
281
- if ($isError === true) {
282
- $phpcsFile->addError($error, $stackPtr);
283
- } else {
284
- $phpcsFile->addWarning($error, $stackPtr);
285
- }
286
- }
 
 
 
287
 
288
- }//end addError()
289
 
290
  }//end class
19
  * @version 1.0.0
20
  * @copyright 2013 Cu.be Solutions bvba
21
  */
22
+ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_AbstractNewFeatureSniff
23
  {
24
 
25
  /**
194
  public function register()
195
  {
196
  // Handle case-insensitivity of class names.
197
+ $this->newClasses = $this->arrayKeysToLowercase($this->newClasses);
 
 
198
 
199
  return array(
200
  T_NEW,
244
  return;
245
  }
246
 
247
+ $itemInfo = array(
248
+ 'name' => $className,
249
+ 'nameLc' => $classNameLc,
250
+ );
251
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
252
 
253
  }//end process()
254
 
255
 
256
  /**
257
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
258
  *
259
+ * @param array $itemInfo Base information about the item.
 
 
 
260
  *
261
+ * @return array Version and other information about the item.
262
  */
263
+ public function getItemArray(array $itemInfo)
264
  {
265
+ return $this->newClasses[$itemInfo['nameLc']];
266
+ }
 
267
 
 
 
 
 
 
 
 
 
 
 
268
 
269
+ /**
270
+ * Get the error message template for this sniff.
271
+ *
272
+ * @return string
273
+ */
274
+ protected function getErrorMsgTemplate()
275
+ {
276
+ return 'The built-in class '.parent::getErrorMsgTemplate();
277
+ }
278
 
 
279
 
280
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewClosureSniff.php CHANGED
@@ -45,7 +45,11 @@ class PHPCompatibility_Sniffs_PHP_NewClosureSniff extends PHPCompatibility_Sniff
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
  if ($this->supportsBelow('5.2')) {
48
- $phpcsFile->addError('Closures / anonymous functions are not available in PHP 5.2 or earlier', $stackPtr);
 
 
 
 
49
  }
50
  }//end process()
51
 
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
  if ($this->supportsBelow('5.2')) {
48
+ $phpcsFile->addError(
49
+ 'Closures / anonymous functions are not available in PHP 5.2 or earlier',
50
+ $stackPtr,
51
+ 'Found'
52
+ );
53
  }
54
  }//end process()
55
 
vendor/wimg/php-compatibility/Sniffs/PHP/NewConstVisibilitySniff.php CHANGED
@@ -59,8 +59,8 @@ class PHPCompatibility_Sniffs_PHP_NewConstVisibilitySniff extends PHPCompatibili
59
  if ($this->tokenHasScope($phpcsFile, $stackPtr, array(T_CLASS, T_INTERFACE)) === true && $this->supportsBelow('7.0') === true) {
60
  $error = 'Visibility indicators for class constants are not supported in PHP 7.0 or earlier. Found "%s const"';
61
  $data = array($tokens[$prevToken]['content']);
62
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
63
 
 
64
  }
65
 
66
  }//end process()
59
  if ($this->tokenHasScope($phpcsFile, $stackPtr, array(T_CLASS, T_INTERFACE)) === true && $this->supportsBelow('7.0') === true) {
60
  $error = 'Visibility indicators for class constants are not supported in PHP 7.0 or earlier. Found "%s const"';
61
  $data = array($tokens[$prevToken]['content']);
 
62
 
63
+ $phpcsFile->addError($error, $stackPtr, 'Found', $data);
64
  }
65
 
66
  }//end process()
vendor/wimg/php-compatibility/Sniffs/PHP/NewExecutionDirectivesSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompatibility_Sniff
18
  {
19
 
20
  /**
@@ -111,11 +111,15 @@ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompati
111
  implode(', ', array_keys($this->newDirectives)),
112
  $directiveContent,
113
  );
 
114
  $phpcsFile->addError($error, $stackPtr, 'InvalidDirectiveFound', $data);
115
  }
116
  else {
117
  // Check for valid directive for version.
118
- $this->maybeAddError($phpcsFile, $stackPtr, $directiveContent);
 
 
 
119
 
120
  // Check for valid directive value.
121
  $valuePtr = $phpcsFile->findNext($this->ignoreTokens, $directivePtr + 1, $closeParenthesis, true);
@@ -130,57 +134,115 @@ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompati
130
 
131
 
132
  /**
133
- * Generates a error or warning for this sniff.
134
  *
135
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
136
- * @param int $stackPtr The position of the declare statement
137
- * in the token array.
138
- * @param string $directive The directive.
139
  *
140
- * @return void
141
  */
142
- protected function maybeAddError($phpcsFile, $stackPtr, $directive)
143
  {
144
- $isError = false;
145
- $notInVersion = '';
146
- $conditionalVersion = '';
147
- foreach ($this->newDirectives[$directive] as $version => $present) {
148
- if (strpos($version, 'valid_') === false && $this->supportsBelow($version)) {
149
- if ($present === false) {
150
- $isError = true;
151
- $notInVersion = $version;
152
- }
153
- else if (is_string($present)) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  // We cannot test for compilation option (ok, except by scraping the output of phpinfo...).
155
- $conditionalVersion = $version;
 
156
  }
157
  }
158
  }
159
- if ($notInVersion !== '' || $conditionalVersion !== '') {
160
- if ($isError === true && $notInVersion !== '') {
161
- $error = 'Directive %s is not present in PHP version %s or earlier';
162
- $errorCode = $directive . 'Found';
163
- $data = array(
164
- $directive,
165
- $notInVersion,
166
- );
167
-
168
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
169
- }
170
- else if($conditionalVersion !== '') {
171
- $error = 'Directive %s is present in PHP version %s but will be disregarded unless PHP is compiled with %s';
172
- $errorCode = $directive . 'Found';
173
- $data = array(
174
- $directive,
175
- $conditionalVersion,
176
- $this->newDirectives[$directive][$conditionalVersion],
177
- );
178
-
179
- $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
180
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
181
  }
182
 
183
- }//end maybeAddError()
184
 
185
 
186
  /**
@@ -198,7 +260,7 @@ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompati
198
  $tokens = $phpcsFile->getTokens();
199
 
200
  $value = $tokens[$stackPtr]['content'];
201
- if ($tokens[$stackPtr]['code'] === T_CONSTANT_ENCAPSED_STRING) {
202
  $value = $this->stripQuotes($value);
203
  }
204
 
@@ -216,12 +278,14 @@ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompati
216
  }
217
 
218
  if ($isError === true) {
219
- $error = 'The execution directive %s does not seem to have a valid value. Please review. Found: %s';
220
- $data = array(
 
221
  $directive,
222
  $value,
223
  );
224
- $phpcsFile->addWarning($error, $stackPtr, 'InvalidDirectiveValueFound', $data);
 
225
  }
226
  }// addErrorOnInvalidValue()
227
 
@@ -270,4 +334,5 @@ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompati
270
  }
271
  }
272
 
 
273
  }//end class
14
  * @package PHPCompatibility
15
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompatibility_AbstractNewFeatureSniff
18
  {
19
 
20
  /**
111
  implode(', ', array_keys($this->newDirectives)),
112
  $directiveContent,
113
  );
114
+
115
  $phpcsFile->addError($error, $stackPtr, 'InvalidDirectiveFound', $data);
116
  }
117
  else {
118
  // Check for valid directive for version.
119
+ $itemInfo = array(
120
+ 'name' => $directiveContent,
121
+ );
122
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
123
 
124
  // Check for valid directive value.
125
  $valuePtr = $phpcsFile->findNext($this->ignoreTokens, $directivePtr + 1, $closeParenthesis, true);
134
 
135
 
136
  /**
137
+ * Determine whether an error/warning should be thrown for an item based on collected information.
138
  *
139
+ * @param array $errorInfo Detail information about an item.
 
 
 
140
  *
141
+ * @return bool
142
  */
143
+ protected function shouldThrowError(array $errorInfo)
144
  {
145
+ return ($errorInfo['not_in_version'] !== '' || $errorInfo['conditional_version'] !== '');
146
+ }
147
+
148
+
149
+ /**
150
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
151
+ *
152
+ * @param array $itemInfo Base information about the item.
153
+ *
154
+ * @return array Version and other information about the item.
155
+ */
156
+ public function getItemArray(array $itemInfo)
157
+ {
158
+ return $this->newDirectives[$itemInfo['name']];
159
+ }
160
+
161
+
162
+ /**
163
+ * Get an array of the non-PHP-version array keys used in a sub-array.
164
+ *
165
+ * @return array
166
+ */
167
+ protected function getNonVersionArrayKeys()
168
+ {
169
+ return array(
170
+ 'valid_value_callback',
171
+ 'valid_values',
172
+ );
173
+ }
174
+
175
+
176
+ /**
177
+ * Retrieve the relevant detail (version) information for use in an error message.
178
+ *
179
+ * @param array $itemArray Version and other information about the item.
180
+ * @param array $itemInfo Base information about the item.
181
+ *
182
+ * @return array
183
+ */
184
+ public function getErrorInfo(array $itemArray, array $itemInfo)
185
+ {
186
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
187
+ $errorInfo['conditional_version'] = '';
188
+ $errorInfo['condition'] = '';
189
+
190
+ $versionArray = $this->getVersionArray($itemArray);
191
+
192
+ if (empty($versionArray) === false) {
193
+ foreach ($versionArray as $version => $present) {
194
+ if (is_string($present) === true && $this->supportsBelow($version) === true) {
195
  // We cannot test for compilation option (ok, except by scraping the output of phpinfo...).
196
+ $errorInfo['conditional_version'] = $version;
197
+ $errorInfo['condition'] = $present;
198
  }
199
  }
200
  }
201
+
202
+ return $errorInfo;
203
+ }
204
+
205
+
206
+ /**
207
+ * Get the error message template for this sniff.
208
+ *
209
+ * @return string
210
+ */
211
+ protected function getErrorMsgTemplate()
212
+ {
213
+ return 'Directive '.parent::getErrorMsgTemplate();
214
+ }
215
+
216
+
217
+ /**
218
+ * Generates the error or warning for this item.
219
+ *
220
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
221
+ * @param int $stackPtr The position of the relevant token in
222
+ * the stack.
223
+ * @param array $itemInfo Base information about the item.
224
+ * @param array $errorInfo Array with detail (version) information
225
+ * relevant to the item.
226
+ *
227
+ * @return void
228
+ */
229
+ public function addError(PHP_CodeSniffer_File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
230
+ {
231
+ if ($errorInfo['not_in_version'] !== '') {
232
+ parent::addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo);
233
+ } else if ($errorInfo['conditional_version'] !== '') {
234
+ $error = 'Directive %s is present in PHP version %s but will be disregarded unless PHP is compiled with %s';
235
+ $errorCode = $this->stringToErrorCode($itemInfo['name']).'WithConditionFound';
236
+ $data = array(
237
+ $itemInfo['name'],
238
+ $errorInfo['conditional_version'],
239
+ $errorInfo['condition'],
240
+ );
241
+
242
+ $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
243
  }
244
 
245
+ }//end addError()
246
 
247
 
248
  /**
260
  $tokens = $phpcsFile->getTokens();
261
 
262
  $value = $tokens[$stackPtr]['content'];
263
+ if (in_array($tokens[$stackPtr]['code'], PHP_CodeSniffer_Tokens::$stringTokens, true) === true) {
264
  $value = $this->stripQuotes($value);
265
  }
266
 
278
  }
279
 
280
  if ($isError === true) {
281
+ $error = 'The execution directive %s does not seem to have a valid value. Please review. Found: %s';
282
+ $errorCode = $this->stringToErrorCode($directive).'InvalidValueFound';
283
+ $data = array(
284
  $directive,
285
  $value,
286
  );
287
+
288
+ $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
289
  }
290
  }// addErrorOnInvalidValue()
291
 
334
  }
335
  }
336
 
337
+
338
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewFunctionArrayDereferencingSniff.php CHANGED
@@ -75,7 +75,11 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionArrayDereferencingSniff extends PHP
75
  $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
76
  $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($closeParenthesis + 1), null, true, null, true);
77
  if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['type'] === 'T_OPEN_SQUARE_BRACKET') {
78
- $phpcsFile->addError('Function array dereferencing is not present in PHP version 5.3 or earlier', $nextNonEmpty);
 
 
 
 
79
  }
80
 
81
  }//end process()
75
  $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer'];
76
  $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($closeParenthesis + 1), null, true, null, true);
77
  if ($nextNonEmpty !== false && $tokens[$nextNonEmpty]['type'] === 'T_OPEN_SQUARE_BRACKET') {
78
+ $phpcsFile->addError(
79
+ 'Function array dereferencing is not present in PHP version 5.3 or earlier',
80
+ $nextNonEmpty,
81
+ 'Found'
82
+ );
83
  }
84
 
85
  }//end process()
vendor/wimg/php-compatibility/Sniffs/PHP/NewFunctionParametersSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatibility_Sniff
18
  {
19
  /**
20
  * A list of new functions, not present in older versions.
@@ -730,13 +730,6 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
730
  );
731
 
732
 
733
- /**
734
- *
735
- * @var array
736
- */
737
- private $newFunctionParametersNames;
738
-
739
-
740
  /**
741
  * Returns an array of tokens this test wants to listen for.
742
  *
@@ -744,9 +737,8 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
744
  */
745
  public function register()
746
  {
747
- // Everyone has had a chance to figure out what functions
748
- // they want to check for, so now we can cache out the list.
749
- $this->newFunctionParametersNames = array_keys($this->newFunctionParameters);
750
 
751
  return array(T_STRING);
752
  }//end register()
@@ -777,9 +769,10 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
777
  return;
778
  }
779
 
780
- $function = strtolower($tokens[$stackPtr]['content']);
 
781
 
782
- if (in_array($function, $this->newFunctionParametersNames) === false) {
783
  return;
784
  }
785
 
@@ -792,9 +785,14 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
792
  $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
793
  $parameterOffsetFound = $parameterCount - 1;
794
 
795
- foreach($this->newFunctionParameters[$function] as $offset => $parameterDetails) {
796
  if ($offset <= $parameterOffsetFound) {
797
- $this->addError($phpcsFile, $openParenthesis, $function, $offset);
 
 
 
 
 
798
  }
799
  }
800
 
@@ -802,39 +800,86 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib
802
 
803
 
804
  /**
805
- * Generates the error or warning for this sniff.
806
  *
807
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
808
- * @param int $stackPtr The position of the function
809
- * in the token array.
810
- * @param string $function The name of the function.
811
- * @param int $parameterLocation The parameter position within the function call.
812
  *
813
- * @return void
814
  */
815
- protected function addError($phpcsFile, $stackPtr, $function, $parameterLocation)
816
  {
817
- $error = '';
 
818
 
819
- $isError = false;
820
- foreach ($this->newFunctionParameters[$function][$parameterLocation] as $version => $present) {
821
- if ($version != 'name' && $present === false && $this->supportsBelow($version)) {
822
- $isError = true;
823
- $error .= 'in PHP version ' . $version . ' or earlier';
824
- break;
825
- }
826
- }
827
 
828
- if (strlen($error) > 0) {
829
- $error = 'The function ' . $function . ' does not have a parameter "' . $this->newFunctionParameters[$function][$parameterLocation]['name'] . '" ' . $error;
 
 
 
 
 
 
 
830
 
831
- if ($isError === true) {
832
- $phpcsFile->addError($error, $stackPtr);
833
- } else {
834
- $phpcsFile->addWarning($error, $stackPtr);
835
- }
836
- }
837
 
838
- }//end addError()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
839
 
840
  }//end class
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatibility_AbstractNewFeatureSniff
18
  {
19
  /**
20
  * A list of new functions, not present in older versions.
730
  );
731
 
732
 
 
 
 
 
 
 
 
733
  /**
734
  * Returns an array of tokens this test wants to listen for.
735
  *
737
  */
738
  public function register()
739
  {
740
+ // Handle case-insensitivity of function names.
741
+ $this->newFunctionParameters = $this->arrayKeysToLowercase($this->newFunctionParameters);
 
742
 
743
  return array(T_STRING);
744
  }//end register()
769
  return;
770
  }
771
 
772
+ $function = $tokens[$stackPtr]['content'];
773
+ $functionLc = strtolower($function);
774
 
775
+ if (isset($this->newFunctionParameters[$functionLc]) === false) {
776
  return;
777
  }
778
 
785
  $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
786
  $parameterOffsetFound = $parameterCount - 1;
787
 
788
+ foreach($this->newFunctionParameters[$functionLc] as $offset => $parameterDetails) {
789
  if ($offset <= $parameterOffsetFound) {
790
+ $itemInfo = array(
791
+ 'name' => $function,
792
+ 'nameLc' => $functionLc,
793
+ 'offset' => $offset,
794
+ );
795
+ $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
796
  }
797
  }
798
 
800
 
801
 
802
  /**
803
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
804
  *
805
+ * @param array $itemInfo Base information about the item.
 
 
 
 
806
  *
807
+ * @return array Version and other information about the item.
808
  */
809
+ public function getItemArray(array $itemInfo)
810
  {
811
+ return $this->newFunctionParameters[$itemInfo['nameLc']][$itemInfo['offset']];
812
+ }
813
 
 
 
 
 
 
 
 
 
814
 
815
+ /**
816
+ * Get an array of the non-PHP-version array keys used in a sub-array.
817
+ *
818
+ * @return array
819
+ */
820
+ protected function getNonVersionArrayKeys()
821
+ {
822
+ return array('name');
823
+ }
824
 
 
 
 
 
 
 
825
 
826
+ /**
827
+ * Retrieve the relevant detail (version) information for use in an error message.
828
+ *
829
+ * @param array $itemArray Version and other information about the item.
830
+ * @param array $itemInfo Base information about the item.
831
+ *
832
+ * @return array
833
+ */
834
+ public function getErrorInfo(array $itemArray, array $itemInfo)
835
+ {
836
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
837
+ $errorInfo['paramName'] = $itemArray['name'];
838
+
839
+ return $errorInfo;
840
+ }
841
+
842
+
843
+ /**
844
+ * Get the item name to be used for the creation of the error code.
845
+ *
846
+ * @param array $itemInfo Base information about the item.
847
+ * @param array $errorInfo Detail information about an item.
848
+ *
849
+ * @return string
850
+ */
851
+ protected function getItemName(array $itemInfo, array $errorInfo)
852
+ {
853
+ return $itemInfo['name'].'_'.$errorInfo['paramName'];
854
+ }
855
+
856
+
857
+ /**
858
+ * Get the error message template for this sniff.
859
+ *
860
+ * @return string
861
+ */
862
+ protected function getErrorMsgTemplate()
863
+ {
864
+ return 'The function %s() does not have a parameter "%s" in PHP version %s or earlier';
865
+ }
866
+
867
+
868
+ /**
869
+ * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
870
+ *
871
+ * @param array $data The error data array which was created.
872
+ * @param array $itemInfo Base information about the item this error message applied to.
873
+ * @param array $errorInfo Detail information about an item this error message applied to.
874
+ *
875
+ * @return array
876
+ */
877
+ protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
878
+ {
879
+ array_shift($data);
880
+ array_unshift($data, $itemInfo['name'], $errorInfo['paramName']);
881
+ return $data;
882
+ }
883
+
884
 
885
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewFunctionsSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sniff
18
  {
19
  /**
20
  * A list of new functions, not present in older versions.
@@ -1242,13 +1242,6 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1242
  );
1243
 
1244
 
1245
- /**
1246
- *
1247
- * @var array
1248
- */
1249
- private $newFunctionNames;
1250
-
1251
-
1252
  /**
1253
  * Returns an array of tokens this test wants to listen for.
1254
  *
@@ -1256,11 +1249,8 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1256
  */
1257
  public function register()
1258
  {
1259
- // Everyone has had a chance to figure out what new functions
1260
- // they want to check for, so now we can cache out the list.
1261
- $this->newFunctionNames = array_keys($this->newFunctions);
1262
- $this->newFunctionNames = array_map('strtolower', $this->newFunctionNames);
1263
- $this->newFunctions = array_combine($this->newFunctionNames, $this->newFunctions);
1264
 
1265
  return array(T_STRING);
1266
 
@@ -1296,51 +1286,44 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Sni
1296
  return;
1297
  }
1298
 
1299
- $function = strtolower($tokens[$stackPtr]['content']);
 
1300
 
1301
- if (in_array($function, $this->newFunctionNames) === false) {
1302
  return;
1303
  }
1304
 
1305
- $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['content']);
 
 
 
 
1306
 
1307
  }//end process()
1308
 
1309
 
1310
  /**
1311
- * Generates the error or warning for this sniff.
1312
  *
1313
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
1314
- * @param int $stackPtr The position of the function
1315
- * in the token array.
1316
- * @param string $function The name of the function.
1317
  *
1318
- * @return void
1319
  */
1320
- protected function addError($phpcsFile, $stackPtr, $function)
1321
  {
1322
- $functionLc = strtolower($function);
1323
- $error = '';
1324
 
1325
- $isError = false;
1326
- foreach ($this->newFunctions[$functionLc] as $version => $present) {
1327
- if ($this->supportsBelow($version)) {
1328
- if ($present === false) {
1329
- $isError = true;
1330
- $error .= 'not present in PHP version ' . $version . ' or earlier';
1331
- }
1332
- }
1333
- }
1334
- if (strlen($error) > 0) {
1335
- $error = 'The function ' . $function . ' is ' . $error;
1336
 
1337
- if ($isError === true) {
1338
- $phpcsFile->addError($error, $stackPtr);
1339
- } else {
1340
- $phpcsFile->addWarning($error, $stackPtr);
1341
- }
1342
- }
 
 
 
1343
 
1344
- }//end addError()
1345
 
1346
  }//end class
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_AbstractNewFeatureSniff
18
  {
19
  /**
20
  * A list of new functions, not present in older versions.
1242
  );
1243
 
1244
 
 
 
 
 
 
 
 
1245
  /**
1246
  * Returns an array of tokens this test wants to listen for.
1247
  *
1249
  */
1250
  public function register()
1251
  {
1252
+ // Handle case-insensitivity of function names.
1253
+ $this->newFunctions = $this->arrayKeysToLowercase($this->newFunctions);
 
 
 
1254
 
1255
  return array(T_STRING);
1256
 
1286
  return;
1287
  }
1288
 
1289
+ $function = $tokens[$stackPtr]['content'];
1290
+ $functionLc = strtolower($function);
1291
 
1292
+ if (isset($this->newFunctions[$functionLc]) === false) {
1293
  return;
1294
  }
1295
 
1296
+ $itemInfo = array(
1297
+ 'name' => $function,
1298
+ 'nameLc' => $functionLc,
1299
+ );
1300
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
1301
 
1302
  }//end process()
1303
 
1304
 
1305
  /**
1306
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
1307
  *
1308
+ * @param array $itemInfo Base information about the item.
 
 
 
1309
  *
1310
+ * @return array Version and other information about the item.
1311
  */
1312
+ public function getItemArray(array $itemInfo)
1313
  {
1314
+ return $this->newFunctions[$itemInfo['nameLc']];
1315
+ }
1316
 
 
 
 
 
 
 
 
 
 
 
 
1317
 
1318
+ /**
1319
+ * Get the error message template for this sniff.
1320
+ *
1321
+ * @return string
1322
+ */
1323
+ protected function getErrorMsgTemplate()
1324
+ {
1325
+ return 'The function %s() is not present in PHP version %s or earlier';
1326
+ }
1327
 
 
1328
 
1329
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewGroupUseDeclarationsSniff.php CHANGED
@@ -25,10 +25,10 @@ class PHPCompatibility_Sniffs_PHP_NewGroupUseDeclarationsSniff extends PHPCompat
25
  */
26
  public function register()
27
  {
28
- if (version_compare(PHP_CodeSniffer::VERSION, '2.3.4') >= 0) {
29
  return array(T_OPEN_USE_GROUP);
30
  } else {
31
- return array();
32
  }
33
  }//end register()
34
 
@@ -44,8 +44,32 @@ class PHPCompatibility_Sniffs_PHP_NewGroupUseDeclarationsSniff extends PHPCompat
44
  */
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
- if ($this->supportsBelow('5.6')) {
48
- $phpcsFile->addError('Group use declarations are not allowed in PHP 5.6 or earlier', $stackPtr);
49
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  }//end process()
51
  }//end class
25
  */
26
  public function register()
27
  {
28
+ if (defined('T_OPEN_USE_GROUP')) {
29
  return array(T_OPEN_USE_GROUP);
30
  } else {
31
+ return array(T_USE);
32
  }
33
  }//end register()
34
 
44
  */
45
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
46
  {
47
+ if ($this->supportsBelow('5.6') === false) {
48
+ return;
49
  }
50
+
51
+ $tokens = $phpcsFile->getTokens();
52
+ $token = $tokens[$stackPtr];
53
+
54
+ // Deal with PHPCS pre-2.6.0.
55
+ if ($token['code'] === T_USE) {
56
+ $hasCurlyBrace = $phpcsFile->findNext(T_OPEN_CURLY_BRACKET, ($stackPtr + 1), null, false, null, true);
57
+ if ($hasCurlyBrace === false) {
58
+ return;
59
+ }
60
+
61
+ $prevToken = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($hasCurlyBrace - 1), null, true);
62
+ if ($prevToken === false || $tokens[$prevToken]['code'] !== T_NS_SEPARATOR) {
63
+ return;
64
+ }
65
+ }
66
+
67
+ // Still here ? In that case, it is a group use statement.
68
+ $phpcsFile->addError(
69
+ 'Group use declarations are not allowed in PHP 5.6 or earlier',
70
+ $stackPtr,
71
+ 'Found'
72
+ );
73
+
74
  }//end process()
75
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewHashAlgorithmsSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_NewHashAlgorithmsSniff extends PHPCompatibility_Sniff
18
  {
19
  /**
20
  * A list of new hash algorithms, not present in older versions.
@@ -106,63 +106,36 @@ class PHPCompatibility_Sniffs_PHP_NewHashAlgorithmsSniff extends PHPCompatibilit
106
  }
107
 
108
  // Check if the algorithm used is new.
109
- $errorInfo = $this->getErrorInfo($algo);
110
-
111
- if ($errorInfo['not_in_version'] !== '') {
112
- $this->addError($phpcsFile, $stackPtr, $algo, $errorInfo);
113
- }
114
 
115
  }//end process()
116
 
117
 
118
  /**
119
- * Retrieve the relevant (version) information for the error message.
120
  *
121
- * @param string $algorithm The name of the algorithm.
122
  *
123
- * @return array
124
  */
125
- protected function getErrorInfo($algorithm)
126
  {
127
- $errorInfo = array(
128
- 'not_in_version' => '',
129
- );
130
-
131
- foreach ($this->newAlgorithms[$algorithm] as $version => $present) {
132
- if ($present === false && $this->supportsBelow($version)) {
133
- $errorInfo['not_in_version'] = $version;
134
- }
135
- }
136
-
137
- return $errorInfo;
138
-
139
- }//end getErrorInfo()
140
 
141
 
142
  /**
143
- * Generates the error or warning for this sniff.
144
- *
145
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
146
- * @param int $stackPtr The position of the function
147
- * in the token array.
148
- * @param string $algorithm The name of the algorithm.
149
- * @param array $errorInfo Array with details about the versions
150
- * in which the algorithm was deprecated
151
- * and/or removed.
152
  *
153
- * @return void
154
  */
155
- protected function addError($phpcsFile, $stackPtr, $algorithm, $errorInfo)
156
  {
157
- $error = 'The %s hash algorithm is not present in PHP version %s or earlier ';
158
- $errorCode = $algorithm . 'Found';
159
- $data = array(
160
- $algorithm,
161
- $errorInfo['not_in_version'],
162
- );
163
-
164
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
165
 
166
- }//end addError()
167
 
168
  }//end class
14
  * @package PHPCompatibility
15
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_NewHashAlgorithmsSniff extends PHPCompatibility_AbstractNewFeatureSniff
18
  {
19
  /**
20
  * A list of new hash algorithms, not present in older versions.
106
  }
107
 
108
  // Check if the algorithm used is new.
109
+ $itemInfo = array(
110
+ 'name' => $algo,
111
+ );
112
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
 
113
 
114
  }//end process()
115
 
116
 
117
  /**
118
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
119
  *
120
+ * @param array $itemInfo Base information about the item.
121
  *
122
+ * @return array Version and other information about the item.
123
  */
124
+ public function getItemArray(array $itemInfo)
125
  {
126
+ return $this->newAlgorithms[$itemInfo['name']];
127
+ }
 
 
 
 
 
 
 
 
 
 
 
128
 
129
 
130
  /**
131
+ * Get the error message template for this sniff.
 
 
 
 
 
 
 
 
132
  *
133
+ * @return string
134
  */
135
+ protected function getErrorMsgTemplate()
136
  {
137
+ return 'The %s hash algorithm is not present in PHP version %s or earlier';
138
+ }
 
 
 
 
 
 
139
 
 
140
 
141
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewIniDirectivesSniff.php CHANGED
@@ -20,11 +20,14 @@
20
  * @author Wim Godden <wim.godden@cu.be>
21
  * @copyright 2013 Cu.be Solutions bvba
22
  */
23
- class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility_Sniff
24
  {
25
  /**
26
  * A list of new INI directives
27
  *
 
 
 
28
  * @var array(string)
29
  */
30
  protected $newIniDirectives = array(
@@ -496,12 +499,12 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
496
  return;
497
  }
498
 
499
- $function = strtolower($tokens[$stackPtr]['content']);
500
- if ($function != 'ini_get' && $function != 'ini_set') {
501
  return;
502
  }
503
 
504
- $iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 1);
505
  if ($iniToken === false) {
506
  return;
507
  }
@@ -511,33 +514,112 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility
511
  return;
512
  }
513
 
514
- $notInVersion = '';
515
- foreach ($this->newIniDirectives[$filteredToken] as $version => $present) {
516
- if ($version !== 'alternative' && $present === false && $this->supportsBelow($version)) {
517
- $notInVersion = $version;
518
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
519
  }
520
 
521
- if ($notInVersion !== '') {
522
- $error = "INI directive '%s' is not present in PHP version %s or earlier";
523
- $isError = ($function !== 'ini_get') ? true : false;
524
- $data = array(
525
- $filteredToken,
526
- $notInVersion
527
- );
528
- if (isset($this->newIniDirectives[$filteredToken]['alternative'])) {
529
- $error .= ". This directive was previously called '%s'.";
530
- $data[] = $this->newIniDirectives[$filteredToken]['alternative'];
531
- }
532
-
533
- if ($isError === true) {
534
- $phpcsFile->addError($error, $iniToken['end'], 'Found', $data);
535
- } else {
536
- $phpcsFile->addWarning($error, $iniToken['end'], 'Found', $data);
537
- }
538
  }
539
 
540
- }//end process()
 
541
 
542
 
543
  }//end class
20
  * @author Wim Godden <wim.godden@cu.be>
21
  * @copyright 2013 Cu.be Solutions bvba
22
  */
23
+ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility_AbstractNewFeatureSniff
24
  {
25
  /**
26
  * A list of new INI directives
27
  *
28
+ * The array lists : version number with false (not present) or true (present).
29
+ * If's sufficient to list the first version where the ini directive appears.
30
+ *
31
  * @var array(string)
32
  */
33
  protected $newIniDirectives = array(
499
  return;
500
  }
501
 
502
+ $functionLc = strtolower($tokens[$stackPtr]['content']);
503
+ if (isset($this->iniFunctions[$functionLc]) === false) {
504
  return;
505
  }
506
 
507
+ $iniToken = $this->getFunctionCallParameter($phpcsFile, $stackPtr, $this->iniFunctions[$functionLc]);
508
  if ($iniToken === false) {
509
  return;
510
  }
514
  return;
515
  }
516
 
517
+ $itemInfo = array(
518
+ 'name' => $filteredToken,
519
+ 'functionLc' => $functionLc,
520
+ );
521
+ $this->handleFeature($phpcsFile, $iniToken['end'], $itemInfo);
522
+
523
+ }//end process()
524
+
525
+
526
+ /**
527
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
528
+ *
529
+ * @param array $itemInfo Base information about the item.
530
+ *
531
+ * @return array Version and other information about the item.
532
+ */
533
+ public function getItemArray(array $itemInfo)
534
+ {
535
+ return $this->newIniDirectives[$itemInfo['name']];
536
+ }
537
+
538
+
539
+ /**
540
+ * Get an array of the non-PHP-version array keys used in a sub-array.
541
+ *
542
+ * @return array
543
+ */
544
+ protected function getNonVersionArrayKeys()
545
+ {
546
+ return array('alternative');
547
+ }
548
+
549
+
550
+ /**
551
+ * Retrieve the relevant detail (version) information for use in an error message.
552
+ *
553
+ * @param array $itemArray Version and other information about the item.
554
+ * @param array $itemInfo Base information about the item.
555
+ *
556
+ * @return array
557
+ */
558
+ public function getErrorInfo(array $itemArray, array $itemInfo)
559
+ {
560
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
561
+ $errorInfo['alternative'] = '';
562
+
563
+ if (isset($itemArray['alternative']) === true) {
564
+ $errorInfo['alternative'] = $itemArray['alternative'];
565
+ }
566
+
567
+ // Lower error level to warning if the function used was ini_get.
568
+ if ($errorInfo['error'] === true && $itemInfo['functionLc'] === 'ini_get') {
569
+ $errorInfo['error'] = false;
570
+ }
571
+
572
+ return $errorInfo;
573
+ }
574
+
575
+
576
+ /**
577
+ * Get the error message template for this sniff.
578
+ *
579
+ * @return string
580
+ */
581
+ protected function getErrorMsgTemplate()
582
+ {
583
+ return "INI directive '%s' is not present in PHP version %s or earlier";
584
+ }
585
+
586
+
587
+ /**
588
+ * Allow for concrete child classes to filter the error message before it's passed to PHPCS.
589
+ *
590
+ * @param string $error The error message which was created.
591
+ * @param array $itemInfo Base information about the item this error message applied to.
592
+ * @param array $errorInfo Detail information about an item this error message applied to.
593
+ *
594
+ * @return string
595
+ */
596
+ protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
597
+ {
598
+ if ($errorInfo['alternative'] !== '') {
599
+ $error .= ". This directive was previously called '%s'.";
600
  }
601
 
602
+ return $error;
603
+ }
604
+
605
+
606
+ /**
607
+ * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
608
+ *
609
+ * @param array $data The error data array which was created.
610
+ * @param array $itemInfo Base information about the item this error message applied to.
611
+ * @param array $errorInfo Detail information about an item this error message applied to.
612
+ *
613
+ * @return array
614
+ */
615
+ protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
616
+ {
617
+ if ($errorInfo['alternative'] !== '') {
618
+ $data[] = $errorInfo['alternative'];
619
  }
620
 
621
+ return $data;
622
+ }
623
 
624
 
625
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewInterfacesSniff.php CHANGED
@@ -16,7 +16,7 @@
16
  * @package PHPCompatibility
17
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
  */
19
- class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_Sniff
20
  {
21
 
22
  /**
@@ -87,14 +87,9 @@ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_Sn
87
  */
88
  public function register()
89
  {
90
- // Handle case-insensitivity of class names.
91
- $keys = array_keys( $this->newInterfaces );
92
- $keys = array_map( 'strtolower', $keys );
93
- $this->newInterfaces = array_combine( $keys, $this->newInterfaces );
94
-
95
- $keys = array_keys( $this->unsupportedMethods );
96
- $keys = array_map( 'strtolower', $keys );
97
- $this->unsupportedMethods = array_combine( $keys, $this->unsupportedMethods );
98
 
99
  return array(T_CLASS);
100
 
@@ -127,27 +122,35 @@ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_Sn
127
  }
128
 
129
  foreach ($interfaces as $interface) {
130
- $lcInterface = strtolower($interface);
131
- if (isset($this->newInterfaces[$lcInterface]) === true) {
132
- $this->addError($phpcsFile, $stackPtr, $interface);
 
 
 
 
 
133
  }
134
 
135
- if ($checkMethods === true && isset($this->unsupportedMethods[$lcInterface]) === true) {
136
  $nextFunc = $stackPtr;
137
  while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
138
- $funcName = strtolower($phpcsFile->getDeclarationName($nextFunc));
139
- if ($funcName === '') {
 
140
  continue;
141
  }
142
 
143
- if (isset($this->unsupportedMethods[$lcInterface][$funcName]) === true) {
144
- $error = 'Classes that implement interface %s do not support the method %s(). See %s';
145
- $data = array(
 
146
  $interface,
147
  $funcName,
148
- $this->unsupportedMethods[$lcInterface][$funcName],
149
  );
150
- $phpcsFile->addError($error, $nextFunc, 'UnsupportedMethod', $data);
 
151
  }
152
  }
153
  }
@@ -157,40 +160,27 @@ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_Sn
157
 
158
 
159
  /**
160
- * Generates the error or warning for this sniff.
161
  *
162
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
163
- * @param int $stackPtr The position of the function
164
- * in the token array.
165
- * @param string $interface The name of the interface.
166
  *
167
- * @return void
168
  */
169
- protected function addError($phpcsFile, $stackPtr, $interface)
170
  {
171
- $interfaceLc = strtolower($interface);
172
- $error = '';
173
-
174
- $isError = false;
175
- foreach ($this->newInterfaces[$interfaceLc] as $version => $present) {
176
- if ($this->supportsBelow($version)) {
177
- if ($present === false) {
178
- $isError = true;
179
- $error .= 'not present in PHP version ' . $version . ' or earlier';
180
- }
181
- }
182
- }
183
 
184
- if (strlen($error) > 0) {
185
- $error = 'The built-in interface ' . $interface . ' is ' . $error;
186
 
187
- if ($isError === true) {
188
- $phpcsFile->addError($error, $stackPtr);
189
- } else {
190
- $phpcsFile->addWarning($error, $stackPtr);
191
- }
192
- }
 
 
 
193
 
194
- }//end addError()
195
 
196
  }//end class
16
  * @package PHPCompatibility
17
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
  */
19
+ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_AbstractNewFeatureSniff
20
  {
21
 
22
  /**
87
  */
88
  public function register()
89
  {
90
+ // Handle case-insensitivity of interface names.
91
+ $this->newInterfaces = $this->arrayKeysToLowercase($this->newInterfaces);
92
+ $this->unsupportedMethods = $this->arrayKeysToLowercase($this->unsupportedMethods);
 
 
 
 
 
93
 
94
  return array(T_CLASS);
95
 
122
  }
123
 
124
  foreach ($interfaces as $interface) {
125
+ $interfaceLc = strtolower($interface);
126
+
127
+ if (isset($this->newInterfaces[$interfaceLc]) === true) {
128
+ $itemInfo = array(
129
+ 'name' => $interface,
130
+ 'nameLc' => $interfaceLc,
131
+ );
132
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
133
  }
134
 
135
+ if ($checkMethods === true && isset($this->unsupportedMethods[$interfaceLc]) === true) {
136
  $nextFunc = $stackPtr;
137
  while (($nextFunc = $phpcsFile->findNext(T_FUNCTION, ($nextFunc + 1), $scopeCloser)) !== false) {
138
+ $funcName = $phpcsFile->getDeclarationName($nextFunc);
139
+ $funcNameLc = strtolower($funcName);
140
+ if ($funcNameLc === '') {
141
  continue;
142
  }
143
 
144
+ if (isset($this->unsupportedMethods[$interfaceLc][$funcNameLc]) === true) {
145
+ $error = 'Classes that implement interface %s do not support the method %s(). See %s';
146
+ $errorCode = $this->stringToErrorCode($interface).'UnsupportedMethod';
147
+ $data = array(
148
  $interface,
149
  $funcName,
150
+ $this->unsupportedMethods[$interfaceLc][$funcNameLc],
151
  );
152
+
153
+ $phpcsFile->addError($error, $nextFunc, $errorCode, $data);
154
  }
155
  }
156
  }
160
 
161
 
162
  /**
163
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
164
  *
165
+ * @param array $itemInfo Base information about the item.
 
 
 
166
  *
167
+ * @return array Version and other information about the item.
168
  */
169
+ public function getItemArray(array $itemInfo)
170
  {
171
+ return $this->newInterfaces[$itemInfo['nameLc']];
172
+ }
 
 
 
 
 
 
 
 
 
 
173
 
 
 
174
 
175
+ /**
176
+ * Get the error message template for this sniff.
177
+ *
178
+ * @return string
179
+ */
180
+ protected function getErrorMsgTemplate()
181
+ {
182
+ return 'The built-in interface '.parent::getErrorMsgTemplate();
183
+ }
184
 
 
185
 
186
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewKeywordsSniff.php CHANGED
@@ -19,7 +19,7 @@
19
  * @version 1.0.0
20
  * @copyright 2013 Cu.be Solutions bvba
21
  */
22
- class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Sniff
23
  {
24
 
25
  /**
@@ -45,7 +45,7 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
45
  '5.2' => false,
46
  '5.3' => true,
47
  'description' => '"const" keyword',
48
- 'condition' => array(T_CLASS), // Keyword is only new when not in class context.
49
  ),
50
  'T_CALLABLE' => array(
51
  '5.3' => false,
@@ -218,43 +218,75 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Snif
218
  }
219
  }
220
 
221
- $this->addError($phpcsFile, $stackPtr, $tokenType);
 
 
 
222
  }
 
223
  }//end process()
224
 
225
 
226
  /**
227
- * Generates the error or warning for this sniff.
228
  *
229
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
230
- * @param int $stackPtr The position of the function
231
- * in the token array.
232
- * @param string $keywordName The name of the keyword.
233
  *
234
- * @return void
235
  */
236
- protected function addError($phpcsFile, $stackPtr, $keywordName)
237
  {
238
- $notInVersion = '';
239
- foreach ($this->newKeywords[$keywordName] as $version => $present) {
240
- if (in_array($version, array('condition', 'description', 'content'), true)) {
241
- continue;
242
- }
243
 
244
- if ($present === false && $this->supportsBelow($version)) {
245
- $notInVersion = $version;
246
- }
247
- }
248
 
249
- if ($notInVersion !== '') {
250
- $error = '%s is not present in PHP version %s or earlier';
251
- $data = array(
252
- $this->newKeywords[$keywordName]['description'],
253
- $notInVersion,
254
- );
255
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
256
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
 
258
- }//end addError()
259
 
260
  }//end class
19
  * @version 1.0.0
20
  * @copyright 2013 Cu.be Solutions bvba
21
  */
22
+ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_AbstractNewFeatureSniff
23
  {
24
 
25
  /**
45
  '5.2' => false,
46
  '5.3' => true,
47
  'description' => '"const" keyword',
48
+ 'condition' => array(T_CLASS, T_INTERFACE), // Keyword is only new when not in class context.
49
  ),
50
  'T_CALLABLE' => array(
51
  '5.3' => false,
218
  }
219
  }
220
 
221
+ $itemInfo = array(
222
+ 'name' => $tokenType,
223
+ );
224
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
225
  }
226
+
227
  }//end process()
228
 
229
 
230
  /**
231
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
232
  *
233
+ * @param array $itemInfo Base information about the item.
 
 
 
234
  *
235
+ * @return array Version and other information about the item.
236
  */
237
+ public function getItemArray(array $itemInfo)
238
  {
239
+ return $this->newKeywords[$itemInfo['name']];
240
+ }
 
 
 
241
 
 
 
 
 
242
 
243
+ /**
244
+ * Get an array of the non-PHP-version array keys used in a sub-array.
245
+ *
246
+ * @return array
247
+ */
248
+ protected function getNonVersionArrayKeys()
249
+ {
250
+ return array(
251
+ 'description',
252
+ 'condition',
253
+ 'content',
254
+ );
255
+ }
256
+
257
+
258
+ /**
259
+ * Retrieve the relevant detail (version) information for use in an error message.
260
+ *
261
+ * @param array $itemArray Version and other information about the item.
262
+ * @param array $itemInfo Base information about the item.
263
+ *
264
+ * @return array
265
+ */
266
+ public function getErrorInfo(array $itemArray, array $itemInfo)
267
+ {
268
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
269
+ $errorInfo['description'] = $itemArray['description'];
270
+
271
+ return $errorInfo;
272
+
273
+ }
274
+
275
+
276
+ /**
277
+ * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
278
+ *
279
+ * @param array $data The error data array which was created.
280
+ * @param array $itemInfo Base information about the item this error message applied to.
281
+ * @param array $errorInfo Detail information about an item this error message applied to.
282
+ *
283
+ * @return array
284
+ */
285
+ protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
286
+ {
287
+ $data[0] = $errorInfo['description'];
288
+ return $data;
289
+ }
290
 
 
291
 
292
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewLanguageConstructsSniff.php CHANGED
@@ -19,7 +19,7 @@
19
  * @version 1.0.0
20
  * @copyright 2013 Cu.be Solutions bvba
21
  */
22
- class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatibility_Sniff
23
  {
24
 
25
  /**
@@ -159,44 +159,70 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib
159
  return;
160
  }
161
 
162
- $this->addError($phpcsFile, $stackPtr, $tokenType);
 
 
 
163
 
164
  }//end process()
165
 
166
 
167
  /**
168
- * Generates the error or warning for this sniff.
169
  *
170
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
171
- * @param int $stackPtr The position of the function
172
- * in the token array.
173
- * @param string $keywordName The name of the keyword.
174
  *
175
- * @return void
176
  */
177
- protected function addError($phpcsFile, $stackPtr, $keywordName)
178
  {
179
- $error = '';
180
-
181
- $isError = false;
182
- foreach ($this->newConstructs[$keywordName] as $version => $present) {
183
- if ($this->supportsBelow($version)) {
184
- if ($present === false) {
185
- $isError = true;
186
- $error .= 'not present in PHP version ' . $version . ' or earlier';
187
- }
188
- }
189
- }
190
- if (strlen($error) > 0) {
191
- $error = $this->newConstructs[$keywordName]['description'] . ' is ' . $error;
192
 
193
- if ($isError === true) {
194
- $phpcsFile->addError($error, $stackPtr);
195
- } else {
196
- $phpcsFile->addWarning($error, $stackPtr);
197
- }
198
- }
199
 
200
- }//end addError()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
201
 
202
  }//end class
19
  * @version 1.0.0
20
  * @copyright 2013 Cu.be Solutions bvba
21
  */
22
+ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatibility_AbstractNewFeatureSniff
23
  {
24
 
25
  /**
159
  return;
160
  }
161
 
162
+ $itemInfo = array(
163
+ 'name' => $tokenType,
164
+ );
165
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
166
 
167
  }//end process()
168
 
169
 
170
  /**
171
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
172
  *
173
+ * @param array $itemInfo Base information about the item.
 
 
 
174
  *
175
+ * @return array Version and other information about the item.
176
  */
177
+ public function getItemArray(array $itemInfo)
178
  {
179
+ return $this->newConstructs[$itemInfo['name']];
180
+ }
 
 
 
 
 
 
 
 
 
 
 
181
 
 
 
 
 
 
 
182
 
183
+ /**
184
+ * Get an array of the non-PHP-version array keys used in a sub-array.
185
+ *
186
+ * @return array
187
+ */
188
+ protected function getNonVersionArrayKeys()
189
+ {
190
+ return array('description');
191
+ }
192
+
193
+
194
+ /**
195
+ * Retrieve the relevant detail (version) information for use in an error message.
196
+ *
197
+ * @param array $itemArray Version and other information about the item.
198
+ * @param array $itemInfo Base information about the item.
199
+ *
200
+ * @return array
201
+ */
202
+ public function getErrorInfo(array $itemArray, array $itemInfo)
203
+ {
204
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
205
+ $errorInfo['description'] = $itemArray['description'];
206
+
207
+ return $errorInfo;
208
+
209
+ }
210
+
211
+
212
+ /**
213
+ * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
214
+ *
215
+ * @param array $data The error data array which was created.
216
+ * @param array $itemInfo Base information about the item this error message applied to.
217
+ * @param array $errorInfo Detail information about an item this error message applied to.
218
+ *
219
+ * @return array
220
+ */
221
+ protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
222
+ {
223
+ $data[0] = $errorInfo['description'];
224
+ return $data;
225
+ }
226
+
227
 
228
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewMagicMethodsSniff.php CHANGED
@@ -16,7 +16,7 @@
16
  * @package PHPCompatibility
17
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
  */
19
- class PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff extends PHPCompatibility_Sniff
20
  {
21
 
22
  /**
@@ -105,27 +105,89 @@ class PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff extends PHPCompatibility_
105
  return;
106
  }
107
 
108
- $lastVersionBelow = '';
109
- foreach ($this->newMagicMethods[$functionNameLc] as $version => $magic) {
110
- if ($version !== 'message' && $magic === false && $this->supportsBelow($version)) {
111
- $lastVersionBelow = $version;
112
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  }
114
 
115
- if ($lastVersionBelow !== '') {
116
- $error = 'The method %s() was not magical in PHP version %s and earlier. The associated magic functionality will not be invoked.';
117
- if (empty($this->newMagicMethods[$functionNameLc]['message']) === false) {
118
- $error = $this->newMagicMethods[$functionNameLc]['message'];
119
- }
120
 
121
- $data = array(
122
- $functionName,
123
- $lastVersionBelow,
124
- );
125
 
126
- $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  }
128
 
129
- }//end process()
 
 
130
 
131
  }//end class
16
  * @package PHPCompatibility
17
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
18
  */
19
+ class PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff extends PHPCompatibility_AbstractNewFeatureSniff
20
  {
21
 
22
  /**
105
  return;
106
  }
107
 
108
+ $itemInfo = array(
109
+ 'name' => $functionName,
110
+ 'nameLc' => $functionNameLc,
111
+ );
112
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
113
+
114
+ }//end process()
115
+
116
+
117
+ /**
118
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
119
+ *
120
+ * @param array $itemInfo Base information about the item.
121
+ *
122
+ * @return array Version and other information about the item.
123
+ */
124
+ public function getItemArray(array $itemInfo)
125
+ {
126
+ return $this->newMagicMethods[$itemInfo['nameLc']];
127
+ }
128
+
129
+
130
+ /**
131
+ * Get an array of the non-PHP-version array keys used in a sub-array.
132
+ *
133
+ * @return array
134
+ */
135
+ protected function getNonVersionArrayKeys()
136
+ {
137
+ return array('message');
138
+ }
139
+
140
+
141
+ /**
142
+ * Retrieve the relevant detail (version) information for use in an error message.
143
+ *
144
+ * @param array $itemArray Version and other information about the item.
145
+ * @param array $itemInfo Base information about the item.
146
+ *
147
+ * @return array
148
+ */
149
+ public function getErrorInfo(array $itemArray, array $itemInfo)
150
+ {
151
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
152
+ $errorInfo['error'] = false; // Warning, not error.
153
+ $errorInfo['message'] = '';
154
+
155
+ if (empty($itemArray['message']) === false) {
156
+ $errorInfo['message'] = $itemArray['message'];
157
  }
158
 
159
+ return $errorInfo;
160
+ }
 
 
 
161
 
 
 
 
 
162
 
163
+ /**
164
+ * Get the error message template for this sniff.
165
+ *
166
+ * @return string
167
+ */
168
+ protected function getErrorMsgTemplate()
169
+ {
170
+ return 'The method %s() was not magical in PHP version %s and earlier. The associated magic functionality will not be invoked.';
171
+ }
172
+
173
+
174
+ /**
175
+ * Allow for concrete child classes to filter the error message before it's passed to PHPCS.
176
+ *
177
+ * @param string $error The error message which was created.
178
+ * @param array $itemInfo Base information about the item this error message applied to.
179
+ * @param array $errorInfo Detail information about an item this error message applied to.
180
+ *
181
+ * @return string
182
+ */
183
+ protected function filterErrorMsg($error, array $itemInfo, array $errorInfo)
184
+ {
185
+ if ($errorInfo['message'] !== '') {
186
+ $error = $errorInfo['message'];
187
  }
188
 
189
+ return $error;
190
+ }
191
+
192
 
193
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewScalarReturnTypeDeclarationsSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends PHPCompatibility_Sniff
18
  {
19
 
20
  /**
@@ -77,48 +77,38 @@ class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends P
77
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
78
  {
79
  $tokens = $phpcsFile->getTokens();
80
- if (in_array($tokens[$stackPtr]['content'], array_keys($this->newTypes))) {
81
- $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['content']);
 
 
 
 
82
  }
83
  }//end process()
84
 
85
 
86
  /**
87
- * Generates the error or warning for this sniff.
88
  *
89
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
90
- * @param int $stackPtr The position of the function
91
- * in the token array.
92
- * @param string $typeName The type.
93
  *
94
- * @return void
95
  */
96
- protected function addError($phpcsFile, $stackPtr, $typeName)
97
  {
98
- $error = '';
 
99
 
100
- $isError = false;
101
- foreach ($this->newTypes[$typeName] as $version => $present) {
102
- if ($this->supportsBelow($version)) {
103
- if ($present === false) {
104
- $isError = true;
105
- $error .= 'not present in PHP version ' . $version . ' or earlier';
106
- }
107
- }
108
- }
109
- if (strlen($error) > 0) {
110
- $error = '%s return type is ' . $error;
111
- $data = array(
112
- $typeName,
113
- );
114
 
115
- if ($isError === true) {
116
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
117
- } else {
118
- $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
119
- }
120
- }
 
 
 
121
 
122
- }//end addError()
123
 
124
  }//end class
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_NewScalarReturnTypeDeclarationsSniff extends PHPCompatibility_AbstractNewFeatureSniff
18
  {
19
 
20
  /**
77
  public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
78
  {
79
  $tokens = $phpcsFile->getTokens();
80
+
81
+ if (isset($this->newTypes[$tokens[$stackPtr]['content']]) === true) {
82
+ $itemInfo = array(
83
+ 'name' => $tokens[$stackPtr]['content'],
84
+ );
85
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
86
  }
87
  }//end process()
88
 
89
 
90
  /**
91
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
92
  *
93
+ * @param array $itemInfo Base information about the item.
 
 
 
94
  *
95
+ * @return array Version and other information about the item.
96
  */
97
+ public function getItemArray(array $itemInfo)
98
  {
99
+ return $this->newTypes[$itemInfo['name']];
100
+ }
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
 
103
+ /**
104
+ * Get the error message template for this sniff.
105
+ *
106
+ * @return string
107
+ */
108
+ protected function getErrorMsgTemplate()
109
+ {
110
+ return '%s return type is not present in PHP version %s or earlier';
111
+ }
112
 
 
113
 
114
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NewScalarTypeDeclarationsSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPCompatibility_Sniff
18
  {
19
 
20
  /**
@@ -108,24 +108,34 @@ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPComp
108
  }
109
 
110
  if ($supportsPHP4 === true) {
111
- $error = 'Type hints were not present in PHP 4.4 or earlier.';
112
- $phpcsFile->addError($error, $stackPtr, 'TypeHintFound');
 
 
 
113
  }
114
  else if (isset($this->newTypes[$param['type_hint']])) {
115
- $this->addError($phpcsFile, $stackPtr, $param['type_hint']);
 
 
 
116
  }
117
  else if (isset($this->invalidTypes[$param['type_hint']])) {
118
  $error = "'%s' is not a valid type declaration. Did you mean %s ?";
119
- $data = array(
120
  $param['type_hint'],
121
  $this->invalidTypes[$param['type_hint']],
122
  );
 
123
  $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHintFound', $data);
124
  }
125
  else if ($param['type_hint'] === 'self') {
126
  if ($this->inClassScope($phpcsFile, $stackPtr) === false) {
127
- $error = "'self' type cannot be used outside of class scope";
128
- $phpcsFile->addError($error, $stackPtr, 'SelfOutsideClassScopeFound');
 
 
 
129
  }
130
  }
131
  }
@@ -133,38 +143,27 @@ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPComp
133
 
134
 
135
  /**
136
- * Generates the error or warning for this sniff.
137
  *
138
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
139
- * @param int $stackPtr The position of the function
140
- * in the token array.
141
- * @param string $typeName The type.
142
  *
143
- * @return void
144
  */
145
- protected function addError($phpcsFile, $stackPtr, $typeName)
146
  {
147
- $error = '';
148
-
149
- $isError = false;
150
- foreach ($this->newTypes[$typeName] as $version => $present) {
151
- if ($this->supportsBelow($version)) {
152
- if ($present === false) {
153
- $isError = true;
154
- $error .= 'not present in PHP version ' . $version . ' or earlier';
155
- }
156
- }
157
- }
158
- if (strlen($error) > 0) {
159
- $error = "'{$typeName}' type declaration is " . $error;
160
 
161
- if ($isError === true) {
162
- $phpcsFile->addError($error, $stackPtr);
163
- } else {
164
- $phpcsFile->addWarning($error, $stackPtr);
165
- }
166
- }
167
 
168
- }//end addError()
 
 
 
 
 
 
 
 
 
169
 
170
  }//end class
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPCompatibility_AbstractNewFeatureSniff
18
  {
19
 
20
  /**
108
  }
109
 
110
  if ($supportsPHP4 === true) {
111
+ $phpcsFile->addError(
112
+ 'Type hints were not present in PHP 4.4 or earlier.',
113
+ $stackPtr,
114
+ 'TypeHintFound'
115
+ );
116
  }
117
  else if (isset($this->newTypes[$param['type_hint']])) {
118
+ $itemInfo = array(
119
+ 'name' => $param['type_hint'],
120
+ );
121
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
122
  }
123
  else if (isset($this->invalidTypes[$param['type_hint']])) {
124
  $error = "'%s' is not a valid type declaration. Did you mean %s ?";
125
+ $data = array(
126
  $param['type_hint'],
127
  $this->invalidTypes[$param['type_hint']],
128
  );
129
+
130
  $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHintFound', $data);
131
  }
132
  else if ($param['type_hint'] === 'self') {
133
  if ($this->inClassScope($phpcsFile, $stackPtr) === false) {
134
+ $phpcsFile->addError(
135
+ "'self' type cannot be used outside of class scope",
136
+ $stackPtr,
137
+ 'SelfOutsideClassScopeFound'
138
+ );
139
  }
140
  }
141
  }
143
 
144
 
145
  /**
146
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
147
  *
148
+ * @param array $itemInfo Base information about the item.
 
 
 
149
  *
150
+ * @return array Version and other information about the item.
151
  */
152
+ public function getItemArray(array $itemInfo)
153
  {
154
+ return $this->newTypes[$itemInfo['name']];
155
+ }
 
 
 
 
 
 
 
 
 
 
 
156
 
 
 
 
 
 
 
157
 
158
+ /**
159
+ * Get the error message template for this sniff.
160
+ *
161
+ * @return string
162
+ */
163
+ protected function getErrorMsgTemplate()
164
+ {
165
+ return "'%s' type declaration is not present in PHP version %s or earlier";
166
+ }
167
+
168
 
169
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/NonStaticMagicMethodsSniff.php CHANGED
@@ -129,28 +129,29 @@ class PHPCompatibility_Sniffs_PHP_NonStaticMagicMethodsSniff extends PHPCompatib
129
  }
130
 
131
  $methodProperties = $phpcsFile->getMethodProperties($functionToken);
 
132
 
133
  if (isset($this->magicMethods[$methodNameLc]['visibility']) && $this->magicMethods[$methodNameLc]['visibility'] !== $methodProperties['scope']) {
134
- $error = 'Visibility for magic method %s must be %s. Found: %s';
135
- $data = array(
 
136
  $methodName,
137
  $this->magicMethods[$methodNameLc]['visibility'],
138
  $methodProperties['scope'],
139
  );
140
 
141
- $phpcsFile->addError($error, $functionToken, 'MethodVisibility', $data);
142
  }
143
 
144
  if (isset($this->magicMethods[$methodNameLc]['static']) && $this->magicMethods[$methodNameLc]['static'] !== $methodProperties['is_static']) {
145
  $error = 'Magic method %s cannot be defined as static.';
146
- $errorCode = 'MethodStatic';
 
 
147
  if ( $this->magicMethods[$methodNameLc]['static'] === true ) {
148
  $error = 'Magic method %s must be defined as static.';
149
- $errorCode = 'MethodNonStatic';
150
  }
151
- $data = array(
152
- $methodName,
153
- );
154
 
155
  $phpcsFile->addError($error, $functionToken, $errorCode, $data);
156
  }
129
  }
130
 
131
  $methodProperties = $phpcsFile->getMethodProperties($functionToken);
132
+ $errorCodeBase = $this->stringToErrorCode($methodNameLc);
133
 
134
  if (isset($this->magicMethods[$methodNameLc]['visibility']) && $this->magicMethods[$methodNameLc]['visibility'] !== $methodProperties['scope']) {
135
+ $error = 'Visibility for magic method %s must be %s. Found: %s';
136
+ $errorCode = $errorCodeBase.'MethodVisibility';
137
+ $data = array(
138
  $methodName,
139
  $this->magicMethods[$methodNameLc]['visibility'],
140
  $methodProperties['scope'],
141
  );
142
 
143
+ $phpcsFile->addError($error, $functionToken, $errorCode, $data);
144
  }
145
 
146
  if (isset($this->magicMethods[$methodNameLc]['static']) && $this->magicMethods[$methodNameLc]['static'] !== $methodProperties['is_static']) {
147
  $error = 'Magic method %s cannot be defined as static.';
148
+ $errorCode = $errorCodeBase.'MethodStatic';
149
+ $data = array($methodName);
150
+
151
  if ( $this->magicMethods[$methodNameLc]['static'] === true ) {
152
  $error = 'Magic method %s must be defined as static.';
153
+ $errorCode = $errorCodeBase.'MethodNonStatic';
154
  }
 
 
 
155
 
156
  $phpcsFile->addError($error, $functionToken, $errorCode, $data);
157
  }
vendor/wimg/php-compatibility/Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php CHANGED
@@ -60,9 +60,11 @@ class PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff extends PHPCo
60
 
61
  foreach ($parameters as $param) {
62
  if (in_array($param['name'], $this->superglobals, true)) {
63
- $error = 'Parameter shadowing super global (%s) causes fatal error since PHP 5.4';
64
- $data = array($param['name']);
65
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
 
 
66
  }
67
  }
68
  }
60
 
61
  foreach ($parameters as $param) {
62
  if (in_array($param['name'], $this->superglobals, true)) {
63
+ $error = 'Parameter shadowing super global (%s) causes fatal error since PHP 5.4';
64
+ $errorCode = $this->stringToErrorCode(substr($param['name'], 1)).'Found';
65
+ $data = array($param['name']);
66
+
67
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
68
  }
69
  }
70
  }
vendor/wimg/php-compatibility/Sniffs/PHP/PregReplaceEModifierSniff.php CHANGED
@@ -78,20 +78,63 @@ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibi
78
  return;
79
  }
80
 
81
- // Get the first parameter in the function call as that should contain the regex.
82
  $firstParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 1);
83
  if ($firstParam === false) {
84
  return;
85
  }
86
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  /*
88
- * The first parameter might be build up of a combination of strings,
89
- * variables and function calls. We are only concerned with the strings.
90
  */
91
  $regex = '';
92
- for ($i = $firstParam['start']; $i <= $firstParam['end']; $i++ ) {
93
  if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens, true) === true) {
94
- $regex .= $this->stripQuotes($tokens[$i]['content']);
 
 
 
 
 
95
  }
96
  }
97
  // Deal with multi-line regexes which were broken up in several string tokens.
@@ -103,6 +146,13 @@ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibi
103
  }
104
 
105
  $regexFirstChar = substr($regex, 0, 1);
 
 
 
 
 
 
 
106
  if (isset($this->doublesSeparators[$regexFirstChar])) {
107
  $regexEndPos = strrpos($regex, $this->doublesSeparators[$regexFirstChar]);
108
  }
@@ -125,14 +175,9 @@ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibi
125
  $errorCode = 'Removed';
126
  }
127
 
128
- if ($isError === true) {
129
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
130
- } else {
131
- $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
132
- }
133
  }
134
  }
135
-
136
- }//end process()
137
 
138
  }//end class
78
  return;
79
  }
80
 
81
+ // Get the first parameter in the function call as that should contain the regex(es).
82
  $firstParam = $this->getFunctionCallParameter($phpcsFile, $stackPtr, 1);
83
  if ($firstParam === false) {
84
  return;
85
  }
86
 
87
+ // Differentiate between an array of patterns passed and a single pattern.
88
+ $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $firstParam['start'], ($firstParam['end'] +1), true);
89
+ if ($nextNonEmpty !== false && ($tokens[$nextNonEmpty]['code'] === T_ARRAY || $tokens[$nextNonEmpty]['code'] === T_OPEN_SHORT_ARRAY)) {
90
+ $arrayValues = $this->getFunctionCallParameters($phpcsFile, $nextNonEmpty);
91
+ foreach ($arrayValues as $value) {
92
+ $hasKey = $phpcsFile->findNext(T_DOUBLE_ARROW, $value['start'], ($value['end'] + 1));
93
+ if ($hasKey !== false) {
94
+ $value['start'] = ($hasKey + 1);
95
+ $value['raw'] = trim($phpcsFile->getTokensAsString($value['start'], (($value['end'] + 1) - $value['start'])));
96
+ }
97
+
98
+ $this->processRegexPattern($value, $phpcsFile, $value['end'], $functionName);
99
+ }
100
+ }
101
+ else {
102
+ $this->processRegexPattern($firstParam, $phpcsFile, $stackPtr, $functionName);
103
+ }
104
+
105
+ }//end process()
106
+
107
+
108
+ /**
109
+ * Analyse a potential regex pattern for usage of the /e modifier.
110
+ *
111
+ * @param array $pattern Array containing the start and end token
112
+ * pointer of the potential regex pattern and
113
+ * the raw string value of the pattern.
114
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
115
+ * @param int $stackPtr The position of the current token in the
116
+ * stack passed in $tokens.
117
+ * @param string $functionName The function which contained the pattern.
118
+ *
119
+ * @return void
120
+ */
121
+ protected function processRegexPattern($pattern, $phpcsFile, $stackPtr, $functionName)
122
+ {
123
+ $tokens = $phpcsFile->getTokens();
124
+
125
  /*
126
+ * The pattern might be build up of a combination of strings, variables
127
+ * and function calls. We are only concerned with the strings.
128
  */
129
  $regex = '';
130
+ for ($i = $pattern['start']; $i <= $pattern['end']; $i++ ) {
131
  if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens, true) === true) {
132
+ $content = $this->stripQuotes($tokens[$i]['content']);
133
+ if ($tokens[$i]['code'] === T_DOUBLE_QUOTED_STRING) {
134
+ $content = $this->stripVariables($content);
135
+ }
136
+
137
+ $regex .= trim($content);
138
  }
139
  }
140
  // Deal with multi-line regexes which were broken up in several string tokens.
146
  }
147
 
148
  $regexFirstChar = substr($regex, 0, 1);
149
+
150
+ // Make sure that the character identified as the delimiter is valid.
151
+ // Otherwise, it is a false positive caused by the string concatenation.
152
+ if (preg_match('`[a-z0-9\\\\ ]`i', $regexFirstChar) === 1) {
153
+ return;
154
+ }
155
+
156
  if (isset($this->doublesSeparators[$regexFirstChar])) {
157
  $regexEndPos = strrpos($regex, $this->doublesSeparators[$regexFirstChar]);
158
  }
175
  $errorCode = 'Removed';
176
  }
177
 
178
+ $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data);
 
 
 
 
179
  }
180
  }
181
+ }//end processRegexPattern()
 
182
 
183
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/RemovedAlternativePHPTagsSniff.php CHANGED
@@ -111,8 +111,12 @@ class PHPCompatibility_Sniffs_PHP_RemovedAlternativePHPTagsSniff extends PHPComp
111
  }
112
 
113
  if (isset($errorCode, $data)) {
114
- $error = '%s style opening tags have been removed in PHP 7.0. Found "%s"';
115
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
 
 
 
 
116
  return;
117
  }
118
 
111
  }
112
 
113
  if (isset($errorCode, $data)) {
114
+ $phpcsFile->addError(
115
+ '%s style opening tags have been removed in PHP 7.0. Found "%s"',
116
+ $stackPtr,
117
+ $errorCode,
118
+ $data
119
+ );
120
  return;
121
  }
122
 
vendor/wimg/php-compatibility/Sniffs/PHP/RemovedExtensionsSniff.php CHANGED
@@ -20,7 +20,7 @@
20
  * @author Wim Godden <wim.godden@cu.be>
21
  * @copyright 2012 Cu.be Solutions bvba
22
  */
23
- class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibility_Sniff
24
  {
25
  /**
26
  * A list of functions to whitelist, if any.
@@ -41,308 +41,130 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
41
 
42
  /**
43
  * A list of removed extensions with their alternative, if any
44
- * Array codes : 0 = removed/unavailable, -1 = deprecated, 1 = active
 
 
45
  *
46
  * @var array(string|null)
47
  */
48
  protected $removedExtensions = array(
49
  'activescript' => array(
50
- '5.0' => 1,
51
- '5.1' => 0,
52
- '5.2' => 0,
53
- '5.3' => 0,
54
- '5.4' => 0,
55
- '5.5' => 0,
56
- '5.6' => 0,
57
- '7.0' => 0,
58
  'alternative' => 'pecl/activescript'
59
  ),
60
  'cpdf' => array(
61
- '5.0' => 1,
62
- '5.1' => 0,
63
- '5.2' => 0,
64
- '5.3' => 0,
65
- '5.4' => 0,
66
- '5.5' => 0,
67
- '5.6' => 0,
68
- '7.0' => 0,
69
  'alternative' => 'pecl/pdflib'
70
  ),
71
  'dbase' => array(
72
- '5.0' => 1,
73
- '5.1' => 1,
74
- '5.2' => 1,
75
- '5.3' => 0,
76
- '5.4' => 0,
77
- '5.5' => 0,
78
- '5.6' => 0,
79
- '7.0' => 0,
80
  'alternative' => null
81
  ),
82
  'dbx' => array(
83
- '5.0' => 1,
84
- '5.1' => 0,
85
- '5.2' => 0,
86
- '5.3' => 0,
87
- '5.4' => 0,
88
- '5.5' => 0,
89
- '5.6' => 0,
90
- '7.0' => 0,
91
  'alternative' => 'pecl/dbx'
92
  ),
93
  'dio' => array(
94
- '5.0' => 1,
95
- '5.1' => 0,
96
- '5.2' => 0,
97
- '5.3' => 0,
98
- '5.4' => 0,
99
- '5.5' => 0,
100
- '5.6' => 0,
101
- '7.0' => 0,
102
  'alternative' => 'pecl/dio'
103
  ),
104
  'ereg' => array(
105
- '5.0' => 1,
106
- '5.1' => 1,
107
- '5.2' => 1,
108
- '5.3' => -1,
109
- '5.4' => -1,
110
- '5.5' => -1,
111
- '5.6' => -1,
112
- '7.0' => 0,
113
  'alternative' => 'pcre'
114
  ),
115
  'fam' => array(
116
- '5.0' => 1,
117
- '5.1' => 0,
118
- '5.2' => 0,
119
- '5.3' => 0,
120
- '5.4' => 0,
121
- '5.5' => 0,
122
- '5.6' => 0,
123
- '7.0' => 0,
124
  'alternative' => null
125
  ),
126
  'fbsql' => array(
127
- '5.0' => 1,
128
- '5.1' => 1,
129
- '5.2' => 1,
130
- '5.3' => 0,
131
- '5.4' => 0,
132
- '5.5' => 0,
133
- '5.6' => 0,
134
- '7.0' => 0,
135
  'alternative' => null
136
  ),
137
  'fdf' => array(
138
- '5.0' => 1,
139
- '5.1' => 1,
140
- '5.2' => 1,
141
- '5.3' => 0,
142
- '5.4' => 0,
143
- '5.5' => 0,
144
- '5.6' => 0,
145
- '7.0' => 0,
146
  'alternative' => 'pecl/fdf'
147
  ),
148
  'filepro' => array(
149
- '5.0' => 1,
150
- '5.1' => 1,
151
- '5.2' => 0,
152
- '5.3' => 0,
153
- '5.4' => 0,
154
- '5.5' => 0,
155
- '5.6' => 0,
156
- '7.0' => 0,
157
  'alternative' => null
158
  ),
159
  'hw_api' => array(
160
- '5.0' => 1,
161
- '5.1' => 1,
162
- '5.2' => 0,
163
- '5.3' => 0,
164
- '5.4' => 0,
165
- '5.5' => 0,
166
- '5.6' => 0,
167
- '7.0' => 0,
168
  'alternative' => null
169
  ),
170
  'ingres' => array(
171
- '5.0' => 1,
172
- '5.1' => 0,
173
- '5.2' => 0,
174
- '5.3' => 0,
175
- '5.4' => 0,
176
- '5.5' => 0,
177
- '5.6' => 0,
178
- '7.0' => 0,
179
  'alternative' => 'pecl/ingres'
180
  ),
181
  'ircg' => array(
182
- '5.0' => 1,
183
- '5.1' => 0,
184
- '5.2' => 0,
185
- '5.3' => 0,
186
- '5.4' => 0,
187
- '5.5' => 0,
188
- '5.6' => 0,
189
- '7.0' => 0,
190
  'alternative' => null
191
  ),
192
  'mcrypt' => array(
193
- '7.0' => 1,
194
- '7.1' => -1,
195
  'alternative' => 'openssl (preferred) or pecl/mcrypt once available'
196
  ),
197
  'mcve' => array(
198
- '5.0' => 1,
199
- '5.1' => 0,
200
- '5.2' => 0,
201
- '5.3' => 0,
202
- '5.4' => 0,
203
- '5.5' => 0,
204
- '5.6' => 0,
205
- '7.0' => 0,
206
  'alternative' => 'pecl/mvce'
207
  ),
208
  'ming' => array(
209
- '5.0' => 1,
210
- '5.1' => 1,
211
- '5.2' => 1,
212
- '5.3' => 0,
213
- '5.4' => 0,
214
- '5.5' => 0,
215
- '5.6' => 0,
216
- '7.0' => 0,
217
  'alternative' => 'pecl/ming'
218
  ),
219
  'mnogosearch' => array(
220
- '5.0' => 1,
221
- '5.1' => 0,
222
- '5.2' => 0,
223
- '5.3' => 0,
224
- '5.4' => 0,
225
- '5.5' => 0,
226
- '5.6' => 0,
227
- '7.0' => 0,
228
  'alternative' => null
229
  ),
230
  'msql' => array(
231
- '5.0' => 1,
232
- '5.1' => 1,
233
- '5.2' => 1,
234
- '5.3' => 0,
235
- '5.4' => 0,
236
- '5.5' => 0,
237
- '5.6' => 0,
238
- '7.0' => 0,
239
  'alternative' => null
240
  ),
241
  'mssql' => array(
242
- '7.0' => 0,
243
  'alternative' => null
244
  ),
245
  'mysql_' => array(
246
- '5.0' => 1,
247
- '5.1' => 1,
248
- '5.2' => 1,
249
- '5.3' => 1,
250
- '5.4' => 1,
251
- '5.5' => -1,
252
- '5.6' => -1,
253
- '7.0' => 0,
254
  'alternative' => 'mysqli',
255
  ),
256
  'ncurses' => array(
257
- '5.0' => 1,
258
- '5.1' => 1,
259
- '5.2' => 1,
260
- '5.3' => 0,
261
- '5.4' => 0,
262
- '5.5' => 0,
263
- '5.6' => 0,
264
- '7.0' => 0,
265
  'alternative' => 'pecl/ncurses'
266
  ),
267
  'oracle' => array(
268
- '5.0' => 1,
269
- '5.1' => 0,
270
- '5.2' => 0,
271
- '5.3' => 0,
272
- '5.4' => 0,
273
- '5.5' => 0,
274
- '5.6' => 0,
275
- '7.0' => 0,
276
  'alternative' => 'oci8 or pdo_oci'
277
  ),
278
  'ovrimos' => array(
279
- '5.0' => 1,
280
- '5.1' => 0,
281
- '5.2' => 0,
282
- '5.3' => 0,
283
- '5.4' => 0,
284
- '5.5' => 0,
285
- '5.6' => 0,
286
- '7.0' => 0,
287
  'alternative' => null
288
  ),
289
  'pfpro' => array(
290
- '5.0' => 1,
291
- '5.1' => 1,
292
- '5.2' => 1,
293
- '5.3' => 0,
294
- '5.4' => 0,
295
- '5.5' => 0,
296
- '5.6' => 0,
297
- '7.0' => 0,
298
  'alternative' => null
299
  ),
300
  'sqlite' => array(
301
- '5.0' => 1,
302
- '5.1' => 1,
303
- '5.2' => 1,
304
- '5.3' => 1,
305
- '5.4' => 0,
306
- '5.5' => 0,
307
- '5.6' => 0,
308
- '7.0' => 0,
309
  'alternative' => null
310
  ),
311
- 'sybase' => array(
312
- '5.0' => 1,
313
- '5.1' => 1,
314
- '5.2' => 1,
315
- '5.3' => 0,
316
- '5.4' => 0,
317
- '5.5' => 0,
318
- '5.6' => 0,
319
- '7.0' => 0,
320
- 'alternative' => 'sybase_ct'
321
- ),
322
  'sybase_ct' => array(
323
- '7.0' => 0,
324
  'alternative' => null
325
  ),
 
 
 
 
326
  'w32api' => array(
327
- '5.0' => 1,
328
- '5.1' => 0,
329
- '5.2' => 0,
330
- '5.3' => 0,
331
- '5.4' => 0,
332
- '5.5' => 0,
333
- '5.6' => 0,
334
- '7.0' => 0,
335
  'alternative' => 'pecl/ffi'
336
  ),
337
  'yp' => array(
338
- '5.0' => 1,
339
- '5.1' => 0,
340
- '5.2' => 0,
341
- '5.3' => 0,
342
- '5.4' => 0,
343
- '5.5' => 0,
344
- '5.6' => 0,
345
- '7.0' => 0,
346
  'alternative' => null
347
  ),
348
  );
@@ -354,6 +176,9 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
354
  */
355
  public function register()
356
  {
 
 
 
357
  return array(T_STRING);
358
 
359
  }//end register()
@@ -403,53 +228,27 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
403
  return;
404
  }
405
 
406
- if($this->isWhiteListed(strtolower($tokens[$stackPtr]['content'])) === true){
 
 
 
407
  // Function is whitelisted.
408
  return;
409
  }
410
 
411
  foreach ($this->removedExtensions as $extension => $versionList) {
412
- if (strpos(strtolower($tokens[$stackPtr]['content']), strtolower($extension)) === 0) {
413
- $error = '';
414
- $isErrored = false;
415
- $isDeprecated = false;
416
- foreach ($versionList as $version => $status) {
417
- if ($version != 'alternative') {
418
- if ($status == -1 || $status == 0) {
419
- if ($this->supportsAbove($version)) {
420
- switch ($status) {
421
- case -1:
422
- if($isDeprecated === false ) {
423
- $error .= 'deprecated since PHP ' . $version . ' and ';
424
- $isDeprecated = true;
425
- }
426
- break;
427
- case 0:
428
- $isErrored = true;
429
- $error .= 'removed since PHP ' . $version . ' and ';
430
- break 2;
431
- }
432
- }
433
- }
434
- }
435
- }
436
- if (strlen($error) > 0) {
437
- $error = "Extension '" . $extension . "' is " . $error;
438
- $error = substr($error, 0, strlen($error) - 5);
439
- if (!is_null($versionList['alternative'])) {
440
- $error .= ' - use ' . $versionList['alternative'] . ' instead.';
441
- }
442
- if ($isErrored === true) {
443
- $phpcsFile->addError($error, $stackPtr);
444
- } else {
445
- $phpcsFile->addWarning($error, $stackPtr);
446
- }
447
- }
448
  }
449
  }
450
 
451
  }//end process()
452
 
 
453
  /**
454
  * Is the current function being checked whitelisted ?
455
  *
@@ -481,4 +280,29 @@ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibilit
481
 
482
  }//end isWhiteListed()
483
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
  }//end class
20
  * @author Wim Godden <wim.godden@cu.be>
21
  * @copyright 2012 Cu.be Solutions bvba
22
  */
23
+ class PHPCompatibility_Sniffs_PHP_RemovedExtensionsSniff extends PHPCompatibility_AbstractRemovedFeatureSniff
24
  {
25
  /**
26
  * A list of functions to whitelist, if any.
41
 
42
  /**
43
  * A list of removed extensions with their alternative, if any
44
+ *
45
+ * The array lists : version number with false (deprecated) and true (removed).
46
+ * If's sufficient to list the first version where the extension was deprecated/removed.
47
  *
48
  * @var array(string|null)
49
  */
50
  protected $removedExtensions = array(
51
  'activescript' => array(
52
+ '5.1' => true,
 
 
 
 
 
 
 
53
  'alternative' => 'pecl/activescript'
54
  ),
55
  'cpdf' => array(
56
+ '5.1' => true,
 
 
 
 
 
 
 
57
  'alternative' => 'pecl/pdflib'
58
  ),
59
  'dbase' => array(
60
+ '5.3' => true,
 
 
 
 
 
 
 
61
  'alternative' => null
62
  ),
63
  'dbx' => array(
64
+ '5.1' => true,
 
 
 
 
 
 
 
65
  'alternative' => 'pecl/dbx'
66
  ),
67
  'dio' => array(
68
+ '5.1' => true,
 
 
 
 
 
 
 
69
  'alternative' => 'pecl/dio'
70
  ),
71
  'ereg' => array(
72
+ '5.3' => false,
73
+ '7.0' => true,
 
 
 
 
 
 
74
  'alternative' => 'pcre'
75
  ),
76
  'fam' => array(
77
+ '5.1' => true,
 
 
 
 
 
 
 
78
  'alternative' => null
79
  ),
80
  'fbsql' => array(
81
+ '5.3' => true,
 
 
 
 
 
 
 
82
  'alternative' => null
83
  ),
84
  'fdf' => array(
85
+ '5.3' => true,
 
 
 
 
 
 
 
86
  'alternative' => 'pecl/fdf'
87
  ),
88
  'filepro' => array(
89
+ '5.2' => true,
 
 
 
 
 
 
 
90
  'alternative' => null
91
  ),
92
  'hw_api' => array(
93
+ '5.2' => true,
 
 
 
 
 
 
 
94
  'alternative' => null
95
  ),
96
  'ingres' => array(
97
+ '5.1' => true,
 
 
 
 
 
 
 
98
  'alternative' => 'pecl/ingres'
99
  ),
100
  'ircg' => array(
101
+ '5.1' => true,
 
 
 
 
 
 
 
102
  'alternative' => null
103
  ),
104
  'mcrypt' => array(
105
+ '7.1' => false,
 
106
  'alternative' => 'openssl (preferred) or pecl/mcrypt once available'
107
  ),
108
  'mcve' => array(
109
+ '5.1' => true,
 
 
 
 
 
 
 
110
  'alternative' => 'pecl/mvce'
111
  ),
112
  'ming' => array(
113
+ '5.3' => true,
 
 
 
 
 
 
 
114
  'alternative' => 'pecl/ming'
115
  ),
116
  'mnogosearch' => array(
117
+ '5.1' => true,
 
 
 
 
 
 
 
118
  'alternative' => null
119
  ),
120
  'msql' => array(
121
+ '5.3' => true,
 
 
 
 
 
 
 
122
  'alternative' => null
123
  ),
124
  'mssql' => array(
125
+ '7.0' => true,
126
  'alternative' => null
127
  ),
128
  'mysql_' => array(
129
+ '5.5' => false,
130
+ '7.0' => true,
 
 
 
 
 
 
131
  'alternative' => 'mysqli',
132
  ),
133
  'ncurses' => array(
134
+ '5.3' => true,
 
 
 
 
 
 
 
135
  'alternative' => 'pecl/ncurses'
136
  ),
137
  'oracle' => array(
138
+ '5.1' => true,
 
 
 
 
 
 
 
139
  'alternative' => 'oci8 or pdo_oci'
140
  ),
141
  'ovrimos' => array(
142
+ '5.1' => true,
 
 
 
 
 
 
 
143
  'alternative' => null
144
  ),
145
  'pfpro' => array(
146
+ '5.3' => true,
 
 
 
 
 
 
 
147
  'alternative' => null
148
  ),
149
  'sqlite' => array(
150
+ '5.4' => true,
 
 
 
 
 
 
 
151
  'alternative' => null
152
  ),
153
+ // Has to be before `sybase` as otherwise it will never match.
 
 
 
 
 
 
 
 
 
 
154
  'sybase_ct' => array(
155
+ '7.0' => true,
156
  'alternative' => null
157
  ),
158
+ 'sybase' => array(
159
+ '5.3' => true,
160
+ 'alternative' => 'sybase_ct'
161
+ ),
162
  'w32api' => array(
163
+ '5.1' => true,
 
 
 
 
 
 
 
164
  'alternative' => 'pecl/ffi'
165
  ),
166
  'yp' => array(
167
+ '5.1' => true,
 
 
 
 
 
 
 
168
  'alternative' => null
169
  ),
170
  );
176
  */
177
  public function register()
178
  {
179
+ // Handle case-insensitivity of function names.
180
+ $this->removedExtensions = $this->arrayKeysToLowercase($this->removedExtensions);
181
+
182
  return array(T_STRING);
183
 
184
  }//end register()
228
  return;
229
  }
230
 
231
+ $function = $tokens[$stackPtr]['content'];
232
+ $functionLc = strtolower($function);
233
+
234
+ if($this->isWhiteListed($functionLc) === true){
235
  // Function is whitelisted.
236
  return;
237
  }
238
 
239
  foreach ($this->removedExtensions as $extension => $versionList) {
240
+ if (strpos($functionLc, $extension) === 0) {
241
+ $itemInfo = array(
242
+ 'name' => $extension,
243
+ );
244
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
245
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  }
247
  }
248
 
249
  }//end process()
250
 
251
+
252
  /**
253
  * Is the current function being checked whitelisted ?
254
  *
280
 
281
  }//end isWhiteListed()
282
 
283
+
284
+ /**
285
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
286
+ *
287
+ * @param array $itemInfo Base information about the item.
288
+ *
289
+ * @return array Version and other information about the item.
290
+ */
291
+ public function getItemArray(array $itemInfo)
292
+ {
293
+ return $this->removedExtensions[$itemInfo['name']];
294
+ }
295
+
296
+
297
+ /**
298
+ * Get the error message template for this sniff.
299
+ *
300
+ * @return string
301
+ */
302
+ protected function getErrorMsgTemplate()
303
+ {
304
+ return "Extension '%s' is ";
305
+ }
306
+
307
+
308
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/RemovedFunctionParametersSniff.php CHANGED
@@ -14,14 +14,14 @@
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPCompatibility_Sniff
18
  {
19
  /**
20
  * A list of removed function parameters, which were present in older versions.
21
  *
22
- * The array lists : version number with true (deprecated) and false (removed).
23
  * The index is the location of the parameter in the parameter list, starting at 0 !
24
- * If's sufficient to list the first version where the function was deprecated/removed.
25
  *
26
  * @var array
27
  */
@@ -29,39 +29,32 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
29
  'gmmktime' => array(
30
  6 => array(
31
  'name' => 'is_dst',
32
- '5.1' => true, // deprecated
33
- '7.0' => false,
34
  ),
35
  ),
36
  'ldap_first_attribute' => array(
37
  2 => array(
38
  'name' => 'ber_identifier',
39
- '5.2.4' => false,
40
  ),
41
  ),
42
  'ldap_next_attribute' => array(
43
  2 => array(
44
  'name' => 'ber_identifier',
45
- '5.2.4' => false,
46
  ),
47
  ),
48
  'mktime' => array(
49
  6 => array(
50
  'name' => 'is_dst',
51
- '5.1' => true, // deprecated
52
- '7.0' => false,
53
  ),
54
  ),
55
  );
56
 
57
 
58
- /**
59
- *
60
- * @var array
61
- */
62
- private $removedFunctionParametersNames;
63
-
64
-
65
  /**
66
  * Returns an array of tokens this test wants to listen for.
67
  *
@@ -69,9 +62,8 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
69
  */
70
  public function register()
71
  {
72
- // Everyone has had a chance to figure out what removed function parameters
73
- // they want to check for, so now we can cache out the list.
74
- $this->removedFunctionParametersNames = array_keys($this->removedFunctionParameters);
75
 
76
  return array(T_STRING);
77
  }//end register()
@@ -102,9 +94,10 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
102
  return;
103
  }
104
 
105
- $function = strtolower($tokens[$stackPtr]['content']);
 
106
 
107
- if (in_array($function, $this->removedFunctionParametersNames) === false) {
108
  return;
109
  }
110
 
@@ -117,9 +110,14 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
117
  $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
118
  $parameterOffsetFound = $parameterCount - 1;
119
 
120
- foreach($this->removedFunctionParameters[$function] as $offset => $parameterDetails) {
121
  if ($offset <= $parameterOffsetFound) {
122
- $this->addError($phpcsFile, $openParenthesis, $function, $offset);
 
 
 
 
 
123
  }
124
  }
125
 
@@ -127,54 +125,86 @@ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPComp
127
 
128
 
129
  /**
130
- * Generates the error or warning for this sniff.
131
  *
132
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
133
- * @param int $stackPtr The position of the function
134
- * in the token array.
135
- * @param string $function The name of the function.
136
- * @param int $parameterLocation The parameter position within the function call.
137
  *
138
- * @return void
139
  */
140
- protected function addError($phpcsFile, $stackPtr, $function, $parameterLocation)
141
  {
142
- $error = '';
143
-
144
- $isError = false;
145
- $previousStatus = null;
146
- foreach ($this->removedFunctionParameters[$function][$parameterLocation] as $version => $present) {
147
- if ($version != 'name' && $this->supportsAbove($version)) {
148
-
149
- if ($previousStatus !== $present) {
150
- $previousStatus = $present;
151
- if ($present === false) {
152
- $isError = true;
153
- $error .= 'removed';
154
- } else {
155
- $error .= 'deprecated';
156
- }
157
- $error .= ' in PHP version ' . $version . ' and ';
158
- }
159
- }
160
- }
161
 
162
- if (strlen($error) > 0) {
163
- $error = 'The "%s" parameter for function %s was ' . $error;
164
- $error = substr($error, 0, strlen($error) - 5);
165
- $errorCode = 'RemovedParameter';
166
- $data = array(
167
- $this->removedFunctionParameters[$function][$parameterLocation]['name'],
168
- $function,
169
- );
170
-
171
- if ($isError === true) {
172
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
173
- } else {
174
- $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
175
- }
176
- }
177
 
178
- }//end addError()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
 
180
  }//end class
14
  * @package PHPCompatibility
15
  * @author Wim Godden <wim.godden@cu.be>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_RemovedFunctionParametersSniff extends PHPCompatibility_AbstractRemovedFeatureSniff
18
  {
19
  /**
20
  * A list of removed function parameters, which were present in older versions.
21
  *
22
+ * The array lists : version number with false (deprecated) and true (removed).
23
  * The index is the location of the parameter in the parameter list, starting at 0 !
24
+ * If's sufficient to list the first version where the function parameter was deprecated/removed.
25
  *
26
  * @var array
27
  */
29
  'gmmktime' => array(
30
  6 => array(
31
  'name' => 'is_dst',
32
+ '5.1' => false, // deprecated
33
+ '7.0' => true,
34
  ),
35
  ),
36
  'ldap_first_attribute' => array(
37
  2 => array(
38
  'name' => 'ber_identifier',
39
+ '5.2.4' => true,
40
  ),
41
  ),
42
  'ldap_next_attribute' => array(
43
  2 => array(
44
  'name' => 'ber_identifier',
45
+ '5.2.4' => true,
46
  ),
47
  ),
48
  'mktime' => array(
49
  6 => array(
50
  'name' => 'is_dst',
51
+ '5.1' => false, // deprecated
52
+ '7.0' => true,
53
  ),
54
  ),
55
  );
56
 
57
 
 
 
 
 
 
 
 
58
  /**
59
  * Returns an array of tokens this test wants to listen for.
60
  *
62
  */
63
  public function register()
64
  {
65
+ // Handle case-insensitivity of function names.
66
+ $this->removedFunctionParameters = $this->arrayKeysToLowercase($this->removedFunctionParameters);
 
67
 
68
  return array(T_STRING);
69
  }//end register()
94
  return;
95
  }
96
 
97
+ $function = $tokens[$stackPtr]['content'];
98
+ $functionLc = strtolower($function);
99
 
100
+ if (isset($this->removedFunctionParameters[$functionLc]) === false) {
101
  return;
102
  }
103
 
110
  $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
111
  $parameterOffsetFound = $parameterCount - 1;
112
 
113
+ foreach($this->removedFunctionParameters[$functionLc] as $offset => $parameterDetails) {
114
  if ($offset <= $parameterOffsetFound) {
115
+ $itemInfo = array(
116
+ 'name' => $function,
117
+ 'nameLc' => $functionLc,
118
+ 'offset' => $offset,
119
+ );
120
+ $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
121
  }
122
  }
123
 
125
 
126
 
127
  /**
128
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
129
  *
130
+ * @param array $itemInfo Base information about the item.
 
 
 
 
131
  *
132
+ * @return array Version and other information about the item.
133
  */
134
+ public function getItemArray(array $itemInfo)
135
  {
136
+ return $this->removedFunctionParameters[$itemInfo['nameLc']][$itemInfo['offset']];
137
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
 
140
+ /**
141
+ * Get an array of the non-PHP-version array keys used in a sub-array.
142
+ *
143
+ * @return array
144
+ */
145
+ protected function getNonVersionArrayKeys()
146
+ {
147
+ return array('name');
148
+ }
149
+
150
+
151
+ /**
152
+ * Retrieve the relevant detail (version) information for use in an error message.
153
+ *
154
+ * @param array $itemArray Version and other information about the item.
155
+ * @param array $itemInfo Base information about the item.
156
+ *
157
+ * @return array
158
+ */
159
+ public function getErrorInfo(array $itemArray, array $itemInfo)
160
+ {
161
+ $errorInfo = parent::getErrorInfo($itemArray, $itemInfo);
162
+ $errorInfo['paramName'] = $itemArray['name'];
163
+
164
+ return $errorInfo;
165
+ }
166
+
167
+
168
+ /**
169
+ * Get the item name to be used for the creation of the error code.
170
+ *
171
+ * @param array $itemInfo Base information about the item.
172
+ * @param array $errorInfo Detail information about an item.
173
+ *
174
+ * @return string
175
+ */
176
+ protected function getItemName(array $itemInfo, array $errorInfo)
177
+ {
178
+ return $itemInfo['name'].'_'.$errorInfo['paramName'];
179
+ }
180
+
181
+
182
+ /**
183
+ * Get the error message template for this sniff.
184
+ *
185
+ * @return string
186
+ */
187
+ protected function getErrorMsgTemplate()
188
+ {
189
+ return 'The "%s" parameter for function %s() is ';
190
+ }
191
+
192
+
193
+ /**
194
+ * Allow for concrete child classes to filter the error data before it's passed to PHPCS.
195
+ *
196
+ * @param array $data The error data array which was created.
197
+ * @param array $itemInfo Base information about the item this error message applied to.
198
+ * @param array $errorInfo Detail information about an item this error message applied to.
199
+ *
200
+ * @return array
201
+ */
202
+ protected function filterErrorData(array $data, array $itemInfo, array $errorInfo)
203
+ {
204
+ array_shift($data);
205
+ array_unshift($data, $errorInfo['paramName'], $itemInfo['name']);
206
+ return $data;
207
+ }
208
+
209
 
210
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/RemovedGlobalVariablesSniff.php CHANGED
@@ -16,20 +16,21 @@
16
  * @package PHPCompatibility
17
  * @author Wim Godden <wim.godden@cu.be>
18
  */
19
- class PHPCompatibility_Sniffs_PHP_RemovedGlobalVariablesSniff extends PHPCompatibility_Sniff
20
  {
21
 
22
  /**
23
- * A list of removed global variables with their alternative, if any
24
- * Array codes : 0 = removed/unavailable, -1 = deprecated, 1 = active
 
 
25
  *
26
  * @var array(string|null)
27
  */
28
  protected $removedGlobalVariables = array(
29
  'HTTP_RAW_POST_DATA' => array(
30
- '5.5' => 1,
31
- '5.6' => -1,
32
- '7.0' => 0,
33
  'alternative' => 'php://input'
34
  ),
35
  );
@@ -63,42 +64,36 @@ class PHPCompatibility_Sniffs_PHP_RemovedGlobalVariablesSniff extends PHPCompati
63
  return;
64
  }
65
 
66
- $versionList = $this->removedGlobalVariables[$varName];
67
-
68
- $error = '';
69
- $isError = false;
70
- foreach ($versionList as $version => $status) {
71
- if ($version !== 'alternative' && ($status === -1 || $status === 0)) {
72
- if ($this->supportsAbove($version)) {
73
- switch ($status) {
74
- case -1:
75
- $error .= 'deprecated since PHP ' . $version . ' and ';
76
- break;
77
- case 0:
78
- $isError = true;
79
- $error .= 'removed since PHP ' . $version . ' and ';
80
- break 2;
81
- }
82
- }
83
- }
84
- }
85
- if (strlen($error) > 0) {
86
- $error = "Global variable '%s' is " . $error;
87
- $error = substr($error, 0, strlen($error) - 5);
88
- $data = array(
89
- $tokens[$stackPtr]['content']
90
- );
91
- if (isset($versionList['alternative'])) {
92
- $error .= ' - use %s instead.';
93
- $data[] = $versionList['alternative'];
94
- }
95
- if ($isError === true) {
96
- $phpcsFile->addError($error, $stackPtr, 'Found', $data);
97
- } else {
98
- $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
99
- }
100
- }
101
 
102
  }//end process()
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  }//end class
16
  * @package PHPCompatibility
17
  * @author Wim Godden <wim.godden@cu.be>
18
  */
19
+ class PHPCompatibility_Sniffs_PHP_RemovedGlobalVariablesSniff extends PHPCompatibility_AbstractRemovedFeatureSniff
20
  {
21
 
22
  /**
23
+ * A list of removed global variables with their alternative, if any.
24
+ *
25
+ * The array lists : version number with false (deprecated) and true (removed).
26
+ * If's sufficient to list the first version where the variable was deprecated/removed.
27
  *
28
  * @var array(string|null)
29
  */
30
  protected $removedGlobalVariables = array(
31
  'HTTP_RAW_POST_DATA' => array(
32
+ '5.6' => false,
33
+ '7.0' => true,
 
34
  'alternative' => 'php://input'
35
  ),
36
  );
64
  return;
65
  }
66
 
67
+ $itemInfo = array(
68
+ 'name' => $varName,
69
+ );
70
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
  }//end process()
73
 
74
+
75
+ /**
76
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
77
+ *
78
+ * @param array $itemInfo Base information about the item.
79
+ *
80
+ * @return array Version and other information about the item.
81
+ */
82
+ public function getItemArray(array $itemInfo)
83
+ {
84
+ return $this->removedGlobalVariables[$itemInfo['name']];
85
+ }
86
+
87
+
88
+ /**
89
+ * Get the error message template for this sniff.
90
+ *
91
+ * @return string
92
+ */
93
+ protected function getErrorMsgTemplate()
94
+ {
95
+ return "Global variable '\$%s' is ";
96
+ }
97
+
98
+
99
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/RemovedHashAlgorithmsSniff.php CHANGED
@@ -22,7 +22,7 @@
22
  * @author Wim Godden <wim.godden@cu.be>
23
  * @copyright 2012 Cu.be Solutions bvba
24
  */
25
- class PHPCompatibility_Sniffs_PHP_RemovedHashAlgorithmsSniff extends PHPCompatibility_Sniff
26
  {
27
 
28
  /**
@@ -75,84 +75,36 @@ class PHPCompatibility_Sniffs_PHP_RemovedHashAlgorithmsSniff extends PHPCompatib
75
  return;
76
  }
77
 
78
- // Check if the algorithm used is deprecated or removed.
79
- $errorInfo = $this->getErrorInfo($algo);
80
-
81
- if ($errorInfo['deprecated'] !== '' || $errorInfo['removed'] !== '') {
82
- $this->addError($phpcsFile, $stackPtr, $algo, $errorInfo);
83
- }
84
 
85
  }//end process()
86
 
87
 
88
  /**
89
- * Retrieve the relevant (version) information for the error message.
90
  *
91
- * @param string $algorithm The name of the algorithm.
92
  *
93
- * @return array
94
  */
95
- protected function getErrorInfo($algorithm)
96
  {
97
- $errorInfo = array(
98
- 'deprecated' => '',
99
- 'removed' => '',
100
- 'error' => false,
101
- );
102
-
103
- foreach ($this->removedAlgorithms[$algorithm] as $version => $removed) {
104
- if ($this->supportsAbove($version)) {
105
- if ($removed === true && $errorInfo['removed'] === '') {
106
- $errorInfo['removed'] = $version;
107
- $errorInfo['error'] = true;
108
- } elseif ($errorInfo['deprecated'] === '') {
109
- $errorInfo['deprecated'] = $version;
110
- }
111
- }
112
- }
113
-
114
- return $errorInfo;
115
-
116
- }//end getErrorInfo()
117
 
118
 
119
  /**
120
- * Generates the error or warning for this sniff.
121
  *
122
- * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
123
- * @param int $stackPtr The position of the function
124
- * in the token array.
125
- * @param string $algorithm The name of the algorithm.
126
- * @param array $errorInfo Array with details about the versions
127
- * in which the algorithm was deprecated
128
- * and/or removed.
129
- *
130
- * @return void
131
  */
132
- protected function addError($phpcsFile, $stackPtr, $algorithm, $errorInfo)
133
  {
134
- $error = 'The %s hash algorithm is ';
135
- $errorCode = $algorithm . 'Found';
136
- $data = array($algorithm);
137
-
138
- if ($errorInfo['deprecated'] !== '') {
139
- $error .= 'deprecated since PHP version %s and ';
140
- $data[] = $errorInfo['deprecated'];
141
- }
142
- if ($errorInfo['removed'] !== '') {
143
- $error .= 'removed since PHP version %s and ';
144
- $data[] = $errorInfo['removed'];
145
- }
146
-
147
- // Remove the last 'and' from the message.
148
- $error = substr($error, 0, strlen($error) - 5);
149
-
150
- if ($errorInfo['error'] === true) {
151
- $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
152
- } else {
153
- $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data);
154
- }
155
 
156
- }//end addError()
157
 
158
  }//end class
22
  * @author Wim Godden <wim.godden@cu.be>
23
  * @copyright 2012 Cu.be Solutions bvba
24
  */
25
+ class PHPCompatibility_Sniffs_PHP_RemovedHashAlgorithmsSniff extends PHPCompatibility_AbstractRemovedFeatureSniff
26
  {
27
 
28
  /**
75
  return;
76
  }
77
 
78
+ $itemInfo = array(
79
+ 'name' => $algo,
80
+ );
81
+ $this->handleFeature($phpcsFile, $stackPtr, $itemInfo);
 
 
82
 
83
  }//end process()
84
 
85
 
86
  /**
87
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
88
  *
89
+ * @param array $itemInfo Base information about the item.
90
  *
91
+ * @return array Version and other information about the item.
92
  */
93
+ public function getItemArray(array $itemInfo)
94
  {
95
+ return $this->removedAlgorithms[$itemInfo['name']];
96
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
97
 
98
 
99
  /**
100
+ * Get the error message template for this sniff.
101
  *
102
+ * @return string
 
 
 
 
 
 
 
 
103
  */
104
+ protected function getErrorMsgTemplate()
105
  {
106
+ return 'The %s hash algorithm is ';
107
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
 
 
109
 
110
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/RequiredOptionalFunctionParametersSniff.php CHANGED
@@ -14,7 +14,7 @@
14
  * @package PHPCompatibility
15
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
  */
17
- class PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff extends PHPCompatibility_Sniff
18
  {
19
 
20
  /**
@@ -52,6 +52,9 @@ class PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff extend
52
  */
53
  public function register()
54
  {
 
 
 
55
  return array(T_STRING);
56
  }//end register()
57
 
@@ -81,9 +84,10 @@ class PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff extend
81
  return;
82
  }
83
 
84
- $function = strtolower($tokens[$stackPtr]['content']);
 
85
 
86
- if (isset($this->functionParameters[$function]) === false) {
87
  return;
88
  }
89
 
@@ -95,32 +99,124 @@ class PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff extend
95
  // If the parameter count returned > 0, we know there will be valid open parenthesis.
96
  $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
97
  $parameterOffsetFound = $parameterCount - 1;
98
- $requiredVersion = null;
99
- $parameterName = null;
100
 
101
- foreach($this->functionParameters[$function] as $offset => $parameterDetails) {
102
  if ($offset > $parameterOffsetFound) {
103
- foreach ($parameterDetails as $version => $present) {
104
- if ($version !== 'name' && $present === true && $this->supportsBelow($version)) {
105
- $requiredVersion = $version;
106
- $parameterName = $parameterDetails['name'];
107
- }
108
- }
109
  }
110
  }
111
-
112
- if (isset($requiredVersion, $parameterName)) {
113
-
114
- $error = 'The "%s" parameter for function %s is missing, but was required for PHP version %s and lower';
115
- $errorCode = 'MissingRequiredParameter';
116
- $data = array(
117
- $parameterName,
118
- $function,
119
- $requiredVersion,
120
- );
121
- $phpcsFile->addError($error, $openParenthesis, $errorCode, $data);
122
- }
123
 
124
  }//end process()
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  }//end class
14
  * @package PHPCompatibility
15
  * @author Juliette Reinders Folmer <phpcompatibility_nospam@adviesenzo.nl>
16
  */
17
+ class PHPCompatibility_Sniffs_PHP_RequiredOptionalFunctionParametersSniff extends PHPCompatibility_AbstractComplexVersionSniff
18
  {
19
 
20
  /**
52
  */
53
  public function register()
54
  {
55
+ // Handle case-insensitivity of function names.
56
+ $this->functionParameters = $this->arrayKeysToLowercase($this->functionParameters);
57
+
58
  return array(T_STRING);
59
  }//end register()
60
 
84
  return;
85
  }
86
 
87
+ $function = $tokens[$stackPtr]['content'];
88
+ $functionLc = strtolower($function);
89
 
90
+ if (isset($this->functionParameters[$functionLc]) === false) {
91
  return;
92
  }
93
 
99
  // If the parameter count returned > 0, we know there will be valid open parenthesis.
100
  $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true);
101
  $parameterOffsetFound = $parameterCount - 1;
 
 
102
 
103
+ foreach($this->functionParameters[$functionLc] as $offset => $parameterDetails) {
104
  if ($offset > $parameterOffsetFound) {
105
+ $itemInfo = array(
106
+ 'name' => $function,
107
+ 'nameLc' => $functionLc,
108
+ 'offset' => $offset,
109
+ );
110
+ $this->handleFeature($phpcsFile, $openParenthesis, $itemInfo);
111
  }
112
  }
 
 
 
 
 
 
 
 
 
 
 
 
113
 
114
  }//end process()
115
 
116
+
117
+ /**
118
+ * Determine whether an error/warning should be thrown for an item based on collected information.
119
+ *
120
+ * @param array $errorInfo Detail information about an item.
121
+ *
122
+ * @return bool
123
+ */
124
+ protected function shouldThrowError(array $errorInfo)
125
+ {
126
+ return ($errorInfo['requiredVersion'] !== '');
127
+ }
128
+
129
+
130
+ /**
131
+ * Get the relevant sub-array for a specific item from a multi-dimensional array.
132
+ *
133
+ * @param array $itemInfo Base information about the item.
134
+ *
135
+ * @return array Version and other information about the item.
136
+ */
137
+ public function getItemArray(array $itemInfo)
138
+ {
139
+ return $this->functionParameters[$itemInfo['nameLc']][$itemInfo['offset']];
140
+ }
141
+
142
+
143
+ /**
144
+ * Get an array of the non-PHP-version array keys used in a sub-array.
145
+ *
146
+ * @return array
147
+ */
148
+ protected function getNonVersionArrayKeys()
149
+ {
150
+ return array('name');
151
+ }
152
+
153
+
154
+ /**
155
+ * Retrieve the relevant detail (version) information for use in an error message.
156
+ *
157
+ * @param array $itemArray Version and other information about the item.
158
+ * @param array $itemInfo Base information about the item.
159
+ *
160
+ * @return array
161
+ */
162
+ public function getErrorInfo(array $itemArray, array $itemInfo)
163
+ {
164
+ $errorInfo = array(
165
+ 'paramName' => '',
166
+ 'requiredVersion' => '',
167
+ );
168
+
169
+ $versionArray = $this->getVersionArray($itemArray);
170
+
171
+ foreach ($versionArray as $version => $required) {
172
+ if ($version !== 'name' && $required === true && $this->supportsBelow($version) === true) {
173
+ $errorInfo['requiredVersion'] = $version;
174
+ }
175
+ }
176
+
177
+ $errorInfo['paramName'] = $itemArray['name'];
178
+
179
+ return $errorInfo;
180
+
181
+ }//end getErrorInfo()
182
+
183
+
184
+ /**
185
+ * Get the error message template for this sniff.
186
+ *
187
+ * @return string
188
+ */
189
+ protected function getErrorMsgTemplate()
190
+ {
191
+ return 'The "%s" parameter for function %s is missing, but was required for PHP version %s and lower';
192
+ }
193
+
194
+
195
+ /**
196
+ * Generates the error or warning for this item.
197
+ *
198
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
199
+ * @param int $stackPtr The position of the relevant token in
200
+ * the stack.
201
+ * @param array $itemInfo Base information about the item.
202
+ * @param array $errorInfo Array with detail (version) information
203
+ * relevant to the item.
204
+ *
205
+ * @return void
206
+ */
207
+ public function addError(PHP_CodeSniffer_File $phpcsFile, $stackPtr, array $itemInfo, array $errorInfo)
208
+ {
209
+ $error = $this->getErrorMsgTemplate();
210
+ $errorCode = $this->stringToErrorCode($itemInfo['name'].'_'.$errorInfo['paramName']).'Missing';
211
+ $data = array(
212
+ $errorInfo['paramName'],
213
+ $itemInfo['name'],
214
+ $errorInfo['requiredVersion'],
215
+ );
216
+
217
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
218
+
219
+ }//end addError()
220
+
221
+
222
  }//end class
vendor/wimg/php-compatibility/Sniffs/PHP/TernaryOperatorsSniff.php CHANGED
@@ -59,8 +59,11 @@ class PHPCompatibility_Sniffs_PHP_TernaryOperatorsSniff extends PHPCompatibility
59
  ($stackPtr + 1), null, true);
60
 
61
  if ($next !== false && $tokens[$next]['code'] === T_INLINE_ELSE) {
62
- $error = 'Middle may not be omitted from ternary operators in PHP < 5.3';
63
- $phpcsFile->addError($error, $stackPtr);
 
 
 
64
  }
65
  }
66
  }
59
  ($stackPtr + 1), null, true);
60
 
61
  if ($next !== false && $tokens[$next]['code'] === T_INLINE_ELSE) {
62
+ $phpcsFile->addError(
63
+ 'Middle may not be omitted from ternary operators in PHP < 5.3',
64
+ $stackPtr,
65
+ 'MiddleMissing'
66
+ );
67
  }
68
  }
69
  }
vendor/wimg/php-compatibility/Sniffs/PHP/ValidIntegersSniff.php CHANGED
@@ -69,29 +69,30 @@ class PHPCompatibility_Sniffs_PHP_ValidIntegersSniff extends PHPCompatibility_Sn
69
  return;
70
  }
71
 
72
- $data = array( $token['content'] );
73
- if ($this->isInvalidOctalInteger($tokens, $stackPtr) === true) {
74
- $error = 'Invalid octal integer detected. Prior to PHP 7 this would lead to a truncated number. From PHP 7 onwards this causes a parse error. Found: %s';
75
- $isError = $this->supportsAbove('7.0');
76
-
77
- if ($isError === true) {
78
- $phpcsFile->addError($error, $stackPtr, 'InvalidOctalIntegerFound', $data);
79
- } else {
80
- $phpcsFile->addWarning($error, $stackPtr, 'InvalidOctalIntegerFound', $data);
81
- }
82
 
 
 
 
 
 
 
 
 
 
83
  return;
84
  }
85
 
86
  if ($this->isHexidecimalNumericString($tokens, $stackPtr) === true) {
87
- $error = 'The behaviour of hexadecimal numeric strings was inconsistent prior to PHP 7 and support has been removed in PHP 7. Found: %s';
88
- $isError = $this->supportsAbove('7.0');
89
-
90
- if ($isError === true) {
91
- $phpcsFile->addError($error, $stackPtr, 'HexNumericStringFound', $data);
92
- } else {
93
- $phpcsFile->addWarning($error, $stackPtr, 'HexNumericStringFound', $data);
94
- }
95
  return;
96
  }
97
 
69
  return;
70
  }
71
 
72
+ $isError = $this->supportsAbove('7.0');
73
+ $data = array( $token['content'] );
 
 
 
 
 
 
 
 
74
 
75
+ if ($this->isInvalidOctalInteger($tokens, $stackPtr) === true) {
76
+ $this->addMessage(
77
+ $phpcsFile,
78
+ 'Invalid octal integer detected. Prior to PHP 7 this would lead to a truncated number. From PHP 7 onwards this causes a parse error. Found: %s',
79
+ $stackPtr,
80
+ $isError,
81
+ 'InvalidOctalIntegerFound',
82
+ $data
83
+ );
84
  return;
85
  }
86
 
87
  if ($this->isHexidecimalNumericString($tokens, $stackPtr) === true) {
88
+ $this->addMessage(
89
+ $phpcsFile,
90
+ 'The behaviour of hexadecimal numeric strings was inconsistent prior to PHP 7 and support has been removed in PHP 7. Found: %s',
91
+ $stackPtr,
92
+ $isError,
93
+ 'HexNumericStringFound',
94
+ $data
95
+ );
96
  return;
97
  }
98
 
wpengine-phpcompat.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: PHP Compatibility Checker
4
  Plugin URI: https://wpengine.com
5
  Description: Make sure your plugins and themes are compatible with newer PHP versions.
6
  Author: WP Engine
7
- Version: 1.4.0
8
  Author URI: https://wpengine.com
9
  Text Domain: php-compatibility-checker
10
  */
4
  Plugin URI: https://wpengine.com
5
  Description: Make sure your plugins and themes are compatible with newer PHP versions.
6
  Author: WP Engine
7
+ Version: 1.4.1
8
  Author URI: https://wpengine.com
9
  Text Domain: php-compatibility-checker
10
  */