PHP Compatibility Checker - Version 1.4.4

Version Description

  • PHP 5.2 Support & PHP 7.1 and 7.2 Lints.
  • Updated call to action sidebar depending on platform.
Download this release

Release Info

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

Code changes from version 1.4.3 to 1.4.4

Files changed (164) hide show
  1. load-files.php +33 -0
  2. php52/vendor/autoload.php +7 -0
  3. php52/vendor/autoload_52.php +7 -0
  4. php52/vendor/composer/ClassLoader.php +445 -0
  5. php52/vendor/composer/ClassLoader52.php +271 -0
  6. php52/vendor/composer/LICENSE +21 -0
  7. php52/vendor/composer/autoload_classmap.php +261 -0
  8. php52/vendor/composer/autoload_namespaces.php +10 -0
  9. php52/vendor/composer/autoload_psr4.php +10 -0
  10. php52/vendor/composer/autoload_real.php +52 -0
  11. php52/vendor/composer/autoload_real_52.php +44 -0
  12. php52/vendor/composer/autoload_static.php +298 -0
  13. php52/vendor/composer/installed.json +161 -0
  14. php52/vendor/squizlabs/php_codesniffer/CONTRIBUTING.md +13 -0
  15. php52/vendor/squizlabs/php_codesniffer/CodeSniffer.conf.dist +9 -0
  16. php52/vendor/squizlabs/php_codesniffer/CodeSniffer.php +2578 -0
  17. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php +1444 -0
  18. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/Generator.php +184 -0
  19. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/HTML.php +292 -0
  20. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/Markdown.php +179 -0
  21. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/Text.php +265 -0
  22. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Exception.php +31 -0
  23. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/File.php +3814 -0
  24. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Fixer.php +741 -0
  25. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Report.php +83 -0
  26. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reporting.php +425 -0
  27. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Cbf.php +151 -0
  28. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Checkstyle.php +128 -0
  29. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Csv.php +111 -0
  30. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Diff.php +149 -0
  31. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Emacs.php +110 -0
  32. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Full.php +237 -0
  33. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Gitblame.php +105 -0
  34. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Hgblame.php +124 -0
  35. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Info.php +162 -0
  36. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Json.php +128 -0
  37. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Junit.php +149 -0
  38. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Notifysend.php +262 -0
  39. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Source.php +334 -0
  40. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Summary.php +189 -0
  41. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Svnblame.php +90 -0
  42. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/VersionControl.php +342 -0
  43. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Xml.php +132 -0
  44. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Sniff.php +94 -0
  45. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractPatternSniff.php +962 -0
  46. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractScopeSniff.php +199 -0
  47. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractVariableSniff.php +245 -0
  48. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Classes/DuplicateClassNameStandard.xml +27 -0
  49. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Classes/OpeningBraceSameLineStandard.xml +28 -0
  50. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/EmptyStatementStandard.xml +23 -0
  51. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/ForLoopShouldBeWhileLoopStandard.xml +23 -0
  52. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/ForLoopWithTestFunctionCallStandard.xml +24 -0
  53. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/JumbledIncrementerStandard.xml +25 -0
  54. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/UnconditionalIfStatementStandard.xml +39 -0
  55. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/UnnecessaryFinalModifierStandard.xml +29 -0
  56. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/UnusedFunctionParameterStandard.xml +25 -0
  57. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/UselessOverridingMethodStandard.xml +32 -0
  58. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Commenting/FixmeStandard.xml +25 -0
  59. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Commenting/TodoStandard.xml +25 -0
  60. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/ControlStructures/InlineControlStructureStandard.xml +22 -0
  61. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Debug/CSSLintStandard.xml +19 -0
  62. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Debug/ClosureLinterStandard.xml +19 -0
  63. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Debug/JSHintStandard.xml +19 -0
  64. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/ByteOrderMarkStandard.xml +7 -0
  65. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/EndFileNewlineStandard.xml +7 -0
  66. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/EndFileNoNewlineStandard.xml +7 -0
  67. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/InlineHTMLStandard.xml +24 -0
  68. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/LineEndingsStandard.xml +7 -0
  69. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/LineLengthStandard.xml +7 -0
  70. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/LowercasedFilenameStandard.xml +7 -0
  71. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/OneClassPerFileStandard.xml +29 -0
  72. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/OneInterfacePerFileStandard.xml +29 -0
  73. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Formatting/DisallowMultipleStatementsStandard.xml +20 -0
  74. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Formatting/MultipleStatementAlignmentStandard.xml +56 -0
  75. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Formatting/NoSpaceAfterCastStandard.xml +19 -0
  76. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Formatting/SpaceAfterCastStandard.xml +19 -0
  77. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Functions/CallTimePassByReferenceStandard.xml +31 -0
  78. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Functions/FunctionCallArgumentSpacingStandard.xml +39 -0
  79. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceBsdAllmanStandard.xml +24 -0
  80. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceKernighanRitchieStandard.xml +24 -0
  81. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Metrics/CyclomaticComplexityStandard.xml +7 -0
  82. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Metrics/NestingLevelStandard.xml +7 -0
  83. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/NamingConventions/CamelCapsFunctionNameStandard.xml +23 -0
  84. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/NamingConventions/ConstructorNameStandard.xml +29 -0
  85. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/NamingConventions/UpperCaseConstantNameStandard.xml +29 -0
  86. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/BacktickOperatorStandard.xml +7 -0
  87. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/CharacterBeforePHPOpeningTagStandard.xml +22 -0
  88. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/ClosingPHPTagStandard.xml +22 -0
  89. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/DeprecatedFunctionsStandard.xml +19 -0
  90. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/DisallowAlternativePHPTagsStandard.xml +7 -0
  91. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/DisallowShortOpenTagStandard.xml +7 -0
  92. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/ForbiddenFunctionsStandard.xml +19 -0
  93. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/LowerCaseConstantStandard.xml +23 -0
  94. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/LowerCaseKeywordStandard.xml +19 -0
  95. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/NoSilencedErrorsStandard.xml +23 -0
  96. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/SAPIUsageStandard.xml +23 -0
  97. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/UpperCaseConstantStandard.xml +23 -0
  98. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Strings/UnnecessaryStringConcatStandard.xml +19 -0
  99. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/VersionControl/SubversionPropertiesStandard.xml +7 -0
  100. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/WhiteSpace/DisallowSpaceIndentStandard.xml +7 -0
  101. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/WhiteSpace/DisallowTabIndentStandard.xml +7 -0
  102. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/WhiteSpace/ScopeIndentStandard.xml +23 -0
  103. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php +79 -0
  104. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php +72 -0
  105. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php +127 -0
  106. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php +141 -0
  107. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php +106 -0
  108. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php +102 -0
  109. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php +111 -0
  110. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php +146 -0
  111. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php +104 -0
  112. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php +96 -0
  113. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php +187 -0
  114. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php +172 -0
  115. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php +350 -0
  116. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php +91 -0
  117. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php +89 -0
  118. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php +316 -0
  119. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/CSSLintSniff.php +107 -0
  120. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php +128 -0
  121. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/ESLintSniff.php +121 -0
  122. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php +99 -0
  123. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php +94 -0
  124. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php +94 -0
  125. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php +91 -0
  126. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php +70 -0
  127. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php +151 -0
  128. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php +177 -0
  129. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php +78 -0
  130. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php +62 -0
  131. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php +62 -0
  132. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php +62 -0
  133. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php +102 -0
  134. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php +330 -0
  135. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php +72 -0
  136. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php +83 -0
  137. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php +90 -0
  138. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php +159 -0
  139. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php +179 -0
  140. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php +191 -0
  141. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php +180 -0
  142. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php +127 -0
  143. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php +112 -0
  144. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php +221 -0
  145. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php +148 -0
  146. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php +187 -0
  147. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php +63 -0
  148. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php +74 -0
  149. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php +62 -0
  150. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php +95 -0
  151. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php +269 -0
  152. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php +182 -0
  153. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php +243 -0
  154. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php +98 -0
  155. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php +148 -0
  156. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php +79 -0
  157. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php +79 -0
  158. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/SyntaxSniff.php +97 -0
  159. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php +88 -0
  160. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php +138 -0
  161. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php +204 -0
  162. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php +184 -0
  163. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php +149 -0
  164. php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php +1170 -0
load-files.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dependency loader
4
+ *
5
+ * @package WPEngine\PHPCompat
6
+ * @since 1.0.0
7
+ */
8
+
9
+ // Exit if this file is directly accessed.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ /**
15
+ * Loads the plugin files.
16
+ */
17
+ function wpephpcompat_load_files() {
18
+ require_once dirname( __FILE__ ) . '/src/wpephpcompat.php';
19
+
20
+ if ( version_compare( phpversion(), '5.3', '<' ) ) {
21
+ $autoload_file = dirname( __FILE__ ) . '/php52/vendor/autoload_52.php';
22
+ } else {
23
+ $autoload_file = dirname( __FILE__ ) . '/vendor/autoload.php';
24
+ }
25
+
26
+ require_once $autoload_file;
27
+
28
+ if ( defined( 'WP_CLI' ) && WP_CLI ) {
29
+ require_once dirname( __FILE__ ) . '/src/wpcli.php';
30
+ }
31
+ }
32
+
33
+ wpephpcompat_load_files();
php52/vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit9822e31ee142ea70a5a882638b9cf0bf::getLoader();
php52/vendor/autoload_52.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_52.php generated by xrstf/composer-php52
4
+
5
+ require_once dirname(__FILE__) . '/composer'.'/autoload_real_52.php';
6
+
7
+ return ComposerAutoloaderInita4ae2997dc6cca14c59c813063e62e17::getLoader();
php52/vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see http://www.php-fig.org/psr/psr-0/
41
+ * @see http://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
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
+ {
62
+ if (!empty($this->prefixesPsr0)) {
63
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
64
+ }
65
+
66
+ return array();
67
+ }
68
+
69
+ public function getPrefixesPsr4()
70
+ {
71
+ return $this->prefixDirsPsr4;
72
+ }
73
+
74
+ public function getFallbackDirs()
75
+ {
76
+ return $this->fallbackDirsPsr0;
77
+ }
78
+
79
+ public function getFallbackDirsPsr4()
80
+ {
81
+ return $this->fallbackDirsPsr4;
82
+ }
83
+
84
+ public function getClassMap()
85
+ {
86
+ return $this->classMap;
87
+ }
88
+
89
+ /**
90
+ * @param array $classMap Class to filename map
91
+ */
92
+ public function addClassMap(array $classMap)
93
+ {
94
+ if ($this->classMap) {
95
+ $this->classMap = array_merge($this->classMap, $classMap);
96
+ } else {
97
+ $this->classMap = $classMap;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Registers a set of PSR-0 directories for a given prefix, either
103
+ * appending or prepending to the ones previously set for this prefix.
104
+ *
105
+ * @param string $prefix The prefix
106
+ * @param array|string $paths The PSR-0 root directories
107
+ * @param bool $prepend Whether to prepend the directories
108
+ */
109
+ public function add($prefix, $paths, $prepend = false)
110
+ {
111
+ if (!$prefix) {
112
+ if ($prepend) {
113
+ $this->fallbackDirsPsr0 = array_merge(
114
+ (array) $paths,
115
+ $this->fallbackDirsPsr0
116
+ );
117
+ } else {
118
+ $this->fallbackDirsPsr0 = array_merge(
119
+ $this->fallbackDirsPsr0,
120
+ (array) $paths
121
+ );
122
+ }
123
+
124
+ return;
125
+ }
126
+
127
+ $first = $prefix[0];
128
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
129
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
130
+
131
+ return;
132
+ }
133
+ if ($prepend) {
134
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
135
+ (array) $paths,
136
+ $this->prefixesPsr0[$first][$prefix]
137
+ );
138
+ } else {
139
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
140
+ $this->prefixesPsr0[$first][$prefix],
141
+ (array) $paths
142
+ );
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Registers a set of PSR-4 directories for a given namespace, either
148
+ * appending or prepending to the ones previously set for this namespace.
149
+ *
150
+ * @param string $prefix The prefix/namespace, with trailing '\\'
151
+ * @param array|string $paths The PSR-4 base directories
152
+ * @param bool $prepend Whether to prepend the directories
153
+ *
154
+ * @throws \InvalidArgumentException
155
+ */
156
+ public function addPsr4($prefix, $paths, $prepend = false)
157
+ {
158
+ if (!$prefix) {
159
+ // Register directories for the root namespace.
160
+ if ($prepend) {
161
+ $this->fallbackDirsPsr4 = array_merge(
162
+ (array) $paths,
163
+ $this->fallbackDirsPsr4
164
+ );
165
+ } else {
166
+ $this->fallbackDirsPsr4 = array_merge(
167
+ $this->fallbackDirsPsr4,
168
+ (array) $paths
169
+ );
170
+ }
171
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
172
+ // Register directories for a new namespace.
173
+ $length = strlen($prefix);
174
+ if ('\\' !== $prefix[$length - 1]) {
175
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176
+ }
177
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
179
+ } elseif ($prepend) {
180
+ // Prepend directories for an already registered namespace.
181
+ $this->prefixDirsPsr4[$prefix] = array_merge(
182
+ (array) $paths,
183
+ $this->prefixDirsPsr4[$prefix]
184
+ );
185
+ } else {
186
+ // Append directories for an already registered namespace.
187
+ $this->prefixDirsPsr4[$prefix] = array_merge(
188
+ $this->prefixDirsPsr4[$prefix],
189
+ (array) $paths
190
+ );
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Registers a set of PSR-0 directories for a given prefix,
196
+ * replacing any others previously set for this prefix.
197
+ *
198
+ * @param string $prefix The prefix
199
+ * @param array|string $paths The PSR-0 base directories
200
+ */
201
+ public function set($prefix, $paths)
202
+ {
203
+ if (!$prefix) {
204
+ $this->fallbackDirsPsr0 = (array) $paths;
205
+ } else {
206
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Registers a set of PSR-4 directories for a given namespace,
212
+ * replacing any others previously set for this namespace.
213
+ *
214
+ * @param string $prefix The prefix/namespace, with trailing '\\'
215
+ * @param array|string $paths The PSR-4 base directories
216
+ *
217
+ * @throws \InvalidArgumentException
218
+ */
219
+ public function setPsr4($prefix, $paths)
220
+ {
221
+ if (!$prefix) {
222
+ $this->fallbackDirsPsr4 = (array) $paths;
223
+ } else {
224
+ $length = strlen($prefix);
225
+ if ('\\' !== $prefix[$length - 1]) {
226
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227
+ }
228
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Turns on searching the include path for class files.
235
+ *
236
+ * @param bool $useIncludePath
237
+ */
238
+ public function setUseIncludePath($useIncludePath)
239
+ {
240
+ $this->useIncludePath = $useIncludePath;
241
+ }
242
+
243
+ /**
244
+ * Can be used to check if the autoloader uses the include path to check
245
+ * for classes.
246
+ *
247
+ * @return bool
248
+ */
249
+ public function getUseIncludePath()
250
+ {
251
+ return $this->useIncludePath;
252
+ }
253
+
254
+ /**
255
+ * Turns off searching the prefix and fallback directories for classes
256
+ * that have not been registered with the class map.
257
+ *
258
+ * @param bool $classMapAuthoritative
259
+ */
260
+ public function setClassMapAuthoritative($classMapAuthoritative)
261
+ {
262
+ $this->classMapAuthoritative = $classMapAuthoritative;
263
+ }
264
+
265
+ /**
266
+ * Should class lookup fail if not found in the current class map?
267
+ *
268
+ * @return bool
269
+ */
270
+ public function isClassMapAuthoritative()
271
+ {
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
+ *
298
+ * @param bool $prepend Whether to prepend the autoloader or not
299
+ */
300
+ public function register($prepend = false)
301
+ {
302
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
303
+ }
304
+
305
+ /**
306
+ * Unregisters this instance as an autoloader.
307
+ */
308
+ public function unregister()
309
+ {
310
+ spl_autoload_unregister(array($this, 'loadClass'));
311
+ }
312
+
313
+ /**
314
+ * Loads the given class or interface.
315
+ *
316
+ * @param string $class The name of the class
317
+ * @return bool|null True if loaded, null otherwise
318
+ */
319
+ public function loadClass($class)
320
+ {
321
+ if ($file = $this->findFile($class)) {
322
+ includeFile($file);
323
+
324
+ return true;
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Finds the path to the file where the class is defined.
330
+ *
331
+ * @param string $class The name of the class
332
+ *
333
+ * @return string|false The path if found, false otherwise
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;
368
+ }
369
+
370
+ private function findFileWithExtension($class, $ext)
371
+ {
372
+ // PSR-4 lookup
373
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
374
+
375
+ $first = $class[0];
376
+ if (isset($this->prefixLengthsPsr4[$first])) {
377
+ $subPath = $class;
378
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
379
+ $subPath = substr($subPath, 0, $lastPos);
380
+ $search = $subPath.'\\';
381
+ if (isset($this->prefixDirsPsr4[$search])) {
382
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
383
+ $length = $this->prefixLengthsPsr4[$first][$search];
384
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
385
+ return $file;
386
+ }
387
+ }
388
+ }
389
+ }
390
+ }
391
+
392
+ // PSR-4 fallback dirs
393
+ foreach ($this->fallbackDirsPsr4 as $dir) {
394
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
395
+ return $file;
396
+ }
397
+ }
398
+
399
+ // PSR-0 lookup
400
+ if (false !== $pos = strrpos($class, '\\')) {
401
+ // namespaced class name
402
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
403
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
404
+ } else {
405
+ // PEAR-like class name
406
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
407
+ }
408
+
409
+ if (isset($this->prefixesPsr0[$first])) {
410
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
411
+ if (0 === strpos($class, $prefix)) {
412
+ foreach ($dirs as $dir) {
413
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
414
+ return $file;
415
+ }
416
+ }
417
+ }
418
+ }
419
+ }
420
+
421
+ // PSR-0 fallback dirs
422
+ foreach ($this->fallbackDirsPsr0 as $dir) {
423
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
424
+ return $file;
425
+ }
426
+ }
427
+
428
+ // PSR-0 include paths.
429
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
430
+ return $file;
431
+ }
432
+
433
+ return false;
434
+ }
435
+ }
436
+
437
+ /**
438
+ * Scope isolated include.
439
+ *
440
+ * Prevents access to $this/self from included files.
441
+ */
442
+ function includeFile($file)
443
+ {
444
+ include $file;
445
+ }
php52/vendor/composer/ClassLoader52.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Copyright (c) 2013, Christoph Mewes, http://www.xrstf.de
4
+ *
5
+ * This file is released under the terms of the MIT license. You can find the
6
+ * complete text in the attached LICENSE file or online at:
7
+ *
8
+ * http://www.opensource.org/licenses/mit-license.php
9
+ *
10
+ * --------------------------------------------------------------------------
11
+ *
12
+ * 99% of this is copied as-is from the original Composer source code and is
13
+ * released under MIT license as well. Copyright goes to:
14
+ *
15
+ * - Fabien Potencier <fabien@symfony.com>
16
+ * - Jordi Boggiano <j.boggiano@seld.be>
17
+ */
18
+
19
+ class xrstf_Composer52_ClassLoader {
20
+ private $prefixes = array();
21
+ private $fallbackDirs = array();
22
+ private $useIncludePath = false;
23
+ private $classMap = array();
24
+ private $classMapAuthoratative = false;
25
+ private $allowUnderscore = false;
26
+
27
+ /**
28
+ * @param boolean $flag true to allow class names with a leading underscore, false to disable
29
+ */
30
+ public function setAllowUnderscore($flag) {
31
+ $this->allowUnderscore = (boolean) $flag;
32
+ }
33
+
34
+ /**
35
+ * @return array
36
+ */
37
+ public function getPrefixes() {
38
+ return $this->prefixes;
39
+ }
40
+
41
+ /**
42
+ * Turns off searching the prefix and fallback directories for classes
43
+ * that have not been registered with the class map.
44
+ *
45
+ * @param bool $classMapAuthoratative
46
+ */
47
+ public function setClassMapAuthoritative($classMapAuthoratative) {
48
+ $this->classMapAuthoratative = $classMapAuthoratative;
49
+ }
50
+
51
+ /**
52
+ * Should class lookup fail if not found in the current class map?
53
+ *
54
+ * @return bool
55
+ */
56
+ public function getClassMapAuthoratative() {
57
+ return $this->classMapAuthoratative;
58
+ }
59
+
60
+ /**
61
+ * @return array
62
+ */
63
+ public function getFallbackDirs() {
64
+ return $this->fallbackDirs;
65
+ }
66
+
67
+ /**
68
+ * @return array
69
+ */
70
+ public function getClassMap() {
71
+ return $this->classMap;
72
+ }
73
+
74
+ /**
75
+ * @param array $classMap class to filename map
76
+ */
77
+ public function addClassMap(array $classMap) {
78
+ if ($this->classMap) {
79
+ $this->classMap = array_merge($this->classMap, $classMap);
80
+ }
81
+ else {
82
+ $this->classMap = $classMap;
83
+ }
84
+ }
85
+
86
+ /**
87
+ * Registers a set of classes, merging with any others previously set.
88
+ *
89
+ * @param string $prefix the classes prefix
90
+ * @param array|string $paths the location(s) of the classes
91
+ * @param bool $prepend prepend the location(s)
92
+ */
93
+ public function add($prefix, $paths, $prepend = false) {
94
+ if (!$prefix) {
95
+ if ($prepend) {
96
+ $this->fallbackDirs = array_merge(
97
+ (array) $paths,
98
+ $this->fallbackDirs
99
+ );
100
+ }
101
+ else {
102
+ $this->fallbackDirs = array_merge(
103
+ $this->fallbackDirs,
104
+ (array) $paths
105
+ );
106
+ }
107
+
108
+ return;
109
+ }
110
+
111
+ if (!isset($this->prefixes[$prefix])) {
112
+ $this->prefixes[$prefix] = (array) $paths;
113
+ return;
114
+ }
115
+
116
+ if ($prepend) {
117
+ $this->prefixes[$prefix] = array_merge(
118
+ (array) $paths,
119
+ $this->prefixes[$prefix]
120
+ );
121
+ }
122
+ else {
123
+ $this->prefixes[$prefix] = array_merge(
124
+ $this->prefixes[$prefix],
125
+ (array) $paths
126
+ );
127
+ }
128
+ }
129
+
130
+ /**
131
+ * Registers a set of classes, replacing any others previously set.
132
+ *
133
+ * @param string $prefix the classes prefix
134
+ * @param array|string $paths the location(s) of the classes
135
+ */
136
+ public function set($prefix, $paths) {
137
+ if (!$prefix) {
138
+ $this->fallbackDirs = (array) $paths;
139
+ return;
140
+ }
141
+
142
+ $this->prefixes[$prefix] = (array) $paths;
143
+ }
144
+
145
+ /**
146
+ * Turns on searching the include path for class files.
147
+ *
148
+ * @param bool $useIncludePath
149
+ */
150
+ public function setUseIncludePath($useIncludePath) {
151
+ $this->useIncludePath = $useIncludePath;
152
+ }
153
+
154
+ /**
155
+ * Can be used to check if the autoloader uses the include path to check
156
+ * for classes.
157
+ *
158
+ * @return bool
159
+ */
160
+ public function getUseIncludePath() {
161
+ return $this->useIncludePath;
162
+ }
163
+
164
+ /**
165
+ * Registers this instance as an autoloader.
166
+ */
167
+ public function register() {
168
+ spl_autoload_register(array($this, 'loadClass'), true);
169
+ }
170
+
171
+ /**
172
+ * Unregisters this instance as an autoloader.
173
+ */
174
+ public function unregister() {
175
+ spl_autoload_unregister(array($this, 'loadClass'));
176
+ }
177
+
178
+ /**
179
+ * Loads the given class or interface.
180
+ *
181
+ * @param string $class the name of the class
182
+ * @return bool|null true, if loaded
183
+ */
184
+ public function loadClass($class) {
185
+ if ($file = $this->findFile($class)) {
186
+ include $file;
187
+ return true;
188
+ }
189
+ }
190
+
191
+ /**
192
+ * Finds the path to the file where the class is defined.
193
+ *
194
+ * @param string $class the name of the class
195
+ * @return string|null the path, if found
196
+ */
197
+ public function findFile($class) {
198
+ if ('\\' === $class[0]) {
199
+ $class = substr($class, 1);
200
+ }
201
+
202
+ if (isset($this->classMap[$class])) {
203
+ return $this->classMap[$class];
204
+ }
205
+ elseif ($this->classMapAuthoratative) {
206
+ return false;
207
+ }
208
+
209
+ $classPath = $this->getClassPath($class);
210
+
211
+ foreach ($this->prefixes as $prefix => $dirs) {
212
+ if (0 === strpos($class, $prefix)) {
213
+ foreach ($dirs as $dir) {
214
+ if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
215
+ return $dir.DIRECTORY_SEPARATOR.$classPath;
216
+ }
217
+ }
218
+ }
219
+ }
220
+
221
+ foreach ($this->fallbackDirs as $dir) {
222
+ if (file_exists($dir.DIRECTORY_SEPARATOR.$classPath)) {
223
+ return $dir.DIRECTORY_SEPARATOR.$classPath;
224
+ }
225
+ }
226
+
227
+ if ($this->useIncludePath && $file = self::resolveIncludePath($classPath)) {
228
+ return $file;
229
+ }
230
+
231
+ return $this->classMap[$class] = false;
232
+ }
233
+
234
+ private function getClassPath($class) {
235
+ if (false !== $pos = strrpos($class, '\\')) {
236
+ // namespaced class name
237
+ $classPath = str_replace('\\', DIRECTORY_SEPARATOR, substr($class, 0, $pos)).DIRECTORY_SEPARATOR;
238
+ $className = substr($class, $pos + 1);
239
+ }
240
+ else {
241
+ // PEAR-like class name
242
+ $classPath = null;
243
+ $className = $class;
244
+ }
245
+
246
+ $className = str_replace('_', DIRECTORY_SEPARATOR, $className);
247
+
248
+ // restore the prefix
249
+ if ($this->allowUnderscore && DIRECTORY_SEPARATOR === $className[0]) {
250
+ $className[0] = '_';
251
+ }
252
+
253
+ $classPath .= $className.'.php';
254
+
255
+ return $classPath;
256
+ }
257
+
258
+ public static function resolveIncludePath($classPath) {
259
+ $paths = explode(PATH_SEPARATOR, get_include_path());
260
+
261
+ foreach ($paths as $path) {
262
+ $path = rtrim($path, '/\\');
263
+
264
+ if ($file = file_exists($path.DIRECTORY_SEPARATOR.$file)) {
265
+ return $file;
266
+ }
267
+ }
268
+
269
+ return false;
270
+ }
271
+ }
php52/vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
php52/vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,261 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ 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_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',
16
+ 'Generic_Sniffs_CodeAnalysis_JumbledIncrementerSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php',
17
+ 'Generic_Sniffs_CodeAnalysis_UnconditionalIfStatementSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php',
18
+ 'Generic_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php',
19
+ 'Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php',
20
+ 'Generic_Sniffs_CodeAnalysis_UselessOverridingMethodSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php',
21
+ 'Generic_Sniffs_Commenting_DocCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php',
22
+ 'Generic_Sniffs_Commenting_FixmeSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php',
23
+ 'Generic_Sniffs_Commenting_TodoSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php',
24
+ 'Generic_Sniffs_ControlStructures_InlineControlStructureSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php',
25
+ 'Generic_Sniffs_Debug_CSSLintSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/CSSLintSniff.php',
26
+ 'Generic_Sniffs_Debug_ClosureLinterSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php',
27
+ 'Generic_Sniffs_Debug_ESLintSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/ESLintSniff.php',
28
+ 'Generic_Sniffs_Debug_JSHintSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php',
29
+ 'Generic_Sniffs_Files_ByteOrderMarkSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php',
30
+ 'Generic_Sniffs_Files_EndFileNewlineSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php',
31
+ 'Generic_Sniffs_Files_EndFileNoNewlineSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php',
32
+ 'Generic_Sniffs_Files_InlineHTMLSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php',
33
+ 'Generic_Sniffs_Files_LineEndingsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php',
34
+ 'Generic_Sniffs_Files_LineLengthSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php',
35
+ 'Generic_Sniffs_Files_LowercasedFilenameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php',
36
+ 'Generic_Sniffs_Files_OneClassPerFileSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php',
37
+ 'Generic_Sniffs_Files_OneInterfacePerFileSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php',
38
+ 'Generic_Sniffs_Files_OneTraitPerFileSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php',
39
+ 'Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php',
40
+ 'Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php',
41
+ 'Generic_Sniffs_Formatting_NoSpaceAfterCastSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php',
42
+ 'Generic_Sniffs_Formatting_SpaceAfterCastSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php',
43
+ 'Generic_Sniffs_Formatting_SpaceAfterNotSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php',
44
+ 'Generic_Sniffs_Functions_CallTimePassByReferenceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php',
45
+ 'Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php',
46
+ 'Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php',
47
+ 'Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php',
48
+ 'Generic_Sniffs_Metrics_CyclomaticComplexitySniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php',
49
+ 'Generic_Sniffs_Metrics_NestingLevelSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php',
50
+ 'Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php',
51
+ 'Generic_Sniffs_NamingConventions_ConstructorNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php',
52
+ 'Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php',
53
+ 'Generic_Sniffs_PHP_BacktickOperatorSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php',
54
+ 'Generic_Sniffs_PHP_CharacterBeforePHPOpeningTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php',
55
+ 'Generic_Sniffs_PHP_ClosingPHPTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php',
56
+ 'Generic_Sniffs_PHP_DeprecatedFunctionsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php',
57
+ 'Generic_Sniffs_PHP_DisallowAlternativePHPTagsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php',
58
+ 'Generic_Sniffs_PHP_DisallowShortOpenTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php',
59
+ 'Generic_Sniffs_PHP_ForbiddenFunctionsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php',
60
+ 'Generic_Sniffs_PHP_LowerCaseConstantSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php',
61
+ 'Generic_Sniffs_PHP_LowerCaseKeywordSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php',
62
+ 'Generic_Sniffs_PHP_NoSilencedErrorsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php',
63
+ 'Generic_Sniffs_PHP_SAPIUsageSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php',
64
+ 'Generic_Sniffs_PHP_SyntaxSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/SyntaxSniff.php',
65
+ 'Generic_Sniffs_PHP_UpperCaseConstantSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php',
66
+ 'Generic_Sniffs_Strings_UnnecessaryStringConcatSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php',
67
+ 'Generic_Sniffs_VersionControl_SubversionPropertiesSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php',
68
+ 'Generic_Sniffs_WhiteSpace_DisallowSpaceIndentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php',
69
+ 'Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php',
70
+ 'Generic_Sniffs_WhiteSpace_ScopeIndentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php',
71
+ 'MySource_Sniffs_CSS_BrowserSpecificStylesSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php',
72
+ 'MySource_Sniffs_Channels_DisallowSelfActionsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php',
73
+ 'MySource_Sniffs_Channels_IncludeOwnSystemSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php',
74
+ 'MySource_Sniffs_Channels_IncludeSystemSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php',
75
+ 'MySource_Sniffs_Channels_UnusedSystemSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php',
76
+ 'MySource_Sniffs_Commenting_FunctionCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php',
77
+ 'MySource_Sniffs_Debug_DebugCodeSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php',
78
+ 'MySource_Sniffs_Debug_FirebugConsoleSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php',
79
+ 'MySource_Sniffs_Objects_AssignThisSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Objects/AssignThisSniff.php',
80
+ 'MySource_Sniffs_Objects_CreateWidgetTypeCallbackSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php',
81
+ 'MySource_Sniffs_Objects_DisallowNewWidgetSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php',
82
+ 'MySource_Sniffs_PHP_AjaxNullComparisonSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php',
83
+ 'MySource_Sniffs_PHP_EvalObjectFactorySniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php',
84
+ 'MySource_Sniffs_PHP_GetRequestDataSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php',
85
+ 'MySource_Sniffs_PHP_ReturnFunctionValueSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php',
86
+ 'MySource_Sniffs_Strings_JoinStringsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php',
87
+ 'PEAR_Sniffs_Classes_ClassDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php',
88
+ 'PEAR_Sniffs_Commenting_ClassCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php',
89
+ 'PEAR_Sniffs_Commenting_FileCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php',
90
+ 'PEAR_Sniffs_Commenting_FunctionCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php',
91
+ 'PEAR_Sniffs_Commenting_InlineCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php',
92
+ 'PEAR_Sniffs_ControlStructures_ControlSignatureSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php',
93
+ 'PEAR_Sniffs_ControlStructures_MultiLineConditionSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php',
94
+ 'PEAR_Sniffs_Files_IncludingFileSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php',
95
+ 'PEAR_Sniffs_Formatting_MultiLineAssignmentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php',
96
+ 'PEAR_Sniffs_Functions_FunctionCallSignatureSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php',
97
+ 'PEAR_Sniffs_Functions_FunctionDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php',
98
+ 'PEAR_Sniffs_Functions_ValidDefaultValueSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php',
99
+ 'PEAR_Sniffs_NamingConventions_ValidClassNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php',
100
+ 'PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php',
101
+ 'PEAR_Sniffs_NamingConventions_ValidVariableNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php',
102
+ 'PEAR_Sniffs_WhiteSpace_ObjectOperatorIndentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php',
103
+ 'PEAR_Sniffs_WhiteSpace_ScopeClosingBraceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php',
104
+ 'PEAR_Sniffs_WhiteSpace_ScopeIndentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php',
105
+ 'PHP_CodeSniffer' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer.php',
106
+ 'PHP_CodeSniffer_CLI' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/CLI.php',
107
+ 'PHP_CodeSniffer_DocGenerators_Generator' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/Generator.php',
108
+ 'PHP_CodeSniffer_DocGenerators_HTML' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/HTML.php',
109
+ 'PHP_CodeSniffer_DocGenerators_Markdown' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/Markdown.php',
110
+ 'PHP_CodeSniffer_DocGenerators_Text' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/Text.php',
111
+ 'PHP_CodeSniffer_Exception' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Exception.php',
112
+ 'PHP_CodeSniffer_File' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/File.php',
113
+ 'PHP_CodeSniffer_Fixer' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Fixer.php',
114
+ 'PHP_CodeSniffer_Report' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Report.php',
115
+ 'PHP_CodeSniffer_Reporting' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reporting.php',
116
+ 'PHP_CodeSniffer_Reports_Cbf' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Cbf.php',
117
+ 'PHP_CodeSniffer_Reports_Checkstyle' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Checkstyle.php',
118
+ 'PHP_CodeSniffer_Reports_Csv' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Csv.php',
119
+ 'PHP_CodeSniffer_Reports_Diff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Diff.php',
120
+ 'PHP_CodeSniffer_Reports_Emacs' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Emacs.php',
121
+ 'PHP_CodeSniffer_Reports_Full' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Full.php',
122
+ 'PHP_CodeSniffer_Reports_Gitblame' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Gitblame.php',
123
+ 'PHP_CodeSniffer_Reports_Hgblame' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Hgblame.php',
124
+ 'PHP_CodeSniffer_Reports_Info' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Info.php',
125
+ 'PHP_CodeSniffer_Reports_Json' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Json.php',
126
+ 'PHP_CodeSniffer_Reports_Junit' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Junit.php',
127
+ 'PHP_CodeSniffer_Reports_Notifysend' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Notifysend.php',
128
+ 'PHP_CodeSniffer_Reports_Source' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Source.php',
129
+ 'PHP_CodeSniffer_Reports_Summary' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Summary.php',
130
+ 'PHP_CodeSniffer_Reports_Svnblame' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Svnblame.php',
131
+ 'PHP_CodeSniffer_Reports_VersionControl' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/VersionControl.php',
132
+ 'PHP_CodeSniffer_Reports_Xml' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Xml.php',
133
+ 'PHP_CodeSniffer_Sniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Sniff.php',
134
+ 'PHP_CodeSniffer_Standards_AbstractPatternSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractPatternSniff.php',
135
+ 'PHP_CodeSniffer_Standards_AbstractScopeSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractScopeSniff.php',
136
+ 'PHP_CodeSniffer_Standards_AbstractVariableSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractVariableSniff.php',
137
+ 'PHP_CodeSniffer_Standards_IncorrectPatternException' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/IncorrectPatternException.php',
138
+ 'PHP_CodeSniffer_Tokenizers_CSS' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/CSS.php',
139
+ 'PHP_CodeSniffer_Tokenizers_Comment' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/Comment.php',
140
+ 'PHP_CodeSniffer_Tokenizers_JS' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/JS.php',
141
+ 'PHP_CodeSniffer_Tokenizers_PHP' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/PHP.php',
142
+ 'PHP_CodeSniffer_Tokens' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Tokens.php',
143
+ 'PSR1_Sniffs_Classes_ClassDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php',
144
+ 'PSR1_Sniffs_Files_SideEffectsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php',
145
+ 'PSR1_Sniffs_Methods_CamelCapsMethodNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php',
146
+ 'PSR2_Sniffs_Classes_ClassDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php',
147
+ 'PSR2_Sniffs_Classes_PropertyDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php',
148
+ 'PSR2_Sniffs_ControlStructures_ControlStructureSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php',
149
+ 'PSR2_Sniffs_ControlStructures_ElseIfDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php',
150
+ 'PSR2_Sniffs_ControlStructures_SwitchDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php',
151
+ 'PSR2_Sniffs_Files_ClosingTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php',
152
+ 'PSR2_Sniffs_Files_EndFileNewlineSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php',
153
+ 'PSR2_Sniffs_Methods_FunctionCallSignatureSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php',
154
+ 'PSR2_Sniffs_Methods_FunctionClosingBraceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php',
155
+ 'PSR2_Sniffs_Methods_MethodDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php',
156
+ 'PSR2_Sniffs_Namespaces_NamespaceDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php',
157
+ 'PSR2_Sniffs_Namespaces_UseDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php',
158
+ 'Squiz_Sniffs_Arrays_ArrayBracketSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php',
159
+ 'Squiz_Sniffs_Arrays_ArrayDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php',
160
+ 'Squiz_Sniffs_CSS_ClassDefinitionClosingBraceSpaceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php',
161
+ 'Squiz_Sniffs_CSS_ClassDefinitionNameSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php',
162
+ 'Squiz_Sniffs_CSS_ClassDefinitionOpeningBraceSpaceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php',
163
+ 'Squiz_Sniffs_CSS_ColonSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php',
164
+ 'Squiz_Sniffs_CSS_ColourDefinitionSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php',
165
+ 'Squiz_Sniffs_CSS_DisallowMultipleStyleDefinitionsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php',
166
+ 'Squiz_Sniffs_CSS_DuplicateClassDefinitionSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php',
167
+ 'Squiz_Sniffs_CSS_DuplicateStyleDefinitionSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php',
168
+ 'Squiz_Sniffs_CSS_EmptyClassDefinitionSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php',
169
+ 'Squiz_Sniffs_CSS_EmptyStyleDefinitionSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php',
170
+ 'Squiz_Sniffs_CSS_ForbiddenStylesSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php',
171
+ 'Squiz_Sniffs_CSS_IndentationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/IndentationSniff.php',
172
+ 'Squiz_Sniffs_CSS_LowercaseStyleDefinitionSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php',
173
+ 'Squiz_Sniffs_CSS_MissingColonSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php',
174
+ 'Squiz_Sniffs_CSS_NamedColoursSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php',
175
+ 'Squiz_Sniffs_CSS_OpacitySniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/OpacitySniff.php',
176
+ 'Squiz_Sniffs_CSS_SemicolonSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php',
177
+ 'Squiz_Sniffs_CSS_ShorthandSizeSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php',
178
+ 'Squiz_Sniffs_Classes_ClassDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php',
179
+ 'Squiz_Sniffs_Classes_ClassFileNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php',
180
+ 'Squiz_Sniffs_Classes_DuplicatePropertySniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php',
181
+ 'Squiz_Sniffs_Classes_LowercaseClassKeywordsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php',
182
+ 'Squiz_Sniffs_Classes_SelfMemberReferenceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php',
183
+ 'Squiz_Sniffs_Classes_ValidClassNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php',
184
+ 'Squiz_Sniffs_Commenting_BlockCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php',
185
+ 'Squiz_Sniffs_Commenting_ClassCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php',
186
+ 'Squiz_Sniffs_Commenting_ClosingDeclarationCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php',
187
+ 'Squiz_Sniffs_Commenting_DocCommentAlignmentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php',
188
+ 'Squiz_Sniffs_Commenting_EmptyCatchCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php',
189
+ 'Squiz_Sniffs_Commenting_FileCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php',
190
+ 'Squiz_Sniffs_Commenting_FunctionCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php',
191
+ 'Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php',
192
+ 'Squiz_Sniffs_Commenting_InlineCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php',
193
+ 'Squiz_Sniffs_Commenting_LongConditionClosingCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php',
194
+ 'Squiz_Sniffs_Commenting_PostStatementCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php',
195
+ 'Squiz_Sniffs_Commenting_VariableCommentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php',
196
+ 'Squiz_Sniffs_ControlStructures_ControlSignatureSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php',
197
+ 'Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php',
198
+ 'Squiz_Sniffs_ControlStructures_ForEachLoopDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php',
199
+ 'Squiz_Sniffs_ControlStructures_ForLoopDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php',
200
+ 'Squiz_Sniffs_ControlStructures_InlineIfDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php',
201
+ 'Squiz_Sniffs_ControlStructures_LowercaseDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php',
202
+ 'Squiz_Sniffs_ControlStructures_SwitchDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php',
203
+ 'Squiz_Sniffs_Debug_JSLintSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Debug/JSLintSniff.php',
204
+ 'Squiz_Sniffs_Debug_JavaScriptLintSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php',
205
+ 'Squiz_Sniffs_Files_FileExtensionSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php',
206
+ 'Squiz_Sniffs_Formatting_OperatorBracketSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php',
207
+ 'Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php',
208
+ 'Squiz_Sniffs_Functions_FunctionDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php',
209
+ 'Squiz_Sniffs_Functions_FunctionDuplicateArgumentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php',
210
+ 'Squiz_Sniffs_Functions_GlobalFunctionSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php',
211
+ 'Squiz_Sniffs_Functions_LowercaseFunctionKeywordsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php',
212
+ 'Squiz_Sniffs_Functions_MultiLineFunctionDeclarationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php',
213
+ 'Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php',
214
+ 'Squiz_Sniffs_NamingConventions_ValidVariableNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php',
215
+ 'Squiz_Sniffs_Objects_DisallowObjectStringIndexSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php',
216
+ 'Squiz_Sniffs_Objects_ObjectInstantiationSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php',
217
+ 'Squiz_Sniffs_Objects_ObjectMemberCommaSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php',
218
+ 'Squiz_Sniffs_Operators_ComparisonOperatorUsageSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php',
219
+ 'Squiz_Sniffs_Operators_IncrementDecrementUsageSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php',
220
+ 'Squiz_Sniffs_Operators_ValidLogicalOperatorsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php',
221
+ 'Squiz_Sniffs_PHP_CommentedOutCodeSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php',
222
+ 'Squiz_Sniffs_PHP_DisallowBooleanStatementSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php',
223
+ 'Squiz_Sniffs_PHP_DisallowComparisonAssignmentSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php',
224
+ 'Squiz_Sniffs_PHP_DisallowInlineIfSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php',
225
+ 'Squiz_Sniffs_PHP_DisallowMultipleAssignmentsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php',
226
+ 'Squiz_Sniffs_PHP_DisallowObEndFlushSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php',
227
+ 'Squiz_Sniffs_PHP_DisallowSizeFunctionsInLoopsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php',
228
+ 'Squiz_Sniffs_PHP_DiscouragedFunctionsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php',
229
+ 'Squiz_Sniffs_PHP_EmbeddedPhpSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php',
230
+ 'Squiz_Sniffs_PHP_EvalSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/EvalSniff.php',
231
+ 'Squiz_Sniffs_PHP_ForbiddenFunctionsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php',
232
+ 'Squiz_Sniffs_PHP_GlobalKeywordSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php',
233
+ 'Squiz_Sniffs_PHP_HeredocSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/HeredocSniff.php',
234
+ 'Squiz_Sniffs_PHP_InnerFunctionsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php',
235
+ 'Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php',
236
+ 'Squiz_Sniffs_PHP_NonExecutableCodeSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php',
237
+ 'Squiz_Sniffs_Scope_MemberVarScopeSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php',
238
+ 'Squiz_Sniffs_Scope_MethodScopeSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php',
239
+ 'Squiz_Sniffs_Scope_StaticThisUsageSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php',
240
+ 'Squiz_Sniffs_Strings_ConcatenationSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php',
241
+ 'Squiz_Sniffs_Strings_DoubleQuoteUsageSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php',
242
+ 'Squiz_Sniffs_Strings_EchoedStringsSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php',
243
+ 'Squiz_Sniffs_WhiteSpace_CastSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php',
244
+ 'Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php',
245
+ 'Squiz_Sniffs_WhiteSpace_FunctionClosingBraceSpaceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php',
246
+ 'Squiz_Sniffs_WhiteSpace_FunctionOpeningBraceSpaceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php',
247
+ 'Squiz_Sniffs_WhiteSpace_FunctionSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php',
248
+ 'Squiz_Sniffs_WhiteSpace_LanguageConstructSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php',
249
+ 'Squiz_Sniffs_WhiteSpace_LogicalOperatorSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php',
250
+ 'Squiz_Sniffs_WhiteSpace_MemberVarSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php',
251
+ 'Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php',
252
+ 'Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php',
253
+ 'Squiz_Sniffs_WhiteSpace_PropertyLabelSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php',
254
+ 'Squiz_Sniffs_WhiteSpace_ScopeClosingBraceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php',
255
+ 'Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php',
256
+ 'Squiz_Sniffs_WhiteSpace_SemicolonSpacingSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php',
257
+ 'Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php',
258
+ 'Zend_Sniffs_Debug_CodeAnalyzerSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php',
259
+ 'Zend_Sniffs_Files_ClosingTagSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Zend/Sniffs/Files/ClosingTagSniff.php',
260
+ 'Zend_Sniffs_NamingConventions_ValidVariableNameSniff' => $vendorDir . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php',
261
+ );
php52/vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'xrstf\\Composer52' => array($vendorDir . '/xrstf/composer-php52/lib'),
10
+ );
php52/vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ 'PHPCompatibility\\' => array($vendorDir . '/wimg/php-compatibility'),
10
+ );
php52/vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInit9822e31ee142ea70a5a882638b9cf0bf
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ public static function getLoader()
17
+ {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInit9822e31ee142ea70a5a882638b9cf0bf', 'loadClassLoader'), true, true);
23
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit9822e31ee142ea70a5a882638b9cf0bf', '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\ComposerStaticInit9822e31ee142ea70a5a882638b9cf0bf::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);
49
+
50
+ return $loader;
51
+ }
52
+ }
php52/vendor/composer/autoload_real_52.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real_52.php generated by xrstf/composer-php52
4
+
5
+ class ComposerAutoloaderInita4ae2997dc6cca14c59c813063e62e17 {
6
+ private static $loader;
7
+
8
+ public static function loadClassLoader($class) {
9
+ if ('xrstf_Composer52_ClassLoader' === $class) {
10
+ require dirname(__FILE__).'/ClassLoader52.php';
11
+ }
12
+ }
13
+
14
+ /**
15
+ * @return xrstf_Composer52_ClassLoader
16
+ */
17
+ public static function getLoader() {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInita4ae2997dc6cca14c59c813063e62e17', 'loadClassLoader'), true /*, true */);
23
+ self::$loader = $loader = new xrstf_Composer52_ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInita4ae2997dc6cca14c59c813063e62e17', 'loadClassLoader'));
25
+
26
+ $vendorDir = dirname(dirname(__FILE__));
27
+ $baseDir = dirname($vendorDir);
28
+ $dir = dirname(__FILE__);
29
+
30
+ $map = require $dir.'/autoload_namespaces.php';
31
+ foreach ($map as $namespace => $path) {
32
+ $loader->add($namespace, $path);
33
+ }
34
+
35
+ $classMap = require $dir.'/autoload_classmap.php';
36
+ if ($classMap) {
37
+ $loader->addClassMap($classMap);
38
+ }
39
+
40
+ $loader->register(true);
41
+
42
+ return $loader;
43
+ }
44
+ }
php52/vendor/composer/autoload_static.php ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_static.php @generated by Composer
4
+
5
+ namespace Composer\Autoload;
6
+
7
+ class ComposerStaticInit9822e31ee142ea70a5a882638b9cf0bf
8
+ {
9
+ public static $prefixLengthsPsr4 = array (
10
+ 'P' =>
11
+ array (
12
+ 'PHPCompatibility\\' => 17,
13
+ ),
14
+ );
15
+
16
+ public static $prefixDirsPsr4 = array (
17
+ 'PHPCompatibility\\' =>
18
+ array (
19
+ 0 => __DIR__ . '/..' . '/wimg/php-compatibility',
20
+ ),
21
+ );
22
+
23
+ public static $prefixesPsr0 = array (
24
+ 'x' =>
25
+ array (
26
+ 'xrstf\\Composer52' =>
27
+ array (
28
+ 0 => __DIR__ . '/..' . '/xrstf/composer-php52/lib',
29
+ ),
30
+ ),
31
+ );
32
+
33
+ public static $classMap = array (
34
+ 'Generic_Sniffs_Arrays_DisallowLongArraySyntaxSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php',
35
+ 'Generic_Sniffs_Arrays_DisallowShortArraySyntaxSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php',
36
+ 'Generic_Sniffs_Classes_DuplicateClassNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php',
37
+ 'Generic_Sniffs_Classes_OpeningBraceSameLineSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php',
38
+ 'Generic_Sniffs_CodeAnalysis_EmptyStatementSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php',
39
+ 'Generic_Sniffs_CodeAnalysis_ForLoopShouldBeWhileLoopSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php',
40
+ 'Generic_Sniffs_CodeAnalysis_ForLoopWithTestFunctionCallSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php',
41
+ 'Generic_Sniffs_CodeAnalysis_JumbledIncrementerSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php',
42
+ 'Generic_Sniffs_CodeAnalysis_UnconditionalIfStatementSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php',
43
+ 'Generic_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php',
44
+ 'Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php',
45
+ 'Generic_Sniffs_CodeAnalysis_UselessOverridingMethodSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php',
46
+ 'Generic_Sniffs_Commenting_DocCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php',
47
+ 'Generic_Sniffs_Commenting_FixmeSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php',
48
+ 'Generic_Sniffs_Commenting_TodoSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php',
49
+ 'Generic_Sniffs_ControlStructures_InlineControlStructureSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php',
50
+ 'Generic_Sniffs_Debug_CSSLintSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/CSSLintSniff.php',
51
+ 'Generic_Sniffs_Debug_ClosureLinterSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php',
52
+ 'Generic_Sniffs_Debug_ESLintSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/ESLintSniff.php',
53
+ 'Generic_Sniffs_Debug_JSHintSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php',
54
+ 'Generic_Sniffs_Files_ByteOrderMarkSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php',
55
+ 'Generic_Sniffs_Files_EndFileNewlineSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php',
56
+ 'Generic_Sniffs_Files_EndFileNoNewlineSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php',
57
+ 'Generic_Sniffs_Files_InlineHTMLSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php',
58
+ 'Generic_Sniffs_Files_LineEndingsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php',
59
+ 'Generic_Sniffs_Files_LineLengthSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php',
60
+ 'Generic_Sniffs_Files_LowercasedFilenameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php',
61
+ 'Generic_Sniffs_Files_OneClassPerFileSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php',
62
+ 'Generic_Sniffs_Files_OneInterfacePerFileSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php',
63
+ 'Generic_Sniffs_Files_OneTraitPerFileSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php',
64
+ 'Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php',
65
+ 'Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php',
66
+ 'Generic_Sniffs_Formatting_NoSpaceAfterCastSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php',
67
+ 'Generic_Sniffs_Formatting_SpaceAfterCastSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php',
68
+ 'Generic_Sniffs_Formatting_SpaceAfterNotSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php',
69
+ 'Generic_Sniffs_Functions_CallTimePassByReferenceSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php',
70
+ 'Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php',
71
+ 'Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php',
72
+ 'Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php',
73
+ 'Generic_Sniffs_Metrics_CyclomaticComplexitySniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php',
74
+ 'Generic_Sniffs_Metrics_NestingLevelSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php',
75
+ 'Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php',
76
+ 'Generic_Sniffs_NamingConventions_ConstructorNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php',
77
+ 'Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php',
78
+ 'Generic_Sniffs_PHP_BacktickOperatorSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php',
79
+ 'Generic_Sniffs_PHP_CharacterBeforePHPOpeningTagSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php',
80
+ 'Generic_Sniffs_PHP_ClosingPHPTagSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php',
81
+ 'Generic_Sniffs_PHP_DeprecatedFunctionsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php',
82
+ 'Generic_Sniffs_PHP_DisallowAlternativePHPTagsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php',
83
+ 'Generic_Sniffs_PHP_DisallowShortOpenTagSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php',
84
+ 'Generic_Sniffs_PHP_ForbiddenFunctionsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php',
85
+ 'Generic_Sniffs_PHP_LowerCaseConstantSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php',
86
+ 'Generic_Sniffs_PHP_LowerCaseKeywordSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php',
87
+ 'Generic_Sniffs_PHP_NoSilencedErrorsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php',
88
+ 'Generic_Sniffs_PHP_SAPIUsageSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php',
89
+ 'Generic_Sniffs_PHP_SyntaxSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/SyntaxSniff.php',
90
+ 'Generic_Sniffs_PHP_UpperCaseConstantSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php',
91
+ 'Generic_Sniffs_Strings_UnnecessaryStringConcatSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php',
92
+ 'Generic_Sniffs_VersionControl_SubversionPropertiesSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php',
93
+ 'Generic_Sniffs_WhiteSpace_DisallowSpaceIndentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php',
94
+ 'Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php',
95
+ 'Generic_Sniffs_WhiteSpace_ScopeIndentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php',
96
+ 'MySource_Sniffs_CSS_BrowserSpecificStylesSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/CSS/BrowserSpecificStylesSniff.php',
97
+ 'MySource_Sniffs_Channels_DisallowSelfActionsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Channels/DisallowSelfActionsSniff.php',
98
+ 'MySource_Sniffs_Channels_IncludeOwnSystemSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeOwnSystemSniff.php',
99
+ 'MySource_Sniffs_Channels_IncludeSystemSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Channels/IncludeSystemSniff.php',
100
+ 'MySource_Sniffs_Channels_UnusedSystemSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Channels/UnusedSystemSniff.php',
101
+ 'MySource_Sniffs_Commenting_FunctionCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Commenting/FunctionCommentSniff.php',
102
+ 'MySource_Sniffs_Debug_DebugCodeSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Debug/DebugCodeSniff.php',
103
+ 'MySource_Sniffs_Debug_FirebugConsoleSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Debug/FirebugConsoleSniff.php',
104
+ 'MySource_Sniffs_Objects_AssignThisSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Objects/AssignThisSniff.php',
105
+ 'MySource_Sniffs_Objects_CreateWidgetTypeCallbackSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Objects/CreateWidgetTypeCallbackSniff.php',
106
+ 'MySource_Sniffs_Objects_DisallowNewWidgetSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Objects/DisallowNewWidgetSniff.php',
107
+ 'MySource_Sniffs_PHP_AjaxNullComparisonSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/PHP/AjaxNullComparisonSniff.php',
108
+ 'MySource_Sniffs_PHP_EvalObjectFactorySniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/PHP/EvalObjectFactorySniff.php',
109
+ 'MySource_Sniffs_PHP_GetRequestDataSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/PHP/GetRequestDataSniff.php',
110
+ 'MySource_Sniffs_PHP_ReturnFunctionValueSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/PHP/ReturnFunctionValueSniff.php',
111
+ 'MySource_Sniffs_Strings_JoinStringsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/MySource/Sniffs/Strings/JoinStringsSniff.php',
112
+ 'PEAR_Sniffs_Classes_ClassDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Classes/ClassDeclarationSniff.php',
113
+ 'PEAR_Sniffs_Commenting_ClassCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Commenting/ClassCommentSniff.php',
114
+ 'PEAR_Sniffs_Commenting_FileCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FileCommentSniff.php',
115
+ 'PEAR_Sniffs_Commenting_FunctionCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Commenting/FunctionCommentSniff.php',
116
+ 'PEAR_Sniffs_Commenting_InlineCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Commenting/InlineCommentSniff.php',
117
+ 'PEAR_Sniffs_ControlStructures_ControlSignatureSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/ControlSignatureSniff.php',
118
+ 'PEAR_Sniffs_ControlStructures_MultiLineConditionSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/ControlStructures/MultiLineConditionSniff.php',
119
+ 'PEAR_Sniffs_Files_IncludingFileSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Files/IncludingFileSniff.php',
120
+ 'PEAR_Sniffs_Formatting_MultiLineAssignmentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Formatting/MultiLineAssignmentSniff.php',
121
+ 'PEAR_Sniffs_Functions_FunctionCallSignatureSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionCallSignatureSniff.php',
122
+ 'PEAR_Sniffs_Functions_FunctionDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/FunctionDeclarationSniff.php',
123
+ 'PEAR_Sniffs_Functions_ValidDefaultValueSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/Functions/ValidDefaultValueSniff.php',
124
+ 'PEAR_Sniffs_NamingConventions_ValidClassNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidClassNameSniff.php',
125
+ 'PEAR_Sniffs_NamingConventions_ValidFunctionNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidFunctionNameSniff.php',
126
+ 'PEAR_Sniffs_NamingConventions_ValidVariableNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/NamingConventions/ValidVariableNameSniff.php',
127
+ 'PEAR_Sniffs_WhiteSpace_ObjectOperatorIndentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ObjectOperatorIndentSniff.php',
128
+ 'PEAR_Sniffs_WhiteSpace_ScopeClosingBraceSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php',
129
+ 'PEAR_Sniffs_WhiteSpace_ScopeIndentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PEAR/Sniffs/WhiteSpace/ScopeIndentSniff.php',
130
+ 'PHP_CodeSniffer' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer.php',
131
+ 'PHP_CodeSniffer_CLI' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/CLI.php',
132
+ 'PHP_CodeSniffer_DocGenerators_Generator' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/Generator.php',
133
+ 'PHP_CodeSniffer_DocGenerators_HTML' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/HTML.php',
134
+ 'PHP_CodeSniffer_DocGenerators_Markdown' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/Markdown.php',
135
+ 'PHP_CodeSniffer_DocGenerators_Text' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/Text.php',
136
+ 'PHP_CodeSniffer_Exception' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Exception.php',
137
+ 'PHP_CodeSniffer_File' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/File.php',
138
+ 'PHP_CodeSniffer_Fixer' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Fixer.php',
139
+ 'PHP_CodeSniffer_Report' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Report.php',
140
+ 'PHP_CodeSniffer_Reporting' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reporting.php',
141
+ 'PHP_CodeSniffer_Reports_Cbf' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Cbf.php',
142
+ 'PHP_CodeSniffer_Reports_Checkstyle' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Checkstyle.php',
143
+ 'PHP_CodeSniffer_Reports_Csv' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Csv.php',
144
+ 'PHP_CodeSniffer_Reports_Diff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Diff.php',
145
+ 'PHP_CodeSniffer_Reports_Emacs' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Emacs.php',
146
+ 'PHP_CodeSniffer_Reports_Full' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Full.php',
147
+ 'PHP_CodeSniffer_Reports_Gitblame' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Gitblame.php',
148
+ 'PHP_CodeSniffer_Reports_Hgblame' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Hgblame.php',
149
+ 'PHP_CodeSniffer_Reports_Info' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Info.php',
150
+ 'PHP_CodeSniffer_Reports_Json' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Json.php',
151
+ 'PHP_CodeSniffer_Reports_Junit' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Junit.php',
152
+ 'PHP_CodeSniffer_Reports_Notifysend' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Notifysend.php',
153
+ 'PHP_CodeSniffer_Reports_Source' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Source.php',
154
+ 'PHP_CodeSniffer_Reports_Summary' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Summary.php',
155
+ 'PHP_CodeSniffer_Reports_Svnblame' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Svnblame.php',
156
+ 'PHP_CodeSniffer_Reports_VersionControl' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/VersionControl.php',
157
+ 'PHP_CodeSniffer_Reports_Xml' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Reports/Xml.php',
158
+ 'PHP_CodeSniffer_Sniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Sniff.php',
159
+ 'PHP_CodeSniffer_Standards_AbstractPatternSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractPatternSniff.php',
160
+ 'PHP_CodeSniffer_Standards_AbstractScopeSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractScopeSniff.php',
161
+ 'PHP_CodeSniffer_Standards_AbstractVariableSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractVariableSniff.php',
162
+ 'PHP_CodeSniffer_Standards_IncorrectPatternException' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/IncorrectPatternException.php',
163
+ 'PHP_CodeSniffer_Tokenizers_CSS' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/CSS.php',
164
+ 'PHP_CodeSniffer_Tokenizers_Comment' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/Comment.php',
165
+ 'PHP_CodeSniffer_Tokenizers_JS' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/JS.php',
166
+ 'PHP_CodeSniffer_Tokenizers_PHP' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Tokenizers/PHP.php',
167
+ 'PHP_CodeSniffer_Tokens' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Tokens.php',
168
+ 'PSR1_Sniffs_Classes_ClassDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR1/Sniffs/Classes/ClassDeclarationSniff.php',
169
+ 'PSR1_Sniffs_Files_SideEffectsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR1/Sniffs/Files/SideEffectsSniff.php',
170
+ 'PSR1_Sniffs_Methods_CamelCapsMethodNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR1/Sniffs/Methods/CamelCapsMethodNameSniff.php',
171
+ 'PSR2_Sniffs_Classes_ClassDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Classes/ClassDeclarationSniff.php',
172
+ 'PSR2_Sniffs_Classes_PropertyDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Classes/PropertyDeclarationSniff.php',
173
+ 'PSR2_Sniffs_ControlStructures_ControlStructureSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/ControlStructureSpacingSniff.php',
174
+ 'PSR2_Sniffs_ControlStructures_ElseIfDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/ElseIfDeclarationSniff.php',
175
+ 'PSR2_Sniffs_ControlStructures_SwitchDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/ControlStructures/SwitchDeclarationSniff.php',
176
+ 'PSR2_Sniffs_Files_ClosingTagSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Files/ClosingTagSniff.php',
177
+ 'PSR2_Sniffs_Files_EndFileNewlineSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Files/EndFileNewlineSniff.php',
178
+ 'PSR2_Sniffs_Methods_FunctionCallSignatureSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/FunctionCallSignatureSniff.php',
179
+ 'PSR2_Sniffs_Methods_FunctionClosingBraceSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/FunctionClosingBraceSniff.php',
180
+ 'PSR2_Sniffs_Methods_MethodDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Methods/MethodDeclarationSniff.php',
181
+ 'PSR2_Sniffs_Namespaces_NamespaceDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/NamespaceDeclarationSniff.php',
182
+ 'PSR2_Sniffs_Namespaces_UseDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/PSR2/Sniffs/Namespaces/UseDeclarationSniff.php',
183
+ 'Squiz_Sniffs_Arrays_ArrayBracketSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayBracketSpacingSniff.php',
184
+ 'Squiz_Sniffs_Arrays_ArrayDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Arrays/ArrayDeclarationSniff.php',
185
+ 'Squiz_Sniffs_CSS_ClassDefinitionClosingBraceSpaceSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionClosingBraceSpaceSniff.php',
186
+ 'Squiz_Sniffs_CSS_ClassDefinitionNameSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionNameSpacingSniff.php',
187
+ 'Squiz_Sniffs_CSS_ClassDefinitionOpeningBraceSpaceSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ClassDefinitionOpeningBraceSpaceSniff.php',
188
+ 'Squiz_Sniffs_CSS_ColonSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColonSpacingSniff.php',
189
+ 'Squiz_Sniffs_CSS_ColourDefinitionSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ColourDefinitionSniff.php',
190
+ 'Squiz_Sniffs_CSS_DisallowMultipleStyleDefinitionsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/DisallowMultipleStyleDefinitionsSniff.php',
191
+ 'Squiz_Sniffs_CSS_DuplicateClassDefinitionSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateClassDefinitionSniff.php',
192
+ 'Squiz_Sniffs_CSS_DuplicateStyleDefinitionSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/DuplicateStyleDefinitionSniff.php',
193
+ 'Squiz_Sniffs_CSS_EmptyClassDefinitionSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyClassDefinitionSniff.php',
194
+ 'Squiz_Sniffs_CSS_EmptyStyleDefinitionSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/EmptyStyleDefinitionSniff.php',
195
+ 'Squiz_Sniffs_CSS_ForbiddenStylesSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ForbiddenStylesSniff.php',
196
+ 'Squiz_Sniffs_CSS_IndentationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/IndentationSniff.php',
197
+ 'Squiz_Sniffs_CSS_LowercaseStyleDefinitionSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/LowercaseStyleDefinitionSniff.php',
198
+ 'Squiz_Sniffs_CSS_MissingColonSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/MissingColonSniff.php',
199
+ 'Squiz_Sniffs_CSS_NamedColoursSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/NamedColoursSniff.php',
200
+ 'Squiz_Sniffs_CSS_OpacitySniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/OpacitySniff.php',
201
+ 'Squiz_Sniffs_CSS_SemicolonSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/SemicolonSpacingSniff.php',
202
+ 'Squiz_Sniffs_CSS_ShorthandSizeSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/CSS/ShorthandSizeSniff.php',
203
+ 'Squiz_Sniffs_Classes_ClassDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassDeclarationSniff.php',
204
+ 'Squiz_Sniffs_Classes_ClassFileNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ClassFileNameSniff.php',
205
+ 'Squiz_Sniffs_Classes_DuplicatePropertySniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/DuplicatePropertySniff.php',
206
+ 'Squiz_Sniffs_Classes_LowercaseClassKeywordsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/LowercaseClassKeywordsSniff.php',
207
+ 'Squiz_Sniffs_Classes_SelfMemberReferenceSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/SelfMemberReferenceSniff.php',
208
+ 'Squiz_Sniffs_Classes_ValidClassNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Classes/ValidClassNameSniff.php',
209
+ 'Squiz_Sniffs_Commenting_BlockCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/BlockCommentSniff.php',
210
+ 'Squiz_Sniffs_Commenting_ClassCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClassCommentSniff.php',
211
+ 'Squiz_Sniffs_Commenting_ClosingDeclarationCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/ClosingDeclarationCommentSniff.php',
212
+ 'Squiz_Sniffs_Commenting_DocCommentAlignmentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/DocCommentAlignmentSniff.php',
213
+ 'Squiz_Sniffs_Commenting_EmptyCatchCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/EmptyCatchCommentSniff.php',
214
+ 'Squiz_Sniffs_Commenting_FileCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FileCommentSniff.php',
215
+ 'Squiz_Sniffs_Commenting_FunctionCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php',
216
+ 'Squiz_Sniffs_Commenting_FunctionCommentThrowTagSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentThrowTagSniff.php',
217
+ 'Squiz_Sniffs_Commenting_InlineCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/InlineCommentSniff.php',
218
+ 'Squiz_Sniffs_Commenting_LongConditionClosingCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/LongConditionClosingCommentSniff.php',
219
+ 'Squiz_Sniffs_Commenting_PostStatementCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/PostStatementCommentSniff.php',
220
+ 'Squiz_Sniffs_Commenting_VariableCommentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Commenting/VariableCommentSniff.php',
221
+ 'Squiz_Sniffs_ControlStructures_ControlSignatureSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ControlSignatureSniff.php',
222
+ 'Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ElseIfDeclarationSniff.php',
223
+ 'Squiz_Sniffs_ControlStructures_ForEachLoopDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForEachLoopDeclarationSniff.php',
224
+ 'Squiz_Sniffs_ControlStructures_ForLoopDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/ForLoopDeclarationSniff.php',
225
+ 'Squiz_Sniffs_ControlStructures_InlineIfDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/InlineIfDeclarationSniff.php',
226
+ 'Squiz_Sniffs_ControlStructures_LowercaseDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/LowercaseDeclarationSniff.php',
227
+ 'Squiz_Sniffs_ControlStructures_SwitchDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/ControlStructures/SwitchDeclarationSniff.php',
228
+ 'Squiz_Sniffs_Debug_JSLintSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Debug/JSLintSniff.php',
229
+ 'Squiz_Sniffs_Debug_JavaScriptLintSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Debug/JavaScriptLintSniff.php',
230
+ 'Squiz_Sniffs_Files_FileExtensionSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Files/FileExtensionSniff.php',
231
+ 'Squiz_Sniffs_Formatting_OperatorBracketSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Formatting/OperatorBracketSniff.php',
232
+ 'Squiz_Sniffs_Functions_FunctionDeclarationArgumentSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationArgumentSpacingSniff.php',
233
+ 'Squiz_Sniffs_Functions_FunctionDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDeclarationSniff.php',
234
+ 'Squiz_Sniffs_Functions_FunctionDuplicateArgumentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/FunctionDuplicateArgumentSniff.php',
235
+ 'Squiz_Sniffs_Functions_GlobalFunctionSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/GlobalFunctionSniff.php',
236
+ 'Squiz_Sniffs_Functions_LowercaseFunctionKeywordsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/LowercaseFunctionKeywordsSniff.php',
237
+ 'Squiz_Sniffs_Functions_MultiLineFunctionDeclarationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Functions/MultiLineFunctionDeclarationSniff.php',
238
+ 'Squiz_Sniffs_NamingConventions_ValidFunctionNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidFunctionNameSniff.php',
239
+ 'Squiz_Sniffs_NamingConventions_ValidVariableNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/NamingConventions/ValidVariableNameSniff.php',
240
+ 'Squiz_Sniffs_Objects_DisallowObjectStringIndexSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Objects/DisallowObjectStringIndexSniff.php',
241
+ 'Squiz_Sniffs_Objects_ObjectInstantiationSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectInstantiationSniff.php',
242
+ 'Squiz_Sniffs_Objects_ObjectMemberCommaSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Objects/ObjectMemberCommaSniff.php',
243
+ 'Squiz_Sniffs_Operators_ComparisonOperatorUsageSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/ComparisonOperatorUsageSniff.php',
244
+ 'Squiz_Sniffs_Operators_IncrementDecrementUsageSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/IncrementDecrementUsageSniff.php',
245
+ 'Squiz_Sniffs_Operators_ValidLogicalOperatorsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Operators/ValidLogicalOperatorsSniff.php',
246
+ 'Squiz_Sniffs_PHP_CommentedOutCodeSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/CommentedOutCodeSniff.php',
247
+ 'Squiz_Sniffs_PHP_DisallowBooleanStatementSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowBooleanStatementSniff.php',
248
+ 'Squiz_Sniffs_PHP_DisallowComparisonAssignmentSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowComparisonAssignmentSniff.php',
249
+ 'Squiz_Sniffs_PHP_DisallowInlineIfSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowInlineIfSniff.php',
250
+ 'Squiz_Sniffs_PHP_DisallowMultipleAssignmentsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowMultipleAssignmentsSniff.php',
251
+ 'Squiz_Sniffs_PHP_DisallowObEndFlushSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowObEndFlushSniff.php',
252
+ 'Squiz_Sniffs_PHP_DisallowSizeFunctionsInLoopsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DisallowSizeFunctionsInLoopsSniff.php',
253
+ 'Squiz_Sniffs_PHP_DiscouragedFunctionsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/DiscouragedFunctionsSniff.php',
254
+ 'Squiz_Sniffs_PHP_EmbeddedPhpSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/EmbeddedPhpSniff.php',
255
+ 'Squiz_Sniffs_PHP_EvalSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/EvalSniff.php',
256
+ 'Squiz_Sniffs_PHP_ForbiddenFunctionsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/ForbiddenFunctionsSniff.php',
257
+ 'Squiz_Sniffs_PHP_GlobalKeywordSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/GlobalKeywordSniff.php',
258
+ 'Squiz_Sniffs_PHP_HeredocSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/HeredocSniff.php',
259
+ 'Squiz_Sniffs_PHP_InnerFunctionsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/InnerFunctionsSniff.php',
260
+ 'Squiz_Sniffs_PHP_LowercasePHPFunctionsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/LowercasePHPFunctionsSniff.php',
261
+ 'Squiz_Sniffs_PHP_NonExecutableCodeSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/PHP/NonExecutableCodeSniff.php',
262
+ 'Squiz_Sniffs_Scope_MemberVarScopeSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Scope/MemberVarScopeSniff.php',
263
+ 'Squiz_Sniffs_Scope_MethodScopeSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Scope/MethodScopeSniff.php',
264
+ 'Squiz_Sniffs_Scope_StaticThisUsageSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Scope/StaticThisUsageSniff.php',
265
+ 'Squiz_Sniffs_Strings_ConcatenationSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Strings/ConcatenationSpacingSniff.php',
266
+ 'Squiz_Sniffs_Strings_DoubleQuoteUsageSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Strings/DoubleQuoteUsageSniff.php',
267
+ 'Squiz_Sniffs_Strings_EchoedStringsSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/Strings/EchoedStringsSniff.php',
268
+ 'Squiz_Sniffs_WhiteSpace_CastSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/CastSpacingSniff.php',
269
+ 'Squiz_Sniffs_WhiteSpace_ControlStructureSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ControlStructureSpacingSniff.php',
270
+ 'Squiz_Sniffs_WhiteSpace_FunctionClosingBraceSpaceSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionClosingBraceSpaceSniff.php',
271
+ 'Squiz_Sniffs_WhiteSpace_FunctionOpeningBraceSpaceSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionOpeningBraceSpaceSniff.php',
272
+ 'Squiz_Sniffs_WhiteSpace_FunctionSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/FunctionSpacingSniff.php',
273
+ 'Squiz_Sniffs_WhiteSpace_LanguageConstructSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LanguageConstructSpacingSniff.php',
274
+ 'Squiz_Sniffs_WhiteSpace_LogicalOperatorSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/LogicalOperatorSpacingSniff.php',
275
+ 'Squiz_Sniffs_WhiteSpace_MemberVarSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/MemberVarSpacingSniff.php',
276
+ 'Squiz_Sniffs_WhiteSpace_ObjectOperatorSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ObjectOperatorSpacingSniff.php',
277
+ 'Squiz_Sniffs_WhiteSpace_OperatorSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/OperatorSpacingSniff.php',
278
+ 'Squiz_Sniffs_WhiteSpace_PropertyLabelSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/PropertyLabelSpacingSniff.php',
279
+ 'Squiz_Sniffs_WhiteSpace_ScopeClosingBraceSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeClosingBraceSniff.php',
280
+ 'Squiz_Sniffs_WhiteSpace_ScopeKeywordSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php',
281
+ 'Squiz_Sniffs_WhiteSpace_SemicolonSpacingSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SemicolonSpacingSniff.php',
282
+ 'Squiz_Sniffs_WhiteSpace_SuperfluousWhitespaceSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Squiz/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php',
283
+ 'Zend_Sniffs_Debug_CodeAnalyzerSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Zend/Sniffs/Debug/CodeAnalyzerSniff.php',
284
+ 'Zend_Sniffs_Files_ClosingTagSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Zend/Sniffs/Files/ClosingTagSniff.php',
285
+ 'Zend_Sniffs_NamingConventions_ValidVariableNameSniff' => __DIR__ . '/..' . '/squizlabs/php_codesniffer/CodeSniffer/Standards/Zend/Sniffs/NamingConventions/ValidVariableNameSniff.php',
286
+ );
287
+
288
+ public static function getInitializer(ClassLoader $loader)
289
+ {
290
+ return \Closure::bind(function () use ($loader) {
291
+ $loader->prefixLengthsPsr4 = ComposerStaticInit9822e31ee142ea70a5a882638b9cf0bf::$prefixLengthsPsr4;
292
+ $loader->prefixDirsPsr4 = ComposerStaticInit9822e31ee142ea70a5a882638b9cf0bf::$prefixDirsPsr4;
293
+ $loader->prefixesPsr0 = ComposerStaticInit9822e31ee142ea70a5a882638b9cf0bf::$prefixesPsr0;
294
+ $loader->classMap = ComposerStaticInit9822e31ee142ea70a5a882638b9cf0bf::$classMap;
295
+
296
+ }, null, ClassLoader::class);
297
+ }
298
+ }
php52/vendor/composer/installed.json ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "name": "squizlabs/php_codesniffer",
4
+ "version": "2.9.1",
5
+ "version_normalized": "2.9.1.0",
6
+ "source": {
7
+ "type": "git",
8
+ "url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
9
+ "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62"
10
+ },
11
+ "dist": {
12
+ "type": "zip",
13
+ "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/dcbed1074f8244661eecddfc2a675430d8d33f62",
14
+ "reference": "dcbed1074f8244661eecddfc2a675430d8d33f62",
15
+ "shasum": ""
16
+ },
17
+ "require": {
18
+ "ext-simplexml": "*",
19
+ "ext-tokenizer": "*",
20
+ "ext-xmlwriter": "*",
21
+ "php": ">=5.1.2"
22
+ },
23
+ "require-dev": {
24
+ "phpunit/phpunit": "~4.0"
25
+ },
26
+ "time": "2017-05-22T02:43:20+00:00",
27
+ "bin": [
28
+ "scripts/phpcs",
29
+ "scripts/phpcbf"
30
+ ],
31
+ "type": "library",
32
+ "extra": {
33
+ "branch-alias": {
34
+ "dev-master": "2.x-dev"
35
+ }
36
+ },
37
+ "installation-source": "dist",
38
+ "autoload": {
39
+ "classmap": [
40
+ "CodeSniffer.php",
41
+ "CodeSniffer/CLI.php",
42
+ "CodeSniffer/Exception.php",
43
+ "CodeSniffer/File.php",
44
+ "CodeSniffer/Fixer.php",
45
+ "CodeSniffer/Report.php",
46
+ "CodeSniffer/Reporting.php",
47
+ "CodeSniffer/Sniff.php",
48
+ "CodeSniffer/Tokens.php",
49
+ "CodeSniffer/Reports/",
50
+ "CodeSniffer/Tokenizers/",
51
+ "CodeSniffer/DocGenerators/",
52
+ "CodeSniffer/Standards/AbstractPatternSniff.php",
53
+ "CodeSniffer/Standards/AbstractScopeSniff.php",
54
+ "CodeSniffer/Standards/AbstractVariableSniff.php",
55
+ "CodeSniffer/Standards/IncorrectPatternException.php",
56
+ "CodeSniffer/Standards/Generic/Sniffs/",
57
+ "CodeSniffer/Standards/MySource/Sniffs/",
58
+ "CodeSniffer/Standards/PEAR/Sniffs/",
59
+ "CodeSniffer/Standards/PSR1/Sniffs/",
60
+ "CodeSniffer/Standards/PSR2/Sniffs/",
61
+ "CodeSniffer/Standards/Squiz/Sniffs/",
62
+ "CodeSniffer/Standards/Zend/Sniffs/"
63
+ ]
64
+ },
65
+ "notification-url": "https://packagist.org/downloads/",
66
+ "license": [
67
+ "BSD-3-Clause"
68
+ ],
69
+ "authors": [
70
+ {
71
+ "name": "Greg Sherwood",
72
+ "role": "lead"
73
+ }
74
+ ],
75
+ "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
76
+ "homepage": "http://www.squizlabs.com/php-codesniffer",
77
+ "keywords": [
78
+ "phpcs",
79
+ "standards"
80
+ ]
81
+ },
82
+ {
83
+ "name": "wimg/php-compatibility",
84
+ "version": "7.1.5",
85
+ "version_normalized": "7.1.5.0",
86
+ "source": {
87
+ "type": "git",
88
+ "url": "https://github.com/wimg/PHPCompatibility.git",
89
+ "reference": "1649732fb1a2115608dfe805a644e4405fb6444b"
90
+ },
91
+ "dist": {
92
+ "type": "zip",
93
+ "url": "https://api.github.com/repos/wimg/PHPCompatibility/zipball/1649732fb1a2115608dfe805a644e4405fb6444b",
94
+ "reference": "1649732fb1a2115608dfe805a644e4405fb6444b",
95
+ "shasum": ""
96
+ },
97
+ "require": {
98
+ "ext-tokenizer": "*",
99
+ "php": ">=5.1.2",
100
+ "squizlabs/php_codesniffer": "^2.0"
101
+ },
102
+ "time": "2017-07-15T23:03:53+00:00",
103
+ "type": "phpcodesniffer-standard",
104
+ "installation-source": "dist",
105
+ "autoload": {
106
+ "psr-4": {
107
+ "PHPCompatibility\\": ""
108
+ }
109
+ },
110
+ "notification-url": "https://packagist.org/downloads/",
111
+ "license": [
112
+ "LGPL-3.0"
113
+ ],
114
+ "authors": [
115
+ {
116
+ "name": "Wim Godden",
117
+ "role": "lead"
118
+ }
119
+ ],
120
+ "description": "This is a set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.",
121
+ "homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
122
+ "keywords": [
123
+ "compatibility",
124
+ "phpcs",
125
+ "standards"
126
+ ]
127
+ },
128
+ {
129
+ "name": "xrstf/composer-php52",
130
+ "version": "v1.0.20",
131
+ "version_normalized": "1.0.20.0",
132
+ "source": {
133
+ "type": "git",
134
+ "url": "https://github.com/composer-php52/composer-php52.git",
135
+ "reference": "bd41459d5e27df8d33057842b32377c39e97a5a8"
136
+ },
137
+ "dist": {
138
+ "type": "zip",
139
+ "url": "https://api.github.com/repos/composer-php52/composer-php52/zipball/bd41459d5e27df8d33057842b32377c39e97a5a8",
140
+ "reference": "bd41459d5e27df8d33057842b32377c39e97a5a8",
141
+ "shasum": ""
142
+ },
143
+ "time": "2016-04-16T21:52:24+00:00",
144
+ "type": "library",
145
+ "extra": {
146
+ "branch-alias": {
147
+ "dev-default": "1.x-dev"
148
+ }
149
+ },
150
+ "installation-source": "dist",
151
+ "autoload": {
152
+ "psr-0": {
153
+ "xrstf\\Composer52": "lib/"
154
+ }
155
+ },
156
+ "notification-url": "https://packagist.org/downloads/",
157
+ "license": [
158
+ "MIT"
159
+ ]
160
+ }
161
+ ]
php52/vendor/squizlabs/php_codesniffer/CONTRIBUTING.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Contributing
2
+ -------------
3
+
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
+
11
+ phpunit
12
+
13
+ Which should give you no failures or errors. You can ignore any skipped tests as these are for external tools.
php52/vendor/squizlabs/php_codesniffer/CodeSniffer.conf.dist ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $phpCodeSnifferConfig = array (
3
+ 'default_standard' => 'PSR2',
4
+ 'report_format' => 'summary',
5
+ 'show_warnings' => '0',
6
+ 'show_progress' => '1',
7
+ 'report_width' => '120',
8
+ )
9
+ ?>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer.php ADDED
@@ -0,0 +1,2578 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PHP_CodeSniffer tokenizes PHP code and detects violations of a
4
+ * defined set of coding standards.
5
+ *
6
+ * PHP version 5
7
+ *
8
+ * @category PHP
9
+ * @package PHP_CodeSniffer
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @author Marc McIntyre <mmcintyre@squiz.net>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ spl_autoload_register(array('PHP_CodeSniffer', 'autoload'));
18
+
19
+ if (class_exists('PHP_CodeSniffer_Exception', true) === false) {
20
+ throw new Exception('Class PHP_CodeSniffer_Exception not found');
21
+ }
22
+
23
+ if (class_exists('PHP_CodeSniffer_File', true) === false) {
24
+ throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_File not found');
25
+ }
26
+
27
+ if (class_exists('PHP_CodeSniffer_Fixer', true) === false) {
28
+ throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Fixer not found');
29
+ }
30
+
31
+ if (class_exists('PHP_CodeSniffer_Tokens', true) === false) {
32
+ throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Tokens not found');
33
+ }
34
+
35
+ if (class_exists('PHP_CodeSniffer_CLI', true) === false) {
36
+ throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CLI not found');
37
+ }
38
+
39
+ if (interface_exists('PHP_CodeSniffer_Sniff', true) === false) {
40
+ throw new PHP_CodeSniffer_Exception('Interface PHP_CodeSniffer_Sniff not found');
41
+ }
42
+
43
+ /**
44
+ * PHP_CodeSniffer tokenizes PHP code and detects violations of a
45
+ * defined set of coding standards.
46
+ *
47
+ * Standards are specified by classes that implement the PHP_CodeSniffer_Sniff
48
+ * interface. A sniff registers what token types it wishes to listen for, then
49
+ * PHP_CodeSniffer encounters that token, the sniff is invoked and passed
50
+ * information about where the token was found in the stack, and the token stack
51
+ * itself.
52
+ *
53
+ * Sniff files and their containing class must be prefixed with Sniff, and
54
+ * have an extension of .php.
55
+ *
56
+ * Multiple PHP_CodeSniffer operations can be performed by re-calling the
57
+ * process function with different parameters.
58
+ *
59
+ * @category PHP
60
+ * @package PHP_CodeSniffer
61
+ * @author Greg Sherwood <gsherwood@squiz.net>
62
+ * @author Marc McIntyre <mmcintyre@squiz.net>
63
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
64
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
65
+ * @version Release: @package_version@
66
+ * @link http://pear.php.net/package/PHP_CodeSniffer
67
+ */
68
+ class PHP_CodeSniffer
69
+ {
70
+
71
+ /**
72
+ * The current version.
73
+ *
74
+ * @var string
75
+ */
76
+ const VERSION = '2.9.1';
77
+
78
+ /**
79
+ * Package stability; either stable, beta or alpha.
80
+ *
81
+ * @var string
82
+ */
83
+ const STABILITY = 'stable';
84
+
85
+ /**
86
+ * The file or directory that is currently being processed.
87
+ *
88
+ * @var string
89
+ */
90
+ protected $file = '';
91
+
92
+ /**
93
+ * The directories that the processed rulesets are in.
94
+ *
95
+ * This is declared static because it is also used in the
96
+ * autoloader to look for sniffs outside the PHPCS install.
97
+ * This way, standards designed to be installed inside PHPCS can
98
+ * also be used from outside the PHPCS Standards directory.
99
+ *
100
+ * @var string
101
+ */
102
+ protected static $rulesetDirs = array();
103
+
104
+ /**
105
+ * The CLI object controlling the run.
106
+ *
107
+ * @var PHP_CodeSniffer_CLI
108
+ */
109
+ public $cli = null;
110
+
111
+ /**
112
+ * The Reporting object controlling report generation.
113
+ *
114
+ * @var PHP_CodeSniffer_Reporting
115
+ */
116
+ public $reporting = null;
117
+
118
+ /**
119
+ * An array of sniff objects that are being used to check files.
120
+ *
121
+ * @var array(PHP_CodeSniffer_Sniff)
122
+ */
123
+ protected $listeners = array();
124
+
125
+ /**
126
+ * An array of sniffs that are being used to check files.
127
+ *
128
+ * @var array(string)
129
+ */
130
+ protected $sniffs = array();
131
+
132
+ /**
133
+ * A mapping of sniff codes to fully qualified class names.
134
+ *
135
+ * The key is the sniff code and the value
136
+ * is the fully qualified name of the sniff class.
137
+ *
138
+ * @var array<string, string>
139
+ */
140
+ public $sniffCodes = array();
141
+
142
+ /**
143
+ * The listeners array, indexed by token type.
144
+ *
145
+ * @var array
146
+ */
147
+ private $_tokenListeners = array();
148
+
149
+ /**
150
+ * An array of rules from the ruleset.xml file.
151
+ *
152
+ * It may be empty, indicating that the ruleset does not override
153
+ * any of the default sniff settings.
154
+ *
155
+ * @var array
156
+ */
157
+ protected $ruleset = array();
158
+
159
+ /**
160
+ * An array of patterns to use for skipping files.
161
+ *
162
+ * @var array
163
+ */
164
+ protected $ignorePatterns = array();
165
+
166
+ /**
167
+ * An array of extensions for files we will check.
168
+ *
169
+ * @var array
170
+ */
171
+ public $allowedFileExtensions = array();
172
+
173
+ /**
174
+ * An array of default extensions and associated tokenizers.
175
+ *
176
+ * If no extensions are set, these will be used as the defaults.
177
+ * If extensions are set, these will be used when the correct tokenizer
178
+ * can not be determined, such as when checking a passed filename instead
179
+ * of files in a directory.
180
+ *
181
+ * @var array
182
+ */
183
+ public $defaultFileExtensions = array(
184
+ 'php' => 'PHP',
185
+ 'inc' => 'PHP',
186
+ 'js' => 'JS',
187
+ 'css' => 'CSS',
188
+ );
189
+
190
+ /**
191
+ * An array of variable types for param/var we will check.
192
+ *
193
+ * @var array(string)
194
+ */
195
+ public static $allowedTypes = array(
196
+ 'array',
197
+ 'boolean',
198
+ 'float',
199
+ 'integer',
200
+ 'mixed',
201
+ 'object',
202
+ 'string',
203
+ 'resource',
204
+ 'callable',
205
+ );
206
+
207
+
208
+ /**
209
+ * Constructs a PHP_CodeSniffer object.
210
+ *
211
+ * @param int $verbosity The verbosity level.
212
+ * 1: Print progress information.
213
+ * 2: Print tokenizer debug information.
214
+ * 3: Print sniff debug information.
215
+ * @param int $tabWidth The number of spaces each tab represents.
216
+ * If greater than zero, tabs will be replaced
217
+ * by spaces before testing each file.
218
+ * @param string $encoding The charset of the sniffed files.
219
+ * This is important for some reports that output
220
+ * with utf-8 encoding as you don't want it double
221
+ * encoding messages.
222
+ * @param bool $interactive If TRUE, will stop after each file with errors
223
+ * and wait for user input.
224
+ *
225
+ * @see process()
226
+ */
227
+ public function __construct(
228
+ $verbosity=0,
229
+ $tabWidth=0,
230
+ $encoding='iso-8859-1',
231
+ $interactive=false
232
+ ) {
233
+ if ($verbosity !== null) {
234
+ $this->setVerbosity($verbosity);
235
+ }
236
+
237
+ if ($tabWidth !== null) {
238
+ $this->setTabWidth($tabWidth);
239
+ }
240
+
241
+ if ($encoding !== null) {
242
+ $this->setEncoding($encoding);
243
+ }
244
+
245
+ if ($interactive !== null) {
246
+ $this->setInteractive($interactive);
247
+ }
248
+
249
+ if (defined('PHPCS_DEFAULT_ERROR_SEV') === false) {
250
+ define('PHPCS_DEFAULT_ERROR_SEV', 5);
251
+ }
252
+
253
+ if (defined('PHPCS_DEFAULT_WARN_SEV') === false) {
254
+ define('PHPCS_DEFAULT_WARN_SEV', 5);
255
+ }
256
+
257
+ if (defined('PHP_CODESNIFFER_CBF') === false) {
258
+ define('PHP_CODESNIFFER_CBF', false);
259
+ }
260
+
261
+ // Set default CLI object in case someone is running us
262
+ // without using the command line script.
263
+ $this->cli = new PHP_CodeSniffer_CLI();
264
+ $this->cli->errorSeverity = PHPCS_DEFAULT_ERROR_SEV;
265
+ $this->cli->warningSeverity = PHPCS_DEFAULT_WARN_SEV;
266
+ $this->cli->dieOnUnknownArg = false;
267
+
268
+ $this->reporting = new PHP_CodeSniffer_Reporting();
269
+
270
+ }//end __construct()
271
+
272
+
273
+ /**
274
+ * Autoload static method for loading classes and interfaces.
275
+ *
276
+ * @param string $className The name of the class or interface.
277
+ *
278
+ * @return void
279
+ */
280
+ public static function autoload($className)
281
+ {
282
+ if (substr($className, 0, 4) === 'PHP_') {
283
+ $newClassName = substr($className, 4);
284
+ } else {
285
+ $newClassName = $className;
286
+ }
287
+
288
+ $path = str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $newClassName).'.php';
289
+
290
+ if (is_file(dirname(__FILE__).DIRECTORY_SEPARATOR.$path) === true) {
291
+ // Check standard file locations based on class name.
292
+ include dirname(__FILE__).DIRECTORY_SEPARATOR.$path;
293
+ return;
294
+ } else {
295
+ // Check for included sniffs.
296
+ $installedPaths = PHP_CodeSniffer::getInstalledStandardPaths();
297
+ foreach ($installedPaths as $installedPath) {
298
+ if (is_file($installedPath.DIRECTORY_SEPARATOR.$path) === true) {
299
+ include $installedPath.DIRECTORY_SEPARATOR.$path;
300
+ return;
301
+ }
302
+ }
303
+
304
+ // Check standard file locations based on the loaded rulesets.
305
+ foreach (self::$rulesetDirs as $rulesetDir) {
306
+ if (is_file(dirname($rulesetDir).DIRECTORY_SEPARATOR.$path) === true) {
307
+ include_once dirname($rulesetDir).DIRECTORY_SEPARATOR.$path;
308
+ return;
309
+ }
310
+ }
311
+ }//end if
312
+
313
+ // Everything else.
314
+ @include $path;
315
+
316
+ }//end autoload()
317
+
318
+
319
+ /**
320
+ * Sets the verbosity level.
321
+ *
322
+ * @param int $verbosity The verbosity level.
323
+ * 1: Print progress information.
324
+ * 2: Print tokenizer debug information.
325
+ * 3: Print sniff debug information.
326
+ *
327
+ * @return void
328
+ */
329
+ public function setVerbosity($verbosity)
330
+ {
331
+ if (defined('PHP_CODESNIFFER_VERBOSITY') === false) {
332
+ define('PHP_CODESNIFFER_VERBOSITY', $verbosity);
333
+ }
334
+
335
+ }//end setVerbosity()
336
+
337
+
338
+ /**
339
+ * Sets the tab width.
340
+ *
341
+ * @param int $tabWidth The number of spaces each tab represents.
342
+ * If greater than zero, tabs will be replaced
343
+ * by spaces before testing each file.
344
+ *
345
+ * @return void
346
+ */
347
+ public function setTabWidth($tabWidth)
348
+ {
349
+ if (defined('PHP_CODESNIFFER_TAB_WIDTH') === false) {
350
+ define('PHP_CODESNIFFER_TAB_WIDTH', $tabWidth);
351
+ }
352
+
353
+ }//end setTabWidth()
354
+
355
+
356
+ /**
357
+ * Sets the encoding.
358
+ *
359
+ * @param string $encoding The charset of the sniffed files.
360
+ * This is important for some reports that output
361
+ * with utf-8 encoding as you don't want it double
362
+ * encoding messages.
363
+ *
364
+ * @return void
365
+ */
366
+ public function setEncoding($encoding)
367
+ {
368
+ if (defined('PHP_CODESNIFFER_ENCODING') === false) {
369
+ define('PHP_CODESNIFFER_ENCODING', $encoding);
370
+ }
371
+
372
+ }//end setEncoding()
373
+
374
+
375
+ /**
376
+ * Sets the interactive flag.
377
+ *
378
+ * @param bool $interactive If TRUE, will stop after each file with errors
379
+ * and wait for user input.
380
+ *
381
+ * @return void
382
+ */
383
+ public function setInteractive($interactive)
384
+ {
385
+ if (defined('PHP_CODESNIFFER_INTERACTIVE') === false) {
386
+ define('PHP_CODESNIFFER_INTERACTIVE', $interactive);
387
+ }
388
+
389
+ }//end setInteractive()
390
+
391
+
392
+ /**
393
+ * Sets an array of file extensions that we will allow checking of.
394
+ *
395
+ * If the extension is one of the defaults, a specific tokenizer
396
+ * will be used. Otherwise, the PHP tokenizer will be used for
397
+ * all extensions passed.
398
+ *
399
+ * @param array $extensions An array of file extensions.
400
+ *
401
+ * @return void
402
+ */
403
+ public function setAllowedFileExtensions(array $extensions)
404
+ {
405
+ $newExtensions = array();
406
+ foreach ($extensions as $ext) {
407
+ $slash = strpos($ext, '/');
408
+ if ($slash !== false) {
409
+ // They specified the tokenizer too.
410
+ list($ext, $tokenizer) = explode('/', $ext);
411
+ $newExtensions[$ext] = strtoupper($tokenizer);
412
+ continue;
413
+ }
414
+
415
+ if (isset($this->allowedFileExtensions[$ext]) === true) {
416
+ $newExtensions[$ext] = $this->allowedFileExtensions[$ext];
417
+ } else if (isset($this->defaultFileExtensions[$ext]) === true) {
418
+ $newExtensions[$ext] = $this->defaultFileExtensions[$ext];
419
+ } else {
420
+ $newExtensions[$ext] = 'PHP';
421
+ }
422
+ }
423
+
424
+ $this->allowedFileExtensions = $newExtensions;
425
+
426
+ }//end setAllowedFileExtensions()
427
+
428
+
429
+ /**
430
+ * Sets an array of ignore patterns that we use to skip files and folders.
431
+ *
432
+ * Patterns are not case sensitive.
433
+ *
434
+ * @param array $patterns An array of ignore patterns. The pattern is the key
435
+ * and the value is either "absolute" or "relative",
436
+ * depending on how the pattern should be applied to a
437
+ * file path.
438
+ *
439
+ * @return void
440
+ */
441
+ public function setIgnorePatterns(array $patterns)
442
+ {
443
+ $this->ignorePatterns = $patterns;
444
+
445
+ }//end setIgnorePatterns()
446
+
447
+
448
+ /**
449
+ * Gets the array of ignore patterns.
450
+ *
451
+ * Optionally takes a listener to get ignore patterns specified
452
+ * for that sniff only.
453
+ *
454
+ * @param string $listener The listener to get patterns for. If NULL, all
455
+ * patterns are returned.
456
+ *
457
+ * @return array
458
+ */
459
+ public function getIgnorePatterns($listener=null)
460
+ {
461
+ if ($listener === null) {
462
+ return $this->ignorePatterns;
463
+ }
464
+
465
+ if (isset($this->ignorePatterns[$listener]) === true) {
466
+ return $this->ignorePatterns[$listener];
467
+ }
468
+
469
+ return array();
470
+
471
+ }//end getIgnorePatterns()
472
+
473
+
474
+ /**
475
+ * Sets the internal CLI object.
476
+ *
477
+ * @param object $cli The CLI object controlling the run.
478
+ *
479
+ * @return void
480
+ */
481
+ public function setCli($cli)
482
+ {
483
+ $this->cli = $cli;
484
+
485
+ }//end setCli()
486
+
487
+
488
+ /**
489
+ * Start a PHP_CodeSniffer run.
490
+ *
491
+ * @param string|array $files The files and directories to process. For
492
+ * directories, each sub directory will also
493
+ * be traversed for source files.
494
+ * @param string|array $standards The set of code sniffs we are testing
495
+ * against.
496
+ * @param array $restrictions The sniff codes to restrict the
497
+ * violations to.
498
+ * @param boolean $local If true, don't recurse into directories.
499
+ *
500
+ * @return void
501
+ */
502
+ public function process($files, $standards, array $restrictions=array(), $local=false)
503
+ {
504
+ $files = (array) $files;
505
+ $this->initStandard($standards, $restrictions);
506
+ $this->processFiles($files, $local);
507
+
508
+ }//end process()
509
+
510
+
511
+ /**
512
+ * Initialise the standard that the run will use.
513
+ *
514
+ * @param string|array $standards The set of code sniffs we are testing
515
+ * against.
516
+ * @param array $restrictions The sniff codes to restrict the testing to.
517
+ * @param array $exclusions The sniff codes to exclude from testing.
518
+ *
519
+ * @return void
520
+ */
521
+ public function initStandard($standards, array $restrictions=array(), array $exclusions=array())
522
+ {
523
+ $standards = (array) $standards;
524
+
525
+ // Reset the members.
526
+ $this->listeners = array();
527
+ $this->sniffs = array();
528
+ $this->ruleset = array();
529
+ $this->_tokenListeners = array();
530
+ self::$rulesetDirs = array();
531
+
532
+ // Ensure this option is enabled or else line endings will not always
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
+ ) {
546
+ $standard = self::realpath($standard.DIRECTORY_SEPARATOR.'ruleset.xml');
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) {
584
+ $parts = explode('.', strtolower($sniffCode));
585
+ $sniffRestrictions[] = $parts[0].'_sniffs_'.$parts[1].'_'.$parts[2].'sniff';
586
+ }
587
+
588
+ $sniffExclusions = array();
589
+ foreach ($exclusions as $sniffCode) {
590
+ $parts = explode('.', strtolower($sniffCode));
591
+ $sniffExclusions[] = $parts[0].'_sniffs_'.$parts[1].'_'.$parts[2].'sniff';
592
+ }
593
+
594
+ $this->registerSniffs($sniffs, $sniffRestrictions, $sniffExclusions);
595
+ $this->populateTokenListeners();
596
+
597
+ if (PHP_CODESNIFFER_VERBOSITY === 1) {
598
+ $numSniffs = count($this->sniffs);
599
+ echo "DONE ($numSniffs sniffs registered)".PHP_EOL;
600
+ }
601
+
602
+ }//end initStandard()
603
+
604
+
605
+ /**
606
+ * Processes the files/directories that PHP_CodeSniffer was constructed with.
607
+ *
608
+ * @param string|array $files The files and directories to process. For
609
+ * directories, each sub directory will also
610
+ * be traversed for source files.
611
+ * @param boolean $local If true, don't recurse into directories.
612
+ *
613
+ * @return void
614
+ * @throws PHP_CodeSniffer_Exception If files are invalid.
615
+ */
616
+ public function processFiles($files, $local=false)
617
+ {
618
+ $files = (array) $files;
619
+ $cliValues = $this->cli->getCommandLineValues();
620
+ $showProgress = $cliValues['showProgress'];
621
+ $useColors = $cliValues['colors'];
622
+
623
+ if (PHP_CODESNIFFER_VERBOSITY > 0) {
624
+ echo 'Creating file list... ';
625
+ }
626
+
627
+ if (empty($this->allowedFileExtensions) === true) {
628
+ $this->allowedFileExtensions = $this->defaultFileExtensions;
629
+ }
630
+
631
+ $todo = $this->getFilesToProcess($files, $local);
632
+ $numFiles = count($todo);
633
+
634
+ if (PHP_CODESNIFFER_VERBOSITY > 0) {
635
+ echo "DONE ($numFiles files in queue)".PHP_EOL;
636
+ }
637
+
638
+ $numProcessed = 0;
639
+ $dots = 0;
640
+ $maxLength = strlen($numFiles);
641
+ $lastDir = '';
642
+ foreach ($todo as $file) {
643
+ $this->file = $file;
644
+ $currDir = dirname($file);
645
+ if ($lastDir !== $currDir) {
646
+ if (PHP_CODESNIFFER_VERBOSITY > 0 || PHP_CODESNIFFER_CBF === true) {
647
+ echo 'Changing into directory '.$currDir.PHP_EOL;
648
+ }
649
+
650
+ $lastDir = $currDir;
651
+ }
652
+
653
+ $phpcsFile = $this->processFile($file, null);
654
+ $numProcessed++;
655
+
656
+ if (PHP_CODESNIFFER_VERBOSITY > 0
657
+ || PHP_CODESNIFFER_INTERACTIVE === true
658
+ || $showProgress === false
659
+ ) {
660
+ continue;
661
+ }
662
+
663
+ // Show progress information.
664
+ if ($phpcsFile === null) {
665
+ echo 'S';
666
+ } else {
667
+ $errors = $phpcsFile->getErrorCount();
668
+ $warnings = $phpcsFile->getWarningCount();
669
+ if ($errors > 0) {
670
+ if ($useColors === true) {
671
+ echo "\033[31m";
672
+ }
673
+
674
+ echo 'E';
675
+ } else if ($warnings > 0) {
676
+ if ($useColors === true) {
677
+ echo "\033[33m";
678
+ }
679
+
680
+ echo 'W';
681
+ } else {
682
+ echo '.';
683
+ }
684
+
685
+ if ($useColors === true) {
686
+ echo "\033[0m";
687
+ }
688
+ }//end if
689
+
690
+ $dots++;
691
+ if ($dots === 60) {
692
+ $padding = ($maxLength - strlen($numProcessed));
693
+ echo str_repeat(' ', $padding);
694
+ $percent = round(($numProcessed / $numFiles) * 100);
695
+ echo " $numProcessed / $numFiles ($percent%)".PHP_EOL;
696
+ $dots = 0;
697
+ }
698
+ }//end foreach
699
+
700
+ if (PHP_CODESNIFFER_VERBOSITY === 0
701
+ && PHP_CODESNIFFER_INTERACTIVE === false
702
+ && $showProgress === true
703
+ ) {
704
+ echo PHP_EOL.PHP_EOL;
705
+ }
706
+
707
+ }//end processFiles()
708
+
709
+
710
+ /**
711
+ * Processes a single ruleset and returns a list of the sniffs it represents.
712
+ *
713
+ * Rules founds within the ruleset are processed immediately, but sniff classes
714
+ * are not registered by this method.
715
+ *
716
+ * @param string $rulesetPath The path to a ruleset XML file.
717
+ * @param int $depth How many nested processing steps we are in. This
718
+ * is only used for debug output.
719
+ *
720
+ * @return array
721
+ * @throws PHP_CodeSniffer_Exception If the ruleset path is invalid.
722
+ */
723
+ public function processRuleset($rulesetPath, $depth=0)
724
+ {
725
+ $rulesetPath = self::realpath($rulesetPath);
726
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
727
+ echo str_repeat("\t", $depth);
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
+ }
735
+
736
+ $ownSniffs = array();
737
+ $includedSniffs = array();
738
+ $excludedSniffs = array();
739
+ $cliValues = $this->cli->getCommandLineValues();
740
+
741
+ $rulesetDir = dirname($rulesetPath);
742
+ self::$rulesetDirs[] = $rulesetDir;
743
+
744
+ if (is_dir($rulesetDir.DIRECTORY_SEPARATOR.'Sniffs') === true) {
745
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
746
+ echo str_repeat("\t", $depth);
747
+ echo "\tAdding sniff files from \"/.../".basename($rulesetDir)."/Sniffs/\" directory".PHP_EOL;
748
+ }
749
+
750
+ $ownSniffs = $this->_expandSniffDirectory($rulesetDir.DIRECTORY_SEPARATOR.'Sniffs', $depth);
751
+ }
752
+
753
+ // Process custom sniff config settings.
754
+ foreach ($ruleset->{'config'} as $config) {
755
+ if ($this->_shouldProcessElement($config) === false) {
756
+ continue;
757
+ }
758
+
759
+ $this->setConfigData((string) $config['name'], (string) $config['value'], true);
760
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
761
+ echo str_repeat("\t", $depth);
762
+ echo "\t=> set config value ".(string) $config['name'].': '.(string) $config['value'].PHP_EOL;
763
+ }
764
+ }
765
+
766
+ foreach ($ruleset->rule as $rule) {
767
+ if (isset($rule['ref']) === false
768
+ || $this->_shouldProcessElement($rule) === false
769
+ ) {
770
+ continue;
771
+ }
772
+
773
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
774
+ echo str_repeat("\t", $depth);
775
+ echo "\tProcessing rule \"".$rule['ref'].'"'.PHP_EOL;
776
+ }
777
+
778
+ $includedSniffs = array_merge(
779
+ $includedSniffs,
780
+ $this->_expandRulesetReference($rule['ref'], $rulesetDir, $depth)
781
+ );
782
+
783
+ if (isset($rule->exclude) === true) {
784
+ foreach ($rule->exclude as $exclude) {
785
+ if ($this->_shouldProcessElement($exclude) === false) {
786
+ continue;
787
+ }
788
+
789
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
790
+ echo str_repeat("\t", $depth);
791
+ echo "\t\tExcluding rule \"".$exclude['name'].'"'.PHP_EOL;
792
+ }
793
+
794
+ // Check if a single code is being excluded, which is a shortcut
795
+ // for setting the severity of the message to 0.
796
+ $parts = explode('.', $exclude['name']);
797
+ if (count($parts) === 4) {
798
+ $this->ruleset[(string) $exclude['name']]['severity'] = 0;
799
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
800
+ echo str_repeat("\t", $depth);
801
+ echo "\t\t=> severity set to 0".PHP_EOL;
802
+ }
803
+ } else {
804
+ $excludedSniffs = array_merge(
805
+ $excludedSniffs,
806
+ $this->_expandRulesetReference($exclude['name'], $rulesetDir, ($depth + 1))
807
+ );
808
+ }
809
+ }//end foreach
810
+ }//end if
811
+
812
+ $this->_processRule($rule, $depth);
813
+ }//end foreach
814
+
815
+ // Process custom command line arguments.
816
+ $cliArgs = array();
817
+ foreach ($ruleset->{'arg'} as $arg) {
818
+ if ($this->_shouldProcessElement($arg) === false) {
819
+ continue;
820
+ }
821
+
822
+ if (isset($arg['name']) === true) {
823
+ $argString = '--'.(string) $arg['name'];
824
+ if (isset($arg['value']) === true) {
825
+ $argString .= '='.(string) $arg['value'];
826
+ }
827
+ } else {
828
+ $argString = '-'.(string) $arg['value'];
829
+ }
830
+
831
+ $cliArgs[] = $argString;
832
+
833
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
834
+ echo str_repeat("\t", $depth);
835
+ echo "\t=> set command line value $argString".PHP_EOL;
836
+ }
837
+ }//end foreach
838
+
839
+ // Set custom php ini values as CLI args.
840
+ foreach ($ruleset->{'ini'} as $arg) {
841
+ if ($this->_shouldProcessElement($arg) === false) {
842
+ continue;
843
+ }
844
+
845
+ if (isset($arg['name']) === false) {
846
+ continue;
847
+ }
848
+
849
+ $name = (string) $arg['name'];
850
+ $argString = $name;
851
+ if (isset($arg['value']) === true) {
852
+ $value = (string) $arg['value'];
853
+ $argString .= "=$value";
854
+ } else {
855
+ $value = 'true';
856
+ }
857
+
858
+ $cliArgs[] = '-d';
859
+ $cliArgs[] = $argString;
860
+
861
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
862
+ echo str_repeat("\t", $depth);
863
+ echo "\t=> set PHP ini value $name to $value".PHP_EOL;
864
+ }
865
+ }//end foreach
866
+
867
+ if (empty($cliValues['files']) === true && $cliValues['stdin'] === null) {
868
+ // Process hard-coded file paths.
869
+ foreach ($ruleset->{'file'} as $file) {
870
+ $file = (string) $file;
871
+ $cliArgs[] = $file;
872
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
873
+ echo str_repeat("\t", $depth);
874
+ echo "\t=> added \"$file\" to the file list".PHP_EOL;
875
+ }
876
+ }
877
+ }
878
+
879
+ if (empty($cliArgs) === false) {
880
+ // Change the directory so all relative paths are worked
881
+ // out based on the location of the ruleset instead of
882
+ // the location of the user.
883
+ $inPhar = self::isPharFile($rulesetDir);
884
+ if ($inPhar === false) {
885
+ $currentDir = getcwd();
886
+ chdir($rulesetDir);
887
+ }
888
+
889
+ $this->cli->setCommandLineValues($cliArgs);
890
+
891
+ if ($inPhar === false) {
892
+ chdir($currentDir);
893
+ }
894
+ }
895
+
896
+ // Process custom ignore pattern rules.
897
+ foreach ($ruleset->{'exclude-pattern'} as $pattern) {
898
+ if ($this->_shouldProcessElement($pattern) === false) {
899
+ continue;
900
+ }
901
+
902
+ if (isset($pattern['type']) === false) {
903
+ $pattern['type'] = 'absolute';
904
+ }
905
+
906
+ $this->ignorePatterns[(string) $pattern] = (string) $pattern['type'];
907
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
908
+ echo str_repeat("\t", $depth);
909
+ echo "\t=> added global ".(string) $pattern['type'].' ignore pattern: '.(string) $pattern.PHP_EOL;
910
+ }
911
+ }
912
+
913
+ $includedSniffs = array_unique(array_merge($ownSniffs, $includedSniffs));
914
+ $excludedSniffs = array_unique($excludedSniffs);
915
+
916
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
917
+ $included = count($includedSniffs);
918
+ $excluded = count($excludedSniffs);
919
+ echo str_repeat("\t", $depth);
920
+ echo "=> Ruleset processing complete; included $included sniffs and excluded $excluded".PHP_EOL;
921
+ }
922
+
923
+ // Merge our own sniff list with our externally included
924
+ // sniff list, but filter out any excluded sniffs.
925
+ $files = array();
926
+ foreach ($includedSniffs as $sniff) {
927
+ if (in_array($sniff, $excludedSniffs) === true) {
928
+ continue;
929
+ } else {
930
+ $files[] = self::realpath($sniff);
931
+ }
932
+ }
933
+
934
+ return $files;
935
+
936
+ }//end processRuleset()
937
+
938
+
939
+ /**
940
+ * Expands a directory into a list of sniff files within.
941
+ *
942
+ * @param string $directory The path to a directory.
943
+ * @param int $depth How many nested processing steps we are in. This
944
+ * is only used for debug output.
945
+ *
946
+ * @return array
947
+ */
948
+ private function _expandSniffDirectory($directory, $depth=0)
949
+ {
950
+ $sniffs = array();
951
+
952
+ if (defined('RecursiveDirectoryIterator::FOLLOW_SYMLINKS') === true) {
953
+ $rdi = new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::FOLLOW_SYMLINKS);
954
+ } else {
955
+ $rdi = new RecursiveDirectoryIterator($directory);
956
+ }
957
+
958
+ $di = new RecursiveIteratorIterator($rdi, 0, RecursiveIteratorIterator::CATCH_GET_CHILD);
959
+
960
+ $dirLen = strlen($directory);
961
+
962
+ foreach ($di as $file) {
963
+ $filename = $file->getFilename();
964
+
965
+ // Skip hidden files.
966
+ if (substr($filename, 0, 1) === '.') {
967
+ continue;
968
+ }
969
+
970
+ // We are only interested in PHP and sniff files.
971
+ $fileParts = explode('.', $filename);
972
+ if (array_pop($fileParts) !== 'php') {
973
+ continue;
974
+ }
975
+
976
+ $basename = basename($filename, '.php');
977
+ if (substr($basename, -5) !== 'Sniff') {
978
+ continue;
979
+ }
980
+
981
+ $path = $file->getPathname();
982
+
983
+ // Skip files in hidden directories within the Sniffs directory of this
984
+ // standard. We use the offset with strpos() to allow hidden directories
985
+ // before, valid example:
986
+ // /home/foo/.composer/vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/...
987
+ if (strpos($path, DIRECTORY_SEPARATOR.'.', $dirLen) !== false) {
988
+ continue;
989
+ }
990
+
991
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
992
+ echo str_repeat("\t", $depth);
993
+ echo "\t\t=> $path".PHP_EOL;
994
+ }
995
+
996
+ $sniffs[] = $path;
997
+ }//end foreach
998
+
999
+ return $sniffs;
1000
+
1001
+ }//end _expandSniffDirectory()
1002
+
1003
+
1004
+ /**
1005
+ * Expands a ruleset reference into a list of sniff files.
1006
+ *
1007
+ * @param string $ref The reference from the ruleset XML file.
1008
+ * @param string $rulesetDir The directory of the ruleset XML file, used to
1009
+ * evaluate relative paths.
1010
+ * @param int $depth How many nested processing steps we are in. This
1011
+ * is only used for debug output.
1012
+ *
1013
+ * @return array
1014
+ * @throws PHP_CodeSniffer_Exception If the reference is invalid.
1015
+ */
1016
+ private function _expandRulesetReference($ref, $rulesetDir, $depth=0)
1017
+ {
1018
+ // Ignore internal sniffs codes as they are used to only
1019
+ // hide and change internal messages.
1020
+ if (substr($ref, 0, 9) === 'Internal.') {
1021
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1022
+ echo str_repeat("\t", $depth);
1023
+ echo "\t\t* ignoring internal sniff code *".PHP_EOL;
1024
+ }
1025
+
1026
+ return array();
1027
+ }
1028
+
1029
+ // As sniffs can't begin with a full stop, assume references in
1030
+ // this format are relative paths and attempt to convert them
1031
+ // to absolute paths. If this fails, let the reference run through
1032
+ // the normal checks and have it fail as normal.
1033
+ if (substr($ref, 0, 1) === '.') {
1034
+ $realpath = self::realpath($rulesetDir.'/'.$ref);
1035
+ if ($realpath !== false) {
1036
+ $ref = $realpath;
1037
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1038
+ echo str_repeat("\t", $depth);
1039
+ echo "\t\t=> $ref".PHP_EOL;
1040
+ }
1041
+ }
1042
+ }
1043
+
1044
+ // As sniffs can't begin with a tilde, assume references in
1045
+ // this format at relative to the user's home directory.
1046
+ if (substr($ref, 0, 2) === '~/') {
1047
+ $realpath = self::realpath($ref);
1048
+ if ($realpath !== false) {
1049
+ $ref = $realpath;
1050
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1051
+ echo str_repeat("\t", $depth);
1052
+ echo "\t\t=> $ref".PHP_EOL;
1053
+ }
1054
+ }
1055
+ }
1056
+
1057
+ if (is_file($ref) === true) {
1058
+ if (substr($ref, -9) === 'Sniff.php') {
1059
+ // A single external sniff.
1060
+ self::$rulesetDirs[] = dirname(dirname(dirname($ref)));
1061
+ return array($ref);
1062
+ }
1063
+ } else {
1064
+ // See if this is a whole standard being referenced.
1065
+ $path = $this->getInstalledStandardPath($ref);
1066
+ if (self::isPharFile($path) === true && strpos($path, 'ruleset.xml') === false) {
1067
+ // If the ruleset exists inside the phar file, use it.
1068
+ if (file_exists($path.DIRECTORY_SEPARATOR.'ruleset.xml') === true) {
1069
+ $path = $path.DIRECTORY_SEPARATOR.'ruleset.xml';
1070
+ } else {
1071
+ $path = null;
1072
+ }
1073
+ }
1074
+
1075
+ if ($path !== null) {
1076
+ $ref = $path;
1077
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1078
+ echo str_repeat("\t", $depth);
1079
+ echo "\t\t=> $ref".PHP_EOL;
1080
+ }
1081
+ } else if (is_dir($ref) === false) {
1082
+ // Work out the sniff path.
1083
+ $sepPos = strpos($ref, DIRECTORY_SEPARATOR);
1084
+ if ($sepPos !== false) {
1085
+ $stdName = substr($ref, 0, $sepPos);
1086
+ $path = substr($ref, $sepPos);
1087
+ } else {
1088
+ $parts = explode('.', $ref);
1089
+ $stdName = $parts[0];
1090
+ if (count($parts) === 1) {
1091
+ // A whole standard?
1092
+ $path = '';
1093
+ } else if (count($parts) === 2) {
1094
+ // A directory of sniffs?
1095
+ $path = DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR.$parts[1];
1096
+ } else {
1097
+ // A single sniff?
1098
+ $path = DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR.$parts[1].DIRECTORY_SEPARATOR.$parts[2].'Sniff.php';
1099
+ }
1100
+ }
1101
+
1102
+ $newRef = false;
1103
+ $stdPath = $this->getInstalledStandardPath($stdName);
1104
+ if ($stdPath !== null && $path !== '') {
1105
+ if (self::isPharFile($stdPath) === true
1106
+ && strpos($stdPath, 'ruleset.xml') === false
1107
+ ) {
1108
+ // Phar files can only return the directory,
1109
+ // since ruleset can be omitted if building one standard.
1110
+ $newRef = self::realpath($stdPath.$path);
1111
+ } else {
1112
+ $newRef = self::realpath(dirname($stdPath).$path);
1113
+ }
1114
+ }
1115
+
1116
+ if ($newRef === false) {
1117
+ // The sniff is not locally installed, so check if it is being
1118
+ // referenced as a remote sniff outside the install. We do this
1119
+ // by looking through all directories where we have found ruleset
1120
+ // files before, looking for ones for this particular standard,
1121
+ // and seeing if it is in there.
1122
+ foreach (self::$rulesetDirs as $dir) {
1123
+ if (strtolower(basename($dir)) !== strtolower($stdName)) {
1124
+ continue;
1125
+ }
1126
+
1127
+ $newRef = self::realpath($dir.$path);
1128
+
1129
+ if ($newRef !== false) {
1130
+ $ref = $newRef;
1131
+ }
1132
+ }
1133
+ } else {
1134
+ $ref = $newRef;
1135
+ }
1136
+
1137
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1138
+ echo str_repeat("\t", $depth);
1139
+ echo "\t\t=> $ref".PHP_EOL;
1140
+ }
1141
+ }//end if
1142
+ }//end if
1143
+
1144
+ if (is_dir($ref) === true) {
1145
+ if (is_file($ref.DIRECTORY_SEPARATOR.'ruleset.xml') === true) {
1146
+ // We are referencing an external coding standard.
1147
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1148
+ echo str_repeat("\t", $depth);
1149
+ echo "\t\t* rule is referencing a standard using directory name; processing *".PHP_EOL;
1150
+ }
1151
+
1152
+ return $this->processRuleset($ref.DIRECTORY_SEPARATOR.'ruleset.xml', ($depth + 2));
1153
+ } else {
1154
+ // We are referencing a whole directory of sniffs.
1155
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1156
+ echo str_repeat("\t", $depth);
1157
+ echo "\t\t* rule is referencing a directory of sniffs *".PHP_EOL;
1158
+ echo str_repeat("\t", $depth);
1159
+ echo "\t\tAdding sniff files from directory".PHP_EOL;
1160
+ }
1161
+
1162
+ return $this->_expandSniffDirectory($ref, ($depth + 1));
1163
+ }
1164
+ } else {
1165
+ if (is_file($ref) === false) {
1166
+ $error = "Referenced sniff \"$ref\" does not exist";
1167
+ throw new PHP_CodeSniffer_Exception($error);
1168
+ }
1169
+
1170
+ if (substr($ref, -9) === 'Sniff.php') {
1171
+ // A single sniff.
1172
+ return array($ref);
1173
+ } else {
1174
+ // Assume an external ruleset.xml file.
1175
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1176
+ echo str_repeat("\t", $depth);
1177
+ echo "\t\t* rule is referencing a standard using ruleset path; processing *".PHP_EOL;
1178
+ }
1179
+
1180
+ return $this->processRuleset($ref, ($depth + 2));
1181
+ }
1182
+ }//end if
1183
+
1184
+ }//end _expandRulesetReference()
1185
+
1186
+
1187
+ /**
1188
+ * Processes a rule from a ruleset XML file, overriding built-in defaults.
1189
+ *
1190
+ * @param SimpleXMLElement $rule The rule object from a ruleset XML file.
1191
+ * @param int $depth How many nested processing steps we are in.
1192
+ * This is only used for debug output.
1193
+ *
1194
+ * @return void
1195
+ */
1196
+ private function _processRule($rule, $depth=0)
1197
+ {
1198
+ $code = (string) $rule['ref'];
1199
+
1200
+ // Custom severity.
1201
+ if (isset($rule->severity) === true
1202
+ && $this->_shouldProcessElement($rule->severity) === true
1203
+ ) {
1204
+ if (isset($this->ruleset[$code]) === false) {
1205
+ $this->ruleset[$code] = array();
1206
+ }
1207
+
1208
+ $this->ruleset[$code]['severity'] = (int) $rule->severity;
1209
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1210
+ echo str_repeat("\t", $depth);
1211
+ echo "\t\t=> severity set to ".(int) $rule->severity.PHP_EOL;
1212
+ }
1213
+ }
1214
+
1215
+ // Custom message type.
1216
+ if (isset($rule->type) === true
1217
+ && $this->_shouldProcessElement($rule->type) === true
1218
+ ) {
1219
+ if (isset($this->ruleset[$code]) === false) {
1220
+ $this->ruleset[$code] = array();
1221
+ }
1222
+
1223
+ $this->ruleset[$code]['type'] = (string) $rule->type;
1224
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1225
+ echo str_repeat("\t", $depth);
1226
+ echo "\t\t=> message type set to ".(string) $rule->type.PHP_EOL;
1227
+ }
1228
+ }
1229
+
1230
+ // Custom message.
1231
+ if (isset($rule->message) === true
1232
+ && $this->_shouldProcessElement($rule->message) === true
1233
+ ) {
1234
+ if (isset($this->ruleset[$code]) === false) {
1235
+ $this->ruleset[$code] = array();
1236
+ }
1237
+
1238
+ $this->ruleset[$code]['message'] = (string) $rule->message;
1239
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1240
+ echo str_repeat("\t", $depth);
1241
+ echo "\t\t=> message set to ".(string) $rule->message.PHP_EOL;
1242
+ }
1243
+ }
1244
+
1245
+ // Custom properties.
1246
+ if (isset($rule->properties) === true
1247
+ && $this->_shouldProcessElement($rule->properties) === true
1248
+ ) {
1249
+ foreach ($rule->properties->property as $prop) {
1250
+ if ($this->_shouldProcessElement($prop) === false) {
1251
+ continue;
1252
+ }
1253
+
1254
+ if (isset($this->ruleset[$code]) === false) {
1255
+ $this->ruleset[$code] = array(
1256
+ 'properties' => array(),
1257
+ );
1258
+ } else if (isset($this->ruleset[$code]['properties']) === false) {
1259
+ $this->ruleset[$code]['properties'] = array();
1260
+ }
1261
+
1262
+ $name = (string) $prop['name'];
1263
+ if (isset($prop['type']) === true
1264
+ && (string) $prop['type'] === 'array'
1265
+ ) {
1266
+ $value = (string) $prop['value'];
1267
+ $values = array();
1268
+ foreach (explode(',', $value) as $val) {
1269
+ $v = '';
1270
+
1271
+ list($k,$v) = explode('=>', $val.'=>');
1272
+ if ($v !== '') {
1273
+ $values[$k] = $v;
1274
+ } else {
1275
+ $values[] = $k;
1276
+ }
1277
+ }
1278
+
1279
+ $this->ruleset[$code]['properties'][$name] = $values;
1280
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1281
+ echo str_repeat("\t", $depth);
1282
+ echo "\t\t=> array property \"$name\" set to \"$value\"".PHP_EOL;
1283
+ }
1284
+ } else {
1285
+ $this->ruleset[$code]['properties'][$name] = (string) $prop['value'];
1286
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1287
+ echo str_repeat("\t", $depth);
1288
+ echo "\t\t=> property \"$name\" set to \"".(string) $prop['value'].'"'.PHP_EOL;
1289
+ }
1290
+ }//end if
1291
+ }//end foreach
1292
+ }//end if
1293
+
1294
+ // Ignore patterns.
1295
+ foreach ($rule->{'exclude-pattern'} as $pattern) {
1296
+ if ($this->_shouldProcessElement($pattern) === false) {
1297
+ continue;
1298
+ }
1299
+
1300
+ if (isset($this->ignorePatterns[$code]) === false) {
1301
+ $this->ignorePatterns[$code] = array();
1302
+ }
1303
+
1304
+ if (isset($pattern['type']) === false) {
1305
+ $pattern['type'] = 'absolute';
1306
+ }
1307
+
1308
+ $this->ignorePatterns[$code][(string) $pattern] = (string) $pattern['type'];
1309
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1310
+ echo str_repeat("\t", $depth);
1311
+ echo "\t\t=> added sniff-specific ".(string) $pattern['type'].' ignore pattern: '.(string) $pattern.PHP_EOL;
1312
+ }
1313
+ }
1314
+
1315
+ }//end _processRule()
1316
+
1317
+
1318
+ /**
1319
+ * Determine if an element should be processed or ignored.
1320
+ *
1321
+ * @param SimpleXMLElement $element An object from a ruleset XML file.
1322
+ * @param int $depth How many nested processing steps we are in.
1323
+ * This is only used for debug output.
1324
+ *
1325
+ * @return bool
1326
+ */
1327
+ private function _shouldProcessElement($element, $depth=0)
1328
+ {
1329
+ if (isset($element['phpcbf-only']) === false
1330
+ && isset($element['phpcs-only']) === false
1331
+ ) {
1332
+ // No exceptions are being made.
1333
+ return true;
1334
+ }
1335
+
1336
+ if (PHP_CODESNIFFER_CBF === true
1337
+ && isset($element['phpcbf-only']) === true
1338
+ && (string) $element['phpcbf-only'] === 'true'
1339
+ ) {
1340
+ return true;
1341
+ }
1342
+
1343
+ if (PHP_CODESNIFFER_CBF === false
1344
+ && isset($element['phpcs-only']) === true
1345
+ && (string) $element['phpcs-only'] === 'true'
1346
+ ) {
1347
+ return true;
1348
+ }
1349
+
1350
+ return false;
1351
+
1352
+ }//end _shouldProcessElement()
1353
+
1354
+
1355
+ /**
1356
+ * Loads and stores sniffs objects used for sniffing files.
1357
+ *
1358
+ * @param array $files Paths to the sniff files to register.
1359
+ * @param array $restrictions The sniff class names to restrict the allowed
1360
+ * listeners to.
1361
+ * @param array $exclusions The sniff class names to exclude from the
1362
+ * listeners list.
1363
+ *
1364
+ * @return void
1365
+ * @throws PHP_CodeSniffer_Exception If a sniff file path is invalid.
1366
+ */
1367
+ public function registerSniffs($files, $restrictions, $exclusions)
1368
+ {
1369
+ $listeners = array();
1370
+
1371
+ foreach ($files as $file) {
1372
+ // Work out where the position of /StandardName/Sniffs/... is
1373
+ // so we can determine what the class will be called.
1374
+ $sniffPos = strrpos($file, DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR);
1375
+ if ($sniffPos === false) {
1376
+ continue;
1377
+ }
1378
+
1379
+ $slashPos = strrpos(substr($file, 0, $sniffPos), DIRECTORY_SEPARATOR);
1380
+ if ($slashPos === false) {
1381
+ continue;
1382
+ }
1383
+
1384
+ $className = substr($file, ($slashPos + 1));
1385
+
1386
+ if (substr_count($className, DIRECTORY_SEPARATOR) !== 3) {
1387
+ throw new PHP_CodeSniffer_Exception("Sniff file $className is not valid; sniff files must be located in a .../StandardName/Sniffs/CategoryName/ directory");
1388
+ }
1389
+
1390
+ $className = substr($className, 0, -4);
1391
+ $className = str_replace(DIRECTORY_SEPARATOR, '_', $className);
1392
+
1393
+ // If they have specified a list of sniffs to restrict to, check
1394
+ // to see if this sniff is allowed.
1395
+ if (empty($restrictions) === false
1396
+ && in_array(strtolower($className), $restrictions) === false
1397
+ ) {
1398
+ continue;
1399
+ }
1400
+
1401
+ // If they have specified a list of sniffs to exclude, check
1402
+ // to see if this sniff is allowed.
1403
+ if (empty($exclusions) === false
1404
+ && in_array(strtolower($className), $exclusions) === true
1405
+ ) {
1406
+ continue;
1407
+ }
1408
+
1409
+ include_once $file;
1410
+
1411
+ // Support the use of PHP namespaces. If the class name we included
1412
+ // contains namespace separators instead of underscores, use this as the
1413
+ // class name from now on.
1414
+ $classNameNS = str_replace('_', '\\', $className);
1415
+ if (class_exists($classNameNS, false) === true) {
1416
+ $className = $classNameNS;
1417
+ }
1418
+
1419
+ // Skip abstract classes.
1420
+ $reflection = new ReflectionClass($className);
1421
+ if ($reflection->isAbstract() === true) {
1422
+ continue;
1423
+ }
1424
+
1425
+ $listeners[$className] = $className;
1426
+
1427
+ if (PHP_CODESNIFFER_VERBOSITY > 2) {
1428
+ echo "Registered $className".PHP_EOL;
1429
+ }
1430
+ }//end foreach
1431
+
1432
+ $this->sniffs = $listeners;
1433
+
1434
+ }//end registerSniffs()
1435
+
1436
+
1437
+ /**
1438
+ * Populates the array of PHP_CodeSniffer_Sniff's for this file.
1439
+ *
1440
+ * @return void
1441
+ * @throws PHP_CodeSniffer_Exception If sniff registration fails.
1442
+ */
1443
+ public function populateTokenListeners()
1444
+ {
1445
+ // Construct a list of listeners indexed by token being listened for.
1446
+ $this->_tokenListeners = array();
1447
+
1448
+ foreach ($this->sniffs as $listenerClass) {
1449
+ // Work out the internal code for this sniff. Detect usage of namespace
1450
+ // separators instead of underscores to support PHP namespaces.
1451
+ if (strstr($listenerClass, '\\') === false) {
1452
+ $parts = explode('_', $listenerClass);
1453
+ } else {
1454
+ $parts = explode('\\', $listenerClass);
1455
+ }
1456
+
1457
+ $code = $parts[0].'.'.$parts[2].'.'.$parts[3];
1458
+ $code = substr($code, 0, -5);
1459
+
1460
+ $this->listeners[$listenerClass] = new $listenerClass();
1461
+ $this->sniffCodes[$code] = $listenerClass;
1462
+
1463
+ // Set custom properties.
1464
+ if (isset($this->ruleset[$code]['properties']) === true) {
1465
+ foreach ($this->ruleset[$code]['properties'] as $name => $value) {
1466
+ $this->setSniffProperty($listenerClass, $name, $value);
1467
+ }
1468
+ }
1469
+
1470
+ $tokenizers = array();
1471
+ $vars = get_class_vars($listenerClass);
1472
+ if (isset($vars['supportedTokenizers']) === true) {
1473
+ foreach ($vars['supportedTokenizers'] as $tokenizer) {
1474
+ $tokenizers[$tokenizer] = $tokenizer;
1475
+ }
1476
+ } else {
1477
+ $tokenizers = array('PHP' => 'PHP');
1478
+ }
1479
+
1480
+ $tokens = $this->listeners[$listenerClass]->register();
1481
+ if (is_array($tokens) === false) {
1482
+ $msg = "Sniff $listenerClass register() method must return an array";
1483
+ throw new PHP_CodeSniffer_Exception($msg);
1484
+ }
1485
+
1486
+ $parts = explode('_', str_replace('\\', '_', $listenerClass));
1487
+ $listenerSource = $parts[0].'.'.$parts[2].'.'.substr($parts[3], 0, -5);
1488
+ $ignorePatterns = array();
1489
+ $patterns = $this->getIgnorePatterns($listenerSource);
1490
+ foreach ($patterns as $pattern => $type) {
1491
+ // While there is support for a type of each pattern
1492
+ // (absolute or relative) we don't actually support it here.
1493
+ $replacements = array(
1494
+ '\\,' => ',',
1495
+ '*' => '.*',
1496
+ );
1497
+
1498
+ $ignorePatterns[] = strtr($pattern, $replacements);
1499
+ }
1500
+
1501
+ foreach ($tokens as $token) {
1502
+ if (isset($this->_tokenListeners[$token]) === false) {
1503
+ $this->_tokenListeners[$token] = array();
1504
+ }
1505
+
1506
+ if (isset($this->_tokenListeners[$token][$listenerClass]) === false) {
1507
+ $this->_tokenListeners[$token][$listenerClass] = array(
1508
+ 'class' => $listenerClass,
1509
+ 'source' => $listenerSource,
1510
+ 'tokenizers' => $tokenizers,
1511
+ 'ignore' => $ignorePatterns,
1512
+ );
1513
+ }
1514
+ }
1515
+ }//end foreach
1516
+
1517
+ }//end populateTokenListeners()
1518
+
1519
+
1520
+ /**
1521
+ * Set a single property for a sniff.
1522
+ *
1523
+ * @param string $listenerClass The class name of the sniff.
1524
+ * @param string $name The name of the property to change.
1525
+ * @param string $value The new value of the property.
1526
+ *
1527
+ * @return void
1528
+ */
1529
+ public function setSniffProperty($listenerClass, $name, $value)
1530
+ {
1531
+ // Setting a property for a sniff we are not using.
1532
+ if (isset($this->listeners[$listenerClass]) === false) {
1533
+ return;
1534
+ }
1535
+
1536
+ $name = trim($name);
1537
+ if (is_string($value) === true) {
1538
+ $value = trim($value);
1539
+ }
1540
+
1541
+ // Special case for booleans.
1542
+ if ($value === 'true') {
1543
+ $value = true;
1544
+ } else if ($value === 'false') {
1545
+ $value = false;
1546
+ }
1547
+
1548
+ $this->listeners[$listenerClass]->$name = $value;
1549
+
1550
+ }//end setSniffProperty()
1551
+
1552
+
1553
+ /**
1554
+ * Get a list of files that will be processed.
1555
+ *
1556
+ * If passed directories, this method will find all files within them.
1557
+ * The method will also perform file extension and ignore pattern filtering.
1558
+ *
1559
+ * @param string $paths A list of file or directory paths to process.
1560
+ * @param boolean $local If true, only process 1 level of files in directories
1561
+ *
1562
+ * @return array
1563
+ * @throws Exception If there was an error opening a directory.
1564
+ * @see shouldProcessFile()
1565
+ */
1566
+ public function getFilesToProcess($paths, $local=false)
1567
+ {
1568
+ $files = array();
1569
+
1570
+ foreach ($paths as $path) {
1571
+ if (is_dir($path) === true || self::isPharFile($path) === true) {
1572
+ if (self::isPharFile($path) === true) {
1573
+ $path = 'phar://'.$path;
1574
+ }
1575
+
1576
+ if ($local === true) {
1577
+ $di = new DirectoryIterator($path);
1578
+ } else {
1579
+ $di = new RecursiveIteratorIterator(
1580
+ new RecursiveDirectoryIterator($path),
1581
+ 0,
1582
+ RecursiveIteratorIterator::CATCH_GET_CHILD
1583
+ );
1584
+ }
1585
+
1586
+ foreach ($di as $file) {
1587
+ // Check if the file exists after all symlinks are resolved.
1588
+ $filePath = self::realpath($file->getPathname());
1589
+ if ($filePath === false) {
1590
+ continue;
1591
+ }
1592
+
1593
+ if (is_dir($filePath) === true) {
1594
+ continue;
1595
+ }
1596
+
1597
+ if ($this->shouldProcessFile($file->getPathname(), $path) === false) {
1598
+ continue;
1599
+ }
1600
+
1601
+ $files[] = $file->getPathname();
1602
+ }//end foreach
1603
+ } else {
1604
+ if ($this->shouldIgnoreFile($path, dirname($path)) === true) {
1605
+ continue;
1606
+ }
1607
+
1608
+ $files[] = $path;
1609
+ }//end if
1610
+ }//end foreach
1611
+
1612
+ return $files;
1613
+
1614
+ }//end getFilesToProcess()
1615
+
1616
+
1617
+ /**
1618
+ * Checks filtering rules to see if a file should be checked.
1619
+ *
1620
+ * Checks both file extension filters and path ignore filters.
1621
+ *
1622
+ * @param string $path The path to the file being checked.
1623
+ * @param string $basedir The directory to use for relative path checks.
1624
+ *
1625
+ * @return bool
1626
+ */
1627
+ public function shouldProcessFile($path, $basedir)
1628
+ {
1629
+ // Check that the file's extension is one we are checking.
1630
+ // We are strict about checking the extension and we don't
1631
+ // let files through with no extension or that start with a dot.
1632
+ $fileName = basename($path);
1633
+ $fileParts = explode('.', $fileName);
1634
+ if ($fileParts[0] === $fileName || $fileParts[0] === '') {
1635
+ return false;
1636
+ }
1637
+
1638
+ // Checking multi-part file extensions, so need to create a
1639
+ // complete extension list and make sure one is allowed.
1640
+ $extensions = array();
1641
+ array_shift($fileParts);
1642
+ foreach ($fileParts as $part) {
1643
+ $extensions[implode('.', $fileParts)] = 1;
1644
+ array_shift($fileParts);
1645
+ }
1646
+
1647
+ $matches = array_intersect_key($extensions, $this->allowedFileExtensions);
1648
+ if (empty($matches) === true) {
1649
+ return false;
1650
+ }
1651
+
1652
+ // If the file's path matches one of our ignore patterns, skip it.
1653
+ if ($this->shouldIgnoreFile($path, $basedir) === true) {
1654
+ return false;
1655
+ }
1656
+
1657
+ return true;
1658
+
1659
+ }//end shouldProcessFile()
1660
+
1661
+
1662
+ /**
1663
+ * Checks filtering rules to see if a file should be ignored.
1664
+ *
1665
+ * @param string $path The path to the file being checked.
1666
+ * @param string $basedir The directory to use for relative path checks.
1667
+ *
1668
+ * @return bool
1669
+ */
1670
+ public function shouldIgnoreFile($path, $basedir)
1671
+ {
1672
+ $relativePath = $path;
1673
+ if (strpos($path, $basedir) === 0) {
1674
+ // The +1 cuts off the directory separator as well.
1675
+ $relativePath = substr($path, (strlen($basedir) + 1));
1676
+ }
1677
+
1678
+ foreach ($this->ignorePatterns as $pattern => $type) {
1679
+ if (is_array($type) === true) {
1680
+ // A sniff specific ignore pattern.
1681
+ continue;
1682
+ }
1683
+
1684
+ // Maintains backwards compatibility in case the ignore pattern does
1685
+ // not have a relative/absolute value.
1686
+ if (is_int($pattern) === true) {
1687
+ $pattern = $type;
1688
+ $type = 'absolute';
1689
+ }
1690
+
1691
+ $replacements = array(
1692
+ '\\,' => ',',
1693
+ '*' => '.*',
1694
+ );
1695
+
1696
+ // We assume a / directory separator, as do the exclude rules
1697
+ // most developers write, so we need a special case for any system
1698
+ // that is different.
1699
+ if (DIRECTORY_SEPARATOR === '\\') {
1700
+ $replacements['/'] = '\\\\';
1701
+ }
1702
+
1703
+ $pattern = strtr($pattern, $replacements);
1704
+
1705
+ if ($type === 'relative') {
1706
+ $testPath = $relativePath;
1707
+ } else {
1708
+ $testPath = $path;
1709
+ }
1710
+
1711
+ $pattern = '`'.$pattern.'`i';
1712
+ if (preg_match($pattern, $testPath) === 1) {
1713
+ return true;
1714
+ }
1715
+ }//end foreach
1716
+
1717
+ return false;
1718
+
1719
+ }//end shouldIgnoreFile()
1720
+
1721
+
1722
+ /**
1723
+ * Run the code sniffs over a single given file.
1724
+ *
1725
+ * Processes the file and runs the PHP_CodeSniffer sniffs to verify that it
1726
+ * conforms with the standard. Returns the processed file object, or NULL
1727
+ * if no file was processed due to error.
1728
+ *
1729
+ * @param string $file The file to process.
1730
+ * @param string $contents The contents to parse. If NULL, the content
1731
+ * is taken from the file system.
1732
+ *
1733
+ * @return PHP_CodeSniffer_File
1734
+ * @throws PHP_CodeSniffer_Exception If the file could not be processed.
1735
+ * @see _processFile()
1736
+ */
1737
+ public function processFile($file, $contents=null)
1738
+ {
1739
+ if ($contents === null && file_exists($file) === false) {
1740
+ throw new PHP_CodeSniffer_Exception("Source file $file does not exist");
1741
+ }
1742
+
1743
+ $filePath = self::realpath($file);
1744
+ if ($filePath === false) {
1745
+ $filePath = $file;
1746
+ }
1747
+
1748
+ // Before we go and spend time tokenizing this file, just check
1749
+ // to see if there is a tag up top to indicate that the whole
1750
+ // file should be ignored. It must be on one of the first two lines.
1751
+ $firstContent = $contents;
1752
+ if ($contents === null && is_readable($filePath) === true) {
1753
+ $handle = fopen($filePath, 'r');
1754
+ stream_set_blocking($handle, true);
1755
+ if ($handle !== false) {
1756
+ $firstContent = fgets($handle);
1757
+ $firstContent .= fgets($handle);
1758
+ fclose($handle);
1759
+
1760
+ if (strpos($firstContent, '@codingStandardsIgnoreFile') !== false) {
1761
+ // We are ignoring the whole file.
1762
+ if (PHP_CODESNIFFER_VERBOSITY > 0) {
1763
+ echo 'Ignoring '.basename($filePath).PHP_EOL;
1764
+ }
1765
+
1766
+ return null;
1767
+ }
1768
+ }
1769
+ }//end if
1770
+
1771
+ try {
1772
+ $phpcsFile = $this->_processFile($file, $contents);
1773
+ } catch (Exception $e) {
1774
+ $trace = $e->getTrace();
1775
+
1776
+ $filename = $trace[0]['args'][0];
1777
+ if (is_object($filename) === true
1778
+ && get_class($filename) === 'PHP_CodeSniffer_File'
1779
+ ) {
1780
+ $filename = $filename->getFilename();
1781
+ } else if (is_numeric($filename) === true) {
1782
+ // See if we can find the PHP_CodeSniffer_File object.
1783
+ foreach ($trace as $data) {
1784
+ if (isset($data['args'][0]) === true
1785
+ && ($data['args'][0] instanceof PHP_CodeSniffer_File) === true
1786
+ ) {
1787
+ $filename = $data['args'][0]->getFilename();
1788
+ }
1789
+ }
1790
+ } else if (is_string($filename) === false) {
1791
+ $filename = (string) $filename;
1792
+ }
1793
+
1794
+ $errorMessage = '"'.$e->getMessage().'" at '.$e->getFile().':'.$e->getLine();
1795
+ $error = "An error occurred during processing; checking has been aborted. The error message was: $errorMessage";
1796
+
1797
+ $phpcsFile = new PHP_CodeSniffer_File(
1798
+ $filename,
1799
+ $this->_tokenListeners,
1800
+ $this->ruleset,
1801
+ $this
1802
+ );
1803
+
1804
+ $phpcsFile->addError($error, null, 'Internal.Exception');
1805
+ }//end try
1806
+
1807
+ $cliValues = $this->cli->getCommandLineValues();
1808
+
1809
+ if (PHP_CODESNIFFER_INTERACTIVE === false) {
1810
+ // Cache the report data for this file so we can unset it to save memory.
1811
+ $this->reporting->cacheFileReport($phpcsFile, $cliValues);
1812
+ $phpcsFile->cleanUp();
1813
+ return $phpcsFile;
1814
+ }
1815
+
1816
+ /*
1817
+ Running interactively.
1818
+ Print the error report for the current file and then wait for user input.
1819
+ */
1820
+
1821
+ // Get current violations and then clear the list to make sure
1822
+ // we only print violations for a single file each time.
1823
+ $numErrors = null;
1824
+ while ($numErrors !== 0) {
1825
+ $numErrors = ($phpcsFile->getErrorCount() + $phpcsFile->getWarningCount());
1826
+ if ($numErrors === 0) {
1827
+ continue;
1828
+ }
1829
+
1830
+ $reportClass = $this->reporting->factory('full');
1831
+ $reportData = $this->reporting->prepareFileReport($phpcsFile);
1832
+ $reportClass->generateFileReport($reportData, $phpcsFile, $cliValues['showSources'], $cliValues['reportWidth']);
1833
+
1834
+ echo '<ENTER> to recheck, [s] to skip or [q] to quit : ';
1835
+ $input = fgets(STDIN);
1836
+ $input = trim($input);
1837
+
1838
+ switch ($input) {
1839
+ case 's':
1840
+ break(2);
1841
+ case 'q':
1842
+ exit(0);
1843
+ break;
1844
+ default:
1845
+ // Repopulate the sniffs because some of them save their state
1846
+ // and only clear it when the file changes, but we are rechecking
1847
+ // the same file.
1848
+ $this->populateTokenListeners();
1849
+ $phpcsFile = $this->_processFile($file, $contents);
1850
+ break;
1851
+ }
1852
+ }//end while
1853
+
1854
+ return $phpcsFile;
1855
+
1856
+ }//end processFile()
1857
+
1858
+
1859
+ /**
1860
+ * Process the sniffs for a single file.
1861
+ *
1862
+ * Does raw processing only. No interactive support or error checking.
1863
+ *
1864
+ * @param string $file The file to process.
1865
+ * @param string $contents The contents to parse. If NULL, the content
1866
+ * is taken from the file system.
1867
+ *
1868
+ * @return PHP_CodeSniffer_File
1869
+ * @see processFile()
1870
+ */
1871
+ private function _processFile($file, $contents)
1872
+ {
1873
+ $stdin = false;
1874
+ $cliValues = $this->cli->getCommandLineValues();
1875
+ if (empty($cliValues['files']) === true) {
1876
+ $stdin = true;
1877
+ }
1878
+
1879
+ if (PHP_CODESNIFFER_VERBOSITY > 0 || (PHP_CODESNIFFER_CBF === true && $stdin === false)) {
1880
+ $startTime = microtime(true);
1881
+ echo 'Processing '.basename($file).' ';
1882
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1883
+ echo PHP_EOL;
1884
+ }
1885
+ }
1886
+
1887
+ $phpcsFile = new PHP_CodeSniffer_File(
1888
+ $file,
1889
+ $this->_tokenListeners,
1890
+ $this->ruleset,
1891
+ $this
1892
+ );
1893
+
1894
+ $phpcsFile->start($contents);
1895
+
1896
+ if (PHP_CODESNIFFER_VERBOSITY > 0 || (PHP_CODESNIFFER_CBF === true && $stdin === false)) {
1897
+ $timeTaken = ((microtime(true) - $startTime) * 1000);
1898
+ if ($timeTaken < 1000) {
1899
+ $timeTaken = round($timeTaken);
1900
+ echo "DONE in {$timeTaken}ms";
1901
+ } else {
1902
+ $timeTaken = round(($timeTaken / 1000), 2);
1903
+ echo "DONE in $timeTaken secs";
1904
+ }
1905
+
1906
+ if (PHP_CODESNIFFER_CBF === true) {
1907
+ $errors = $phpcsFile->getFixableCount();
1908
+ echo " ($errors fixable violations)".PHP_EOL;
1909
+ } else {
1910
+ $errors = $phpcsFile->getErrorCount();
1911
+ $warnings = $phpcsFile->getWarningCount();
1912
+ echo " ($errors errors, $warnings warnings)".PHP_EOL;
1913
+ }
1914
+ }
1915
+
1916
+ return $phpcsFile;
1917
+
1918
+ }//end _processFile()
1919
+
1920
+
1921
+ /**
1922
+ * Generates documentation for a coding standard.
1923
+ *
1924
+ * @param string $standard The standard to generate docs for
1925
+ * @param array $sniffs A list of sniffs to limit the docs to.
1926
+ * @param string $generator The name of the generator class to use.
1927
+ *
1928
+ * @return void
1929
+ */
1930
+ public function generateDocs($standard, array $sniffs=array(), $generator='Text')
1931
+ {
1932
+ if (class_exists('PHP_CodeSniffer_DocGenerators_'.$generator, true) === false) {
1933
+ throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_DocGenerators_'.$generator.' not found');
1934
+ }
1935
+
1936
+ $class = "PHP_CodeSniffer_DocGenerators_$generator";
1937
+ $generator = new $class($standard, $sniffs);
1938
+
1939
+ $generator->generate();
1940
+
1941
+ }//end generateDocs()
1942
+
1943
+
1944
+ /**
1945
+ * Gets the array of PHP_CodeSniffer_Sniff's.
1946
+ *
1947
+ * @return PHP_CodeSniffer_Sniff[]
1948
+ */
1949
+ public function getSniffs()
1950
+ {
1951
+ return $this->listeners;
1952
+
1953
+ }//end getSniffs()
1954
+
1955
+
1956
+ /**
1957
+ * Gets the array of PHP_CodeSniffer_Sniff's indexed by token type.
1958
+ *
1959
+ * @return array
1960
+ */
1961
+ public function getTokenSniffs()
1962
+ {
1963
+ return $this->_tokenListeners;
1964
+
1965
+ }//end getTokenSniffs()
1966
+
1967
+
1968
+ /**
1969
+ * Returns true if the specified string is in the camel caps format.
1970
+ *
1971
+ * @param string $string The string the verify.
1972
+ * @param boolean $classFormat If true, check to see if the string is in the
1973
+ * class format. Class format strings must start
1974
+ * with a capital letter and contain no
1975
+ * underscores.
1976
+ * @param boolean $public If true, the first character in the string
1977
+ * must be an a-z character. If false, the
1978
+ * character must be an underscore. This
1979
+ * argument is only applicable if $classFormat
1980
+ * is false.
1981
+ * @param boolean $strict If true, the string must not have two capital
1982
+ * letters next to each other. If false, a
1983
+ * relaxed camel caps policy is used to allow
1984
+ * for acronyms.
1985
+ *
1986
+ * @return boolean
1987
+ */
1988
+ public static function isCamelCaps(
1989
+ $string,
1990
+ $classFormat=false,
1991
+ $public=true,
1992
+ $strict=true
1993
+ ) {
1994
+ // Check the first character first.
1995
+ if ($classFormat === false) {
1996
+ $legalFirstChar = '';
1997
+ if ($public === false) {
1998
+ $legalFirstChar = '[_]';
1999
+ }
2000
+
2001
+ if ($strict === false) {
2002
+ // Can either start with a lowercase letter, or multiple uppercase
2003
+ // in a row, representing an acronym.
2004
+ $legalFirstChar .= '([A-Z]{2,}|[a-z])';
2005
+ } else {
2006
+ $legalFirstChar .= '[a-z]';
2007
+ }
2008
+ } else {
2009
+ $legalFirstChar = '[A-Z]';
2010
+ }
2011
+
2012
+ if (preg_match("/^$legalFirstChar/", $string) === 0) {
2013
+ return false;
2014
+ }
2015
+
2016
+ // Check that the name only contains legal characters.
2017
+ $legalChars = 'a-zA-Z0-9';
2018
+ if (preg_match("|[^$legalChars]|", substr($string, 1)) > 0) {
2019
+ return false;
2020
+ }
2021
+
2022
+ if ($strict === true) {
2023
+ // Check that there are not two capital letters next to each other.
2024
+ $length = strlen($string);
2025
+ $lastCharWasCaps = $classFormat;
2026
+
2027
+ for ($i = 1; $i < $length; $i++) {
2028
+ $ascii = ord($string{$i});
2029
+ if ($ascii >= 48 && $ascii <= 57) {
2030
+ // The character is a number, so it cant be a capital.
2031
+ $isCaps = false;
2032
+ } else {
2033
+ if (strtoupper($string{$i}) === $string{$i}) {
2034
+ $isCaps = true;
2035
+ } else {
2036
+ $isCaps = false;
2037
+ }
2038
+ }
2039
+
2040
+ if ($isCaps === true && $lastCharWasCaps === true) {
2041
+ return false;
2042
+ }
2043
+
2044
+ $lastCharWasCaps = $isCaps;
2045
+ }
2046
+ }//end if
2047
+
2048
+ return true;
2049
+
2050
+ }//end isCamelCaps()
2051
+
2052
+
2053
+ /**
2054
+ * Returns true if the specified string is in the underscore caps format.
2055
+ *
2056
+ * @param string $string The string to verify.
2057
+ *
2058
+ * @return boolean
2059
+ */
2060
+ public static function isUnderscoreName($string)
2061
+ {
2062
+ // If there are space in the name, it can't be valid.
2063
+ if (strpos($string, ' ') !== false) {
2064
+ return false;
2065
+ }
2066
+
2067
+ $validName = true;
2068
+ $nameBits = explode('_', $string);
2069
+
2070
+ if (preg_match('|^[A-Z]|', $string) === 0) {
2071
+ // Name does not begin with a capital letter.
2072
+ $validName = false;
2073
+ } else {
2074
+ foreach ($nameBits as $bit) {
2075
+ if ($bit === '') {
2076
+ continue;
2077
+ }
2078
+
2079
+ if ($bit{0} !== strtoupper($bit{0})) {
2080
+ $validName = false;
2081
+ break;
2082
+ }
2083
+ }
2084
+ }
2085
+
2086
+ return $validName;
2087
+
2088
+ }//end isUnderscoreName()
2089
+
2090
+
2091
+ /**
2092
+ * Returns a valid variable type for param/var tag.
2093
+ *
2094
+ * If type is not one of the standard type, it must be a custom type.
2095
+ * Returns the correct type name suggestion if type name is invalid.
2096
+ *
2097
+ * @param string $varType The variable type to process.
2098
+ *
2099
+ * @return string
2100
+ */
2101
+ public static function suggestType($varType)
2102
+ {
2103
+ if ($varType === '') {
2104
+ return '';
2105
+ }
2106
+
2107
+ if (in_array($varType, self::$allowedTypes) === true) {
2108
+ return $varType;
2109
+ } else {
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
+
2127
+ if (strpos($lowerVarType, 'array(') !== false) {
2128
+ // Valid array declaration:
2129
+ // array, array(type), array(type1 => type2).
2130
+ $matches = array();
2131
+ $pattern = '/^array\(\s*([^\s^=^>]*)(\s*=>\s*(.*))?\s*\)/i';
2132
+ if (preg_match($pattern, $varType, $matches) !== 0) {
2133
+ $type1 = '';
2134
+ if (isset($matches[1]) === true) {
2135
+ $type1 = $matches[1];
2136
+ }
2137
+
2138
+ $type2 = '';
2139
+ if (isset($matches[3]) === true) {
2140
+ $type2 = $matches[3];
2141
+ }
2142
+
2143
+ $type1 = self::suggestType($type1);
2144
+ $type2 = self::suggestType($type2);
2145
+ if ($type2 !== '') {
2146
+ $type2 = ' => '.$type2;
2147
+ }
2148
+
2149
+ return "array($type1$type2)";
2150
+ } else {
2151
+ return 'array';
2152
+ }//end if
2153
+ } else if (in_array($lowerVarType, self::$allowedTypes) === true) {
2154
+ // A valid type, but not lower cased.
2155
+ return $lowerVarType;
2156
+ } else {
2157
+ // Must be a custom type name.
2158
+ return $varType;
2159
+ }//end if
2160
+ }//end if
2161
+
2162
+ }//end suggestType()
2163
+
2164
+
2165
+ /**
2166
+ * Prepares token content for output to screen.
2167
+ *
2168
+ * Replaces invisible characters so they are visible. On non-Windows
2169
+ * OSes it will also colour the invisible characters.
2170
+ *
2171
+ * @param string $content The content to prepare.
2172
+ *
2173
+ * @return string
2174
+ */
2175
+ public static function prepareForOutput($content)
2176
+ {
2177
+ if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
2178
+ $content = str_replace("\r", '\r', $content);
2179
+ $content = str_replace("\n", '\n', $content);
2180
+ $content = str_replace("\t", '\t', $content);
2181
+ } else {
2182
+ $content = str_replace("\r", "\033[30;1m\\r\033[0m", $content);
2183
+ $content = str_replace("\n", "\033[30;1m\\n\033[0m", $content);
2184
+ $content = str_replace("\t", "\033[30;1m\\t\033[0m", $content);
2185
+ $content = str_replace(' ', "\033[30;1m·\033[0m", $content);
2186
+ }
2187
+
2188
+ return $content;
2189
+
2190
+ }//end prepareForOutput()
2191
+
2192
+
2193
+ /**
2194
+ * Get a list paths where standards are installed.
2195
+ *
2196
+ * @return array
2197
+ */
2198
+ public static function getInstalledStandardPaths()
2199
+ {
2200
+ $installedPaths = array(dirname(__FILE__).DIRECTORY_SEPARATOR.'CodeSniffer'.DIRECTORY_SEPARATOR.'Standards');
2201
+ $configPaths = PHP_CodeSniffer::getConfigData('installed_paths');
2202
+ if ($configPaths !== null) {
2203
+ $installedPaths = array_merge($installedPaths, explode(',', $configPaths));
2204
+ }
2205
+
2206
+ $resolvedInstalledPaths = array();
2207
+ foreach ($installedPaths as $installedPath) {
2208
+ if (substr($installedPath, 0, 1) === '.') {
2209
+ $installedPath = dirname(__FILE__).DIRECTORY_SEPARATOR.$installedPath;
2210
+ }
2211
+
2212
+ $resolvedInstalledPaths[] = $installedPath;
2213
+ }
2214
+
2215
+ return $resolvedInstalledPaths;
2216
+
2217
+ }//end getInstalledStandardPaths()
2218
+
2219
+
2220
+ /**
2221
+ * Get a list of all coding standards installed.
2222
+ *
2223
+ * Coding standards are directories located in the
2224
+ * CodeSniffer/Standards directory. Valid coding standards
2225
+ * include a Sniffs subdirectory.
2226
+ *
2227
+ * @param boolean $includeGeneric If true, the special "Generic"
2228
+ * coding standard will be included
2229
+ * if installed.
2230
+ * @param string $standardsDir A specific directory to look for standards
2231
+ * in. If not specified, PHP_CodeSniffer will
2232
+ * look in its default locations.
2233
+ *
2234
+ * @return array
2235
+ * @see isInstalledStandard()
2236
+ */
2237
+ public static function getInstalledStandards(
2238
+ $includeGeneric=false,
2239
+ $standardsDir=''
2240
+ ) {
2241
+ $installedStandards = array();
2242
+
2243
+ if ($standardsDir === '') {
2244
+ $installedPaths = self::getInstalledStandardPaths();
2245
+ } else {
2246
+ $installedPaths = array($standardsDir);
2247
+ }
2248
+
2249
+ foreach ($installedPaths as $standardsDir) {
2250
+ $di = new DirectoryIterator($standardsDir);
2251
+ foreach ($di as $file) {
2252
+ if ($file->isDir() === true && $file->isDot() === false) {
2253
+ $filename = $file->getFilename();
2254
+
2255
+ // Ignore the special "Generic" standard.
2256
+ if ($includeGeneric === false && $filename === 'Generic') {
2257
+ continue;
2258
+ }
2259
+
2260
+ // Valid coding standard dirs include a ruleset.
2261
+ $csFile = $file->getPathname().'/ruleset.xml';
2262
+ if (is_file($csFile) === true) {
2263
+ $installedStandards[] = $filename;
2264
+ }
2265
+ }
2266
+ }
2267
+ }//end foreach
2268
+
2269
+ return $installedStandards;
2270
+
2271
+ }//end getInstalledStandards()
2272
+
2273
+
2274
+ /**
2275
+ * Determine if a standard is installed.
2276
+ *
2277
+ * Coding standards are directories located in the
2278
+ * CodeSniffer/Standards directory. Valid coding standards
2279
+ * include a ruleset.xml file.
2280
+ *
2281
+ * @param string $standard The name of the coding standard.
2282
+ *
2283
+ * @return boolean
2284
+ * @see getInstalledStandards()
2285
+ */
2286
+ public static function isInstalledStandard($standard)
2287
+ {
2288
+ $path = self::getInstalledStandardPath($standard);
2289
+ if ($path !== null && strpos($path, 'ruleset.xml') !== false) {
2290
+ return true;
2291
+ } else {
2292
+ // This could be a custom standard, installed outside our
2293
+ // standards directory.
2294
+ $standard = self::realPath($standard);
2295
+
2296
+ // Might be an actual ruleset file itself.
2297
+ // If it has an XML extension, let's at least try it.
2298
+ if (is_file($standard) === true
2299
+ && (substr(strtolower($standard), -4) === '.xml'
2300
+ || substr(strtolower($standard), -9) === '.xml.dist')
2301
+ ) {
2302
+ return true;
2303
+ }
2304
+
2305
+ // If it is a directory with a ruleset.xml file in it,
2306
+ // it is a standard.
2307
+ $ruleset = rtrim($standard, ' /\\').DIRECTORY_SEPARATOR.'ruleset.xml';
2308
+ if (is_file($ruleset) === true) {
2309
+ return true;
2310
+ }
2311
+ }//end if
2312
+
2313
+ return false;
2314
+
2315
+ }//end isInstalledStandard()
2316
+
2317
+
2318
+ /**
2319
+ * Return the path of an installed coding standard.
2320
+ *
2321
+ * Coding standards are directories located in the
2322
+ * CodeSniffer/Standards directory. Valid coding standards
2323
+ * include a ruleset.xml file.
2324
+ *
2325
+ * @param string $standard The name of the coding standard.
2326
+ *
2327
+ * @return string|null
2328
+ */
2329
+ public static function getInstalledStandardPath($standard)
2330
+ {
2331
+ $installedPaths = self::getInstalledStandardPaths();
2332
+ foreach ($installedPaths as $installedPath) {
2333
+ $standardPath = $installedPath.DIRECTORY_SEPARATOR.$standard;
2334
+ $path = self::realpath($standardPath.DIRECTORY_SEPARATOR.'ruleset.xml');
2335
+ if (is_file($path) === true) {
2336
+ return $path;
2337
+ } else if (self::isPharFile($standardPath) === true) {
2338
+ $path = self::realpath($standardPath);
2339
+ if ($path !== false) {
2340
+ return $path;
2341
+ }
2342
+ }
2343
+ }
2344
+
2345
+ return null;
2346
+
2347
+ }//end getInstalledStandardPath()
2348
+
2349
+
2350
+ /**
2351
+ * Get a single config value.
2352
+ *
2353
+ * Config data is stored in the data dir, in a file called
2354
+ * CodeSniffer.conf. It is a simple PHP array.
2355
+ *
2356
+ * @param string $key The name of the config value.
2357
+ *
2358
+ * @return string|null
2359
+ * @see setConfigData()
2360
+ * @see getAllConfigData()
2361
+ */
2362
+ public static function getConfigData($key)
2363
+ {
2364
+ $phpCodeSnifferConfig = self::getAllConfigData();
2365
+
2366
+ if ($phpCodeSnifferConfig === null) {
2367
+ return null;
2368
+ }
2369
+
2370
+ if (isset($phpCodeSnifferConfig[$key]) === false) {
2371
+ return null;
2372
+ }
2373
+
2374
+ return $phpCodeSnifferConfig[$key];
2375
+
2376
+ }//end getConfigData()
2377
+
2378
+
2379
+ /**
2380
+ * Set a single config value.
2381
+ *
2382
+ * Config data is stored in the data dir, in a file called
2383
+ * CodeSniffer.conf. It is a simple PHP array.
2384
+ *
2385
+ * @param string $key The name of the config value.
2386
+ * @param string|null $value The value to set. If null, the config
2387
+ * entry is deleted, reverting it to the
2388
+ * default value.
2389
+ * @param boolean $temp Set this config data temporarily for this
2390
+ * script run. This will not write the config
2391
+ * data to the config file.
2392
+ *
2393
+ * @return boolean
2394
+ * @see getConfigData()
2395
+ * @throws PHP_CodeSniffer_Exception If the config file can not be written.
2396
+ */
2397
+ public static function setConfigData($key, $value, $temp=false)
2398
+ {
2399
+ if ($temp === false) {
2400
+ $path = '';
2401
+ if (is_callable('Phar::running') === true) {
2402
+ $path = Phar::running(false);
2403
+ }
2404
+
2405
+ if ($path !== '') {
2406
+ $configFile = dirname($path).'/CodeSniffer.conf';
2407
+ } else {
2408
+ $configFile = dirname(__FILE__).'/CodeSniffer.conf';
2409
+ if (is_file($configFile) === false
2410
+ && strpos('@data_dir@', '@data_dir') === false
2411
+ ) {
2412
+ // If data_dir was replaced, this is a PEAR install and we can
2413
+ // use the PEAR data dir to store the conf file.
2414
+ $configFile = '@data_dir@/PHP_CodeSniffer/CodeSniffer.conf';
2415
+ }
2416
+ }
2417
+
2418
+ if (is_file($configFile) === true
2419
+ && is_writable($configFile) === false
2420
+ ) {
2421
+ $error = 'Config file '.$configFile.' is not writable';
2422
+ throw new PHP_CodeSniffer_Exception($error);
2423
+ }
2424
+ }//end if
2425
+
2426
+ $phpCodeSnifferConfig = self::getAllConfigData();
2427
+
2428
+ if ($value === null) {
2429
+ if (isset($phpCodeSnifferConfig[$key]) === true) {
2430
+ unset($phpCodeSnifferConfig[$key]);
2431
+ }
2432
+ } else {
2433
+ $phpCodeSnifferConfig[$key] = $value;
2434
+ }
2435
+
2436
+ if ($temp === false) {
2437
+ $output = '<'.'?php'."\n".' $phpCodeSnifferConfig = ';
2438
+ $output .= var_export($phpCodeSnifferConfig, true);
2439
+ $output .= "\n?".'>';
2440
+
2441
+ if (file_put_contents($configFile, $output) === false) {
2442
+ return false;
2443
+ }
2444
+ }
2445
+
2446
+ $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA'] = $phpCodeSnifferConfig;
2447
+
2448
+ return true;
2449
+
2450
+ }//end setConfigData()
2451
+
2452
+
2453
+ /**
2454
+ * Get all config data in an array.
2455
+ *
2456
+ * @return array<string, string>
2457
+ * @see getConfigData()
2458
+ */
2459
+ public static function getAllConfigData()
2460
+ {
2461
+ if (isset($GLOBALS['PHP_CODESNIFFER_CONFIG_DATA']) === true) {
2462
+ return $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA'];
2463
+ }
2464
+
2465
+ $path = '';
2466
+ if (is_callable('Phar::running') === true) {
2467
+ $path = Phar::running(false);
2468
+ }
2469
+
2470
+ if ($path !== '') {
2471
+ $configFile = dirname($path).'/CodeSniffer.conf';
2472
+ } else {
2473
+ $configFile = dirname(__FILE__).'/CodeSniffer.conf';
2474
+ if (is_file($configFile) === false) {
2475
+ $configFile = '@data_dir@/PHP_CodeSniffer/CodeSniffer.conf';
2476
+ }
2477
+ }
2478
+
2479
+ if (is_file($configFile) === false) {
2480
+ $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA'] = array();
2481
+ return array();
2482
+ }
2483
+
2484
+ include $configFile;
2485
+ $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA'] = $phpCodeSnifferConfig;
2486
+ return $GLOBALS['PHP_CODESNIFFER_CONFIG_DATA'];
2487
+
2488
+ }//end getAllConfigData()
2489
+
2490
+
2491
+ /**
2492
+ * Return TRUE, if the path is a phar file.
2493
+ *
2494
+ * @param string $path The path to use.
2495
+ *
2496
+ * @return mixed
2497
+ */
2498
+ public static function isPharFile($path)
2499
+ {
2500
+ if (strpos($path, 'phar://') === 0) {
2501
+ return true;
2502
+ }
2503
+
2504
+ return false;
2505
+
2506
+ }//end isPharFile()
2507
+
2508
+
2509
+ /**
2510
+ * CodeSniffer alternative for realpath.
2511
+ *
2512
+ * Allows for phar support.
2513
+ *
2514
+ * @param string $path The path to use.
2515
+ *
2516
+ * @return mixed
2517
+ */
2518
+ public static function realpath($path)
2519
+ {
2520
+ // Support the path replacement of ~ with the user's home directory.
2521
+ if (substr($path, 0, 2) === '~/') {
2522
+ $homeDir = getenv('HOME');
2523
+ if ($homeDir !== false) {
2524
+ $path = $homeDir.substr($path, 1);
2525
+ }
2526
+ }
2527
+
2528
+ // No extra work needed if this is not a phar file.
2529
+ if (self::isPharFile($path) === false) {
2530
+ return realpath($path);
2531
+ }
2532
+
2533
+ // Before trying to break down the file path,
2534
+ // check if it exists first because it will mostly not
2535
+ // change after running the below code.
2536
+ if (file_exists($path) === true) {
2537
+ return $path;
2538
+ }
2539
+
2540
+ $phar = Phar::running(false);
2541
+ $extra = str_replace('phar://'.$phar, '', $path);
2542
+ $path = realpath($phar);
2543
+ if ($path === false) {
2544
+ return false;
2545
+ }
2546
+
2547
+ $path = 'phar://'.$path.$extra;
2548
+ if (file_exists($path) === true) {
2549
+ return $path;
2550
+ }
2551
+
2552
+ return false;
2553
+
2554
+ }//end realpath()
2555
+
2556
+
2557
+ /**
2558
+ * CodeSniffer alternative for chdir().
2559
+ *
2560
+ * Allows for phar support.
2561
+ *
2562
+ * @param string $path The path to use.
2563
+ *
2564
+ * @return void
2565
+ */
2566
+ public static function chdir($path)
2567
+ {
2568
+ if (self::isPharFile($path) === true) {
2569
+ $phar = Phar::running(false);
2570
+ chdir(dirname($phar));
2571
+ } else {
2572
+ chdir($path);
2573
+ }
2574
+
2575
+ }//end chdir()
2576
+
2577
+
2578
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/CLI.php ADDED
@@ -0,0 +1,1444 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * A class to process command line phpcs scripts.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
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) {
29
+ include_once $a;
30
+ }
31
+ }
32
+
33
+ if (file_exists($a = dirname(__FILE__).'/../CodeSniffer.php') === true) {
34
+ // Running from a git clone.
35
+ include_once $a;
36
+ } else {
37
+ // PEAR installed.
38
+ include_once 'PHP/CodeSniffer.php';
39
+ }
40
+
41
+ /**
42
+ * A class to process command line phpcs scripts.
43
+ *
44
+ * @category PHP
45
+ * @package PHP_CodeSniffer
46
+ * @author Greg Sherwood <gsherwood@squiz.net>
47
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
48
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
49
+ * @version Release: @package_version@
50
+ * @link http://pear.php.net/package/PHP_CodeSniffer
51
+ */
52
+ class PHP_CodeSniffer_CLI
53
+ {
54
+
55
+ /**
56
+ * An array of all values specified on the command line.
57
+ *
58
+ * @var array
59
+ */
60
+ protected $values = array();
61
+
62
+ /**
63
+ * The minimum severity level errors must have to be displayed.
64
+ *
65
+ * @var bool
66
+ */
67
+ public $errorSeverity = 0;
68
+
69
+ /**
70
+ * The minimum severity level warnings must have to be displayed.
71
+ *
72
+ * @var bool
73
+ */
74
+ public $warningSeverity = 0;
75
+
76
+ /**
77
+ * Whether or not to kill the process when an unknown command line arg is found.
78
+ *
79
+ * If FALSE, arguments that are not command line options or file/directory paths
80
+ * will be ignored and execution will continue.
81
+ *
82
+ * @var bool
83
+ */
84
+ public $dieOnUnknownArg = true;
85
+
86
+ /**
87
+ * An array of the current command line arguments we are processing.
88
+ *
89
+ * @var array
90
+ */
91
+ private $_cliArgs = array();
92
+
93
+
94
+ /**
95
+ * Run the PHPCS script.
96
+ *
97
+ * @return array
98
+ */
99
+ public function runphpcs()
100
+ {
101
+ if (defined('PHP_CODESNIFFER_CBF') === false) {
102
+ define('PHP_CODESNIFFER_CBF', false);
103
+ }
104
+
105
+ if (is_file(dirname(__FILE__).'/../CodeSniffer/Reporting.php') === true) {
106
+ include_once dirname(__FILE__).'/../CodeSniffer/Reporting.php';
107
+ } else {
108
+ include_once 'PHP/CodeSniffer/Reporting.php';
109
+ }
110
+
111
+ PHP_CodeSniffer_Reporting::startTiming();
112
+ $this->checkRequirements();
113
+ $numErrors = $this->process();
114
+ if ($numErrors === 0) {
115
+ exit(0);
116
+ } else {
117
+ exit(1);
118
+ }
119
+
120
+ }//end runphpcs()
121
+
122
+
123
+ /**
124
+ * Run the PHPCBF script.
125
+ *
126
+ * @return array
127
+ */
128
+ public function runphpcbf()
129
+ {
130
+ if (defined('PHP_CODESNIFFER_CBF') === false) {
131
+ define('PHP_CODESNIFFER_CBF', true);
132
+ }
133
+
134
+ if (is_file(dirname(__FILE__).'/../CodeSniffer/Reporting.php') === true) {
135
+ include_once dirname(__FILE__).'/../CodeSniffer/Reporting.php';
136
+ } else {
137
+ include_once 'PHP/CodeSniffer/Reporting.php';
138
+ }
139
+
140
+ PHP_CodeSniffer_Reporting::startTiming();
141
+ $this->checkRequirements();
142
+
143
+ $this->dieOnUnknownArg = false;
144
+
145
+ // Override some of the command line settings that might break the fixes.
146
+ $cliValues = $this->getCommandLineValues();
147
+ $cliValues['verbosity'] = 0;
148
+ $cliValues['showProgress'] = false;
149
+ $cliValues['generator'] = '';
150
+ $cliValues['explain'] = false;
151
+ $cliValues['interactive'] = false;
152
+ $cliValues['showSources'] = false;
153
+ $cliValues['reportFile'] = null;
154
+ $cliValues['reports'] = array();
155
+
156
+ $suffix = '';
157
+ if (isset($cliValues['suffix']) === true) {
158
+ $suffix = $cliValues['suffix'];
159
+ }
160
+
161
+ $allowPatch = true;
162
+ if (isset($cliValues['no-patch']) === true || empty($cliValues['files']) === true) {
163
+ // They either asked for this,
164
+ // or they are using STDIN, which can't use diff.
165
+ $allowPatch = false;
166
+ }
167
+
168
+ if ($suffix === '' && $allowPatch === true) {
169
+ // Using the diff/patch tools.
170
+ $diffFile = getcwd().'/phpcbf-fixed.diff';
171
+ $cliValues['reports'] = array('diff' => $diffFile);
172
+ if (file_exists($diffFile) === true) {
173
+ unlink($diffFile);
174
+ }
175
+ } else {
176
+ // Replace the file without the patch command
177
+ // or writing to a file with a new suffix.
178
+ $cliValues['reports'] = array('cbf' => null);
179
+ $cliValues['phpcbf-suffix'] = $suffix;
180
+ }
181
+
182
+ $numErrors = $this->process($cliValues);
183
+
184
+ if ($suffix === '' && $allowPatch === true) {
185
+ if (file_exists($diffFile) === false) {
186
+ // Nothing to fix.
187
+ if ($numErrors === 0) {
188
+ // And no errors reported.
189
+ $exit = 0;
190
+ } else {
191
+ // Errors we can't fix.
192
+ $exit = 2;
193
+ }
194
+ } else {
195
+ if (filesize($diffFile) < 10) {
196
+ // Empty or bad diff file.
197
+ if ($numErrors === 0) {
198
+ // And no errors reported.
199
+ $exit = 0;
200
+ } else {
201
+ // Errors we can't fix.
202
+ $exit = 2;
203
+ }
204
+ } else {
205
+ $cmd = "patch -p0 -ui \"$diffFile\"";
206
+ $output = array();
207
+ $retVal = null;
208
+ exec($cmd, $output, $retVal);
209
+
210
+ if ($retVal === 0) {
211
+ // Everything went well.
212
+ $filesPatched = count($output);
213
+ echo "Patched $filesPatched file";
214
+ if ($filesPatched > 1) {
215
+ echo 's';
216
+ }
217
+
218
+ echo PHP_EOL;
219
+ $exit = 1;
220
+ } else {
221
+ print_r($output);
222
+ echo "Returned: $retVal".PHP_EOL;
223
+ $exit = 3;
224
+ }
225
+ }//end if
226
+
227
+ unlink($diffFile);
228
+ }//end if
229
+ } else {
230
+ // File are being patched manually, so we can't tell
231
+ // how many errors were fixed.
232
+ $exit = 1;
233
+ }//end if
234
+
235
+ if ($exit === 0) {
236
+ echo 'No fixable errors were found'.PHP_EOL;
237
+ } else if ($exit === 2) {
238
+ echo 'PHPCBF could not fix all the errors found'.PHP_EOL;
239
+ }
240
+
241
+ PHP_CodeSniffer_Reporting::printRunTime();
242
+ exit($exit);
243
+
244
+ }//end runphpcbf()
245
+
246
+
247
+ /**
248
+ * Exits if the minimum requirements of PHP_CodSniffer are not met.
249
+ *
250
+ * @return array
251
+ */
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
+ }
259
+
260
+ if (extension_loaded('tokenizer') === false) {
261
+ echo 'ERROR: PHP_CodeSniffer requires the tokenizer extension to be enabled.'.PHP_EOL;
262
+ exit(2);
263
+ }
264
+
265
+ }//end checkRequirements()
266
+
267
+
268
+ /**
269
+ * Get a list of default values for all possible command line arguments.
270
+ *
271
+ * @return array
272
+ */
273
+ public function getDefaults()
274
+ {
275
+ if (defined('PHP_CODESNIFFER_IN_TESTS') === true) {
276
+ return array();
277
+ }
278
+
279
+ // The default values for config settings.
280
+ $defaults['files'] = array();
281
+ $defaults['standard'] = null;
282
+ $defaults['verbosity'] = 0;
283
+ $defaults['interactive'] = false;
284
+ $defaults['colors'] = false;
285
+ $defaults['explain'] = false;
286
+ $defaults['local'] = false;
287
+ $defaults['showSources'] = false;
288
+ $defaults['extensions'] = array();
289
+ $defaults['sniffs'] = array();
290
+ $defaults['exclude'] = array();
291
+ $defaults['ignored'] = array();
292
+ $defaults['reportFile'] = null;
293
+ $defaults['generator'] = '';
294
+ $defaults['reports'] = array();
295
+ $defaults['bootstrap'] = array();
296
+ $defaults['errorSeverity'] = null;
297
+ $defaults['warningSeverity'] = null;
298
+ $defaults['stdin'] = null;
299
+ $defaults['stdinPath'] = '';
300
+
301
+ $reportFormat = PHP_CodeSniffer::getConfigData('report_format');
302
+ if ($reportFormat !== null) {
303
+ $defaults['reports'][$reportFormat] = null;
304
+ }
305
+
306
+ $tabWidth = PHP_CodeSniffer::getConfigData('tab_width');
307
+ if ($tabWidth === null) {
308
+ $defaults['tabWidth'] = 0;
309
+ } else {
310
+ $defaults['tabWidth'] = (int) $tabWidth;
311
+ }
312
+
313
+ $encoding = PHP_CodeSniffer::getConfigData('encoding');
314
+ if ($encoding === null) {
315
+ $defaults['encoding'] = 'iso-8859-1';
316
+ } else {
317
+ $defaults['encoding'] = strtolower($encoding);
318
+ }
319
+
320
+ $severity = PHP_CodeSniffer::getConfigData('severity');
321
+ if ($severity !== null) {
322
+ $defaults['errorSeverity'] = (int) $severity;
323
+ $defaults['warningSeverity'] = (int) $severity;
324
+ }
325
+
326
+ $severity = PHP_CodeSniffer::getConfigData('error_severity');
327
+ if ($severity !== null) {
328
+ $defaults['errorSeverity'] = (int) $severity;
329
+ }
330
+
331
+ $severity = PHP_CodeSniffer::getConfigData('warning_severity');
332
+ if ($severity !== null) {
333
+ $defaults['warningSeverity'] = (int) $severity;
334
+ }
335
+
336
+ $showWarnings = PHP_CodeSniffer::getConfigData('show_warnings');
337
+ if ($showWarnings !== null) {
338
+ $showWarnings = (bool) $showWarnings;
339
+ if ($showWarnings === false) {
340
+ $defaults['warningSeverity'] = 0;
341
+ }
342
+ }
343
+
344
+ $reportWidth = PHP_CodeSniffer::getConfigData('report_width');
345
+ if ($reportWidth !== null) {
346
+ $defaults['reportWidth'] = $this->_validateReportWidth($reportWidth);
347
+ } else {
348
+ // Use function defaults.
349
+ $defaults['reportWidth'] = null;
350
+ }
351
+
352
+ $showProgress = PHP_CodeSniffer::getConfigData('show_progress');
353
+ if ($showProgress === null) {
354
+ $defaults['showProgress'] = false;
355
+ } else {
356
+ $defaults['showProgress'] = (bool) $showProgress;
357
+ }
358
+
359
+ $quiet = PHP_CodeSniffer::getConfigData('quiet');
360
+ if ($quiet === null) {
361
+ $defaults['quiet'] = false;
362
+ } else {
363
+ $defaults['quiet'] = (bool) $quiet;
364
+ }
365
+
366
+ $colors = PHP_CodeSniffer::getConfigData('colors');
367
+ if ($colors === null) {
368
+ $defaults['colors'] = false;
369
+ } else {
370
+ $defaults['colors'] = (bool) $colors;
371
+ }
372
+
373
+ if (PHP_CodeSniffer::isPharFile(dirname(dirname(__FILE__))) === true) {
374
+ // If this is a phar file, check for the standard in the config.
375
+ $standard = PHP_CodeSniffer::getConfigData('standard');
376
+ if ($standard !== null) {
377
+ $defaults['standard'] = $standard;
378
+ }
379
+ }
380
+
381
+ return $defaults;
382
+
383
+ }//end getDefaults()
384
+
385
+
386
+ /**
387
+ * Gets the processed command line values.
388
+ *
389
+ * If the values have not yet been set, the values will be sourced
390
+ * from the command line arguments.
391
+ *
392
+ * @return array
393
+ */
394
+ public function getCommandLineValues()
395
+ {
396
+ if (empty($this->values) === false) {
397
+ return $this->values;
398
+ }
399
+
400
+ $args = $_SERVER['argv'];
401
+ array_shift($args);
402
+
403
+ $this->setCommandLineValues($args);
404
+
405
+ // Check for content on STDIN.
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
+ }
413
+
414
+ stream_set_blocking($handle, true);
415
+ fclose($handle);
416
+ if (trim($fileContents) !== '') {
417
+ $this->values['stdin'] = $fileContents;
418
+ }
419
+ }
420
+
421
+ return $this->values;
422
+
423
+ }//end getCommandLineValues()
424
+
425
+
426
+ /**
427
+ * Set the command line values.
428
+ *
429
+ * @param array $args An array of command line arguments to process.
430
+ *
431
+ * @return void
432
+ */
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
+ }
443
+
444
+ $this->_cliArgs = $args;
445
+ $numArgs = count($args);
446
+
447
+ for ($i = 0; $i < $numArgs; $i++) {
448
+ $arg = $this->_cliArgs[$i];
449
+ if ($arg === '') {
450
+ continue;
451
+ }
452
+
453
+ if ($arg{0} === '-') {
454
+ if ($arg === '-' || $arg === '--') {
455
+ // Empty argument, ignore it.
456
+ continue;
457
+ }
458
+
459
+ if ($arg{1} === '-') {
460
+ $this->processLongArgument(substr($arg, 2), $i);
461
+ } else {
462
+ $switches = str_split($arg);
463
+ foreach ($switches as $switch) {
464
+ if ($switch === '-') {
465
+ continue;
466
+ }
467
+
468
+ $this->processShortArgument($switch, $i);
469
+ }
470
+ }
471
+ } else {
472
+ $this->processUnknownArgument($arg, $i);
473
+ }//end if
474
+ }//end for
475
+
476
+ }//end setCommandLineValues()
477
+
478
+
479
+ /**
480
+ * Processes a short (-e) command line argument.
481
+ *
482
+ * @param string $arg The command line argument.
483
+ * @param int $pos The position of the argument on the command line.
484
+ *
485
+ * @return void
486
+ */
487
+ public function processShortArgument($arg, $pos)
488
+ {
489
+ switch ($arg) {
490
+ case 'h':
491
+ case '?':
492
+ $this->printUsage();
493
+ exit(0);
494
+ case 'i' :
495
+ $this->printInstalledStandards();
496
+ exit(0);
497
+ case 'v' :
498
+ if ($this->values['quiet'] === true) {
499
+ // Ignore when quiet mode is enabled.
500
+ break;
501
+ }
502
+
503
+ if (isset($this->values['verbosity']) === false) {
504
+ $this->values['verbosity'] = 1;
505
+ } else {
506
+ $this->values['verbosity']++;
507
+ }
508
+ break;
509
+ case 'l' :
510
+ $this->values['local'] = true;
511
+ break;
512
+ case 's' :
513
+ $this->values['showSources'] = true;
514
+ break;
515
+ case 'a' :
516
+ $this->values['interactive'] = true;
517
+ break;
518
+ case 'e':
519
+ $this->values['explain'] = true;
520
+ break;
521
+ case 'p' :
522
+ if ($this->values['quiet'] === true) {
523
+ // Ignore when quiet mode is enabled.
524
+ break;
525
+ }
526
+
527
+ $this->values['showProgress'] = true;
528
+ break;
529
+ case 'q' :
530
+ // Quiet mode disables a few other settings as well.
531
+ $this->values['quiet'] = true;
532
+ $this->values['showProgress'] = false;
533
+ $this->values['verbosity'] = 0;
534
+ break;
535
+ case 'd' :
536
+ $ini = explode('=', $this->_cliArgs[($pos + 1)]);
537
+ $this->_cliArgs[($pos + 1)] = '';
538
+ if (isset($ini[1]) === true) {
539
+ ini_set($ini[0], $ini[1]);
540
+ } else {
541
+ ini_set($ini[0], true);
542
+ }
543
+ break;
544
+ case 'n' :
545
+ $this->values['warningSeverity'] = 0;
546
+ break;
547
+ case 'w' :
548
+ $this->values['warningSeverity'] = null;
549
+ break;
550
+ default:
551
+ if ($this->dieOnUnknownArg === false) {
552
+ $this->values[$arg] = $arg;
553
+ } else {
554
+ $this->processUnknownArgument('-'.$arg, $pos);
555
+ }
556
+ }//end switch
557
+
558
+ }//end processShortArgument()
559
+
560
+
561
+ /**
562
+ * Processes a long (--example) command line argument.
563
+ *
564
+ * @param string $arg The command line argument.
565
+ * @param int $pos The position of the argument on the command line.
566
+ *
567
+ * @return void
568
+ */
569
+ public function processLongArgument($arg, $pos)
570
+ {
571
+ switch ($arg) {
572
+ case 'help':
573
+ $this->printUsage();
574
+ exit(0);
575
+ case 'version':
576
+ echo 'PHP_CodeSniffer version '.PHP_CodeSniffer::VERSION.' ('.PHP_CodeSniffer::STABILITY.') ';
577
+ echo 'by Squiz (http://www.squiz.net)'.PHP_EOL;
578
+ exit(0);
579
+ case 'colors':
580
+ $this->values['colors'] = true;
581
+ break;
582
+ case 'no-colors':
583
+ $this->values['colors'] = false;
584
+ break;
585
+ case 'config-set':
586
+ if (isset($this->_cliArgs[($pos + 1)]) === false
587
+ || isset($this->_cliArgs[($pos + 2)]) === false
588
+ ) {
589
+ echo 'ERROR: Setting a config option requires a name and value'.PHP_EOL.PHP_EOL;
590
+ $this->printUsage();
591
+ exit(0);
592
+ }
593
+
594
+ $key = $this->_cliArgs[($pos + 1)];
595
+ $value = $this->_cliArgs[($pos + 2)];
596
+ $current = PHP_CodeSniffer::getConfigData($key);
597
+
598
+ try {
599
+ PHP_CodeSniffer::setConfigData($key, $value);
600
+ } catch (Exception $e) {
601
+ echo $e->getMessage().PHP_EOL;
602
+ exit(2);
603
+ }
604
+
605
+ if ($current === null) {
606
+ echo "Config value \"$key\" added successfully".PHP_EOL;
607
+ } else {
608
+ echo "Config value \"$key\" updated successfully; old value was \"$current\"".PHP_EOL;
609
+ }
610
+ exit(0);
611
+ case 'config-delete':
612
+ if (isset($this->_cliArgs[($pos + 1)]) === false) {
613
+ echo 'ERROR: Deleting a config option requires the name of the option'.PHP_EOL.PHP_EOL;
614
+ $this->printUsage();
615
+ exit(0);
616
+ }
617
+
618
+ $key = $this->_cliArgs[($pos + 1)];
619
+ $current = PHP_CodeSniffer::getConfigData($key);
620
+ if ($current === null) {
621
+ echo "Config value \"$key\" has not been set".PHP_EOL;
622
+ } else {
623
+ try {
624
+ PHP_CodeSniffer::setConfigData($key, null);
625
+ } catch (Exception $e) {
626
+ echo $e->getMessage().PHP_EOL;
627
+ exit(2);
628
+ }
629
+
630
+ echo "Config value \"$key\" removed successfully; old value was \"$current\"".PHP_EOL;
631
+ }
632
+ exit(0);
633
+ case 'config-show':
634
+ $data = PHP_CodeSniffer::getAllConfigData();
635
+ $this->printConfigData($data);
636
+ exit(0);
637
+ case 'runtime-set':
638
+ if (isset($this->_cliArgs[($pos + 1)]) === false
639
+ || isset($this->_cliArgs[($pos + 2)]) === false
640
+ ) {
641
+ echo 'ERROR: Setting a runtime config option requires a name and value'.PHP_EOL.PHP_EOL;
642
+ $this->printUsage();
643
+ exit(0);
644
+ }
645
+
646
+ $key = $this->_cliArgs[($pos + 1)];
647
+ $value = $this->_cliArgs[($pos + 2)];
648
+ $this->_cliArgs[($pos + 1)] = '';
649
+ $this->_cliArgs[($pos + 2)] = '';
650
+ PHP_CodeSniffer::setConfigData($key, $value, true);
651
+ break;
652
+ default:
653
+ if (substr($arg, 0, 7) === 'sniffs=') {
654
+ $sniffs = explode(',', substr($arg, 7));
655
+ foreach ($sniffs as $sniff) {
656
+ if (substr_count($sniff, '.') !== 2) {
657
+ echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL;
658
+ $this->printUsage();
659
+ exit(2);
660
+ }
661
+ }
662
+
663
+ $this->values['sniffs'] = $sniffs;
664
+ } else if (substr($arg, 0, 8) === 'exclude=') {
665
+ $sniffs = explode(',', substr($arg, 8));
666
+ foreach ($sniffs as $sniff) {
667
+ if (substr_count($sniff, '.') !== 2) {
668
+ echo 'ERROR: The specified sniff code "'.$sniff.'" is invalid'.PHP_EOL.PHP_EOL;
669
+ $this->printUsage();
670
+ exit(2);
671
+ }
672
+ }
673
+
674
+ $this->values['exclude'] = $sniffs;
675
+ } else if (substr($arg, 0, 10) === 'bootstrap=') {
676
+ $files = explode(',', substr($arg, 10));
677
+ foreach ($files as $file) {
678
+ $path = PHP_CodeSniffer::realpath($file);
679
+ if ($path === false) {
680
+ echo 'ERROR: The specified bootstrap file "'.$file.'" does not exist'.PHP_EOL.PHP_EOL;
681
+ $this->printUsage();
682
+ exit(2);
683
+ }
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
+
717
+ // It may not exist and return false instead, so just use whatever they gave us.
718
+ if ($this->values['stdinPath'] === false) {
719
+ $this->values['stdinPath'] = trim(substr($arg, 11));
720
+ }
721
+ } else if (substr($arg, 0, 12) === 'report-file=') {
722
+ $this->values['reportFile'] = PHP_CodeSniffer::realpath(substr($arg, 12));
723
+
724
+ // It may not exist and return false instead.
725
+ if ($this->values['reportFile'] === false) {
726
+ $this->values['reportFile'] = substr($arg, 12);
727
+
728
+ $dir = dirname($this->values['reportFile']);
729
+ if (is_dir($dir) === false) {
730
+ echo 'ERROR: The specified report file path "'.$this->values['reportFile'].'" points to a non-existent directory'.PHP_EOL.PHP_EOL;
731
+ $this->printUsage();
732
+ exit(2);
733
+ }
734
+
735
+ if ($dir === '.') {
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']);
749
+ }
750
+ }
751
+ }//end if
752
+
753
+ if (is_dir($this->values['reportFile']) === true) {
754
+ echo 'ERROR: The specified report file path "'.$this->values['reportFile'].'" is a directory'.PHP_EOL.PHP_EOL;
755
+ $this->printUsage();
756
+ exit(2);
757
+ }
758
+ } else if (substr($arg, 0, 13) === 'report-width=') {
759
+ $this->values['reportWidth'] = $this->_validateReportWidth(substr($arg, 13));
760
+ } else if (substr($arg, 0, 7) === 'report='
761
+ || substr($arg, 0, 7) === 'report-'
762
+ ) {
763
+ if ($arg[6] === '-') {
764
+ // This is a report with file output.
765
+ $split = strpos($arg, '=');
766
+ if ($split === false) {
767
+ $report = substr($arg, 7);
768
+ $output = null;
769
+ } else {
770
+ $report = substr($arg, 7, ($split - 7));
771
+ $output = substr($arg, ($split + 1));
772
+ if ($output === false) {
773
+ $output = null;
774
+ } else {
775
+ $dir = dirname($output);
776
+ if ($dir === '.') {
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);
790
+ }
791
+ }
792
+ }//end if
793
+ }//end if
794
+ } else {
795
+ // This is a single report.
796
+ $report = substr($arg, 7);
797
+ $output = null;
798
+ }//end if
799
+
800
+ $this->values['reports'][$report] = $output;
801
+ } else if (substr($arg, 0, 9) === 'standard=') {
802
+ $standards = trim(substr($arg, 9));
803
+ if ($standards !== '') {
804
+ $this->values['standard'] = explode(',', $standards);
805
+ }
806
+ } else if (substr($arg, 0, 11) === 'extensions=') {
807
+ if (isset($this->values['extensions']) === false) {
808
+ $this->values['extensions'] = array();
809
+ }
810
+
811
+ $this->values['extensions'] = array_merge($this->values['extensions'], explode(',', substr($arg, 11)));
812
+ } else if (substr($arg, 0, 9) === 'severity=') {
813
+ $this->values['errorSeverity'] = (int) substr($arg, 9);
814
+ $this->values['warningSeverity'] = $this->values['errorSeverity'];
815
+ } else if (substr($arg, 0, 15) === 'error-severity=') {
816
+ $this->values['errorSeverity'] = (int) substr($arg, 15);
817
+ } else if (substr($arg, 0, 17) === 'warning-severity=') {
818
+ $this->values['warningSeverity'] = (int) substr($arg, 17);
819
+ } else if (substr($arg, 0, 7) === 'ignore=') {
820
+ // Split the ignore string on commas, unless the comma is escaped
821
+ // using 1 or 3 slashes (\, or \\\,).
822
+ $ignored = preg_split(
823
+ '/(?<=(?<!\\\\)\\\\\\\\),|(?<!\\\\),/',
824
+ substr($arg, 7)
825
+ );
826
+ foreach ($ignored as $pattern) {
827
+ $pattern = trim($pattern);
828
+ if ($pattern === '') {
829
+ continue;
830
+ }
831
+
832
+ $this->values['ignored'][$pattern] = 'absolute';
833
+ }
834
+ } else if (substr($arg, 0, 10) === 'generator=') {
835
+ $this->values['generator'] = substr($arg, 10);
836
+ } else if (substr($arg, 0, 9) === 'encoding=') {
837
+ $this->values['encoding'] = strtolower(substr($arg, 9));
838
+ } else if (substr($arg, 0, 10) === 'tab-width=') {
839
+ $this->values['tabWidth'] = (int) substr($arg, 10);
840
+ } else {
841
+ if ($this->dieOnUnknownArg === false) {
842
+ $eqPos = strpos($arg, '=');
843
+ if ($eqPos === false) {
844
+ $this->values[$arg] = $arg;
845
+ } else {
846
+ $value = substr($arg, ($eqPos + 1));
847
+ $arg = substr($arg, 0, $eqPos);
848
+ $this->values[$arg] = $value;
849
+ }
850
+ } else {
851
+ $this->processUnknownArgument('--'.$arg, $pos);
852
+ }
853
+ }//end if
854
+
855
+ break;
856
+ }//end switch
857
+
858
+ }//end processLongArgument()
859
+
860
+
861
+ /**
862
+ * Processes an unknown command line argument.
863
+ *
864
+ * Assumes all unknown arguments are files and folders to check.
865
+ *
866
+ * @param string $arg The command line argument.
867
+ * @param int $pos The position of the argument on the command line.
868
+ *
869
+ * @return void
870
+ */
871
+ public function processUnknownArgument($arg, $pos)
872
+ {
873
+ // We don't know about any additional switches; just files.
874
+ if ($arg{0} === '-') {
875
+ if ($this->dieOnUnknownArg === false) {
876
+ return;
877
+ }
878
+
879
+ echo 'ERROR: option "'.$arg.'" not known.'.PHP_EOL.PHP_EOL;
880
+ $this->printUsage();
881
+ exit(2);
882
+ }
883
+
884
+ $file = PHP_CodeSniffer::realpath($arg);
885
+ if (file_exists($file) === false) {
886
+ if ($this->dieOnUnknownArg === false) {
887
+ return;
888
+ }
889
+
890
+ echo 'ERROR: The file "'.$arg.'" does not exist.'.PHP_EOL.PHP_EOL;
891
+ $this->printUsage();
892
+ exit(2);
893
+ } else {
894
+ $this->values['files'][] = $file;
895
+ }
896
+
897
+ }//end processUnknownArgument()
898
+
899
+
900
+ /**
901
+ * Runs PHP_CodeSniffer over files and directories.
902
+ *
903
+ * @param array $values An array of values determined from CLI args.
904
+ *
905
+ * @return int The number of error and warning messages shown.
906
+ * @see getCommandLineValues()
907
+ */
908
+ public function process($values=array())
909
+ {
910
+ if (empty($values) === true) {
911
+ $values = $this->getCommandLineValues();
912
+ } else {
913
+ $values = array_merge($this->getDefaults(), $values);
914
+ $this->values = $values;
915
+ }
916
+
917
+ if ($values['generator'] !== '') {
918
+ $phpcs = new PHP_CodeSniffer($values['verbosity']);
919
+ if ($values['standard'] === null) {
920
+ $values['standard'] = $this->validateStandard(null);
921
+ }
922
+
923
+ foreach ($values['standard'] as $standard) {
924
+ $phpcs->generateDocs(
925
+ $standard,
926
+ $values['sniffs'],
927
+ $values['generator']
928
+ );
929
+ }
930
+
931
+ exit(0);
932
+ }
933
+
934
+ // If no standard is supplied, get the default.
935
+ $values['standard'] = $this->validateStandard($values['standard']);
936
+ foreach ($values['standard'] as $standard) {
937
+ if (PHP_CodeSniffer::isInstalledStandard($standard) === false) {
938
+ // They didn't select a valid coding standard, so help them
939
+ // out by letting them know which standards are installed.
940
+ echo 'ERROR: the "'.$standard.'" coding standard is not installed. ';
941
+ $this->printInstalledStandards();
942
+ exit(2);
943
+ }
944
+ }
945
+
946
+ if ($values['explain'] === true) {
947
+ foreach ($values['standard'] as $standard) {
948
+ $this->explainStandard($standard);
949
+ }
950
+
951
+ exit(0);
952
+ }
953
+
954
+ $phpcs = new PHP_CodeSniffer($values['verbosity'], null, null, null);
955
+ $phpcs->setCli($this);
956
+ $phpcs->initStandard($values['standard'], $values['sniffs'], $values['exclude']);
957
+ $values = $this->values;
958
+
959
+ $phpcs->setTabWidth($values['tabWidth']);
960
+ $phpcs->setEncoding($values['encoding']);
961
+ $phpcs->setInteractive($values['interactive']);
962
+
963
+ // Set file extensions if they were specified. Otherwise,
964
+ // let PHP_CodeSniffer decide on the defaults.
965
+ if (empty($values['extensions']) === false) {
966
+ $phpcs->setAllowedFileExtensions($values['extensions']);
967
+ }
968
+
969
+ // Set ignore patterns if they were specified.
970
+ if (empty($values['ignored']) === false) {
971
+ $ignorePatterns = array_merge($phpcs->getIgnorePatterns(), $values['ignored']);
972
+ $phpcs->setIgnorePatterns($ignorePatterns);
973
+ }
974
+
975
+ // Set some convenience member vars.
976
+ if ($values['errorSeverity'] === null) {
977
+ $this->errorSeverity = PHPCS_DEFAULT_ERROR_SEV;
978
+ } else {
979
+ $this->errorSeverity = $values['errorSeverity'];
980
+ }
981
+
982
+ if ($values['warningSeverity'] === null) {
983
+ $this->warningSeverity = PHPCS_DEFAULT_WARN_SEV;
984
+ } else {
985
+ $this->warningSeverity = $values['warningSeverity'];
986
+ }
987
+
988
+ if (empty($values['reports']) === true) {
989
+ $values['reports']['full'] = $values['reportFile'];
990
+ $this->values['reports'] = $values['reports'];
991
+ }
992
+
993
+ // Include bootstrap files.
994
+ foreach ($values['bootstrap'] as $bootstrap) {
995
+ include $bootstrap;
996
+ }
997
+
998
+ $phpcs->processFiles($values['files'], $values['local']);
999
+
1000
+ if (empty($values['files']) === true || $values['stdin'] !== null) {
1001
+ $fileContents = $values['stdin'];
1002
+ if ($fileContents === null) {
1003
+ // Check if they are passing in the file contents.
1004
+ $handle = fopen('php://stdin', 'r');
1005
+ stream_set_blocking($handle, true);
1006
+ $fileContents = stream_get_contents($handle);
1007
+ fclose($handle);
1008
+ }
1009
+
1010
+ if ($fileContents === '') {
1011
+ // No files and no content passed in.
1012
+ echo 'ERROR: You must supply at least one file or directory to process.'.PHP_EOL.PHP_EOL;
1013
+ $this->printUsage();
1014
+ exit(2);
1015
+ } else {
1016
+ $this->values['stdin'] = $fileContents;
1017
+ $phpcs->processFile('STDIN', $fileContents);
1018
+ }
1019
+ }
1020
+
1021
+ // Interactive runs don't require a final report and it doesn't really
1022
+ // matter what the retun value is because we know it isn't being read
1023
+ // by a script.
1024
+ if ($values['interactive'] === true) {
1025
+ return 0;
1026
+ }
1027
+
1028
+ return $this->printErrorReport(
1029
+ $phpcs,
1030
+ $values['reports'],
1031
+ $values['showSources'],
1032
+ $values['reportFile'],
1033
+ $values['reportWidth']
1034
+ );
1035
+
1036
+ }//end process()
1037
+
1038
+
1039
+ /**
1040
+ * Prints the error report for the run.
1041
+ *
1042
+ * Note that this function may actually print multiple reports
1043
+ * as the user may have specified a number of output formats.
1044
+ *
1045
+ * @param PHP_CodeSniffer $phpcs The PHP_CodeSniffer object containing
1046
+ * the errors.
1047
+ * @param array $reports A list of reports to print.
1048
+ * @param bool $showSources TRUE if report should show error sources
1049
+ * (not used by all reports).
1050
+ * @param string $reportFile A default file to log report output to.
1051
+ * @param int $reportWidth How wide the screen reports should be.
1052
+ *
1053
+ * @return int The number of error and warning messages shown.
1054
+ */
1055
+ public function printErrorReport(
1056
+ PHP_CodeSniffer $phpcs,
1057
+ $reports,
1058
+ $showSources,
1059
+ $reportFile,
1060
+ $reportWidth
1061
+ ) {
1062
+ if (empty($reports) === true) {
1063
+ $reports['full'] = $reportFile;
1064
+ }
1065
+
1066
+ $errors = 0;
1067
+ $warnings = 0;
1068
+ $toScreen = false;
1069
+
1070
+ foreach ($reports as $report => $output) {
1071
+ if ($output === null) {
1072
+ $output = $reportFile;
1073
+ }
1074
+
1075
+ if ($reportFile === null) {
1076
+ $toScreen = true;
1077
+ }
1078
+
1079
+ // We don't add errors here because the number of
1080
+ // errors reported by each report type will always be the
1081
+ // same, so we really just need 1 number.
1082
+ $result = $phpcs->reporting->printReport(
1083
+ $report,
1084
+ $showSources,
1085
+ $this->values,
1086
+ $output,
1087
+ $reportWidth
1088
+ );
1089
+
1090
+ $errors = $result['errors'];
1091
+ $warnings = $result['warnings'];
1092
+ }//end foreach
1093
+
1094
+ // Only print timer output if no reports were
1095
+ // printed to the screen so we don't put additional output
1096
+ // in something like an XML report. If we are printing to screen,
1097
+ // the report types would have already worked out who should
1098
+ // print the timer info.
1099
+ if (PHP_CODESNIFFER_INTERACTIVE === false
1100
+ && ($toScreen === false
1101
+ || (($errors + $warnings) === 0 && $this->values['showProgress'] === true))
1102
+ ) {
1103
+ PHP_CodeSniffer_Reporting::printRunTime();
1104
+ }
1105
+
1106
+ // They should all return the same value, so it
1107
+ // doesn't matter which return value we end up using.
1108
+ $ignoreWarnings = PHP_CodeSniffer::getConfigData('ignore_warnings_on_exit');
1109
+ $ignoreErrors = PHP_CodeSniffer::getConfigData('ignore_errors_on_exit');
1110
+
1111
+ $return = ($errors + $warnings);
1112
+ if ($ignoreErrors !== null) {
1113
+ $ignoreErrors = (bool) $ignoreErrors;
1114
+ if ($ignoreErrors === true) {
1115
+ $return -= $errors;
1116
+ }
1117
+ }
1118
+
1119
+ if ($ignoreWarnings !== null) {
1120
+ $ignoreWarnings = (bool) $ignoreWarnings;
1121
+ if ($ignoreWarnings === true) {
1122
+ $return -= $warnings;
1123
+ }
1124
+ }
1125
+
1126
+ return $return;
1127
+
1128
+ }//end printErrorReport()
1129
+
1130
+
1131
+ /**
1132
+ * Convert the passed standards into valid standards.
1133
+ *
1134
+ * Checks things like default values and case.
1135
+ *
1136
+ * @param array $standards The standards to validate.
1137
+ *
1138
+ * @return array
1139
+ */
1140
+ public function validateStandard($standards)
1141
+ {
1142
+ if ($standards === null) {
1143
+ // They did not supply a standard to use.
1144
+ // Look for a default ruleset in the current directory or higher.
1145
+ $currentDir = getcwd();
1146
+
1147
+ do {
1148
+ $default = $currentDir.DIRECTORY_SEPARATOR.'phpcs.xml';
1149
+ if (is_file($default) === true) {
1150
+ return array($default);
1151
+ }
1152
+
1153
+ $default = $currentDir.DIRECTORY_SEPARATOR.'phpcs.xml.dist';
1154
+ if (is_file($default) === true) {
1155
+ return array($default);
1156
+ }
1157
+
1158
+ $lastDir = $currentDir;
1159
+ $currentDir = dirname($currentDir);
1160
+ } while ($currentDir !== '.' && $currentDir !== $lastDir);
1161
+
1162
+ // Try to get the default from the config system.
1163
+ $standard = PHP_CodeSniffer::getConfigData('default_standard');
1164
+ if ($standard === null) {
1165
+ // Product default standard.
1166
+ $standard = 'PEAR';
1167
+ }
1168
+
1169
+ return explode(',', $standard);
1170
+ }//end if
1171
+
1172
+ $cleaned = array();
1173
+ $standards = (array) $standards;
1174
+
1175
+ // Check if the standard name is valid, or if the case is invalid.
1176
+ $installedStandards = PHP_CodeSniffer::getInstalledStandards();
1177
+ foreach ($standards as $standard) {
1178
+ foreach ($installedStandards as $validStandard) {
1179
+ if (strtolower($standard) === strtolower($validStandard)) {
1180
+ $standard = $validStandard;
1181
+ break;
1182
+ }
1183
+ }
1184
+
1185
+ $cleaned[] = $standard;
1186
+ }
1187
+
1188
+ return $cleaned;
1189
+
1190
+ }//end validateStandard()
1191
+
1192
+
1193
+ /**
1194
+ * Prints a report showing the sniffs contained in a standard.
1195
+ *
1196
+ * @param string $standard The standard to validate.
1197
+ *
1198
+ * @return void
1199
+ */
1200
+ public function explainStandard($standard)
1201
+ {
1202
+ $phpcs = new PHP_CodeSniffer();
1203
+ $phpcs->process(array(), $standard);
1204
+ $sniffs = $phpcs->getSniffs();
1205
+ $sniffs = array_keys($sniffs);
1206
+ sort($sniffs);
1207
+
1208
+ ob_start();
1209
+
1210
+ $lastStandard = '';
1211
+ $lastCount = '';
1212
+ $sniffCount = count($sniffs);
1213
+ $sniffs[] = '___';
1214
+
1215
+ echo PHP_EOL."The $standard standard contains $sniffCount sniffs".PHP_EOL;
1216
+
1217
+ ob_start();
1218
+
1219
+ foreach ($sniffs as $sniff) {
1220
+ $parts = explode('_', str_replace('\\', '_', $sniff));
1221
+ if ($lastStandard === '') {
1222
+ $lastStandard = $parts[0];
1223
+ }
1224
+
1225
+ if ($parts[0] !== $lastStandard) {
1226
+ $sniffList = ob_get_contents();
1227
+ ob_end_clean();
1228
+
1229
+ echo PHP_EOL.$lastStandard.' ('.$lastCount.' sniffs)'.PHP_EOL;
1230
+ echo str_repeat('-', (strlen($lastStandard.$lastCount) + 10));
1231
+ echo PHP_EOL;
1232
+ echo $sniffList;
1233
+
1234
+ $lastStandard = $parts[0];
1235
+ $lastCount = 0;
1236
+
1237
+ ob_start();
1238
+ }
1239
+
1240
+ echo ' '.$parts[0].'.'.$parts[2].'.'.substr($parts[3], 0, -5).PHP_EOL;
1241
+ $lastCount++;
1242
+ }//end foreach
1243
+
1244
+ ob_end_clean();
1245
+
1246
+ }//end explainStandard()
1247
+
1248
+
1249
+ /**
1250
+ * Prints out the gathered config data.
1251
+ *
1252
+ * @param array $data The config data to print.
1253
+ *
1254
+ * @return void
1255
+ */
1256
+ public function printConfigData($data)
1257
+ {
1258
+ $max = 0;
1259
+ $keys = array_keys($data);
1260
+ foreach ($keys as $key) {
1261
+ $len = strlen($key);
1262
+ if (strlen($key) > $max) {
1263
+ $max = $len;
1264
+ }
1265
+ }
1266
+
1267
+ if ($max === 0) {
1268
+ return;
1269
+ }
1270
+
1271
+ $max += 2;
1272
+ ksort($data);
1273
+ foreach ($data as $name => $value) {
1274
+ echo str_pad($name.': ', $max).$value.PHP_EOL;
1275
+ }
1276
+
1277
+ }//end printConfigData()
1278
+
1279
+
1280
+ /**
1281
+ * Prints out the usage information for this script.
1282
+ *
1283
+ * @return void
1284
+ */
1285
+ public function printUsage()
1286
+ {
1287
+ if (PHP_CODESNIFFER_CBF === true) {
1288
+ $this->printPHPCBFUsage();
1289
+ } else {
1290
+ $this->printPHPCSUsage();
1291
+ }
1292
+
1293
+ }//end printUsage()
1294
+
1295
+
1296
+ /**
1297
+ * Prints out the usage information for PHPCS.
1298
+ *
1299
+ * @return void
1300
+ */
1301
+ public function printPHPCSUsage()
1302
+ {
1303
+ echo 'Usage: phpcs [-nwlsaepqvi] [-d key[=value]] [--colors] [--no-colors] [--stdin-path=<stdinPath>]'.PHP_EOL;
1304
+ echo ' [--report=<report>] [--report-file=<reportFile>] [--report-<report>=<reportFile>] ...'.PHP_EOL;
1305
+ echo ' [--report-width=<reportWidth>] [--generator=<generator>] [--tab-width=<tabWidth>]'.PHP_EOL;
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;
1314
+ echo ' -l Local directory only, no recursion'.PHP_EOL;
1315
+ echo ' -s Show sniff codes in all reports'.PHP_EOL;
1316
+ echo ' -a Run interactively'.PHP_EOL;
1317
+ echo ' -e Explain a standard by showing the sniffs it includes'.PHP_EOL;
1318
+ echo ' -p Show progress of the run'.PHP_EOL;
1319
+ echo ' -q Quiet mode; disables progress and verbose output'.PHP_EOL;
1320
+ echo ' -v[v][v] Print verbose output'.PHP_EOL;
1321
+ echo ' -i Show a list of installed coding standards'.PHP_EOL;
1322
+ echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted'.PHP_EOL;
1323
+ echo ' --help Print this help message'.PHP_EOL;
1324
+ echo ' --version Print version information'.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;
1332
+ echo ' <extensions> A comma separated list of file extensions to check'.PHP_EOL;
1333
+ echo ' (extension filtering only valid when checking a directory)'.PHP_EOL;
1334
+ echo ' The type of the file can be specified using: ext/type'.PHP_EOL;
1335
+ echo ' e.g., module/php,es/js'.PHP_EOL;
1336
+ echo ' <generator> Uses either the "HTML", "Markdown" or "Text" generator'.PHP_EOL;
1337
+ echo ' (forces documentation generation instead of checking)'.PHP_EOL;
1338
+ echo ' <patterns> A comma separated list of patterns to ignore files and directories'.PHP_EOL;
1339
+ echo ' <report> Print either the "full", "xml", "checkstyle", "csv"'.PHP_EOL;
1340
+ echo ' "json", "emacs", "source", "summary", "diff", "junit"'.PHP_EOL;
1341
+ echo ' "svnblame", "gitblame", "hgblame" or "notifysend" report'.PHP_EOL;
1342
+ echo ' (the "full" report is printed by default)'.PHP_EOL;
1343
+ echo ' <reportFile> Write the report to the specified file path'.PHP_EOL;
1344
+ echo ' <reportWidth> How many columns wide screen reports should be printed'.PHP_EOL;
1345
+ echo ' or set to "auto" to use current screen width, where supported'.PHP_EOL;
1346
+ echo ' <sniffs> A comma separated list of sniff codes to include or exclude during checking'.PHP_EOL;
1347
+ echo ' (all sniffs must be part of the specified standard)'.PHP_EOL;
1348
+ echo ' <severity> The minimum severity required to display an error or warning'.PHP_EOL;
1349
+ echo ' <standard> The name or path of the coding standard to use'.PHP_EOL;
1350
+ echo ' <tabWidth> The number of spaces each tab represents'.PHP_EOL;
1351
+
1352
+ }//end printPHPCSUsage()
1353
+
1354
+
1355
+ /**
1356
+ * Prints out the usage information for PHPCBF.
1357
+ *
1358
+ * @return void
1359
+ */
1360
+ public function printPHPCBFUsage()
1361
+ {
1362
+ echo 'Usage: phpcbf [-nwli] [-d key[=value]] [--stdin-path=<stdinPath>]'.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;
1371
+ echo ' -i Show a list of installed coding standards'.PHP_EOL;
1372
+ echo ' -d Set the [key] php.ini value to [value] or [true] if value is omitted'.PHP_EOL;
1373
+ echo ' --help Print this help message'.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;
1381
+ echo ' <extensions> A comma separated list of file extensions to fix'.PHP_EOL;
1382
+ echo ' (extension filtering only valid when checking a directory)'.PHP_EOL;
1383
+ echo ' The type of the file can be specified using: ext/type'.PHP_EOL;
1384
+ echo ' e.g., module/php,es/js'.PHP_EOL;
1385
+ echo ' <patterns> A comma separated list of patterns to ignore files and directories'.PHP_EOL;
1386
+ echo ' <sniffs> A comma separated list of sniff codes to include or exclude during fixing'.PHP_EOL;
1387
+ echo ' (all sniffs must be part of the specified standard)'.PHP_EOL;
1388
+ echo ' <severity> The minimum severity required to fix an error or warning'.PHP_EOL;
1389
+ echo ' <standard> The name or path of the coding standard to use'.PHP_EOL;
1390
+ echo ' <suffix> Write modified files to a filename using this suffix'.PHP_EOL;
1391
+ echo ' ("diff" and "patch" are not used in this mode)'.PHP_EOL;
1392
+ echo ' <tabWidth> The number of spaces each tab represents'.PHP_EOL;
1393
+
1394
+ }//end printPHPCBFUsage()
1395
+
1396
+
1397
+ /**
1398
+ * Prints out a list of installed coding standards.
1399
+ *
1400
+ * @return void
1401
+ */
1402
+ public function printInstalledStandards()
1403
+ {
1404
+ $installedStandards = PHP_CodeSniffer::getInstalledStandards();
1405
+ $numStandards = count($installedStandards);
1406
+
1407
+ if ($numStandards === 0) {
1408
+ echo 'No coding standards are installed.'.PHP_EOL;
1409
+ } else {
1410
+ $lastStandard = array_pop($installedStandards);
1411
+ if ($numStandards === 1) {
1412
+ echo "The only coding standard installed is $lastStandard".PHP_EOL;
1413
+ } else {
1414
+ $standardList = implode(', ', $installedStandards);
1415
+ $standardList .= ' and '.$lastStandard;
1416
+ echo 'The installed coding standards are '.$standardList.PHP_EOL;
1417
+ }
1418
+ }
1419
+
1420
+ }//end printInstalledStandards()
1421
+
1422
+
1423
+ /**
1424
+ * Set report width based on terminal width.
1425
+ *
1426
+ * @param int $width The width of the report. If "auto" then will
1427
+ * be replaced by the terminal width.
1428
+ *
1429
+ * @return int
1430
+ */
1431
+ private function _validateReportWidth($width)
1432
+ {
1433
+ if ($width === 'auto'
1434
+ && preg_match('|\d+ (\d+)|', shell_exec('stty size 2>&1'), $matches) === 1
1435
+ ) {
1436
+ return (int) $matches[1];
1437
+ }
1438
+
1439
+ return (int) $width;
1440
+
1441
+ }//end _validateReportWidth()
1442
+
1443
+
1444
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/Generator.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * The base class for all PHP_CodeSniffer documentation generators.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * The base class for all PHP_CodeSniffer documentation generators.
18
+ *
19
+ * Documentation generators are used to print documentation about code sniffs
20
+ * in a standard.
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Greg Sherwood <gsherwood@squiz.net>
25
+ * @author Marc McIntyre <mmcintyre@squiz.net>
26
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
27
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
28
+ * @version Release: @package_version@
29
+ * @link http://pear.php.net/package/PHP_CodeSniffer
30
+ */
31
+ abstract class PHP_CodeSniffer_DocGenerators_Generator
32
+ {
33
+
34
+ /**
35
+ * The name of the coding standard we are generating docs for.
36
+ *
37
+ * @var string
38
+ */
39
+ private $_standard = '';
40
+
41
+ /**
42
+ * An array of sniffs that we are limiting the generated docs to.
43
+ *
44
+ * If this array is empty, docs are generated for all sniffs in the
45
+ * supplied coding standard.
46
+ *
47
+ * @var string
48
+ */
49
+ private $_sniffs = array();
50
+
51
+
52
+ /**
53
+ * Constructs a PHP_CodeSniffer_DocGenerators_Generator object.
54
+ *
55
+ * @param string $standard The name of the coding standard to generate
56
+ * docs for.
57
+ * @param array $sniffs An array of sniffs that we are limiting the
58
+ * generated docs to.
59
+ *
60
+ * @see generate()
61
+ */
62
+ public function __construct($standard, array $sniffs=array())
63
+ {
64
+ $this->_standard = $standard;
65
+ $this->_sniffs = $sniffs;
66
+
67
+ }//end __construct()
68
+
69
+
70
+ /**
71
+ * Retrieves the title of the sniff from the DOMNode supplied.
72
+ *
73
+ * @param DOMNode $doc The DOMNode object for the sniff.
74
+ * It represents the "documentation" tag in the XML
75
+ * standard file.
76
+ *
77
+ * @return string
78
+ */
79
+ protected function getTitle(DOMNode $doc)
80
+ {
81
+ return $doc->getAttribute('title');
82
+
83
+ }//end getTitle()
84
+
85
+
86
+ /**
87
+ * Retrieves the name of the standard we are generating docs for.
88
+ *
89
+ * @return string
90
+ */
91
+ protected function getStandard()
92
+ {
93
+ return $this->_standard;
94
+
95
+ }//end getStandard()
96
+
97
+
98
+ /**
99
+ * Generates the documentation for a standard.
100
+ *
101
+ * It's probably wise for doc generators to override this method so they
102
+ * have control over how the docs are produced. Otherwise, the processSniff
103
+ * method should be overridden to output content for each sniff.
104
+ *
105
+ * @return void
106
+ * @see processSniff()
107
+ */
108
+ public function generate()
109
+ {
110
+ $standardFiles = $this->getStandardFiles();
111
+
112
+ foreach ($standardFiles as $standard) {
113
+ $doc = new DOMDocument();
114
+ $doc->load($standard);
115
+ $documentation = $doc->getElementsByTagName('documentation')->item(0);
116
+ $this->processSniff($documentation);
117
+ }
118
+
119
+ }//end generate()
120
+
121
+
122
+ /**
123
+ * Returns a list of paths to XML standard files for all sniffs in a standard.
124
+ *
125
+ * Any sniffs that do not have an XML standard file are obviously not included
126
+ * in the returned array. If documentation is only being generated for some
127
+ * sniffs (ie. $this->_sniffs is not empty) then all others sniffs will
128
+ * be filtered from the results as well.
129
+ *
130
+ * @return string[]
131
+ */
132
+ protected function getStandardFiles()
133
+ {
134
+ $phpcs = new PHP_CodeSniffer();
135
+ $phpcs->process(array(), $this->_standard);
136
+ $sniffs = $phpcs->getSniffs();
137
+
138
+ $standardFiles = array();
139
+ foreach ($sniffs as $className => $sniffClass) {
140
+ $object = new ReflectionObject($sniffClass);
141
+ $sniff = $object->getFilename();
142
+ if (empty($this->_sniffs) === false) {
143
+ // We are limiting the docs to certain sniffs only, so filter
144
+ // out any unwanted sniffs.
145
+ $parts = explode('_', $className);
146
+ $sniffName = $parts[0].'.'.$parts[2].'.'.substr($parts[3], 0, -5);
147
+ if (in_array($sniffName, $this->_sniffs) === false) {
148
+ continue;
149
+ }
150
+ }
151
+
152
+ $standardFile = str_replace(
153
+ DIRECTORY_SEPARATOR.'Sniffs'.DIRECTORY_SEPARATOR,
154
+ DIRECTORY_SEPARATOR.'Docs'.DIRECTORY_SEPARATOR,
155
+ $sniff
156
+ );
157
+ $standardFile = str_replace('Sniff.php', 'Standard.xml', $standardFile);
158
+
159
+ if (is_file($standardFile) === true) {
160
+ $standardFiles[] = $standardFile;
161
+ }
162
+ }//end foreach
163
+
164
+ return $standardFiles;
165
+
166
+ }//end getStandardFiles()
167
+
168
+
169
+ /**
170
+ * Process the documentation for a single sniff.
171
+ *
172
+ * Doc generators must implement this function to produce output.
173
+ *
174
+ * @param DOMNode $doc The DOMNode object for the sniff.
175
+ * It represents the "documentation" tag in the XML
176
+ * standard file.
177
+ *
178
+ * @return void
179
+ * @see generate()
180
+ */
181
+ protected abstract function processSniff(DOMNode $doc);
182
+
183
+
184
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/HTML.php ADDED
@@ -0,0 +1,292 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * A doc generator that outputs documentation in one big HTML file.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ if (class_exists('PHP_CodeSniffer_DocGenerators_Generator', true) === false) {
17
+ throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_DocGenerators_Generator not found');
18
+ }
19
+
20
+ /**
21
+ * A doc generator that outputs documentation in one big HTML file.
22
+ *
23
+ * Output is in one large HTML file and is designed for you to style with
24
+ * your own stylesheet. It contains a table of contents at the top with anchors
25
+ * to each sniff.
26
+ *
27
+ * @category PHP
28
+ * @package PHP_CodeSniffer
29
+ * @author Greg Sherwood <gsherwood@squiz.net>
30
+ * @author Marc McIntyre <mmcintyre@squiz.net>
31
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
32
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
33
+ * @version Release: @package_version@
34
+ * @link http://pear.php.net/package/PHP_CodeSniffer
35
+ */
36
+ class PHP_CodeSniffer_DocGenerators_HTML extends PHP_CodeSniffer_DocGenerators_Generator
37
+ {
38
+
39
+
40
+ /**
41
+ * Generates the documentation for a standard.
42
+ *
43
+ * @return void
44
+ * @see processSniff()
45
+ */
46
+ public function generate()
47
+ {
48
+ ob_start();
49
+ $this->printHeader();
50
+
51
+ $standardFiles = $this->getStandardFiles();
52
+ $this->printToc($standardFiles);
53
+
54
+ foreach ($standardFiles as $standard) {
55
+ $doc = new DOMDocument();
56
+ $doc->load($standard);
57
+ $documentation = $doc->getElementsByTagName('documentation')->item(0);
58
+ $this->processSniff($documentation);
59
+ }
60
+
61
+ $this->printFooter();
62
+
63
+ $content = ob_get_contents();
64
+ ob_end_clean();
65
+
66
+ echo $content;
67
+
68
+ }//end generate()
69
+
70
+
71
+ /**
72
+ * Print the header of the HTML page.
73
+ *
74
+ * @return void
75
+ */
76
+ protected function printHeader()
77
+ {
78
+ $standard = $this->getStandard();
79
+ echo '<html>'.PHP_EOL;
80
+ echo ' <head>'.PHP_EOL;
81
+ echo " <title>$standard Coding Standards</title>".PHP_EOL;
82
+ echo ' <style>
83
+ body {
84
+ background-color: #FFFFFF;
85
+ font-size: 14px;
86
+ font-family: Arial, Helvetica, sans-serif;
87
+ color: #000000;
88
+ }
89
+
90
+ h1 {
91
+ color: #666666;
92
+ font-size: 20px;
93
+ font-weight: bold;
94
+ margin-top: 0px;
95
+ background-color: #E6E7E8;
96
+ padding: 20px;
97
+ border: 1px solid #BBBBBB;
98
+ }
99
+
100
+ h2 {
101
+ color: #00A5E3;
102
+ font-size: 16px;
103
+ font-weight: normal;
104
+ margin-top: 50px;
105
+ }
106
+
107
+ .code-comparison {
108
+ width: 100%;
109
+ }
110
+
111
+ .code-comparison td {
112
+ border: 1px solid #CCCCCC;
113
+ }
114
+
115
+ .code-comparison-title, .code-comparison-code {
116
+ font-family: Arial, Helvetica, sans-serif;
117
+ font-size: 12px;
118
+ color: #000000;
119
+ vertical-align: top;
120
+ padding: 4px;
121
+ width: 50%;
122
+ background-color: #F1F1F1;
123
+ line-height: 15px;
124
+ }
125
+
126
+ .code-comparison-code {
127
+ font-family: Courier;
128
+ background-color: #F9F9F9;
129
+ }
130
+
131
+ .code-comparison-highlight {
132
+ background-color: #DDF1F7;
133
+ border: 1px solid #00A5E3;
134
+ line-height: 15px;
135
+ }
136
+
137
+ .tag-line {
138
+ text-align: center;
139
+ width: 100%;
140
+ margin-top: 30px;
141
+ font-size: 12px;
142
+ }
143
+
144
+ .tag-line a {
145
+ color: #000000;
146
+ }
147
+ </style>'.PHP_EOL;
148
+ echo ' </head>'.PHP_EOL;
149
+ echo ' <body>'.PHP_EOL;
150
+ echo " <h1>$standard Coding Standards</h1>".PHP_EOL;
151
+
152
+ }//end printHeader()
153
+
154
+
155
+ /**
156
+ * Print the table of contents for the standard.
157
+ *
158
+ * The TOC is just an unordered list of bookmarks to sniffs on the page.
159
+ *
160
+ * @param array $standardFiles An array of paths to the XML standard files.
161
+ *
162
+ * @return void
163
+ */
164
+ protected function printToc($standardFiles)
165
+ {
166
+ echo ' <h2>Table of Contents</h2>'.PHP_EOL;
167
+ echo ' <ul class="toc">'.PHP_EOL;
168
+
169
+ foreach ($standardFiles as $standard) {
170
+ $doc = new DOMDocument();
171
+ $doc->load($standard);
172
+ $documentation = $doc->getElementsByTagName('documentation')->item(0);
173
+ $title = $this->getTitle($documentation);
174
+ echo ' <li><a href="#'.str_replace(' ', '-', $title)."\">$title</a></li>".PHP_EOL;
175
+ }
176
+
177
+ echo ' </ul>'.PHP_EOL;
178
+
179
+ }//end printToc()
180
+
181
+
182
+ /**
183
+ * Print the footer of the HTML page.
184
+ *
185
+ * @return void
186
+ */
187
+ protected function printFooter()
188
+ {
189
+ // Turn off errors so we don't get timezone warnings if people
190
+ // don't have their timezone set.
191
+ $errorLevel = error_reporting(0);
192
+ echo ' <div class="tag-line">';
193
+ echo 'Documentation generated on '.date('r');
194
+ echo ' by <a href="https://github.com/squizlabs/PHP_CodeSniffer">PHP_CodeSniffer '.PHP_CodeSniffer::VERSION.'</a>';
195
+ echo '</div>'.PHP_EOL;
196
+ error_reporting($errorLevel);
197
+
198
+ echo ' </body>'.PHP_EOL;
199
+ echo '</html>'.PHP_EOL;
200
+
201
+ }//end printFooter()
202
+
203
+
204
+ /**
205
+ * Process the documentation for a single sniff.
206
+ *
207
+ * @param DOMNode $doc The DOMNode object for the sniff.
208
+ * It represents the "documentation" tag in the XML
209
+ * standard file.
210
+ *
211
+ * @return void
212
+ */
213
+ public function processSniff(DOMNode $doc)
214
+ {
215
+ $title = $this->getTitle($doc);
216
+ echo ' <a name="'.str_replace(' ', '-', $title).'" />'.PHP_EOL;
217
+ echo " <h2>$title</h2>".PHP_EOL;
218
+
219
+ foreach ($doc->childNodes as $node) {
220
+ if ($node->nodeName === 'standard') {
221
+ $this->printTextBlock($node);
222
+ } else if ($node->nodeName === 'code_comparison') {
223
+ $this->printCodeComparisonBlock($node);
224
+ }
225
+ }
226
+
227
+ }//end processSniff()
228
+
229
+
230
+ /**
231
+ * Print a text block found in a standard.
232
+ *
233
+ * @param DOMNode $node The DOMNode object for the text block.
234
+ *
235
+ * @return void
236
+ */
237
+ protected function printTextBlock($node)
238
+ {
239
+ $content = trim($node->nodeValue);
240
+ $content = htmlspecialchars($content);
241
+
242
+ // Allow em tags only.
243
+ $content = str_replace('&lt;em&gt;', '<em>', $content);
244
+ $content = str_replace('&lt;/em&gt;', '</em>', $content);
245
+
246
+ echo " <p class=\"text\">$content</p>".PHP_EOL;
247
+
248
+ }//end printTextBlock()
249
+
250
+
251
+ /**
252
+ * Print a code comparison block found in a standard.
253
+ *
254
+ * @param DOMNode $node The DOMNode object for the code comparison block.
255
+ *
256
+ * @return void
257
+ */
258
+ protected function printCodeComparisonBlock($node)
259
+ {
260
+ $codeBlocks = $node->getElementsByTagName('code');
261
+
262
+ $firstTitle = $codeBlocks->item(0)->getAttribute('title');
263
+ $first = trim($codeBlocks->item(0)->nodeValue);
264
+ $first = str_replace('<?php', '&lt;?php', $first);
265
+ $first = str_replace("\n", '</br>', $first);
266
+ $first = str_replace(' ', '&nbsp;', $first);
267
+ $first = str_replace('<em>', '<span class="code-comparison-highlight">', $first);
268
+ $first = str_replace('</em>', '</span>', $first);
269
+
270
+ $secondTitle = $codeBlocks->item(1)->getAttribute('title');
271
+ $second = trim($codeBlocks->item(1)->nodeValue);
272
+ $second = str_replace('<?php', '&lt;?php', $second);
273
+ $second = str_replace("\n", '</br>', $second);
274
+ $second = str_replace(' ', '&nbsp;', $second);
275
+ $second = str_replace('<em>', '<span class="code-comparison-highlight">', $second);
276
+ $second = str_replace('</em>', '</span>', $second);
277
+
278
+ echo ' <table class="code-comparison">'.PHP_EOL;
279
+ echo ' <tr>'.PHP_EOL;
280
+ echo " <td class=\"code-comparison-title\">$firstTitle</td>".PHP_EOL;
281
+ echo " <td class=\"code-comparison-title\">$secondTitle</td>".PHP_EOL;
282
+ echo ' </tr>'.PHP_EOL;
283
+ echo ' <tr>'.PHP_EOL;
284
+ echo " <td class=\"code-comparison-code\">$first</td>".PHP_EOL;
285
+ echo " <td class=\"code-comparison-code\">$second</td>".PHP_EOL;
286
+ echo ' </tr>'.PHP_EOL;
287
+ echo ' </table>'.PHP_EOL;
288
+
289
+ }//end printCodeComparisonBlock()
290
+
291
+
292
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/Markdown.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * A doc generator that outputs documentation in Markdown format.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Stefano Kowalke <blueduck@gmx.net>
10
+ * @copyright 2014 Arroba IT
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ if (class_exists('PHP_CodeSniffer_DocGenerators_Generator', true) === false) {
16
+ throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_DocGenerators_Generator not found');
17
+ }
18
+
19
+ /**
20
+ * A doc generator that outputs documentation in Markdown format.
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Stefano Kowalke <blueduck@gmx.net>
25
+ * @copyright 2014 Arroba IT
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class PHP_CodeSniffer_DocGenerators_Markdown extends PHP_CodeSniffer_DocGenerators_Generator
31
+ {
32
+
33
+
34
+ /**
35
+ * Generates the documentation for a standard.
36
+ *
37
+ * @return void
38
+ * @see processSniff()
39
+ */
40
+ public function generate()
41
+ {
42
+ ob_start();
43
+ $this->printHeader();
44
+
45
+ $standardFiles = $this->getStandardFiles();
46
+
47
+ foreach ($standardFiles as $standard) {
48
+ $doc = new DOMDocument();
49
+ $doc->load($standard);
50
+ $documentation = $doc->getElementsByTagName('documentation')->item(0);
51
+ $this->processSniff($documentation);
52
+ }
53
+
54
+ $this->printFooter();
55
+ $content = ob_get_contents();
56
+ ob_end_clean();
57
+
58
+ echo $content;
59
+
60
+ }//end generate()
61
+
62
+
63
+ /**
64
+ * Print the markdown header.
65
+ *
66
+ * @return void
67
+ */
68
+ protected function printHeader()
69
+ {
70
+ $standard = $this->getStandard();
71
+
72
+ echo "# $standard Coding Standard".PHP_EOL;
73
+
74
+ }//end printHeader()
75
+
76
+
77
+ /**
78
+ * Print the markdown footer.
79
+ *
80
+ * @return void
81
+ */
82
+ protected function printFooter()
83
+ {
84
+ // Turn off errors so we don't get timezone warnings if people
85
+ // don't have their timezone set.
86
+ error_reporting(0);
87
+ echo 'Documentation generated on '.date('r');
88
+ echo ' by [PHP_CodeSniffer '.PHP_CodeSniffer::VERSION.'](https://github.com/squizlabs/PHP_CodeSniffer)';
89
+
90
+ }//end printFooter()
91
+
92
+
93
+ /**
94
+ * Process the documentation for a single sniff.
95
+ *
96
+ * @param DOMNode $doc The DOMNode object for the sniff.
97
+ * It represents the "documentation" tag in the XML
98
+ * standard file.
99
+ *
100
+ * @return void
101
+ */
102
+ protected function processSniff(DOMNode $doc)
103
+ {
104
+ $title = $this->getTitle($doc);
105
+ echo "## $title".PHP_EOL;
106
+
107
+ foreach ($doc->childNodes as $node) {
108
+ if ($node->nodeName === 'standard') {
109
+ $this->printTextBlock($node);
110
+ } else if ($node->nodeName === 'code_comparison') {
111
+ $this->printCodeComparisonBlock($node);
112
+ }
113
+ }
114
+
115
+ }//end processSniff()
116
+
117
+
118
+ /**
119
+ * Print a text block found in a standard.
120
+ *
121
+ * @param DOMNode $node The DOMNode object for the text block.
122
+ *
123
+ * @return void
124
+ */
125
+ protected function printTextBlock(DOMNode $node)
126
+ {
127
+ $content = trim($node->nodeValue);
128
+ $content = htmlspecialchars($content);
129
+
130
+ $content = str_replace('&lt;em&gt;', '*', $content);
131
+ $content = str_replace('&lt;/em&gt;', '*', $content);
132
+
133
+ echo $content.PHP_EOL;
134
+
135
+ }//end printTextBlock()
136
+
137
+
138
+ /**
139
+ * Print a code comparison block found in a standard.
140
+ *
141
+ * @param DOMNode $node The DOMNode object for the code comparison block.
142
+ *
143
+ * @return void
144
+ */
145
+ protected function printCodeComparisonBlock(DOMNode $node)
146
+ {
147
+ $codeBlocks = $node->getElementsByTagName('code');
148
+
149
+ $firstTitle = $codeBlocks->item(0)->getAttribute('title');
150
+ $first = trim($codeBlocks->item(0)->nodeValue);
151
+ $first = str_replace("\n", "\n ", $first);
152
+ $first = str_replace('<em>', '', $first);
153
+ $first = str_replace('</em>', '', $first);
154
+
155
+ $secondTitle = $codeBlocks->item(1)->getAttribute('title');
156
+ $second = trim($codeBlocks->item(1)->nodeValue);
157
+ $second = str_replace("\n", "\n ", $second);
158
+ $second = str_replace('<em>', '', $second);
159
+ $second = str_replace('</em>', '', $second);
160
+
161
+ echo ' <table>'.PHP_EOL;
162
+ echo ' <tr>'.PHP_EOL;
163
+ echo " <th>$firstTitle</th>".PHP_EOL;
164
+ echo " <th>$secondTitle</th>".PHP_EOL;
165
+ echo ' </tr>'.PHP_EOL;
166
+ echo ' <tr>'.PHP_EOL;
167
+ echo '<td>'.PHP_EOL.PHP_EOL;
168
+ echo " $first".PHP_EOL.PHP_EOL;
169
+ echo '</td>'.PHP_EOL;
170
+ echo '<td>'.PHP_EOL.PHP_EOL;
171
+ echo " $second".PHP_EOL.PHP_EOL;
172
+ echo '</td>'.PHP_EOL;
173
+ echo ' </tr>'.PHP_EOL;
174
+ echo ' </table>'.PHP_EOL;
175
+
176
+ }//end printCodeComparisonBlock()
177
+
178
+
179
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/DocGenerators/Text.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * A doc generator that outputs text-based documentation.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ if (class_exists('PHP_CodeSniffer_DocGenerators_Generator', true) === false) {
17
+ throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_DocGenerators_Generator not found');
18
+ }
19
+
20
+ /**
21
+ * A doc generator that outputs text-based documentation.
22
+ *
23
+ * Output is designed to be displayed in a terminal and is wrapped to 100 characters.
24
+ *
25
+ * @category PHP
26
+ * @package PHP_CodeSniffer
27
+ * @author Greg Sherwood <gsherwood@squiz.net>
28
+ * @author Marc McIntyre <mmcintyre@squiz.net>
29
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
30
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
31
+ * @version Release: @package_version@
32
+ * @link http://pear.php.net/package/PHP_CodeSniffer
33
+ */
34
+ class PHP_CodeSniffer_DocGenerators_Text extends PHP_CodeSniffer_DocGenerators_Generator
35
+ {
36
+
37
+
38
+ /**
39
+ * Process the documentation for a single sniff.
40
+ *
41
+ * @param DOMNode $doc The DOMNode object for the sniff.
42
+ * It represents the "documentation" tag in the XML
43
+ * standard file.
44
+ *
45
+ * @return void
46
+ */
47
+ public function processSniff(DOMNode $doc)
48
+ {
49
+ $this->printTitle($doc);
50
+
51
+ foreach ($doc->childNodes as $node) {
52
+ if ($node->nodeName === 'standard') {
53
+ $this->printTextBlock($node);
54
+ } else if ($node->nodeName === 'code_comparison') {
55
+ $this->printCodeComparisonBlock($node);
56
+ }
57
+ }
58
+
59
+ }//end processSniff()
60
+
61
+
62
+ /**
63
+ * Prints the title area for a single sniff.
64
+ *
65
+ * @param DOMNode $doc The DOMNode object for the sniff.
66
+ * It represents the "documentation" tag in the XML
67
+ * standard file.
68
+ *
69
+ * @return void
70
+ */
71
+ protected function printTitle(DOMNode $doc)
72
+ {
73
+ $title = $this->getTitle($doc);
74
+ $standard = $this->getStandard();
75
+
76
+ echo PHP_EOL;
77
+ echo str_repeat('-', (strlen("$standard CODING STANDARD: $title") + 4));
78
+ echo strtoupper(PHP_EOL."| $standard CODING STANDARD: $title |".PHP_EOL);
79
+ echo str_repeat('-', (strlen("$standard CODING STANDARD: $title") + 4));
80
+ echo PHP_EOL.PHP_EOL;
81
+
82
+ }//end printTitle()
83
+
84
+
85
+ /**
86
+ * Print a text block found in a standard.
87
+ *
88
+ * @param DOMNode $node The DOMNode object for the text block.
89
+ *
90
+ * @return void
91
+ */
92
+ protected function printTextBlock($node)
93
+ {
94
+ $text = trim($node->nodeValue);
95
+ $text = str_replace('<em>', '*', $text);
96
+ $text = str_replace('</em>', '*', $text);
97
+
98
+ $lines = array();
99
+ $tempLine = '';
100
+ $words = explode(' ', $text);
101
+
102
+ foreach ($words as $word) {
103
+ if (strlen($tempLine.$word) >= 99) {
104
+ if (strlen($tempLine.$word) === 99) {
105
+ // Adding the extra space will push us to the edge
106
+ // so we are done.
107
+ $lines[] = $tempLine.$word;
108
+ $tempLine = '';
109
+ } else if (strlen($tempLine.$word) === 100) {
110
+ // We are already at the edge, so we are done.
111
+ $lines[] = $tempLine.$word;
112
+ $tempLine = '';
113
+ } else {
114
+ $lines[] = rtrim($tempLine);
115
+ $tempLine = $word.' ';
116
+ }
117
+ } else {
118
+ $tempLine .= $word.' ';
119
+ }
120
+ }//end foreach
121
+
122
+ if ($tempLine !== '') {
123
+ $lines[] = rtrim($tempLine);
124
+ }
125
+
126
+ echo implode(PHP_EOL, $lines).PHP_EOL.PHP_EOL;
127
+
128
+ }//end printTextBlock()
129
+
130
+
131
+ /**
132
+ * Print a code comparison block found in a standard.
133
+ *
134
+ * @param DOMNode $node The DOMNode object for the code comparison block.
135
+ *
136
+ * @return void
137
+ */
138
+ protected function printCodeComparisonBlock($node)
139
+ {
140
+ $codeBlocks = $node->getElementsByTagName('code');
141
+ $first = trim($codeBlocks->item(0)->nodeValue);
142
+ $firstTitle = $codeBlocks->item(0)->getAttribute('title');
143
+
144
+ $firstTitleLines = array();
145
+ $tempTitle = '';
146
+ $words = explode(' ', $firstTitle);
147
+
148
+ foreach ($words as $word) {
149
+ if (strlen($tempTitle.$word) >= 45) {
150
+ if (strlen($tempTitle.$word) === 45) {
151
+ // Adding the extra space will push us to the edge
152
+ // so we are done.
153
+ $firstTitleLines[] = $tempTitle.$word;
154
+ $tempTitle = '';
155
+ } else if (strlen($tempTitle.$word) === 46) {
156
+ // We are already at the edge, so we are done.
157
+ $firstTitleLines[] = $tempTitle.$word;
158
+ $tempTitle = '';
159
+ } else {
160
+ $firstTitleLines[] = $tempTitle;
161
+ $tempTitle = $word;
162
+ }
163
+ } else {
164
+ $tempTitle .= $word.' ';
165
+ }
166
+ }//end foreach
167
+
168
+ if ($tempTitle !== '') {
169
+ $firstTitleLines[] = $tempTitle;
170
+ }
171
+
172
+ $first = str_replace('<em>', '', $first);
173
+ $first = str_replace('</em>', '', $first);
174
+ $firstLines = explode("\n", $first);
175
+
176
+ $second = trim($codeBlocks->item(1)->nodeValue);
177
+ $secondTitle = $codeBlocks->item(1)->getAttribute('title');
178
+
179
+ $secondTitleLines = array();
180
+ $tempTitle = '';
181
+ $words = explode(' ', $secondTitle);
182
+
183
+ foreach ($words as $word) {
184
+ if (strlen($tempTitle.$word) >= 45) {
185
+ if (strlen($tempTitle.$word) === 45) {
186
+ // Adding the extra space will push us to the edge
187
+ // so we are done.
188
+ $secondTitleLines[] = $tempTitle.$word;
189
+ $tempTitle = '';
190
+ } else if (strlen($tempTitle.$word) === 46) {
191
+ // We are already at the edge, so we are done.
192
+ $secondTitleLines[] = $tempTitle.$word;
193
+ $tempTitle = '';
194
+ } else {
195
+ $secondTitleLines[] = $tempTitle;
196
+ $tempTitle = $word;
197
+ }
198
+ } else {
199
+ $tempTitle .= $word.' ';
200
+ }
201
+ }//end foreach
202
+
203
+ if ($tempTitle !== '') {
204
+ $secondTitleLines[] = $tempTitle;
205
+ }
206
+
207
+ $second = str_replace('<em>', '', $second);
208
+ $second = str_replace('</em>', '', $second);
209
+ $secondLines = explode("\n", $second);
210
+
211
+ $maxCodeLines = max(count($firstLines), count($secondLines));
212
+ $maxTitleLines = max(count($firstTitleLines), count($secondTitleLines));
213
+
214
+ echo str_repeat('-', 41);
215
+ echo ' CODE COMPARISON ';
216
+ echo str_repeat('-', 42).PHP_EOL;
217
+
218
+ for ($i = 0; $i < $maxTitleLines; $i++) {
219
+ if (isset($firstTitleLines[$i]) === true) {
220
+ $firstLineText = $firstTitleLines[$i];
221
+ } else {
222
+ $firstLineText = '';
223
+ }
224
+
225
+ if (isset($secondTitleLines[$i]) === true) {
226
+ $secondLineText = $secondTitleLines[$i];
227
+ } else {
228
+ $secondLineText = '';
229
+ }
230
+
231
+ echo '| ';
232
+ echo $firstLineText.str_repeat(' ', (46 - strlen($firstLineText)));
233
+ echo ' | ';
234
+ echo $secondLineText.str_repeat(' ', (47 - strlen($secondLineText)));
235
+ echo ' |'.PHP_EOL;
236
+ }//end for
237
+
238
+ echo str_repeat('-', 100).PHP_EOL;
239
+
240
+ for ($i = 0; $i < $maxCodeLines; $i++) {
241
+ if (isset($firstLines[$i]) === true) {
242
+ $firstLineText = $firstLines[$i];
243
+ } else {
244
+ $firstLineText = '';
245
+ }
246
+
247
+ if (isset($secondLines[$i]) === true) {
248
+ $secondLineText = $secondLines[$i];
249
+ } else {
250
+ $secondLineText = '';
251
+ }
252
+
253
+ echo '| ';
254
+ echo $firstLineText.str_repeat(' ', (47 - strlen($firstLineText)));
255
+ echo '| ';
256
+ echo $secondLineText.str_repeat(' ', (48 - strlen($secondLineText)));
257
+ echo '|'.PHP_EOL;
258
+ }//end for
259
+
260
+ echo str_repeat('-', 100).PHP_EOL.PHP_EOL;
261
+
262
+ }//end printCodeComparisonBlock()
263
+
264
+
265
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Exception.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * An exception thrown by PHP_CodeSniffer when it encounters an unrecoverable error.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * An exception thrown by PHP_CodeSniffer when it encounters an unrecoverable error.
18
+ *
19
+ * @category PHP
20
+ * @package PHP_CodeSniffer
21
+ * @author Greg Sherwood <gsherwood@squiz.net>
22
+ * @author Marc McIntyre <mmcintyre@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class PHP_CodeSniffer_Exception extends Exception
29
+ {
30
+
31
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/File.php ADDED
@@ -0,0 +1,3814 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * A PHP_CodeSniffer_File object represents a PHP source file and the tokens
4
+ * associated with it.
5
+ *
6
+ * PHP version 5
7
+ *
8
+ * @category PHP
9
+ * @package PHP_CodeSniffer
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @author Marc McIntyre <mmcintyre@squiz.net>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * A PHP_CodeSniffer_File object represents a PHP source file and the tokens
19
+ * associated with it.
20
+ *
21
+ * It provides a means for traversing the token stack, along with
22
+ * other token related operations. If a PHP_CodeSniffer_Sniff finds and error or
23
+ * warning within a PHP_CodeSniffer_File, you can raise an error using the
24
+ * addError() or addWarning() methods.
25
+ *
26
+ * <b>Token Information</b>
27
+ *
28
+ * Each token within the stack contains information about itself:
29
+ *
30
+ * <code>
31
+ * array(
32
+ * 'code' => 301, // the token type code (see token_get_all())
33
+ * 'content' => 'if', // the token content
34
+ * 'type' => 'T_IF', // the token name
35
+ * 'line' => 56, // the line number when the token is located
36
+ * 'column' => 12, // the column in the line where this token
37
+ * // starts (starts from 1)
38
+ * 'level' => 2 // the depth a token is within the scopes open
39
+ * 'conditions' => array( // a list of scope condition token
40
+ * // positions => codes that
41
+ * 2 => 50, // opened the scopes that this token exists
42
+ * 9 => 353, // in (see conditional tokens section below)
43
+ * ),
44
+ * );
45
+ * </code>
46
+ *
47
+ * <b>Conditional Tokens</b>
48
+ *
49
+ * In addition to the standard token fields, conditions contain information to
50
+ * determine where their scope begins and ends:
51
+ *
52
+ * <code>
53
+ * array(
54
+ * 'scope_condition' => 38, // the token position of the condition
55
+ * 'scope_opener' => 41, // the token position that started the scope
56
+ * 'scope_closer' => 70, // the token position that ended the scope
57
+ * );
58
+ * </code>
59
+ *
60
+ * The condition, the scope opener and the scope closer each contain this
61
+ * information.
62
+ *
63
+ * <b>Parenthesis Tokens</b>
64
+ *
65
+ * Each parenthesis token (T_OPEN_PARENTHESIS and T_CLOSE_PARENTHESIS) has a
66
+ * reference to their opening and closing parenthesis, one being itself, the
67
+ * other being its opposite.
68
+ *
69
+ * <code>
70
+ * array(
71
+ * 'parenthesis_opener' => 34,
72
+ * 'parenthesis_closer' => 40,
73
+ * );
74
+ * </code>
75
+ *
76
+ * Some tokens can "own" a set of parenthesis. For example a T_FUNCTION token
77
+ * has parenthesis around its argument list. These tokens also have the
78
+ * parenthesis_opener and and parenthesis_closer indices. Not all parenthesis
79
+ * have owners, for example parenthesis used for arithmetic operations and
80
+ * function calls. The parenthesis tokens that have an owner have the following
81
+ * auxiliary array indices.
82
+ *
83
+ * <code>
84
+ * array(
85
+ * 'parenthesis_opener' => 34,
86
+ * 'parenthesis_closer' => 40,
87
+ * 'parenthesis_owner' => 33,
88
+ * );
89
+ * </code>
90
+ *
91
+ * Each token within a set of parenthesis also has an array index
92
+ * 'nested_parenthesis' which is an array of the
93
+ * left parenthesis => right parenthesis token positions.
94
+ *
95
+ * <code>
96
+ * 'nested_parenthesis' => array(
97
+ * 12 => 15
98
+ * 11 => 14
99
+ * );
100
+ * </code>
101
+ *
102
+ * <b>Extended Tokens</b>
103
+ *
104
+ * PHP_CodeSniffer extends and augments some of the tokens created by
105
+ * <i>token_get_all()</i>. A full list of these tokens can be seen in the
106
+ * <i>Tokens.php</i> file.
107
+ *
108
+ * @category PHP
109
+ * @package PHP_CodeSniffer
110
+ * @author Greg Sherwood <gsherwood@squiz.net>
111
+ * @author Marc McIntyre <mmcintyre@squiz.net>
112
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
113
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
114
+ * @version Release: @package_version@
115
+ * @link http://pear.php.net/package/PHP_CodeSniffer
116
+ */
117
+ class PHP_CodeSniffer_File
118
+ {
119
+
120
+ /**
121
+ * The absolute path to the file associated with this object.
122
+ *
123
+ * @var string
124
+ */
125
+ private $_file = '';
126
+
127
+ /**
128
+ * The EOL character this file uses.
129
+ *
130
+ * @var string
131
+ */
132
+ public $eolChar = '';
133
+
134
+ /**
135
+ * The PHP_CodeSniffer object controlling this run.
136
+ *
137
+ * @var PHP_CodeSniffer
138
+ */
139
+ public $phpcs = null;
140
+
141
+ /**
142
+ * The Fixer object to control fixing errors.
143
+ *
144
+ * @var PHP_CodeSniffer_Fixer
145
+ */
146
+ public $fixer = null;
147
+
148
+ /**
149
+ * The tokenizer being used for this file.
150
+ *
151
+ * @var object
152
+ */
153
+ public $tokenizer = null;
154
+
155
+ /**
156
+ * The tokenizer being used for this file.
157
+ *
158
+ * @var string
159
+ */
160
+ public $tokenizerType = 'PHP';
161
+
162
+ /**
163
+ * The number of tokens in this file.
164
+ *
165
+ * Stored here to save calling count() everywhere.
166
+ *
167
+ * @var int
168
+ */
169
+ public $numTokens = 0;
170
+
171
+ /**
172
+ * The tokens stack map.
173
+ *
174
+ * Note that the tokens in this array differ in format to the tokens
175
+ * produced by token_get_all(). Tokens are initially produced with
176
+ * token_get_all(), then augmented so that it's easier to process them.
177
+ *
178
+ * @var array()
179
+ * @see Tokens.php
180
+ */
181
+ private $_tokens = array();
182
+
183
+ /**
184
+ * The errors raised from PHP_CodeSniffer_Sniffs.
185
+ *
186
+ * @var array()
187
+ * @see getErrors()
188
+ */
189
+ private $_errors = array();
190
+
191
+ /**
192
+ * The warnings raised from PHP_CodeSniffer_Sniffs.
193
+ *
194
+ * @var array()
195
+ * @see getWarnings()
196
+ */
197
+ private $_warnings = array();
198
+
199
+ /**
200
+ * The metrics recorded from PHP_CodeSniffer_Sniffs.
201
+ *
202
+ * @var array()
203
+ * @see getMetrics()
204
+ */
205
+ private $_metrics = array();
206
+
207
+ /**
208
+ * Record the errors and warnings raised.
209
+ *
210
+ * @var bool
211
+ */
212
+ private $_recordErrors = true;
213
+
214
+ /**
215
+ * An array of lines that are being ignored.
216
+ *
217
+ * @var array()
218
+ */
219
+ private static $_ignoredLines = array();
220
+
221
+ /**
222
+ * An array of sniffs that are being ignored.
223
+ *
224
+ * @var array()
225
+ */
226
+ private $_ignoredListeners = array();
227
+
228
+ /**
229
+ * An array of message codes that are being ignored.
230
+ *
231
+ * @var array()
232
+ */
233
+ private $_ignoredCodes = array();
234
+
235
+ /**
236
+ * The total number of errors raised.
237
+ *
238
+ * @var int
239
+ */
240
+ private $_errorCount = 0;
241
+
242
+ /**
243
+ * The total number of warnings raised.
244
+ *
245
+ * @var int
246
+ */
247
+ private $_warningCount = 0;
248
+
249
+ /**
250
+ * The total number of errors/warnings that can be fixed.
251
+ *
252
+ * @var int
253
+ */
254
+ private $_fixableCount = 0;
255
+
256
+ /**
257
+ * An array of sniffs listening to this file's processing.
258
+ *
259
+ * @var array(PHP_CodeSniffer_Sniff)
260
+ */
261
+ private $_listeners = array();
262
+
263
+ /**
264
+ * The class name of the sniff currently processing the file.
265
+ *
266
+ * @var string
267
+ */
268
+ private $_activeListener = '';
269
+
270
+ /**
271
+ * An array of sniffs being processed and how long they took.
272
+ *
273
+ * @var array()
274
+ */
275
+ private $_listenerTimes = array();
276
+
277
+ /**
278
+ * An array of rules from the ruleset.xml file.
279
+ *
280
+ * This value gets set by PHP_CodeSniffer when the object is created.
281
+ * It may be empty, indicating that the ruleset does not override
282
+ * any of the default sniff settings.
283
+ *
284
+ * @var array
285
+ */
286
+ protected $ruleset = array();
287
+
288
+
289
+ /**
290
+ * Constructs a PHP_CodeSniffer_File.
291
+ *
292
+ * @param string $file The absolute path to the file to process.
293
+ * @param array(string) $listeners The initial listeners listening to processing of this file.
294
+ * to processing of this file.
295
+ * @param array $ruleset An array of rules from the ruleset.xml file.
296
+ * ruleset.xml file.
297
+ * @param PHP_CodeSniffer $phpcs The PHP_CodeSniffer object controlling this run.
298
+ * this run.
299
+ *
300
+ * @throws PHP_CodeSniffer_Exception If the register() method does
301
+ * not return an array.
302
+ */
303
+ public function __construct(
304
+ $file,
305
+ array $listeners,
306
+ array $ruleset,
307
+ PHP_CodeSniffer $phpcs
308
+ ) {
309
+ $this->_file = trim($file);
310
+ $this->_listeners = $listeners;
311
+ $this->ruleset = $ruleset;
312
+ $this->phpcs = $phpcs;
313
+ $this->fixer = new PHP_CodeSniffer_Fixer();
314
+
315
+ if (PHP_CODESNIFFER_INTERACTIVE === false) {
316
+ $cliValues = $phpcs->cli->getCommandLineValues();
317
+ if (isset($cliValues['showSources']) === true
318
+ && $cliValues['showSources'] !== true
319
+ ) {
320
+ $recordErrors = false;
321
+ foreach ($cliValues['reports'] as $report => $output) {
322
+ $reportClass = $phpcs->reporting->factory($report);
323
+ if (property_exists($reportClass, 'recordErrors') === false
324
+ || $reportClass->recordErrors === true
325
+ ) {
326
+ $recordErrors = true;
327
+ break;
328
+ }
329
+ }
330
+
331
+ $this->_recordErrors = $recordErrors;
332
+ }
333
+ }
334
+
335
+ }//end __construct()
336
+
337
+
338
+ /**
339
+ * Sets the name of the currently active sniff.
340
+ *
341
+ * @param string $activeListener The class name of the current sniff.
342
+ *
343
+ * @return void
344
+ */
345
+ public function setActiveListener($activeListener)
346
+ {
347
+ $this->_activeListener = $activeListener;
348
+
349
+ }//end setActiveListener()
350
+
351
+
352
+ /**
353
+ * Adds a listener to the token stack that listens to the specific tokens.
354
+ *
355
+ * When PHP_CodeSniffer encounters on the the tokens specified in $tokens,
356
+ * it invokes the process method of the sniff.
357
+ *
358
+ * @param PHP_CodeSniffer_Sniff $listener The listener to add to the
359
+ * listener stack.
360
+ * @param array(int) $tokens The token types the listener wishes to
361
+ * listen to.
362
+ *
363
+ * @return void
364
+ */
365
+ public function addTokenListener(PHP_CodeSniffer_Sniff $listener, array $tokens)
366
+ {
367
+ $class = get_class($listener);
368
+ foreach ($tokens as $token) {
369
+ if (isset($this->_listeners[$token]) === false) {
370
+ $this->_listeners[$token] = array();
371
+ }
372
+
373
+ if (isset($this->_listeners[$token][$class]) === false) {
374
+ $this->_listeners[$token][$class] = $listener;
375
+ }
376
+ }
377
+
378
+ }//end addTokenListener()
379
+
380
+
381
+ /**
382
+ * Removes a listener from listening from the specified tokens.
383
+ *
384
+ * @param PHP_CodeSniffer_Sniff $listener The listener to remove from the
385
+ * listener stack.
386
+ * @param array(int) $tokens The token types the listener wishes to
387
+ * stop listen to.
388
+ *
389
+ * @return void
390
+ */
391
+ public function removeTokenListener(
392
+ PHP_CodeSniffer_Sniff $listener,
393
+ array $tokens
394
+ ) {
395
+ $class = get_class($listener);
396
+ foreach ($tokens as $token) {
397
+ if (isset($this->_listeners[$token]) === false) {
398
+ continue;
399
+ }
400
+
401
+ unset($this->_listeners[$token][$class]);
402
+ }
403
+
404
+ }//end removeTokenListener()
405
+
406
+
407
+ /**
408
+ * Rebuilds the list of listeners to ensure their state is cleared.
409
+ *
410
+ * @return void
411
+ */
412
+ public function refreshTokenListeners()
413
+ {
414
+ $this->phpcs->populateTokenListeners();
415
+ $this->_listeners = $this->phpcs->getTokenSniffs();
416
+
417
+ }//end refreshTokenListeners()
418
+
419
+
420
+ /**
421
+ * Returns the token stack for this file.
422
+ *
423
+ * @return array
424
+ */
425
+ public function getTokens()
426
+ {
427
+ return $this->_tokens;
428
+
429
+ }//end getTokens()
430
+
431
+
432
+ /**
433
+ * Starts the stack traversal and tells listeners when tokens are found.
434
+ *
435
+ * @param string $contents The contents to parse. If NULL, the content
436
+ * is taken from the file system.
437
+ *
438
+ * @return void
439
+ */
440
+ public function start($contents=null)
441
+ {
442
+ $this->_errors = array();
443
+ $this->_warnings = array();
444
+ $this->_errorCount = 0;
445
+ $this->_warningCount = 0;
446
+ $this->_fixableCount = 0;
447
+
448
+ // Reset the ignored lines because lines numbers may have changed
449
+ // if we are fixing this file.
450
+ self::$_ignoredLines = array();
451
+
452
+ try {
453
+ $this->eolChar = self::detectLineEndings($this->_file, $contents);
454
+ } catch (PHP_CodeSniffer_Exception $e) {
455
+ $this->addWarning($e->getMessage(), null, 'Internal.DetectLineEndings');
456
+ return;
457
+ }
458
+
459
+ // If this is standard input, see if a filename was passed in as well.
460
+ // This is done by including: phpcs_input_file: [file path]
461
+ // as the first line of content.
462
+ if ($this->_file === 'STDIN') {
463
+ $cliValues = $this->phpcs->cli->getCommandLineValues();
464
+ if ($cliValues['stdinPath'] !== '') {
465
+ $this->_file = $cliValues['stdinPath'];
466
+ } else if ($contents !== null && substr($contents, 0, 17) === 'phpcs_input_file:') {
467
+ $eolPos = strpos($contents, $this->eolChar);
468
+ $filename = trim(substr($contents, 17, ($eolPos - 17)));
469
+ $contents = substr($contents, ($eolPos + strlen($this->eolChar)));
470
+ $this->_file = $filename;
471
+ }
472
+ }
473
+
474
+ $this->_parse($contents);
475
+ $this->fixer->startFile($this);
476
+
477
+ if (PHP_CODESNIFFER_VERBOSITY > 2) {
478
+ echo "\t*** START TOKEN PROCESSING ***".PHP_EOL;
479
+ }
480
+
481
+ $foundCode = false;
482
+ $listeners = $this->phpcs->getSniffs();
483
+ $listenerIgnoreTo = array();
484
+ $inTests = defined('PHP_CODESNIFFER_IN_TESTS');
485
+
486
+ // Foreach of the listeners that have registered to listen for this
487
+ // token, get them to process it.
488
+ foreach ($this->_tokens as $stackPtr => $token) {
489
+ // Check for ignored lines.
490
+ if ($token['code'] === T_COMMENT
491
+ || $token['code'] === T_DOC_COMMENT_TAG
492
+ || ($inTests === true && $token['code'] === T_INLINE_HTML)
493
+ ) {
494
+ if (strpos($token['content'], '@codingStandards') !== false) {
495
+ if (strpos($token['content'], '@codingStandardsIgnoreFile') !== false) {
496
+ // Ignoring the whole file, just a little late.
497
+ $this->_errors = array();
498
+ $this->_warnings = array();
499
+ $this->_errorCount = 0;
500
+ $this->_warningCount = 0;
501
+ $this->_fixableCount = 0;
502
+ return;
503
+ } else if (strpos($token['content'], '@codingStandardsChangeSetting') !== false) {
504
+ $start = strpos($token['content'], '@codingStandardsChangeSetting');
505
+ $comment = substr($token['content'], ($start + 30));
506
+ $parts = explode(' ', $comment);
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
518
+ }//end if
519
+
520
+ if (PHP_CODESNIFFER_VERBOSITY > 2) {
521
+ $type = $token['type'];
522
+ $content = PHP_CodeSniffer::prepareForOutput($token['content']);
523
+ echo "\t\tProcess token $stackPtr: $type => $content".PHP_EOL;
524
+ }
525
+
526
+ if ($token['code'] !== T_INLINE_HTML) {
527
+ $foundCode = true;
528
+ }
529
+
530
+ if (isset($this->_listeners[$token['code']]) === false) {
531
+ continue;
532
+ }
533
+
534
+ foreach ($this->_listeners[$token['code']] as $listenerData) {
535
+ if (isset($this->_ignoredListeners[$listenerData['class']]) === true
536
+ || (isset($listenerIgnoreTo[$listenerData['class']]) === true
537
+ && $listenerIgnoreTo[$listenerData['class']] > $stackPtr)
538
+ ) {
539
+ // This sniff is ignoring past this token, or the whole file.
540
+ continue;
541
+ }
542
+
543
+ // Make sure this sniff supports the tokenizer
544
+ // we are currently using.
545
+ $class = $listenerData['class'];
546
+
547
+ if (isset($listenerData['tokenizers'][$this->tokenizerType]) === false) {
548
+ continue;
549
+ }
550
+
551
+ // If the file path matches one of our ignore patterns, skip it.
552
+ // While there is support for a type of each pattern
553
+ // (absolute or relative) we don't actually support it here.
554
+ foreach ($listenerData['ignore'] as $pattern) {
555
+ // We assume a / directory separator, as do the exclude rules
556
+ // most developers write, so we need a special case for any system
557
+ // that is different.
558
+ if (DIRECTORY_SEPARATOR === '\\') {
559
+ $pattern = str_replace('/', '\\\\', $pattern);
560
+ }
561
+
562
+ $pattern = '`'.$pattern.'`i';
563
+ if (preg_match($pattern, $this->_file) === 1) {
564
+ $this->_ignoredListeners[$class] = true;
565
+ continue(2);
566
+ }
567
+ }
568
+
569
+ $this->_activeListener = $class;
570
+
571
+ if (PHP_CODESNIFFER_VERBOSITY > 2) {
572
+ $startTime = microtime(true);
573
+ echo "\t\t\tProcessing ".$this->_activeListener.'... ';
574
+ }
575
+
576
+ $ignoreTo = $listeners[$class]->process($this, $stackPtr);
577
+ if ($ignoreTo !== null) {
578
+ $listenerIgnoreTo[$this->_activeListener] = $ignoreTo;
579
+ }
580
+
581
+ if (PHP_CODESNIFFER_VERBOSITY > 2) {
582
+ $timeTaken = (microtime(true) - $startTime);
583
+ if (isset($this->_listenerTimes[$this->_activeListener]) === false) {
584
+ $this->_listenerTimes[$this->_activeListener] = 0;
585
+ }
586
+
587
+ $this->_listenerTimes[$this->_activeListener] += $timeTaken;
588
+
589
+ $timeTaken = round(($timeTaken), 4);
590
+ echo "DONE in $timeTaken seconds".PHP_EOL;
591
+ }
592
+
593
+ $this->_activeListener = '';
594
+ }//end foreach
595
+ }//end foreach
596
+
597
+ if ($this->_recordErrors === false) {
598
+ $this->_errors = array();
599
+ $this->_warnings = array();
600
+ }
601
+
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.';
612
+ $this->addWarning($error, null, 'Internal.NoCodeFound');
613
+ }
614
+ }
615
+
616
+ if (PHP_CODESNIFFER_VERBOSITY > 2) {
617
+ echo "\t*** END TOKEN PROCESSING ***".PHP_EOL;
618
+ echo "\t*** START SNIFF PROCESSING REPORT ***".PHP_EOL;
619
+
620
+ asort($this->_listenerTimes, SORT_NUMERIC);
621
+ $this->_listenerTimes = array_reverse($this->_listenerTimes, true);
622
+ foreach ($this->_listenerTimes as $listener => $timeTaken) {
623
+ echo "\t$listener: ".round(($timeTaken), 4).' secs'.PHP_EOL;
624
+ }
625
+
626
+ echo "\t*** END SNIFF PROCESSING REPORT ***".PHP_EOL;
627
+ }
628
+
629
+ }//end start()
630
+
631
+
632
+ /**
633
+ * Remove vars stored in this file that are no longer required.
634
+ *
635
+ * @return void
636
+ */
637
+ public function cleanUp()
638
+ {
639
+ $this->_tokens = null;
640
+ $this->_listeners = null;
641
+
642
+ }//end cleanUp()
643
+
644
+
645
+ /**
646
+ * Tokenizes the file and prepares it for the test run.
647
+ *
648
+ * @param string $contents The contents to parse. If NULL, the content
649
+ * is taken from the file system.
650
+ *
651
+ * @return void
652
+ */
653
+ private function _parse($contents=null)
654
+ {
655
+ if ($contents === null && empty($this->_tokens) === false) {
656
+ // File has already been parsed.
657
+ return;
658
+ }
659
+
660
+ $stdin = false;
661
+ $cliValues = $this->phpcs->cli->getCommandLineValues();
662
+ if (empty($cliValues['files']) === true) {
663
+ $stdin = true;
664
+ }
665
+
666
+ // Determine the tokenizer from the file extension.
667
+ $fileParts = explode('.', $this->_file);
668
+ $extension = array_pop($fileParts);
669
+ if (isset($this->phpcs->allowedFileExtensions[$extension]) === true) {
670
+ $tokenizerClass = 'PHP_CodeSniffer_Tokenizers_'.$this->phpcs->allowedFileExtensions[$extension];
671
+ $this->tokenizerType = $this->phpcs->allowedFileExtensions[$extension];
672
+ } else if (isset($this->phpcs->defaultFileExtensions[$extension]) === true) {
673
+ $tokenizerClass = 'PHP_CodeSniffer_Tokenizers_'.$this->phpcs->defaultFileExtensions[$extension];
674
+ $this->tokenizerType = $this->phpcs->defaultFileExtensions[$extension];
675
+ } else {
676
+ // Revert to default.
677
+ $tokenizerClass = 'PHP_CodeSniffer_Tokenizers_'.$this->tokenizerType;
678
+ }
679
+
680
+ $tokenizer = new $tokenizerClass();
681
+ $this->tokenizer = $tokenizer;
682
+
683
+ if ($contents === null) {
684
+ $contents = file_get_contents($this->_file);
685
+ }
686
+
687
+ try {
688
+ $tabWidth = null;
689
+ $encoding = null;
690
+ if (defined('PHP_CODESNIFFER_IN_TESTS') === true) {
691
+ $cliValues = $this->phpcs->cli->getCommandLineValues();
692
+ if (isset($cliValues['tabWidth']) === true) {
693
+ $tabWidth = $cliValues['tabWidth'];
694
+ }
695
+
696
+ if (isset($cliValues['encoding']) === true) {
697
+ $encoding = $cliValues['encoding'];
698
+ }
699
+ }
700
+
701
+ $this->_tokens = self::tokenizeString($contents, $tokenizer, $this->eolChar, $tabWidth, $encoding);
702
+ } catch (PHP_CodeSniffer_Exception $e) {
703
+ $this->addWarning($e->getMessage(), null, 'Internal.Tokenizer.Exception');
704
+ if (PHP_CODESNIFFER_VERBOSITY > 0 || (PHP_CODESNIFFER_CBF === true && $stdin === false)) {
705
+ echo "[$this->tokenizerType => tokenizer error]... ";
706
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
707
+ echo PHP_EOL;
708
+ }
709
+ }
710
+
711
+ return;
712
+ }//end try
713
+
714
+ $this->numTokens = count($this->_tokens);
715
+
716
+ // Check for mixed line endings as these can cause tokenizer errors and we
717
+ // should let the user know that the results they get may be incorrect.
718
+ // This is done by removing all backslashes, removing the newline char we
719
+ // detected, then converting newlines chars into text. If any backslashes
720
+ // are left at the end, we have additional newline chars in use.
721
+ $contents = str_replace('\\', '', $contents);
722
+ $contents = str_replace($this->eolChar, '', $contents);
723
+ $contents = str_replace("\n", '\n', $contents);
724
+ $contents = str_replace("\r", '\r', $contents);
725
+ if (strpos($contents, '\\') !== false) {
726
+ $error = 'File has mixed line endings; this may cause incorrect results';
727
+ $this->addWarning($error, 0, 'Internal.LineEndings.Mixed');
728
+ }
729
+
730
+ if (PHP_CODESNIFFER_VERBOSITY > 0 || (PHP_CODESNIFFER_CBF === true && $stdin === false)) {
731
+ if ($this->numTokens === 0) {
732
+ $numLines = 0;
733
+ } else {
734
+ $numLines = $this->_tokens[($this->numTokens - 1)]['line'];
735
+ }
736
+
737
+ echo "[$this->tokenizerType => $this->numTokens tokens in $numLines lines]... ";
738
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
739
+ echo PHP_EOL;
740
+ }
741
+ }
742
+
743
+ }//end _parse()
744
+
745
+
746
+ /**
747
+ * Opens a file and detects the EOL character being used.
748
+ *
749
+ * @param string $file The full path to the file.
750
+ * @param string $contents The contents to parse. If NULL, the content
751
+ * is taken from the file system.
752
+ *
753
+ * @return string
754
+ * @throws PHP_CodeSniffer_Exception If $file could not be opened.
755
+ */
756
+ public static function detectLineEndings($file, $contents=null)
757
+ {
758
+ if ($contents === null) {
759
+ // Determine the newline character being used in this file.
760
+ // Will be either \r, \r\n or \n.
761
+ if (is_readable($file) === false) {
762
+ $error = 'Error opening file; file no longer exists or you do not have access to read the file';
763
+ throw new PHP_CodeSniffer_Exception($error);
764
+ } else {
765
+ $handle = fopen($file, 'r');
766
+ if ($handle === false) {
767
+ $error = 'Error opening file; could not auto-detect line endings';
768
+ throw new PHP_CodeSniffer_Exception($error);
769
+ }
770
+ }
771
+
772
+ $firstLine = fgets($handle);
773
+ fclose($handle);
774
+
775
+ $eolChar = substr($firstLine, -1);
776
+ if ($eolChar === "\n") {
777
+ $secondLastChar = substr($firstLine, -2, 1);
778
+ if ($secondLastChar === "\r") {
779
+ $eolChar = "\r\n";
780
+ }
781
+ } else if ($eolChar !== "\r") {
782
+ // Must not be an EOL char at the end of the line.
783
+ // Probably a one-line file, so assume \n as it really
784
+ // doesn't matter considering there are no newlines.
785
+ $eolChar = "\n";
786
+ }
787
+ } else {
788
+ if (preg_match("/\r\n?|\n/", $contents, $matches) !== 1) {
789
+ // Assuming there are no newlines.
790
+ $eolChar = "\n";
791
+ } else {
792
+ $eolChar = $matches[0];
793
+ }
794
+ }//end if
795
+
796
+ return $eolChar;
797
+
798
+ }//end detectLineEndings()
799
+
800
+
801
+ /**
802
+ * Records an error against a specific token in the file.
803
+ *
804
+ * @param string $error The error message.
805
+ * @param int $stackPtr The stack position where the error occurred.
806
+ * @param string $code A violation code unique to the sniff message.
807
+ * @param array $data Replacements for the error message.
808
+ * @param int $severity The severity level for this error. A value of 0
809
+ * will be converted into the default severity level.
810
+ * @param boolean $fixable Can the error be fixed by the sniff?
811
+ *
812
+ * @return boolean
813
+ */
814
+ public function addError(
815
+ $error,
816
+ $stackPtr,
817
+ $code='',
818
+ $data=array(),
819
+ $severity=0,
820
+ $fixable=false
821
+ ) {
822
+ if ($stackPtr === null) {
823
+ $line = 1;
824
+ $column = 1;
825
+ } else {
826
+ $line = $this->_tokens[$stackPtr]['line'];
827
+ $column = $this->_tokens[$stackPtr]['column'];
828
+ }
829
+
830
+ return $this->_addError($error, $line, $column, $code, $data, $severity, $fixable);
831
+
832
+ }//end addError()
833
+
834
+
835
+ /**
836
+ * Records a warning against a specific token in the file.
837
+ *
838
+ * @param string $warning The error message.
839
+ * @param int $stackPtr The stack position where the error occurred.
840
+ * @param string $code A violation code unique to the sniff message.
841
+ * @param array $data Replacements for the warning message.
842
+ * @param int $severity The severity level for this warning. A value of 0
843
+ * will be converted into the default severity level.
844
+ * @param boolean $fixable Can the warning be fixed by the sniff?
845
+ *
846
+ * @return boolean
847
+ */
848
+ public function addWarning(
849
+ $warning,
850
+ $stackPtr,
851
+ $code='',
852
+ $data=array(),
853
+ $severity=0,
854
+ $fixable=false
855
+ ) {
856
+ if ($stackPtr === null) {
857
+ $line = 1;
858
+ $column = 1;
859
+ } else {
860
+ $line = $this->_tokens[$stackPtr]['line'];
861
+ $column = $this->_tokens[$stackPtr]['column'];
862
+ }
863
+
864
+ return $this->_addWarning($warning, $line, $column, $code, $data, $severity, $fixable);
865
+
866
+ }//end addWarning()
867
+
868
+
869
+ /**
870
+ * Records an error against a specific line in the file.
871
+ *
872
+ * @param string $error The error message.
873
+ * @param int $line The line on which the error occurred.
874
+ * @param string $code A violation code unique to the sniff message.
875
+ * @param array $data Replacements for the error message.
876
+ * @param int $severity The severity level for this error. A value of 0
877
+ * will be converted into the default severity level.
878
+ *
879
+ * @return boolean
880
+ */
881
+ public function addErrorOnLine(
882
+ $error,
883
+ $line,
884
+ $code='',
885
+ $data=array(),
886
+ $severity=0
887
+ ) {
888
+ return $this->_addError($error, $line, 1, $code, $data, $severity, false);
889
+
890
+ }//end addErrorOnLine()
891
+
892
+
893
+ /**
894
+ * Records a warning against a specific token in the file.
895
+ *
896
+ * @param string $warning The error message.
897
+ * @param int $line The line on which the warning occurred.
898
+ * @param string $code A violation code unique to the sniff message.
899
+ * @param array $data Replacements for the warning message.
900
+ * @param int $severity The severity level for this warning. A value of 0
901
+ * will be converted into the default severity level.
902
+ *
903
+ * @return boolean
904
+ */
905
+ public function addWarningOnLine(
906
+ $warning,
907
+ $line,
908
+ $code='',
909
+ $data=array(),
910
+ $severity=0
911
+ ) {
912
+ return $this->_addWarning($warning, $line, 1, $code, $data, $severity, false);
913
+
914
+ }//end addWarningOnLine()
915
+
916
+
917
+ /**
918
+ * Records a fixable error against a specific token in the file.
919
+ *
920
+ * Returns true if the error was recorded and should be fixed.
921
+ *
922
+ * @param string $error The error message.
923
+ * @param int $stackPtr The stack position where the error occurred.
924
+ * @param string $code A violation code unique to the sniff message.
925
+ * @param array $data Replacements for the error message.
926
+ * @param int $severity The severity level for this error. A value of 0
927
+ * will be converted into the default severity level.
928
+ *
929
+ * @return boolean
930
+ */
931
+ public function addFixableError(
932
+ $error,
933
+ $stackPtr,
934
+ $code='',
935
+ $data=array(),
936
+ $severity=0
937
+ ) {
938
+ $recorded = $this->addError($error, $stackPtr, $code, $data, $severity, true);
939
+ if ($recorded === true && $this->fixer->enabled === true) {
940
+ return true;
941
+ }
942
+
943
+ return false;
944
+
945
+ }//end addFixableError()
946
+
947
+
948
+ /**
949
+ * Records a fixable warning against a specific token in the file.
950
+ *
951
+ * Returns true if the warning was recorded and should be fixed.
952
+ *
953
+ * @param string $warning The error message.
954
+ * @param int $stackPtr The stack position where the error occurred.
955
+ * @param string $code A violation code unique to the sniff message.
956
+ * @param array $data Replacements for the warning message.
957
+ * @param int $severity The severity level for this warning. A value of 0
958
+ * will be converted into the default severity level.
959
+ *
960
+ * @return boolean
961
+ */
962
+ public function addFixableWarning(
963
+ $warning,
964
+ $stackPtr,
965
+ $code='',
966
+ $data=array(),
967
+ $severity=0
968
+ ) {
969
+ $recorded = $this->addWarning($warning, $stackPtr, $code, $data, $severity, true);
970
+ if ($recorded === true && $this->fixer->enabled === true) {
971
+ return true;
972
+ }
973
+
974
+ return false;
975
+
976
+ }//end addFixableWarning()
977
+
978
+
979
+ /**
980
+ * Adds an error to the error stack.
981
+ *
982
+ * @param string $error The error message.
983
+ * @param int $line The line on which the error occurred.
984
+ * @param int $column The column at which the error occurred.
985
+ * @param string $code A violation code unique to the sniff message.
986
+ * @param array $data Replacements for the error message.
987
+ * @param int $severity The severity level for this error. A value of 0
988
+ * will be converted into the default severity level.
989
+ * @param boolean $fixable Can the error be fixed by the sniff?
990
+ *
991
+ * @return boolean
992
+ */
993
+ private function _addError($error, $line, $column, $code, $data, $severity, $fixable)
994
+ {
995
+ if (isset(self::$_ignoredLines[$line]) === true) {
996
+ return false;
997
+ }
998
+
999
+ // Work out which sniff generated the error.
1000
+ if (substr($code, 0, 9) === 'Internal.') {
1001
+ // Any internal message.
1002
+ $sniffCode = $code;
1003
+ } else {
1004
+ $parts = explode('_', str_replace('\\', '_', $this->_activeListener));
1005
+ if (isset($parts[3]) === true) {
1006
+ $sniff = $parts[0].'.'.$parts[2].'.'.$parts[3];
1007
+
1008
+ // Remove "Sniff" from the end.
1009
+ $sniff = substr($sniff, 0, -5);
1010
+ } else {
1011
+ $sniff = 'unknownSniff';
1012
+ }
1013
+
1014
+ $sniffCode = $sniff;
1015
+ if ($code !== '') {
1016
+ $sniffCode .= '.'.$code;
1017
+ }
1018
+ }//end if
1019
+
1020
+ // If we know this sniff code is being ignored for this file, return early.
1021
+ if (isset($this->_ignoredCodes[$sniffCode]) === true) {
1022
+ return false;
1023
+ }
1024
+
1025
+ // Make sure this message type has not been set to "warning".
1026
+ if (isset($this->ruleset[$sniffCode]['type']) === true
1027
+ && $this->ruleset[$sniffCode]['type'] === 'warning'
1028
+ ) {
1029
+ // Pass this off to the warning handler.
1030
+ return $this->_addWarning($error, $line, $column, $code, $data, $severity, $fixable);
1031
+ } else if ($this->phpcs->cli->errorSeverity === 0) {
1032
+ // Don't bother doing any processing as errors are just going to
1033
+ // be hidden in the reports anyway.
1034
+ return false;
1035
+ }
1036
+
1037
+ // Make sure we are interested in this severity level.
1038
+ if (isset($this->ruleset[$sniffCode]['severity']) === true) {
1039
+ $severity = $this->ruleset[$sniffCode]['severity'];
1040
+ } else if ($severity === 0) {
1041
+ $severity = PHPCS_DEFAULT_ERROR_SEV;
1042
+ }
1043
+
1044
+ if ($this->phpcs->cli->errorSeverity > $severity) {
1045
+ return false;
1046
+ }
1047
+
1048
+ // Make sure we are not ignoring this file.
1049
+ $patterns = $this->phpcs->getIgnorePatterns($sniffCode);
1050
+ foreach ($patterns as $pattern => $type) {
1051
+ // While there is support for a type of each pattern
1052
+ // (absolute or relative) we don't actually support it here.
1053
+ $replacements = array(
1054
+ '\\,' => ',',
1055
+ '*' => '.*',
1056
+ );
1057
+
1058
+ // We assume a / directory separator, as do the exclude rules
1059
+ // most developers write, so we need a special case for any system
1060
+ // that is different.
1061
+ if (DIRECTORY_SEPARATOR === '\\') {
1062
+ $replacements['/'] = '\\\\';
1063
+ }
1064
+
1065
+ $pattern = '`'.strtr($pattern, $replacements).'`i';
1066
+ if (preg_match($pattern, $this->_file) === 1) {
1067
+ $this->_ignoredCodes[$sniffCode] = true;
1068
+ return false;
1069
+ }
1070
+ }//end foreach
1071
+
1072
+ $this->_errorCount++;
1073
+ if ($fixable === true) {
1074
+ $this->_fixableCount++;
1075
+ }
1076
+
1077
+ if ($this->_recordErrors === false) {
1078
+ if (isset($this->_errors[$line]) === false) {
1079
+ $this->_errors[$line] = 0;
1080
+ }
1081
+
1082
+ $this->_errors[$line]++;
1083
+ return true;
1084
+ }
1085
+
1086
+ // Work out the error message.
1087
+ if (isset($this->ruleset[$sniffCode]['message']) === true) {
1088
+ $error = $this->ruleset[$sniffCode]['message'];
1089
+ }
1090
+
1091
+ if (empty($data) === true) {
1092
+ $message = $error;
1093
+ } else {
1094
+ $message = vsprintf($error, $data);
1095
+ }
1096
+
1097
+ if (isset($this->_errors[$line]) === false) {
1098
+ $this->_errors[$line] = array();
1099
+ }
1100
+
1101
+ if (isset($this->_errors[$line][$column]) === false) {
1102
+ $this->_errors[$line][$column] = array();
1103
+ }
1104
+
1105
+ $this->_errors[$line][$column][] = array(
1106
+ 'message' => $message,
1107
+ 'source' => $sniffCode,
1108
+ 'severity' => $severity,
1109
+ 'fixable' => $fixable,
1110
+ );
1111
+
1112
+ if (PHP_CODESNIFFER_VERBOSITY > 1
1113
+ && $this->fixer->enabled === true
1114
+ && $fixable === true
1115
+ ) {
1116
+ @ob_end_clean();
1117
+ echo "\tE: [Line $line] $message ($sniffCode)".PHP_EOL;
1118
+ ob_start();
1119
+ }
1120
+
1121
+ return true;
1122
+
1123
+ }//end _addError()
1124
+
1125
+
1126
+ /**
1127
+ * Adds an warning to the warning stack.
1128
+ *
1129
+ * @param string $warning The error message.
1130
+ * @param int $line The line on which the warning occurred.
1131
+ * @param int $column The column at which the warning occurred.
1132
+ * @param string $code A violation code unique to the sniff message.
1133
+ * @param array $data Replacements for the warning message.
1134
+ * @param int $severity The severity level for this warning. A value of 0
1135
+ * will be converted into the default severity level.
1136
+ * @param boolean $fixable Can the warning be fixed by the sniff?
1137
+ *
1138
+ * @return boolean
1139
+ */
1140
+ private function _addWarning($warning, $line, $column, $code, $data, $severity, $fixable)
1141
+ {
1142
+ if (isset(self::$_ignoredLines[$line]) === true) {
1143
+ return false;
1144
+ }
1145
+
1146
+ // Work out which sniff generated the warning.
1147
+ if (substr($code, 0, 9) === 'Internal.') {
1148
+ // Any internal message.
1149
+ $sniffCode = $code;
1150
+ } else {
1151
+ $parts = explode('_', str_replace('\\', '_', $this->_activeListener));
1152
+ if (isset($parts[3]) === true) {
1153
+ $sniff = $parts[0].'.'.$parts[2].'.'.$parts[3];
1154
+
1155
+ // Remove "Sniff" from the end.
1156
+ $sniff = substr($sniff, 0, -5);
1157
+ } else {
1158
+ $sniff = 'unknownSniff';
1159
+ }
1160
+
1161
+ $sniffCode = $sniff;
1162
+ if ($code !== '') {
1163
+ $sniffCode .= '.'.$code;
1164
+ }
1165
+ }//end if
1166
+
1167
+ // If we know this sniff code is being ignored for this file, return early.
1168
+ if (isset($this->_ignoredCodes[$sniffCode]) === true) {
1169
+ return false;
1170
+ }
1171
+
1172
+ // Make sure this message type has not been set to "error".
1173
+ if (isset($this->ruleset[$sniffCode]['type']) === true
1174
+ && $this->ruleset[$sniffCode]['type'] === 'error'
1175
+ ) {
1176
+ // Pass this off to the error handler.
1177
+ return $this->_addError($warning, $line, $column, $code, $data, $severity, $fixable);
1178
+ } else if ($this->phpcs->cli->warningSeverity === 0) {
1179
+ // Don't bother doing any processing as warnings are just going to
1180
+ // be hidden in the reports anyway.
1181
+ return false;
1182
+ }
1183
+
1184
+ // Make sure we are interested in this severity level.
1185
+ if (isset($this->ruleset[$sniffCode]['severity']) === true) {
1186
+ $severity = $this->ruleset[$sniffCode]['severity'];
1187
+ } else if ($severity === 0) {
1188
+ $severity = PHPCS_DEFAULT_WARN_SEV;
1189
+ }
1190
+
1191
+ if ($this->phpcs->cli->warningSeverity > $severity) {
1192
+ return false;
1193
+ }
1194
+
1195
+ // Make sure we are not ignoring this file.
1196
+ $patterns = $this->phpcs->getIgnorePatterns($sniffCode);
1197
+ foreach ($patterns as $pattern => $type) {
1198
+ // While there is support for a type of each pattern
1199
+ // (absolute or relative) we don't actually support it here.
1200
+ $replacements = array(
1201
+ '\\,' => ',',
1202
+ '*' => '.*',
1203
+ );
1204
+
1205
+ // We assume a / directory separator, as do the exclude rules
1206
+ // most developers write, so we need a special case for any system
1207
+ // that is different.
1208
+ if (DIRECTORY_SEPARATOR === '\\') {
1209
+ $replacements['/'] = '\\\\';
1210
+ }
1211
+
1212
+ $pattern = '`'.strtr($pattern, $replacements).'`i';
1213
+ if (preg_match($pattern, $this->_file) === 1) {
1214
+ $this->_ignoredCodes[$sniffCode] = true;
1215
+ return false;
1216
+ }
1217
+ }//end foreach
1218
+
1219
+ $this->_warningCount++;
1220
+ if ($fixable === true) {
1221
+ $this->_fixableCount++;
1222
+ }
1223
+
1224
+ if ($this->_recordErrors === false) {
1225
+ if (isset($this->_warnings[$line]) === false) {
1226
+ $this->_warnings[$line] = 0;
1227
+ }
1228
+
1229
+ $this->_warnings[$line]++;
1230
+ return true;
1231
+ }
1232
+
1233
+ // Work out the warning message.
1234
+ if (isset($this->ruleset[$sniffCode]['message']) === true) {
1235
+ $warning = $this->ruleset[$sniffCode]['message'];
1236
+ }
1237
+
1238
+ if (empty($data) === true) {
1239
+ $message = $warning;
1240
+ } else {
1241
+ $message = vsprintf($warning, $data);
1242
+ }
1243
+
1244
+ if (isset($this->_warnings[$line]) === false) {
1245
+ $this->_warnings[$line] = array();
1246
+ }
1247
+
1248
+ if (isset($this->_warnings[$line][$column]) === false) {
1249
+ $this->_warnings[$line][$column] = array();
1250
+ }
1251
+
1252
+ $this->_warnings[$line][$column][] = array(
1253
+ 'message' => $message,
1254
+ 'source' => $sniffCode,
1255
+ 'severity' => $severity,
1256
+ 'fixable' => $fixable,
1257
+ );
1258
+
1259
+ if (PHP_CODESNIFFER_VERBOSITY > 1
1260
+ && $this->fixer->enabled === true
1261
+ && $fixable === true
1262
+ ) {
1263
+ @ob_end_clean();
1264
+ echo "\tW: $message ($sniffCode)".PHP_EOL;
1265
+ ob_start();
1266
+ }
1267
+
1268
+ return true;
1269
+
1270
+ }//end _addWarning()
1271
+
1272
+
1273
+ /**
1274
+ * Adds an warning to the warning stack.
1275
+ *
1276
+ * @param int $stackPtr The stack position where the metric was recorded.
1277
+ * @param string $metric The name of the metric being recorded.
1278
+ * @param string $value The value of the metric being recorded.
1279
+ *
1280
+ * @return boolean
1281
+ */
1282
+ public function recordMetric($stackPtr, $metric, $value)
1283
+ {
1284
+ if (isset($this->_metrics[$metric]) === false) {
1285
+ $this->_metrics[$metric] = array(
1286
+ 'values' => array(
1287
+ $value => array($stackPtr),
1288
+ ),
1289
+ );
1290
+ } else {
1291
+ if (isset($this->_metrics[$metric]['values'][$value]) === false) {
1292
+ $this->_metrics[$metric]['values'][$value] = array($stackPtr);
1293
+ } else {
1294
+ $this->_metrics[$metric]['values'][$value][] = $stackPtr;
1295
+ }
1296
+ }
1297
+
1298
+ return true;
1299
+
1300
+ }//end recordMetric()
1301
+
1302
+
1303
+ /**
1304
+ * Returns the number of errors raised.
1305
+ *
1306
+ * @return int
1307
+ */
1308
+ public function getErrorCount()
1309
+ {
1310
+ return $this->_errorCount;
1311
+
1312
+ }//end getErrorCount()
1313
+
1314
+
1315
+ /**
1316
+ * Returns the number of warnings raised.
1317
+ *
1318
+ * @return int
1319
+ */
1320
+ public function getWarningCount()
1321
+ {
1322
+ return $this->_warningCount;
1323
+
1324
+ }//end getWarningCount()
1325
+
1326
+
1327
+ /**
1328
+ * Returns the number of successes recorded.
1329
+ *
1330
+ * @return int
1331
+ */
1332
+ public function getSuccessCount()
1333
+ {
1334
+ return $this->_successCount;
1335
+
1336
+ }//end getSuccessCount()
1337
+
1338
+
1339
+ /**
1340
+ * Returns the number of fixable errors/warnings raised.
1341
+ *
1342
+ * @return int
1343
+ */
1344
+ public function getFixableCount()
1345
+ {
1346
+ return $this->_fixableCount;
1347
+
1348
+ }//end getFixableCount()
1349
+
1350
+
1351
+ /**
1352
+ * Returns the list of ignored lines.
1353
+ *
1354
+ * @return array
1355
+ */
1356
+ public function getIgnoredLines()
1357
+ {
1358
+ return self::$_ignoredLines;
1359
+
1360
+ }//end getIgnoredLines()
1361
+
1362
+
1363
+ /**
1364
+ * Returns the errors raised from processing this file.
1365
+ *
1366
+ * @return array
1367
+ */
1368
+ public function getErrors()
1369
+ {
1370
+ return $this->_errors;
1371
+
1372
+ }//end getErrors()
1373
+
1374
+
1375
+ /**
1376
+ * Returns the warnings raised from processing this file.
1377
+ *
1378
+ * @return array
1379
+ */
1380
+ public function getWarnings()
1381
+ {
1382
+ return $this->_warnings;
1383
+
1384
+ }//end getWarnings()
1385
+
1386
+
1387
+ /**
1388
+ * Returns the metrics found while processing this file.
1389
+ *
1390
+ * @return array
1391
+ */
1392
+ public function getMetrics()
1393
+ {
1394
+ return $this->_metrics;
1395
+
1396
+ }//end getMetrics()
1397
+
1398
+
1399
+ /**
1400
+ * Returns the absolute filename of this file.
1401
+ *
1402
+ * @return string
1403
+ */
1404
+ public function getFilename()
1405
+ {
1406
+ return $this->_file;
1407
+
1408
+ }//end getFilename()
1409
+
1410
+
1411
+ /**
1412
+ * Creates an array of tokens when given some PHP code.
1413
+ *
1414
+ * Starts by using token_get_all() but does a lot of extra processing
1415
+ * to insert information about the context of the token.
1416
+ *
1417
+ * @param string $string The string to tokenize.
1418
+ * @param object $tokenizer A tokenizer class to use to tokenize the string.
1419
+ * @param string $eolChar The EOL character to use for splitting strings.
1420
+ * @param int $tabWidth The number of spaces each tab respresents.
1421
+ * @param string $encoding The charset of the sniffed file.
1422
+ *
1423
+ * @throws PHP_CodeSniffer_Exception If the file cannot be processed.
1424
+ * @return array
1425
+ */
1426
+ public static function tokenizeString($string, $tokenizer, $eolChar='\n', $tabWidth=null, $encoding=null)
1427
+ {
1428
+ // Minified files often have a very large number of characters per line
1429
+ // and cause issues when tokenizing.
1430
+ if (property_exists($tokenizer, 'skipMinified') === true
1431
+ && $tokenizer->skipMinified === true
1432
+ ) {
1433
+ $numChars = strlen($string);
1434
+ $numLines = (substr_count($string, $eolChar) + 1);
1435
+ $average = ($numChars / $numLines);
1436
+ if ($average > 100) {
1437
+ throw new PHP_CodeSniffer_Exception('File appears to be minified and cannot be processed');
1438
+ }
1439
+ }
1440
+
1441
+ $tokens = $tokenizer->tokenizeString($string, $eolChar);
1442
+
1443
+ if ($tabWidth === null) {
1444
+ $tabWidth = PHP_CODESNIFFER_TAB_WIDTH;
1445
+ }
1446
+
1447
+ if ($encoding === null) {
1448
+ $encoding = PHP_CODESNIFFER_ENCODING;
1449
+ }
1450
+
1451
+ self::_createPositionMap($tokens, $tokenizer, $eolChar, $encoding, $tabWidth);
1452
+ self::_createTokenMap($tokens, $tokenizer, $eolChar);
1453
+ self::_createParenthesisNestingMap($tokens, $tokenizer, $eolChar);
1454
+ self::_createScopeMap($tokens, $tokenizer, $eolChar);
1455
+
1456
+ self::_createLevelMap($tokens, $tokenizer, $eolChar);
1457
+
1458
+ // Allow the tokenizer to do additional processing if required.
1459
+ $tokenizer->processAdditional($tokens, $eolChar);
1460
+
1461
+ return $tokens;
1462
+
1463
+ }//end tokenizeString()
1464
+
1465
+
1466
+ /**
1467
+ * Sets token position information.
1468
+ *
1469
+ * Can also convert tabs into spaces. Each tab can represent between
1470
+ * 1 and $width spaces, so this cannot be a straight string replace.
1471
+ *
1472
+ * @param array $tokens The array of tokens to process.
1473
+ * @param object $tokenizer The tokenizer being used to process this file.
1474
+ * @param string $eolChar The EOL character to use for splitting strings.
1475
+ * @param string $encoding The charset of the sniffed file.
1476
+ * @param int $tabWidth The number of spaces that each tab represents.
1477
+ * Set to 0 to disable tab replacement.
1478
+ *
1479
+ * @return void
1480
+ */
1481
+ private static function _createPositionMap(&$tokens, $tokenizer, $eolChar, $encoding, $tabWidth)
1482
+ {
1483
+ $currColumn = 1;
1484
+ $lineNumber = 1;
1485
+ $eolLen = (strlen($eolChar) * -1);
1486
+ $tokenizerType = get_class($tokenizer);
1487
+ $ignoring = false;
1488
+ $inTests = defined('PHP_CODESNIFFER_IN_TESTS');
1489
+
1490
+ $checkEncoding = false;
1491
+ if ($encoding !== 'iso-8859-1' && function_exists('iconv_strlen') === true) {
1492
+ $checkEncoding = true;
1493
+ }
1494
+
1495
+ $tokensWithTabs = array(
1496
+ T_WHITESPACE => true,
1497
+ T_COMMENT => true,
1498
+ T_DOC_COMMENT => true,
1499
+ T_DOC_COMMENT_WHITESPACE => true,
1500
+ T_DOC_COMMENT_STRING => true,
1501
+ T_CONSTANT_ENCAPSED_STRING => true,
1502
+ T_DOUBLE_QUOTED_STRING => true,
1503
+ T_HEREDOC => true,
1504
+ T_NOWDOC => true,
1505
+ T_INLINE_HTML => true,
1506
+ );
1507
+
1508
+ $numTokens = count($tokens);
1509
+ for ($i = 0; $i < $numTokens; $i++) {
1510
+ $tokens[$i]['line'] = $lineNumber;
1511
+ $tokens[$i]['column'] = $currColumn;
1512
+
1513
+ if ($tokenizerType === 'PHP_CodeSniffer_Tokenizers_PHP'
1514
+ && isset(PHP_CodeSniffer_Tokens::$knownLengths[$tokens[$i]['code']]) === true
1515
+ ) {
1516
+ // There are no tabs in the tokens we know the length of.
1517
+ $length = PHP_CodeSniffer_Tokens::$knownLengths[$tokens[$i]['code']];
1518
+ $currColumn += $length;
1519
+ } else if ($tabWidth === 0
1520
+ || isset($tokensWithTabs[$tokens[$i]['code']]) === false
1521
+ || strpos($tokens[$i]['content'], "\t") === false
1522
+ ) {
1523
+ // There are no tabs in this content, or we aren't replacing them.
1524
+ if ($checkEncoding === true) {
1525
+ // Not using the default encoding, so take a bit more care.
1526
+ $length = @iconv_strlen($tokens[$i]['content'], $encoding);
1527
+ if ($length === false) {
1528
+ // String contained invalid characters, so revert to default.
1529
+ $length = strlen($tokens[$i]['content']);
1530
+ }
1531
+ } else {
1532
+ $length = strlen($tokens[$i]['content']);
1533
+ }
1534
+
1535
+ $currColumn += $length;
1536
+ } else {
1537
+ if (str_replace("\t", '', $tokens[$i]['content']) === '') {
1538
+ // String only contains tabs, so we can shortcut the process.
1539
+ $numTabs = strlen($tokens[$i]['content']);
1540
+
1541
+ $newContent = '';
1542
+ $firstTabSize = ($tabWidth - (($currColumn - 1) % $tabWidth));
1543
+ $length = ($firstTabSize + ($tabWidth * ($numTabs - 1)));
1544
+ $currColumn += $length;
1545
+ $newContent = str_repeat(' ', $length);
1546
+ } else {
1547
+ // We need to determine the length of each tab.
1548
+ $tabs = explode("\t", $tokens[$i]['content']);
1549
+
1550
+ $numTabs = (count($tabs) - 1);
1551
+ $tabNum = 0;
1552
+ $newContent = '';
1553
+ $length = 0;
1554
+
1555
+ foreach ($tabs as $content) {
1556
+ if ($content !== '') {
1557
+ $newContent .= $content;
1558
+ if ($checkEncoding === true) {
1559
+ // Not using the default encoding, so take a bit more care.
1560
+ $contentLength = @iconv_strlen($content, $encoding);
1561
+ if ($contentLength === false) {
1562
+ // String contained invalid characters, so revert to default.
1563
+ $contentLength = strlen($content);
1564
+ }
1565
+ } else {
1566
+ $contentLength = strlen($content);
1567
+ }
1568
+
1569
+ $currColumn += $contentLength;
1570
+ $length += $contentLength;
1571
+ }
1572
+
1573
+ // The last piece of content does not have a tab after it.
1574
+ if ($tabNum === $numTabs) {
1575
+ break;
1576
+ }
1577
+
1578
+ // Process the tab that comes after the content.
1579
+ $lastCurrColumn = $currColumn;
1580
+ $tabNum++;
1581
+
1582
+ // Move the pointer to the next tab stop.
1583
+ if (($currColumn % $tabWidth) === 0) {
1584
+ // This is the first tab, and we are already at a
1585
+ // tab stop, so this tab counts as a single space.
1586
+ $currColumn++;
1587
+ } else {
1588
+ $currColumn++;
1589
+ while (($currColumn % $tabWidth) !== 0) {
1590
+ $currColumn++;
1591
+ }
1592
+
1593
+ $currColumn++;
1594
+ }
1595
+
1596
+ $length += ($currColumn - $lastCurrColumn);
1597
+ $newContent .= str_repeat(' ', ($currColumn - $lastCurrColumn));
1598
+ }//end foreach
1599
+ }//end if
1600
+
1601
+ $tokens[$i]['orig_content'] = $tokens[$i]['content'];
1602
+ $tokens[$i]['content'] = $newContent;
1603
+ }//end if
1604
+
1605
+ $tokens[$i]['length'] = $length;
1606
+
1607
+ if (isset(PHP_CodeSniffer_Tokens::$knownLengths[$tokens[$i]['code']]) === false
1608
+ && strpos($tokens[$i]['content'], $eolChar) !== false
1609
+ ) {
1610
+ $lineNumber++;
1611
+ $currColumn = 1;
1612
+
1613
+ // Newline chars are not counted in the token length.
1614
+ $tokens[$i]['length'] += $eolLen;
1615
+ }
1616
+
1617
+ if ($tokens[$i]['code'] === T_COMMENT
1618
+ || $tokens[$i]['code'] === T_DOC_COMMENT_TAG
1619
+ || ($inTests === true && $tokens[$i]['code'] === T_INLINE_HTML)
1620
+ ) {
1621
+ if (strpos($tokens[$i]['content'], '@codingStandards') !== false) {
1622
+ if ($ignoring === false
1623
+ && strpos($tokens[$i]['content'], '@codingStandardsIgnoreStart') !== false
1624
+ ) {
1625
+ $ignoring = true;
1626
+ } else if ($ignoring === true
1627
+ && strpos($tokens[$i]['content'], '@codingStandardsIgnoreEnd') !== false
1628
+ ) {
1629
+ $ignoring = false;
1630
+ // Ignore this comment too.
1631
+ self::$_ignoredLines[$tokens[$i]['line']] = true;
1632
+ } else if ($ignoring === false
1633
+ && strpos($tokens[$i]['content'], '@codingStandardsIgnoreLine') !== false
1634
+ ) {
1635
+ self::$_ignoredLines[($tokens[$i]['line'] + 1)] = true;
1636
+ // Ignore this comment too.
1637
+ self::$_ignoredLines[$tokens[$i]['line']] = true;
1638
+ }
1639
+ }
1640
+ }//end if
1641
+
1642
+ if ($ignoring === true) {
1643
+ self::$_ignoredLines[$tokens[$i]['line']] = true;
1644
+ }
1645
+ }//end for
1646
+
1647
+ }//end _createPositionMap()
1648
+
1649
+
1650
+ /**
1651
+ * Creates a map of brackets positions.
1652
+ *
1653
+ * @param array $tokens The array of tokens to process.
1654
+ * @param object $tokenizer The tokenizer being used to process this file.
1655
+ * @param string $eolChar The EOL character to use for splitting strings.
1656
+ *
1657
+ * @return void
1658
+ */
1659
+ private static function _createTokenMap(&$tokens, $tokenizer, $eolChar)
1660
+ {
1661
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1662
+ echo "\t*** START TOKEN MAP ***".PHP_EOL;
1663
+ }
1664
+
1665
+ $squareOpeners = array();
1666
+ $curlyOpeners = array();
1667
+ $numTokens = count($tokens);
1668
+
1669
+ $openers = array();
1670
+ $openOwner = null;
1671
+
1672
+ for ($i = 0; $i < $numTokens; $i++) {
1673
+ /*
1674
+ Parenthesis mapping.
1675
+ */
1676
+
1677
+ if (isset(PHP_CodeSniffer_Tokens::$parenthesisOpeners[$tokens[$i]['code']]) === true) {
1678
+ $tokens[$i]['parenthesis_opener'] = null;
1679
+ $tokens[$i]['parenthesis_closer'] = null;
1680
+ $tokens[$i]['parenthesis_owner'] = $i;
1681
+ $openOwner = $i;
1682
+ } else if ($tokens[$i]['code'] === T_OPEN_PARENTHESIS) {
1683
+ $openers[] = $i;
1684
+ $tokens[$i]['parenthesis_opener'] = $i;
1685
+ if ($openOwner !== null) {
1686
+ $tokens[$openOwner]['parenthesis_opener'] = $i;
1687
+ $tokens[$i]['parenthesis_owner'] = $openOwner;
1688
+ $openOwner = null;
1689
+ }
1690
+ } else if ($tokens[$i]['code'] === T_CLOSE_PARENTHESIS) {
1691
+ // Did we set an owner for this set of parenthesis?
1692
+ $numOpeners = count($openers);
1693
+ if ($numOpeners !== 0) {
1694
+ $opener = array_pop($openers);
1695
+ if (isset($tokens[$opener]['parenthesis_owner']) === true) {
1696
+ $owner = $tokens[$opener]['parenthesis_owner'];
1697
+
1698
+ $tokens[$owner]['parenthesis_closer'] = $i;
1699
+ $tokens[$i]['parenthesis_owner'] = $owner;
1700
+ }
1701
+
1702
+ $tokens[$i]['parenthesis_opener'] = $opener;
1703
+ $tokens[$i]['parenthesis_closer'] = $i;
1704
+ $tokens[$opener]['parenthesis_closer'] = $i;
1705
+ }
1706
+ }//end if
1707
+
1708
+ /*
1709
+ Bracket mapping.
1710
+ */
1711
+
1712
+ switch ($tokens[$i]['code']) {
1713
+ case T_OPEN_SQUARE_BRACKET:
1714
+ $squareOpeners[] = $i;
1715
+
1716
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1717
+ echo str_repeat("\t", count($squareOpeners));
1718
+ echo str_repeat("\t", count($curlyOpeners));
1719
+ echo "=> Found square bracket opener at $i".PHP_EOL;
1720
+ }
1721
+ break;
1722
+ case T_OPEN_CURLY_BRACKET:
1723
+ if (isset($tokens[$i]['scope_closer']) === false) {
1724
+ $curlyOpeners[] = $i;
1725
+
1726
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1727
+ echo str_repeat("\t", count($squareOpeners));
1728
+ echo str_repeat("\t", count($curlyOpeners));
1729
+ echo "=> Found curly bracket opener at $i".PHP_EOL;
1730
+ }
1731
+ }
1732
+ break;
1733
+ case T_CLOSE_SQUARE_BRACKET:
1734
+ if (empty($squareOpeners) === false) {
1735
+ $opener = array_pop($squareOpeners);
1736
+ $tokens[$i]['bracket_opener'] = $opener;
1737
+ $tokens[$i]['bracket_closer'] = $i;
1738
+ $tokens[$opener]['bracket_opener'] = $opener;
1739
+ $tokens[$opener]['bracket_closer'] = $i;
1740
+
1741
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1742
+ echo str_repeat("\t", count($squareOpeners));
1743
+ echo str_repeat("\t", count($curlyOpeners));
1744
+ echo "\t=> Found square bracket closer at $i for $opener".PHP_EOL;
1745
+ }
1746
+ }
1747
+ break;
1748
+ case T_CLOSE_CURLY_BRACKET:
1749
+ if (empty($curlyOpeners) === false
1750
+ && isset($tokens[$i]['scope_opener']) === false
1751
+ ) {
1752
+ $opener = array_pop($curlyOpeners);
1753
+ $tokens[$i]['bracket_opener'] = $opener;
1754
+ $tokens[$i]['bracket_closer'] = $i;
1755
+ $tokens[$opener]['bracket_opener'] = $opener;
1756
+ $tokens[$opener]['bracket_closer'] = $i;
1757
+
1758
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1759
+ echo str_repeat("\t", count($squareOpeners));
1760
+ echo str_repeat("\t", count($curlyOpeners));
1761
+ echo "\t=> Found curly bracket closer at $i for $opener".PHP_EOL;
1762
+ }
1763
+ }
1764
+ break;
1765
+ default:
1766
+ continue;
1767
+ }//end switch
1768
+ }//end for
1769
+
1770
+ // Cleanup for any openers that we didn't find closers for.
1771
+ // This typically means there was a syntax error breaking things.
1772
+ foreach ($openers as $opener) {
1773
+ unset($tokens[$opener]['parenthesis_opener']);
1774
+ unset($tokens[$opener]['parenthesis_owner']);
1775
+ }
1776
+
1777
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1778
+ echo "\t*** END TOKEN MAP ***".PHP_EOL;
1779
+ }
1780
+
1781
+ }//end _createTokenMap()
1782
+
1783
+
1784
+ /**
1785
+ * Creates a map for the parenthesis tokens that surround other tokens.
1786
+ *
1787
+ * @param array $tokens The array of tokens to process.
1788
+ * @param object $tokenizer The tokenizer being used to process this file.
1789
+ * @param string $eolChar The EOL character to use for splitting strings.
1790
+ *
1791
+ * @return void
1792
+ */
1793
+ private static function _createParenthesisNestingMap(
1794
+ &$tokens,
1795
+ $tokenizer,
1796
+ $eolChar
1797
+ ) {
1798
+ $numTokens = count($tokens);
1799
+ $map = array();
1800
+ for ($i = 0; $i < $numTokens; $i++) {
1801
+ if (isset($tokens[$i]['parenthesis_opener']) === true
1802
+ && $i === $tokens[$i]['parenthesis_opener']
1803
+ ) {
1804
+ if (empty($map) === false) {
1805
+ $tokens[$i]['nested_parenthesis'] = $map;
1806
+ }
1807
+
1808
+ if (isset($tokens[$i]['parenthesis_closer']) === true) {
1809
+ $map[$tokens[$i]['parenthesis_opener']]
1810
+ = $tokens[$i]['parenthesis_closer'];
1811
+ }
1812
+ } else if (isset($tokens[$i]['parenthesis_closer']) === true
1813
+ && $i === $tokens[$i]['parenthesis_closer']
1814
+ ) {
1815
+ array_pop($map);
1816
+ if (empty($map) === false) {
1817
+ $tokens[$i]['nested_parenthesis'] = $map;
1818
+ }
1819
+ } else {
1820
+ if (empty($map) === false) {
1821
+ $tokens[$i]['nested_parenthesis'] = $map;
1822
+ }
1823
+ }//end if
1824
+ }//end for
1825
+
1826
+ }//end _createParenthesisNestingMap()
1827
+
1828
+
1829
+ /**
1830
+ * Creates a scope map of tokens that open scopes.
1831
+ *
1832
+ * @param array $tokens The array of tokens to process.
1833
+ * @param object $tokenizer The tokenizer being used to process this file.
1834
+ * @param string $eolChar The EOL character to use for splitting strings.
1835
+ *
1836
+ * @return void
1837
+ * @see _recurseScopeMap()
1838
+ */
1839
+ private static function _createScopeMap(&$tokens, $tokenizer, $eolChar)
1840
+ {
1841
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1842
+ echo "\t*** START SCOPE MAP ***".PHP_EOL;
1843
+ }
1844
+
1845
+ $numTokens = count($tokens);
1846
+ for ($i = 0; $i < $numTokens; $i++) {
1847
+ // Check to see if the current token starts a new scope.
1848
+ if (isset($tokenizer->scopeOpeners[$tokens[$i]['code']]) === true) {
1849
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1850
+ $type = $tokens[$i]['type'];
1851
+ $content = PHP_CodeSniffer::prepareForOutput($tokens[$i]['content']);
1852
+ echo "\tStart scope map at $i:$type => $content".PHP_EOL;
1853
+ }
1854
+
1855
+ if (isset($tokens[$i]['scope_condition']) === true) {
1856
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1857
+ echo "\t* already processed, skipping *".PHP_EOL;
1858
+ }
1859
+
1860
+ continue;
1861
+ }
1862
+
1863
+ $i = self::_recurseScopeMap(
1864
+ $tokens,
1865
+ $numTokens,
1866
+ $tokenizer,
1867
+ $eolChar,
1868
+ $i
1869
+ );
1870
+ }//end if
1871
+ }//end for
1872
+
1873
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1874
+ echo "\t*** END SCOPE MAP ***".PHP_EOL;
1875
+ }
1876
+
1877
+ }//end _createScopeMap()
1878
+
1879
+
1880
+ /**
1881
+ * Recurses though the scope openers to build a scope map.
1882
+ *
1883
+ * @param array $tokens The array of tokens to process.
1884
+ * @param int $numTokens The size of the tokens array.
1885
+ * @param object $tokenizer The tokenizer being used to process this file.
1886
+ * @param string $eolChar The EOL character to use for splitting strings.
1887
+ * @param int $stackPtr The position in the stack of the token that
1888
+ * opened the scope (eg. an IF token or FOR token).
1889
+ * @param int $depth How many scope levels down we are.
1890
+ * @param int $ignore How many curly braces we are ignoring.
1891
+ *
1892
+ * @return int The position in the stack that closed the scope.
1893
+ */
1894
+ private static function _recurseScopeMap(
1895
+ &$tokens,
1896
+ $numTokens,
1897
+ $tokenizer,
1898
+ $eolChar,
1899
+ $stackPtr,
1900
+ $depth=1,
1901
+ &$ignore=0
1902
+ ) {
1903
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1904
+ echo str_repeat("\t", $depth);
1905
+ echo "=> Begin scope map recursion at token $stackPtr with depth $depth".PHP_EOL;
1906
+ }
1907
+
1908
+ $opener = null;
1909
+ $currType = $tokens[$stackPtr]['code'];
1910
+ $startLine = $tokens[$stackPtr]['line'];
1911
+
1912
+ // We will need this to restore the value if we end up
1913
+ // returning a token ID that causes our calling function to go back
1914
+ // over already ignored braces.
1915
+ $originalIgnore = $ignore;
1916
+
1917
+ // If the start token for this scope opener is the same as
1918
+ // the scope token, we have already found our opener.
1919
+ if (isset($tokenizer->scopeOpeners[$currType]['start'][$currType]) === true) {
1920
+ $opener = $stackPtr;
1921
+ }
1922
+
1923
+ for ($i = ($stackPtr + 1); $i < $numTokens; $i++) {
1924
+ $tokenType = $tokens[$i]['code'];
1925
+
1926
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1927
+ $type = $tokens[$i]['type'];
1928
+ $line = $tokens[$i]['line'];
1929
+ $content = PHP_CodeSniffer::prepareForOutput($tokens[$i]['content']);
1930
+
1931
+ echo str_repeat("\t", $depth);
1932
+ echo "Process token $i on line $line [";
1933
+ if ($opener !== null) {
1934
+ echo "opener:$opener;";
1935
+ }
1936
+
1937
+ if ($ignore > 0) {
1938
+ echo "ignore=$ignore;";
1939
+ }
1940
+
1941
+ echo "]: $type => $content".PHP_EOL;
1942
+ }//end if
1943
+
1944
+ // Very special case for IF statements in PHP that can be defined without
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
+ ) {
1954
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1955
+ $type = $tokens[$stackPtr]['type'];
1956
+ echo str_repeat("\t", $depth);
1957
+ echo "=> Found semicolon before scope opener for $stackPtr:$type, bailing".PHP_EOL;
1958
+ }
1959
+
1960
+ return $i;
1961
+ }
1962
+
1963
+ if ($opener === null
1964
+ && $ignore === 0
1965
+ && $tokenType === T_CLOSE_CURLY_BRACKET
1966
+ && isset($tokenizer->scopeOpeners[$currType]['end'][$tokenType]) === true
1967
+ ) {
1968
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1969
+ $type = $tokens[$stackPtr]['type'];
1970
+ echo str_repeat("\t", $depth);
1971
+ echo "=> Found curly brace closer before scope opener for $stackPtr:$type, bailing".PHP_EOL;
1972
+ }
1973
+
1974
+ return ($i - 1);
1975
+ }
1976
+
1977
+ if ($opener !== null
1978
+ && (isset($tokens[$i]['scope_opener']) === false
1979
+ || $tokenizer->scopeOpeners[$tokens[$stackPtr]['code']]['shared'] === true)
1980
+ && isset($tokenizer->scopeOpeners[$currType]['end'][$tokenType]) === true
1981
+ ) {
1982
+ if ($ignore > 0 && $tokenType === T_CLOSE_CURLY_BRACKET) {
1983
+ // The last opening bracket must have been for a string
1984
+ // offset or alike, so let's ignore it.
1985
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1986
+ echo str_repeat("\t", $depth);
1987
+ echo '* finished ignoring curly brace *'.PHP_EOL;
1988
+ }
1989
+
1990
+ $ignore--;
1991
+ continue;
1992
+ } else if ($tokens[$opener]['code'] === T_OPEN_CURLY_BRACKET
1993
+ && $tokenType !== T_CLOSE_CURLY_BRACKET
1994
+ ) {
1995
+ // The opener is a curly bracket so the closer must be a curly bracket as well.
1996
+ // We ignore this closer to handle cases such as T_ELSE or T_ELSEIF being considered
1997
+ // a closer of T_IF when it should not.
1998
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
1999
+ $type = $tokens[$stackPtr]['type'];
2000
+ echo str_repeat("\t", $depth);
2001
+ echo "=> Ignoring non-curly scope closer for $stackPtr:$type".PHP_EOL;
2002
+ }
2003
+ } else {
2004
+ $scopeCloser = $i;
2005
+ $todo = array(
2006
+ $stackPtr,
2007
+ $opener,
2008
+ );
2009
+
2010
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2011
+ $type = $tokens[$stackPtr]['type'];
2012
+ $closerType = $tokens[$scopeCloser]['type'];
2013
+ echo str_repeat("\t", $depth);
2014
+ echo "=> Found scope closer ($scopeCloser:$closerType) for $stackPtr:$type".PHP_EOL;
2015
+ }
2016
+
2017
+ $validCloser = true;
2018
+ if (($tokens[$stackPtr]['code'] === T_IF || $tokens[$stackPtr]['code'] === T_ELSEIF)
2019
+ && ($tokenType === T_ELSE || $tokenType === T_ELSEIF)
2020
+ ) {
2021
+ // To be a closer, this token must have an opener.
2022
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2023
+ echo str_repeat("\t", $depth);
2024
+ echo "* closer needs to be tested *".PHP_EOL;
2025
+ }
2026
+
2027
+ $i = self::_recurseScopeMap(
2028
+ $tokens,
2029
+ $numTokens,
2030
+ $tokenizer,
2031
+ $eolChar,
2032
+ $i,
2033
+ ($depth + 1),
2034
+ $ignore
2035
+ );
2036
+
2037
+ if (isset($tokens[$scopeCloser]['scope_opener']) === false) {
2038
+ $validCloser = false;
2039
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2040
+ echo str_repeat("\t", $depth);
2041
+ echo "* closer is not valid (no opener found) *".PHP_EOL;
2042
+ }
2043
+ } else if ($tokens[$tokens[$scopeCloser]['scope_opener']]['code'] !== $tokens[$opener]['code']) {
2044
+ $validCloser = false;
2045
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2046
+ echo str_repeat("\t", $depth);
2047
+ $type = $tokens[$tokens[$scopeCloser]['scope_opener']]['type'];
2048
+ $openerType = $tokens[$opener]['type'];
2049
+ echo "* closer is not valid (mismatched opener type; $type != $openerType) *".PHP_EOL;
2050
+ }
2051
+ } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
2052
+ echo str_repeat("\t", $depth);
2053
+ echo "* closer was valid *".PHP_EOL;
2054
+ }
2055
+ } else {
2056
+ // The closer was not processed, so we need to
2057
+ // complete that token as well.
2058
+ $todo[] = $scopeCloser;
2059
+ }//end if
2060
+
2061
+ if ($validCloser === true) {
2062
+ foreach ($todo as $token) {
2063
+ $tokens[$token]['scope_condition'] = $stackPtr;
2064
+ $tokens[$token]['scope_opener'] = $opener;
2065
+ $tokens[$token]['scope_closer'] = $scopeCloser;
2066
+ }
2067
+
2068
+ if ($tokenizer->scopeOpeners[$tokens[$stackPtr]['code']]['shared'] === true) {
2069
+ // As we are going back to where we started originally, restore
2070
+ // the ignore value back to its original value.
2071
+ $ignore = $originalIgnore;
2072
+ return $opener;
2073
+ } else if ($scopeCloser === $i
2074
+ && isset($tokenizer->scopeOpeners[$tokenType]) === true
2075
+ ) {
2076
+ // Unset scope_condition here or else the token will appear to have
2077
+ // already been processed, and it will be skipped. Normally we want that,
2078
+ // but in this case, the token is both a closer and an opener, so
2079
+ // it needs to act like an opener. This is also why we return the
2080
+ // token before this one; so the closer has a chance to be processed
2081
+ // a second time, but as an opener.
2082
+ unset($tokens[$scopeCloser]['scope_condition']);
2083
+ return ($i - 1);
2084
+ } else {
2085
+ return $i;
2086
+ }
2087
+ } else {
2088
+ continue;
2089
+ }//end if
2090
+ }//end if
2091
+ }//end if
2092
+
2093
+ // Is this an opening condition ?
2094
+ if (isset($tokenizer->scopeOpeners[$tokenType]) === true) {
2095
+ if ($opener === null) {
2096
+ if ($tokenType === T_USE) {
2097
+ // PHP use keywords are special because they can be
2098
+ // used as blocks but also inline in function definitions.
2099
+ // So if we find them nested inside another opener, just skip them.
2100
+ continue;
2101
+ }
2102
+
2103
+ if ($tokenType === T_FUNCTION
2104
+ && $tokens[$stackPtr]['code'] !== T_FUNCTION
2105
+ ) {
2106
+ // Probably a closure, so process it manually.
2107
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2108
+ $type = $tokens[$stackPtr]['type'];
2109
+ echo str_repeat("\t", $depth);
2110
+ echo "=> Found function before scope opener for $stackPtr:$type, processing manually".PHP_EOL;
2111
+ }
2112
+
2113
+ if (isset($tokens[$i]['scope_closer']) === true) {
2114
+ // We've already processed this closure.
2115
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2116
+ echo str_repeat("\t", $depth);
2117
+ echo '* already processed, skipping *'.PHP_EOL;
2118
+ }
2119
+
2120
+ $i = $tokens[$i]['scope_closer'];
2121
+ continue;
2122
+ }
2123
+
2124
+ $i = self::_recurseScopeMap(
2125
+ $tokens,
2126
+ $numTokens,
2127
+ $tokenizer,
2128
+ $eolChar,
2129
+ $i,
2130
+ ($depth + 1),
2131
+ $ignore
2132
+ );
2133
+
2134
+ continue;
2135
+ }//end if
2136
+
2137
+ // Found another opening condition but still haven't
2138
+ // found our opener, so we are never going to find one.
2139
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2140
+ $type = $tokens[$stackPtr]['type'];
2141
+ echo str_repeat("\t", $depth);
2142
+ echo "=> Found new opening condition before scope opener for $stackPtr:$type, ";
2143
+ }
2144
+
2145
+ if (($tokens[$stackPtr]['code'] === T_IF
2146
+ || $tokens[$stackPtr]['code'] === T_ELSEIF
2147
+ || $tokens[$stackPtr]['code'] === T_ELSE)
2148
+ && ($tokens[$i]['code'] === T_ELSE
2149
+ || $tokens[$i]['code'] === T_ELSEIF)
2150
+ ) {
2151
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2152
+ echo "continuing".PHP_EOL;
2153
+ }
2154
+
2155
+ return ($i - 1);
2156
+ } else {
2157
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2158
+ echo "backtracking".PHP_EOL;
2159
+ }
2160
+
2161
+ return $stackPtr;
2162
+ }
2163
+ }//end if
2164
+
2165
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2166
+ echo str_repeat("\t", $depth);
2167
+ echo '* token is an opening condition *'.PHP_EOL;
2168
+ }
2169
+
2170
+ $isShared = ($tokenizer->scopeOpeners[$tokenType]['shared'] === true);
2171
+
2172
+ if (isset($tokens[$i]['scope_condition']) === true) {
2173
+ // We've been here before.
2174
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2175
+ echo str_repeat("\t", $depth);
2176
+ echo '* already processed, skipping *'.PHP_EOL;
2177
+ }
2178
+
2179
+ if ($isShared === false
2180
+ && isset($tokens[$i]['scope_closer']) === true
2181
+ ) {
2182
+ $i = $tokens[$i]['scope_closer'];
2183
+ }
2184
+
2185
+ continue;
2186
+ } else if ($currType === $tokenType
2187
+ && $isShared === false
2188
+ && $opener === null
2189
+ ) {
2190
+ // We haven't yet found our opener, but we have found another
2191
+ // scope opener which is the same type as us, and we don't
2192
+ // share openers, so we will never find one.
2193
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2194
+ echo str_repeat("\t", $depth);
2195
+ echo '* it was another token\'s opener, bailing *'.PHP_EOL;
2196
+ }
2197
+
2198
+ return $stackPtr;
2199
+ } else {
2200
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2201
+ echo str_repeat("\t", $depth);
2202
+ echo '* searching for opener *'.PHP_EOL;
2203
+ }
2204
+
2205
+ if (isset($tokenizer->scopeOpeners[$tokenType]['end'][T_CLOSE_CURLY_BRACKET]) === true) {
2206
+ $oldIgnore = $ignore;
2207
+ $ignore = 0;
2208
+ }
2209
+
2210
+ // PHP has a max nesting level for functions. Stop before we hit that limit
2211
+ // because too many loops means we've run into trouble anyway.
2212
+ if ($depth > 50) {
2213
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2214
+ echo str_repeat("\t", $depth);
2215
+ echo '* reached maximum nesting level; aborting *'.PHP_EOL;
2216
+ }
2217
+
2218
+ throw new PHP_CodeSniffer_Exception('Maximum nesting level reached; file could not be processed');
2219
+ }
2220
+
2221
+ $oldDepth = $depth;
2222
+ if ($isShared === true
2223
+ && isset($tokenizer->scopeOpeners[$tokenType]['with'][$currType]) === true
2224
+ ) {
2225
+ // Don't allow the depth to increment because this is
2226
+ // possibly not a true nesting if we are sharing our closer.
2227
+ // This can happen, for example, when a SWITCH has a large
2228
+ // number of CASE statements with the same shared BREAK.
2229
+ $depth--;
2230
+ }
2231
+
2232
+ $i = self::_recurseScopeMap(
2233
+ $tokens,
2234
+ $numTokens,
2235
+ $tokenizer,
2236
+ $eolChar,
2237
+ $i,
2238
+ ($depth + 1),
2239
+ $ignore
2240
+ );
2241
+
2242
+ $depth = $oldDepth;
2243
+
2244
+ if (isset($tokenizer->scopeOpeners[$tokenType]['end'][T_CLOSE_CURLY_BRACKET]) === true) {
2245
+ $ignore = $oldIgnore;
2246
+ }
2247
+ }//end if
2248
+ }//end if
2249
+
2250
+ if (isset($tokenizer->scopeOpeners[$currType]['start'][$tokenType]) === true
2251
+ && $opener === null
2252
+ ) {
2253
+ if ($tokenType === T_OPEN_CURLY_BRACKET) {
2254
+ if (isset($tokens[$stackPtr]['parenthesis_closer']) === true
2255
+ && $i < $tokens[$stackPtr]['parenthesis_closer']
2256
+ ) {
2257
+ // We found a curly brace inside the condition of the
2258
+ // current scope opener, so it must be a string offset.
2259
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2260
+ echo str_repeat("\t", $depth);
2261
+ echo '* ignoring curly brace inside condition *'.PHP_EOL;
2262
+ }
2263
+
2264
+ $ignore++;
2265
+ } else {
2266
+ // Make sure this is actually an opener and not a
2267
+ // string offset (e.g., $var{0}).
2268
+ for ($x = ($i - 1); $x > 0; $x--) {
2269
+ if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[$x]['code']]) === true) {
2270
+ continue;
2271
+ } else {
2272
+ // If the first non-whitespace/comment token looks like this
2273
+ // brace is a string offset, or this brace is mid-way through
2274
+ // a new statement, it isn't a scope opener.
2275
+ $disallowed = PHP_CodeSniffer_Tokens::$assignmentTokens;
2276
+ $disallowed += array(
2277
+ T_VARIABLE => true,
2278
+ T_OBJECT_OPERATOR => true,
2279
+ T_COMMA => true,
2280
+ T_OPEN_PARENTHESIS => true,
2281
+ );
2282
+
2283
+ if (isset($disallowed[$tokens[$x]['code']]) === true) {
2284
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2285
+ echo str_repeat("\t", $depth);
2286
+ echo '* ignoring curly brace after condition *'.PHP_EOL;
2287
+ }
2288
+
2289
+ $ignore++;
2290
+ }//end if
2291
+
2292
+ break;
2293
+ }//end if
2294
+ }//end for
2295
+ }//end if
2296
+ }//end if
2297
+
2298
+ if ($ignore === 0 || $tokenType !== T_OPEN_CURLY_BRACKET) {
2299
+ // We found the opening scope token for $currType.
2300
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2301
+ $type = $tokens[$stackPtr]['type'];
2302
+ echo str_repeat("\t", $depth);
2303
+ echo "=> Found scope opener for $stackPtr:$type".PHP_EOL;
2304
+ }
2305
+
2306
+ $opener = $i;
2307
+ }
2308
+ } else if ($tokenType === T_OPEN_PARENTHESIS) {
2309
+ if (isset($tokens[$i]['parenthesis_owner']) === true) {
2310
+ $owner = $tokens[$i]['parenthesis_owner'];
2311
+ if (isset(PHP_CodeSniffer_Tokens::$scopeOpeners[$tokens[$owner]['code']]) === true
2312
+ && isset($tokens[$i]['parenthesis_closer']) === true
2313
+ ) {
2314
+ // If we get into here, then we opened a parenthesis for
2315
+ // a scope (eg. an if or else if) so we need to update the
2316
+ // start of the line so that when we check to see
2317
+ // if the closing parenthesis is more than 3 lines away from
2318
+ // the statement, we check from the closing parenthesis.
2319
+ $startLine = $tokens[$tokens[$i]['parenthesis_closer']]['line'];
2320
+ }
2321
+ }
2322
+ } else if ($tokenType === T_OPEN_CURLY_BRACKET && $opener !== null) {
2323
+ // We opened something that we don't have a scope opener for.
2324
+ // Examples of this are curly brackets for string offsets etc.
2325
+ // We want to ignore this so that we don't have an invalid scope
2326
+ // map.
2327
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2328
+ echo str_repeat("\t", $depth);
2329
+ echo '* ignoring curly brace *'.PHP_EOL;
2330
+ }
2331
+
2332
+ $ignore++;
2333
+ } else if ($tokenType === T_CLOSE_CURLY_BRACKET && $ignore > 0) {
2334
+ // We found the end token for the opener we were ignoring.
2335
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2336
+ echo str_repeat("\t", $depth);
2337
+ echo '* finished ignoring curly brace *'.PHP_EOL;
2338
+ }
2339
+
2340
+ $ignore--;
2341
+ } else if ($opener === null
2342
+ && isset($tokenizer->scopeOpeners[$currType]) === true
2343
+ ) {
2344
+ // If we still haven't found the opener after 3 lines,
2345
+ // we're not going to find it, unless we know it requires
2346
+ // an opener (in which case we better keep looking) or the last
2347
+ // token was empty (in which case we'll just confirm there is
2348
+ // more code in this file and not just a big comment).
2349
+ if ($tokens[$i]['line'] >= ($startLine + 3)
2350
+ && isset(PHP_CodeSniffer_Tokens::$emptyTokens[$tokens[($i - 1)]['code']]) === false
2351
+ ) {
2352
+ if ($tokenizer->scopeOpeners[$currType]['strict'] === true) {
2353
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2354
+ $type = $tokens[$stackPtr]['type'];
2355
+ $lines = ($tokens[$i]['line'] - $startLine);
2356
+ echo str_repeat("\t", $depth);
2357
+ echo "=> Still looking for $stackPtr:$type scope opener after $lines lines".PHP_EOL;
2358
+ }
2359
+ } else {
2360
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2361
+ $type = $tokens[$stackPtr]['type'];
2362
+ echo str_repeat("\t", $depth);
2363
+ echo "=> Couldn't find scope opener for $stackPtr:$type, bailing".PHP_EOL;
2364
+ }
2365
+
2366
+ return $stackPtr;
2367
+ }
2368
+ }
2369
+ } else if ($opener !== null
2370
+ && $tokenType !== T_BREAK
2371
+ && isset($tokenizer->endScopeTokens[$tokenType]) === true
2372
+ ) {
2373
+ if (isset($tokens[$i]['scope_condition']) === false) {
2374
+ if ($ignore > 0) {
2375
+ // We found the end token for the opener we were ignoring.
2376
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2377
+ echo str_repeat("\t", $depth);
2378
+ echo '* finished ignoring curly brace *'.PHP_EOL;
2379
+ }
2380
+
2381
+ $ignore--;
2382
+ } else {
2383
+ // We found a token that closes the scope but it doesn't
2384
+ // have a condition, so it belongs to another token and
2385
+ // our token doesn't have a closer, so pretend this is
2386
+ // the closer.
2387
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2388
+ $type = $tokens[$stackPtr]['type'];
2389
+ echo str_repeat("\t", $depth);
2390
+ echo "=> Found (unexpected) scope closer for $stackPtr:$type".PHP_EOL;
2391
+ }
2392
+
2393
+ foreach (array($stackPtr, $opener) as $token) {
2394
+ $tokens[$token]['scope_condition'] = $stackPtr;
2395
+ $tokens[$token]['scope_opener'] = $opener;
2396
+ $tokens[$token]['scope_closer'] = $i;
2397
+ }
2398
+
2399
+ return ($i - 1);
2400
+ }//end if
2401
+ }//end if
2402
+ }//end if
2403
+ }//end for
2404
+
2405
+ return $stackPtr;
2406
+
2407
+ }//end _recurseScopeMap()
2408
+
2409
+
2410
+ /**
2411
+ * Constructs the level map.
2412
+ *
2413
+ * The level map adds a 'level' index to each token which indicates the
2414
+ * depth that a token within a set of scope blocks. It also adds a
2415
+ * 'condition' index which is an array of the scope conditions that opened
2416
+ * each of the scopes - position 0 being the first scope opener.
2417
+ *
2418
+ * @param array $tokens The array of tokens to process.
2419
+ * @param object $tokenizer The tokenizer being used to process this file.
2420
+ * @param string $eolChar The EOL character to use for splitting strings.
2421
+ *
2422
+ * @return void
2423
+ */
2424
+ private static function _createLevelMap(&$tokens, $tokenizer, $eolChar)
2425
+ {
2426
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2427
+ echo "\t*** START LEVEL MAP ***".PHP_EOL;
2428
+ }
2429
+
2430
+ $numTokens = count($tokens);
2431
+ $level = 0;
2432
+ $conditions = array();
2433
+ $lastOpener = null;
2434
+ $openers = array();
2435
+
2436
+ for ($i = 0; $i < $numTokens; $i++) {
2437
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2438
+ $type = $tokens[$i]['type'];
2439
+ $line = $tokens[$i]['line'];
2440
+ $len = $tokens[$i]['length'];
2441
+ $col = $tokens[$i]['column'];
2442
+
2443
+ $content = PHP_CodeSniffer::prepareForOutput($tokens[$i]['content']);
2444
+
2445
+ echo str_repeat("\t", ($level + 1));
2446
+ echo "Process token $i on line $line [col:$col;len:$len;lvl:$level;";
2447
+ if (empty($conditions) !== true) {
2448
+ $condString = 'conds;';
2449
+ foreach ($conditions as $condition) {
2450
+ $condString .= token_name($condition).',';
2451
+ }
2452
+
2453
+ echo rtrim($condString, ',').';';
2454
+ }
2455
+
2456
+ echo "]: $type => $content".PHP_EOL;
2457
+ }//end if
2458
+
2459
+ $tokens[$i]['level'] = $level;
2460
+ $tokens[$i]['conditions'] = $conditions;
2461
+
2462
+ if (isset($tokens[$i]['scope_condition']) === true) {
2463
+ // Check to see if this token opened the scope.
2464
+ if ($tokens[$i]['scope_opener'] === $i) {
2465
+ $stackPtr = $tokens[$i]['scope_condition'];
2466
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2467
+ $type = $tokens[$stackPtr]['type'];
2468
+ echo str_repeat("\t", ($level + 1));
2469
+ echo "=> Found scope opener for $stackPtr:$type".PHP_EOL;
2470
+ }
2471
+
2472
+ $stackPtr = $tokens[$i]['scope_condition'];
2473
+
2474
+ // If we find a scope opener that has a shared closer,
2475
+ // then we need to go back over the condition map that we
2476
+ // just created and fix ourselves as we just added some
2477
+ // conditions where there was none. This happens for T_CASE
2478
+ // statements that are using the same break statement.
2479
+ if ($lastOpener !== null && $tokens[$lastOpener]['scope_closer'] === $tokens[$i]['scope_closer']) {
2480
+ // This opener shares its closer with the previous opener,
2481
+ // but we still need to check if the two openers share their
2482
+ // closer with each other directly (like CASE and DEFAULT)
2483
+ // or if they are just sharing because one doesn't have a
2484
+ // closer (like CASE with no BREAK using a SWITCHes closer).
2485
+ $thisType = $tokens[$tokens[$i]['scope_condition']]['code'];
2486
+ $opener = $tokens[$lastOpener]['scope_condition'];
2487
+
2488
+ $isShared = isset($tokenizer->scopeOpeners[$thisType]['with'][$tokens[$opener]['code']]);
2489
+
2490
+ reset($tokenizer->scopeOpeners[$thisType]['end']);
2491
+ reset($tokenizer->scopeOpeners[$tokens[$opener]['code']]['end']);
2492
+ $sameEnd = (current($tokenizer->scopeOpeners[$thisType]['end']) === current($tokenizer->scopeOpeners[$tokens[$opener]['code']]['end']));
2493
+
2494
+ if ($isShared === true && $sameEnd === true) {
2495
+ $badToken = $opener;
2496
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2497
+ $type = $tokens[$badToken]['type'];
2498
+ echo str_repeat("\t", ($level + 1));
2499
+ echo "* shared closer, cleaning up $badToken:$type *".PHP_EOL;
2500
+ }
2501
+
2502
+ for ($x = $tokens[$i]['scope_condition']; $x <= $i; $x++) {
2503
+ $oldConditions = $tokens[$x]['conditions'];
2504
+ $oldLevel = $tokens[$x]['level'];
2505
+ $tokens[$x]['level']--;
2506
+ unset($tokens[$x]['conditions'][$badToken]);
2507
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2508
+ $type = $tokens[$x]['type'];
2509
+ $oldConds = '';
2510
+ foreach ($oldConditions as $condition) {
2511
+ $oldConds .= token_name($condition).',';
2512
+ }
2513
+
2514
+ $oldConds = rtrim($oldConds, ',');
2515
+
2516
+ $newConds = '';
2517
+ foreach ($tokens[$x]['conditions'] as $condition) {
2518
+ $newConds .= token_name($condition).',';
2519
+ }
2520
+
2521
+ $newConds = rtrim($newConds, ',');
2522
+
2523
+ $newLevel = $tokens[$x]['level'];
2524
+ echo str_repeat("\t", ($level + 1));
2525
+ echo "* cleaned $x:$type *".PHP_EOL;
2526
+ echo str_repeat("\t", ($level + 2));
2527
+ echo "=> level changed from $oldLevel to $newLevel".PHP_EOL;
2528
+ echo str_repeat("\t", ($level + 2));
2529
+ echo "=> conditions changed from $oldConds to $newConds".PHP_EOL;
2530
+ }//end if
2531
+ }//end for
2532
+
2533
+ unset($conditions[$badToken]);
2534
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2535
+ $type = $tokens[$badToken]['type'];
2536
+ echo str_repeat("\t", ($level + 1));
2537
+ echo "* token $badToken:$type removed from conditions array *".PHP_EOL;
2538
+ }
2539
+
2540
+ unset($openers[$lastOpener]);
2541
+
2542
+ $level--;
2543
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2544
+ echo str_repeat("\t", ($level + 2));
2545
+ echo '* level decreased *'.PHP_EOL;
2546
+ }
2547
+ }//end if
2548
+ }//end if
2549
+
2550
+ $level++;
2551
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2552
+ echo str_repeat("\t", ($level + 1));
2553
+ echo '* level increased *'.PHP_EOL;
2554
+ }
2555
+
2556
+ $conditions[$stackPtr] = $tokens[$stackPtr]['code'];
2557
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2558
+ $type = $tokens[$stackPtr]['type'];
2559
+ echo str_repeat("\t", ($level + 1));
2560
+ echo "* token $stackPtr:$type added to conditions array *".PHP_EOL;
2561
+ }
2562
+
2563
+ $lastOpener = $tokens[$i]['scope_opener'];
2564
+ if ($lastOpener !== null) {
2565
+ $openers[$lastOpener] = $lastOpener;
2566
+ }
2567
+ } else if ($lastOpener !== null && $tokens[$lastOpener]['scope_closer'] === $i) {
2568
+ foreach (array_reverse($openers) as $opener) {
2569
+ if ($tokens[$opener]['scope_closer'] === $i) {
2570
+ $oldOpener = array_pop($openers);
2571
+ if (empty($openers) === false) {
2572
+ $lastOpener = array_pop($openers);
2573
+ $openers[$lastOpener] = $lastOpener;
2574
+ } else {
2575
+ $lastOpener = null;
2576
+ }
2577
+
2578
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2579
+ $type = $tokens[$oldOpener]['type'];
2580
+ echo str_repeat("\t", ($level + 1));
2581
+ echo "=> Found scope closer for $oldOpener:$type".PHP_EOL;
2582
+ }
2583
+
2584
+ $oldCondition = array_pop($conditions);
2585
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2586
+ echo str_repeat("\t", ($level + 1));
2587
+ echo '* token '.token_name($oldCondition).' removed from conditions array *'.PHP_EOL;
2588
+ }
2589
+
2590
+ // Make sure this closer actually belongs to us.
2591
+ // Either the condition also has to think this is the
2592
+ // closer, or it has to allow sharing with us.
2593
+ $condition = $tokens[$tokens[$i]['scope_condition']]['code'];
2594
+ if ($condition !== $oldCondition) {
2595
+ if (isset($tokenizer->scopeOpeners[$oldCondition]['with'][$condition]) === false) {
2596
+ $badToken = $tokens[$oldOpener]['scope_condition'];
2597
+
2598
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2599
+ $type = token_name($oldCondition);
2600
+ echo str_repeat("\t", ($level + 1));
2601
+ echo "* scope closer was bad, cleaning up $badToken:$type *".PHP_EOL;
2602
+ }
2603
+
2604
+ for ($x = ($oldOpener + 1); $x <= $i; $x++) {
2605
+ $oldConditions = $tokens[$x]['conditions'];
2606
+ $oldLevel = $tokens[$x]['level'];
2607
+ $tokens[$x]['level']--;
2608
+ unset($tokens[$x]['conditions'][$badToken]);
2609
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2610
+ $type = $tokens[$x]['type'];
2611
+ $oldConds = '';
2612
+ foreach ($oldConditions as $condition) {
2613
+ $oldConds .= token_name($condition).',';
2614
+ }
2615
+
2616
+ $oldConds = rtrim($oldConds, ',');
2617
+
2618
+ $newConds = '';
2619
+ foreach ($tokens[$x]['conditions'] as $condition) {
2620
+ $newConds .= token_name($condition).',';
2621
+ }
2622
+
2623
+ $newConds = rtrim($newConds, ',');
2624
+
2625
+ $newLevel = $tokens[$x]['level'];
2626
+ echo str_repeat("\t", ($level + 1));
2627
+ echo "* cleaned $x:$type *".PHP_EOL;
2628
+ echo str_repeat("\t", ($level + 2));
2629
+ echo "=> level changed from $oldLevel to $newLevel".PHP_EOL;
2630
+ echo str_repeat("\t", ($level + 2));
2631
+ echo "=> conditions changed from $oldConds to $newConds".PHP_EOL;
2632
+ }//end if
2633
+ }//end for
2634
+ }//end if
2635
+ }//end if
2636
+
2637
+ $level--;
2638
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2639
+ echo str_repeat("\t", ($level + 2));
2640
+ echo '* level decreased *'.PHP_EOL;
2641
+ }
2642
+
2643
+ $tokens[$i]['level'] = $level;
2644
+ $tokens[$i]['conditions'] = $conditions;
2645
+ }//end if
2646
+ }//end foreach
2647
+ }//end if
2648
+ }//end if
2649
+ }//end for
2650
+
2651
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
2652
+ echo "\t*** END LEVEL MAP ***".PHP_EOL;
2653
+ }
2654
+
2655
+ }//end _createLevelMap()
2656
+
2657
+
2658
+ /**
2659
+ * Returns the declaration names for classes, interfaces, and functions.
2660
+ *
2661
+ * @param int $stackPtr The position of the declaration token which
2662
+ * declared the class, interface, trait or function.
2663
+ *
2664
+ * @return string|null The name of the class, interface or function.
2665
+ * or NULL if the function or class is anonymous.
2666
+ * @throws PHP_CodeSniffer_Exception If the specified token is not of type
2667
+ * T_FUNCTION, T_CLASS, T_ANON_CLASS,
2668
+ * T_TRAIT or T_INTERFACE.
2669
+ */
2670
+ public function getDeclarationName($stackPtr)
2671
+ {
2672
+ $tokenCode = $this->_tokens[$stackPtr]['code'];
2673
+
2674
+ if ($tokenCode === T_ANON_CLASS) {
2675
+ return null;
2676
+ }
2677
+
2678
+ if ($tokenCode === T_CLOSURE) {
2679
+ return null;
2680
+ }
2681
+
2682
+ if ($tokenCode !== T_FUNCTION
2683
+ && $tokenCode !== T_CLASS
2684
+ && $tokenCode !== T_INTERFACE
2685
+ && $tokenCode !== T_TRAIT
2686
+ ) {
2687
+ throw new PHP_CodeSniffer_Exception('Token type "'.$this->_tokens[$stackPtr]['type'].'" is not T_FUNCTION, T_CLASS, T_INTERFACE or T_TRAIT');
2688
+ }
2689
+
2690
+ $content = null;
2691
+ for ($i = $stackPtr; $i < $this->numTokens; $i++) {
2692
+ if ($this->_tokens[$i]['code'] === T_STRING) {
2693
+ $content = $this->_tokens[$i]['content'];
2694
+ break;
2695
+ }
2696
+ }
2697
+
2698
+ return $content;
2699
+
2700
+ }//end getDeclarationName()
2701
+
2702
+
2703
+ /**
2704
+ * Check if the token at the specified position is a anonymous function.
2705
+ *
2706
+ * @param int $stackPtr The position of the declaration token which
2707
+ * declared the class, interface or function.
2708
+ *
2709
+ * @return boolean
2710
+ * @throws PHP_CodeSniffer_Exception If the specified token is not of type
2711
+ * T_FUNCTION
2712
+ */
2713
+ public function isAnonymousFunction($stackPtr)
2714
+ {
2715
+ $tokenCode = $this->_tokens[$stackPtr]['code'];
2716
+ if ($tokenCode !== T_FUNCTION) {
2717
+ throw new PHP_CodeSniffer_Exception('Token type is not T_FUNCTION');
2718
+ }
2719
+
2720
+ if (isset($this->_tokens[$stackPtr]['parenthesis_opener']) === false) {
2721
+ // Something is not right with this function.
2722
+ return false;
2723
+ }
2724
+
2725
+ $name = false;
2726
+ for ($i = ($stackPtr + 1); $i < $this->numTokens; $i++) {
2727
+ if ($this->_tokens[$i]['code'] === T_STRING) {
2728
+ $name = $i;
2729
+ break;
2730
+ }
2731
+ }
2732
+
2733
+ if ($name === false) {
2734
+ // No name found.
2735
+ return true;
2736
+ }
2737
+
2738
+ $open = $this->_tokens[$stackPtr]['parenthesis_opener'];
2739
+ if ($name > $open) {
2740
+ return true;
2741
+ }
2742
+
2743
+ return false;
2744
+
2745
+ }//end isAnonymousFunction()
2746
+
2747
+
2748
+ /**
2749
+ * Returns the method parameters for the specified function token.
2750
+ *
2751
+ * Each parameter is in the following format:
2752
+ *
2753
+ * <code>
2754
+ * 0 => array(
2755
+ * 'token' => int, // The position of the var in the token stack.
2756
+ * 'name' => '$var', // The variable name.
2757
+ * 'content' => string, // The full content of the variable definition.
2758
+ * 'pass_by_reference' => boolean, // Is the variable passed by reference?
2759
+ * 'variable_length' => boolean, // Is the param of variable length through use of `...` ?
2760
+ * 'type_hint' => string, // The type hint for the variable.
2761
+ * 'nullable_type' => boolean, // Is the variable using a nullable type?
2762
+ * )
2763
+ * </code>
2764
+ *
2765
+ * Parameters with default values have an additional array index of
2766
+ * 'default' with the value of the default as a string.
2767
+ *
2768
+ * @param int $stackPtr The position in the stack of the function token
2769
+ * to acquire the parameters for.
2770
+ *
2771
+ * @return array
2772
+ * @throws PHP_CodeSniffer_Exception If the specified $stackPtr is not of
2773
+ * type T_FUNCTION or T_CLOSURE.
2774
+ */
2775
+ public function getMethodParameters($stackPtr)
2776
+ {
2777
+ if ($this->_tokens[$stackPtr]['code'] !== T_FUNCTION
2778
+ && $this->_tokens[$stackPtr]['code'] !== T_CLOSURE
2779
+ ) {
2780
+ throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_FUNCTION or T_CLOSURE');
2781
+ }
2782
+
2783
+ $opener = $this->_tokens[$stackPtr]['parenthesis_opener'];
2784
+ $closer = $this->_tokens[$stackPtr]['parenthesis_closer'];
2785
+
2786
+ $vars = array();
2787
+ $currVar = null;
2788
+ $paramStart = ($opener + 1);
2789
+ $defaultStart = null;
2790
+ $paramCount = 0;
2791
+ $passByReference = false;
2792
+ $variableLength = false;
2793
+ $typeHint = '';
2794
+ $nullableType = false;
2795
+
2796
+ for ($i = $paramStart; $i <= $closer; $i++) {
2797
+ // Check to see if this token has a parenthesis or bracket opener. If it does
2798
+ // it's likely to be an array which might have arguments in it. This
2799
+ // could cause problems in our parsing below, so lets just skip to the
2800
+ // end of it.
2801
+ if (isset($this->_tokens[$i]['parenthesis_opener']) === true) {
2802
+ // Don't do this if it's the close parenthesis for the method.
2803
+ if ($i !== $this->_tokens[$i]['parenthesis_closer']) {
2804
+ $i = ($this->_tokens[$i]['parenthesis_closer'] + 1);
2805
+ }
2806
+ }
2807
+
2808
+ if (isset($this->_tokens[$i]['bracket_opener']) === true) {
2809
+ // Don't do this if it's the close parenthesis for the method.
2810
+ if ($i !== $this->_tokens[$i]['bracket_closer']) {
2811
+ $i = ($this->_tokens[$i]['bracket_closer'] + 1);
2812
+ }
2813
+ }
2814
+
2815
+ switch ($this->_tokens[$i]['code']) {
2816
+ case T_BITWISE_AND:
2817
+ $passByReference = true;
2818
+ break;
2819
+ case T_VARIABLE:
2820
+ $currVar = $i;
2821
+ break;
2822
+ case T_ELLIPSIS:
2823
+ $variableLength = true;
2824
+ break;
2825
+ case T_ARRAY_HINT:
2826
+ case T_CALLABLE:
2827
+ $typeHint .= $this->_tokens[$i]['content'];
2828
+ break;
2829
+ case T_SELF:
2830
+ case T_PARENT:
2831
+ case T_STATIC:
2832
+ // Self is valid, the others invalid, but were probably intended as type hints.
2833
+ if (isset($defaultStart) === false) {
2834
+ $typeHint .= $this->_tokens[$i]['content'];
2835
+ }
2836
+ break;
2837
+ case T_STRING:
2838
+ // This is a string, so it may be a type hint, but it could
2839
+ // also be a constant used as a default value.
2840
+ $prevComma = false;
2841
+ for ($t = $i; $t >= $opener; $t--) {
2842
+ if ($this->_tokens[$t]['code'] === T_COMMA) {
2843
+ $prevComma = $t;
2844
+ break;
2845
+ }
2846
+ }
2847
+
2848
+ if ($prevComma !== false) {
2849
+ $nextEquals = false;
2850
+ for ($t = $prevComma; $t < $i; $t++) {
2851
+ if ($this->_tokens[$t]['code'] === T_EQUAL) {
2852
+ $nextEquals = $t;
2853
+ break;
2854
+ }
2855
+ }
2856
+
2857
+ if ($nextEquals !== false) {
2858
+ break;
2859
+ }
2860
+ }
2861
+
2862
+ if ($defaultStart === null) {
2863
+ $typeHint .= $this->_tokens[$i]['content'];
2864
+ }
2865
+ break;
2866
+ case T_NS_SEPARATOR:
2867
+ // Part of a type hint or default value.
2868
+ if ($defaultStart === null) {
2869
+ $typeHint .= $this->_tokens[$i]['content'];
2870
+ }
2871
+ break;
2872
+ case T_NULLABLE:
2873
+ if ($defaultStart === null) {
2874
+ $nullableType = true;
2875
+ $typeHint .= $this->_tokens[$i]['content'];
2876
+ }
2877
+ break;
2878
+ case T_CLOSE_PARENTHESIS:
2879
+ case T_COMMA:
2880
+ // If it's null, then there must be no parameters for this
2881
+ // method.
2882
+ if ($currVar === null) {
2883
+ continue;
2884
+ }
2885
+
2886
+ $vars[$paramCount] = array();
2887
+ $vars[$paramCount]['token'] = $currVar;
2888
+ $vars[$paramCount]['name'] = $this->_tokens[$currVar]['content'];
2889
+ $vars[$paramCount]['content'] = trim($this->getTokensAsString($paramStart, ($i - $paramStart)));
2890
+
2891
+ if ($defaultStart !== null) {
2892
+ $vars[$paramCount]['default'] = trim($this->getTokensAsString($defaultStart, ($i - $defaultStart)));
2893
+ }
2894
+
2895
+ $vars[$paramCount]['pass_by_reference'] = $passByReference;
2896
+ $vars[$paramCount]['variable_length'] = $variableLength;
2897
+ $vars[$paramCount]['type_hint'] = $typeHint;
2898
+ $vars[$paramCount]['nullable_type'] = $nullableType;
2899
+
2900
+ // Reset the vars, as we are about to process the next parameter.
2901
+ $defaultStart = null;
2902
+ $paramStart = ($i + 1);
2903
+ $passByReference = false;
2904
+ $variableLength = false;
2905
+ $typeHint = '';
2906
+ $nullableType = false;
2907
+
2908
+ $paramCount++;
2909
+ break;
2910
+ case T_EQUAL:
2911
+ $defaultStart = ($i + 1);
2912
+ break;
2913
+ }//end switch
2914
+ }//end for
2915
+
2916
+ return $vars;
2917
+
2918
+ }//end getMethodParameters()
2919
+
2920
+
2921
+ /**
2922
+ * Returns the visibility and implementation properties of a method.
2923
+ *
2924
+ * The format of the array is:
2925
+ * <code>
2926
+ * array(
2927
+ * 'scope' => 'public', // public private or protected
2928
+ * 'scope_specified' => true, // true is scope keyword was found.
2929
+ * 'is_abstract' => false, // true if the abstract keyword was found.
2930
+ * 'is_final' => false, // true if the final keyword was found.
2931
+ * 'is_static' => false, // true if the static keyword was found.
2932
+ * 'is_closure' => false, // true if no name is found.
2933
+ * );
2934
+ * </code>
2935
+ *
2936
+ * @param int $stackPtr The position in the stack of the T_FUNCTION token to
2937
+ * acquire the properties for.
2938
+ *
2939
+ * @return array
2940
+ * @throws PHP_CodeSniffer_Exception If the specified position is not a
2941
+ * T_FUNCTION token.
2942
+ */
2943
+ public function getMethodProperties($stackPtr)
2944
+ {
2945
+ if ($this->_tokens[$stackPtr]['code'] !== T_FUNCTION) {
2946
+ throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_FUNCTION');
2947
+ }
2948
+
2949
+ $valid = array(
2950
+ T_PUBLIC => T_PUBLIC,
2951
+ T_PRIVATE => T_PRIVATE,
2952
+ T_PROTECTED => T_PROTECTED,
2953
+ T_STATIC => T_STATIC,
2954
+ T_FINAL => T_FINAL,
2955
+ T_ABSTRACT => T_ABSTRACT,
2956
+ T_WHITESPACE => T_WHITESPACE,
2957
+ T_COMMENT => T_COMMENT,
2958
+ T_DOC_COMMENT => T_DOC_COMMENT,
2959
+ );
2960
+
2961
+ $scope = 'public';
2962
+ $scopeSpecified = false;
2963
+ $isAbstract = false;
2964
+ $isFinal = false;
2965
+ $isStatic = false;
2966
+ $isClosure = $this->isAnonymousFunction($stackPtr);
2967
+
2968
+ for ($i = ($stackPtr - 1); $i > 0; $i--) {
2969
+ if (isset($valid[$this->_tokens[$i]['code']]) === false) {
2970
+ break;
2971
+ }
2972
+
2973
+ switch ($this->_tokens[$i]['code']) {
2974
+ case T_PUBLIC:
2975
+ $scope = 'public';
2976
+ $scopeSpecified = true;
2977
+ break;
2978
+ case T_PRIVATE:
2979
+ $scope = 'private';
2980
+ $scopeSpecified = true;
2981
+ break;
2982
+ case T_PROTECTED:
2983
+ $scope = 'protected';
2984
+ $scopeSpecified = true;
2985
+ break;
2986
+ case T_ABSTRACT:
2987
+ $isAbstract = true;
2988
+ break;
2989
+ case T_FINAL:
2990
+ $isFinal = true;
2991
+ break;
2992
+ case T_STATIC:
2993
+ $isStatic = true;
2994
+ break;
2995
+ }//end switch
2996
+ }//end for
2997
+
2998
+ return array(
2999
+ 'scope' => $scope,
3000
+ 'scope_specified' => $scopeSpecified,
3001
+ 'is_abstract' => $isAbstract,
3002
+ 'is_final' => $isFinal,
3003
+ 'is_static' => $isStatic,
3004
+ 'is_closure' => $isClosure,
3005
+ );
3006
+
3007
+ }//end getMethodProperties()
3008
+
3009
+
3010
+ /**
3011
+ * Returns the visibility and implementation properties of the class member
3012
+ * variable found at the specified position in the stack.
3013
+ *
3014
+ * The format of the array is:
3015
+ *
3016
+ * <code>
3017
+ * array(
3018
+ * 'scope' => 'public', // public private or protected
3019
+ * 'is_static' => false, // true if the static keyword was found.
3020
+ * );
3021
+ * </code>
3022
+ *
3023
+ * @param int $stackPtr The position in the stack of the T_VARIABLE token to
3024
+ * acquire the properties for.
3025
+ *
3026
+ * @return array
3027
+ * @throws PHP_CodeSniffer_Exception If the specified position is not a
3028
+ * T_VARIABLE token, or if the position is not
3029
+ * a class member variable.
3030
+ */
3031
+ public function getMemberProperties($stackPtr)
3032
+ {
3033
+ if ($this->_tokens[$stackPtr]['code'] !== T_VARIABLE) {
3034
+ throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_VARIABLE');
3035
+ }
3036
+
3037
+ $conditions = array_keys($this->_tokens[$stackPtr]['conditions']);
3038
+ $ptr = array_pop($conditions);
3039
+ if (isset($this->_tokens[$ptr]) === false
3040
+ || ($this->_tokens[$ptr]['code'] !== T_CLASS
3041
+ && $this->_tokens[$ptr]['code'] !== T_ANON_CLASS
3042
+ && $this->_tokens[$ptr]['code'] !== T_TRAIT)
3043
+ ) {
3044
+ if (isset($this->_tokens[$ptr]) === true
3045
+ && $this->_tokens[$ptr]['code'] === T_INTERFACE
3046
+ ) {
3047
+ // T_VARIABLEs in interfaces can actually be method arguments
3048
+ // but they wont be seen as being inside the method because there
3049
+ // are no scope openers and closers for abstract methods. If it is in
3050
+ // parentheses, we can be pretty sure it is a method argument.
3051
+ if (isset($this->_tokens[$stackPtr]['nested_parenthesis']) === false
3052
+ || empty($this->_tokens[$stackPtr]['nested_parenthesis']) === true
3053
+ ) {
3054
+ $error = 'Possible parse error: interfaces may not include member vars';
3055
+ $this->addWarning($error, $stackPtr, 'Internal.ParseError.InterfaceHasMemberVar');
3056
+ return array();
3057
+ }
3058
+ } else {
3059
+ throw new PHP_CodeSniffer_Exception('$stackPtr is not a class member var');
3060
+ }
3061
+ }
3062
+
3063
+ $valid = array(
3064
+ T_PUBLIC => T_PUBLIC,
3065
+ T_PRIVATE => T_PRIVATE,
3066
+ T_PROTECTED => T_PROTECTED,
3067
+ T_STATIC => T_STATIC,
3068
+ T_WHITESPACE => T_WHITESPACE,
3069
+ T_COMMENT => T_COMMENT,
3070
+ T_DOC_COMMENT => T_DOC_COMMENT,
3071
+ T_VARIABLE => T_VARIABLE,
3072
+ T_COMMA => T_COMMA,
3073
+ );
3074
+
3075
+ $scope = 'public';
3076
+ $scopeSpecified = false;
3077
+ $isStatic = false;
3078
+
3079
+ for ($i = ($stackPtr - 1); $i > 0; $i--) {
3080
+ if (isset($valid[$this->_tokens[$i]['code']]) === false) {
3081
+ break;
3082
+ }
3083
+
3084
+ switch ($this->_tokens[$i]['code']) {
3085
+ case T_PUBLIC:
3086
+ $scope = 'public';
3087
+ $scopeSpecified = true;
3088
+ break;
3089
+ case T_PRIVATE:
3090
+ $scope = 'private';
3091
+ $scopeSpecified = true;
3092
+ break;
3093
+ case T_PROTECTED:
3094
+ $scope = 'protected';
3095
+ $scopeSpecified = true;
3096
+ break;
3097
+ case T_STATIC:
3098
+ $isStatic = true;
3099
+ break;
3100
+ }
3101
+ }//end for
3102
+
3103
+ return array(
3104
+ 'scope' => $scope,
3105
+ 'scope_specified' => $scopeSpecified,
3106
+ 'is_static' => $isStatic,
3107
+ );
3108
+
3109
+ }//end getMemberProperties()
3110
+
3111
+
3112
+ /**
3113
+ * Returns the visibility and implementation properties of a class.
3114
+ *
3115
+ * The format of the array is:
3116
+ * <code>
3117
+ * array(
3118
+ * 'is_abstract' => false, // true if the abstract keyword was found.
3119
+ * 'is_final' => false, // true if the final keyword was found.
3120
+ * );
3121
+ * </code>
3122
+ *
3123
+ * @param int $stackPtr The position in the stack of the T_CLASS token to
3124
+ * acquire the properties for.
3125
+ *
3126
+ * @return array
3127
+ * @throws PHP_CodeSniffer_Exception If the specified position is not a
3128
+ * T_CLASS token.
3129
+ */
3130
+ public function getClassProperties($stackPtr)
3131
+ {
3132
+ if ($this->_tokens[$stackPtr]['code'] !== T_CLASS) {
3133
+ throw new PHP_CodeSniffer_Exception('$stackPtr must be of type T_CLASS');
3134
+ }
3135
+
3136
+ $valid = array(
3137
+ T_FINAL => T_FINAL,
3138
+ T_ABSTRACT => T_ABSTRACT,
3139
+ T_WHITESPACE => T_WHITESPACE,
3140
+ T_COMMENT => T_COMMENT,
3141
+ T_DOC_COMMENT => T_DOC_COMMENT,
3142
+ );
3143
+
3144
+ $isAbstract = false;
3145
+ $isFinal = false;
3146
+
3147
+ for ($i = ($stackPtr - 1); $i > 0; $i--) {
3148
+ if (isset($valid[$this->_tokens[$i]['code']]) === false) {
3149
+ break;
3150
+ }
3151
+
3152
+ switch ($this->_tokens[$i]['code']) {
3153
+ case T_ABSTRACT:
3154
+ $isAbstract = true;
3155
+ break;
3156
+
3157
+ case T_FINAL:
3158
+ $isFinal = true;
3159
+ break;
3160
+ }
3161
+ }//end for
3162
+
3163
+ return array(
3164
+ 'is_abstract' => $isAbstract,
3165
+ 'is_final' => $isFinal,
3166
+ );
3167
+
3168
+ }//end getClassProperties()
3169
+
3170
+
3171
+ /**
3172
+ * Determine if the passed token is a reference operator.
3173
+ *
3174
+ * Returns true if the specified token position represents a reference.
3175
+ * Returns false if the token represents a bitwise operator.
3176
+ *
3177
+ * @param int $stackPtr The position of the T_BITWISE_AND token.
3178
+ *
3179
+ * @return boolean
3180
+ */
3181
+ public function isReference($stackPtr)
3182
+ {
3183
+ if ($this->_tokens[$stackPtr]['code'] !== T_BITWISE_AND) {
3184
+ return false;
3185
+ }
3186
+
3187
+ $tokenBefore = $this->findPrevious(
3188
+ PHP_CodeSniffer_Tokens::$emptyTokens,
3189
+ ($stackPtr - 1),
3190
+ null,
3191
+ true
3192
+ );
3193
+
3194
+ if ($this->_tokens[$tokenBefore]['code'] === T_FUNCTION) {
3195
+ // Function returns a reference.
3196
+ return true;
3197
+ }
3198
+
3199
+ if ($this->_tokens[$tokenBefore]['code'] === T_DOUBLE_ARROW) {
3200
+ // Inside a foreach loop, this is a reference.
3201
+ return true;
3202
+ }
3203
+
3204
+ if ($this->_tokens[$tokenBefore]['code'] === T_AS) {
3205
+ // Inside a foreach loop, this is a reference.
3206
+ return true;
3207
+ }
3208
+
3209
+ if ($this->_tokens[$tokenBefore]['code'] === T_OPEN_SHORT_ARRAY) {
3210
+ // Inside an array declaration, this is a reference.
3211
+ return true;
3212
+ }
3213
+
3214
+ if (isset(PHP_CodeSniffer_Tokens::$assignmentTokens[$this->_tokens[$tokenBefore]['code']]) === true) {
3215
+ // This is directly after an assignment. It's a reference. Even if
3216
+ // it is part of an operation, the other tests will handle it.
3217
+ return true;
3218
+ }
3219
+
3220
+ if (isset($this->_tokens[$stackPtr]['nested_parenthesis']) === true) {
3221
+ $brackets = $this->_tokens[$stackPtr]['nested_parenthesis'];
3222
+ $lastBracket = array_pop($brackets);
3223
+ if (isset($this->_tokens[$lastBracket]['parenthesis_owner']) === true) {
3224
+ $owner = $this->_tokens[$this->_tokens[$lastBracket]['parenthesis_owner']];
3225
+ if ($owner['code'] === T_FUNCTION
3226
+ || $owner['code'] === T_CLOSURE
3227
+ || $owner['code'] === T_ARRAY
3228
+ ) {
3229
+ // Inside a function or array declaration, this is a reference.
3230
+ return true;
3231
+ }
3232
+ } else {
3233
+ $prev = false;
3234
+ for ($t = ($this->_tokens[$lastBracket]['parenthesis_opener'] - 1); $t >= 0; $t--) {
3235
+ if ($this->_tokens[$t]['code'] !== T_WHITESPACE) {
3236
+ $prev = $t;
3237
+ break;
3238
+ }
3239
+ }
3240
+
3241
+ if ($prev !== false && $this->_tokens[$prev]['code'] === T_USE) {
3242
+ return true;
3243
+ }
3244
+ }//end if
3245
+ }//end if
3246
+
3247
+ $tokenAfter = $this->findNext(
3248
+ PHP_CodeSniffer_Tokens::$emptyTokens,
3249
+ ($stackPtr + 1),
3250
+ null,
3251
+ true
3252
+ );
3253
+
3254
+ if ($this->_tokens[$tokenAfter]['code'] === T_VARIABLE
3255
+ && ($this->_tokens[$tokenBefore]['code'] === T_OPEN_PARENTHESIS
3256
+ || $this->_tokens[$tokenBefore]['code'] === T_COMMA)
3257
+ ) {
3258
+ return true;
3259
+ }
3260
+
3261
+ return false;
3262
+
3263
+ }//end isReference()
3264
+
3265
+
3266
+ /**
3267
+ * Returns the content of the tokens from the specified start position in
3268
+ * the token stack for the specified length.
3269
+ *
3270
+ * @param int $start The position to start from in the token stack.
3271
+ * @param int $length The length of tokens to traverse from the start pos.
3272
+ *
3273
+ * @return string The token contents.
3274
+ */
3275
+ public function getTokensAsString($start, $length)
3276
+ {
3277
+ $str = '';
3278
+ $end = ($start + $length);
3279
+ if ($end > $this->numTokens) {
3280
+ $end = $this->numTokens;
3281
+ }
3282
+
3283
+ for ($i = $start; $i < $end; $i++) {
3284
+ $str .= $this->_tokens[$i]['content'];
3285
+ }
3286
+
3287
+ return $str;
3288
+
3289
+ }//end getTokensAsString()
3290
+
3291
+
3292
+ /**
3293
+ * Returns the position of the previous specified token(s).
3294
+ *
3295
+ * If a value is specified, the previous token of the specified type(s)
3296
+ * containing the specified value will be returned.
3297
+ *
3298
+ * Returns false if no token can be found.
3299
+ *
3300
+ * @param int|array $types The type(s) of tokens to search for.
3301
+ * @param int $start The position to start searching from in the
3302
+ * token stack.
3303
+ * @param int $end The end position to fail if no token is found.
3304
+ * if not specified or null, end will default to
3305
+ * the start of the token stack.
3306
+ * @param bool $exclude If true, find the previous token that are NOT of
3307
+ * the types specified in $types.
3308
+ * @param string $value The value that the token(s) must be equal to.
3309
+ * If value is omitted, tokens with any value will
3310
+ * be returned.
3311
+ * @param bool $local If true, tokens outside the current statement
3312
+ * will not be checked. IE. checking will stop
3313
+ * at the previous semi-colon found.
3314
+ *
3315
+ * @return int|bool
3316
+ * @see findNext()
3317
+ */
3318
+ public function findPrevious(
3319
+ $types,
3320
+ $start,
3321
+ $end=null,
3322
+ $exclude=false,
3323
+ $value=null,
3324
+ $local=false
3325
+ ) {
3326
+ $types = (array) $types;
3327
+
3328
+ if ($end === null) {
3329
+ $end = 0;
3330
+ }
3331
+
3332
+ for ($i = $start; $i >= $end; $i--) {
3333
+ $found = (bool) $exclude;
3334
+ foreach ($types as $type) {
3335
+ if ($this->_tokens[$i]['code'] === $type) {
3336
+ $found = !$exclude;
3337
+ break;
3338
+ }
3339
+ }
3340
+
3341
+ if ($found === true) {
3342
+ if ($value === null) {
3343
+ return $i;
3344
+ } else if ($this->_tokens[$i]['content'] === $value) {
3345
+ return $i;
3346
+ }
3347
+ }
3348
+
3349
+ if ($local === true) {
3350
+ if (isset($this->_tokens[$i]['scope_opener']) === true
3351
+ && $i === $this->_tokens[$i]['scope_closer']
3352
+ ) {
3353
+ $i = $this->_tokens[$i]['scope_opener'];
3354
+ } else if (isset($this->_tokens[$i]['bracket_opener']) === true
3355
+ && $i === $this->_tokens[$i]['bracket_closer']
3356
+ ) {
3357
+ $i = $this->_tokens[$i]['bracket_opener'];
3358
+ } else if (isset($this->_tokens[$i]['parenthesis_opener']) === true
3359
+ && $i === $this->_tokens[$i]['parenthesis_closer']
3360
+ ) {
3361
+ $i = $this->_tokens[$i]['parenthesis_opener'];
3362
+ } else if ($this->_tokens[$i]['code'] === T_SEMICOLON) {
3363
+ break;
3364
+ }
3365
+ }
3366
+ }//end for
3367
+
3368
+ return false;
3369
+
3370
+ }//end findPrevious()
3371
+
3372
+
3373
+ /**
3374
+ * Returns the position of the next specified token(s).
3375
+ *
3376
+ * If a value is specified, the next token of the specified type(s)
3377
+ * containing the specified value will be returned.
3378
+ *
3379
+ * Returns false if no token can be found.
3380
+ *
3381
+ * @param int|array $types The type(s) of tokens to search for.
3382
+ * @param int $start The position to start searching from in the
3383
+ * token stack.
3384
+ * @param int $end The end position to fail if no token is found.
3385
+ * if not specified or null, end will default to
3386
+ * the end of the token stack.
3387
+ * @param bool $exclude If true, find the next token that is NOT of
3388
+ * a type specified in $types.
3389
+ * @param string $value The value that the token(s) must be equal to.
3390
+ * If value is omitted, tokens with any value will
3391
+ * be returned.
3392
+ * @param bool $local If true, tokens outside the current statement
3393
+ * will not be checked. i.e., checking will stop
3394
+ * at the next semi-colon found.
3395
+ *
3396
+ * @return int|bool
3397
+ * @see findPrevious()
3398
+ */
3399
+ public function findNext(
3400
+ $types,
3401
+ $start,
3402
+ $end=null,
3403
+ $exclude=false,
3404
+ $value=null,
3405
+ $local=false
3406
+ ) {
3407
+ $types = (array) $types;
3408
+
3409
+ if ($end === null || $end > $this->numTokens) {
3410
+ $end = $this->numTokens;
3411
+ }
3412
+
3413
+ for ($i = $start; $i < $end; $i++) {
3414
+ $found = (bool) $exclude;
3415
+ foreach ($types as $type) {
3416
+ if ($this->_tokens[$i]['code'] === $type) {
3417
+ $found = !$exclude;
3418
+ break;
3419
+ }
3420
+ }
3421
+
3422
+ if ($found === true) {
3423
+ if ($value === null) {
3424
+ return $i;
3425
+ } else if ($this->_tokens[$i]['content'] === $value) {
3426
+ return $i;
3427
+ }
3428
+ }
3429
+
3430
+ if ($local === true && $this->_tokens[$i]['code'] === T_SEMICOLON) {
3431
+ break;
3432
+ }
3433
+ }//end for
3434
+
3435
+ return false;
3436
+
3437
+ }//end findNext()
3438
+
3439
+
3440
+ /**
3441
+ * Returns the position of the first non-whitespace token in a statement.
3442
+ *
3443
+ * @param int $start The position to start searching from in the token stack.
3444
+ * @param int|array $ignore Token types that should not be considered stop points.
3445
+ *
3446
+ * @return int
3447
+ */
3448
+ public function findStartOfStatement($start, $ignore=null)
3449
+ {
3450
+ $endTokens = PHP_CodeSniffer_Tokens::$blockOpeners;
3451
+
3452
+ $endTokens[T_COLON] = true;
3453
+ $endTokens[T_COMMA] = true;
3454
+ $endTokens[T_DOUBLE_ARROW] = true;
3455
+ $endTokens[T_SEMICOLON] = true;
3456
+ $endTokens[T_OPEN_TAG] = true;
3457
+ $endTokens[T_CLOSE_TAG] = true;
3458
+ $endTokens[T_OPEN_SHORT_ARRAY] = true;
3459
+
3460
+ if ($ignore !== null) {
3461
+ $ignore = (array) $ignore;
3462
+ foreach ($ignore as $code) {
3463
+ if (isset($endTokens[$code]) === true) {
3464
+ unset($endTokens[$code]);
3465
+ }
3466
+ }
3467
+ }
3468
+
3469
+ $lastNotEmpty = $start;
3470
+
3471
+ for ($i = $start; $i >= 0; $i--) {
3472
+ if (isset($endTokens[$this->_tokens[$i]['code']]) === true) {
3473
+ // Found the end of the previous statement.
3474
+ return $lastNotEmpty;
3475
+ }
3476
+
3477
+ if (isset($this->_tokens[$i]['scope_opener']) === true
3478
+ && $i === $this->_tokens[$i]['scope_closer']
3479
+ ) {
3480
+ // Found the end of the previous scope block.
3481
+ return $lastNotEmpty;
3482
+ }
3483
+
3484
+ // Skip nested statements.
3485
+ if (isset($this->_tokens[$i]['bracket_opener']) === true
3486
+ && $i === $this->_tokens[$i]['bracket_closer']
3487
+ ) {
3488
+ $i = $this->_tokens[$i]['bracket_opener'];
3489
+ } else if (isset($this->_tokens[$i]['parenthesis_opener']) === true
3490
+ && $i === $this->_tokens[$i]['parenthesis_closer']
3491
+ ) {
3492
+ $i = $this->_tokens[$i]['parenthesis_opener'];
3493
+ }
3494
+
3495
+ if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$this->_tokens[$i]['code']]) === false) {
3496
+ $lastNotEmpty = $i;
3497
+ }
3498
+ }//end for
3499
+
3500
+ return 0;
3501
+
3502
+ }//end findStartOfStatement()
3503
+
3504
+
3505
+ /**
3506
+ * Returns the position of the last non-whitespace token in a statement.
3507
+ *
3508
+ * @param int $start The position to start searching from in the token stack.
3509
+ * @param int|array $ignore Token types that should not be considered stop points.
3510
+ *
3511
+ * @return int
3512
+ */
3513
+ public function findEndOfStatement($start, $ignore=null)
3514
+ {
3515
+ $endTokens = array(
3516
+ T_COLON => true,
3517
+ T_COMMA => true,
3518
+ T_DOUBLE_ARROW => true,
3519
+ T_SEMICOLON => true,
3520
+ T_CLOSE_PARENTHESIS => true,
3521
+ T_CLOSE_SQUARE_BRACKET => true,
3522
+ T_CLOSE_CURLY_BRACKET => true,
3523
+ T_CLOSE_SHORT_ARRAY => true,
3524
+ T_OPEN_TAG => true,
3525
+ T_CLOSE_TAG => true,
3526
+ );
3527
+
3528
+ if ($ignore !== null) {
3529
+ $ignore = (array) $ignore;
3530
+ foreach ($ignore as $code) {
3531
+ if (isset($endTokens[$code]) === true) {
3532
+ unset($endTokens[$code]);
3533
+ }
3534
+ }
3535
+ }
3536
+
3537
+ $lastNotEmpty = $start;
3538
+
3539
+ for ($i = $start; $i < $this->numTokens; $i++) {
3540
+ if ($i !== $start && isset($endTokens[$this->_tokens[$i]['code']]) === true) {
3541
+ // Found the end of the statement.
3542
+ if ($this->_tokens[$i]['code'] === T_CLOSE_PARENTHESIS
3543
+ || $this->_tokens[$i]['code'] === T_CLOSE_SQUARE_BRACKET
3544
+ || $this->_tokens[$i]['code'] === T_CLOSE_CURLY_BRACKET
3545
+ || $this->_tokens[$i]['code'] === T_CLOSE_SHORT_ARRAY
3546
+ || $this->_tokens[$i]['code'] === T_OPEN_TAG
3547
+ || $this->_tokens[$i]['code'] === T_CLOSE_TAG
3548
+ ) {
3549
+ return $lastNotEmpty;
3550
+ }
3551
+
3552
+ return $i;
3553
+ }
3554
+
3555
+ // Skip nested statements.
3556
+ if (isset($this->_tokens[$i]['scope_closer']) === true
3557
+ && ($i === $this->_tokens[$i]['scope_opener']
3558
+ || $i === $this->_tokens[$i]['scope_condition'])
3559
+ ) {
3560
+ $i = $this->_tokens[$i]['scope_closer'];
3561
+ } else if (isset($this->_tokens[$i]['bracket_closer']) === true
3562
+ && $i === $this->_tokens[$i]['bracket_opener']
3563
+ ) {
3564
+ $i = $this->_tokens[$i]['bracket_closer'];
3565
+ } else if (isset($this->_tokens[$i]['parenthesis_closer']) === true
3566
+ && $i === $this->_tokens[$i]['parenthesis_opener']
3567
+ ) {
3568
+ $i = $this->_tokens[$i]['parenthesis_closer'];
3569
+ }
3570
+
3571
+ if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$this->_tokens[$i]['code']]) === false) {
3572
+ $lastNotEmpty = $i;
3573
+ }
3574
+ }//end for
3575
+
3576
+ return ($this->numTokens - 1);
3577
+
3578
+ }//end findEndOfStatement()
3579
+
3580
+
3581
+ /**
3582
+ * Returns the position of the first token on a line, matching given type.
3583
+ *
3584
+ * Returns false if no token can be found.
3585
+ *
3586
+ * @param int|array $types The type(s) of tokens to search for.
3587
+ * @param int $start The position to start searching from in the
3588
+ * token stack. The first token matching on
3589
+ * this line before this token will be returned.
3590
+ * @param bool $exclude If true, find the token that is NOT of
3591
+ * the types specified in $types.
3592
+ * @param string $value The value that the token must be equal to.
3593
+ * If value is omitted, tokens with any value will
3594
+ * be returned.
3595
+ *
3596
+ * @return int | bool
3597
+ */
3598
+ public function findFirstOnLine($types, $start, $exclude=false, $value=null)
3599
+ {
3600
+ if (is_array($types) === false) {
3601
+ $types = array($types);
3602
+ }
3603
+
3604
+ $foundToken = false;
3605
+
3606
+ for ($i = $start; $i >= 0; $i--) {
3607
+ if ($this->_tokens[$i]['line'] < $this->_tokens[$start]['line']) {
3608
+ break;
3609
+ }
3610
+
3611
+ $found = $exclude;
3612
+ foreach ($types as $type) {
3613
+ if ($exclude === false) {
3614
+ if ($this->_tokens[$i]['code'] === $type) {
3615
+ $found = true;
3616
+ break;
3617
+ }
3618
+ } else {
3619
+ if ($this->_tokens[$i]['code'] === $type) {
3620
+ $found = false;
3621
+ break;
3622
+ }
3623
+ }
3624
+ }
3625
+
3626
+ if ($found === true) {
3627
+ if ($value === null) {
3628
+ $foundToken = $i;
3629
+ } else if ($this->_tokens[$i]['content'] === $value) {
3630
+ $foundToken = $i;
3631
+ }
3632
+ }
3633
+ }//end for
3634
+
3635
+ return $foundToken;
3636
+
3637
+ }//end findFirstOnLine()
3638
+
3639
+
3640
+ /**
3641
+ * Determine if the passed token has a condition of one of the passed types.
3642
+ *
3643
+ * @param int $stackPtr The position of the token we are checking.
3644
+ * @param int|array $types The type(s) of tokens to search for.
3645
+ *
3646
+ * @return boolean
3647
+ */
3648
+ public function hasCondition($stackPtr, $types)
3649
+ {
3650
+ // Check for the existence of the token.
3651
+ if (isset($this->_tokens[$stackPtr]) === false) {
3652
+ return false;
3653
+ }
3654
+
3655
+ // Make sure the token has conditions.
3656
+ if (isset($this->_tokens[$stackPtr]['conditions']) === false) {
3657
+ return false;
3658
+ }
3659
+
3660
+ $types = (array) $types;
3661
+ $conditions = $this->_tokens[$stackPtr]['conditions'];
3662
+
3663
+ foreach ($types as $type) {
3664
+ if (in_array($type, $conditions) === true) {
3665
+ // We found a token with the required type.
3666
+ return true;
3667
+ }
3668
+ }
3669
+
3670
+ return false;
3671
+
3672
+ }//end hasCondition()
3673
+
3674
+
3675
+ /**
3676
+ * Return the position of the condition for the passed token.
3677
+ *
3678
+ * Returns FALSE if the token does not have the condition.
3679
+ *
3680
+ * @param int $stackPtr The position of the token we are checking.
3681
+ * @param int $type The type of token to search for.
3682
+ *
3683
+ * @return int
3684
+ */
3685
+ public function getCondition($stackPtr, $type)
3686
+ {
3687
+ // Check for the existence of the token.
3688
+ if (isset($this->_tokens[$stackPtr]) === false) {
3689
+ return false;
3690
+ }
3691
+
3692
+ // Make sure the token has conditions.
3693
+ if (isset($this->_tokens[$stackPtr]['conditions']) === false) {
3694
+ return false;
3695
+ }
3696
+
3697
+ $conditions = $this->_tokens[$stackPtr]['conditions'];
3698
+ foreach ($conditions as $token => $condition) {
3699
+ if ($condition === $type) {
3700
+ return $token;
3701
+ }
3702
+ }
3703
+
3704
+ return false;
3705
+
3706
+ }//end getCondition()
3707
+
3708
+
3709
+ /**
3710
+ * Returns the name of the class that the specified class extends.
3711
+ *
3712
+ * Returns FALSE on error or if there is no extended class name.
3713
+ *
3714
+ * @param int $stackPtr The stack position of the class.
3715
+ *
3716
+ * @return string
3717
+ */
3718
+ public function findExtendedClassName($stackPtr)
3719
+ {
3720
+ // Check for the existence of the token.
3721
+ if (isset($this->_tokens[$stackPtr]) === false) {
3722
+ return false;
3723
+ }
3724
+
3725
+ if ($this->_tokens[$stackPtr]['code'] !== T_CLASS
3726
+ && $this->_tokens[$stackPtr]['code'] !== T_ANON_CLASS
3727
+ ) {
3728
+ return false;
3729
+ }
3730
+
3731
+ if (isset($this->_tokens[$stackPtr]['scope_closer']) === false) {
3732
+ return false;
3733
+ }
3734
+
3735
+ $classCloserIndex = $this->_tokens[$stackPtr]['scope_closer'];
3736
+ $extendsIndex = $this->findNext(T_EXTENDS, $stackPtr, $classCloserIndex);
3737
+ if (false === $extendsIndex) {
3738
+ return false;
3739
+ }
3740
+
3741
+ $find = array(
3742
+ T_NS_SEPARATOR,
3743
+ T_STRING,
3744
+ T_WHITESPACE,
3745
+ );
3746
+
3747
+ $end = $this->findNext($find, ($extendsIndex + 1), $classCloserIndex, true);
3748
+ $name = $this->getTokensAsString(($extendsIndex + 1), ($end - $extendsIndex - 1));
3749
+ $name = trim($name);
3750
+
3751
+ if ($name === '') {
3752
+ return false;
3753
+ }
3754
+
3755
+ return $name;
3756
+
3757
+ }//end findExtendedClassName()
3758
+
3759
+
3760
+ /**
3761
+ * Returns the name(s) of the interface(s) that the specified class implements.
3762
+ *
3763
+ * Returns FALSE on error or if there are no implemented interface names.
3764
+ *
3765
+ * @param int $stackPtr The stack position of the class.
3766
+ *
3767
+ * @return array|false
3768
+ */
3769
+ public function findImplementedInterfaceNames($stackPtr)
3770
+ {
3771
+ // Check for the existence of the token.
3772
+ if (isset($this->_tokens[$stackPtr]) === false) {
3773
+ return false;
3774
+ }
3775
+
3776
+ if ($this->_tokens[$stackPtr]['code'] !== T_CLASS
3777
+ && $this->_tokens[$stackPtr]['code'] !== T_ANON_CLASS
3778
+ ) {
3779
+ return false;
3780
+ }
3781
+
3782
+ if (isset($this->_tokens[$stackPtr]['scope_closer']) === false) {
3783
+ return false;
3784
+ }
3785
+
3786
+ $classOpenerIndex = $this->_tokens[$stackPtr]['scope_opener'];
3787
+ $implementsIndex = $this->findNext(T_IMPLEMENTS, $stackPtr, $classOpenerIndex);
3788
+ if ($implementsIndex === false) {
3789
+ return false;
3790
+ }
3791
+
3792
+ $find = array(
3793
+ T_NS_SEPARATOR,
3794
+ T_STRING,
3795
+ T_WHITESPACE,
3796
+ T_COMMA,
3797
+ );
3798
+
3799
+ $end = $this->findNext($find, ($implementsIndex + 1), ($classOpenerIndex + 1), true);
3800
+ $name = $this->getTokensAsString(($implementsIndex + 1), ($end - $implementsIndex - 1));
3801
+ $name = trim($name);
3802
+
3803
+ if ($name === '') {
3804
+ return false;
3805
+ } else {
3806
+ $names = explode(',', $name);
3807
+ $names = array_map('trim', $names);
3808
+ return $names;
3809
+ }
3810
+
3811
+ }//end findImplementedInterfaceNames()
3812
+
3813
+
3814
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Fixer.php ADDED
@@ -0,0 +1,741 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * A helper class for fixing errors.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * A helper class for fixing errors.
17
+ *
18
+ * Provides helper functions that act upon a token array and modify the file
19
+ * content.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
25
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
26
+ * @version Release: @package_version@
27
+ * @link http://pear.php.net/package/PHP_CodeSniffer
28
+ */
29
+ class PHP_CodeSniffer_Fixer
30
+ {
31
+
32
+ /**
33
+ * Is the fixer enabled and fixing a file?
34
+ *
35
+ * Sniffs should check this value to ensure they are not
36
+ * doing extra processing to prepare for a fix when fixing is
37
+ * not required.
38
+ *
39
+ * @var boolean
40
+ */
41
+ public $enabled = false;
42
+
43
+ /**
44
+ * The number of times we have looped over a file.
45
+ *
46
+ * @var int
47
+ */
48
+ public $loops = 0;
49
+
50
+ /**
51
+ * The file being fixed.
52
+ *
53
+ * @var PHP_CodeSniffer_File
54
+ */
55
+ private $_currentFile = null;
56
+
57
+ /**
58
+ * The list of tokens that make up the file contents.
59
+ *
60
+ * This is a simplified list which just contains the token content and nothing
61
+ * else. This is the array that is updated as fixes are made, not the file's
62
+ * token array. Imploding this array will give you the file content back.
63
+ *
64
+ * @var array(int => string)
65
+ */
66
+ private $_tokens = array();
67
+
68
+ /**
69
+ * A list of tokens that have already been fixed.
70
+ *
71
+ * We don't allow the same token to be fixed more than once each time
72
+ * through a file as this can easily cause conflicts between sniffs.
73
+ *
74
+ * @var array(int)
75
+ */
76
+ private $_fixedTokens = array();
77
+
78
+ /**
79
+ * The last value of each fixed token.
80
+ *
81
+ * If a token is being "fixed" back to its last value, the fix is
82
+ * probably conflicting with another.
83
+ *
84
+ * @var array(int => string)
85
+ */
86
+ private $_oldTokenValues = array();
87
+
88
+ /**
89
+ * A list of tokens that have been fixed during a changeset.
90
+ *
91
+ * All changes in changeset must be able to be applied, or else
92
+ * the entire changeset is rejected.
93
+ *
94
+ * @var array()
95
+ */
96
+ private $_changeset = array();
97
+
98
+ /**
99
+ * Is there an open changeset.
100
+ *
101
+ * @var boolean
102
+ */
103
+ private $_inChangeset = false;
104
+
105
+ /**
106
+ * Is the current fixing loop in conflict?
107
+ *
108
+ * @var boolean
109
+ */
110
+ private $_inConflict = false;
111
+
112
+ /**
113
+ * The number of fixes that have been performed.
114
+ *
115
+ * @var int
116
+ */
117
+ private $_numFixes = 0;
118
+
119
+
120
+ /**
121
+ * Starts fixing a new file.
122
+ *
123
+ * @param PHP_CodeSniffer_File $phpcsFile The file being fixed.
124
+ *
125
+ * @return void
126
+ */
127
+ public function startFile($phpcsFile)
128
+ {
129
+ $this->_currentFile = $phpcsFile;
130
+ $this->_numFixes = 0;
131
+ $this->_fixedTokens = array();
132
+
133
+ $tokens = $phpcsFile->getTokens();
134
+ $this->_tokens = array();
135
+ foreach ($tokens as $index => $token) {
136
+ if (isset($token['orig_content']) === true) {
137
+ $this->_tokens[$index] = $token['orig_content'];
138
+ } else {
139
+ $this->_tokens[$index] = $token['content'];
140
+ }
141
+ }
142
+
143
+ }//end startFile()
144
+
145
+
146
+ /**
147
+ * Attempt to fix the file by processing it until no fixes are made.
148
+ *
149
+ * @return boolean
150
+ */
151
+ public function fixFile()
152
+ {
153
+ $fixable = $this->_currentFile->getFixableCount();
154
+ if ($fixable === 0) {
155
+ // Nothing to fix.
156
+ return false;
157
+ }
158
+
159
+ $stdin = false;
160
+ $cliValues = $this->_currentFile->phpcs->cli->getCommandLineValues();
161
+ if (empty($cliValues['files']) === true) {
162
+ $stdin = true;
163
+ }
164
+
165
+ $this->enabled = true;
166
+
167
+ $this->loops = 0;
168
+ while ($this->loops < 50) {
169
+ ob_start();
170
+
171
+ // Only needed once file content has changed.
172
+ $contents = $this->getContents();
173
+
174
+ if (PHP_CODESNIFFER_VERBOSITY > 2) {
175
+ @ob_end_clean();
176
+ echo '---START FILE CONTENT---'.PHP_EOL;
177
+ $lines = explode($this->_currentFile->eolChar, $contents);
178
+ $max = strlen(count($lines));
179
+ foreach ($lines as $lineNum => $line) {
180
+ $lineNum++;
181
+ echo str_pad($lineNum, $max, ' ', STR_PAD_LEFT).'|'.$line.PHP_EOL;
182
+ }
183
+
184
+ echo '--- END FILE CONTENT ---'.PHP_EOL;
185
+ ob_start();
186
+ }
187
+
188
+ $this->_inConflict = false;
189
+ $this->_currentFile->refreshTokenListeners();
190
+ $this->_currentFile->start($contents);
191
+ ob_end_clean();
192
+
193
+ $this->loops++;
194
+
195
+ if (PHP_CODESNIFFER_CBF === true && $stdin === false) {
196
+ echo "\r".str_repeat(' ', 80)."\r";
197
+ echo "\t=> Fixing file: $this->_numFixes/$fixable violations remaining [made $this->loops pass";
198
+ if ($this->loops > 1) {
199
+ echo 'es';
200
+ }
201
+
202
+ echo ']... ';
203
+ }
204
+
205
+ if ($this->_numFixes === 0 && $this->_inConflict === false) {
206
+ // Nothing left to do.
207
+ break;
208
+ } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
209
+ echo "\t* fixed $this->_numFixes violations, starting loop ".($this->loops + 1).' *'.PHP_EOL;
210
+ }
211
+ }//end while
212
+
213
+ $this->enabled = false;
214
+
215
+ if ($this->_numFixes > 0) {
216
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
217
+ @ob_end_clean();
218
+ echo "\t*** Reached maximum number of loops with $this->_numFixes violations left unfixed ***".PHP_EOL;
219
+ ob_start();
220
+ }
221
+
222
+ return false;
223
+ }
224
+
225
+ return true;
226
+
227
+ }//end fixFile()
228
+
229
+
230
+ /**
231
+ * Generates a text diff of the original file and the new content.
232
+ *
233
+ * @param string $filePath Optional file path to diff the file against.
234
+ * If not specified, the original version of the
235
+ * file will be used.
236
+ * @param boolean $colors Print colored output or not.
237
+ *
238
+ * @return string
239
+ */
240
+ public function generateDiff($filePath=null, $colors=true)
241
+ {
242
+ if ($filePath === null) {
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) {
256
+ // This is needed for HHVM support, but only available from 5.2.1.
257
+ $tempName = tempnam(sys_get_temp_dir(), 'phpcs-fixer');
258
+ $fixedFile = fopen($tempName, 'w');
259
+ } else {
260
+ $fixedFile = tmpfile();
261
+ $data = stream_get_meta_data($fixedFile);
262
+ $tempName = $data['uri'];
263
+ }
264
+
265
+ fwrite($fixedFile, $contents);
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);
275
+ if (is_file($tempName) === true) {
276
+ unlink($tempName);
277
+ }
278
+
279
+ if ($colors === false) {
280
+ return $diff;
281
+ }
282
+
283
+ $diffLines = explode(PHP_EOL, $diff);
284
+ if (count($diffLines) === 1) {
285
+ // Seems to be required for cygwin.
286
+ $diffLines = explode("\n", $diff);
287
+ }
288
+
289
+ $diff = array();
290
+ foreach ($diffLines as $line) {
291
+ if (isset($line[0]) === true) {
292
+ switch ($line[0]) {
293
+ case '-':
294
+ $diff[] = "\033[31m$line\033[0m";
295
+ break;
296
+ case '+':
297
+ $diff[] = "\033[32m$line\033[0m";
298
+ break;
299
+ default:
300
+ $diff[] = $line;
301
+ }
302
+ }
303
+ }
304
+
305
+ $diff = implode(PHP_EOL, $diff);
306
+
307
+ return $diff;
308
+
309
+ }//end generateDiff()
310
+
311
+
312
+ /**
313
+ * Get a count of fixes that have been performed on the file.
314
+ *
315
+ * This value is reset every time a new file is started, or an existing
316
+ * file is restarted.
317
+ *
318
+ * @return int
319
+ */
320
+ public function getFixCount()
321
+ {
322
+ return $this->_numFixes;
323
+
324
+ }//end getFixCount()
325
+
326
+
327
+ /**
328
+ * Get the current content of the file, as a string.
329
+ *
330
+ * @return string
331
+ */
332
+ public function getContents()
333
+ {
334
+ $contents = implode($this->_tokens);
335
+ return $contents;
336
+
337
+ }//end getContents()
338
+
339
+
340
+ /**
341
+ * Get the current fixed content of a token.
342
+ *
343
+ * This function takes changesets into account so should be used
344
+ * instead of directly accessing the token array.
345
+ *
346
+ * @param int $stackPtr The position of the token in the token stack.
347
+ *
348
+ * @return string
349
+ */
350
+ public function getTokenContent($stackPtr)
351
+ {
352
+ if ($this->_inChangeset === true
353
+ && isset($this->_changeset[$stackPtr]) === true
354
+ ) {
355
+ return $this->_changeset[$stackPtr];
356
+ } else {
357
+ return $this->_tokens[$stackPtr];
358
+ }
359
+
360
+ }//end getTokenContent()
361
+
362
+
363
+ /**
364
+ * Start recording actions for a changeset.
365
+ *
366
+ * @return void
367
+ */
368
+ public function beginChangeset()
369
+ {
370
+ if ($this->_inConflict === true) {
371
+ return false;
372
+ }
373
+
374
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
375
+ $bt = debug_backtrace();
376
+ $sniff = $bt[1]['class'];
377
+ $line = $bt[0]['line'];
378
+
379
+ @ob_end_clean();
380
+ echo "\t=> Changeset started by $sniff (line $line)".PHP_EOL;
381
+ ob_start();
382
+ }
383
+
384
+ $this->_changeset = array();
385
+ $this->_inChangeset = true;
386
+
387
+ }//end beginChangeset()
388
+
389
+
390
+ /**
391
+ * Stop recording actions for a changeset, and apply logged changes.
392
+ *
393
+ * @return boolean
394
+ */
395
+ public function endChangeset()
396
+ {
397
+ if ($this->_inConflict === true) {
398
+ return false;
399
+ }
400
+
401
+ $this->_inChangeset = false;
402
+
403
+ $success = true;
404
+ $applied = array();
405
+ foreach ($this->_changeset as $stackPtr => $content) {
406
+ $success = $this->replaceToken($stackPtr, $content);
407
+ if ($success === false) {
408
+ break;
409
+ } else {
410
+ $applied[] = $stackPtr;
411
+ }
412
+ }
413
+
414
+ if ($success === false) {
415
+ // Rolling back all changes.
416
+ foreach ($applied as $stackPtr) {
417
+ $this->revertToken($stackPtr);
418
+ }
419
+
420
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
421
+ @ob_end_clean();
422
+ echo "\t=> Changeset failed to apply".PHP_EOL;
423
+ ob_start();
424
+ }
425
+ } else if (PHP_CODESNIFFER_VERBOSITY > 1) {
426
+ $fixes = count($this->_changeset);
427
+ @ob_end_clean();
428
+ echo "\t=> Changeset ended: $fixes changes applied".PHP_EOL;
429
+ ob_start();
430
+ }
431
+
432
+ $this->_changeset = array();
433
+
434
+ }//end endChangeset()
435
+
436
+
437
+ /**
438
+ * Stop recording actions for a changeset, and discard logged changes.
439
+ *
440
+ * @return void
441
+ */
442
+ public function rollbackChangeset()
443
+ {
444
+ $this->_inChangeset = false;
445
+ $this->_inConflict = false;
446
+
447
+ if (empty($this->_changeset) === false) {
448
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
449
+ $bt = debug_backtrace();
450
+ if ($bt[1]['class'] === 'PHP_CodeSniffer_Fixer') {
451
+ $sniff = $bt[2]['class'];
452
+ $line = $bt[1]['line'];
453
+ } else {
454
+ $sniff = $bt[1]['class'];
455
+ $line = $bt[0]['line'];
456
+ }
457
+
458
+ $numChanges = count($this->_changeset);
459
+
460
+ @ob_end_clean();
461
+ echo "\t\tR: $sniff (line $line) rolled back the changeset ($numChanges changes)".PHP_EOL;
462
+ echo "\t=> Changeset rolled back".PHP_EOL;
463
+ ob_start();
464
+ }
465
+
466
+ $this->_changeset = array();
467
+ }//end if
468
+
469
+ }//end rollbackChangeset()
470
+
471
+
472
+ /**
473
+ * Replace the entire contents of a token.
474
+ *
475
+ * @param int $stackPtr The position of the token in the token stack.
476
+ * @param string $content The new content of the token.
477
+ *
478
+ * @return bool If the change was accepted.
479
+ */
480
+ public function replaceToken($stackPtr, $content)
481
+ {
482
+ if ($this->_inConflict === true) {
483
+ return false;
484
+ }
485
+
486
+ if ($this->_inChangeset === false
487
+ && isset($this->_fixedTokens[$stackPtr]) === true
488
+ ) {
489
+ $indent = "\t";
490
+ if (empty($this->_changeset) === false) {
491
+ $indent .= "\t";
492
+ }
493
+
494
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
495
+ @ob_end_clean();
496
+ echo "$indent* token $stackPtr has already been modified, skipping *".PHP_EOL;
497
+ ob_start();
498
+ }
499
+
500
+ return false;
501
+ }
502
+
503
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
504
+ $bt = debug_backtrace();
505
+ if ($bt[1]['class'] === 'PHP_CodeSniffer_Fixer') {
506
+ $sniff = $bt[2]['class'];
507
+ $line = $bt[1]['line'];
508
+ } else {
509
+ $sniff = $bt[1]['class'];
510
+ $line = $bt[0]['line'];
511
+ }
512
+
513
+ $tokens = $this->_currentFile->getTokens();
514
+ $type = $tokens[$stackPtr]['type'];
515
+ $oldContent = PHP_CodeSniffer::prepareForOutput($this->_tokens[$stackPtr]);
516
+ $newContent = PHP_CodeSniffer::prepareForOutput($content);
517
+ if (trim($this->_tokens[$stackPtr]) === '' && isset($this->_tokens[($stackPtr + 1)]) === true) {
518
+ // Add some context for whitespace only changes.
519
+ $append = PHP_CodeSniffer::prepareForOutput($this->_tokens[($stackPtr + 1)]);
520
+ $oldContent .= $append;
521
+ $newContent .= $append;
522
+ }
523
+ }//end if
524
+
525
+ if ($this->_inChangeset === true) {
526
+ $this->_changeset[$stackPtr] = $content;
527
+
528
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
529
+ @ob_end_clean();
530
+ echo "\t\tQ: $sniff (line $line) replaced token $stackPtr ($type) \"$oldContent\" => \"$newContent\"".PHP_EOL;
531
+ ob_start();
532
+ }
533
+
534
+ return true;
535
+ }
536
+
537
+ if (isset($this->_oldTokenValues[$stackPtr]) === false) {
538
+ $this->_oldTokenValues[$stackPtr] = array(
539
+ 'curr' => $content,
540
+ 'prev' => $this->_tokens[$stackPtr],
541
+ 'loop' => $this->loops,
542
+ );
543
+ } else {
544
+ if ($this->_oldTokenValues[$stackPtr]['prev'] === $content
545
+ && $this->_oldTokenValues[$stackPtr]['loop'] === ($this->loops - 1)
546
+ ) {
547
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
548
+ $indent = "\t";
549
+ if (empty($this->_changeset) === false) {
550
+ $indent .= "\t";
551
+ }
552
+
553
+ $loop = $this->_oldTokenValues[$stackPtr]['loop'];
554
+
555
+ @ob_end_clean();
556
+ echo "$indent**** $sniff (line $line) has possible conflict with another sniff on loop $loop; caused by the following change ****".PHP_EOL;
557
+ echo "$indent**** replaced token $stackPtr ($type) \"$oldContent\" => \"$newContent\" ****".PHP_EOL;
558
+ }
559
+
560
+ if ($this->_oldTokenValues[$stackPtr]['loop'] >= ($this->loops - 1)) {
561
+ $this->_inConflict = true;
562
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
563
+ echo "$indent**** ignoring all changes until next loop ****".PHP_EOL;
564
+ }
565
+ }
566
+
567
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
568
+ ob_start();
569
+ }
570
+
571
+ return false;
572
+ }//end if
573
+
574
+ $this->_oldTokenValues[$stackPtr]['prev'] = $this->_oldTokenValues[$stackPtr]['curr'];
575
+ $this->_oldTokenValues[$stackPtr]['curr'] = $content;
576
+ $this->_oldTokenValues[$stackPtr]['loop'] = $this->loops;
577
+ }//end if
578
+
579
+ $this->_fixedTokens[$stackPtr] = $this->_tokens[$stackPtr];
580
+ $this->_tokens[$stackPtr] = $content;
581
+ $this->_numFixes++;
582
+
583
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
584
+ $indent = "\t";
585
+ if (empty($this->_changeset) === false) {
586
+ $indent .= "\tA: ";
587
+ }
588
+
589
+ @ob_end_clean();
590
+ echo "$indent$sniff (line $line) replaced token $stackPtr ($type) \"$oldContent\" => \"$newContent\"".PHP_EOL;
591
+ ob_start();
592
+ }
593
+
594
+ return true;
595
+
596
+ }//end replaceToken()
597
+
598
+
599
+ /**
600
+ * Reverts the previous fix made to a token.
601
+ *
602
+ * @param int $stackPtr The position of the token in the token stack.
603
+ *
604
+ * @return bool If a change was reverted.
605
+ */
606
+ public function revertToken($stackPtr)
607
+ {
608
+ if (isset($this->_fixedTokens[$stackPtr]) === false) {
609
+ return false;
610
+ }
611
+
612
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
613
+ $bt = debug_backtrace();
614
+ if ($bt[1]['class'] === 'PHP_CodeSniffer_Fixer') {
615
+ $sniff = $bt[2]['class'];
616
+ $line = $bt[1]['line'];
617
+ } else {
618
+ $sniff = $bt[1]['class'];
619
+ $line = $bt[0]['line'];
620
+ }
621
+
622
+ $tokens = $this->_currentFile->getTokens();
623
+ $type = $tokens[$stackPtr]['type'];
624
+ $oldContent = PHP_CodeSniffer::prepareForOutput($this->_tokens[$stackPtr]);
625
+ $newContent = PHP_CodeSniffer::prepareForOutput($this->_fixedTokens[$stackPtr]);
626
+ if (trim($this->_tokens[$stackPtr]) === '' && isset($tokens[($stackPtr + 1)]) === true) {
627
+ // Add some context for whitespace only changes.
628
+ $append = PHP_CodeSniffer::prepareForOutput($this->_tokens[($stackPtr + 1)]);
629
+ $oldContent .= $append;
630
+ $newContent .= $append;
631
+ }
632
+ }//end if
633
+
634
+ $this->_tokens[$stackPtr] = $this->_fixedTokens[$stackPtr];
635
+ unset($this->_fixedTokens[$stackPtr]);
636
+ $this->_numFixes--;
637
+
638
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
639
+ $indent = "\t";
640
+ if (empty($this->_changeset) === false) {
641
+ $indent .= "\tR: ";
642
+ }
643
+
644
+ @ob_end_clean();
645
+ echo "$indent$sniff (line $line) reverted token $stackPtr ($type) \"$oldContent\" => \"$newContent\"".PHP_EOL;
646
+ ob_start();
647
+ }
648
+
649
+ return true;
650
+
651
+ }//end revertToken()
652
+
653
+
654
+ /**
655
+ * Replace the content of a token with a part of its current content.
656
+ *
657
+ * @param int $stackPtr The position of the token in the token stack.
658
+ * @param int $start The first character to keep.
659
+ * @param int $length The number of chacters to keep. If NULL, the content of
660
+ * the token from $start to the end of the content is kept.
661
+ *
662
+ * @return bool If the change was accepted.
663
+ */
664
+ public function substrToken($stackPtr, $start, $length=null)
665
+ {
666
+ $current = $this->getTokenContent($stackPtr);
667
+
668
+ if ($length === null) {
669
+ $newContent = substr($current, $start);
670
+ } else {
671
+ $newContent = substr($current, $start, $length);
672
+ }
673
+
674
+ return $this->replaceToken($stackPtr, $newContent);
675
+
676
+ }//end substrToken()
677
+
678
+
679
+ /**
680
+ * Adds a newline to end of a token's content.
681
+ *
682
+ * @param int $stackPtr The position of the token in the token stack.
683
+ *
684
+ * @return bool If the change was accepted.
685
+ */
686
+ public function addNewline($stackPtr)
687
+ {
688
+ $current = $this->getTokenContent($stackPtr);
689
+ return $this->replaceToken($stackPtr, $current.$this->_currentFile->eolChar);
690
+
691
+ }//end addNewline()
692
+
693
+
694
+ /**
695
+ * Adds a newline to the start of a token's content.
696
+ *
697
+ * @param int $stackPtr The position of the token in the token stack.
698
+ *
699
+ * @return bool If the change was accepted.
700
+ */
701
+ public function addNewlineBefore($stackPtr)
702
+ {
703
+ $current = $this->getTokenContent($stackPtr);
704
+ return $this->replaceToken($stackPtr, $this->_currentFile->eolChar.$current);
705
+
706
+ }//end addNewlineBefore()
707
+
708
+
709
+ /**
710
+ * Adds content to the end of a token's current content.
711
+ *
712
+ * @param int $stackPtr The position of the token in the token stack.
713
+ * @param string $content The content to add.
714
+ *
715
+ * @return bool If the change was accepted.
716
+ */
717
+ public function addContent($stackPtr, $content)
718
+ {
719
+ $current = $this->getTokenContent($stackPtr);
720
+ return $this->replaceToken($stackPtr, $current.$content);
721
+
722
+ }//end addContent()
723
+
724
+
725
+ /**
726
+ * Adds content to the start of a token's current content.
727
+ *
728
+ * @param int $stackPtr The position of the token in the token stack.
729
+ * @param string $content The content to add.
730
+ *
731
+ * @return bool If the change was accepted.
732
+ */
733
+ public function addContentBefore($stackPtr, $content)
734
+ {
735
+ $current = $this->getTokenContent($stackPtr);
736
+ return $this->replaceToken($stackPtr, $content.$current);
737
+
738
+ }//end addContentBefore()
739
+
740
+
741
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Report.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Represents a PHP_CodeSniffer report.
4
+ *
5
+ * PHP version 5.
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Gabriele Santini <gsantini@sqli.com>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2009-2014 SQLI <www.sqli.com>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * Represents a PHP_CodeSniffer report.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Gabriele Santini <gsantini@sqli.com>
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @copyright 2009-2014 SQLI <www.sqli.com>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ interface PHP_CodeSniffer_Report
31
+ {
32
+
33
+
34
+ /**
35
+ * Generate a partial report for a single processed file.
36
+ *
37
+ * Function should return TRUE if it printed or stored data about the file
38
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
39
+ * its data should be counted in the grand totals.
40
+ *
41
+ * @param array $report Prepared report data.
42
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
43
+ * @param boolean $showSources Show sources?
44
+ * @param int $width Maximum allowed line width.
45
+ *
46
+ * @return boolean
47
+ */
48
+ public function generateFileReport(
49
+ $report,
50
+ PHP_CodeSniffer_File $phpcsFile,
51
+ $showSources=false,
52
+ $width=80
53
+ );
54
+
55
+
56
+ /**
57
+ * Generate the actual report.
58
+ *
59
+ * @param string $cachedData Any partial report data that was returned from
60
+ * generateFileReport during the run.
61
+ * @param int $totalFiles Total number of files processed during the run.
62
+ * @param int $totalErrors Total number of errors found during the run.
63
+ * @param int $totalWarnings Total number of warnings found during the run.
64
+ * @param int $totalFixable Total number of problems that can be fixed.
65
+ * @param boolean $showSources Show sources?
66
+ * @param int $width Maximum allowed line width.
67
+ * @param boolean $toScreen Is the report being printed to screen?
68
+ *
69
+ * @return void
70
+ */
71
+ public function generate(
72
+ $cachedData,
73
+ $totalFiles,
74
+ $totalErrors,
75
+ $totalWarnings,
76
+ $totalFixable,
77
+ $showSources=false,
78
+ $width=80,
79
+ $toScreen=true
80
+ );
81
+
82
+
83
+ }//end interface
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reporting.php ADDED
@@ -0,0 +1,425 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * A class to manage reporting.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Gabriele Santini <gsantini@sqli.com>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2009-2014 SQLI <www.sqli.com>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * A class to manage reporting.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Gabriele Santini <gsantini@sqli.com>
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @copyright 2009-2014 SQLI <www.sqli.com>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class PHP_CodeSniffer_Reporting
31
+ {
32
+
33
+ /**
34
+ * Total number of files that contain errors or warnings.
35
+ *
36
+ * @var int
37
+ */
38
+ public $totalFiles = 0;
39
+
40
+ /**
41
+ * Total number of errors found during the run.
42
+ *
43
+ * @var int
44
+ */
45
+ public $totalErrors = 0;
46
+
47
+ /**
48
+ * Total number of warnings found during the run.
49
+ *
50
+ * @var int
51
+ */
52
+ public $totalWarnings = 0;
53
+
54
+ /**
55
+ * Total number of errors/warnings that can be fixed.
56
+ *
57
+ * @var int
58
+ */
59
+ public $totalFixable = 0;
60
+
61
+ /**
62
+ * When the PHPCS run started.
63
+ *
64
+ * @var float
65
+ */
66
+ public static $startTime = 0;
67
+
68
+ /**
69
+ * A list of reports that have written partial report output.
70
+ *
71
+ * @var array
72
+ */
73
+ private $_cachedReports = array();
74
+
75
+ /**
76
+ * A cache of report objects.
77
+ *
78
+ * @var array
79
+ */
80
+ private $_reports = array();
81
+
82
+ /**
83
+ * A cache of opened tmp files.
84
+ *
85
+ * @var array
86
+ */
87
+ private $_tmpFiles = array();
88
+
89
+
90
+ /**
91
+ * Produce the appropriate report object based on $type parameter.
92
+ *
93
+ * @param string $type The type of the report.
94
+ *
95
+ * @return PHP_CodeSniffer_Report
96
+ * @throws PHP_CodeSniffer_Exception If report is not available.
97
+ */
98
+ public function factory($type)
99
+ {
100
+ $type = ucfirst($type);
101
+ if (isset($this->_reports[$type]) === true) {
102
+ return $this->_reports[$type];
103
+ }
104
+
105
+ if (strpos($type, '.') !== false) {
106
+ // This is a path to a custom report class.
107
+ $filename = realpath($type);
108
+ if ($filename === false) {
109
+ echo 'ERROR: Custom report "'.$type.'" not found'.PHP_EOL;
110
+ exit(2);
111
+ }
112
+
113
+ $reportClassName = 'PHP_CodeSniffer_Reports_'.basename($filename);
114
+ $reportClassName = substr($reportClassName, 0, strpos($reportClassName, '.'));
115
+ include_once $filename;
116
+ } else {
117
+ $filename = $type.'.php';
118
+ $reportClassName = 'PHP_CodeSniffer_Reports_'.$type;
119
+ if (class_exists($reportClassName, true) === false) {
120
+ echo 'ERROR: Report type "'.$type.'" not found'.PHP_EOL;
121
+ exit(2);
122
+ }
123
+ }//end if
124
+
125
+ $reportClass = new $reportClassName();
126
+ if (false === ($reportClass instanceof PHP_CodeSniffer_Report)) {
127
+ throw new PHP_CodeSniffer_Exception('Class "'.$reportClassName.'" must implement the "PHP_CodeSniffer_Report" interface.');
128
+ }
129
+
130
+ $this->_reports[$type] = $reportClass;
131
+ return $this->_reports[$type];
132
+
133
+ }//end factory()
134
+
135
+
136
+ /**
137
+ * Actually generates the report.
138
+ *
139
+ * @param PHP_CodeSniffer_File $phpcsFile The file that has been processed.
140
+ * @param array $cliValues An array of command line arguments.
141
+ *
142
+ * @return void
143
+ */
144
+ public function cacheFileReport(PHP_CodeSniffer_File $phpcsFile, array $cliValues)
145
+ {
146
+ if (isset($cliValues['reports']) === false) {
147
+ // This happens during unit testing, or any time someone just wants
148
+ // the error data and not the printed report.
149
+ return;
150
+ }
151
+
152
+ $reportData = $this->prepareFileReport($phpcsFile);
153
+ $errorsShown = false;
154
+
155
+ foreach ($cliValues['reports'] as $report => $output) {
156
+ $reportClass = $this->factory($report);
157
+ $report = get_class($reportClass);
158
+
159
+ ob_start();
160
+ $result = $reportClass->generateFileReport($reportData, $phpcsFile, $cliValues['showSources'], $cliValues['reportWidth']);
161
+ if ($result === true) {
162
+ $errorsShown = true;
163
+ }
164
+
165
+ $generatedReport = ob_get_contents();
166
+ ob_end_clean();
167
+
168
+ if ($output === null && $cliValues['reportFile'] !== null) {
169
+ $output = $cliValues['reportFile'];
170
+ }
171
+
172
+ if ($output === null) {
173
+ // Using a temp file.
174
+ if (isset($this->_tmpFiles[$report]) === false) {
175
+ if (function_exists('sys_get_temp_dir') === true) {
176
+ // This is needed for HHVM support, but only available from 5.2.1.
177
+ $this->_tmpFiles[$report] = fopen(tempnam(sys_get_temp_dir(), 'phpcs'), 'w');
178
+ } else {
179
+ $this->_tmpFiles[$report] = tmpfile();
180
+ }
181
+ }
182
+
183
+ fwrite($this->_tmpFiles[$report], $generatedReport);
184
+ } else {
185
+ $flags = FILE_APPEND;
186
+ if (isset($this->_cachedReports[$report]) === false) {
187
+ $this->_cachedReports[$report] = true;
188
+ $flags = null;
189
+ }
190
+
191
+ file_put_contents($output, $generatedReport, $flags);
192
+ }//end if
193
+ }//end foreach
194
+
195
+ if ($errorsShown === true) {
196
+ $this->totalFiles++;
197
+ $this->totalErrors += $reportData['errors'];
198
+ $this->totalWarnings += $reportData['warnings'];
199
+ $this->totalFixable += $reportData['fixable'];
200
+ }
201
+
202
+ }//end cacheFileReport()
203
+
204
+
205
+ /**
206
+ * Generates and prints a final report.
207
+ *
208
+ * Returns an array with the number of errors and the number of
209
+ * warnings, in the form ['errors' => int, 'warnings' => int].
210
+ *
211
+ * @param string $report Report type.
212
+ * @param boolean $showSources Show sources?
213
+ * @param array $cliValues An array of command line arguments.
214
+ * @param string $reportFile Report file to generate.
215
+ * @param integer $reportWidth Report max width.
216
+ *
217
+ * @return int[]
218
+ */
219
+ public function printReport(
220
+ $report,
221
+ $showSources,
222
+ array $cliValues,
223
+ $reportFile='',
224
+ $reportWidth=80
225
+ ) {
226
+ $reportClass = $this->factory($report);
227
+ $report = get_class($reportClass);
228
+
229
+ if ($reportFile !== null) {
230
+ $filename = $reportFile;
231
+ $toScreen = false;
232
+
233
+ if (file_exists($filename) === true
234
+ && isset($this->_cachedReports[$report]) === true
235
+ ) {
236
+ $reportCache = file_get_contents($filename);
237
+ } else {
238
+ $reportCache = '';
239
+ }
240
+ } else {
241
+ if (isset($this->_tmpFiles[$report]) === true) {
242
+ $data = stream_get_meta_data($this->_tmpFiles[$report]);
243
+ $filename = $data['uri'];
244
+ $reportCache = file_get_contents($filename);
245
+ fclose($this->_tmpFiles[$report]);
246
+ } else {
247
+ $reportCache = '';
248
+ $filename = null;
249
+ }
250
+
251
+ $toScreen = true;
252
+ }//end if
253
+
254
+ ob_start();
255
+ $reportClass->generate(
256
+ $reportCache,
257
+ $this->totalFiles,
258
+ $this->totalErrors,
259
+ $this->totalWarnings,
260
+ $this->totalFixable,
261
+ $showSources,
262
+ $reportWidth,
263
+ $toScreen
264
+ );
265
+ $generatedReport = ob_get_contents();
266
+ ob_end_clean();
267
+
268
+ if ($cliValues['colors'] !== true || $reportFile !== null) {
269
+ $generatedReport = preg_replace('`\033\[[0-9]+m`', '', $generatedReport);
270
+ }
271
+
272
+ if ($reportFile !== null) {
273
+ if (PHP_CODESNIFFER_VERBOSITY > 0) {
274
+ echo $generatedReport;
275
+ }
276
+
277
+ file_put_contents($reportFile, $generatedReport.PHP_EOL);
278
+ } else {
279
+ echo $generatedReport;
280
+ if ($filename !== null && file_exists($filename) === true) {
281
+ unlink($filename);
282
+ }
283
+ }
284
+
285
+ return array(
286
+ 'errors' => $this->totalErrors,
287
+ 'warnings' => $this->totalWarnings,
288
+ );
289
+
290
+ }//end printReport()
291
+
292
+
293
+ /**
294
+ * Pre-process and package violations for all files.
295
+ *
296
+ * Used by error reports to get a packaged list of all errors in each file.
297
+ *
298
+ * @param PHP_CodeSniffer_File $phpcsFile The file that has been processed.
299
+ *
300
+ * @return array
301
+ */
302
+ public function prepareFileReport(PHP_CodeSniffer_File $phpcsFile)
303
+ {
304
+ $report = array(
305
+ 'filename' => $phpcsFile->getFilename(),
306
+ 'errors' => $phpcsFile->getErrorCount(),
307
+ 'warnings' => $phpcsFile->getWarningCount(),
308
+ 'fixable' => $phpcsFile->getFixableCount(),
309
+ 'messages' => array(),
310
+ );
311
+
312
+ if ($report['errors'] === 0 && $report['warnings'] === 0) {
313
+ // Prefect score!
314
+ return $report;
315
+ }
316
+
317
+ $errors = array();
318
+
319
+ // Merge errors and warnings.
320
+ foreach ($phpcsFile->getErrors() as $line => $lineErrors) {
321
+ if (is_array($lineErrors) === false) {
322
+ continue;
323
+ }
324
+
325
+ foreach ($lineErrors as $column => $colErrors) {
326
+ $newErrors = array();
327
+ foreach ($colErrors as $data) {
328
+ $newErrors[] = array(
329
+ 'message' => $data['message'],
330
+ 'source' => $data['source'],
331
+ 'severity' => $data['severity'],
332
+ 'fixable' => $data['fixable'],
333
+ 'type' => 'ERROR',
334
+ );
335
+ }//end foreach
336
+
337
+ $errors[$line][$column] = $newErrors;
338
+ }//end foreach
339
+
340
+ ksort($errors[$line]);
341
+ }//end foreach
342
+
343
+ foreach ($phpcsFile->getWarnings() as $line => $lineWarnings) {
344
+ if (is_array($lineWarnings) === false) {
345
+ continue;
346
+ }
347
+
348
+ foreach ($lineWarnings as $column => $colWarnings) {
349
+ $newWarnings = array();
350
+ foreach ($colWarnings as $data) {
351
+ $newWarnings[] = array(
352
+ 'message' => $data['message'],
353
+ 'source' => $data['source'],
354
+ 'severity' => $data['severity'],
355
+ 'fixable' => $data['fixable'],
356
+ 'type' => 'WARNING',
357
+ );
358
+ }//end foreach
359
+
360
+ if (isset($errors[$line]) === false) {
361
+ $errors[$line] = array();
362
+ }
363
+
364
+ if (isset($errors[$line][$column]) === true) {
365
+ $errors[$line][$column] = array_merge(
366
+ $newWarnings,
367
+ $errors[$line][$column]
368
+ );
369
+ } else {
370
+ $errors[$line][$column] = $newWarnings;
371
+ }
372
+ }//end foreach
373
+
374
+ ksort($errors[$line]);
375
+ }//end foreach
376
+
377
+ ksort($errors);
378
+ $report['messages'] = $errors;
379
+ return $report;
380
+
381
+ }//end prepareFileReport()
382
+
383
+
384
+ /**
385
+ * Start recording time for the run.
386
+ *
387
+ * @return void
388
+ */
389
+ public static function startTiming()
390
+ {
391
+
392
+ self::$startTime = microtime(true);
393
+
394
+ }//end startTiming()
395
+
396
+
397
+ /**
398
+ * Print information about the run.
399
+ *
400
+ * @return void
401
+ */
402
+ public static function printRunTime()
403
+ {
404
+ $time = ((microtime(true) - self::$startTime) * 1000);
405
+
406
+ if ($time > 60000) {
407
+ $mins = floor($time / 60000);
408
+ $secs = round((($time % 60000) / 1000), 2);
409
+ $time = $mins.' mins';
410
+ if ($secs !== 0) {
411
+ $time .= ", $secs secs";
412
+ }
413
+ } else if ($time > 1000) {
414
+ $time = round(($time / 1000), 2).' secs';
415
+ } else {
416
+ $time = round($time).'ms';
417
+ }
418
+
419
+ $mem = round((memory_get_peak_usage(true) / (1024 * 1024)), 2).'Mb';
420
+ echo "Time: $time; Memory: $mem".PHP_EOL.PHP_EOL;
421
+
422
+ }//end printRunTime()
423
+
424
+
425
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Cbf.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * CBF report for PHP_CodeSniffer.
4
+ *
5
+ * This report implements the various auto-fixing features of the
6
+ * PHPCBF script and is not intended (or allowed) to be selected as a
7
+ * report from the command line.
8
+ *
9
+ * PHP version 5
10
+ *
11
+ * @category PHP
12
+ * @package PHP_CodeSniffer
13
+ * @author Greg Sherwood <gsherwood@squiz.net>
14
+ * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
15
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
16
+ * @link http://pear.php.net/package/PHP_CodeSniffer
17
+ */
18
+
19
+ /**
20
+ * CBF report for PHP_CodeSniffer.
21
+ *
22
+ * This report implements the various auto-fixing features of the
23
+ * PHPCBF script and is not intended (or allowed) to be selected as a
24
+ * report from the command line.
25
+ *
26
+ * PHP version 5
27
+ *
28
+ * @category PHP
29
+ * @package PHP_CodeSniffer
30
+ * @author Greg Sherwood <gsherwood@squiz.net>
31
+ * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
32
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
33
+ * @version Release: @package_version@
34
+ * @link http://pear.php.net/package/PHP_CodeSniffer
35
+ */
36
+ class PHP_CodeSniffer_Reports_Cbf implements PHP_CodeSniffer_Report
37
+ {
38
+
39
+
40
+ /**
41
+ * Generate a partial report for a single processed file.
42
+ *
43
+ * Function should return TRUE if it printed or stored data about the file
44
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
45
+ * its data should be counted in the grand totals.
46
+ *
47
+ * @param array $report Prepared report data.
48
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
49
+ * @param boolean $showSources Show sources?
50
+ * @param int $width Maximum allowed line width.
51
+ *
52
+ * @return boolean
53
+ */
54
+ public function generateFileReport(
55
+ $report,
56
+ PHP_CodeSniffer_File $phpcsFile,
57
+ $showSources=false,
58
+ $width=80
59
+ ) {
60
+ $cliValues = $phpcsFile->phpcs->cli->getCommandLineValues();
61
+ $errors = $phpcsFile->getFixableCount();
62
+ if ($errors !== 0) {
63
+ if (empty($cliValues['files']) === false) {
64
+ ob_end_clean();
65
+ $errors = $phpcsFile->getFixableCount();
66
+ $startTime = microtime(true);
67
+ echo "\t=> Fixing file: $errors/$errors violations remaining";
68
+ }
69
+
70
+ $fixed = $phpcsFile->fixer->fixFile();
71
+ }
72
+
73
+ if (empty($cliValues['files']) === true) {
74
+ // Replacing STDIN, so output current file to STDOUT
75
+ // even if nothing was fixed. Exit here because we
76
+ // can't process any more than 1 file in this setup.
77
+ echo $phpcsFile->fixer->getContents();
78
+ ob_end_flush();
79
+ exit(1);
80
+ }
81
+
82
+ if ($errors === 0) {
83
+ return false;
84
+ }
85
+
86
+ if ($fixed === false) {
87
+ echo 'ERROR';
88
+ } else {
89
+ echo 'DONE';
90
+ }
91
+
92
+ $timeTaken = ((microtime(true) - $startTime) * 1000);
93
+ if ($timeTaken < 1000) {
94
+ $timeTaken = round($timeTaken);
95
+ echo " in {$timeTaken}ms".PHP_EOL;
96
+ } else {
97
+ $timeTaken = round(($timeTaken / 1000), 2);
98
+ echo " in $timeTaken secs".PHP_EOL;
99
+ }
100
+
101
+ if ($fixed === true) {
102
+ $newFilename = $report['filename'].$cliValues['phpcbf-suffix'];
103
+ $newContent = $phpcsFile->fixer->getContents();
104
+ file_put_contents($newFilename, $newContent);
105
+
106
+ if ($newFilename === $report['filename']) {
107
+ echo "\t=> File was overwritten".PHP_EOL;
108
+ } else {
109
+ echo "\t=> Fixed file written to ".basename($newFilename).PHP_EOL;
110
+ }
111
+ }
112
+
113
+ ob_start();
114
+
115
+ return $fixed;
116
+
117
+ }//end generateFileReport()
118
+
119
+
120
+ /**
121
+ * Prints all errors and warnings for each file processed.
122
+ *
123
+ * @param string $cachedData Any partial report data that was returned from
124
+ * generateFileReport during the run.
125
+ * @param int $totalFiles Total number of files processed during the run.
126
+ * @param int $totalErrors Total number of errors found during the run.
127
+ * @param int $totalWarnings Total number of warnings found during the run.
128
+ * @param int $totalFixable Total number of problems that can be fixed.
129
+ * @param boolean $showSources Show sources?
130
+ * @param int $width Maximum allowed line width.
131
+ * @param boolean $toScreen Is the report being printed to screen?
132
+ *
133
+ * @return void
134
+ */
135
+ public function generate(
136
+ $cachedData,
137
+ $totalFiles,
138
+ $totalErrors,
139
+ $totalWarnings,
140
+ $totalFixable,
141
+ $showSources=false,
142
+ $width=80,
143
+ $toScreen=true
144
+ ) {
145
+ echo $cachedData;
146
+ echo "Fixed $totalFiles files".PHP_EOL;
147
+
148
+ }//end generate()
149
+
150
+
151
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Checkstyle.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Checkstyle report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Gabriele Santini <gsantini@sqli.com>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2009-2014 SQLI <www.sqli.com>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * Checkstyle report for PHP_CodeSniffer.
19
+ *
20
+ * PHP version 5
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Gabriele Santini <gsantini@sqli.com>
25
+ * @author Greg Sherwood <gsherwood@squiz.net>
26
+ * @copyright 2009-2014 SQLI <www.sqli.com>
27
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class PHP_CodeSniffer_Reports_Checkstyle implements PHP_CodeSniffer_Report
33
+ {
34
+
35
+
36
+ /**
37
+ * Generate a partial report for a single processed file.
38
+ *
39
+ * Function should return TRUE if it printed or stored data about the file
40
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
41
+ * its data should be counted in the grand totals.
42
+ *
43
+ * @param array $report Prepared report data.
44
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
45
+ * @param boolean $showSources Show sources?
46
+ * @param int $width Maximum allowed line width.
47
+ *
48
+ * @return boolean
49
+ */
50
+ public function generateFileReport(
51
+ $report,
52
+ PHP_CodeSniffer_File $phpcsFile,
53
+ $showSources=false,
54
+ $width=80
55
+ ) {
56
+ $out = new XMLWriter;
57
+ $out->openMemory();
58
+ $out->setIndent(true);
59
+
60
+ if ($report['errors'] === 0 && $report['warnings'] === 0) {
61
+ // Nothing to print.
62
+ return false;
63
+ }
64
+
65
+ $out->startElement('file');
66
+ $out->writeAttribute('name', $report['filename']);
67
+
68
+ foreach ($report['messages'] as $line => $lineErrors) {
69
+ foreach ($lineErrors as $column => $colErrors) {
70
+ foreach ($colErrors as $error) {
71
+ $error['type'] = strtolower($error['type']);
72
+ if (PHP_CODESNIFFER_ENCODING !== 'utf-8') {
73
+ $error['message'] = iconv(PHP_CODESNIFFER_ENCODING, 'utf-8', $error['message']);
74
+ }
75
+
76
+ $out->startElement('error');
77
+ $out->writeAttribute('line', $line);
78
+ $out->writeAttribute('column', $column);
79
+ $out->writeAttribute('severity', $error['type']);
80
+ $out->writeAttribute('message', $error['message']);
81
+ $out->writeAttribute('source', $error['source']);
82
+ $out->endElement();
83
+ }
84
+ }
85
+ }//end foreach
86
+
87
+ $out->endElement();
88
+ echo $out->flush();
89
+
90
+ return true;
91
+
92
+ }//end generateFileReport()
93
+
94
+
95
+ /**
96
+ * Prints all violations for processed files, in a Checkstyle format.
97
+ *
98
+ * @param string $cachedData Any partial report data that was returned from
99
+ * generateFileReport during the run.
100
+ * @param int $totalFiles Total number of files processed during the run.
101
+ * @param int $totalErrors Total number of errors found during the run.
102
+ * @param int $totalWarnings Total number of warnings found during the run.
103
+ * @param int $totalFixable Total number of problems that can be fixed.
104
+ * @param boolean $showSources Show sources?
105
+ * @param int $width Maximum allowed line width.
106
+ * @param boolean $toScreen Is the report being printed to screen?
107
+ *
108
+ * @return void
109
+ */
110
+ public function generate(
111
+ $cachedData,
112
+ $totalFiles,
113
+ $totalErrors,
114
+ $totalWarnings,
115
+ $totalFixable,
116
+ $showSources=false,
117
+ $width=80,
118
+ $toScreen=true
119
+ ) {
120
+ echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
121
+ echo '<checkstyle version="'.PHP_CodeSniffer::VERSION.'">'.PHP_EOL;
122
+ echo $cachedData;
123
+ echo '</checkstyle>'.PHP_EOL;
124
+
125
+ }//end generate()
126
+
127
+
128
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Csv.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Csv report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Gabriele Santini <gsantini@sqli.com>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2009-2014 SQLI <www.sqli.com>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * Csv report for PHP_CodeSniffer.
19
+ *
20
+ * PHP version 5
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Gabriele Santini <gsantini@sqli.com>
25
+ * @author Greg Sherwood <gsherwood@squiz.net>
26
+ * @copyright 2009-2014 SQLI <www.sqli.com>
27
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class PHP_CodeSniffer_Reports_Csv implements PHP_CodeSniffer_Report
33
+ {
34
+
35
+
36
+ /**
37
+ * Generate a partial report for a single processed file.
38
+ *
39
+ * Function should return TRUE if it printed or stored data about the file
40
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
41
+ * its data should be counted in the grand totals.
42
+ *
43
+ * @param array $report Prepared report data.
44
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
45
+ * @param boolean $showSources Show sources?
46
+ * @param int $width Maximum allowed line width.
47
+ *
48
+ * @return boolean
49
+ */
50
+ public function generateFileReport(
51
+ $report,
52
+ PHP_CodeSniffer_File $phpcsFile,
53
+ $showSources=false,
54
+ $width=80
55
+ ) {
56
+ if ($report['errors'] === 0 && $report['warnings'] === 0) {
57
+ // Nothing to print.
58
+ return false;
59
+ }
60
+
61
+ foreach ($report['messages'] as $line => $lineErrors) {
62
+ foreach ($lineErrors as $column => $colErrors) {
63
+ foreach ($colErrors as $error) {
64
+ $filename = str_replace('"', '\"', $report['filename']);
65
+ $message = str_replace('"', '\"', $error['message']);
66
+ $type = strtolower($error['type']);
67
+ $source = $error['source'];
68
+ $severity = $error['severity'];
69
+ $fixable = (int) $error['fixable'];
70
+ echo "\"$filename\",$line,$column,$type,\"$message\",$source,$severity,$fixable".PHP_EOL;
71
+ }
72
+ }
73
+ }
74
+
75
+ return true;
76
+
77
+ }//end generateFileReport()
78
+
79
+
80
+ /**
81
+ * Generates a csv report.
82
+ *
83
+ * @param string $cachedData Any partial report data that was returned from
84
+ * generateFileReport during the run.
85
+ * @param int $totalFiles Total number of files processed during the run.
86
+ * @param int $totalErrors Total number of errors found during the run.
87
+ * @param int $totalWarnings Total number of warnings found during the run.
88
+ * @param int $totalFixable Total number of problems that can be fixed.
89
+ * @param boolean $showSources Show sources?
90
+ * @param int $width Maximum allowed line width.
91
+ * @param boolean $toScreen Is the report being printed to screen?
92
+ *
93
+ * @return void
94
+ */
95
+ public function generate(
96
+ $cachedData,
97
+ $totalFiles,
98
+ $totalErrors,
99
+ $totalWarnings,
100
+ $totalFixable,
101
+ $showSources=false,
102
+ $width=80,
103
+ $toScreen=true
104
+ ) {
105
+ echo 'File,Line,Column,Type,Message,Source,Severity,Fixable'.PHP_EOL;
106
+ echo $cachedData;
107
+
108
+ }//end generate()
109
+
110
+
111
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Diff.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Diff report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Diff report for PHP_CodeSniffer.
17
+ *
18
+ * PHP version 5
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class PHP_CodeSniffer_Reports_Diff implements PHP_CodeSniffer_Report
29
+ {
30
+
31
+
32
+ /**
33
+ * Generate a partial report for a single processed file.
34
+ *
35
+ * Function should return TRUE if it printed or stored data about the file
36
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
37
+ * its data should be counted in the grand totals.
38
+ *
39
+ * @param array $report Prepared report data.
40
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
41
+ * @param boolean $showSources Show sources?
42
+ * @param int $width Maximum allowed line width.
43
+ *
44
+ * @return boolean
45
+ */
46
+ public function generateFileReport(
47
+ $report,
48
+ PHP_CodeSniffer_File $phpcsFile,
49
+ $showSources=false,
50
+ $width=80
51
+ ) {
52
+ $errors = $phpcsFile->getFixableCount();
53
+ if ($errors === 0) {
54
+ return false;
55
+ }
56
+
57
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
58
+ ob_end_clean();
59
+ echo "\t*** START FILE FIXING ***".PHP_EOL;
60
+ }
61
+
62
+ if (PHP_CODESNIFFER_CBF === true) {
63
+ ob_end_clean();
64
+ $startTime = microtime(true);
65
+ echo "\t=> Fixing file: $errors/$errors violations remaining";
66
+ }
67
+
68
+ $fixed = $phpcsFile->fixer->fixFile();
69
+
70
+ if (PHP_CODESNIFFER_CBF === true) {
71
+ if ($fixed === false) {
72
+ echo "\033[31mERROR\033[0m";
73
+ } else {
74
+ echo "\033[32mDONE\033[0m";
75
+ }
76
+
77
+ $timeTaken = ((microtime(true) - $startTime) * 1000);
78
+ if ($timeTaken < 1000) {
79
+ $timeTaken = round($timeTaken);
80
+ echo " in {$timeTaken}ms".PHP_EOL;
81
+ } else {
82
+ $timeTaken = round(($timeTaken / 1000), 2);
83
+ echo " in $timeTaken secs".PHP_EOL;
84
+ }
85
+
86
+ ob_start();
87
+ }
88
+
89
+ if (PHP_CODESNIFFER_VERBOSITY > 1) {
90
+ echo "\t*** END FILE FIXING ***".PHP_EOL;
91
+ ob_start();
92
+ }
93
+
94
+ if ($fixed === false) {
95
+ return false;
96
+ }
97
+
98
+ if (PHP_CODESNIFFER_CBF === true) {
99
+ // Diff without colours.
100
+ $diff = $phpcsFile->fixer->generateDiff(null, false);
101
+ } else {
102
+ $diff = $phpcsFile->fixer->generateDiff();
103
+ }
104
+
105
+ if ($diff === '') {
106
+ // Nothing to print.
107
+ return false;
108
+ }
109
+
110
+ echo $diff.PHP_EOL;
111
+ return true;
112
+
113
+ }//end generateFileReport()
114
+
115
+
116
+ /**
117
+ * Prints all errors and warnings for each file processed.
118
+ *
119
+ * @param string $cachedData Any partial report data that was returned from
120
+ * generateFileReport during the run.
121
+ * @param int $totalFiles Total number of files processed during the run.
122
+ * @param int $totalErrors Total number of errors found during the run.
123
+ * @param int $totalWarnings Total number of warnings found during the run.
124
+ * @param int $totalFixable Total number of problems that can be fixed.
125
+ * @param boolean $showSources Show sources?
126
+ * @param int $width Maximum allowed line width.
127
+ * @param boolean $toScreen Is the report being printed to screen?
128
+ *
129
+ * @return void
130
+ */
131
+ public function generate(
132
+ $cachedData,
133
+ $totalFiles,
134
+ $totalErrors,
135
+ $totalWarnings,
136
+ $totalFixable,
137
+ $showSources=false,
138
+ $width=80,
139
+ $toScreen=true
140
+ ) {
141
+ echo $cachedData;
142
+ if ($toScreen === true) {
143
+ echo PHP_EOL;
144
+ }
145
+
146
+ }//end generate()
147
+
148
+
149
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Emacs.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Emacs report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Gabriele Santini <gsantini@sqli.com>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2009-2014 SQLI <www.sqli.com>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * Emacs report for PHP_CodeSniffer.
19
+ *
20
+ * PHP version 5
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Gabriele Santini <gsantini@sqli.com>
25
+ * @author Greg Sherwood <gsherwood@squiz.net>
26
+ * @copyright 2009-2014 SQLI <www.sqli.com>
27
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class PHP_CodeSniffer_Reports_Emacs implements PHP_CodeSniffer_Report
33
+ {
34
+
35
+
36
+ /**
37
+ * Generate a partial report for a single processed file.
38
+ *
39
+ * Function should return TRUE if it printed or stored data about the file
40
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
41
+ * its data should be counted in the grand totals.
42
+ *
43
+ * @param array $report Prepared report data.
44
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
45
+ * @param boolean $showSources Show sources?
46
+ * @param int $width Maximum allowed line width.
47
+ *
48
+ * @return boolean
49
+ */
50
+ public function generateFileReport(
51
+ $report,
52
+ PHP_CodeSniffer_File $phpcsFile,
53
+ $showSources=false,
54
+ $width=80
55
+ ) {
56
+ if ($report['errors'] === 0 && $report['warnings'] === 0) {
57
+ // Nothing to print.
58
+ return false;
59
+ }
60
+
61
+ foreach ($report['messages'] as $line => $lineErrors) {
62
+ foreach ($lineErrors as $column => $colErrors) {
63
+ foreach ($colErrors as $error) {
64
+ $message = $error['message'];
65
+ if ($showSources === true) {
66
+ $message .= ' ('.$error['source'].')';
67
+ }
68
+
69
+ $type = strtolower($error['type']);
70
+ echo $report['filename'].':'.$line.':'.$column.': '.$type.' - '.$message.PHP_EOL;
71
+ }
72
+ }
73
+ }
74
+
75
+ return true;
76
+
77
+ }//end generateFileReport()
78
+
79
+
80
+ /**
81
+ * Generates an emacs report.
82
+ *
83
+ * @param string $cachedData Any partial report data that was returned from
84
+ * generateFileReport during the run.
85
+ * @param int $totalFiles Total number of files processed during the run.
86
+ * @param int $totalErrors Total number of errors found during the run.
87
+ * @param int $totalWarnings Total number of warnings found during the run.
88
+ * @param int $totalFixable Total number of problems that can be fixed.
89
+ * @param boolean $showSources Show sources?
90
+ * @param int $width Maximum allowed line width.
91
+ * @param boolean $toScreen Is the report being printed to screen?
92
+ *
93
+ * @return void
94
+ */
95
+ public function generate(
96
+ $cachedData,
97
+ $totalFiles,
98
+ $totalErrors,
99
+ $totalWarnings,
100
+ $totalFixable,
101
+ $showSources=false,
102
+ $width=80,
103
+ $toScreen=true
104
+ ) {
105
+ echo $cachedData;
106
+
107
+ }//end generate()
108
+
109
+
110
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Full.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Full report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Gabriele Santini <gsantini@sqli.com>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2009-2014 SQLI <www.sqli.com>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * Full report for PHP_CodeSniffer.
19
+ *
20
+ * PHP version 5
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Gabriele Santini <gsantini@sqli.com>
25
+ * @author Greg Sherwood <gsherwood@squiz.net>
26
+ * @copyright 2009-2014 SQLI <www.sqli.com>
27
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class PHP_CodeSniffer_Reports_Full implements PHP_CodeSniffer_Report
33
+ {
34
+
35
+
36
+ /**
37
+ * Generate a partial report for a single processed file.
38
+ *
39
+ * Function should return TRUE if it printed or stored data about the file
40
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
41
+ * its data should be counted in the grand totals.
42
+ *
43
+ * @param array $report Prepared report data.
44
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
45
+ * @param boolean $showSources Show sources?
46
+ * @param int $width Maximum allowed line width.
47
+ *
48
+ * @return boolean
49
+ */
50
+ public function generateFileReport(
51
+ $report,
52
+ PHP_CodeSniffer_File $phpcsFile,
53
+ $showSources=false,
54
+ $width=80
55
+ ) {
56
+ if ($report['errors'] === 0 && $report['warnings'] === 0) {
57
+ // Nothing to print.
58
+ return false;
59
+ }
60
+
61
+ // The length of the word ERROR or WARNING; used for padding.
62
+ if ($report['warnings'] > 0) {
63
+ $typeLength = 7;
64
+ } else {
65
+ $typeLength = 5;
66
+ }
67
+
68
+ // Work out the max line number length for formatting.
69
+ $maxLineNumLength = max(array_map('strlen', array_keys($report['messages'])));
70
+
71
+ // The padding that all lines will require that are
72
+ // printing an error message overflow.
73
+ $paddingLine2 = str_repeat(' ', ($maxLineNumLength + 1));
74
+ $paddingLine2 .= ' | ';
75
+ $paddingLine2 .= str_repeat(' ', $typeLength);
76
+ $paddingLine2 .= ' | ';
77
+ if ($report['fixable'] > 0) {
78
+ $paddingLine2 .= ' ';
79
+ }
80
+
81
+ $paddingLength = strlen($paddingLine2);
82
+
83
+ // Make sure the report width isn't too big.
84
+ $maxErrorLength = 0;
85
+ foreach ($report['messages'] as $line => $lineErrors) {
86
+ foreach ($lineErrors as $column => $colErrors) {
87
+ foreach ($colErrors as $error) {
88
+ $length = strlen($error['message']);
89
+ if ($showSources === true) {
90
+ $length += (strlen($error['source']) + 3);
91
+ }
92
+
93
+ $maxErrorLength = max($maxErrorLength, ($length + 1));
94
+ }
95
+ }
96
+ }
97
+
98
+ $file = $report['filename'];
99
+ $fileLength = strlen($file);
100
+ $maxWidth = max(($fileLength + 6), ($maxErrorLength + $paddingLength));
101
+ $width = min($width, $maxWidth);
102
+ if ($width < 70) {
103
+ $width = 70;
104
+ }
105
+
106
+ echo PHP_EOL."\033[1mFILE: ";
107
+ if ($fileLength <= ($width - 6)) {
108
+ echo $file;
109
+ } else {
110
+ echo '...'.substr($file, ($fileLength - ($width - 6)));
111
+ }
112
+
113
+ echo "\033[0m".PHP_EOL;
114
+ echo str_repeat('-', $width).PHP_EOL;
115
+
116
+ echo "\033[1m".'FOUND '.$report['errors'].' ERROR';
117
+ if ($report['errors'] !== 1) {
118
+ echo 'S';
119
+ }
120
+
121
+ if ($report['warnings'] > 0) {
122
+ echo ' AND '.$report['warnings'].' WARNING';
123
+ if ($report['warnings'] !== 1) {
124
+ echo 'S';
125
+ }
126
+ }
127
+
128
+ echo ' AFFECTING '.count($report['messages']).' LINE';
129
+ if (count($report['messages']) !== 1) {
130
+ echo 'S';
131
+ }
132
+
133
+ echo "\033[0m".PHP_EOL;
134
+ echo str_repeat('-', $width).PHP_EOL;
135
+
136
+ // The maximum amount of space an error message can use.
137
+ $maxErrorSpace = ($width - $paddingLength - 1);
138
+ if ($showSources === true) {
139
+ // Account for the chars used to print colors.
140
+ $maxErrorSpace += 8;
141
+ }
142
+
143
+ foreach ($report['messages'] as $line => $lineErrors) {
144
+ foreach ($lineErrors as $column => $colErrors) {
145
+ foreach ($colErrors as $error) {
146
+ $message = $error['message'];
147
+ $message = str_replace("\n", "\n".$paddingLine2, $message);
148
+ if ($showSources === true) {
149
+ $message = "\033[1m".$message."\033[0m".' ('.$error['source'].')';
150
+ }
151
+
152
+ // The padding that goes on the front of the line.
153
+ $padding = ($maxLineNumLength - strlen($line));
154
+ $errorMsg = wordwrap(
155
+ $message,
156
+ $maxErrorSpace,
157
+ PHP_EOL.$paddingLine2
158
+ );
159
+
160
+ echo ' '.str_repeat(' ', $padding).$line.' | ';
161
+ if ($error['type'] === 'ERROR') {
162
+ echo "\033[31mERROR\033[0m";
163
+ if ($report['warnings'] > 0) {
164
+ echo ' ';
165
+ }
166
+ } else {
167
+ echo "\033[33mWARNING\033[0m";
168
+ }
169
+
170
+ echo ' | ';
171
+ if ($report['fixable'] > 0) {
172
+ echo '[';
173
+ if ($error['fixable'] === true) {
174
+ echo 'x';
175
+ } else {
176
+ echo ' ';
177
+ }
178
+
179
+ echo '] ';
180
+ }
181
+
182
+ echo $errorMsg.PHP_EOL;
183
+ }//end foreach
184
+ }//end foreach
185
+ }//end foreach
186
+
187
+ echo str_repeat('-', $width).PHP_EOL;
188
+ if ($report['fixable'] > 0) {
189
+ echo "\033[1m".'PHPCBF CAN FIX THE '.$report['fixable'].' MARKED SNIFF VIOLATIONS AUTOMATICALLY'."\033[0m".PHP_EOL;
190
+ echo str_repeat('-', $width).PHP_EOL;
191
+ }
192
+
193
+ echo PHP_EOL;
194
+ return true;
195
+
196
+ }//end generateFileReport()
197
+
198
+
199
+ /**
200
+ * Prints all errors and warnings for each file processed.
201
+ *
202
+ * @param string $cachedData Any partial report data that was returned from
203
+ * generateFileReport during the run.
204
+ * @param int $totalFiles Total number of files processed during the run.
205
+ * @param int $totalErrors Total number of errors found during the run.
206
+ * @param int $totalWarnings Total number of warnings found during the run.
207
+ * @param int $totalFixable Total number of problems that can be fixed.
208
+ * @param boolean $showSources Show sources?
209
+ * @param int $width Maximum allowed line width.
210
+ * @param boolean $toScreen Is the report being printed to screen?
211
+ *
212
+ * @return void
213
+ */
214
+ public function generate(
215
+ $cachedData,
216
+ $totalFiles,
217
+ $totalErrors,
218
+ $totalWarnings,
219
+ $totalFixable,
220
+ $showSources=false,
221
+ $width=80,
222
+ $toScreen=true
223
+ ) {
224
+ if ($cachedData === '') {
225
+ return;
226
+ }
227
+
228
+ echo $cachedData;
229
+
230
+ if ($toScreen === true && PHP_CODESNIFFER_INTERACTIVE === false) {
231
+ PHP_CodeSniffer_Reporting::printRunTime();
232
+ }
233
+
234
+ }//end generate()
235
+
236
+
237
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Gitblame.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Gitblame report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Ben Selby <benmatselby@gmail.com>
10
+ * @copyright 2009-2014 SQLI <www.sqli.com>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Gitblame report for PHP_CodeSniffer.
18
+ *
19
+ * PHP version 5
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Ben Selby <benmatselby@gmail.com>
24
+ * @copyright 2009-2014 SQLI <www.sqli.com>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: 1.2.2
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class PHP_CodeSniffer_Reports_Gitblame extends PHP_CodeSniffer_Reports_VersionControl
31
+ {
32
+
33
+ /**
34
+ * The name of the report we want in the output
35
+ *
36
+ * @var string
37
+ */
38
+ protected $reportName = 'GIT';
39
+
40
+
41
+ /**
42
+ * Extract the author from a blame line.
43
+ *
44
+ * @param string $line Line to parse.
45
+ *
46
+ * @return mixed string or false if impossible to recover.
47
+ */
48
+ protected function getAuthor($line)
49
+ {
50
+ $blameParts = array();
51
+ $line = preg_replace('|\s+|', ' ', $line);
52
+ preg_match(
53
+ '|\(.+[0-9]{4}-[0-9]{2}-[0-9]{2}\s+[0-9]+\)|',
54
+ $line,
55
+ $blameParts
56
+ );
57
+
58
+ if (isset($blameParts[0]) === false) {
59
+ return false;
60
+ }
61
+
62
+ $parts = explode(' ', $blameParts[0]);
63
+
64
+ if (count($parts) < 2) {
65
+ return false;
66
+ }
67
+
68
+ $parts = array_slice($parts, 0, (count($parts) - 2));
69
+ $author = preg_replace('|\(|', '', implode($parts, ' '));
70
+ return $author;
71
+
72
+ }//end getAuthor()
73
+
74
+
75
+ /**
76
+ * Gets the blame output.
77
+ *
78
+ * @param string $filename File to blame.
79
+ *
80
+ * @return array
81
+ */
82
+ protected function getBlameContent($filename)
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) {
90
+ echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL;
91
+ exit(2);
92
+ }
93
+
94
+ $rawContent = stream_get_contents($handle);
95
+ fclose($handle);
96
+
97
+ $blames = explode("\n", $rawContent);
98
+ chdir($cwd);
99
+
100
+ return $blames;
101
+
102
+ }//end getBlameContent()
103
+
104
+
105
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Hgblame.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Mercurial report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Ben Selby <benmatselby@gmail.com>
10
+ * @copyright 2009-2014 SQLI <www.sqli.com>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Mercurial report for PHP_CodeSniffer.
18
+ *
19
+ * PHP version 5
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Ben Selby <benmatselby@gmail.com>
24
+ * @copyright 2009-2014 SQLI <www.sqli.com>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class PHP_CodeSniffer_Reports_Hgblame extends PHP_CodeSniffer_Reports_VersionControl
31
+ {
32
+
33
+ /**
34
+ * The name of the report we want in the output
35
+ *
36
+ * @var string
37
+ */
38
+ protected $reportName = 'MERCURIAL';
39
+
40
+
41
+ /**
42
+ * Extract the author from a blame line.
43
+ *
44
+ * @param string $line Line to parse.
45
+ *
46
+ * @return mixed string or false if impossible to recover.
47
+ */
48
+ protected function getAuthor($line)
49
+ {
50
+ $blameParts = array();
51
+ $line = preg_replace('|\s+|', ' ', $line);
52
+
53
+ preg_match(
54
+ '|(.+[0-9]{2}:[0-9]{2}:[0-9]{2}\s[0-9]{4}\s.[0-9]{4}:)|',
55
+ $line,
56
+ $blameParts
57
+ );
58
+
59
+ if (isset($blameParts[0]) === false) {
60
+ return false;
61
+ }
62
+
63
+ $parts = explode(' ', $blameParts[0]);
64
+
65
+ if (count($parts) < 6) {
66
+ return false;
67
+ }
68
+
69
+ $parts = array_slice($parts, 0, (count($parts) - 6));
70
+
71
+ return trim(preg_replace('|<.+>|', '', implode($parts, ' ')));
72
+
73
+ }//end getAuthor()
74
+
75
+
76
+ /**
77
+ * Gets the blame output.
78
+ *
79
+ * @param string $filename File to blame.
80
+ *
81
+ * @return array
82
+ */
83
+ protected function getBlameContent($filename)
84
+ {
85
+ $cwd = getcwd();
86
+
87
+ $fileParts = explode(DIRECTORY_SEPARATOR, $filename);
88
+ $found = false;
89
+ $location = '';
90
+ while (empty($fileParts) === false) {
91
+ array_pop($fileParts);
92
+ $location = implode($fileParts, DIRECTORY_SEPARATOR);
93
+ if (is_dir($location.DIRECTORY_SEPARATOR.'.hg') === true) {
94
+ $found = true;
95
+ break;
96
+ }
97
+ }
98
+
99
+ if ($found === true) {
100
+ chdir($location);
101
+ } else {
102
+ echo 'ERROR: Could not locate .hg directory '.PHP_EOL.PHP_EOL;
103
+ exit(2);
104
+ }
105
+
106
+ $command = 'hg blame -u -d -v "'.$filename.'" 2>&1';
107
+ $handle = popen($command, 'r');
108
+ if ($handle === false) {
109
+ echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL;
110
+ exit(2);
111
+ }
112
+
113
+ $rawContent = stream_get_contents($handle);
114
+ fclose($handle);
115
+
116
+ $blames = explode("\n", $rawContent);
117
+ chdir($cwd);
118
+
119
+ return $blames;
120
+
121
+ }//end getBlameContent()
122
+
123
+
124
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Info.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Info report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Info report for PHP_CodeSniffer.
17
+ *
18
+ * PHP version 5
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class PHP_CodeSniffer_Reports_Info implements PHP_CodeSniffer_Report
29
+ {
30
+
31
+ /**
32
+ * TRUE if this report needs error messages instead of just totals.
33
+ *
34
+ * @var boolean
35
+ */
36
+ public $recordErrors = false;
37
+
38
+ /**
39
+ * A cache of metrics collected during the run.
40
+ *
41
+ * @var array
42
+ */
43
+ private $_metricCache = array();
44
+
45
+
46
+ /**
47
+ * Generate a partial report for a single processed file.
48
+ *
49
+ * Function should return TRUE if it printed or stored data about the file
50
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
51
+ * its data should be counted in the grand totals.
52
+ *
53
+ * @param array $report Prepared report data.
54
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
55
+ * @param boolean $showSources Show sources?
56
+ * @param int $width Maximum allowed line width.
57
+ *
58
+ * @return boolean
59
+ */
60
+ public function generateFileReport(
61
+ $report,
62
+ PHP_CodeSniffer_File $phpcsFile,
63
+ $showSources=false,
64
+ $width=80
65
+ ) {
66
+ $metrics = $phpcsFile->getMetrics();
67
+ foreach ($metrics as $metric => $data) {
68
+ if (isset($this->_metricCache[$metric]) === false) {
69
+ $this->_metricCache[$metric] = array();
70
+ }
71
+
72
+ foreach ($data['values'] as $value => $locations) {
73
+ $locations = array_unique($locations);
74
+ $count = count($locations);
75
+
76
+ if (isset($this->_metricCache[$metric][$value]) === false) {
77
+ $this->_metricCache[$metric][$value] = $count;
78
+ } else {
79
+ $this->_metricCache[$metric][$value] += $count;
80
+ }
81
+ }
82
+ }//end foreach
83
+
84
+ return true;
85
+
86
+ }//end generateFileReport()
87
+
88
+
89
+ /**
90
+ * Prints the source of all errors and warnings.
91
+ *
92
+ * @param string $cachedData Any partial report data that was returned from
93
+ * generateFileReport during the run.
94
+ * @param int $totalFiles Total number of files processed during the run.
95
+ * @param int $totalErrors Total number of errors found during the run.
96
+ * @param int $totalWarnings Total number of warnings found during the run.
97
+ * @param int $totalFixable Total number of problems that can be fixed.
98
+ * @param boolean $showSources Show sources?
99
+ * @param int $width Maximum allowed line width.
100
+ * @param boolean $toScreen Is the report being printed to screen?
101
+ *
102
+ * @return void
103
+ */
104
+ public function generate(
105
+ $cachedData,
106
+ $totalFiles,
107
+ $totalErrors,
108
+ $totalWarnings,
109
+ $totalFixable,
110
+ $showSources=false,
111
+ $width=80,
112
+ $toScreen=true
113
+ ) {
114
+ if (empty($this->_metricCache) === true) {
115
+ // Nothing to show.
116
+ return;
117
+ }
118
+
119
+ ksort($this->_metricCache);
120
+
121
+ echo PHP_EOL."\033[1m".'PHP CODE SNIFFER INFORMATION REPORT'."\033[0m".PHP_EOL;
122
+ echo str_repeat('-', 70).PHP_EOL;
123
+
124
+ foreach ($this->_metricCache as $metric => $values) {
125
+ $winner = '';
126
+ $winnerCount = 0;
127
+ $totalCount = 0;
128
+ foreach ($values as $value => $count) {
129
+ $totalCount += $count;
130
+ if ($count > $winnerCount) {
131
+ $winner = $value;
132
+ $winnerCount = $count;
133
+ }
134
+ }
135
+
136
+ $winPercent = round(($winnerCount / $totalCount * 100), 2);
137
+ echo "$metric: \033[4m$winner\033[0m [$winnerCount/$totalCount, $winPercent%]".PHP_EOL;
138
+
139
+ asort($values);
140
+ $values = array_reverse($values, true);
141
+ foreach ($values as $value => $count) {
142
+ if ($value === $winner) {
143
+ continue;
144
+ }
145
+
146
+ $percent = round(($count / $totalCount * 100), 2);
147
+ echo "\t$value => $count ($percent%)".PHP_EOL;
148
+ }
149
+
150
+ echo PHP_EOL;
151
+ }//end foreach
152
+
153
+ echo str_repeat('-', 70).PHP_EOL;
154
+
155
+ if ($toScreen === true && PHP_CODESNIFFER_INTERACTIVE === false) {
156
+ PHP_CodeSniffer_Reporting::printRunTime();
157
+ }
158
+
159
+ }//end generate()
160
+
161
+
162
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Json.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Json report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Jeffrey Fisher <jeffslofish@gmail.com>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Json report for PHP_CodeSniffer.
18
+ *
19
+ * PHP version 5
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Jeffrey Fisher <jeffslofish@gmail.com>
24
+ * @author Greg Sherwood <gsherwood@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class PHP_CodeSniffer_Reports_Json implements PHP_CodeSniffer_Report
31
+ {
32
+
33
+
34
+ /**
35
+ * Generate a partial report for a single processed file.
36
+ *
37
+ * Function should return TRUE if it printed or stored data about the file
38
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
39
+ * its data should be counted in the grand totals.
40
+ *
41
+ * @param array $report Prepared report data.
42
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
43
+ * @param boolean $showSources Show sources?
44
+ * @param int $width Maximum allowed line width.
45
+ *
46
+ * @return boolean
47
+ */
48
+ public function generateFileReport(
49
+ $report,
50
+ PHP_CodeSniffer_File $phpcsFile,
51
+ $showSources=false,
52
+ $width=80
53
+ ) {
54
+ $filename = str_replace('\\', '\\\\', $report['filename']);
55
+ $filename = str_replace('"', '\"', $filename);
56
+ $filename = str_replace('/', '\/', $filename);
57
+ echo '"'.$filename.'":{';
58
+ echo '"errors":'.$report['errors'].',"warnings":'.$report['warnings'].',"messages":[';
59
+
60
+ $messages = '';
61
+ foreach ($report['messages'] as $line => $lineErrors) {
62
+ foreach ($lineErrors as $column => $colErrors) {
63
+ foreach ($colErrors as $error) {
64
+ $error['message'] = str_replace('\\', '\\\\', $error['message']);
65
+ $error['message'] = str_replace('"', '\"', $error['message']);
66
+ $error['message'] = str_replace('/', '\/', $error['message']);
67
+ $error['message'] = str_replace("\n", '\n', $error['message']);
68
+ $error['message'] = str_replace("\r", '\r', $error['message']);
69
+ $error['message'] = str_replace("\t", '\t', $error['message']);
70
+
71
+ $fixable = 'false';
72
+ if ($error['fixable'] === true) {
73
+ $fixable = 'true';
74
+ }
75
+
76
+ $messages .= '{"message":"'.$error['message'].'",';
77
+ $messages .= '"source":"'.$error['source'].'",';
78
+ $messages .= '"severity":'.$error['severity'].',';
79
+ $messages .= '"type":"'.$error['type'].'",';
80
+ $messages .= '"line":'.$line.',';
81
+ $messages .= '"column":'.$column.',';
82
+ $messages .= '"fixable":'.$fixable;
83
+ $messages .= '},';
84
+ }//end foreach
85
+ }//end foreach
86
+ }//end foreach
87
+
88
+ echo rtrim($messages, ',');
89
+ echo ']},';
90
+
91
+ return true;
92
+
93
+ }//end generateFileReport()
94
+
95
+
96
+ /**
97
+ * Generates a JSON report.
98
+ *
99
+ * @param string $cachedData Any partial report data that was returned from
100
+ * generateFileReport during the run.
101
+ * @param int $totalFiles Total number of files processed during the run.
102
+ * @param int $totalErrors Total number of errors found during the run.
103
+ * @param int $totalWarnings Total number of warnings found during the run.
104
+ * @param int $totalFixable Total number of problems that can be fixed.
105
+ * @param boolean $showSources Show sources?
106
+ * @param int $width Maximum allowed line width.
107
+ * @param boolean $toScreen Is the report being printed to screen?
108
+ *
109
+ * @return void
110
+ */
111
+ public function generate(
112
+ $cachedData,
113
+ $totalFiles,
114
+ $totalErrors,
115
+ $totalWarnings,
116
+ $totalFixable,
117
+ $showSources=false,
118
+ $width=80,
119
+ $toScreen=true
120
+ ) {
121
+ echo '{"totals":{"errors":'.$totalErrors.',"warnings":'.$totalWarnings.',"fixable":'.$totalFixable.'},"files":{';
122
+ echo rtrim($cachedData, ',');
123
+ echo "}}";
124
+
125
+ }//end generate()
126
+
127
+
128
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Junit.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * JUnit report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Oleg Lobach <oleg@lobach.info>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * JUnit report for PHP_CodeSniffer.
18
+ *
19
+ * PHP version 5
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Oleg Lobach <oleg@lobach.info>
24
+ * @author Greg Sherwood <gsherwood@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class PHP_CodeSniffer_Reports_Junit implements PHP_CodeSniffer_Report
31
+ {
32
+
33
+ /**
34
+ * A count of tests that have been performed.
35
+ *
36
+ * @var int
37
+ */
38
+ private $_tests = 0;
39
+
40
+
41
+ /**
42
+ * Generate a partial report for a single processed file.
43
+ *
44
+ * Function should return TRUE if it printed or stored data about the file
45
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
46
+ * its data should be counted in the grand totals.
47
+ *
48
+ * @param array $report Prepared report data.
49
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
50
+ * @param boolean $showSources Show sources?
51
+ * @param int $width Maximum allowed line width.
52
+ *
53
+ * @return boolean
54
+ */
55
+ public function generateFileReport(
56
+ $report,
57
+ PHP_CodeSniffer_File $phpcsFile,
58
+ $showSources=false,
59
+ $width=80
60
+ ) {
61
+ if (count($report['messages']) === 0) {
62
+ $this->_tests++;
63
+ } else {
64
+ $this->_tests += ($report['errors'] + $report['warnings']);
65
+ }
66
+
67
+ $out = new XMLWriter;
68
+ $out->openMemory();
69
+ $out->setIndent(true);
70
+
71
+ $out->startElement('testsuite');
72
+ $out->writeAttribute('name', $report['filename']);
73
+
74
+ if (count($report['messages']) === 0) {
75
+ $out->writeAttribute('tests', 1);
76
+ $out->writeAttribute('failures', 0);
77
+
78
+ $out->startElement('testcase');
79
+ $out->writeAttribute('name', $report['filename']);
80
+ $out->endElement();
81
+ } else {
82
+ $failures = ($report['errors'] + $report['warnings']);
83
+ $out->writeAttribute('tests', $failures);
84
+ $out->writeAttribute('failures', $failures);
85
+
86
+ foreach ($report['messages'] as $line => $lineErrors) {
87
+ foreach ($lineErrors as $column => $colErrors) {
88
+ foreach ($colErrors as $error) {
89
+ $out->startElement('testcase');
90
+ $out->writeAttribute('name', $error['source'].' at '.$report['filename']." ($line:$column)");
91
+
92
+ $error['type'] = strtolower($error['type']);
93
+ if (PHP_CODESNIFFER_ENCODING !== 'utf-8') {
94
+ $error['message'] = iconv(PHP_CODESNIFFER_ENCODING, 'utf-8', $error['message']);
95
+ }
96
+
97
+ $out->startElement('failure');
98
+ $out->writeAttribute('type', $error['type']);
99
+ $out->writeAttribute('message', $error['message']);
100
+ $out->endElement();
101
+
102
+ $out->endElement();
103
+ }
104
+ }
105
+ }
106
+ }//end if
107
+
108
+ $out->endElement();
109
+ echo $out->flush();
110
+ return true;
111
+
112
+ }//end generateFileReport()
113
+
114
+
115
+ /**
116
+ * Prints all violations for processed files, in a proprietary XML format.
117
+ *
118
+ * @param string $cachedData Any partial report data that was returned from
119
+ * generateFileReport during the run.
120
+ * @param int $totalFiles Total number of files processed during the run.
121
+ * @param int $totalErrors Total number of errors found during the run.
122
+ * @param int $totalWarnings Total number of warnings found during the run.
123
+ * @param int $totalFixable Total number of problems that can be fixed.
124
+ * @param boolean $showSources Show sources?
125
+ * @param int $width Maximum allowed line width.
126
+ * @param boolean $toScreen Is the report being printed to screen?
127
+ *
128
+ * @return void
129
+ */
130
+ public function generate(
131
+ $cachedData,
132
+ $totalFiles,
133
+ $totalErrors,
134
+ $totalWarnings,
135
+ $totalFixable,
136
+ $showSources=false,
137
+ $width=80,
138
+ $toScreen=true
139
+ ) {
140
+ $failures = ($totalErrors + $totalWarnings);
141
+ echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
142
+ echo '<testsuites name="PHP_CodeSniffer '.PHP_CodeSniffer::VERSION.'" tests="'.$this->_tests.'" failures="'.$failures.'">'.PHP_EOL;
143
+ echo $cachedData;
144
+ echo '</testsuites>'.PHP_EOL;
145
+
146
+ }//end generate()
147
+
148
+
149
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Notifysend.php ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Notify-send report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Christian Weiske <christian.weiske@netresearch.de>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2012-2014 Christian Weiske
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * Notify-send report for PHP_CodeSniffer.
19
+ *
20
+ * Supported configuration parameters:
21
+ * - notifysend_path - Full path to notify-send cli command
22
+ * - notifysend_timeout - Timeout in milliseconds
23
+ * - notifysend_showok - Show "ok, all fine" messages (0/1)
24
+ *
25
+ * @category PHP
26
+ * @package PHP_CodeSniffer
27
+ * @author Christian Weiske <christian.weiske@netresearch.de>
28
+ * @author Greg Sherwood <gsherwood@squiz.net>
29
+ * @copyright 2012-2014 Christian Weiske
30
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
31
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
32
+ * @version Release: @package_version@
33
+ * @link http://pear.php.net/package/PHP_CodeSniffer
34
+ */
35
+ class PHP_CodeSniffer_Reports_Notifysend implements PHP_CodeSniffer_Report
36
+ {
37
+
38
+ /**
39
+ * Notification timeout in milliseconds.
40
+ *
41
+ * @var integer
42
+ */
43
+ protected $timeout = 3000;
44
+
45
+ /**
46
+ * Path to notify-send command.
47
+ *
48
+ * @var string
49
+ */
50
+ protected $path = 'notify-send';
51
+
52
+ /**
53
+ * Show "ok, all fine" messages.
54
+ *
55
+ * @var boolean
56
+ */
57
+ protected $showOk = true;
58
+
59
+ /**
60
+ * Version of installed notify-send executable.
61
+ *
62
+ * @var string
63
+ */
64
+ protected $version = null;
65
+
66
+ /**
67
+ * A record of the last file checked.
68
+ *
69
+ * This is used in case we only checked one file and need to print
70
+ * the name/path of the file. We wont have access to the checked file list
71
+ * after the run has been completed.
72
+ *
73
+ * @var string
74
+ */
75
+ private $_lastCheckedFile = '';
76
+
77
+
78
+ /**
79
+ * Load configuration data.
80
+ */
81
+ public function __construct()
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');
89
+ if ($timeout !== null) {
90
+ $this->timeout = (int) $timeout;
91
+ }
92
+
93
+ $showOk = PHP_CodeSniffer::getConfigData('notifysend_showok');
94
+ if ($showOk !== null) {
95
+ $this->showOk = (boolean) $showOk;
96
+ }
97
+
98
+ $this->version = str_replace(
99
+ 'notify-send ',
100
+ '',
101
+ exec($this->path.' --version')
102
+ );
103
+
104
+ }//end __construct()
105
+
106
+
107
+ /**
108
+ * Generate a partial report for a single processed file.
109
+ *
110
+ * Function should return TRUE if it printed or stored data about the file
111
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
112
+ * its data should be counted in the grand totals.
113
+ *
114
+ * @param array $report Prepared report data.
115
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
116
+ * @param boolean $showSources Show sources?
117
+ * @param int $width Maximum allowed line width.
118
+ *
119
+ * @return boolean
120
+ */
121
+ public function generateFileReport(
122
+ $report,
123
+ PHP_CodeSniffer_File $phpcsFile,
124
+ $showSources=false,
125
+ $width=80
126
+ ) {
127
+ // We don't need to print anything, but we want this file counted
128
+ // in the total number of checked files even if it has no errors.
129
+ $this->_lastCheckedFile = $report['filename'];
130
+ return true;
131
+
132
+ }//end generateFileReport()
133
+
134
+
135
+ /**
136
+ * Generates a summary of errors and warnings for each file processed.
137
+ *
138
+ * @param string $cachedData Any partial report data that was returned from
139
+ * generateFileReport during the run.
140
+ * @param int $totalFiles Total number of files processed during the run.
141
+ * @param int $totalErrors Total number of errors found during the run.
142
+ * @param int $totalWarnings Total number of warnings found during the run.
143
+ * @param int $totalFixable Total number of problems that can be fixed.
144
+ * @param boolean $showSources Show sources?
145
+ * @param int $width Maximum allowed line width.
146
+ * @param boolean $toScreen Is the report being printed to screen?
147
+ *
148
+ * @return void
149
+ */
150
+ public function generate(
151
+ $cachedData,
152
+ $totalFiles,
153
+ $totalErrors,
154
+ $totalWarnings,
155
+ $totalFixable,
156
+ $showSources=false,
157
+ $width=80,
158
+ $toScreen=true
159
+ ) {
160
+ $msg = $this->generateMessage($totalFiles, $totalErrors, $totalWarnings);
161
+ if ($msg === null) {
162
+ if ($this->showOk === true) {
163
+ $this->notifyAllFine();
164
+ }
165
+ } else {
166
+ $this->notifyErrors($msg);
167
+ }
168
+
169
+ }//end generate()
170
+
171
+
172
+ /**
173
+ * Generate the error message to show to the user.
174
+ *
175
+ * @param int $totalFiles Total number of files processed during the run.
176
+ * @param int $totalErrors Total number of errors found during the run.
177
+ * @param int $totalWarnings Total number of warnings found during the run.
178
+ *
179
+ * @return string Error message or NULL if no error/warning found.
180
+ */
181
+ protected function generateMessage($totalFiles, $totalErrors, $totalWarnings)
182
+ {
183
+ if ($totalErrors === 0 && $totalWarnings === 0) {
184
+ // Nothing to print.
185
+ return null;
186
+ }
187
+
188
+ $msg = '';
189
+ if ($totalFiles > 1) {
190
+ $msg .= 'Checked '.$totalFiles.' files'.PHP_EOL;
191
+ } else {
192
+ $msg .= $this->_lastCheckedFile.PHP_EOL;
193
+ }
194
+
195
+ if ($totalWarnings > 0) {
196
+ $msg .= $totalWarnings.' warnings'.PHP_EOL;
197
+ }
198
+
199
+ if ($totalErrors > 0) {
200
+ $msg .= $totalErrors.' errors'.PHP_EOL;
201
+ }
202
+
203
+ return $msg;
204
+
205
+ }//end generateMessage()
206
+
207
+
208
+ /**
209
+ * Tell the user that all is fine and no error/warning has been found.
210
+ *
211
+ * @return void
212
+ */
213
+ protected function notifyAllFine()
214
+ {
215
+ $cmd = $this->getBasicCommand();
216
+ $cmd .= ' -i info';
217
+ $cmd .= ' "PHP CodeSniffer: Ok"';
218
+ $cmd .= ' "All fine"';
219
+ exec($cmd);
220
+
221
+ }//end notifyAllFine()
222
+
223
+
224
+ /**
225
+ * Tell the user that errors/warnings have been found.
226
+ *
227
+ * @param string $msg Message to display.
228
+ *
229
+ * @return void
230
+ */
231
+ protected function notifyErrors($msg)
232
+ {
233
+ $cmd = $this->getBasicCommand();
234
+ $cmd .= ' -i error';
235
+ $cmd .= ' "PHP CodeSniffer: Error"';
236
+ $cmd .= ' '.escapeshellarg(trim($msg));
237
+ exec($cmd);
238
+
239
+ }//end notifyErrors()
240
+
241
+
242
+ /**
243
+ * Generate and return the basic notify-send command string to execute.
244
+ *
245
+ * @return string Shell command with common parameters.
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;
253
+ if (version_compare($this->version, '0.7.3', '>=') === true) {
254
+ $cmd .= ' -a phpcs';
255
+ }
256
+
257
+ return $cmd;
258
+
259
+ }//end getBasicCommand()
260
+
261
+
262
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Source.php ADDED
@@ -0,0 +1,334 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Source report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Gabriele Santini <gsantini@sqli.com>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2009-2014 SQLI <www.sqli.com>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * Source report for PHP_CodeSniffer.
19
+ *
20
+ * PHP version 5
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Gabriele Santini <gsantini@sqli.com>
25
+ * @author Greg Sherwood <gsherwood@squiz.net>
26
+ * @copyright 2009-2014 SQLI <www.sqli.com>
27
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class PHP_CodeSniffer_Reports_Source implements PHP_CodeSniffer_Report
33
+ {
34
+
35
+ /**
36
+ * A cache of source stats collected during the run.
37
+ *
38
+ * @var array
39
+ */
40
+ private $_sourceCache = array();
41
+
42
+
43
+ /**
44
+ * Generate a partial report for a single processed file.
45
+ *
46
+ * Function should return TRUE if it printed or stored data about the file
47
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
48
+ * its data should be counted in the grand totals.
49
+ *
50
+ * @param array $report Prepared report data.
51
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
52
+ * @param boolean $showSources Show sources?
53
+ * @param int $width Maximum allowed line width.
54
+ *
55
+ * @return boolean
56
+ */
57
+ public function generateFileReport(
58
+ $report,
59
+ PHP_CodeSniffer_File $phpcsFile,
60
+ $showSources=false,
61
+ $width=80
62
+ ) {
63
+ if ($report['errors'] === 0 && $report['warnings'] === 0) {
64
+ // Nothing to print.
65
+ return false;
66
+ }
67
+
68
+ foreach ($report['messages'] as $line => $lineErrors) {
69
+ foreach ($lineErrors as $column => $colErrors) {
70
+ foreach ($colErrors as $error) {
71
+ $source = $error['source'];
72
+ if (isset($this->_sourceCache[$source]) === false) {
73
+ if ($showSources === true) {
74
+ $parts = null;
75
+ $sniff = $source;
76
+ } else {
77
+ $parts = explode('.', $source);
78
+ if ($parts[0] === 'Internal') {
79
+ $parts[2] = $parts[1];
80
+ $parts[1] = '';
81
+ }
82
+
83
+ $parts[1] = $this->makeFriendlyName($parts[1]);
84
+
85
+ $sniff = $this->makeFriendlyName($parts[2]);
86
+ if (isset($parts[3]) === true) {
87
+ $name = $this->makeFriendlyName($parts[3]);
88
+ $name[0] = strtolower($name[0]);
89
+ $sniff .= ' '.$name;
90
+ unset($parts[3]);
91
+ }
92
+
93
+ $parts[2] = $sniff;
94
+ }//end if
95
+
96
+ $this->_sourceCache[$source] = array(
97
+ 'count' => 1,
98
+ 'fixable' => $error['fixable'],
99
+ 'parts' => $parts,
100
+ 'strlen' => strlen($sniff),
101
+ );
102
+ } else {
103
+ $this->_sourceCache[$source]['count']++;
104
+ }//end if
105
+ }//end foreach
106
+ }//end foreach
107
+ }//end foreach
108
+
109
+ return true;
110
+
111
+ }//end generateFileReport()
112
+
113
+
114
+ /**
115
+ * Prints the source of all errors and warnings.
116
+ *
117
+ * @param string $cachedData Any partial report data that was returned from
118
+ * generateFileReport during the run.
119
+ * @param int $totalFiles Total number of files processed during the run.
120
+ * @param int $totalErrors Total number of errors found during the run.
121
+ * @param int $totalWarnings Total number of warnings found during the run.
122
+ * @param int $totalFixable Total number of problems that can be fixed.
123
+ * @param boolean $showSources Show sources?
124
+ * @param int $width Maximum allowed line width.
125
+ * @param boolean $toScreen Is the report being printed to screen?
126
+ *
127
+ * @return void
128
+ */
129
+ public function generate(
130
+ $cachedData,
131
+ $totalFiles,
132
+ $totalErrors,
133
+ $totalWarnings,
134
+ $totalFixable,
135
+ $showSources=false,
136
+ $width=80,
137
+ $toScreen=true
138
+ ) {
139
+ if (empty($this->_sourceCache) === true) {
140
+ // Nothing to show.
141
+ return;
142
+ }
143
+
144
+ // Make sure the report width isn't too big.
145
+ $maxLength = 0;
146
+ foreach ($this->_sourceCache as $source => $data) {
147
+ $maxLength = max($maxLength, $data['strlen']);
148
+ }
149
+
150
+ if ($showSources === true) {
151
+ $width = min($width, ($maxLength + 11));
152
+ } else {
153
+ $width = min($width, ($maxLength + 41));
154
+ }
155
+
156
+ $width = max($width, 70);
157
+
158
+ asort($this->_sourceCache);
159
+ $this->_sourceCache = array_reverse($this->_sourceCache);
160
+
161
+ echo PHP_EOL."\033[1mPHP CODE SNIFFER VIOLATION SOURCE SUMMARY\033[0m".PHP_EOL;
162
+ echo str_repeat('-', $width).PHP_EOL."\033[1m";
163
+ if ($showSources === true) {
164
+ if ($totalFixable > 0) {
165
+ echo ' SOURCE'.str_repeat(' ', ($width - 15)).'COUNT'.PHP_EOL;
166
+ } else {
167
+ echo 'SOURCE'.str_repeat(' ', ($width - 11)).'COUNT'.PHP_EOL;
168
+ }
169
+ } else {
170
+ if ($totalFixable > 0) {
171
+ echo ' STANDARD CATEGORY SNIFF'.str_repeat(' ', ($width - 44)).'COUNT'.PHP_EOL;
172
+ } else {
173
+ echo 'STANDARD CATEGORY SNIFF'.str_repeat(' ', ($width - 40)).'COUNT'.PHP_EOL;
174
+ }
175
+ }
176
+
177
+ echo "\033[0m".str_repeat('-', $width).PHP_EOL;
178
+
179
+ $fixableSources = 0;
180
+
181
+ if ($showSources === true) {
182
+ $maxSniffWidth = ($width - 7);
183
+ } else {
184
+ $maxSniffWidth = ($width - 37);
185
+ }
186
+
187
+ if ($totalFixable > 0) {
188
+ $maxSniffWidth -= 4;
189
+ }
190
+
191
+ foreach ($this->_sourceCache as $source => $sourceData) {
192
+ if ($totalFixable > 0) {
193
+ echo '[';
194
+ if ($sourceData['fixable'] === true) {
195
+ echo 'x';
196
+ $fixableSources++;
197
+ } else {
198
+ echo ' ';
199
+ }
200
+
201
+ echo '] ';
202
+ }
203
+
204
+ if ($showSources === true) {
205
+ if ($sourceData['strlen'] > $maxSniffWidth) {
206
+ $source = substr($source, 0, $maxSniffWidth);
207
+ }
208
+
209
+ echo $source;
210
+ if ($totalFixable > 0) {
211
+ echo str_repeat(' ', ($width - 9 - strlen($source)));
212
+ } else {
213
+ echo str_repeat(' ', ($width - 5 - strlen($source)));
214
+ }
215
+ } else {
216
+ $parts = $sourceData['parts'];
217
+
218
+ if (strlen($parts[0]) > 8) {
219
+ $parts[0] = substr($parts[0], 0, ((strlen($parts[0]) - 8) * -1));
220
+ }
221
+
222
+ echo $parts[0].str_repeat(' ', (10 - strlen($parts[0])));
223
+
224
+ $category = $parts[1];
225
+ if (strlen($category) > 18) {
226
+ $category = substr($category, 0, ((strlen($category) - 18) * -1));
227
+ }
228
+
229
+ echo $category.str_repeat(' ', (20 - strlen($category)));
230
+
231
+ $sniff = $parts[2];
232
+ if (strlen($sniff) > $maxSniffWidth) {
233
+ $sniff = substr($sniff, 0, $maxSniffWidth);
234
+ }
235
+
236
+ if ($totalFixable > 0) {
237
+ echo $sniff.str_repeat(' ', ($width - 39 - strlen($sniff)));
238
+ } else {
239
+ echo $sniff.str_repeat(' ', ($width - 35 - strlen($sniff)));
240
+ }
241
+ }//end if
242
+
243
+ echo $sourceData['count'].PHP_EOL;
244
+ }//end foreach
245
+
246
+ echo str_repeat('-', $width).PHP_EOL;
247
+ echo "\033[1m".'A TOTAL OF '.($totalErrors + $totalWarnings).' SNIFF VIOLATION';
248
+ if (($totalErrors + $totalWarnings) > 1) {
249
+ echo 'S';
250
+ }
251
+
252
+ echo ' WERE FOUND IN '.count($this->_sourceCache).' SOURCE';
253
+ if (count($this->_sourceCache) !== 1) {
254
+ echo 'S';
255
+ }
256
+
257
+ echo "\033[0m";
258
+
259
+ if ($totalFixable > 0) {
260
+ echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
261
+ echo "\033[1mPHPCBF CAN FIX THE $fixableSources MARKED SOURCES AUTOMATICALLY ($totalFixable VIOLATIONS IN TOTAL)\033[0m";
262
+ }
263
+
264
+ echo PHP_EOL.str_repeat('-', $width).PHP_EOL.PHP_EOL;
265
+
266
+ if ($toScreen === true && PHP_CODESNIFFER_INTERACTIVE === false) {
267
+ PHP_CodeSniffer_Reporting::printRunTime();
268
+ }
269
+
270
+ }//end generate()
271
+
272
+
273
+ /**
274
+ * Converts a camel caps name into a readable string.
275
+ *
276
+ * @param string $name The camel caps name to convert.
277
+ *
278
+ * @return string
279
+ */
280
+ public function makeFriendlyName($name)
281
+ {
282
+ if (trim($name) === '') {
283
+ return '';
284
+ }
285
+
286
+ $friendlyName = '';
287
+ $length = strlen($name);
288
+
289
+ $lastWasUpper = false;
290
+ $lastWasNumeric = false;
291
+ for ($i = 0; $i < $length; $i++) {
292
+ if (is_numeric($name[$i]) === true) {
293
+ if ($lastWasNumeric === false) {
294
+ $friendlyName .= ' ';
295
+ }
296
+
297
+ $lastWasUpper = false;
298
+ $lastWasNumeric = true;
299
+ } else {
300
+ $lastWasNumeric = false;
301
+
302
+ $char = strtolower($name[$i]);
303
+ if ($char === $name[$i]) {
304
+ // Lowercase.
305
+ $lastWasUpper = false;
306
+ } else {
307
+ // Uppercase.
308
+ if ($lastWasUpper === false) {
309
+ $friendlyName .= ' ';
310
+ if ($i < ($length - 1)) {
311
+ $next = $name[($i + 1)];
312
+ if (strtolower($next) === $next) {
313
+ // Next char is lowercase so it is a word boundary.
314
+ $name[$i] = strtolower($name[$i]);
315
+ }
316
+ }
317
+ }
318
+
319
+ $lastWasUpper = true;
320
+ }
321
+ }//end if
322
+
323
+ $friendlyName .= $name[$i];
324
+ }//end for
325
+
326
+ $friendlyName = trim($friendlyName);
327
+ $friendlyName[0] = strtoupper($friendlyName[0]);
328
+
329
+ return $friendlyName;
330
+
331
+ }//end makeFriendlyName()
332
+
333
+
334
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Summary.php ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Summary report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Gabriele Santini <gsantini@sqli.com>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2009-2014 SQLI <www.sqli.com>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * Summary report for PHP_CodeSniffer.
19
+ *
20
+ * PHP version 5
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Gabriele Santini <gsantini@sqli.com>
25
+ * @author Greg Sherwood <gsherwood@squiz.net>
26
+ * @copyright 2009-2014 SQLI <www.sqli.com>
27
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class PHP_CodeSniffer_Reports_Summary implements PHP_CodeSniffer_Report
33
+ {
34
+
35
+ /**
36
+ * TRUE if this report needs error messages instead of just totals.
37
+ *
38
+ * @var boolean
39
+ */
40
+ public $recordErrors = false;
41
+
42
+ /**
43
+ * An array of process files and their error data.
44
+ *
45
+ * @var boolean
46
+ */
47
+ private $_reportFiles = array();
48
+
49
+
50
+ /**
51
+ * Generate a partial report for a single processed file.
52
+ *
53
+ * Function should return TRUE if it printed or stored data about the file
54
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
55
+ * its data should be counted in the grand totals.
56
+ *
57
+ * @param array $report Prepared report data.
58
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
59
+ * @param boolean $showSources Show sources?
60
+ * @param int $width Maximum allowed line width.
61
+ *
62
+ * @return boolean
63
+ */
64
+ public function generateFileReport(
65
+ $report,
66
+ PHP_CodeSniffer_File $phpcsFile,
67
+ $showSources=false,
68
+ $width=80
69
+ ) {
70
+ if (PHP_CODESNIFFER_VERBOSITY === 0
71
+ && $report['errors'] === 0
72
+ && $report['warnings'] === 0
73
+ ) {
74
+ // Nothing to print.
75
+ return false;
76
+ }
77
+
78
+ $this->_reportFiles[$report['filename']] = array(
79
+ 'errors' => $report['errors'],
80
+ 'warnings' => $report['warnings'],
81
+ 'strlen' => strlen($report['filename']),
82
+ );
83
+
84
+ return true;
85
+
86
+ }//end generateFileReport()
87
+
88
+
89
+ /**
90
+ * Generates a summary of errors and warnings for each file processed.
91
+ *
92
+ * @param string $cachedData Any partial report data that was returned from
93
+ * generateFileReport during the run.
94
+ * @param int $totalFiles Total number of files processed during the run.
95
+ * @param int $totalErrors Total number of errors found during the run.
96
+ * @param int $totalWarnings Total number of warnings found during the run.
97
+ * @param int $totalFixable Total number of problems that can be fixed.
98
+ * @param boolean $showSources Show sources?
99
+ * @param int $width Maximum allowed line width.
100
+ * @param boolean $toScreen Is the report being printed to screen?
101
+ *
102
+ * @return void
103
+ */
104
+ public function generate(
105
+ $cachedData,
106
+ $totalFiles,
107
+ $totalErrors,
108
+ $totalWarnings,
109
+ $totalFixable,
110
+ $showSources=false,
111
+ $width=80,
112
+ $toScreen=true
113
+ ) {
114
+
115
+ if (empty($this->_reportFiles) === true) {
116
+ return;
117
+ }
118
+
119
+ // Make sure the report width isn't too big.
120
+ $maxLength = 0;
121
+ foreach ($this->_reportFiles as $file => $data) {
122
+ $maxLength = max($maxLength, $data['strlen']);
123
+ }
124
+
125
+ $width = min($width, ($maxLength + 21));
126
+ $width = max($width, 70);
127
+
128
+ echo PHP_EOL."\033[1m".'PHP CODE SNIFFER REPORT SUMMARY'."\033[0m".PHP_EOL;
129
+ echo str_repeat('-', $width).PHP_EOL;
130
+ echo "\033[1m".'FILE'.str_repeat(' ', ($width - 20)).'ERRORS WARNINGS'."\033[0m".PHP_EOL;
131
+ echo str_repeat('-', $width).PHP_EOL;
132
+
133
+ foreach ($this->_reportFiles as $file => $data) {
134
+ $padding = ($width - 18 - $data['strlen']);
135
+ if ($padding < 0) {
136
+ $file = '...'.substr($file, (($padding * -1) + 3));
137
+ $padding = 0;
138
+ }
139
+
140
+ echo $file.str_repeat(' ', $padding).' ';
141
+ if ($data['errors'] !== 0) {
142
+ echo "\033[31m".$data['errors']."\033[0m";
143
+ echo str_repeat(' ', (8 - strlen((string) $data['errors'])));
144
+ } else {
145
+ echo '0 ';
146
+ }
147
+
148
+ if ($data['warnings'] !== 0) {
149
+ echo "\033[33m".$data['warnings']."\033[0m";
150
+ } else {
151
+ echo '0';
152
+ }
153
+
154
+ echo PHP_EOL;
155
+ }//end foreach
156
+
157
+ echo str_repeat('-', $width).PHP_EOL;
158
+ echo "\033[1mA TOTAL OF $totalErrors ERROR";
159
+ if ($totalErrors !== 1) {
160
+ echo 'S';
161
+ }
162
+
163
+ echo ' AND '.$totalWarnings.' WARNING';
164
+ if ($totalWarnings !== 1) {
165
+ echo 'S';
166
+ }
167
+
168
+ echo ' WERE FOUND IN '.$totalFiles.' FILE';
169
+ if ($totalFiles !== 1) {
170
+ echo 'S';
171
+ }
172
+
173
+ echo "\033[0m";
174
+
175
+ if ($totalFixable > 0) {
176
+ echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
177
+ echo "\033[1mPHPCBF CAN FIX $totalFixable OF THESE SNIFF VIOLATIONS AUTOMATICALLY\033[0m";
178
+ }
179
+
180
+ echo PHP_EOL.str_repeat('-', $width).PHP_EOL.PHP_EOL;
181
+
182
+ if ($toScreen === true && PHP_CODESNIFFER_INTERACTIVE === false) {
183
+ PHP_CodeSniffer_Reporting::printRunTime();
184
+ }
185
+
186
+ }//end generate()
187
+
188
+
189
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Svnblame.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Svnblame report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Gabriele Santini <gsantini@sqli.com>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2009-2014 SQLI <www.sqli.com>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * Svnblame report for PHP_CodeSniffer.
19
+ *
20
+ * PHP version 5
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Gabriele Santini <gsantini@sqli.com>
25
+ * @author Greg Sherwood <gsherwood@squiz.net>
26
+ * @copyright 2009-2014 SQLI <www.sqli.com>
27
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class PHP_CodeSniffer_Reports_Svnblame extends PHP_CodeSniffer_Reports_VersionControl
33
+ {
34
+
35
+ /**
36
+ * The name of the report we want in the output
37
+ *
38
+ * @var string
39
+ */
40
+ protected $reportName = 'SVN';
41
+
42
+
43
+ /**
44
+ * Extract the author from a blame line.
45
+ *
46
+ * @param string $line Line to parse.
47
+ *
48
+ * @return mixed string or false if impossible to recover.
49
+ */
50
+ protected function getAuthor($line)
51
+ {
52
+ $blameParts = array();
53
+ preg_match('|\s*([^\s]+)\s+([^\s]+)|', $line, $blameParts);
54
+
55
+ if (isset($blameParts[2]) === false) {
56
+ return false;
57
+ }
58
+
59
+ return $blameParts[2];
60
+
61
+ }//end getAuthor()
62
+
63
+
64
+ /**
65
+ * Gets the blame output.
66
+ *
67
+ * @param string $filename File to blame.
68
+ *
69
+ * @return array
70
+ */
71
+ protected function getBlameContent($filename)
72
+ {
73
+ $command = 'svn blame "'.$filename.'" 2>&1';
74
+ $handle = popen($command, 'r');
75
+ if ($handle === false) {
76
+ echo 'ERROR: Could not execute "'.$command.'"'.PHP_EOL.PHP_EOL;
77
+ exit(2);
78
+ }
79
+
80
+ $rawContent = stream_get_contents($handle);
81
+ fclose($handle);
82
+
83
+ $blames = explode("\n", $rawContent);
84
+
85
+ return $blames;
86
+
87
+ }//end getBlameContent()
88
+
89
+
90
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/VersionControl.php ADDED
@@ -0,0 +1,342 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Version control report base class for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Ben Selby <benmatselby@gmail.com>
10
+ * @copyright 2009-2014 SQLI <www.sqli.com>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Version control report base class for PHP_CodeSniffer.
18
+ *
19
+ * PHP version 5
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Ben Selby <benmatselby@gmail.com>
24
+ * @copyright 2009-2014 SQLI <www.sqli.com>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: 1.2.2
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ abstract class PHP_CodeSniffer_Reports_VersionControl implements PHP_CodeSniffer_Report
31
+ {
32
+
33
+ /**
34
+ * The name of the report we want in the output.
35
+ *
36
+ * @var string
37
+ */
38
+ protected $reportName = 'VERSION CONTROL';
39
+
40
+ /**
41
+ * A cache of author stats collected during the run.
42
+ *
43
+ * @var array
44
+ */
45
+ private $_authorCache = array();
46
+
47
+ /**
48
+ * A cache of blame stats collected during the run.
49
+ *
50
+ * @var array
51
+ */
52
+ private $_praiseCache = array();
53
+
54
+ /**
55
+ * A cache of source stats collected during the run.
56
+ *
57
+ * @var array
58
+ */
59
+ private $_sourceCache = array();
60
+
61
+
62
+ /**
63
+ * Generate a partial report for a single processed file.
64
+ *
65
+ * Function should return TRUE if it printed or stored data about the file
66
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
67
+ * its data should be counted in the grand totals.
68
+ *
69
+ * @param array $report Prepared report data.
70
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
71
+ * @param boolean $showSources Show sources?
72
+ * @param int $width Maximum allowed line width.
73
+ *
74
+ * @return boolean
75
+ */
76
+ public function generateFileReport(
77
+ $report,
78
+ PHP_CodeSniffer_File $phpcsFile,
79
+ $showSources=false,
80
+ $width=80
81
+ ) {
82
+ $blames = $this->getBlameContent($report['filename']);
83
+
84
+ foreach ($report['messages'] as $line => $lineErrors) {
85
+ $author = 'Unknown';
86
+ if (isset($blames[($line - 1)]) === true) {
87
+ $blameAuthor = $this->getAuthor($blames[($line - 1)]);
88
+ if ($blameAuthor !== false) {
89
+ $author = $blameAuthor;
90
+ }
91
+ }
92
+
93
+ if (isset($this->_authorCache[$author]) === false) {
94
+ $this->_authorCache[$author] = 0;
95
+ $this->_praiseCache[$author] = array(
96
+ 'good' => 0,
97
+ 'bad' => 0,
98
+ );
99
+ }
100
+
101
+ $this->_praiseCache[$author]['bad']++;
102
+
103
+ foreach ($lineErrors as $column => $colErrors) {
104
+ foreach ($colErrors as $error) {
105
+ $this->_authorCache[$author]++;
106
+
107
+ if ($showSources === true) {
108
+ $source = $error['source'];
109
+ if (isset($this->_sourceCache[$author][$source]) === false) {
110
+ $this->_sourceCache[$author][$source] = array(
111
+ 'count' => 1,
112
+ 'fixable' => $error['fixable'],
113
+ );
114
+ } else {
115
+ $this->_sourceCache[$author][$source]['count']++;
116
+ }
117
+ }
118
+ }
119
+ }
120
+
121
+ unset($blames[($line - 1)]);
122
+ }//end foreach
123
+
124
+ // No go through and give the authors some credit for
125
+ // all the lines that do not have errors.
126
+ foreach ($blames as $line) {
127
+ $author = $this->getAuthor($line);
128
+ if ($author === false) {
129
+ $author = 'Unknown';
130
+ }
131
+
132
+ if (isset($this->_authorCache[$author]) === false) {
133
+ // This author doesn't have any errors.
134
+ if (PHP_CODESNIFFER_VERBOSITY === 0) {
135
+ continue;
136
+ }
137
+
138
+ $this->_authorCache[$author] = 0;
139
+ $this->_praiseCache[$author] = array(
140
+ 'good' => 0,
141
+ 'bad' => 0,
142
+ );
143
+ }
144
+
145
+ $this->_praiseCache[$author]['good']++;
146
+ }//end foreach
147
+
148
+ return true;
149
+
150
+ }//end generateFileReport()
151
+
152
+
153
+ /**
154
+ * Prints the author of all errors and warnings, as given by "version control blame".
155
+ *
156
+ * @param string $cachedData Any partial report data that was returned from
157
+ * generateFileReport during the run.
158
+ * @param int $totalFiles Total number of files processed during the run.
159
+ * @param int $totalErrors Total number of errors found during the run.
160
+ * @param int $totalWarnings Total number of warnings found during the run.
161
+ * @param int $totalFixable Total number of problems that can be fixed.
162
+ * @param boolean $showSources Show sources?
163
+ * @param int $width Maximum allowed line width.
164
+ * @param boolean $toScreen Is the report being printed to screen?
165
+ *
166
+ * @return void
167
+ */
168
+ public function generate(
169
+ $cachedData,
170
+ $totalFiles,
171
+ $totalErrors,
172
+ $totalWarnings,
173
+ $totalFixable,
174
+ $showSources=false,
175
+ $width=80,
176
+ $toScreen=true
177
+ ) {
178
+ $errorsShown = ($totalErrors + $totalWarnings);
179
+ if ($errorsShown === 0) {
180
+ // Nothing to show.
181
+ return;
182
+ }
183
+
184
+ // Make sure the report width isn't too big.
185
+ $maxLength = 0;
186
+ foreach ($this->_authorCache as $author => $count) {
187
+ $maxLength = max($maxLength, strlen($author));
188
+ if ($showSources === true && isset($this->_sourceCache[$author]) === true) {
189
+ foreach ($this->_sourceCache[$author] as $source => $sourceData) {
190
+ if ($source === 'count') {
191
+ continue;
192
+ }
193
+
194
+ $maxLength = max($maxLength, (strlen($source) + 9));
195
+ }
196
+ }
197
+ }
198
+
199
+ $width = min($width, ($maxLength + 30));
200
+ $width = max($width, 70);
201
+ arsort($this->_authorCache);
202
+
203
+ echo PHP_EOL."\033[1m".'PHP CODE SNIFFER '.$this->reportName.' BLAME SUMMARY'."\033[0m".PHP_EOL;
204
+ echo str_repeat('-', $width).PHP_EOL."\033[1m";
205
+ if ($showSources === true) {
206
+ echo 'AUTHOR SOURCE'.str_repeat(' ', ($width - 43)).'(Author %) (Overall %) COUNT'.PHP_EOL;
207
+ echo str_repeat('-', $width).PHP_EOL;
208
+ } else {
209
+ echo 'AUTHOR'.str_repeat(' ', ($width - 34)).'(Author %) (Overall %) COUNT'.PHP_EOL;
210
+ echo str_repeat('-', $width).PHP_EOL;
211
+ }
212
+
213
+ echo "\033[0m";
214
+
215
+ if ($showSources === true) {
216
+ $maxSniffWidth = ($width - 15);
217
+
218
+ if ($totalFixable > 0) {
219
+ $maxSniffWidth -= 4;
220
+ }
221
+ }
222
+
223
+ $fixableSources = 0;
224
+
225
+ foreach ($this->_authorCache as $author => $count) {
226
+ if ($this->_praiseCache[$author]['good'] === 0) {
227
+ $percent = 0;
228
+ } else {
229
+ $total = ($this->_praiseCache[$author]['bad'] + $this->_praiseCache[$author]['good']);
230
+ $percent = round(($this->_praiseCache[$author]['bad'] / $total * 100), 2);
231
+ }
232
+
233
+ $overallPercent = '('.round((($count / $errorsShown) * 100), 2).')';
234
+ $authorPercent = '('.$percent.')';
235
+ $line = str_repeat(' ', (6 - strlen($count))).$count;
236
+ $line = str_repeat(' ', (12 - strlen($overallPercent))).$overallPercent.$line;
237
+ $line = str_repeat(' ', (11 - strlen($authorPercent))).$authorPercent.$line;
238
+ $line = $author.str_repeat(' ', ($width - strlen($author) - strlen($line))).$line;
239
+
240
+ if ($showSources === true) {
241
+ $line = "\033[1m$line\033[0m";
242
+ }
243
+
244
+ echo $line.PHP_EOL;
245
+
246
+ if ($showSources === true && isset($this->_sourceCache[$author]) === true) {
247
+ $errors = $this->_sourceCache[$author];
248
+ asort($errors);
249
+ $errors = array_reverse($errors);
250
+
251
+ foreach ($errors as $source => $sourceData) {
252
+ if ($source === 'count') {
253
+ continue;
254
+ }
255
+
256
+ $count = $sourceData['count'];
257
+
258
+ $srcLength = strlen($source);
259
+ if ($srcLength > $maxSniffWidth) {
260
+ $source = substr($source, 0, $maxSniffWidth);
261
+ }
262
+
263
+ $line = str_repeat(' ', (5 - strlen($count))).$count;
264
+
265
+ echo ' ';
266
+ if ($totalFixable > 0) {
267
+ echo '[';
268
+ if ($sourceData['fixable'] === true) {
269
+ echo 'x';
270
+ $fixableSources++;
271
+ } else {
272
+ echo ' ';
273
+ }
274
+
275
+ echo '] ';
276
+ }
277
+
278
+ echo $source;
279
+ if ($totalFixable > 0) {
280
+ echo str_repeat(' ', ($width - 18 - strlen($source)));
281
+ } else {
282
+ echo str_repeat(' ', ($width - 14 - strlen($source)));
283
+ }
284
+
285
+ echo $line.PHP_EOL;
286
+ }//end foreach
287
+ }//end if
288
+ }//end foreach
289
+
290
+ echo str_repeat('-', $width).PHP_EOL;
291
+ echo "\033[1m".'A TOTAL OF '.$errorsShown.' SNIFF VIOLATION';
292
+ if ($errorsShown !== 1) {
293
+ echo 'S';
294
+ }
295
+
296
+ echo ' WERE COMMITTED BY '.count($this->_authorCache).' AUTHOR';
297
+ if (count($this->_authorCache) !== 1) {
298
+ echo 'S';
299
+ }
300
+
301
+ echo "\033[0m";
302
+
303
+ if ($totalFixable > 0) {
304
+ if ($showSources === true) {
305
+ echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
306
+ echo "\033[1mPHPCBF CAN FIX THE $fixableSources MARKED SOURCES AUTOMATICALLY ($totalFixable VIOLATIONS IN TOTAL)\033[0m";
307
+ } else {
308
+ echo PHP_EOL.str_repeat('-', $width).PHP_EOL;
309
+ echo "\033[1mPHPCBF CAN FIX $totalFixable OF THESE SNIFF VIOLATIONS AUTOMATICALLY\033[0m";
310
+ }
311
+ }
312
+
313
+ echo PHP_EOL.str_repeat('-', $width).PHP_EOL.PHP_EOL;
314
+
315
+ if ($toScreen === true && PHP_CODESNIFFER_INTERACTIVE === false) {
316
+ PHP_CodeSniffer_Reporting::printRunTime();
317
+ }
318
+
319
+ }//end generate()
320
+
321
+
322
+ /**
323
+ * Extract the author from a blame line.
324
+ *
325
+ * @param string $line Line to parse.
326
+ *
327
+ * @return mixed string or false if impossible to recover.
328
+ */
329
+ abstract protected function getAuthor($line);
330
+
331
+
332
+ /**
333
+ * Gets the blame output.
334
+ *
335
+ * @param string $filename File to blame.
336
+ *
337
+ * @return array
338
+ */
339
+ abstract protected function getBlameContent($filename);
340
+
341
+
342
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Reports/Xml.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Xml report for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Gabriele Santini <gsantini@sqli.com>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2009-2014 SQLI <www.sqli.com>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * Xml report for PHP_CodeSniffer.
19
+ *
20
+ * PHP version 5
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Gabriele Santini <gsantini@sqli.com>
25
+ * @author Greg Sherwood <gsherwood@squiz.net>
26
+ * @copyright 2009-2014 SQLI <www.sqli.com>
27
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class PHP_CodeSniffer_Reports_Xml implements PHP_CodeSniffer_Report
33
+ {
34
+
35
+
36
+ /**
37
+ * Generate a partial report for a single processed file.
38
+ *
39
+ * Function should return TRUE if it printed or stored data about the file
40
+ * and FALSE if it ignored the file. Returning TRUE indicates that the file and
41
+ * its data should be counted in the grand totals.
42
+ *
43
+ * @param array $report Prepared report data.
44
+ * @param PHP_CodeSniffer_File $phpcsFile The file being reported on.
45
+ * @param boolean $showSources Show sources?
46
+ * @param int $width Maximum allowed line width.
47
+ *
48
+ * @return boolean
49
+ */
50
+ public function generateFileReport(
51
+ $report,
52
+ PHP_CodeSniffer_File $phpcsFile,
53
+ $showSources=false,
54
+ $width=80
55
+ ) {
56
+ $out = new XMLWriter;
57
+ $out->openMemory();
58
+ $out->setIndent(true);
59
+
60
+ if ($report['errors'] === 0 && $report['warnings'] === 0) {
61
+ // Nothing to print.
62
+ return false;
63
+ }
64
+
65
+ $out->startElement('file');
66
+ $out->writeAttribute('name', $report['filename']);
67
+ $out->writeAttribute('errors', $report['errors']);
68
+ $out->writeAttribute('warnings', $report['warnings']);
69
+ $out->writeAttribute('fixable', $report['fixable']);
70
+
71
+ foreach ($report['messages'] as $line => $lineErrors) {
72
+ foreach ($lineErrors as $column => $colErrors) {
73
+ foreach ($colErrors as $error) {
74
+ $error['type'] = strtolower($error['type']);
75
+ if (PHP_CODESNIFFER_ENCODING !== 'utf-8') {
76
+ $error['message'] = iconv(PHP_CODESNIFFER_ENCODING, 'utf-8', $error['message']);
77
+ }
78
+
79
+ $out->startElement($error['type']);
80
+ $out->writeAttribute('line', $line);
81
+ $out->writeAttribute('column', $column);
82
+ $out->writeAttribute('source', $error['source']);
83
+ $out->writeAttribute('severity', $error['severity']);
84
+ $out->writeAttribute('fixable', (int) $error['fixable']);
85
+ $out->text($error['message']);
86
+ $out->endElement();
87
+ }
88
+ }
89
+ }//end foreach
90
+
91
+ $out->endElement();
92
+ echo $out->flush();
93
+
94
+ return true;
95
+
96
+ }//end generateFileReport()
97
+
98
+
99
+ /**
100
+ * Prints all violations for processed files, in a proprietary XML format.
101
+ *
102
+ * @param string $cachedData Any partial report data that was returned from
103
+ * generateFileReport during the run.
104
+ * @param int $totalFiles Total number of files processed during the run.
105
+ * @param int $totalErrors Total number of errors found during the run.
106
+ * @param int $totalWarnings Total number of warnings found during the run.
107
+ * @param int $totalFixable Total number of problems that can be fixed.
108
+ * @param boolean $showSources Show sources?
109
+ * @param int $width Maximum allowed line width.
110
+ * @param boolean $toScreen Is the report being printed to screen?
111
+ *
112
+ * @return void
113
+ */
114
+ public function generate(
115
+ $cachedData,
116
+ $totalFiles,
117
+ $totalErrors,
118
+ $totalWarnings,
119
+ $totalFixable,
120
+ $showSources=false,
121
+ $width=80,
122
+ $toScreen=true
123
+ ) {
124
+ echo '<?xml version="1.0" encoding="UTF-8"?>'.PHP_EOL;
125
+ echo '<phpcs version="'.PHP_CodeSniffer::VERSION.'">'.PHP_EOL;
126
+ echo $cachedData;
127
+ echo '</phpcs>'.PHP_EOL;
128
+
129
+ }//end generate()
130
+
131
+
132
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Sniff.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Represents a PHP_CodeSniffer sniff for sniffing coding standards.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Represents a PHP_CodeSniffer sniff for sniffing coding standards.
18
+ *
19
+ * A sniff registers what token types it wishes to listen for, then, when
20
+ * PHP_CodeSniffer encounters that token, the sniff is invoked and passed
21
+ * information about where the token was found in the stack, and the
22
+ * PHP_CodeSniffer file in which the token was found.
23
+ *
24
+ * @category PHP
25
+ * @package PHP_CodeSniffer
26
+ * @author Greg Sherwood <gsherwood@squiz.net>
27
+ * @author Marc McIntyre <mmcintyre@squiz.net>
28
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
29
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
30
+ * @version Release: @package_version@
31
+ * @link http://pear.php.net/package/PHP_CodeSniffer
32
+ */
33
+ interface PHP_CodeSniffer_Sniff
34
+ {
35
+
36
+
37
+ /**
38
+ * Registers the tokens that this sniff wants to listen for.
39
+ *
40
+ * An example return value for a sniff that wants to listen for whitespace
41
+ * and any comments would be:
42
+ *
43
+ * <code>
44
+ * return array(
45
+ * T_WHITESPACE,
46
+ * T_DOC_COMMENT,
47
+ * T_COMMENT,
48
+ * );
49
+ * </code>
50
+ *
51
+ * @return int[]
52
+ * @see Tokens.php
53
+ */
54
+ public function register();
55
+
56
+
57
+ /**
58
+ * Called when one of the token types that this sniff is listening for
59
+ * is found.
60
+ *
61
+ * The stackPtr variable indicates where in the stack the token was found.
62
+ * A sniff can acquire information this token, along with all the other
63
+ * tokens within the stack by first acquiring the token stack:
64
+ *
65
+ * <code>
66
+ * $tokens = $phpcsFile->getTokens();
67
+ * echo 'Encountered a '.$tokens[$stackPtr]['type'].' token';
68
+ * echo 'token information: ';
69
+ * print_r($tokens[$stackPtr]);
70
+ * </code>
71
+ *
72
+ * If the sniff discovers an anomaly in the code, they can raise an error
73
+ * by calling addError() on the PHP_CodeSniffer_File object, specifying an error
74
+ * message and the position of the offending token:
75
+ *
76
+ * <code>
77
+ * $phpcsFile->addError('Encountered an error', $stackPtr);
78
+ * </code>
79
+ *
80
+ * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the
81
+ * token was found.
82
+ * @param int $stackPtr The position in the PHP_CodeSniffer
83
+ * file's token stack where the token
84
+ * was found.
85
+ *
86
+ * @return void|int Optionally returns a stack pointer. The sniff will not be
87
+ * called again on the current file until the returned stack
88
+ * pointer is reached. Return (count($tokens) + 1) to skip
89
+ * the rest of the file.
90
+ */
91
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr);
92
+
93
+
94
+ }//end interface
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractPatternSniff.php ADDED
@@ -0,0 +1,962 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Processes pattern strings and checks that the code conforms to the pattern.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ if (class_exists('PHP_CodeSniffer_Standards_IncorrectPatternException', true) === false) {
17
+ $error = 'Class PHP_CodeSniffer_Standards_IncorrectPatternException not found';
18
+ throw new PHP_CodeSniffer_Exception($error);
19
+ }
20
+
21
+ /**
22
+ * Processes pattern strings and checks that the code conforms to the pattern.
23
+ *
24
+ * This test essentially checks that code is correctly formatted with whitespace.
25
+ *
26
+ * @category PHP
27
+ * @package PHP_CodeSniffer
28
+ * @author Greg Sherwood <gsherwood@squiz.net>
29
+ * @author Marc McIntyre <mmcintyre@squiz.net>
30
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
31
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
32
+ * @version Release: @package_version@
33
+ * @link http://pear.php.net/package/PHP_CodeSniffer
34
+ */
35
+ abstract class PHP_CodeSniffer_Standards_AbstractPatternSniff implements PHP_CodeSniffer_Sniff
36
+ {
37
+
38
+ /**
39
+ * If true, comments will be ignored if they are found in the code.
40
+ *
41
+ * @var boolean
42
+ */
43
+ public $ignoreComments = false;
44
+
45
+ /**
46
+ * The current file being checked.
47
+ *
48
+ * @var string
49
+ */
50
+ protected $currFile = '';
51
+
52
+ /**
53
+ * The parsed patterns array.
54
+ *
55
+ * @var array
56
+ */
57
+ private $_parsedPatterns = array();
58
+
59
+ /**
60
+ * Tokens that this sniff wishes to process outside of the patterns.
61
+ *
62
+ * @var array(int)
63
+ * @see registerSupplementary()
64
+ * @see processSupplementary()
65
+ */
66
+ private $_supplementaryTokens = array();
67
+
68
+ /**
69
+ * Positions in the stack where errors have occurred.
70
+ *
71
+ * @var array()
72
+ */
73
+ private $_errorPos = array();
74
+
75
+
76
+ /**
77
+ * Constructs a PHP_CodeSniffer_Standards_AbstractPatternSniff.
78
+ *
79
+ * @param boolean $ignoreComments If true, comments will be ignored.
80
+ */
81
+ public function __construct($ignoreComments=null)
82
+ {
83
+ // This is here for backwards compatibility.
84
+ if ($ignoreComments !== null) {
85
+ $this->ignoreComments = $ignoreComments;
86
+ }
87
+
88
+ $this->_supplementaryTokens = $this->registerSupplementary();
89
+
90
+ }//end __construct()
91
+
92
+
93
+ /**
94
+ * Registers the tokens to listen to.
95
+ *
96
+ * Classes extending <i>AbstractPatternTest</i> should implement the
97
+ * <i>getPatterns()</i> method to register the patterns they wish to test.
98
+ *
99
+ * @return int[]
100
+ * @see process()
101
+ */
102
+ public final function register()
103
+ {
104
+ $listenTypes = array();
105
+ $patterns = $this->getPatterns();
106
+
107
+ foreach ($patterns as $pattern) {
108
+ $parsedPattern = $this->_parse($pattern);
109
+
110
+ // Find a token position in the pattern that we can use
111
+ // for a listener token.
112
+ $pos = $this->_getListenerTokenPos($parsedPattern);
113
+ $tokenType = $parsedPattern[$pos]['token'];
114
+ $listenTypes[] = $tokenType;
115
+
116
+ $patternArray = array(
117
+ 'listen_pos' => $pos,
118
+ 'pattern' => $parsedPattern,
119
+ 'pattern_code' => $pattern,
120
+ );
121
+
122
+ if (isset($this->_parsedPatterns[$tokenType]) === false) {
123
+ $this->_parsedPatterns[$tokenType] = array();
124
+ }
125
+
126
+ $this->_parsedPatterns[$tokenType][] = $patternArray;
127
+ }//end foreach
128
+
129
+ return array_unique(array_merge($listenTypes, $this->_supplementaryTokens));
130
+
131
+ }//end register()
132
+
133
+
134
+ /**
135
+ * Returns the token types that the specified pattern is checking for.
136
+ *
137
+ * Returned array is in the format:
138
+ * <code>
139
+ * array(
140
+ * T_WHITESPACE => 0, // 0 is the position where the T_WHITESPACE token
141
+ * // should occur in the pattern.
142
+ * );
143
+ * </code>
144
+ *
145
+ * @param array $pattern The parsed pattern to find the acquire the token
146
+ * types from.
147
+ *
148
+ * @return array<int, int>
149
+ */
150
+ private function _getPatternTokenTypes($pattern)
151
+ {
152
+ $tokenTypes = array();
153
+ foreach ($pattern as $pos => $patternInfo) {
154
+ if ($patternInfo['type'] === 'token') {
155
+ if (isset($tokenTypes[$patternInfo['token']]) === false) {
156
+ $tokenTypes[$patternInfo['token']] = $pos;
157
+ }
158
+ }
159
+ }
160
+
161
+ return $tokenTypes;
162
+
163
+ }//end _getPatternTokenTypes()
164
+
165
+
166
+ /**
167
+ * Returns the position in the pattern that this test should register as
168
+ * a listener for the pattern.
169
+ *
170
+ * @param array $pattern The pattern to acquire the listener for.
171
+ *
172
+ * @return int The position in the pattern that this test should register
173
+ * as the listener.
174
+ * @throws PHP_CodeSniffer_Exception If we could not determine a token
175
+ * to listen for.
176
+ */
177
+ private function _getListenerTokenPos($pattern)
178
+ {
179
+ $tokenTypes = $this->_getPatternTokenTypes($pattern);
180
+ $tokenCodes = array_keys($tokenTypes);
181
+ $token = PHP_CodeSniffer_Tokens::getHighestWeightedToken($tokenCodes);
182
+
183
+ // If we could not get a token.
184
+ if ($token === false) {
185
+ $error = 'Could not determine a token to listen for';
186
+ throw new PHP_CodeSniffer_Exception($error);
187
+ }
188
+
189
+ return $tokenTypes[$token];
190
+
191
+ }//end _getListenerTokenPos()
192
+
193
+
194
+ /**
195
+ * Processes the test.
196
+ *
197
+ * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the
198
+ * token occurred.
199
+ * @param int $stackPtr The position in the tokens stack
200
+ * where the listening token type was
201
+ * found.
202
+ *
203
+ * @return void
204
+ * @see register()
205
+ */
206
+ public final function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
207
+ {
208
+ $file = $phpcsFile->getFilename();
209
+ if ($this->currFile !== $file) {
210
+ // We have changed files, so clean up.
211
+ $this->_errorPos = array();
212
+ $this->currFile = $file;
213
+ }
214
+
215
+ $tokens = $phpcsFile->getTokens();
216
+
217
+ if (in_array($tokens[$stackPtr]['code'], $this->_supplementaryTokens) === true) {
218
+ $this->processSupplementary($phpcsFile, $stackPtr);
219
+ }
220
+
221
+ $type = $tokens[$stackPtr]['code'];
222
+
223
+ // If the type is not set, then it must have been a token registered
224
+ // with registerSupplementary().
225
+ if (isset($this->_parsedPatterns[$type]) === false) {
226
+ return;
227
+ }
228
+
229
+ $allErrors = array();
230
+
231
+ // Loop over each pattern that is listening to the current token type
232
+ // that we are processing.
233
+ foreach ($this->_parsedPatterns[$type] as $patternInfo) {
234
+ // If processPattern returns false, then the pattern that we are
235
+ // checking the code with must not be designed to check that code.
236
+ $errors = $this->processPattern($patternInfo, $phpcsFile, $stackPtr);
237
+ if ($errors === false) {
238
+ // The pattern didn't match.
239
+ continue;
240
+ } else if (empty($errors) === true) {
241
+ // The pattern matched, but there were no errors.
242
+ break;
243
+ }
244
+
245
+ foreach ($errors as $stackPtr => $error) {
246
+ if (isset($this->_errorPos[$stackPtr]) === false) {
247
+ $this->_errorPos[$stackPtr] = true;
248
+ $allErrors[$stackPtr] = $error;
249
+ }
250
+ }
251
+ }
252
+
253
+ foreach ($allErrors as $stackPtr => $error) {
254
+ $phpcsFile->addError($error, $stackPtr, 'Found');
255
+ }
256
+
257
+ }//end process()
258
+
259
+
260
+ /**
261
+ * Processes the pattern and verifies the code at $stackPtr.
262
+ *
263
+ * @param array $patternInfo Information about the pattern used
264
+ * for checking, which includes are
265
+ * parsed token representation of the
266
+ * pattern.
267
+ * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the
268
+ * token occurred.
269
+ * @param int $stackPtr The position in the tokens stack where
270
+ * the listening token type was found.
271
+ *
272
+ * @return array
273
+ */
274
+ protected function processPattern(
275
+ $patternInfo,
276
+ PHP_CodeSniffer_File $phpcsFile,
277
+ $stackPtr
278
+ ) {
279
+ $tokens = $phpcsFile->getTokens();
280
+ $pattern = $patternInfo['pattern'];
281
+ $patternCode = $patternInfo['pattern_code'];
282
+ $errors = array();
283
+ $found = '';
284
+
285
+ $ignoreTokens = array(T_WHITESPACE);
286
+ if ($this->ignoreComments === true) {
287
+ $ignoreTokens
288
+ = array_merge($ignoreTokens, PHP_CodeSniffer_Tokens::$commentTokens);
289
+ }
290
+
291
+ $origStackPtr = $stackPtr;
292
+ $hasError = false;
293
+
294
+ if ($patternInfo['listen_pos'] > 0) {
295
+ $stackPtr--;
296
+
297
+ for ($i = ($patternInfo['listen_pos'] - 1); $i >= 0; $i--) {
298
+ if ($pattern[$i]['type'] === 'token') {
299
+ if ($pattern[$i]['token'] === T_WHITESPACE) {
300
+ if ($tokens[$stackPtr]['code'] === T_WHITESPACE) {
301
+ $found = $tokens[$stackPtr]['content'].$found;
302
+ }
303
+
304
+ // Only check the size of the whitespace if this is not
305
+ // the first token. We don't care about the size of
306
+ // leading whitespace, just that there is some.
307
+ if ($i !== 0) {
308
+ if ($tokens[$stackPtr]['content'] !== $pattern[$i]['value']) {
309
+ $hasError = true;
310
+ }
311
+ }
312
+ } else {
313
+ // Check to see if this important token is the same as the
314
+ // previous important token in the pattern. If it is not,
315
+ // then the pattern cannot be for this piece of code.
316
+ $prev = $phpcsFile->findPrevious(
317
+ $ignoreTokens,
318
+ $stackPtr,
319
+ null,
320
+ true
321
+ );
322
+
323
+ if ($prev === false
324
+ || $tokens[$prev]['code'] !== $pattern[$i]['token']
325
+ ) {
326
+ return false;
327
+ }
328
+
329
+ // If we skipped past some whitespace tokens, then add them
330
+ // to the found string.
331
+ $tokenContent = $phpcsFile->getTokensAsString(
332
+ ($prev + 1),
333
+ ($stackPtr - $prev - 1)
334
+ );
335
+
336
+ $found = $tokens[$prev]['content'].$tokenContent.$found;
337
+
338
+ if (isset($pattern[($i - 1)]) === true
339
+ && $pattern[($i - 1)]['type'] === 'skip'
340
+ ) {
341
+ $stackPtr = $prev;
342
+ } else {
343
+ $stackPtr = ($prev - 1);
344
+ }
345
+ }//end if
346
+ } else if ($pattern[$i]['type'] === 'skip') {
347
+ // Skip to next piece of relevant code.
348
+ if ($pattern[$i]['to'] === 'parenthesis_closer') {
349
+ $to = 'parenthesis_opener';
350
+ } else {
351
+ $to = 'scope_opener';
352
+ }
353
+
354
+ // Find the previous opener.
355
+ $next = $phpcsFile->findPrevious(
356
+ $ignoreTokens,
357
+ $stackPtr,
358
+ null,
359
+ true
360
+ );
361
+
362
+ if ($next === false || isset($tokens[$next][$to]) === false) {
363
+ // If there was not opener, then we must be
364
+ // using the wrong pattern.
365
+ return false;
366
+ }
367
+
368
+ if ($to === 'parenthesis_opener') {
369
+ $found = '{'.$found;
370
+ } else {
371
+ $found = '('.$found;
372
+ }
373
+
374
+ $found = '...'.$found;
375
+
376
+ // Skip to the opening token.
377
+ $stackPtr = ($tokens[$next][$to] - 1);
378
+ } else if ($pattern[$i]['type'] === 'string') {
379
+ $found = 'abc';
380
+ } else if ($pattern[$i]['type'] === 'newline') {
381
+ if ($this->ignoreComments === true
382
+ && isset(PHP_CodeSniffer_Tokens::$commentTokens[$tokens[$stackPtr]['code']]) === true
383
+ ) {
384
+ $startComment = $phpcsFile->findPrevious(
385
+ PHP_CodeSniffer_Tokens::$commentTokens,
386
+ ($stackPtr - 1),
387
+ null,
388
+ true
389
+ );
390
+
391
+ if ($tokens[$startComment]['line'] !== $tokens[($startComment + 1)]['line']) {
392
+ $startComment++;
393
+ }
394
+
395
+ $tokenContent = $phpcsFile->getTokensAsString(
396
+ $startComment,
397
+ ($stackPtr - $startComment + 1)
398
+ );
399
+
400
+ $found = $tokenContent.$found;
401
+ $stackPtr = ($startComment - 1);
402
+ }
403
+
404
+ if ($tokens[$stackPtr]['code'] === T_WHITESPACE) {
405
+ if ($tokens[$stackPtr]['content'] !== $phpcsFile->eolChar) {
406
+ $found = $tokens[$stackPtr]['content'].$found;
407
+
408
+ // This may just be an indent that comes after a newline
409
+ // so check the token before to make sure. If it is a newline, we
410
+ // can ignore the error here.
411
+ if (($tokens[($stackPtr - 1)]['content'] !== $phpcsFile->eolChar)
412
+ && ($this->ignoreComments === true
413
+ && isset(PHP_CodeSniffer_Tokens::$commentTokens[$tokens[($stackPtr - 1)]['code']]) === false)
414
+ ) {
415
+ $hasError = true;
416
+ } else {
417
+ $stackPtr--;
418
+ }
419
+ } else {
420
+ $found = 'EOL'.$found;
421
+ }
422
+ } else {
423
+ $found = $tokens[$stackPtr]['content'].$found;
424
+ $hasError = true;
425
+ }//end if
426
+
427
+ if ($hasError === false && $pattern[($i - 1)]['type'] !== 'newline') {
428
+ // Make sure they only have 1 newline.
429
+ $prev = $phpcsFile->findPrevious($ignoreTokens, ($stackPtr - 1), null, true);
430
+ if ($prev !== false && $tokens[$prev]['line'] !== $tokens[$stackPtr]['line']) {
431
+ $hasError = true;
432
+ }
433
+ }
434
+ }//end if
435
+ }//end for
436
+ }//end if
437
+
438
+ $stackPtr = $origStackPtr;
439
+ $lastAddedStackPtr = null;
440
+ $patternLen = count($pattern);
441
+
442
+ for ($i = $patternInfo['listen_pos']; $i < $patternLen; $i++) {
443
+ if (isset($tokens[$stackPtr]) === false) {
444
+ break;
445
+ }
446
+
447
+ if ($pattern[$i]['type'] === 'token') {
448
+ if ($pattern[$i]['token'] === T_WHITESPACE) {
449
+ if ($this->ignoreComments === true) {
450
+ // If we are ignoring comments, check to see if this current
451
+ // token is a comment. If so skip it.
452
+ if (isset(PHP_CodeSniffer_Tokens::$commentTokens[$tokens[$stackPtr]['code']]) === true) {
453
+ continue;
454
+ }
455
+
456
+ // If the next token is a comment, the we need to skip the
457
+ // current token as we should allow a space before a
458
+ // comment for readability.
459
+ if (isset($tokens[($stackPtr + 1)]) === true
460
+ && isset(PHP_CodeSniffer_Tokens::$commentTokens[$tokens[($stackPtr + 1)]['code']]) === true
461
+ ) {
462
+ continue;
463
+ }
464
+ }
465
+
466
+ $tokenContent = '';
467
+ if ($tokens[$stackPtr]['code'] === T_WHITESPACE) {
468
+ if (isset($pattern[($i + 1)]) === false) {
469
+ // This is the last token in the pattern, so just compare
470
+ // the next token of content.
471
+ $tokenContent = $tokens[$stackPtr]['content'];
472
+ } else {
473
+ // Get all the whitespace to the next token.
474
+ $next = $phpcsFile->findNext(
475
+ PHP_CodeSniffer_Tokens::$emptyTokens,
476
+ $stackPtr,
477
+ null,
478
+ true
479
+ );
480
+
481
+ $tokenContent = $phpcsFile->getTokensAsString(
482
+ $stackPtr,
483
+ ($next - $stackPtr)
484
+ );
485
+
486
+ $lastAddedStackPtr = $stackPtr;
487
+ $stackPtr = $next;
488
+ }//end if
489
+
490
+ if ($stackPtr !== $lastAddedStackPtr) {
491
+ $found .= $tokenContent;
492
+ }
493
+ } else {
494
+ if ($stackPtr !== $lastAddedStackPtr) {
495
+ $found .= $tokens[$stackPtr]['content'];
496
+ $lastAddedStackPtr = $stackPtr;
497
+ }
498
+ }//end if
499
+
500
+ if (isset($pattern[($i + 1)]) === true
501
+ && $pattern[($i + 1)]['type'] === 'skip'
502
+ ) {
503
+ // The next token is a skip token, so we just need to make
504
+ // sure the whitespace we found has *at least* the
505
+ // whitespace required.
506
+ if (strpos($tokenContent, $pattern[$i]['value']) !== 0) {
507
+ $hasError = true;
508
+ }
509
+ } else {
510
+ if ($tokenContent !== $pattern[$i]['value']) {
511
+ $hasError = true;
512
+ }
513
+ }
514
+ } else {
515
+ // Check to see if this important token is the same as the
516
+ // next important token in the pattern. If it is not, then
517
+ // the pattern cannot be for this piece of code.
518
+ $next = $phpcsFile->findNext(
519
+ $ignoreTokens,
520
+ $stackPtr,
521
+ null,
522
+ true
523
+ );
524
+
525
+ if ($next === false
526
+ || $tokens[$next]['code'] !== $pattern[$i]['token']
527
+ ) {
528
+ // The next important token did not match the pattern.
529
+ return false;
530
+ }
531
+
532
+ if ($lastAddedStackPtr !== null) {
533
+ if (($tokens[$next]['code'] === T_OPEN_CURLY_BRACKET
534
+ || $tokens[$next]['code'] === T_CLOSE_CURLY_BRACKET)
535
+ && isset($tokens[$next]['scope_condition']) === true
536
+ && $tokens[$next]['scope_condition'] > $lastAddedStackPtr
537
+ ) {
538
+ // This is a brace, but the owner of it is after the current
539
+ // token, which means it does not belong to any token in
540
+ // our pattern. This means the pattern is not for us.
541
+ return false;
542
+ }
543
+
544
+ if (($tokens[$next]['code'] === T_OPEN_PARENTHESIS
545
+ || $tokens[$next]['code'] === T_CLOSE_PARENTHESIS)
546
+ && isset($tokens[$next]['parenthesis_owner']) === true
547
+ && $tokens[$next]['parenthesis_owner'] > $lastAddedStackPtr
548
+ ) {
549
+ // This is a bracket, but the owner of it is after the current
550
+ // token, which means it does not belong to any token in
551
+ // our pattern. This means the pattern is not for us.
552
+ return false;
553
+ }
554
+ }//end if
555
+
556
+ // If we skipped past some whitespace tokens, then add them
557
+ // to the found string.
558
+ if (($next - $stackPtr) > 0) {
559
+ $hasComment = false;
560
+ for ($j = $stackPtr; $j < $next; $j++) {
561
+ $found .= $tokens[$j]['content'];
562
+ if (isset(PHP_CodeSniffer_Tokens::$commentTokens[$tokens[$j]['code']]) === true) {
563
+ $hasComment = true;
564
+ }
565
+ }
566
+
567
+ // If we are not ignoring comments, this additional
568
+ // whitespace or comment is not allowed. If we are
569
+ // ignoring comments, there needs to be at least one
570
+ // comment for this to be allowed.
571
+ if ($this->ignoreComments === false
572
+ || ($this->ignoreComments === true
573
+ && $hasComment === false)
574
+ ) {
575
+ $hasError = true;
576
+ }
577
+
578
+ // Even when ignoring comments, we are not allowed to include
579
+ // newlines without the pattern specifying them, so
580
+ // everything should be on the same line.
581
+ if ($tokens[$next]['line'] !== $tokens[$stackPtr]['line']) {
582
+ $hasError = true;
583
+ }
584
+ }//end if
585
+
586
+ if ($next !== $lastAddedStackPtr) {
587
+ $found .= $tokens[$next]['content'];
588
+ $lastAddedStackPtr = $next;
589
+ }
590
+
591
+ if (isset($pattern[($i + 1)]) === true
592
+ && $pattern[($i + 1)]['type'] === 'skip'
593
+ ) {
594
+ $stackPtr = $next;
595
+ } else {
596
+ $stackPtr = ($next + 1);
597
+ }
598
+ }//end if
599
+ } else if ($pattern[$i]['type'] === 'skip') {
600
+ if ($pattern[$i]['to'] === 'unknown') {
601
+ $next = $phpcsFile->findNext(
602
+ $pattern[($i + 1)]['token'],
603
+ $stackPtr
604
+ );
605
+
606
+ if ($next === false) {
607
+ // Couldn't find the next token, so we must
608
+ // be using the wrong pattern.
609
+ return false;
610
+ }
611
+
612
+ $found .= '...';
613
+ $stackPtr = $next;
614
+ } else {
615
+ // Find the previous opener.
616
+ $next = $phpcsFile->findPrevious(
617
+ PHP_CodeSniffer_Tokens::$blockOpeners,
618
+ $stackPtr
619
+ );
620
+
621
+ if ($next === false
622
+ || isset($tokens[$next][$pattern[$i]['to']]) === false
623
+ ) {
624
+ // If there was not opener, then we must
625
+ // be using the wrong pattern.
626
+ return false;
627
+ }
628
+
629
+ $found .= '...';
630
+ if ($pattern[$i]['to'] === 'parenthesis_closer') {
631
+ $found .= ')';
632
+ } else {
633
+ $found .= '}';
634
+ }
635
+
636
+ // Skip to the closing token.
637
+ $stackPtr = ($tokens[$next][$pattern[$i]['to']] + 1);
638
+ }//end if
639
+ } else if ($pattern[$i]['type'] === 'string') {
640
+ if ($tokens[$stackPtr]['code'] !== T_STRING) {
641
+ $hasError = true;
642
+ }
643
+
644
+ if ($stackPtr !== $lastAddedStackPtr) {
645
+ $found .= 'abc';
646
+ $lastAddedStackPtr = $stackPtr;
647
+ }
648
+
649
+ $stackPtr++;
650
+ } else if ($pattern[$i]['type'] === 'newline') {
651
+ // Find the next token that contains a newline character.
652
+ $newline = 0;
653
+ for ($j = $stackPtr; $j < $phpcsFile->numTokens; $j++) {
654
+ if (strpos($tokens[$j]['content'], $phpcsFile->eolChar) !== false) {
655
+ $newline = $j;
656
+ break;
657
+ }
658
+ }
659
+
660
+ if ($newline === 0) {
661
+ // We didn't find a newline character in the rest of the file.
662
+ $next = ($phpcsFile->numTokens - 1);
663
+ $hasError = true;
664
+ } else {
665
+ if ($this->ignoreComments === false) {
666
+ // The newline character cannot be part of a comment.
667
+ if (isset(PHP_CodeSniffer_Tokens::$commentTokens[$tokens[$newline]['code']]) === true) {
668
+ $hasError = true;
669
+ }
670
+ }
671
+
672
+ if ($newline === $stackPtr) {
673
+ $next = ($stackPtr + 1);
674
+ } else {
675
+ // Check that there were no significant tokens that we
676
+ // skipped over to find our newline character.
677
+ $next = $phpcsFile->findNext(
678
+ $ignoreTokens,
679
+ $stackPtr,
680
+ null,
681
+ true
682
+ );
683
+
684
+ if ($next < $newline) {
685
+ // We skipped a non-ignored token.
686
+ $hasError = true;
687
+ } else {
688
+ $next = ($newline + 1);
689
+ }
690
+ }
691
+ }//end if
692
+
693
+ if ($stackPtr !== $lastAddedStackPtr) {
694
+ $found .= $phpcsFile->getTokensAsString(
695
+ $stackPtr,
696
+ ($next - $stackPtr)
697
+ );
698
+
699
+ $diff = ($next - $stackPtr);
700
+ $lastAddedStackPtr = ($next - 1);
701
+ }
702
+
703
+ $stackPtr = $next;
704
+ }//end if
705
+ }//end for
706
+
707
+ if ($hasError === true) {
708
+ $error = $this->prepareError($found, $patternCode);
709
+ $errors[$origStackPtr] = $error;
710
+ }
711
+
712
+ return $errors;
713
+
714
+ }//end processPattern()
715
+
716
+
717
+ /**
718
+ * Prepares an error for the specified patternCode.
719
+ *
720
+ * @param string $found The actual found string in the code.
721
+ * @param string $patternCode The expected pattern code.
722
+ *
723
+ * @return string The error message.
724
+ */
725
+ protected function prepareError($found, $patternCode)
726
+ {
727
+ $found = str_replace("\r\n", '\n', $found);
728
+ $found = str_replace("\n", '\n', $found);
729
+ $found = str_replace("\r", '\n', $found);
730
+ $found = str_replace("\t", '\t', $found);
731
+ $found = str_replace('EOL', '\n', $found);
732
+ $expected = str_replace('EOL', '\n', $patternCode);
733
+
734
+ $error = "Expected \"$expected\"; found \"$found\"";
735
+
736
+ return $error;
737
+
738
+ }//end prepareError()
739
+
740
+
741
+ /**
742
+ * Returns the patterns that should be checked.
743
+ *
744
+ * @return string[]
745
+ */
746
+ protected abstract function getPatterns();
747
+
748
+
749
+ /**
750
+ * Registers any supplementary tokens that this test might wish to process.
751
+ *
752
+ * A sniff may wish to register supplementary tests when it wishes to group
753
+ * an arbitrary validation that cannot be performed using a pattern, with
754
+ * other pattern tests.
755
+ *
756
+ * @return int[]
757
+ * @see processSupplementary()
758
+ */
759
+ protected function registerSupplementary()
760
+ {
761
+ return array();
762
+
763
+ }//end registerSupplementary()
764
+
765
+
766
+ /**
767
+ * Processes any tokens registered with registerSupplementary().
768
+ *
769
+ * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where to
770
+ * process the skip.
771
+ * @param int $stackPtr The position in the tokens stack to
772
+ * process.
773
+ *
774
+ * @return void
775
+ * @see registerSupplementary()
776
+ */
777
+ protected function processSupplementary(
778
+ PHP_CodeSniffer_File $phpcsFile,
779
+ $stackPtr
780
+ ) {
781
+
782
+ }//end processSupplementary()
783
+
784
+
785
+ /**
786
+ * Parses a pattern string into an array of pattern steps.
787
+ *
788
+ * @param string $pattern The pattern to parse.
789
+ *
790
+ * @return array The parsed pattern array.
791
+ * @see _createSkipPattern()
792
+ * @see _createTokenPattern()
793
+ */
794
+ private function _parse($pattern)
795
+ {
796
+ $patterns = array();
797
+ $length = strlen($pattern);
798
+ $lastToken = 0;
799
+ $firstToken = 0;
800
+
801
+ for ($i = 0; $i < $length; $i++) {
802
+ $specialPattern = false;
803
+ $isLastChar = ($i === ($length - 1));
804
+ $oldFirstToken = $firstToken;
805
+
806
+ if (substr($pattern, $i, 3) === '...') {
807
+ // It's a skip pattern. The skip pattern requires the
808
+ // content of the token in the "from" position and the token
809
+ // to skip to.
810
+ $specialPattern = $this->_createSkipPattern($pattern, ($i - 1));
811
+ $lastToken = ($i - $firstToken);
812
+ $firstToken = ($i + 3);
813
+ $i = ($i + 2);
814
+
815
+ if ($specialPattern['to'] !== 'unknown') {
816
+ $firstToken++;
817
+ }
818
+ } else if (substr($pattern, $i, 3) === 'abc') {
819
+ $specialPattern = array('type' => 'string');
820
+ $lastToken = ($i - $firstToken);
821
+ $firstToken = ($i + 3);
822
+ $i = ($i + 2);
823
+ } else if (substr($pattern, $i, 3) === 'EOL') {
824
+ $specialPattern = array('type' => 'newline');
825
+ $lastToken = ($i - $firstToken);
826
+ $firstToken = ($i + 3);
827
+ $i = ($i + 2);
828
+ }//end if
829
+
830
+ if ($specialPattern !== false || $isLastChar === true) {
831
+ // If we are at the end of the string, don't worry about a limit.
832
+ if ($isLastChar === true) {
833
+ // Get the string from the end of the last skip pattern, if any,
834
+ // to the end of the pattern string.
835
+ $str = substr($pattern, $oldFirstToken);
836
+ } else {
837
+ // Get the string from the end of the last special pattern,
838
+ // if any, to the start of this special pattern.
839
+ if ($lastToken === 0) {
840
+ // Note that if the last special token was zero characters ago,
841
+ // there will be nothing to process so we can skip this bit.
842
+ // This happens if you have something like: EOL... in your pattern.
843
+ $str = '';
844
+ } else {
845
+ $str = substr($pattern, $oldFirstToken, $lastToken);
846
+ }
847
+ }
848
+
849
+ if ($str !== '') {
850
+ $tokenPatterns = $this->_createTokenPattern($str);
851
+ foreach ($tokenPatterns as $tokenPattern) {
852
+ $patterns[] = $tokenPattern;
853
+ }
854
+ }
855
+
856
+ // Make sure we don't skip the last token.
857
+ if ($isLastChar === false && $i === ($length - 1)) {
858
+ $i--;
859
+ }
860
+ }//end if
861
+
862
+ // Add the skip pattern *after* we have processed
863
+ // all the tokens from the end of the last skip pattern
864
+ // to the start of this skip pattern.
865
+ if ($specialPattern !== false) {
866
+ $patterns[] = $specialPattern;
867
+ }
868
+ }//end for
869
+
870
+ return $patterns;
871
+
872
+ }//end _parse()
873
+
874
+
875
+ /**
876
+ * Creates a skip pattern.
877
+ *
878
+ * @param string $pattern The pattern being parsed.
879
+ * @param string $from The token content that the skip pattern starts from.
880
+ *
881
+ * @return array The pattern step.
882
+ * @see _createTokenPattern()
883
+ * @see _parse()
884
+ */
885
+ private function _createSkipPattern($pattern, $from)
886
+ {
887
+ $skip = array('type' => 'skip');
888
+
889
+ $nestedParenthesis = 0;
890
+ $nestedBraces = 0;
891
+ for ($start = $from; $start >= 0; $start--) {
892
+ switch ($pattern[$start]) {
893
+ case '(':
894
+ if ($nestedParenthesis === 0) {
895
+ $skip['to'] = 'parenthesis_closer';
896
+ }
897
+
898
+ $nestedParenthesis--;
899
+ break;
900
+ case '{':
901
+ if ($nestedBraces === 0) {
902
+ $skip['to'] = 'scope_closer';
903
+ }
904
+
905
+ $nestedBraces--;
906
+ break;
907
+ case '}':
908
+ $nestedBraces++;
909
+ break;
910
+ case ')':
911
+ $nestedParenthesis++;
912
+ break;
913
+ }//end switch
914
+
915
+ if (isset($skip['to']) === true) {
916
+ break;
917
+ }
918
+ }//end for
919
+
920
+ if (isset($skip['to']) === false) {
921
+ $skip['to'] = 'unknown';
922
+ }
923
+
924
+ return $skip;
925
+
926
+ }//end _createSkipPattern()
927
+
928
+
929
+ /**
930
+ * Creates a token pattern.
931
+ *
932
+ * @param string $str The tokens string that the pattern should match.
933
+ *
934
+ * @return array The pattern step.
935
+ * @see _createSkipPattern()
936
+ * @see _parse()
937
+ */
938
+ private function _createTokenPattern($str)
939
+ {
940
+ // Don't add a space after the closing php tag as it will add a new
941
+ // whitespace token.
942
+ $tokenizer = new PHP_CodeSniffer_Tokenizers_PHP();
943
+ $tokens = $tokenizer->tokenizeString('<?php '.$str.'?>');
944
+
945
+ // Remove the <?php tag from the front and the end php tag from the back.
946
+ $tokens = array_slice($tokens, 1, (count($tokens) - 2));
947
+
948
+ $patterns = array();
949
+ foreach ($tokens as $patternInfo) {
950
+ $patterns[] = array(
951
+ 'type' => 'token',
952
+ 'token' => $patternInfo['code'],
953
+ 'value' => $patternInfo['content'],
954
+ );
955
+ }
956
+
957
+ return $patterns;
958
+
959
+ }//end _createTokenPattern()
960
+
961
+
962
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractScopeSniff.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * An AbstractScopeTest allows for tests that extend from this class to
4
+ * listen for tokens within a particular scope.
5
+ *
6
+ * PHP version 5
7
+ *
8
+ * @category PHP
9
+ * @package PHP_CodeSniffer
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @author Marc McIntyre <mmcintyre@squiz.net>
12
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
13
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
14
+ * @link http://pear.php.net/package/PHP_CodeSniffer
15
+ */
16
+
17
+ /**
18
+ * An AbstractScopeTest allows for tests that extend from this class to
19
+ * listen for tokens within a particular scope.
20
+ *
21
+ * Below is a test that listens to methods that exist only within classes:
22
+ * <code>
23
+ * class ClassScopeTest extends PHP_CodeSniffer_Standards_AbstractScopeSniff
24
+ * {
25
+ * public function __construct()
26
+ * {
27
+ * parent::__construct(array(T_CLASS), array(T_FUNCTION));
28
+ * }
29
+ *
30
+ * protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $)
31
+ * {
32
+ * $className = $phpcsFile->getDeclarationName($currScope);
33
+ * echo 'encountered a method within class '.$className;
34
+ * }
35
+ * }
36
+ * </code>
37
+ *
38
+ * @category PHP
39
+ * @package PHP_CodeSniffer
40
+ * @author Greg Sherwood <gsherwood@squiz.net>
41
+ * @author Marc McIntyre <mmcintyre@squiz.net>
42
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
43
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
44
+ * @version Release: @package_version@
45
+ * @link http://pear.php.net/package/PHP_CodeSniffer
46
+ */
47
+ abstract class PHP_CodeSniffer_Standards_AbstractScopeSniff implements PHP_CodeSniffer_Sniff
48
+ {
49
+
50
+ /**
51
+ * The token types that this test wishes to listen to within the scope.
52
+ *
53
+ * @var array
54
+ */
55
+ private $_tokens = array();
56
+
57
+ /**
58
+ * The type of scope opener tokens that this test wishes to listen to.
59
+ *
60
+ * @var string
61
+ */
62
+ private $_scopeTokens = array();
63
+
64
+ /**
65
+ * True if this test should fire on tokens outside of the scope.
66
+ *
67
+ * @var boolean
68
+ */
69
+ private $_listenOutside = false;
70
+
71
+
72
+ /**
73
+ * Constructs a new AbstractScopeTest.
74
+ *
75
+ * @param array $scopeTokens The type of scope the test wishes to listen to.
76
+ * @param array $tokens The tokens that the test wishes to listen to
77
+ * within the scope.
78
+ * @param boolean $listenOutside If true this test will also alert the
79
+ * extending class when a token is found outside
80
+ * the scope, by calling the
81
+ * processTokenOutsideScope method.
82
+ *
83
+ * @see PHP_CodeSniffer.getValidScopeTokeners()
84
+ * @throws PHP_CodeSniffer_Exception If the specified tokens array is empty.
85
+ */
86
+ public function __construct(
87
+ array $scopeTokens,
88
+ array $tokens,
89
+ $listenOutside=false
90
+ ) {
91
+ if (empty($scopeTokens) === true) {
92
+ $error = 'The scope tokens list cannot be empty';
93
+ throw new PHP_CodeSniffer_Exception($error);
94
+ }
95
+
96
+ if (empty($tokens) === true) {
97
+ $error = 'The tokens list cannot be empty';
98
+ throw new PHP_CodeSniffer_Exception($error);
99
+ }
100
+
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
+
108
+ $this->_listenOutside = $listenOutside;
109
+ $this->_scopeTokens = array_flip($scopeTokens);
110
+ $this->_tokens = $tokens;
111
+
112
+ }//end __construct()
113
+
114
+
115
+ /**
116
+ * The method that is called to register the tokens this test wishes to
117
+ * listen to.
118
+ *
119
+ * DO NOT OVERRIDE THIS METHOD. Use the constructor of this class to register
120
+ * for the desired tokens and scope.
121
+ *
122
+ * @return int[]
123
+ * @see __constructor()
124
+ */
125
+ public final function register()
126
+ {
127
+ return $this->_tokens;
128
+
129
+ }//end register()
130
+
131
+
132
+ /**
133
+ * Processes the tokens that this test is listening for.
134
+ *
135
+ * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
136
+ * @param int $stackPtr The position in the stack where this
137
+ * token was found.
138
+ *
139
+ * @return void
140
+ * @see processTokenWithinScope()
141
+ */
142
+ public final function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
143
+ {
144
+ $tokens = $phpcsFile->getTokens();
145
+
146
+ $foundScope = false;
147
+ foreach ($tokens[$stackPtr]['conditions'] as $scope => $code) {
148
+ if (isset($this->_scopeTokens[$code]) === true) {
149
+ $this->processTokenWithinScope($phpcsFile, $stackPtr, $scope);
150
+ $foundScope = true;
151
+ }
152
+ }
153
+
154
+ if ($this->_listenOutside === true && $foundScope === false) {
155
+ $this->processTokenOutsideScope($phpcsFile, $stackPtr);
156
+ }
157
+
158
+ }//end process()
159
+
160
+
161
+ /**
162
+ * Processes a token that is found within the scope that this test is
163
+ * listening to.
164
+ *
165
+ * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
166
+ * @param int $stackPtr The position in the stack where this
167
+ * token was found.
168
+ * @param int $currScope The position in the tokens array that
169
+ * opened the scope that this test is
170
+ * listening for.
171
+ *
172
+ * @return void
173
+ */
174
+ protected abstract function processTokenWithinScope(
175
+ PHP_CodeSniffer_File $phpcsFile,
176
+ $stackPtr,
177
+ $currScope
178
+ );
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.
186
+ * @param int $stackPtr The position in the stack where this
187
+ * token was found.
188
+ *
189
+ * @return void
190
+ */
191
+ protected function processTokenOutsideScope(
192
+ PHP_CodeSniffer_File $phpcsFile,
193
+ $stackPtr
194
+ ) {
195
+
196
+ }//end processTokenOutsideScope()
197
+
198
+
199
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/AbstractVariableSniff.php ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * A class to find T_VARIABLE tokens.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) {
17
+ $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found';
18
+ throw new PHP_CodeSniffer_Exception($error);
19
+ }
20
+
21
+ /**
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.
29
+ *
30
+ * @category PHP
31
+ * @package PHP_CodeSniffer
32
+ * @author Greg Sherwood <gsherwood@squiz.net>
33
+ * @author Marc McIntyre <mmcintyre@squiz.net>
34
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
35
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
36
+ * @version Release: @package_version@
37
+ * @link http://pear.php.net/package/PHP_CodeSniffer
38
+ */
39
+ abstract class PHP_CodeSniffer_Standards_AbstractVariableSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff
40
+ {
41
+
42
+ /**
43
+ * The end token of the current function that we are in.
44
+ *
45
+ * @var int
46
+ */
47
+ private $_endFunction = -1;
48
+
49
+ /**
50
+ * TRUE if a function is currently open.
51
+ *
52
+ * @var boolean
53
+ */
54
+ private $_functionOpen = false;
55
+
56
+ /**
57
+ * The current PHP_CodeSniffer file that we are processing.
58
+ *
59
+ * @var PHP_CodeSniffer_File
60
+ */
61
+ protected $currentFile = null;
62
+
63
+
64
+ /**
65
+ * Constructs an AbstractVariableTest.
66
+ */
67
+ public function __construct()
68
+ {
69
+ $scopes = array(
70
+ T_CLASS,
71
+ T_ANON_CLASS,
72
+ T_TRAIT,
73
+ T_INTERFACE,
74
+ );
75
+
76
+ $listen = array(
77
+ T_FUNCTION,
78
+ T_VARIABLE,
79
+ T_DOUBLE_QUOTED_STRING,
80
+ T_HEREDOC,
81
+ );
82
+
83
+ parent::__construct($scopes, $listen, true);
84
+
85
+ }//end __construct()
86
+
87
+
88
+ /**
89
+ * Processes the token in the specified PHP_CodeSniffer_File.
90
+ *
91
+ * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this
92
+ * token was found.
93
+ * @param int $stackPtr The position where the token was found.
94
+ * @param array $currScope The current scope opener token.
95
+ *
96
+ * @return void
97
+ */
98
+ protected final function processTokenWithinScope(
99
+ PHP_CodeSniffer_File $phpcsFile,
100
+ $stackPtr,
101
+ $currScope
102
+ ) {
103
+ if ($this->currentFile !== $phpcsFile) {
104
+ $this->currentFile = $phpcsFile;
105
+ $this->_functionOpen = false;
106
+ $this->_endFunction = -1;
107
+ }
108
+
109
+ $tokens = $phpcsFile->getTokens();
110
+
111
+ if ($stackPtr > $this->_endFunction) {
112
+ $this->_functionOpen = false;
113
+ }
114
+
115
+ if ($tokens[$stackPtr]['code'] === T_FUNCTION
116
+ && $this->_functionOpen === false
117
+ ) {
118
+ $this->_functionOpen = true;
119
+
120
+ $methodProps = $phpcsFile->getMethodProperties($stackPtr);
121
+
122
+ // If the function is abstract, or is in an interface,
123
+ // then set the end of the function to it's closing semicolon.
124
+ if ($methodProps['is_abstract'] === true
125
+ || $tokens[$currScope]['code'] === T_INTERFACE
126
+ ) {
127
+ $this->_endFunction
128
+ = $phpcsFile->findNext(array(T_SEMICOLON), $stackPtr);
129
+ } else {
130
+ if (isset($tokens[$stackPtr]['scope_closer']) === false) {
131
+ $error = 'Possible parse error: non-abstract method defined as abstract';
132
+ $phpcsFile->addWarning($error, $stackPtr);
133
+ return;
134
+ }
135
+
136
+ $this->_endFunction = $tokens[$stackPtr]['scope_closer'];
137
+ }
138
+ }//end if
139
+
140
+ if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING
141
+ || $tokens[$stackPtr]['code'] === T_HEREDOC
142
+ ) {
143
+ // Check to see if this string has a variable in it.
144
+ $pattern = '|(?<!\\\\)(?:\\\\{2})*\${?[a-zA-Z0-9_]+}?|';
145
+ if (preg_match($pattern, $tokens[$stackPtr]['content']) !== 0) {
146
+ $this->processVariableInString($phpcsFile, $stackPtr);
147
+ }
148
+
149
+ return;
150
+ }
151
+
152
+ if ($this->_functionOpen === true) {
153
+ if ($tokens[$stackPtr]['code'] === T_VARIABLE) {
154
+ $this->processVariable($phpcsFile, $stackPtr);
155
+ }
156
+ } else {
157
+ // What if we assign a member variable to another?
158
+ // ie. private $_count = $this->_otherCount + 1;.
159
+ $this->processMemberVar($phpcsFile, $stackPtr);
160
+ }
161
+
162
+ }//end processTokenWithinScope()
163
+
164
+
165
+ /**
166
+ * Processes the token outside the scope in the file.
167
+ *
168
+ * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this
169
+ * token was found.
170
+ * @param int $stackPtr The position where the token was found.
171
+ *
172
+ * @return void
173
+ */
174
+ protected final function processTokenOutsideScope(
175
+ PHP_CodeSniffer_File $phpcsFile,
176
+ $stackPtr
177
+ ) {
178
+ $tokens = $phpcsFile->getTokens();
179
+ // These variables are not member vars.
180
+ if ($tokens[$stackPtr]['code'] === T_VARIABLE) {
181
+ $this->processVariable($phpcsFile, $stackPtr);
182
+ } else if ($tokens[$stackPtr]['code'] === T_DOUBLE_QUOTED_STRING
183
+ || $tokens[$stackPtr]['code'] === T_HEREDOC
184
+ ) {
185
+ // Check to see if this string has a variable in it.
186
+ $pattern = '|(?<!\\\\)(?:\\\\{2})*\${?[a-zA-Z0-9_]+}?|';
187
+ if (preg_match($pattern, $tokens[$stackPtr]['content']) !== 0) {
188
+ $this->processVariableInString($phpcsFile, $stackPtr);
189
+ }
190
+ }
191
+
192
+ }//end processTokenOutsideScope()
193
+
194
+
195
+ /**
196
+ * Called to process class member vars.
197
+ *
198
+ * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this
199
+ * token was found.
200
+ * @param int $stackPtr The position where the token was found.
201
+ *
202
+ * @return void
203
+ */
204
+ abstract protected function processMemberVar(
205
+ PHP_CodeSniffer_File $phpcsFile,
206
+ $stackPtr
207
+ );
208
+
209
+
210
+ /**
211
+ * Called to process normal member vars.
212
+ *
213
+ * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this
214
+ * token was found.
215
+ * @param int $stackPtr The position where the token was found.
216
+ *
217
+ * @return void
218
+ */
219
+ abstract protected function processVariable(
220
+ PHP_CodeSniffer_File $phpcsFile,
221
+ $stackPtr
222
+ );
223
+
224
+
225
+ /**
226
+ * Called to process variables found in double quoted strings or heredocs.
227
+ *
228
+ * Note that there may be more than one variable in the string, which will
229
+ * result only in one call for the string or one call per line for heredocs.
230
+ *
231
+ * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where this
232
+ * token was found.
233
+ * @param int $stackPtr The position where the double quoted
234
+ * string was found.
235
+ *
236
+ * @return void
237
+ */
238
+ abstract protected function processVariableInString(
239
+ PHP_CodeSniffer_File
240
+ $phpcsFile,
241
+ $stackPtr
242
+ );
243
+
244
+
245
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Classes/DuplicateClassNameStandard.xml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Duplicate Class Names">
2
+ <standard>
3
+ <![CDATA[
4
+ Class and Interface names should be unique in a project. They should never be duplicated.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A unique class name.">
9
+ <![CDATA[
10
+ class <em>Foo</em>
11
+ {
12
+ }
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: A class duplicated (including across multiple files).">
16
+ <![CDATA[
17
+ class <em>Foo</em>
18
+ {
19
+ }
20
+
21
+ class <em>Foo</em>
22
+ {
23
+ }
24
+ ]]>
25
+ </code>
26
+ </code_comparison>
27
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Classes/OpeningBraceSameLineStandard.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Opening Brace on Same Line">
2
+ <standard>
3
+ <![CDATA[
4
+ The opening brace of a class must be on the same line after the definition and must be the last thing on that line.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Opening brace on the same line.">
9
+ <![CDATA[
10
+ class Foo <em>{</em>
11
+ }
12
+ ]]>
13
+ </code>
14
+ <code title="Invalid: Opening brace on the next line.">
15
+ <![CDATA[
16
+ class Foo
17
+ <em>{</em>
18
+ }
19
+ ]]>
20
+ </code>
21
+ <code title="Invalid: Opening brace not last thing on the line.">
22
+ <![CDATA[
23
+ class Foo {<em> // Start of class.</em>
24
+ }
25
+ ]]>
26
+ </code>
27
+ </code_comparison>
28
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/EmptyStatementStandard.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Empty Statements">
2
+ <standard>
3
+ <![CDATA[
4
+ Control Structures must have at least one statement inside of the body.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: There is a statement inside the control structure.">
9
+ <![CDATA[
10
+ if ($test) {
11
+ $var = 1;
12
+ }
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: The control structure has no statements.">
16
+ <![CDATA[
17
+ if ($test) {
18
+ <em>// do nothing</em>
19
+ }
20
+ ]]>
21
+ </code>
22
+ </code_comparison>
23
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/ForLoopShouldBeWhileLoopStandard.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Condition-Only For Loops">
2
+ <standard>
3
+ <![CDATA[
4
+ For loops that have only a second expression (the condition) should be converted to while loops.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A for loop is used with all three expressions.">
9
+ <![CDATA[
10
+ for (<em>$i = 0</em>; $i < 10; <em>$i++</em>) {
11
+ echo "{$i}\n";
12
+ }
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: A for loop is used without a first or third expression.">
16
+ <![CDATA[
17
+ for (<em></em>;$test;<em></em>) {
18
+ $test = doSomething();
19
+ }
20
+ ]]>
21
+ </code>
22
+ </code_comparison>
23
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/ForLoopWithTestFunctionCallStandard.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="For Loops With Function Calls in the Test">
2
+ <standard>
3
+ <![CDATA[
4
+ For loops should not call functions inside the test for the loop when they can be computed beforehand.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A for loop that determines its end condition before the loop starts.">
9
+ <![CDATA[
10
+ <em>$end = count($foo);</em>
11
+ for ($i = 0; $i < $end; $i++) {
12
+ echo $foo[$i]."\n";
13
+ }
14
+ ]]>
15
+ </code>
16
+ <code title="Invalid: A for loop that unnecessarily computes the same value on every iteration.">
17
+ <![CDATA[
18
+ for ($i = 0; $i < <em>count($foo)</em>; $i++) {
19
+ echo $foo[$i]."\n";
20
+ }
21
+ ]]>
22
+ </code>
23
+ </code_comparison>
24
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/JumbledIncrementerStandard.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Jumbled Incrementers">
2
+ <standard>
3
+ <![CDATA[
4
+ Incrementers in nested loops should use different variable names.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Two different variables being used to increment.">
9
+ <![CDATA[
10
+ for ($i = 0; $i < 10; <em>$i++</em>) {
11
+ for ($j = 0; $j < 10; <em>$j++</em>) {
12
+ }
13
+ }
14
+ ]]>
15
+ </code>
16
+ <code title="Invalid: Inner incrementer is the same variable name as the outer one.">
17
+ <![CDATA[
18
+ for ($i = 0; $i < 10; <em>$i++</em>) {
19
+ for ($j = 0; $j < 10; <em>$i++</em>) {
20
+ }
21
+ }
22
+ ]]>
23
+ </code>
24
+ </code_comparison>
25
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/UnconditionalIfStatementStandard.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Unconditional If Statements">
2
+ <standard>
3
+ <![CDATA[
4
+ If statements that are always evaluated should not be used.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: An if statement that only executes conditionally.">
9
+ <![CDATA[
10
+ if (<em>$test</em>) {
11
+ $var = 1;
12
+ }
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: An if statement that is always performed.">
16
+ <![CDATA[
17
+ if (<em>true</em>) {
18
+ $var = 1;
19
+ }
20
+ ]]>
21
+ </code>
22
+ </code_comparison>
23
+ <code_comparison>
24
+ <code title="Valid: An if statement that only executes conditionally.">
25
+ <![CDATA[
26
+ if (<em>$test</em>) {
27
+ $var = 1;
28
+ }
29
+ ]]>
30
+ </code>
31
+ <code title="Invalid: An if statement that is never performed.">
32
+ <![CDATA[
33
+ if (<em>false</em>) {
34
+ $var = 1;
35
+ }
36
+ ]]>
37
+ </code>
38
+ </code_comparison>
39
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/UnnecessaryFinalModifierStandard.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Unnecessary Final Modifiers">
2
+ <standard>
3
+ <![CDATA[
4
+ Methods should not be declared final inside of classes that are declared final.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A method in a final class is not marked final.">
9
+ <![CDATA[
10
+ final class Foo
11
+ {
12
+ public function bar()
13
+ {
14
+ }
15
+ }
16
+ ]]>
17
+ </code>
18
+ <code title="Invalid: A method in a final class is also marked final.">
19
+ <![CDATA[
20
+ final class Foo
21
+ {
22
+ public <em>final</em> function bar()
23
+ {
24
+ }
25
+ }
26
+ ]]>
27
+ </code>
28
+ </code_comparison>
29
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/UnusedFunctionParameterStandard.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Unused function parameters">
2
+ <standard>
3
+ <![CDATA[
4
+ All parameters in a functions signature should be used within the function.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: All the parameters are used.">
9
+ <![CDATA[
10
+ function addThree($a, $b, $c)
11
+ {
12
+ return <em>$a + $b + $c</em>;
13
+ }
14
+ ]]>
15
+ </code>
16
+ <code title="Invalid: One of the parameters is not being used.">
17
+ <![CDATA[
18
+ function addThree($a, $b, $c)
19
+ {
20
+ return <em>$a + $b</em>;
21
+ }
22
+ ]]>
23
+ </code>
24
+ </code_comparison>
25
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/CodeAnalysis/UselessOverridingMethodStandard.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Useless Overriding Methods">
2
+ <standard>
3
+ <![CDATA[
4
+ Methods should not be defined that only call the parent method.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A method that extends functionality on a parent method.">
9
+ <![CDATA[
10
+ final class Foo
11
+ {
12
+ public function bar()
13
+ {
14
+ parent::bar();
15
+ <em>$this->doSomethingElse();</em>
16
+ }
17
+ }
18
+ ]]>
19
+ </code>
20
+ <code title="Invalid: An overriding method that only calls the parent.">
21
+ <![CDATA[
22
+ final class Foo
23
+ {
24
+ public function bar()
25
+ {
26
+ <em>parent::bar();</em>
27
+ }
28
+ }
29
+ ]]>
30
+ </code>
31
+ </code_comparison>
32
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Commenting/FixmeStandard.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Todo Comments">
2
+ <standard>
3
+ <![CDATA[
4
+ FIXME Statements should be taken care of.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A comment without a fixme.">
9
+ <![CDATA[
10
+ // <em>Handle strange case</em>
11
+ if ($test) {
12
+ $var = 1;
13
+ }
14
+ ]]>
15
+ </code>
16
+ <code title="Invalid: A fixme comment.">
17
+ <![CDATA[
18
+ // <em>FIXME</em>: This needs to be fixed!
19
+ if ($test) {
20
+ $var = 1;
21
+ }
22
+ ]]>
23
+ </code>
24
+ </code_comparison>
25
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Commenting/TodoStandard.xml ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Todo Comments">
2
+ <standard>
3
+ <![CDATA[
4
+ TODO Statements should be taken care of.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A comment without a todo.">
9
+ <![CDATA[
10
+ // <em>Handle strange case</em>
11
+ if ($test) {
12
+ $var = 1;
13
+ }
14
+ ]]>
15
+ </code>
16
+ <code title="Invalid: A todo comment.">
17
+ <![CDATA[
18
+ // <em>TODO</em>: This needs to be fixed!
19
+ if ($test) {
20
+ $var = 1;
21
+ }
22
+ ]]>
23
+ </code>
24
+ </code_comparison>
25
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/ControlStructures/InlineControlStructureStandard.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Inline Control Structures">
2
+ <standard>
3
+ <![CDATA[
4
+ Control Structures should use braces.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Braces are used around the control structure.">
9
+ <![CDATA[
10
+ if ($test) <em>{</em>
11
+ $var = 1;
12
+ <em>}</em>
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: No braces are used for the control structure..">
16
+ <![CDATA[
17
+ if ($test)
18
+ $var = 1;
19
+ ]]>
20
+ </code>
21
+ </code_comparison>
22
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Debug/CSSLintStandard.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="CSSLint">
2
+ <standard>
3
+ <![CDATA[
4
+ All css files should pass the basic csslint tests.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Valid CSS Syntax is used.">
9
+ <![CDATA[
10
+ .foo: { width: 100<em></em>%; }
11
+ ]]>
12
+ </code>
13
+ <code title="Invalid: The CSS has a typo in it.">
14
+ <![CDATA[
15
+ .foo: { width: 100<em> </em>%; }
16
+ ]]>
17
+ </code>
18
+ </code_comparison>
19
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Debug/ClosureLinterStandard.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Closure Linter">
2
+ <standard>
3
+ <![CDATA[
4
+ All javascript files should pass basic Closure Linter tests.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Valid JS Syntax is used.">
9
+ <![CDATA[
10
+ var foo = [1, 2<em></em>];
11
+ ]]>
12
+ </code>
13
+ <code title="Invalid: Trailing comma in a javascript array.">
14
+ <![CDATA[
15
+ var foo = [1, 2<em>,</em>];
16
+ ]]>
17
+ </code>
18
+ </code_comparison>
19
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Debug/JSHintStandard.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="JSHint">
2
+ <standard>
3
+ <![CDATA[
4
+ All javascript files should pass basic JSHint tests.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Valid JS Syntax is used.">
9
+ <![CDATA[
10
+ <em>var</em> foo = 5;
11
+ ]]>
12
+ </code>
13
+ <code title="Invalid: The Javascript is using an undefined variable.">
14
+ <![CDATA[
15
+ <em></em>foo = 5;
16
+ ]]>
17
+ </code>
18
+ </code_comparison>
19
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/ByteOrderMarkStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="Byte Order Marks">
2
+ <standard>
3
+ <![CDATA[
4
+ Byte Order Marks that may corrupt your application should not be used. These include 0xefbbbf (UTF-8), 0xfeff (UTF-16 BE) and 0xfffe (UTF-16 LE).
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/EndFileNewlineStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="End of File Newline">
2
+ <standard>
3
+ <![CDATA[
4
+ Files should end with a newline character.
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/EndFileNoNewlineStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="No End of File Newline">
2
+ <standard>
3
+ <![CDATA[
4
+ Files should not end with a newline character.
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/InlineHTMLStandard.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Inline HTML">
2
+ <standard>
3
+ <![CDATA[
4
+ Files that contain php code should only have php code and should not have any "inline html".
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A php file with only php code in it.">
9
+ <![CDATA[
10
+ <?php
11
+ $foo = 'bar';
12
+ echo $foo . 'baz';
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: A php file with html in it outside of the php tags.">
16
+ <![CDATA[
17
+ <em>some string here</em>
18
+ <?php
19
+ $foo = 'bar';
20
+ echo $foo . 'baz';
21
+ ]]>
22
+ </code>
23
+ </code_comparison>
24
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/LineEndingsStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="Line Endings">
2
+ <standard>
3
+ <![CDATA[
4
+ Unix-style line endings are preferred ("\n" instead of "\r\n").
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/LineLengthStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="Line Length">
2
+ <standard>
3
+ <![CDATA[
4
+ It is recommended to keep lines at approximately 80 characters long for better code readability.
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/LowercasedFilenameStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="Lowercased Filenames">
2
+ <standard>
3
+ <![CDATA[
4
+ Lowercase filenames are required.
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/OneClassPerFileStandard.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="One Class Per File">
2
+ <standard>
3
+ <![CDATA[
4
+ There should only be one class defined in a file.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Only one class in the file.">
9
+ <![CDATA[
10
+ <?php
11
+ <em>class Foo</em>
12
+ {
13
+ }
14
+ ]]>
15
+ </code>
16
+ <code title="Invalid: Multiple classes defined in one file.">
17
+ <![CDATA[
18
+ <?php
19
+ <em>class Foo</em>
20
+ {
21
+ }
22
+
23
+ <em>class Bar</em>
24
+ {
25
+ }
26
+ ]]>
27
+ </code>
28
+ </code_comparison>
29
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Files/OneInterfacePerFileStandard.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="One Interface Per File">
2
+ <standard>
3
+ <![CDATA[
4
+ There should only be one interface defined in a file.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Only one interface in the file.">
9
+ <![CDATA[
10
+ <?php
11
+ <em>interface Foo</em>
12
+ {
13
+ }
14
+ ]]>
15
+ </code>
16
+ <code title="Invalid: Multiple interfaces defined in one file.">
17
+ <![CDATA[
18
+ <?php
19
+ <em>interface Foo</em>
20
+ {
21
+ }
22
+
23
+ <em>interface Bar</em>
24
+ {
25
+ }
26
+ ]]>
27
+ </code>
28
+ </code_comparison>
29
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Formatting/DisallowMultipleStatementsStandard.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Multiple Statements On a Single Line">
2
+ <standard>
3
+ <![CDATA[
4
+ Multiple statements are not allowed on a single line.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Two statements are spread out on two separate lines.">
9
+ <![CDATA[
10
+ $foo = 1;
11
+ $bar = 2;
12
+ ]]>
13
+ </code>
14
+ <code title="Invalid: Two statements are combined onto one line.">
15
+ <![CDATA[
16
+ $foo = 1; $bar = 2;
17
+ ]]>
18
+ </code>
19
+ </code_comparison>
20
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Formatting/MultipleStatementAlignmentStandard.xml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Aligning Blocks of Assignments">
2
+ <standard>
3
+ <![CDATA[
4
+ There should be one space on either side of an equals sign used to assign a value to a variable. In the case of a block of related assignments, more space may be inserted to promote readability.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Equals signs aligned">
9
+ <![CDATA[
10
+ $shortVar <em>=</em> (1 + 2);
11
+ $veryLongVarName <em>=</em> 'string';
12
+ $var <em>=</em> foo($bar, $baz, $quux);
13
+ ]]>
14
+ </code>
15
+ <code title="Not aligned; harder to read">
16
+ <![CDATA[
17
+ $shortVar <em>=</em> (1 + 2);
18
+ $veryLongVarName <em>=</em> 'string';
19
+ $var <em>=</em> foo($bar, $baz, $quux);
20
+ ]]>
21
+ </code>
22
+ </code_comparison>
23
+ <standard>
24
+ <![CDATA[
25
+ When using plus-equals, minus-equals etc. still ensure the equals signs are aligned to one space after the longest variable name.
26
+ ]]>
27
+ </standard>
28
+ <code_comparison>
29
+ <code title="Equals signs aligned; only one space after longest var name">
30
+ <![CDATA[
31
+ $shortVar <em>+= </em>1;
32
+ $veryLongVarName<em> = </em>1;
33
+ ]]>
34
+ </code>
35
+ <code title="Two spaces after longest var name">
36
+ <![CDATA[
37
+ $shortVar <em> += </em>1;
38
+ $veryLongVarName<em> = </em>1;
39
+ ]]>
40
+ </code>
41
+ </code_comparison>
42
+ <code_comparison>
43
+ <code title="Equals signs aligned">
44
+ <![CDATA[
45
+ $shortVar <em> = </em>1;
46
+ $veryLongVarName<em> -= </em>1;
47
+ ]]>
48
+ </code>
49
+ <code title="Equals signs not aligned">
50
+ <![CDATA[
51
+ $shortVar <em> = </em>1;
52
+ $veryLongVarName<em> -= </em>1;
53
+ ]]>
54
+ </code>
55
+ </code_comparison>
56
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Formatting/NoSpaceAfterCastStandard.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Space After Casts">
2
+ <standard>
3
+ <![CDATA[
4
+ Spaces are not allowed after casting operators.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A cast operator is immediately before its value.">
9
+ <![CDATA[
10
+ $foo = (string)1;
11
+ ]]>
12
+ </code>
13
+ <code title="Invalid: A cast operator is followed by whitespace.">
14
+ <![CDATA[
15
+ $foo = (string)<em> </em>1;
16
+ ]]>
17
+ </code>
18
+ </code_comparison>
19
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Formatting/SpaceAfterCastStandard.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Space After Casts">
2
+ <standard>
3
+ <![CDATA[
4
+ Exactly one space is allowed after a cast.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A cast operator is followed by one space.">
9
+ <![CDATA[
10
+ $foo = (string)<em> </em>1;
11
+ ]]>
12
+ </code>
13
+ <code title="Invalid: A cast operator is not followed by whitespace.">
14
+ <![CDATA[
15
+ $foo = (string)<em></em>1;
16
+ ]]>
17
+ </code>
18
+ </code_comparison>
19
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Functions/CallTimePassByReferenceStandard.xml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Call-Time Pass-By-Reference">
2
+ <standard>
3
+ <![CDATA[
4
+ Call-time pass-by-reference is not allowed. It should be declared in the function definition.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Pass-by-reference is specified in the function definition.">
9
+ <![CDATA[
10
+ function foo(<em>&</em>$bar)
11
+ {
12
+ $bar++;
13
+ }
14
+
15
+ $baz = 1;
16
+ foo($baz);
17
+ ]]>
18
+ </code>
19
+ <code title="Invalid: Pass-by-reference is done in the call to a function.">
20
+ <![CDATA[
21
+ function foo($bar)
22
+ {
23
+ $bar++;
24
+ }
25
+
26
+ $baz = 1;
27
+ foo(<em>&</em>$baz);
28
+ ]]>
29
+ </code>
30
+ </code_comparison>
31
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Functions/FunctionCallArgumentSpacingStandard.xml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Function Argument Spacing">
2
+ <standard>
3
+ <![CDATA[
4
+ Function arguments should have one space after a comma, and single spaces surrounding the equals sign for default values.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Single spaces after a comma.">
9
+ <![CDATA[
10
+ function foo($bar,<em> </em>$baz)
11
+ {
12
+ }
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: No spaces after a comma.">
16
+ <![CDATA[
17
+ function foo($bar,<em></em>$baz)
18
+ {
19
+ }
20
+ ]]>
21
+ </code>
22
+ </code_comparison>
23
+ <code_comparison>
24
+ <code title="Valid: Single spaces around an equals sign in function declaration.">
25
+ <![CDATA[
26
+ function foo($bar, $baz<em> </em>=<em> </em>true)
27
+ {
28
+ }
29
+ ]]>
30
+ </code>
31
+ <code title="Invalid: No spaces around an equals sign in function declaration.">
32
+ <![CDATA[
33
+ function foo($bar, $baz<em></em>=<em></em>true)
34
+ {
35
+ }
36
+ ]]>
37
+ </code>
38
+ </code_comparison>
39
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceBsdAllmanStandard.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Opening Brace in Function Declarations">
2
+ <standard>
3
+ <![CDATA[
4
+ Function declarations follow the "BSD/Allman style". The function brace is on the line following the function declaration and is indented to the same column as the start of the function declaration.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: brace on next line">
9
+ <![CDATA[
10
+ function fooFunction($arg1, $arg2 = '')
11
+ <em>{</em>
12
+ ...
13
+ }
14
+ ]]>
15
+ </code>
16
+ <code title="Invalid: brace on same line">
17
+ <![CDATA[
18
+ function fooFunction($arg1, $arg2 = '') <em>{</em>
19
+ ...
20
+ }
21
+ ]]>
22
+ </code>
23
+ </code_comparison>
24
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Functions/OpeningFunctionBraceKernighanRitchieStandard.xml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Opening Brace in Function Declarations">
2
+ <standard>
3
+ <![CDATA[
4
+ Function declarations follow the "Kernighan/Ritchie style". The function brace is on the same line as the function declaration. One space is required between the closing parenthesis and the brace.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: brace on same line">
9
+ <![CDATA[
10
+ function fooFunction($arg1, $arg2 = '')<em> {</em>
11
+ ...
12
+ }
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: brace on next line">
16
+ <![CDATA[
17
+ function fooFunction($arg1, $arg2 = '')
18
+ <em>{</em>
19
+ ...
20
+ }
21
+ ]]>
22
+ </code>
23
+ </code_comparison>
24
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Metrics/CyclomaticComplexityStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="Cyclomatic Complexity">
2
+ <standard>
3
+ <![CDATA[
4
+ Functions should not have a cyclomatic complexity greater than 20, and should try to stay below a complexity of 10.
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Metrics/NestingLevelStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="Nesting Level">
2
+ <standard>
3
+ <![CDATA[
4
+ Functions should not have a nesting level greater than 10, and should try to stay below 5.
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/NamingConventions/CamelCapsFunctionNameStandard.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="camelCaps Function Names">
2
+ <standard>
3
+ <![CDATA[
4
+ Functions should use camelCaps format for their names. Only PHP's magic methods should use a double underscore prefix.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A function in camelCaps format.">
9
+ <![CDATA[
10
+ function <em>doSomething</em>()
11
+ {
12
+ }
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: A function in snake_case format.">
16
+ <![CDATA[
17
+ function <em>do_something</em>()
18
+ {
19
+ }
20
+ ]]>
21
+ </code>
22
+ </code_comparison>
23
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/NamingConventions/ConstructorNameStandard.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Constructor name">
2
+ <standard>
3
+ <![CDATA[
4
+ Constructors should be named __construct, not after the class.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: The constructor is named __construct.">
9
+ <![CDATA[
10
+ class Foo
11
+ {
12
+ function <em>__construct</em>()
13
+ {
14
+ }
15
+ }
16
+ ]]>
17
+ </code>
18
+ <code title="Invalid: The old style class name constructor is used.">
19
+ <![CDATA[
20
+ class Foo
21
+ {
22
+ function <em>Foo</em>()
23
+ {
24
+ }
25
+ }
26
+ ]]>
27
+ </code>
28
+ </code_comparison>
29
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/NamingConventions/UpperCaseConstantNameStandard.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Constant Names">
2
+ <standard>
3
+ <![CDATA[
4
+ Constants should always be all-uppercase, with underscores to separate words.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: all uppercase">
9
+ <![CDATA[
10
+ define('<em>FOO_CONSTANT</em>', 'foo');
11
+
12
+ class FooClass
13
+ {
14
+ const <em>FOO_CONSTANT</em> = 'foo';
15
+ }
16
+ ]]>
17
+ </code>
18
+ <code title="Invalid: mixed case">
19
+ <![CDATA[
20
+ define('<em>Foo_Constant</em>', 'foo');
21
+
22
+ class FooClass
23
+ {
24
+ const <em>foo_constant</em> = 'foo';
25
+ }
26
+ ]]>
27
+ </code>
28
+ </code_comparison>
29
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/BacktickOperatorStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="Backtick Operator">
2
+ <standard>
3
+ <![CDATA[
4
+ Disallow the use of the backtick operator for execution of shell commands.
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/CharacterBeforePHPOpeningTagStandard.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Opening Tag at Start of File">
2
+ <standard>
3
+ <![CDATA[
4
+ The opening php tag should be the first item in the file.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A file starting with an opening php tag.">
9
+ <![CDATA[
10
+ <em></em><?php
11
+ echo 'Foo';
12
+ ]]>
13
+ </code>
14
+ <code title="Invalid: A file with content before the opening php tag.">
15
+ <![CDATA[
16
+ <em>Beginning content</em>
17
+ <?php
18
+ echo 'Foo';
19
+ ]]>
20
+ </code>
21
+ </code_comparison>
22
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/ClosingPHPTagStandard.xml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Closing PHP Tags">
2
+ <standard>
3
+ <![CDATA[
4
+ All opening php tags should have a corresponding closing tag.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A closing tag paired with it's opening tag.">
9
+ <![CDATA[
10
+ <em><?php</em>
11
+ echo 'Foo';
12
+ <em>?></em>
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: No closing tag paired with the opening tag.">
16
+ <![CDATA[
17
+ <em><?php</em>
18
+ echo 'Foo';
19
+ ]]>
20
+ </code>
21
+ </code_comparison>
22
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/DeprecatedFunctionsStandard.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Deprecated Functions">
2
+ <standard>
3
+ <![CDATA[
4
+ Deprecated functions should not be used.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A non-deprecated function is used.">
9
+ <![CDATA[
10
+ $foo = <em>explode</em>('a', $bar);
11
+ ]]>
12
+ </code>
13
+ <code title="Invalid: A deprecated function is used.">
14
+ <![CDATA[
15
+ $foo = <em>split</em>('a', $bar);
16
+ ]]>
17
+ </code>
18
+ </code_comparison>
19
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/DisallowAlternativePHPTagsStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="Alternative PHP Code Tags">
2
+ <standard>
3
+ <![CDATA[
4
+ Always use <?php ?> to delimit PHP code, do not use the ASP <% %> style tags nor the <script language="php"></script> tags. This is the most portable way to include PHP code on differing operating systems and setups.
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/DisallowShortOpenTagStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="PHP Code Tags">
2
+ <standard>
3
+ <![CDATA[
4
+ Always use <?php ?> to delimit PHP code, not the <? ?> shorthand. This is the most portable way to include PHP code on differing operating systems and setups.
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/ForbiddenFunctionsStandard.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Forbidden Functions">
2
+ <standard>
3
+ <![CDATA[
4
+ The forbidden functions sizeof() and delete() should not be used.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: count() is used in place of sizeof().">
9
+ <![CDATA[
10
+ $foo = <em>count</em>($bar);
11
+ ]]>
12
+ </code>
13
+ <code title="Invalid: sizeof() is used.">
14
+ <![CDATA[
15
+ $foo = <em>sizeof</em>($bar);
16
+ ]]>
17
+ </code>
18
+ </code_comparison>
19
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/LowerCaseConstantStandard.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="PHP Constants">
2
+ <standard>
3
+ <![CDATA[
4
+ The <em>true</em>, <em>false</em> and <em>null</em> constants must always be lowercase.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: lowercase constants">
9
+ <![CDATA[
10
+ if ($var === <em>false</em> || $var === <em>null</em>) {
11
+ $var = <em>true</em>;
12
+ }
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: uppercase constants">
16
+ <![CDATA[
17
+ if ($var === <em>FALSE</em> || $var === <em>NULL</em>) {
18
+ $var = <em>TRUE</em>;
19
+ }
20
+ ]]>
21
+ </code>
22
+ </code_comparison>
23
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/LowerCaseKeywordStandard.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Lowercase Keywords">
2
+ <standard>
3
+ <![CDATA[
4
+ All PHP keywords should be lowercase.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: Lowercase array keyword used.">
9
+ <![CDATA[
10
+ $foo = <em>array</em>();
11
+ ]]>
12
+ </code>
13
+ <code title="Invalid: Non-lowercase array keyword used.">
14
+ <![CDATA[
15
+ $foo = <em>Array</em>();
16
+ ]]>
17
+ </code>
18
+ </code_comparison>
19
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/NoSilencedErrorsStandard.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Silenced Errors">
2
+ <standard>
3
+ <![CDATA[
4
+ Suppressing Errors is not allowed.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: isset() is used to verify that a variable exists before trying to use it.">
9
+ <![CDATA[
10
+ if (<em>isset($foo)</em> && $foo) {
11
+ echo "Hello\n";
12
+ }
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: Errors are suppressed.">
16
+ <![CDATA[
17
+ if (<em>@</em>$foo) {
18
+ echo "Hello\n";
19
+ }
20
+ ]]>
21
+ </code>
22
+ </code_comparison>
23
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/SAPIUsageStandard.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="SAPI Usage">
2
+ <standard>
3
+ <![CDATA[
4
+ The PHP_SAPI constant should be used instead of php_sapi_name().
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: PHP_SAPI is used.">
9
+ <![CDATA[
10
+ if (<em>PHP_SAPI</em> === 'cli') {
11
+ echo "Hello, CLI user.";
12
+ }
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: php_sapi_name() is used.">
16
+ <![CDATA[
17
+ if (<em>php_sapi_name()</em> === 'cli') {
18
+ echo "Hello, CLI user.";
19
+ }
20
+ ]]>
21
+ </code>
22
+ </code_comparison>
23
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/PHP/UpperCaseConstantStandard.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="PHP Constants">
2
+ <standard>
3
+ <![CDATA[
4
+ The <em>true</em>, <em>false</em> and <em>null</em> constants must always be uppercase.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: uppercase constants">
9
+ <![CDATA[
10
+ if ($var === <em>FALSE</em> || $var === <em>NULL</em>) {
11
+ $var = <em>TRUE</em>;
12
+ }
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: lowercase constants">
16
+ <![CDATA[
17
+ if ($var === <em>false</em> || $var === <em>null</em>) {
18
+ $var = <em>true</em>;
19
+ }
20
+ ]]>
21
+ </code>
22
+ </code_comparison>
23
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/Strings/UnnecessaryStringConcatStandard.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Unnecessary String Concatenation">
2
+ <standard>
3
+ <![CDATA[
4
+ Strings should not be concatenated together.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: A string can be concatenated with an expression.">
9
+ <![CDATA[
10
+ echo '5 + 2 = ' . (5 + 2);
11
+ ]]>
12
+ </code>
13
+ <code title="Invalid: Strings should not be concatenated together.">
14
+ <![CDATA[
15
+ echo 'Hello' . ' ' . 'World';
16
+ ]]>
17
+ </code>
18
+ </code_comparison>
19
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/VersionControl/SubversionPropertiesStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="Subversion Properties">
2
+ <standard>
3
+ <![CDATA[
4
+ All php files in a subversion repository should have the svn:keywords property set to 'Author Id Revision' and the svn:eol-style property set to 'native'.
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/WhiteSpace/DisallowSpaceIndentStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="No Space Indentation">
2
+ <standard>
3
+ <![CDATA[
4
+ Tabs should be used for indentation instead of spaces.
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/WhiteSpace/DisallowTabIndentStandard.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <documentation title="No Tab Indentation">
2
+ <standard>
3
+ <![CDATA[
4
+ Spaces should be used for indentation instead of tabs.
5
+ ]]>
6
+ </standard>
7
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Docs/WhiteSpace/ScopeIndentStandard.xml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <documentation title="Scope Indentation">
2
+ <standard>
3
+ <![CDATA[
4
+ Indentation for control structures, classes, and functions should be 4 spaces per level.
5
+ ]]>
6
+ </standard>
7
+ <code_comparison>
8
+ <code title="Valid: 4 spaces are used to indent a control structure.">
9
+ <![CDATA[
10
+ if ($test) {
11
+ <em> </em>$var = 1;
12
+ }
13
+ ]]>
14
+ </code>
15
+ <code title="Invalid: 8 spaces are used to indent a control structure.">
16
+ <![CDATA[
17
+ if ($test) {
18
+ <em> </em>$var = 1;
19
+ }
20
+ ]]>
21
+ </code>
22
+ </code_comparison>
23
+ </documentation>
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Bans the use of the PHP long array syntax.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Bans the use of the PHP long array syntax.
17
+ *
18
+ * @category PHP
19
+ * @package PHP_CodeSniffer
20
+ * @author Greg Sherwood <gsherwood@squiz.net>
21
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
22
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
23
+ * @version Release: @package_version@
24
+ * @link http://pear.php.net/package/PHP_CodeSniffer
25
+ */
26
+ class Generic_Sniffs_Arrays_DisallowLongArraySyntaxSniff implements PHP_CodeSniffer_Sniff
27
+ {
28
+
29
+
30
+ /**
31
+ * Registers the tokens that this sniff wants to listen for.
32
+ *
33
+ * @return int[]
34
+ */
35
+ public function register()
36
+ {
37
+ return array(T_ARRAY);
38
+
39
+ }//end register()
40
+
41
+
42
+ /**
43
+ * Processes this test, when one of its tokens is encountered.
44
+ *
45
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
+ * @param int $stackPtr The position of the current token
47
+ * in the stack passed in $tokens.
48
+ *
49
+ * @return void
50
+ */
51
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
+ {
53
+ $phpcsFile->recordMetric($stackPtr, 'Short array syntax used', 'no');
54
+
55
+ $error = 'Short array syntax must be used to define arrays';
56
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found');
57
+
58
+ if ($fix === true) {
59
+ $tokens = $phpcsFile->getTokens();
60
+ $opener = $tokens[$stackPtr]['parenthesis_opener'];
61
+ $closer = $tokens[$stackPtr]['parenthesis_closer'];
62
+
63
+ $phpcsFile->fixer->beginChangeset();
64
+
65
+ if ($opener === null) {
66
+ $phpcsFile->fixer->replaceToken($stackPtr, '[]');
67
+ } else {
68
+ $phpcsFile->fixer->replaceToken($stackPtr, '');
69
+ $phpcsFile->fixer->replaceToken($opener, '[');
70
+ $phpcsFile->fixer->replaceToken($closer, ']');
71
+ }
72
+
73
+ $phpcsFile->fixer->endChangeset();
74
+ }
75
+
76
+ }//end process()
77
+
78
+
79
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Arrays/DisallowShortArraySyntaxSniff.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Bans the use of the PHP short array syntax.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Bans the use of the PHP short array syntax.
17
+ *
18
+ * @category PHP
19
+ * @package PHP_CodeSniffer
20
+ * @author Greg Sherwood <gsherwood@squiz.net>
21
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
22
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
23
+ * @version Release: @package_version@
24
+ * @link http://pear.php.net/package/PHP_CodeSniffer
25
+ */
26
+ class Generic_Sniffs_Arrays_DisallowShortArraySyntaxSniff implements PHP_CodeSniffer_Sniff
27
+ {
28
+
29
+
30
+ /**
31
+ * Registers the tokens that this sniff wants to listen for.
32
+ *
33
+ * @return int[]
34
+ */
35
+ public function register()
36
+ {
37
+ return array(T_OPEN_SHORT_ARRAY);
38
+
39
+ }//end register()
40
+
41
+
42
+ /**
43
+ * Processes this test, when one of its tokens is encountered.
44
+ *
45
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
+ * @param int $stackPtr The position of the current token
47
+ * in the stack passed in $tokens.
48
+ *
49
+ * @return void
50
+ */
51
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
+ {
53
+ $phpcsFile->recordMetric($stackPtr, 'Short array syntax used', 'yes');
54
+
55
+ $error = 'Short array syntax is not allowed';
56
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found');
57
+
58
+ if ($fix === true) {
59
+ $tokens = $phpcsFile->getTokens();
60
+ $opener = $tokens[$stackPtr]['bracket_opener'];
61
+ $closer = $tokens[$stackPtr]['bracket_closer'];
62
+
63
+ $phpcsFile->fixer->beginChangeset();
64
+ $phpcsFile->fixer->replaceToken($opener, 'array(');
65
+ $phpcsFile->fixer->replaceToken($closer, ')');
66
+ $phpcsFile->fixer->endChangeset();
67
+ }
68
+
69
+ }//end process()
70
+
71
+
72
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Classes/DuplicateClassNameSniff.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Reports errors if the same class or interface name is used in multiple files.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Reports errors if the same class or interface name is used in multiple files.
17
+ *
18
+ * @category PHP
19
+ * @package PHP_CodeSniffer
20
+ * @author Greg Sherwood <gsherwood@squiz.net>
21
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
22
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
23
+ * @version Release: @package_version@
24
+ * @link http://pear.php.net/package/PHP_CodeSniffer
25
+ */
26
+ class Generic_Sniffs_Classes_DuplicateClassNameSniff implements PHP_CodeSniffer_Sniff
27
+ {
28
+
29
+ /**
30
+ * List of classes that have been found during checking.
31
+ *
32
+ * @var array
33
+ */
34
+ protected $foundClasses = array();
35
+
36
+
37
+ /**
38
+ * Registers the tokens that this sniff wants to listen for.
39
+ *
40
+ * @return int[]
41
+ */
42
+ public function register()
43
+ {
44
+ return array(T_OPEN_TAG);
45
+
46
+ }//end register()
47
+
48
+
49
+ /**
50
+ * Processes this test, when one of its tokens is encountered.
51
+ *
52
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
53
+ * @param int $stackPtr The position of the current token
54
+ * in the stack passed in $tokens.
55
+ *
56
+ * @return void
57
+ */
58
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
59
+ {
60
+ $tokens = $phpcsFile->getTokens();
61
+
62
+ $namespace = '';
63
+ $findTokens = array(
64
+ T_CLASS,
65
+ T_INTERFACE,
66
+ T_NAMESPACE,
67
+ T_CLOSE_TAG,
68
+ );
69
+
70
+ $stackPtr = $phpcsFile->findNext($findTokens, ($stackPtr + 1));
71
+ while ($stackPtr !== false) {
72
+ if ($tokens[$stackPtr]['code'] === T_CLOSE_TAG) {
73
+ // We can stop here. The sniff will continue from the next open
74
+ // tag when PHPCS reaches that token, if there is one.
75
+ return;
76
+ }
77
+
78
+ // Keep track of what namespace we are in.
79
+ if ($tokens[$stackPtr]['code'] === T_NAMESPACE) {
80
+ $nsEnd = $phpcsFile->findNext(
81
+ array(
82
+ T_NS_SEPARATOR,
83
+ T_STRING,
84
+ T_WHITESPACE,
85
+ ),
86
+ ($stackPtr + 1),
87
+ null,
88
+ true
89
+ );
90
+
91
+ $namespace = trim($phpcsFile->getTokensAsString(($stackPtr + 1), ($nsEnd - $stackPtr - 1)));
92
+ $stackPtr = $nsEnd;
93
+ } else {
94
+ $nameToken = $phpcsFile->findNext(T_STRING, $stackPtr);
95
+ $name = $tokens[$nameToken]['content'];
96
+ if ($namespace !== '') {
97
+ $name = $namespace.'\\'.$name;
98
+ }
99
+
100
+ $compareName = strtolower($name);
101
+ if (isset($this->foundClasses[$compareName]) === true) {
102
+ $type = strtolower($tokens[$stackPtr]['content']);
103
+ $file = $this->foundClasses[$compareName]['file'];
104
+ $line = $this->foundClasses[$compareName]['line'];
105
+ $error = 'Duplicate %s name "%s" found; first defined in %s on line %s';
106
+ $data = array(
107
+ $type,
108
+ $name,
109
+ $file,
110
+ $line,
111
+ );
112
+ $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
113
+ } else {
114
+ $this->foundClasses[$compareName] = array(
115
+ 'file' => $phpcsFile->getFilename(),
116
+ 'line' => $tokens[$stackPtr]['line'],
117
+ );
118
+ }
119
+ }//end if
120
+
121
+ $stackPtr = $phpcsFile->findNext($findTokens, ($stackPtr + 1));
122
+ }//end while
123
+
124
+ }//end process()
125
+
126
+
127
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Classes/OpeningBraceSameLineSniff.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Classes_OpeningBraceSameLineSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_Classes_OpeningBraceSameLineSniff.
18
+ *
19
+ * Checks that the opening brace of a class or interface is on the same line
20
+ * as the class declaration.
21
+ *
22
+ * Also checks that the brace is the last thing on that line and has precisely one space before it.
23
+ *
24
+ * @category PHP
25
+ * @package PHP_CodeSniffer
26
+ * @author Greg Sherwood <gsherwood@squiz.net>
27
+ * @author Marc McIntyre <mmcintyre@squiz.net>
28
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
29
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
30
+ * @version Release: @package_version@
31
+ * @link http://pear.php.net/package/PHP_CodeSniffer
32
+ */
33
+ class Generic_Sniffs_Classes_OpeningBraceSameLineSniff implements PHP_CodeSniffer_Sniff
34
+ {
35
+
36
+
37
+ /**
38
+ * Returns an array of tokens this test wants to listen for.
39
+ *
40
+ * @return array
41
+ */
42
+ public function register()
43
+ {
44
+ return array(
45
+ T_CLASS,
46
+ T_INTERFACE,
47
+ T_TRAIT,
48
+ );
49
+
50
+ }//end register()
51
+
52
+
53
+ /**
54
+ * Processes this test, when one of its tokens is encountered.
55
+ *
56
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
57
+ * @param int $stackPtr The position of the current token in the
58
+ * stack passed in $tokens.
59
+ *
60
+ * @return void
61
+ */
62
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
63
+ {
64
+ $tokens = $phpcsFile->getTokens();
65
+ $scope_identifier = $phpcsFile->findNext(T_STRING, ($stackPtr + 1));
66
+ $errorData = array(strtolower($tokens[$stackPtr]['content']).' '.$tokens[$scope_identifier]['content']);
67
+
68
+ if (isset($tokens[$stackPtr]['scope_opener']) === false) {
69
+ $error = 'Possible parse error: %s missing opening or closing brace';
70
+ $phpcsFile->addWarning($error, $stackPtr, 'MissingBrace', $errorData);
71
+ return;
72
+ }
73
+
74
+ $openingBrace = $tokens[$stackPtr]['scope_opener'];
75
+
76
+ // Is the brace on the same line as the class/interface/trait declaration ?
77
+ $lastClassLineToken = $phpcsFile->findPrevious(T_WHITESPACE, ($openingBrace - 1), $stackPtr, true);
78
+ $lastClassLine = $tokens[$lastClassLineToken]['line'];
79
+ $braceLine = $tokens[$openingBrace]['line'];
80
+ $lineDifference = ($braceLine - $lastClassLine);
81
+
82
+ if ($lineDifference > 0) {
83
+ $phpcsFile->recordMetric($stackPtr, 'Class opening brace placement', 'new line');
84
+ $error = 'Opening brace should be on the same line as the declaration for %s';
85
+ $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceOnNewLine', $errorData);
86
+ if ($fix === true) {
87
+ $phpcsFile->fixer->beginChangeset();
88
+ $phpcsFile->fixer->addContent($lastClassLineToken, ' {');
89
+ $phpcsFile->fixer->replaceToken($openingBrace, '');
90
+ $phpcsFile->fixer->endChangeset();
91
+ }
92
+ } else {
93
+ $phpcsFile->recordMetric($stackPtr, 'Class opening brace placement', 'same line');
94
+ }
95
+
96
+ // Is the opening brace the last thing on the line ?
97
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($openingBrace + 1), null, true);
98
+ if ($tokens[$next]['line'] === $tokens[$openingBrace]['line']) {
99
+ if ($next === $tokens[$stackPtr]['scope_closer']) {
100
+ // Ignore empty classes.
101
+ return;
102
+ }
103
+
104
+ $error = 'Opening brace must be the last content on the line';
105
+ $fix = $phpcsFile->addFixableError($error, $openingBrace, 'ContentAfterBrace');
106
+ if ($fix === true) {
107
+ $phpcsFile->fixer->addNewline($openingBrace);
108
+ }
109
+ }
110
+
111
+ // Only continue checking if the opening brace looks good.
112
+ if ($lineDifference > 0) {
113
+ return;
114
+ }
115
+
116
+ // Is there precisely one space before the opening brace ?
117
+ if ($tokens[($openingBrace - 1)]['code'] !== T_WHITESPACE) {
118
+ $length = 0;
119
+ } else if ($tokens[($openingBrace - 1)]['content'] === "\t") {
120
+ $length = '\t';
121
+ } else {
122
+ $length = strlen($tokens[($openingBrace - 1)]['content']);
123
+ }
124
+
125
+ if ($length !== 1) {
126
+ $error = 'Expected 1 space before opening brace; found %s';
127
+ $data = array($length);
128
+ $fix = $phpcsFile->addFixableError($error, $openingBrace, 'SpaceBeforeBrace', $data);
129
+ if ($fix === true) {
130
+ if ($length === 0 || $length === '\t') {
131
+ $phpcsFile->fixer->addContentBefore($openingBrace, ' ');
132
+ } else {
133
+ $phpcsFile->fixer->replaceToken(($openingBrace - 1), ' ');
134
+ }
135
+ }
136
+ }
137
+
138
+ }//end process()
139
+
140
+
141
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/EmptyStatementSniff.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of the CodeAnalysis add-on for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * This sniff class detected empty statement.
18
+ *
19
+ * This sniff implements the common algorithm for empty statement body detection.
20
+ * A body is considered as empty if it is completely empty or it only contains
21
+ * whitespace characters and/or comments.
22
+ *
23
+ * <code>
24
+ * stmt {
25
+ * // foo
26
+ * }
27
+ * stmt (conditions) {
28
+ * // foo
29
+ * }
30
+ * </code>
31
+ *
32
+ * @category PHP
33
+ * @package PHP_CodeSniffer
34
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
35
+ * @author Greg Sherwood <gsherwood@squiz.net>
36
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
37
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
38
+ * @version Release: @package_version@
39
+ * @link http://pear.php.net/package/PHP_CodeSniffer
40
+ */
41
+ class Generic_Sniffs_CodeAnalysis_EmptyStatementSniff implements PHP_CodeSniffer_Sniff
42
+ {
43
+
44
+
45
+ /**
46
+ * Registers the tokens that this sniff wants to listen for.
47
+ *
48
+ * @return int[]
49
+ */
50
+ public function register()
51
+ {
52
+ return array(
53
+ T_CATCH,
54
+ T_DO,
55
+ T_ELSE,
56
+ T_ELSEIF,
57
+ T_FOR,
58
+ T_FOREACH,
59
+ T_IF,
60
+ T_SWITCH,
61
+ T_TRY,
62
+ T_WHILE,
63
+ );
64
+
65
+ }//end register()
66
+
67
+
68
+ /**
69
+ * Processes this test, when one of its tokens is encountered.
70
+ *
71
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
72
+ * @param int $stackPtr The position of the current token
73
+ * in the stack passed in $tokens.
74
+ *
75
+ * @return void
76
+ */
77
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
78
+ {
79
+ $tokens = $phpcsFile->getTokens();
80
+ $token = $tokens[$stackPtr];
81
+
82
+ // Skip statements without a body.
83
+ if (isset($token['scope_opener']) === false) {
84
+ return;
85
+ }
86
+
87
+ $next = $phpcsFile->findNext(
88
+ PHP_CodeSniffer_Tokens::$emptyTokens,
89
+ ($token['scope_opener'] + 1),
90
+ ($token['scope_closer'] - 1),
91
+ true
92
+ );
93
+
94
+ if ($next !== false) {
95
+ return;
96
+ }
97
+
98
+ // Get token identifier.
99
+ $name = strtoupper($token['content']);
100
+ $error = 'Empty %s statement detected';
101
+ $phpcsFile->addError($error, $stackPtr, 'Detected'.$name, array($name));
102
+
103
+ }//end process()
104
+
105
+
106
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopShouldBeWhileLoopSniff.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of the CodeAnalysis add-on for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
11
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
12
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Detects for-loops that can be simplified to a while-loop.
18
+ *
19
+ * This rule is based on the PMD rule catalog. Detects for-loops that can be
20
+ * simplified as a while-loop.
21
+ *
22
+ * <code>
23
+ * class Foo
24
+ * {
25
+ * public function bar($x)
26
+ * {
27
+ * for (;true;) true; // No Init or Update part, may as well be: while (true)
28
+ * }
29
+ * }
30
+ * </code>
31
+ *
32
+ * @category PHP
33
+ * @package PHP_CodeSniffer
34
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
35
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
36
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
37
+ * @version Release: @package_version@
38
+ * @link http://pear.php.net/package/PHP_CodeSniffer
39
+ */
40
+ class Generic_Sniffs_CodeAnalysis_ForLoopShouldBeWhileLoopSniff implements PHP_CodeSniffer_Sniff
41
+ {
42
+
43
+
44
+ /**
45
+ * Registers the tokens that this sniff wants to listen for.
46
+ *
47
+ * @return int[]
48
+ */
49
+ public function register()
50
+ {
51
+ return array(T_FOR);
52
+
53
+ }//end register()
54
+
55
+
56
+ /**
57
+ * Processes this test, when one of its tokens is encountered.
58
+ *
59
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
60
+ * @param int $stackPtr The position of the current token
61
+ * in the stack passed in $tokens.
62
+ *
63
+ * @return void
64
+ */
65
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66
+ {
67
+ $tokens = $phpcsFile->getTokens();
68
+ $token = $tokens[$stackPtr];
69
+
70
+ // Skip invalid statement.
71
+ if (isset($token['parenthesis_opener']) === false) {
72
+ return;
73
+ }
74
+
75
+ $next = ++$token['parenthesis_opener'];
76
+ $end = --$token['parenthesis_closer'];
77
+
78
+ $parts = array(
79
+ 0,
80
+ 0,
81
+ 0,
82
+ );
83
+ $index = 0;
84
+
85
+ for (; $next <= $end; ++$next) {
86
+ $code = $tokens[$next]['code'];
87
+ if ($code === T_SEMICOLON) {
88
+ ++$index;
89
+ } else if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$code]) === false) {
90
+ ++$parts[$index];
91
+ }
92
+ }
93
+
94
+ if ($parts[0] === 0 && $parts[2] === 0 && $parts[1] > 0) {
95
+ $error = 'This FOR loop can be simplified to a WHILE loop';
96
+ $phpcsFile->addWarning($error, $stackPtr, 'CanSimplify');
97
+ }
98
+
99
+ }//end process()
100
+
101
+
102
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/ForLoopWithTestFunctionCallSniff.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of the CodeAnalysis add-on for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
11
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
12
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Detects for-loops that use a function call in the test expression.
18
+ *
19
+ * This rule is based on the PMD rule catalog. Detects for-loops that use a
20
+ * function call in the test expression.
21
+ *
22
+ * <code>
23
+ * class Foo
24
+ * {
25
+ * public function bar($x)
26
+ * {
27
+ * $a = array(1, 2, 3, 4);
28
+ * for ($i = 0; $i < count($a); $i++) {
29
+ * $a[$i] *= $i;
30
+ * }
31
+ * }
32
+ * }
33
+ * </code>
34
+ *
35
+ * @category PHP
36
+ * @package PHP_CodeSniffer
37
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
38
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
39
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
40
+ * @version Release: @package_version@
41
+ * @link http://pear.php.net/package/PHP_CodeSniffer
42
+ */
43
+ class Generic_Sniffs_CodeAnalysis_ForLoopWithTestFunctionCallSniff implements PHP_CodeSniffer_Sniff
44
+ {
45
+
46
+
47
+ /**
48
+ * Registers the tokens that this sniff wants to listen for.
49
+ *
50
+ * @return int[]
51
+ */
52
+ public function register()
53
+ {
54
+ return array(T_FOR);
55
+
56
+ }//end register()
57
+
58
+
59
+ /**
60
+ * Processes this test, when one of its tokens is encountered.
61
+ *
62
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
63
+ * @param int $stackPtr The position of the current token
64
+ * in the stack passed in $tokens.
65
+ *
66
+ * @return void
67
+ */
68
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
69
+ {
70
+ $tokens = $phpcsFile->getTokens();
71
+ $token = $tokens[$stackPtr];
72
+
73
+ // Skip invalid statement.
74
+ if (isset($token['parenthesis_opener']) === false) {
75
+ return;
76
+ }
77
+
78
+ $next = ++$token['parenthesis_opener'];
79
+ $end = --$token['parenthesis_closer'];
80
+
81
+ $position = 0;
82
+
83
+ for (; $next <= $end; ++$next) {
84
+ $code = $tokens[$next]['code'];
85
+ if ($code === T_SEMICOLON) {
86
+ ++$position;
87
+ }
88
+
89
+ if ($position < 1) {
90
+ continue;
91
+ } else if ($position > 1) {
92
+ break;
93
+ } else if ($code !== T_VARIABLE && $code !== T_STRING) {
94
+ continue;
95
+ }
96
+
97
+ // Find next non empty token, if it is a open curly brace we have a
98
+ // function call.
99
+ $index = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true);
100
+
101
+ if ($tokens[$index]['code'] === T_OPEN_PARENTHESIS) {
102
+ $error = 'Avoid function calls in a FOR loop test part';
103
+ $phpcsFile->addWarning($error, $stackPtr, 'NotAllowed');
104
+ break;
105
+ }
106
+ }//end for
107
+
108
+ }//end process()
109
+
110
+
111
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/JumbledIncrementerSniff.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of the CodeAnalysis add-on for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
11
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
12
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Detects incrementer jumbling in for loops.
18
+ *
19
+ * This rule is based on the PMD rule catalog. The jumbling incrementer sniff
20
+ * detects the usage of one and the same incrementer into an outer and an inner
21
+ * loop. Even it is intended this is confusing code.
22
+ *
23
+ * <code>
24
+ * class Foo
25
+ * {
26
+ * public function bar($x)
27
+ * {
28
+ * for ($i = 0; $i < 10; $i++)
29
+ * {
30
+ * for ($k = 0; $k < 20; $i++)
31
+ * {
32
+ * echo 'Hello';
33
+ * }
34
+ * }
35
+ * }
36
+ * }
37
+ * </code>
38
+ *
39
+ * @category PHP
40
+ * @package PHP_CodeSniffer
41
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
42
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
43
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
44
+ * @version Release: @package_version@
45
+ * @link http://pear.php.net/package/PHP_CodeSniffer
46
+ */
47
+ class Generic_Sniffs_CodeAnalysis_JumbledIncrementerSniff implements PHP_CodeSniffer_Sniff
48
+ {
49
+
50
+
51
+ /**
52
+ * Registers the tokens that this sniff wants to listen for.
53
+ *
54
+ * @return int[]
55
+ */
56
+ public function register()
57
+ {
58
+ return array(T_FOR);
59
+
60
+ }//end register()
61
+
62
+
63
+ /**
64
+ * Processes this test, when one of its tokens is encountered.
65
+ *
66
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
67
+ * @param int $stackPtr The position of the current token
68
+ * in the stack passed in $tokens.
69
+ *
70
+ * @return void
71
+ */
72
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
73
+ {
74
+ $tokens = $phpcsFile->getTokens();
75
+ $token = $tokens[$stackPtr];
76
+
77
+ // Skip for-loop without body.
78
+ if (isset($token['scope_opener']) === false) {
79
+ return;
80
+ }
81
+
82
+ // Find incrementors for outer loop.
83
+ $outer = $this->findIncrementers($tokens, $token);
84
+
85
+ // Skip if empty.
86
+ if (count($outer) === 0) {
87
+ return;
88
+ }
89
+
90
+ // Find nested for loops.
91
+ $start = ++$token['scope_opener'];
92
+ $end = --$token['scope_closer'];
93
+
94
+ for (; $start <= $end; ++$start) {
95
+ if ($tokens[$start]['code'] !== T_FOR) {
96
+ continue;
97
+ }
98
+
99
+ $inner = $this->findIncrementers($tokens, $tokens[$start]);
100
+ $diff = array_intersect($outer, $inner);
101
+
102
+ if (count($diff) !== 0) {
103
+ $error = 'Loop incrementor (%s) jumbling with inner loop';
104
+ $data = array(join(', ', $diff));
105
+ $phpcsFile->addWarning($error, $stackPtr, 'Found', $data);
106
+ }
107
+ }
108
+
109
+ }//end process()
110
+
111
+
112
+ /**
113
+ * Get all used variables in the incrementer part of a for statement.
114
+ *
115
+ * @param array(integer=>array) $tokens Array with all code sniffer tokens.
116
+ * @param array(string=>mixed) $token Current for loop token
117
+ *
118
+ * @return string[] List of all found incrementer variables.
119
+ */
120
+ protected function findIncrementers(array $tokens, array $token)
121
+ {
122
+ // Skip invalid statement.
123
+ if (isset($token['parenthesis_opener']) === false) {
124
+ return array();
125
+ }
126
+
127
+ $start = ++$token['parenthesis_opener'];
128
+ $end = --$token['parenthesis_closer'];
129
+
130
+ $incrementers = array();
131
+ $semicolons = 0;
132
+ for ($next = $start; $next <= $end; ++$next) {
133
+ $code = $tokens[$next]['code'];
134
+ if ($code === T_SEMICOLON) {
135
+ ++$semicolons;
136
+ } else if ($semicolons === 2 && $code === T_VARIABLE) {
137
+ $incrementers[] = $tokens[$next]['content'];
138
+ }
139
+ }
140
+
141
+ return $incrementers;
142
+
143
+ }//end findIncrementers()
144
+
145
+
146
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnconditionalIfStatementSniff.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of the CodeAnalysis add-on for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
11
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
12
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Detects unconditional if- and elseif-statements.
18
+ *
19
+ * This rule is based on the PMD rule catalog. The Unconditional If Statement
20
+ * sniff detects statement conditions that are only set to one of the constant
21
+ * values <b>true</b> or <b>false</b>
22
+ *
23
+ * <code>
24
+ * class Foo
25
+ * {
26
+ * public function close()
27
+ * {
28
+ * if (true)
29
+ * {
30
+ * // ...
31
+ * }
32
+ * }
33
+ * }
34
+ * </code>
35
+ *
36
+ * @category PHP
37
+ * @package PHP_CodeSniffer
38
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
39
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
40
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
41
+ * @version Release: @package_version@
42
+ * @link http://pear.php.net/package/PHP_CodeSniffer
43
+ */
44
+ class Generic_Sniffs_CodeAnalysis_UnconditionalIfStatementSniff implements PHP_CodeSniffer_Sniff
45
+ {
46
+
47
+
48
+ /**
49
+ * Registers the tokens that this sniff wants to listen for.
50
+ *
51
+ * @return int[]
52
+ */
53
+ public function register()
54
+ {
55
+ return array(
56
+ T_IF,
57
+ T_ELSEIF,
58
+ );
59
+
60
+ }//end register()
61
+
62
+
63
+ /**
64
+ * Processes this test, when one of its tokens is encountered.
65
+ *
66
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
67
+ * @param int $stackPtr The position of the current token
68
+ * in the stack passed in $tokens.
69
+ *
70
+ * @return void
71
+ */
72
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
73
+ {
74
+ $tokens = $phpcsFile->getTokens();
75
+ $token = $tokens[$stackPtr];
76
+
77
+ // Skip for-loop without body.
78
+ if (isset($token['parenthesis_opener']) === false) {
79
+ return;
80
+ }
81
+
82
+ $next = ++$token['parenthesis_opener'];
83
+ $end = --$token['parenthesis_closer'];
84
+
85
+ $goodCondition = false;
86
+ for (; $next <= $end; ++$next) {
87
+ $code = $tokens[$next]['code'];
88
+
89
+ if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$code]) === true) {
90
+ continue;
91
+ } else if ($code !== T_TRUE && $code !== T_FALSE) {
92
+ $goodCondition = true;
93
+ }
94
+ }
95
+
96
+ if ($goodCondition === false) {
97
+ $error = 'Avoid IF statements that are always true or false';
98
+ $phpcsFile->addWarning($error, $stackPtr, 'Found');
99
+ }
100
+
101
+ }//end process()
102
+
103
+
104
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnnecessaryFinalModifierSniff.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of the CodeAnalysis add-on for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
11
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
12
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Detects unnecessary final modifiers inside of final classes.
18
+ *
19
+ * This rule is based on the PMD rule catalog. The Unnecessary Final Modifier
20
+ * sniff detects the use of the final modifier inside of a final class which
21
+ * is unnecessary.
22
+ *
23
+ * <code>
24
+ * final class Foo
25
+ * {
26
+ * public final function bar()
27
+ * {
28
+ * }
29
+ * }
30
+ * </code>
31
+ *
32
+ * @category PHP
33
+ * @package PHP_CodeSniffer
34
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
35
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
36
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
37
+ * @version Release: @package_version@
38
+ * @link http://pear.php.net/package/PHP_CodeSniffer
39
+ */
40
+ class Generic_Sniffs_CodeAnalysis_UnnecessaryFinalModifierSniff implements PHP_CodeSniffer_Sniff
41
+ {
42
+
43
+
44
+ /**
45
+ * Registers the tokens that this sniff wants to listen for.
46
+ *
47
+ * @return int[]
48
+ */
49
+ public function register()
50
+ {
51
+ return array(T_CLASS);
52
+
53
+ }//end register()
54
+
55
+
56
+ /**
57
+ * Processes this test, when one of its tokens is encountered.
58
+ *
59
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
60
+ * @param int $stackPtr The position of the current token
61
+ * in the stack passed in $tokens.
62
+ *
63
+ * @return void
64
+ */
65
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66
+ {
67
+ $tokens = $phpcsFile->getTokens();
68
+ $token = $tokens[$stackPtr];
69
+
70
+ // Skip for-statements without body.
71
+ if (isset($token['scope_opener']) === false) {
72
+ return;
73
+ }
74
+
75
+ // Fetch previous token.
76
+ $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true);
77
+
78
+ // Skip for non final class.
79
+ if ($prev === false || $tokens[$prev]['code'] !== T_FINAL) {
80
+ return;
81
+ }
82
+
83
+ $next = ++$token['scope_opener'];
84
+ $end = --$token['scope_closer'];
85
+
86
+ for (; $next <= $end; ++$next) {
87
+ if ($tokens[$next]['code'] === T_FINAL) {
88
+ $error = 'Unnecessary FINAL modifier in FINAL class';
89
+ $phpcsFile->addWarning($error, $next, 'Found');
90
+ }
91
+ }
92
+
93
+ }//end process()
94
+
95
+
96
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UnusedFunctionParameterSniff.php ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of the CodeAnalysis add-on for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Checks the for unused function parameters.
18
+ *
19
+ * This sniff checks that all function parameters are used in the function body.
20
+ * One exception is made for empty function bodies or function bodies that only
21
+ * contain comments. This could be useful for the classes that implement an
22
+ * interface that defines multiple methods but the implementation only needs some
23
+ * of them.
24
+ *
25
+ * @category PHP
26
+ * @package PHP_CodeSniffer
27
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
28
+ * @author Greg Sherwood <gsherwood@squiz.net>
29
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
30
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
31
+ * @version Release: @package_version@
32
+ * @link http://pear.php.net/package/PHP_CodeSniffer
33
+ */
34
+ class Generic_Sniffs_CodeAnalysis_UnusedFunctionParameterSniff implements PHP_CodeSniffer_Sniff
35
+ {
36
+
37
+
38
+ /**
39
+ * Returns an array of tokens this test wants to listen for.
40
+ *
41
+ * @return array
42
+ */
43
+ public function register()
44
+ {
45
+ return array(
46
+ T_FUNCTION,
47
+ T_CLOSURE,
48
+ );
49
+
50
+ }//end register()
51
+
52
+
53
+ /**
54
+ * Processes this test, when one of its tokens is encountered.
55
+ *
56
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
57
+ * @param int $stackPtr The position of the current token
58
+ * in the stack passed in $tokens.
59
+ *
60
+ * @return void
61
+ */
62
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
63
+ {
64
+ $tokens = $phpcsFile->getTokens();
65
+ $token = $tokens[$stackPtr];
66
+
67
+ // Skip broken function declarations.
68
+ if (isset($token['scope_opener']) === false || isset($token['parenthesis_opener']) === false) {
69
+ return;
70
+ }
71
+
72
+ $params = array();
73
+ foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) {
74
+ $params[$param['name']] = $stackPtr;
75
+ }
76
+
77
+ $next = ++$token['scope_opener'];
78
+ $end = --$token['scope_closer'];
79
+
80
+ $foundContent = false;
81
+ $validTokens = array(
82
+ T_HEREDOC => T_HEREDOC,
83
+ T_NOWDOC => T_NOWDOC,
84
+ T_END_HEREDOC => T_END_HEREDOC,
85
+ T_END_NOWDOC => T_END_NOWDOC,
86
+ T_DOUBLE_QUOTED_STRING => T_DOUBLE_QUOTED_STRING,
87
+ );
88
+ $validTokens += PHP_CodeSniffer_Tokens::$emptyTokens;
89
+
90
+ for (; $next <= $end; ++$next) {
91
+ $token = $tokens[$next];
92
+ $code = $token['code'];
93
+
94
+ // Ignorable tokens.
95
+ if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$code]) === true) {
96
+ continue;
97
+ }
98
+
99
+ if ($foundContent === false) {
100
+ // A throw statement as the first content indicates an interface method.
101
+ if ($code === T_THROW) {
102
+ return;
103
+ }
104
+
105
+ // A return statement as the first content indicates an interface method.
106
+ if ($code === T_RETURN) {
107
+ $tmp = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true);
108
+ if ($tmp === false) {
109
+ return;
110
+ }
111
+
112
+ // There is a return.
113
+ if ($tokens[$tmp]['code'] === T_SEMICOLON) {
114
+ return;
115
+ }
116
+
117
+ $tmp = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($tmp + 1), null, true);
118
+ if ($tmp !== false && $tokens[$tmp]['code'] === T_SEMICOLON) {
119
+ // There is a return <token>.
120
+ return;
121
+ }
122
+ }//end if
123
+ }//end if
124
+
125
+ $foundContent = true;
126
+
127
+ if ($code === T_VARIABLE && isset($params[$token['content']]) === true) {
128
+ unset($params[$token['content']]);
129
+ } else if ($code === T_DOLLAR) {
130
+ $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($next + 1), null, true);
131
+ if ($tokens[$nextToken]['code'] === T_OPEN_CURLY_BRACKET) {
132
+ $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($nextToken + 1), null, true);
133
+ if ($tokens[$nextToken]['code'] === T_STRING) {
134
+ $varContent = '$'.$tokens[$nextToken]['content'];
135
+ if (isset($params[$varContent]) === true) {
136
+ unset($params[$varContent]);
137
+ }
138
+ }
139
+ }
140
+ } else if ($code === T_DOUBLE_QUOTED_STRING
141
+ || $code === T_START_HEREDOC
142
+ || $code === T_START_NOWDOC
143
+ ) {
144
+ // Tokenize strings that can contain variables.
145
+ // Make sure the string is re-joined if it occurs over multiple lines.
146
+ $content = $token['content'];
147
+ for ($i = ($next + 1); $i <= $end; $i++) {
148
+ if (isset($validTokens[$tokens[$i]['code']]) === true) {
149
+ $content .= $tokens[$i]['content'];
150
+ $next++;
151
+ } else {
152
+ break;
153
+ }
154
+ }
155
+
156
+ $stringTokens = token_get_all(sprintf('<?php %s;?>', $content));
157
+ foreach ($stringTokens as $stringPtr => $stringToken) {
158
+ if (is_array($stringToken) === false) {
159
+ continue;
160
+ }
161
+
162
+ $varContent = '';
163
+ if ($stringToken[0] === T_DOLLAR_OPEN_CURLY_BRACES) {
164
+ $varContent = '$'.$stringTokens[($stringPtr + 1)][1];
165
+ } else if ($stringToken[0] === T_VARIABLE) {
166
+ $varContent = $stringToken[1];
167
+ }
168
+
169
+ if ($varContent !== '' && isset($params[$varContent]) === true) {
170
+ unset($params[$varContent]);
171
+ }
172
+ }
173
+ }//end if
174
+ }//end for
175
+
176
+ if ($foundContent === true && count($params) > 0) {
177
+ foreach ($params as $paramName => $position) {
178
+ $error = 'The method parameter %s is never used';
179
+ $data = array($paramName);
180
+ $phpcsFile->addWarning($error, $position, 'Found', $data);
181
+ }
182
+ }
183
+
184
+ }//end process()
185
+
186
+
187
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/CodeAnalysis/UselessOverridingMethodSniff.php ADDED
@@ -0,0 +1,172 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file is part of the CodeAnalysis add-on for PHP_CodeSniffer.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
11
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
12
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Detects unnecessary overridden methods that simply call their parent.
18
+ *
19
+ * This rule is based on the PMD rule catalog. The Useless Overriding Method
20
+ * sniff detects the use of methods that only call their parent classes's method
21
+ * with the same name and arguments. These methods are not required.
22
+ *
23
+ * <code>
24
+ * class FooBar {
25
+ * public function __construct($a, $b) {
26
+ * parent::__construct($a, $b);
27
+ * }
28
+ * }
29
+ * </code>
30
+ *
31
+ * @category PHP
32
+ * @package PHP_CodeSniffer
33
+ * @author Manuel Pichler <mapi@manuel-pichler.de>
34
+ * @copyright 2007-2014 Manuel Pichler. All rights reserved.
35
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License
36
+ * @version Release: @package_version@
37
+ * @link http://pear.php.net/package/PHP_CodeSniffer
38
+ */
39
+ class Generic_Sniffs_CodeAnalysis_UselessOverridingMethodSniff implements PHP_CodeSniffer_Sniff
40
+ {
41
+
42
+
43
+ /**
44
+ * Registers the tokens that this sniff wants to listen for.
45
+ *
46
+ * @return int[]
47
+ */
48
+ public function register()
49
+ {
50
+ return array(T_FUNCTION);
51
+
52
+ }//end register()
53
+
54
+
55
+ /**
56
+ * Processes this test, when one of its tokens is encountered.
57
+ *
58
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
59
+ * @param int $stackPtr The position of the current token
60
+ * in the stack passed in $tokens.
61
+ *
62
+ * @return void
63
+ */
64
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
65
+ {
66
+ $tokens = $phpcsFile->getTokens();
67
+ $token = $tokens[$stackPtr];
68
+
69
+ // Skip function without body.
70
+ if (isset($token['scope_opener']) === false) {
71
+ return;
72
+ }
73
+
74
+ // Get function name.
75
+ $methodName = $phpcsFile->getDeclarationName($stackPtr);
76
+
77
+ // Get all parameters from method signature.
78
+ $signature = array();
79
+ foreach ($phpcsFile->getMethodParameters($stackPtr) as $param) {
80
+ $signature[] = $param['name'];
81
+ }
82
+
83
+ $next = ++$token['scope_opener'];
84
+ $end = --$token['scope_closer'];
85
+
86
+ for (; $next <= $end; ++$next) {
87
+ $code = $tokens[$next]['code'];
88
+
89
+ if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$code]) === true) {
90
+ continue;
91
+ } else if ($code === T_RETURN) {
92
+ continue;
93
+ }
94
+
95
+ break;
96
+ }
97
+
98
+ // Any token except 'parent' indicates correct code.
99
+ if ($tokens[$next]['code'] !== T_PARENT) {
100
+ return;
101
+ }
102
+
103
+ // Find next non empty token index, should be double colon.
104
+ $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true);
105
+
106
+ // Skip for invalid code.
107
+ if ($next === false || $tokens[$next]['code'] !== T_DOUBLE_COLON) {
108
+ return;
109
+ }
110
+
111
+ // Find next non empty token index, should be the function name.
112
+ $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true);
113
+
114
+ // Skip for invalid code or other method.
115
+ if ($next === false || $tokens[$next]['content'] !== $methodName) {
116
+ return;
117
+ }
118
+
119
+ // Find next non empty token index, should be the open parenthesis.
120
+ $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true);
121
+
122
+ // Skip for invalid code.
123
+ if ($next === false || $tokens[$next]['code'] !== T_OPEN_PARENTHESIS) {
124
+ return;
125
+ }
126
+
127
+ $parameters = array('');
128
+ $parenthesisCount = 1;
129
+ $count = count($tokens);
130
+ for (++$next; $next < $count; ++$next) {
131
+ $code = $tokens[$next]['code'];
132
+
133
+ if ($code === T_OPEN_PARENTHESIS) {
134
+ ++$parenthesisCount;
135
+ } else if ($code === T_CLOSE_PARENTHESIS) {
136
+ --$parenthesisCount;
137
+ } else if ($parenthesisCount === 1 && $code === T_COMMA) {
138
+ $parameters[] = '';
139
+ } else if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$code]) === false) {
140
+ $parameters[(count($parameters) - 1)] .= $tokens[$next]['content'];
141
+ }
142
+
143
+ if ($parenthesisCount === 0) {
144
+ break;
145
+ }
146
+ }//end for
147
+
148
+ $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($next + 1), null, true);
149
+ if ($next === false || $tokens[$next]['code'] !== T_SEMICOLON) {
150
+ return;
151
+ }
152
+
153
+ // Check rest of the scope.
154
+ for (++$next; $next <= $end; ++$next) {
155
+ $code = $tokens[$next]['code'];
156
+ // Skip for any other content.
157
+ if (isset(PHP_CodeSniffer_Tokens::$emptyTokens[$code]) === false) {
158
+ return;
159
+ }
160
+ }
161
+
162
+ $parameters = array_map('trim', $parameters);
163
+ $parameters = array_filter($parameters);
164
+
165
+ if (count($parameters) === count($signature) && $parameters === $signature) {
166
+ $phpcsFile->addWarning('Possible useless method overriding detected', $stackPtr, 'Found');
167
+ }
168
+
169
+ }//end process()
170
+
171
+
172
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Commenting/DocCommentSniff.php ADDED
@@ -0,0 +1,350 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Ensures doc blocks follow basic formatting.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Ensures doc blocks follow basic formatting.
17
+ *
18
+ * @category PHP
19
+ * @package PHP_CodeSniffer
20
+ * @author Greg Sherwood <gsherwood@squiz.net>
21
+ * @copyright 2006-2012 Squiz Pty Ltd (ABN 77 084 670 600)
22
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
23
+ * @version Release: @package_version@
24
+ * @link http://pear.php.net/package/PHP_CodeSniffer
25
+ */
26
+ class Generic_Sniffs_Commenting_DocCommentSniff implements PHP_CodeSniffer_Sniff
27
+ {
28
+
29
+ /**
30
+ * A list of tokenizers this sniff supports.
31
+ *
32
+ * @var array
33
+ */
34
+ public $supportedTokenizers = array(
35
+ 'PHP',
36
+ 'JS',
37
+ );
38
+
39
+
40
+ /**
41
+ * Returns an array of tokens this test wants to listen for.
42
+ *
43
+ * @return array
44
+ */
45
+ public function register()
46
+ {
47
+ return array(T_DOC_COMMENT_OPEN_TAG);
48
+
49
+ }//end register()
50
+
51
+
52
+ /**
53
+ * Processes this test, when one of its tokens is encountered.
54
+ *
55
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
56
+ * @param int $stackPtr The position of the current token
57
+ * in the stack passed in $tokens.
58
+ *
59
+ * @return void
60
+ */
61
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
62
+ {
63
+ $tokens = $phpcsFile->getTokens();
64
+ $commentStart = $stackPtr;
65
+ $commentEnd = $tokens[$stackPtr]['comment_closer'];
66
+
67
+ $empty = array(
68
+ T_DOC_COMMENT_WHITESPACE,
69
+ T_DOC_COMMENT_STAR,
70
+ );
71
+
72
+ $short = $phpcsFile->findNext($empty, ($stackPtr + 1), $commentEnd, true);
73
+ if ($short === false) {
74
+ // No content at all.
75
+ $error = 'Doc comment is empty';
76
+ $phpcsFile->addError($error, $stackPtr, 'Empty');
77
+ return;
78
+ }
79
+
80
+ // The first line of the comment should just be the /** code.
81
+ if ($tokens[$short]['line'] === $tokens[$stackPtr]['line']) {
82
+ $error = 'The open comment tag must be the only content on the line';
83
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'ContentAfterOpen');
84
+ if ($fix === true) {
85
+ $phpcsFile->fixer->beginChangeset();
86
+ $phpcsFile->fixer->addNewline($stackPtr);
87
+ $phpcsFile->fixer->addContentBefore($short, '* ');
88
+ $phpcsFile->fixer->endChangeset();
89
+ }
90
+ }
91
+
92
+ // The last line of the comment should just be the */ code.
93
+ $prev = $phpcsFile->findPrevious($empty, ($commentEnd - 1), $stackPtr, true);
94
+ if ($tokens[$prev]['line'] === $tokens[$commentEnd]['line']) {
95
+ $error = 'The close comment tag must be the only content on the line';
96
+ $fix = $phpcsFile->addFixableError($error, $commentEnd, 'ContentBeforeClose');
97
+ if ($fix === true) {
98
+ $phpcsFile->fixer->addNewlineBefore($commentEnd);
99
+ }
100
+ }
101
+
102
+ // Check for additional blank lines at the end of the comment.
103
+ if ($tokens[$prev]['line'] < ($tokens[$commentEnd]['line'] - 1)) {
104
+ $error = 'Additional blank lines found at end of doc comment';
105
+ $fix = $phpcsFile->addFixableError($error, $commentEnd, 'SpacingAfter');
106
+ if ($fix === true) {
107
+ $phpcsFile->fixer->beginChangeset();
108
+ for ($i = ($prev + 1); $i < $commentEnd; $i++) {
109
+ if ($tokens[($i + 1)]['line'] === $tokens[$commentEnd]['line']) {
110
+ break;
111
+ }
112
+
113
+ $phpcsFile->fixer->replaceToken($i, '');
114
+ }
115
+
116
+ $phpcsFile->fixer->endChangeset();
117
+ }
118
+ }
119
+
120
+ // Check for a comment description.
121
+ if ($tokens[$short]['code'] !== T_DOC_COMMENT_STRING) {
122
+ $error = 'Missing short description in doc comment';
123
+ $phpcsFile->addError($error, $stackPtr, 'MissingShort');
124
+ return;
125
+ }
126
+
127
+ // No extra newline before short description.
128
+ if ($tokens[$short]['line'] !== ($tokens[$stackPtr]['line'] + 1)) {
129
+ $error = 'Doc comment short description must be on the first line';
130
+ $fix = $phpcsFile->addFixableError($error, $short, 'SpacingBeforeShort');
131
+ if ($fix === true) {
132
+ $phpcsFile->fixer->beginChangeset();
133
+ for ($i = $stackPtr; $i < $short; $i++) {
134
+ if ($tokens[$i]['line'] === $tokens[$stackPtr]['line']) {
135
+ continue;
136
+ } else if ($tokens[$i]['line'] === $tokens[$short]['line']) {
137
+ break;
138
+ }
139
+
140
+ $phpcsFile->fixer->replaceToken($i, '');
141
+ }
142
+
143
+ $phpcsFile->fixer->endChangeset();
144
+ }
145
+ }
146
+
147
+ // Account for the fact that a short description might cover
148
+ // multiple lines.
149
+ $shortContent = $tokens[$short]['content'];
150
+ $shortEnd = $short;
151
+ for ($i = ($short + 1); $i < $commentEnd; $i++) {
152
+ if ($tokens[$i]['code'] === T_DOC_COMMENT_STRING) {
153
+ if ($tokens[$i]['line'] === ($tokens[$shortEnd]['line'] + 1)) {
154
+ $shortContent .= $tokens[$i]['content'];
155
+ $shortEnd = $i;
156
+ } else {
157
+ break;
158
+ }
159
+ }
160
+ }
161
+
162
+ if (preg_match('/^\p{Ll}/u', $shortContent) === 1) {
163
+ $error = 'Doc comment short description must start with a capital letter';
164
+ $phpcsFile->addError($error, $short, 'ShortNotCapital');
165
+ }
166
+
167
+ $long = $phpcsFile->findNext($empty, ($shortEnd + 1), ($commentEnd - 1), true);
168
+ if ($long !== false && $tokens[$long]['code'] === T_DOC_COMMENT_STRING) {
169
+ if ($tokens[$long]['line'] !== ($tokens[$shortEnd]['line'] + 2)) {
170
+ $error = 'There must be exactly one blank line between descriptions in a doc comment';
171
+ $fix = $phpcsFile->addFixableError($error, $long, 'SpacingBetween');
172
+ if ($fix === true) {
173
+ $phpcsFile->fixer->beginChangeset();
174
+ for ($i = ($shortEnd + 1); $i < $long; $i++) {
175
+ if ($tokens[$i]['line'] === $tokens[$shortEnd]['line']) {
176
+ continue;
177
+ } else if ($tokens[$i]['line'] === ($tokens[$long]['line'] - 1)) {
178
+ break;
179
+ }
180
+
181
+ $phpcsFile->fixer->replaceToken($i, '');
182
+ }
183
+
184
+ $phpcsFile->fixer->endChangeset();
185
+ }
186
+ }
187
+
188
+ if (preg_match('/^\p{Ll}/u', $tokens[$long]['content']) === 1) {
189
+ $error = 'Doc comment long description must start with a capital letter';
190
+ $phpcsFile->addError($error, $long, 'LongNotCapital');
191
+ }
192
+ }//end if
193
+
194
+ if (empty($tokens[$commentStart]['comment_tags']) === true) {
195
+ // No tags in the comment.
196
+ return;
197
+ }
198
+
199
+ $firstTag = $tokens[$commentStart]['comment_tags'][0];
200
+ $prev = $phpcsFile->findPrevious($empty, ($firstTag - 1), $stackPtr, true);
201
+ if ($tokens[$firstTag]['line'] !== ($tokens[$prev]['line'] + 2)) {
202
+ $error = 'There must be exactly one blank line before the tags in a doc comment';
203
+ $fix = $phpcsFile->addFixableError($error, $firstTag, 'SpacingBeforeTags');
204
+ if ($fix === true) {
205
+ $phpcsFile->fixer->beginChangeset();
206
+ for ($i = ($prev + 1); $i < $firstTag; $i++) {
207
+ if ($tokens[$i]['line'] === $tokens[$firstTag]['line']) {
208
+ break;
209
+ }
210
+
211
+ $phpcsFile->fixer->replaceToken($i, '');
212
+ }
213
+
214
+ $indent = str_repeat(' ', $tokens[$stackPtr]['column']);
215
+ $phpcsFile->fixer->addContent($prev, $phpcsFile->eolChar.$indent.'*'.$phpcsFile->eolChar);
216
+ $phpcsFile->fixer->endChangeset();
217
+ }
218
+ }
219
+
220
+ // Break out the tags into groups and check alignment within each.
221
+ // A tag group is one where there are no blank lines between tags.
222
+ // The param tag group is special as it requires all @param tags to be inside.
223
+ $tagGroups = array();
224
+ $groupid = 0;
225
+ $paramGroupid = null;
226
+ foreach ($tokens[$commentStart]['comment_tags'] as $pos => $tag) {
227
+ if ($pos > 0) {
228
+ $prev = $phpcsFile->findPrevious(
229
+ T_DOC_COMMENT_STRING,
230
+ ($tag - 1),
231
+ $tokens[$commentStart]['comment_tags'][($pos - 1)]
232
+ );
233
+
234
+ if ($prev === false) {
235
+ $prev = $tokens[$commentStart]['comment_tags'][($pos - 1)];
236
+ }
237
+
238
+ if ($tokens[$prev]['line'] !== ($tokens[$tag]['line'] - 1)) {
239
+ $groupid++;
240
+ }
241
+ }
242
+
243
+ if ($tokens[$tag]['content'] === '@param') {
244
+ if (($paramGroupid === null
245
+ && empty($tagGroups[$groupid]) === false)
246
+ || ($paramGroupid !== null
247
+ && $paramGroupid !== $groupid)
248
+ ) {
249
+ $error = 'Parameter tags must be grouped together in a doc comment';
250
+ $phpcsFile->addError($error, $tag, 'ParamGroup');
251
+ }
252
+
253
+ if ($paramGroupid === null) {
254
+ $paramGroupid = $groupid;
255
+ }
256
+ } else if ($groupid === $paramGroupid) {
257
+ $error = 'Tag cannot be grouped with parameter tags in a doc comment';
258
+ $phpcsFile->addError($error, $tag, 'NonParamGroup');
259
+ }//end if
260
+
261
+ $tagGroups[$groupid][] = $tag;
262
+ }//end foreach
263
+
264
+ foreach ($tagGroups as $group) {
265
+ $maxLength = 0;
266
+ $paddings = array();
267
+ foreach ($group as $pos => $tag) {
268
+ $tagLength = strlen($tokens[$tag]['content']);
269
+ if ($tagLength > $maxLength) {
270
+ $maxLength = $tagLength;
271
+ }
272
+
273
+ // Check for a value. No value means no padding needed.
274
+ $string = $phpcsFile->findNext(T_DOC_COMMENT_STRING, $tag, $commentEnd);
275
+ if ($string !== false && $tokens[$string]['line'] === $tokens[$tag]['line']) {
276
+ $paddings[$tag] = strlen($tokens[($tag + 1)]['content']);
277
+ }
278
+ }
279
+
280
+ // Check that there was single blank line after the tag block
281
+ // but account for a multi-line tag comments.
282
+ $lastTag = $group[$pos];
283
+ $next = $phpcsFile->findNext(T_DOC_COMMENT_TAG, ($lastTag + 3), $commentEnd);
284
+ if ($next !== false) {
285
+ $prev = $phpcsFile->findPrevious(array(T_DOC_COMMENT_TAG, T_DOC_COMMENT_STRING), ($next - 1), $commentStart);
286
+ if ($tokens[$next]['line'] !== ($tokens[$prev]['line'] + 2)) {
287
+ $error = 'There must be a single blank line after a tag group';
288
+ $fix = $phpcsFile->addFixableError($error, $lastTag, 'SpacingAfterTagGroup');
289
+ if ($fix === true) {
290
+ $phpcsFile->fixer->beginChangeset();
291
+ for ($i = ($prev + 1); $i < $next; $i++) {
292
+ if ($tokens[$i]['line'] === $tokens[$next]['line']) {
293
+ break;
294
+ }
295
+
296
+ $phpcsFile->fixer->replaceToken($i, '');
297
+ }
298
+
299
+ $indent = str_repeat(' ', $tokens[$stackPtr]['column']);
300
+ $phpcsFile->fixer->addContent($prev, $phpcsFile->eolChar.$indent.'*'.$phpcsFile->eolChar);
301
+ $phpcsFile->fixer->endChangeset();
302
+ }
303
+ }
304
+ }//end if
305
+
306
+ // Now check paddings.
307
+ foreach ($paddings as $tag => $padding) {
308
+ $required = ($maxLength - strlen($tokens[$tag]['content']) + 1);
309
+
310
+ if ($padding !== $required) {
311
+ $error = 'Tag value indented incorrectly; expected %s spaces but found %s';
312
+ $data = array(
313
+ $required,
314
+ $padding,
315
+ );
316
+
317
+ $fix = $phpcsFile->addFixableError($error, ($tag + 1), 'TagValueIndent', $data);
318
+ if ($fix === true) {
319
+ $phpcsFile->fixer->replaceToken(($tag + 1), str_repeat(' ', $required));
320
+ }
321
+ }
322
+ }
323
+ }//end foreach
324
+
325
+ // If there is a param group, it needs to be first.
326
+ if ($paramGroupid !== null && $paramGroupid !== 0) {
327
+ $error = 'Parameter tags must be defined first in a doc comment';
328
+ $phpcsFile->addError($error, $tagGroups[$paramGroupid][0], 'ParamNotFirst');
329
+ }
330
+
331
+ $foundTags = array();
332
+ foreach ($tokens[$stackPtr]['comment_tags'] as $pos => $tag) {
333
+ $tagName = $tokens[$tag]['content'];
334
+ if (isset($foundTags[$tagName]) === true) {
335
+ $lastTag = $tokens[$stackPtr]['comment_tags'][($pos - 1)];
336
+ if ($tokens[$lastTag]['content'] !== $tagName) {
337
+ $error = 'Tags must be grouped together in a doc comment';
338
+ $phpcsFile->addError($error, $tag, 'TagsNotGrouped');
339
+ }
340
+
341
+ continue;
342
+ }
343
+
344
+ $foundTags[$tagName] = true;
345
+ }
346
+
347
+ }//end process()
348
+
349
+
350
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Commenting/FixmeSniff.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Commenting_FixmeSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Sam Graham <php-codesniffer@illusori.co.uk>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_Commenting_FixmeSniff.
18
+ *
19
+ * Warns about FIXME comments.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Sam Graham <php-codesniffer@illusori.co.uk>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_Commenting_FixmeSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+ /**
34
+ * A list of tokenizers this sniff supports.
35
+ *
36
+ * @var array
37
+ */
38
+ public $supportedTokenizers = array(
39
+ 'PHP',
40
+ 'JS',
41
+ );
42
+
43
+
44
+ /**
45
+ * Returns an array of tokens this test wants to listen for.
46
+ *
47
+ * @return array
48
+ */
49
+ public function register()
50
+ {
51
+ return PHP_CodeSniffer_Tokens::$commentTokens;
52
+
53
+ }//end register()
54
+
55
+
56
+ /**
57
+ * Processes this sniff, when one of its tokens is encountered.
58
+ *
59
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
60
+ * @param int $stackPtr The position of the current token
61
+ * in the stack passed in $tokens.
62
+ *
63
+ * @return void
64
+ */
65
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66
+ {
67
+ $tokens = $phpcsFile->getTokens();
68
+
69
+ $content = $tokens[$stackPtr]['content'];
70
+ $matches = array();
71
+ preg_match('/(?:\A|[^\p{L}]+)fixme([^\p{L}]+(.*)|\Z)/ui', $content, $matches);
72
+ if (empty($matches) === false) {
73
+ // Clear whitespace and some common characters not required at
74
+ // the end of a fixme message to make the error more informative.
75
+ $type = 'CommentFound';
76
+ $fixmeMessage = trim($matches[1]);
77
+ $fixmeMessage = trim($fixmeMessage, '-:[](). ');
78
+ $error = 'Comment refers to a FIXME task';
79
+ $data = array($fixmeMessage);
80
+ if ($fixmeMessage !== '') {
81
+ $type = 'TaskFound';
82
+ $error .= ' "%s"';
83
+ }
84
+
85
+ $phpcsFile->addError($error, $stackPtr, $type, $data);
86
+ }
87
+
88
+ }//end process()
89
+
90
+
91
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Commenting/TodoSniff.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Commenting_TodoSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Commenting_TodoSniff.
17
+ *
18
+ * Warns about TODO comments.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_Commenting_TodoSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+ /**
32
+ * A list of tokenizers this sniff supports.
33
+ *
34
+ * @var array
35
+ */
36
+ public $supportedTokenizers = array(
37
+ 'PHP',
38
+ 'JS',
39
+ );
40
+
41
+
42
+ /**
43
+ * Returns an array of tokens this test wants to listen for.
44
+ *
45
+ * @return array
46
+ */
47
+ public function register()
48
+ {
49
+ return PHP_CodeSniffer_Tokens::$commentTokens;
50
+
51
+ }//end register()
52
+
53
+
54
+ /**
55
+ * Processes this sniff, when one of its tokens is encountered.
56
+ *
57
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
58
+ * @param int $stackPtr The position of the current token
59
+ * in the stack passed in $tokens.
60
+ *
61
+ * @return void
62
+ */
63
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
64
+ {
65
+ $tokens = $phpcsFile->getTokens();
66
+
67
+ $content = $tokens[$stackPtr]['content'];
68
+ $matches = array();
69
+ preg_match('/(?:\A|[^\p{L}]+)todo([^\p{L}]+(.*)|\Z)/ui', $content, $matches);
70
+ if (empty($matches) === false) {
71
+ // Clear whitespace and some common characters not required at
72
+ // the end of a to-do message to make the warning more informative.
73
+ $type = 'CommentFound';
74
+ $todoMessage = trim($matches[1]);
75
+ $todoMessage = trim($todoMessage, '-:[](). ');
76
+ $error = 'Comment refers to a TODO task';
77
+ $data = array($todoMessage);
78
+ if ($todoMessage !== '') {
79
+ $type = 'TaskFound';
80
+ $error .= ' "%s"';
81
+ }
82
+
83
+ $phpcsFile->addWarning($error, $stackPtr, $type, $data);
84
+ }
85
+
86
+ }//end process()
87
+
88
+
89
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/ControlStructures/InlineControlStructureSniff.php ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_ControlStructures_InlineControlStructureSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_ControlStructures_InlineControlStructureSniff.
18
+ *
19
+ * Verifies that inline control statements are not present.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Marc McIntyre <mmcintyre@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_ControlStructures_InlineControlStructureSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+ /**
34
+ * A list of tokenizers this sniff supports.
35
+ *
36
+ * @var array
37
+ */
38
+ public $supportedTokenizers = array(
39
+ 'PHP',
40
+ 'JS',
41
+ );
42
+
43
+ /**
44
+ * If true, an error will be thrown; otherwise a warning.
45
+ *
46
+ * @var bool
47
+ */
48
+ public $error = true;
49
+
50
+
51
+ /**
52
+ * Returns an array of tokens this test wants to listen for.
53
+ *
54
+ * @return array
55
+ */
56
+ public function register()
57
+ {
58
+ return array(
59
+ T_IF,
60
+ T_ELSE,
61
+ T_ELSEIF,
62
+ T_FOREACH,
63
+ T_WHILE,
64
+ T_DO,
65
+ T_SWITCH,
66
+ T_FOR,
67
+ );
68
+
69
+ }//end register()
70
+
71
+
72
+ /**
73
+ * Processes this test, when one of its tokens is encountered.
74
+ *
75
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
76
+ * @param int $stackPtr The position of the current token in the
77
+ * stack passed in $tokens.
78
+ *
79
+ * @return void
80
+ */
81
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
82
+ {
83
+ $tokens = $phpcsFile->getTokens();
84
+
85
+ if (isset($tokens[$stackPtr]['scope_opener']) === true) {
86
+ $phpcsFile->recordMetric($stackPtr, 'Control structure defined inline', 'no');
87
+ return;
88
+ }
89
+
90
+ // Ignore the ELSE in ELSE IF. We'll process the IF part later.
91
+ if ($tokens[$stackPtr]['code'] === T_ELSE) {
92
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
93
+ if ($tokens[$next]['code'] === T_IF) {
94
+ return;
95
+ }
96
+ }
97
+
98
+ if ($tokens[$stackPtr]['code'] === T_WHILE) {
99
+ // This could be from a DO WHILE, which doesn't have an opening brace.
100
+ $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
101
+ if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) {
102
+ $brace = $tokens[$lastContent];
103
+ if (isset($brace['scope_condition']) === true) {
104
+ $condition = $tokens[$brace['scope_condition']];
105
+ if ($condition['code'] === T_DO) {
106
+ return;
107
+ }
108
+ }
109
+ }
110
+
111
+ // In Javascript DO WHILE loops without curly braces are legal. This
112
+ // is only valid if a single statement is present between the DO and
113
+ // the WHILE. We can detect this by checking only a single semicolon
114
+ // is present between them.
115
+ if ($phpcsFile->tokenizerType === 'JS') {
116
+ $lastDo = $phpcsFile->findPrevious(T_DO, ($stackPtr - 1));
117
+ $lastSemicolon = $phpcsFile->findPrevious(T_SEMICOLON, ($stackPtr - 1));
118
+ if ($lastDo !== false && $lastSemicolon !== false && $lastDo < $lastSemicolon) {
119
+ $precedingSemicolon = $phpcsFile->findPrevious(T_SEMICOLON, ($lastSemicolon - 1));
120
+ if ($precedingSemicolon === false || $precedingSemicolon < $lastDo) {
121
+ return;
122
+ }
123
+ }
124
+ }
125
+ }//end if
126
+
127
+ // This is a control structure without an opening brace,
128
+ // so it is an inline statement.
129
+ if ($this->error === true) {
130
+ $fix = $phpcsFile->addFixableError('Inline control structures are not allowed', $stackPtr, 'NotAllowed');
131
+ } else {
132
+ $fix = $phpcsFile->addFixableWarning('Inline control structures are discouraged', $stackPtr, 'Discouraged');
133
+ }
134
+
135
+ $phpcsFile->recordMetric($stackPtr, 'Control structure defined inline', 'yes');
136
+
137
+ // Stop here if we are not fixing the error.
138
+ if ($fix !== true) {
139
+ return;
140
+ }
141
+
142
+ $phpcsFile->fixer->beginChangeset();
143
+ if (isset($tokens[$stackPtr]['parenthesis_closer']) === true) {
144
+ $closer = $tokens[$stackPtr]['parenthesis_closer'];
145
+ } else {
146
+ $closer = $stackPtr;
147
+ }
148
+
149
+ if ($tokens[($closer + 1)]['code'] === T_WHITESPACE
150
+ || $tokens[($closer + 1)]['code'] === T_SEMICOLON
151
+ ) {
152
+ $phpcsFile->fixer->addContent($closer, ' {');
153
+ } else {
154
+ $phpcsFile->fixer->addContent($closer, ' { ');
155
+ }
156
+
157
+ $fixableScopeOpeners = $this->register();
158
+
159
+ $lastNonEmpty = $closer;
160
+ for ($end = ($closer + 1); $end < $phpcsFile->numTokens; $end++) {
161
+ if ($tokens[$end]['code'] === T_SEMICOLON) {
162
+ break;
163
+ }
164
+
165
+ if ($tokens[$end]['code'] === T_CLOSE_TAG) {
166
+ $end = $lastNonEmpty;
167
+ break;
168
+ }
169
+
170
+ if (in_array($tokens[$end]['code'], $fixableScopeOpeners) === true
171
+ && isset($tokens[$end]['scope_opener']) === false
172
+ ) {
173
+ // The best way to fix nested inline scopes is middle-out.
174
+ // So skip this one. It will be detected and fixed on a future loop.
175
+ $phpcsFile->fixer->rollbackChangeset();
176
+ return;
177
+ }
178
+
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;
186
+ }
187
+
188
+ $nextType = $tokens[$next]['code'];
189
+
190
+ // Let additional conditions loop and find their ending.
191
+ if (($type === T_IF
192
+ || $type === T_ELSEIF)
193
+ && ($nextType === T_ELSEIF
194
+ || $nextType === T_ELSE)
195
+ ) {
196
+ continue;
197
+ }
198
+
199
+ // Account for DO... WHILE conditions.
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, '');
304
+ $phpcsFile->fixer->addNewlineBefore($endLine);
305
+ $phpcsFile->fixer->addContent($endLine, '}');
306
+ } else {
307
+ $phpcsFile->fixer->replaceToken($end, '}');
308
+ }
309
+ }//end if
310
+
311
+ $phpcsFile->fixer->endChangeset();
312
+
313
+ }//end process()
314
+
315
+
316
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/CSSLintSniff.php ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Debug_CSSLintSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Roman Levishchenko <index.0h@gmail.com>
10
+ * @copyright 2013-2014 Roman Levishchenko
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Debug_CSSLintSniff.
17
+ *
18
+ * Runs csslint on the file.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Roman Levishchenko <index.0h@gmail.com>
23
+ * @copyright 2013-2014 Roman Levishchenko
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_Debug_CSSLintSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+ /**
32
+ * A list of tokenizers this sniff supports.
33
+ *
34
+ * @var array
35
+ */
36
+ public $supportedTokenizers = array('CSS');
37
+
38
+
39
+ /**
40
+ * Returns the token types that this sniff is interested in.
41
+ *
42
+ * @return int[]
43
+ */
44
+ public function register()
45
+ {
46
+ return array(T_OPEN_TAG);
47
+
48
+ }//end register()
49
+
50
+
51
+ /**
52
+ * Processes the tokens that this sniff is interested in.
53
+ *
54
+ * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
55
+ * @param int $stackPtr The position in the stack where
56
+ * the token was found.
57
+ *
58
+ * @return void
59
+ */
60
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
61
+ {
62
+ $fileName = $phpcsFile->getFilename();
63
+
64
+ $csslintPath = PHP_CodeSniffer::getConfigData('csslint_path');
65
+ if ($csslintPath === null) {
66
+ return;
67
+ }
68
+
69
+ $cmd = escapeshellcmd($csslintPath).' '.escapeshellarg($fileName).' 2>&1';
70
+ exec($cmd, $output, $retval);
71
+
72
+ if (is_array($output) === false) {
73
+ return;
74
+ }
75
+
76
+ $count = count($output);
77
+
78
+ for ($i = 0; $i < $count; $i++) {
79
+ $matches = array();
80
+ $numMatches = preg_match(
81
+ '/(error|warning) at line (\d+)/',
82
+ $output[$i],
83
+ $matches
84
+ );
85
+
86
+ if ($numMatches === 0) {
87
+ continue;
88
+ }
89
+
90
+ $line = (int) $matches[2];
91
+ $message = 'csslint says: '.$output[($i + 1)];
92
+ // First line is message with error line and error code.
93
+ // Second is error message.
94
+ // Third is wrong line in file.
95
+ // Fourth is empty line.
96
+ $i += 4;
97
+
98
+ $phpcsFile->addWarningOnLine($message, $line, 'ExternalTool');
99
+ }//end for
100
+
101
+ // Ignore the rest of the file.
102
+ return ($phpcsFile->numTokens + 1);
103
+
104
+ }//end process()
105
+
106
+
107
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/ClosureLinterSniff.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Debug_ClosureLinterSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Debug_ClosureLinterSniff.
17
+ *
18
+ * Runs gjslint on the file.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_Debug_ClosureLinterSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+ /**
32
+ * A list of error codes that should show errors.
33
+ *
34
+ * All other error codes will show warnings.
35
+ *
36
+ * @var int
37
+ */
38
+ public $errorCodes = array();
39
+
40
+ /**
41
+ * A list of error codes to ignore.
42
+ *
43
+ * @var int
44
+ */
45
+ public $ignoreCodes = array();
46
+
47
+ /**
48
+ * A list of tokenizers this sniff supports.
49
+ *
50
+ * @var array
51
+ */
52
+ public $supportedTokenizers = array('JS');
53
+
54
+
55
+ /**
56
+ * Returns the token types that this sniff is interested in.
57
+ *
58
+ * @return int[]
59
+ */
60
+ public function register()
61
+ {
62
+ return array(T_OPEN_TAG);
63
+
64
+ }//end register()
65
+
66
+
67
+ /**
68
+ * Processes the tokens that this sniff is interested in.
69
+ *
70
+ * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
71
+ * @param int $stackPtr The position in the stack where
72
+ * the token was found.
73
+ *
74
+ * @return void
75
+ * @throws PHP_CodeSniffer_Exception If jslint.js could not be run
76
+ */
77
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
78
+ {
79
+ $fileName = $phpcsFile->getFilename();
80
+
81
+ $lintPath = PHP_CodeSniffer::getConfigData('gjslint_path');
82
+ if ($lintPath === null) {
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;
92
+ }
93
+
94
+ foreach ($output as $finding) {
95
+ $matches = array();
96
+ $numMatches = preg_match('/^(.*):([0-9]+):\(.*?([0-9]+)\)(.*)$/', $finding, $matches);
97
+ if ($numMatches === 0) {
98
+ continue;
99
+ }
100
+
101
+ // Skip error codes we are ignoring.
102
+ $code = $matches[3];
103
+ if (in_array($code, $this->ignoreCodes) === true) {
104
+ continue;
105
+ }
106
+
107
+ $line = (int) $matches[2];
108
+ $error = trim($matches[4]);
109
+
110
+ $message = 'gjslint says: (%s) %s';
111
+ $data = array(
112
+ $code,
113
+ $error,
114
+ );
115
+ if (in_array($code, $this->errorCodes) === true) {
116
+ $phpcsFile->addErrorOnLine($message, $line, 'ExternalToolError', $data);
117
+ } else {
118
+ $phpcsFile->addWarningOnLine($message, $line, 'ExternalTool', $data);
119
+ }
120
+ }//end foreach
121
+
122
+ // Ignore the rest of the file.
123
+ return ($phpcsFile->numTokens + 1);
124
+
125
+ }//end process()
126
+
127
+
128
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/ESLintSniff.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Debug_ESLintSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Ryan McCue <ryan+gh@hmn.md>
10
+ * @copyright 2006-2017 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Debug_ESLintSniff.
17
+ *
18
+ * Runs eslint on the file.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Ryan McCue <ryan+gh@hmn.md>
23
+ * @copyright 2006-2017 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_Debug_ESLintSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+ /**
31
+ * A list of tokenizers this sniff supports.
32
+ *
33
+ * @var array
34
+ */
35
+ public $supportedTokenizers = array('JS');
36
+
37
+
38
+ /**
39
+ * ESLint configuration file path.
40
+ *
41
+ * @var string|null Path to eslintrc. Null to autodetect.
42
+ */
43
+ public $configFile = null;
44
+
45
+
46
+ /**
47
+ * Returns the token types that this sniff is interested in.
48
+ *
49
+ * @return int[]
50
+ */
51
+ public function register()
52
+ {
53
+ return array(T_OPEN_TAG);
54
+
55
+ }//end register()
56
+
57
+
58
+ /**
59
+ * Processes the tokens that this sniff is interested in.
60
+ *
61
+ * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
62
+ * @param int $stackPtr The position in the stack where
63
+ * the token was found.
64
+ *
65
+ * @return void
66
+ */
67
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
68
+ {
69
+ $filename = $phpcsFile->getFilename();
70
+ $eslintPath = PHP_CodeSniffer::getConfigData('eslint_path');
71
+ if ($eslintPath === null) {
72
+ return;
73
+ }
74
+
75
+ $configFile = $this->configFile;
76
+ if (empty($configFile) === true) {
77
+ // Attempt to autodetect.
78
+ $candidates = glob('.eslintrc{.js,.yaml,.yml,.json}', GLOB_BRACE);
79
+ if (empty($candidates) === false) {
80
+ $configFile = $candidates[0];
81
+ }
82
+ }
83
+
84
+ $eslintOptions = array('--format json');
85
+ if (empty($configFile) === false) {
86
+ $eslintOptions[] = '--config '.escapeshellarg($configFile);
87
+ }
88
+
89
+ $cmd = escapeshellcmd(escapeshellarg($eslintPath).' '.implode(' ', $eslintOptions).' '.escapeshellarg($filename));
90
+
91
+ // Execute!
92
+ exec($cmd, $stdout, $code);
93
+
94
+ if ($code <= 0) {
95
+ // No errors, continue.
96
+ return ($phpcsFile->numTokens + 1);
97
+ }
98
+
99
+ $data = json_decode(implode("\n", $stdout));
100
+ if (json_last_error() !== JSON_ERROR_NONE) {
101
+ // Ignore any errors.
102
+ return ($phpcsFile->numTokens + 1);
103
+ }
104
+
105
+ // Data is a list of files, but we only pass a single one.
106
+ $messages = $data[0]->messages;
107
+ foreach ($messages as $error) {
108
+ if (empty($error->fatal) === false || $error->severity === 2) {
109
+ $phpcsFile->addErrorOnLine($error->message, $error->line, $error->ruleId);
110
+ } else {
111
+ $phpcsFile->addWarningOnLine($error->message, $error->line, $error->ruleId);
112
+ }
113
+ }
114
+
115
+ // Ignore the rest of the file.
116
+ return ($phpcsFile->numTokens + 1);
117
+
118
+ }//end process()
119
+
120
+
121
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Debug/JSHintSniff.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Debug_JSHintSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Alexander Wei§ <aweisswa@gmx.de>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_Debug_JSHintSniff.
18
+ *
19
+ * Runs jshint.js on the file.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Alexander Wei§ <aweisswa@gmx.de>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_Debug_JSHintSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+ /**
34
+ * A list of tokenizers this sniff supports.
35
+ *
36
+ * @var array
37
+ */
38
+ public $supportedTokenizers = array('JS');
39
+
40
+
41
+ /**
42
+ * Returns the token types that this sniff is interested in.
43
+ *
44
+ * @return int[]
45
+ */
46
+ public function register()
47
+ {
48
+ return array(T_OPEN_TAG);
49
+
50
+ }//end register()
51
+
52
+
53
+ /**
54
+ * Processes the tokens that this sniff is interested in.
55
+ *
56
+ * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
57
+ * @param int $stackPtr The position in the stack where
58
+ * the token was found.
59
+ *
60
+ * @return void
61
+ * @throws PHP_CodeSniffer_Exception If jshint.js could not be run
62
+ */
63
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
64
+ {
65
+ $fileName = $phpcsFile->getFilename();
66
+
67
+ $rhinoPath = PHP_CodeSniffer::getConfigData('rhino_path');
68
+ $jshintPath = PHP_CodeSniffer::getConfigData('jshint_path');
69
+ if ($rhinoPath === null || $jshintPath === null) {
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) {
80
+ foreach ($output as $finding) {
81
+ $matches = array();
82
+ $numMatches = preg_match('/^(.+)\(.+:([0-9]+).*:[0-9]+\)$/', $finding, $matches);
83
+ if ($numMatches === 0) {
84
+ continue;
85
+ }
86
+
87
+ $line = (int) $matches[2];
88
+ $message = 'jshint says: '.trim($matches[1]);
89
+ $phpcsFile->addWarningOnLine($message, $line, 'ExternalTool');
90
+ }
91
+ }
92
+
93
+ // Ignore the rest of the file.
94
+ return ($phpcsFile->numTokens + 1);
95
+
96
+ }//end process()
97
+
98
+
99
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/ByteOrderMarkSniff.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Files_ByteOrderMarkSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Files_ByteOrderMarkSniff.
17
+ *
18
+ * A simple sniff for detecting BOMs that may corrupt application work.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Piotr Karas <office@mediaself.pl>
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @copyright 2010-2014 mediaSELF Sp. z o.o.
25
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
26
+ * @version Release: @package_version@
27
+ * @link http://pear.php.net/package/PHP_CodeSniffer
28
+ * @see http://en.wikipedia.org/wiki/Byte_order_mark
29
+ */
30
+ class Generic_Sniffs_Files_ByteOrderMarkSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+ /**
34
+ * List of supported BOM definitions.
35
+ *
36
+ * Use encoding names as keys and hex BOM representations as values.
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
+ /**
48
+ * Returns an array of tokens this test wants to listen for.
49
+ *
50
+ * @return array
51
+ */
52
+ public function register()
53
+ {
54
+ return array(T_INLINE_HTML);
55
+
56
+ }//end register()
57
+
58
+
59
+ /**
60
+ * Processes this sniff, when one of its tokens is encountered.
61
+ *
62
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
63
+ * @param int $stackPtr The position of the current token in
64
+ * the stack passed in $tokens.
65
+ *
66
+ * @return void
67
+ */
68
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
69
+ {
70
+ // The BOM will be the very first token in the file.
71
+ if ($stackPtr !== 0) {
72
+ return;
73
+ }
74
+
75
+ $tokens = $phpcsFile->getTokens();
76
+
77
+ foreach ($this->bomDefinitions as $bomName => $expectedBomHex) {
78
+ $bomByteLength = (strlen($expectedBomHex) / 2);
79
+ $htmlBomHex = bin2hex(substr($tokens[$stackPtr]['content'], 0, $bomByteLength));
80
+ if ($htmlBomHex === $expectedBomHex) {
81
+ $errorData = array($bomName);
82
+ $error = 'File contains %s byte order mark, which may corrupt your application';
83
+ $phpcsFile->addError($error, $stackPtr, 'Found', $errorData);
84
+ $phpcsFile->recordMetric($stackPtr, 'Using byte order mark', 'yes');
85
+ return;
86
+ }
87
+ }
88
+
89
+ $phpcsFile->recordMetric($stackPtr, 'Using byte order mark', 'no');
90
+
91
+ }//end process()
92
+
93
+
94
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNewlineSniff.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Files_EndFileNewlineSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Files_EndFileNewlineSniff.
17
+ *
18
+ * Ensures the file ends with a newline character.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_Files_EndFileNewlineSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+ /**
32
+ * A list of tokenizers this sniff supports.
33
+ *
34
+ * @var array
35
+ */
36
+ public $supportedTokenizers = array(
37
+ 'PHP',
38
+ 'JS',
39
+ 'CSS',
40
+ );
41
+
42
+
43
+ /**
44
+ * Returns an array of tokens this test wants to listen for.
45
+ *
46
+ * @return array
47
+ */
48
+ public function register()
49
+ {
50
+ return array(T_OPEN_TAG);
51
+
52
+ }//end register()
53
+
54
+
55
+ /**
56
+ * Processes this sniff, when one of its tokens is encountered.
57
+ *
58
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
59
+ * @param int $stackPtr The position of the current token in
60
+ * the stack passed in $tokens.
61
+ *
62
+ * @return int
63
+ */
64
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
65
+ {
66
+ // Skip to the end of the file.
67
+ $tokens = $phpcsFile->getTokens();
68
+ $stackPtr = ($phpcsFile->numTokens - 1);
69
+
70
+ if ($tokens[$stackPtr]['content'] === '') {
71
+ $stackPtr--;
72
+ }
73
+
74
+ $eolCharLen = strlen($phpcsFile->eolChar);
75
+ $lastChars = substr($tokens[$stackPtr]['content'], ($eolCharLen * -1));
76
+ if ($lastChars !== $phpcsFile->eolChar) {
77
+ $phpcsFile->recordMetric($stackPtr, 'Newline at EOF', 'no');
78
+
79
+ $error = 'File must end with a newline character';
80
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NotFound');
81
+ if ($fix === true) {
82
+ $phpcsFile->fixer->addNewline($stackPtr);
83
+ }
84
+ } else {
85
+ $phpcsFile->recordMetric($stackPtr, 'Newline at EOF', 'yes');
86
+ }
87
+
88
+ // Ignore the rest of the file.
89
+ return ($phpcsFile->numTokens + 1);
90
+
91
+ }//end process()
92
+
93
+
94
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/EndFileNoNewlineSniff.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Files_EndFileNoNewlineSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Files_EndFileNoNewlineSniff.
17
+ *
18
+ * Ensures the file does not end with a newline character.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_Files_EndFileNoNewlineSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+ /**
32
+ * A list of tokenizers this sniff supports.
33
+ *
34
+ * @var array
35
+ */
36
+ public $supportedTokenizers = array(
37
+ 'PHP',
38
+ 'JS',
39
+ 'CSS',
40
+ );
41
+
42
+
43
+ /**
44
+ * Returns an array of tokens this test wants to listen for.
45
+ *
46
+ * @return array
47
+ */
48
+ public function register()
49
+ {
50
+ return array(T_OPEN_TAG);
51
+
52
+ }//end register()
53
+
54
+
55
+ /**
56
+ * Processes this sniff, when one of its tokens is encountered.
57
+ *
58
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
59
+ * @param int $stackPtr The position of the current token in
60
+ * the stack passed in $tokens.
61
+ *
62
+ * @return int
63
+ */
64
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
65
+ {
66
+ // Skip to the end of the file.
67
+ $tokens = $phpcsFile->getTokens();
68
+ $stackPtr = ($phpcsFile->numTokens - 1);
69
+
70
+ if ($tokens[$stackPtr]['content'] === '') {
71
+ $stackPtr--;
72
+ }
73
+
74
+ $eolCharLen = strlen($phpcsFile->eolChar);
75
+ $lastChars = substr($tokens[$stackPtr]['content'], ($eolCharLen * -1));
76
+ if ($lastChars === $phpcsFile->eolChar) {
77
+ $error = 'File must not end with a newline character';
78
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found');
79
+ if ($fix === true) {
80
+ $newContent = substr($tokens[$stackPtr]['content'], 0, ($eolCharLen * -1));
81
+ $phpcsFile->fixer->replaceToken($stackPtr, $newContent);
82
+ }
83
+ }
84
+
85
+ // Ignore the rest of the file.
86
+ return ($phpcsFile->numTokens + 1);
87
+
88
+ }//end process()
89
+
90
+
91
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/InlineHTMLSniff.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Files_InlineHTMLSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Files_InlineHTMLSniff.
17
+ *
18
+ * Ensures the whole file is PHP only, with no whitespace or inline HTML anywhere
19
+ * in the file.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
25
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
26
+ * @version Release: @package_version@
27
+ * @link http://pear.php.net/package/PHP_CodeSniffer
28
+ */
29
+ class Generic_Sniffs_Files_InlineHTMLSniff implements PHP_CodeSniffer_Sniff
30
+ {
31
+
32
+
33
+ /**
34
+ * Returns an array of tokens this test wants to listen for.
35
+ *
36
+ * @return array
37
+ */
38
+ public function register()
39
+ {
40
+ return array(T_INLINE_HTML);
41
+
42
+ }//end register()
43
+
44
+
45
+ /**
46
+ * Processes this test, when one of its tokens is encountered.
47
+ *
48
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
49
+ * @param int $stackPtr The position of the current token in
50
+ * the stack passed in $tokens.
51
+ *
52
+ * @return void
53
+ */
54
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
55
+ {
56
+ // Ignore shebang lines.
57
+ $tokens = $phpcsFile->getTokens();
58
+ if (substr($tokens[$stackPtr]['content'], 0, 2) === '#!') {
59
+ return;
60
+ }
61
+
62
+ $error = 'PHP files must only contain PHP code';
63
+ $phpcsFile->addError($error, $stackPtr, 'Found');
64
+
65
+ return $phpcsFile->numTokens;
66
+
67
+ }//end process()
68
+
69
+
70
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LineEndingsSniff.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Files_LineEndingsSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_Files_LineEndingsSniff.
18
+ *
19
+ * Checks that end of line characters are correct.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Marc McIntyre <mmcintyre@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_Files_LineEndingsSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+ /**
34
+ * A list of tokenizers this sniff supports.
35
+ *
36
+ * @var array
37
+ */
38
+ public $supportedTokenizers = array(
39
+ 'PHP',
40
+ 'JS',
41
+ 'CSS',
42
+ );
43
+
44
+ /**
45
+ * The valid EOL character.
46
+ *
47
+ * @var string
48
+ */
49
+ public $eolChar = '\n';
50
+
51
+
52
+ /**
53
+ * Returns an array of tokens this test wants to listen for.
54
+ *
55
+ * @return array
56
+ */
57
+ public function register()
58
+ {
59
+ return array(T_OPEN_TAG);
60
+
61
+ }//end register()
62
+
63
+
64
+ /**
65
+ * Processes this sniff, when one of its tokens is encountered.
66
+ *
67
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
68
+ * @param int $stackPtr The position of the current token in
69
+ * the stack passed in $tokens.
70
+ *
71
+ * @return int
72
+ */
73
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
74
+ {
75
+ $found = $phpcsFile->eolChar;
76
+ $found = str_replace("\n", '\n', $found);
77
+ $found = str_replace("\r", '\r', $found);
78
+
79
+ $phpcsFile->recordMetric($stackPtr, 'EOL char', $found);
80
+
81
+ if ($found === $this->eolChar) {
82
+ // Ignore the rest of the file.
83
+ return ($phpcsFile->numTokens + 1);
84
+ }
85
+
86
+ // Check for single line files without an EOL. This is a very special
87
+ // case and the EOL char is set to \n when this happens.
88
+ if ($found === '\n') {
89
+ $tokens = $phpcsFile->getTokens();
90
+ $lastToken = ($phpcsFile->numTokens - 1);
91
+ if ($tokens[$lastToken]['line'] === 1
92
+ && $tokens[$lastToken]['content'] !== "\n"
93
+ ) {
94
+ return;
95
+ }
96
+ }
97
+
98
+ $error = 'End of line character is invalid; expected "%s" but found "%s"';
99
+ $expected = $this->eolChar;
100
+ $expected = str_replace("\n", '\n', $expected);
101
+ $expected = str_replace("\r", '\r', $expected);
102
+ $data = array(
103
+ $expected,
104
+ $found,
105
+ );
106
+
107
+ // Errors are always reported on line 1, no matter where the first PHP tag is.
108
+ $fix = $phpcsFile->addFixableError($error, 0, 'InvalidEOLChar', $data);
109
+
110
+ if ($fix === true) {
111
+ $tokens = $phpcsFile->getTokens();
112
+ switch ($this->eolChar) {
113
+ case '\n':
114
+ $eolChar = "\n";
115
+ break;
116
+ case '\r':
117
+ $eolChar = "\r";
118
+ break;
119
+ case '\r\n':
120
+ $eolChar = "\r\n";
121
+ break;
122
+ default:
123
+ $eolChar = $this->eolChar;
124
+ break;
125
+ }
126
+
127
+ for ($i = 0; $i < $phpcsFile->numTokens; $i++) {
128
+ if (isset($tokens[($i + 1)]) === false
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
+ }
142
+ }
143
+ }//end if
144
+
145
+ // Ignore the rest of the file.
146
+ return ($phpcsFile->numTokens + 1);
147
+
148
+ }//end process()
149
+
150
+
151
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LineLengthSniff.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Files_LineLengthSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_Files_LineLengthSniff.
18
+ *
19
+ * Checks all lines in the file, and throws warnings if they are over 80
20
+ * characters in length and errors if they are over 100. Both these
21
+ * figures can be changed by extending this sniff in your own standard.
22
+ *
23
+ * @category PHP
24
+ * @package PHP_CodeSniffer
25
+ * @author Greg Sherwood <gsherwood@squiz.net>
26
+ * @author Marc McIntyre <mmcintyre@squiz.net>
27
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class Generic_Sniffs_Files_LineLengthSniff implements PHP_CodeSniffer_Sniff
33
+ {
34
+
35
+ /**
36
+ * The limit that the length of a line should not exceed.
37
+ *
38
+ * @var int
39
+ */
40
+ public $lineLimit = 80;
41
+
42
+ /**
43
+ * The limit that the length of a line must not exceed.
44
+ *
45
+ * Set to zero (0) to disable.
46
+ *
47
+ * @var int
48
+ */
49
+ public $absoluteLineLimit = 100;
50
+
51
+
52
+ /**
53
+ * Returns an array of tokens this test wants to listen for.
54
+ *
55
+ * @return array
56
+ */
57
+ public function register()
58
+ {
59
+ return array(T_OPEN_TAG);
60
+
61
+ }//end register()
62
+
63
+
64
+ /**
65
+ * Processes this test, when one of its tokens is encountered.
66
+ *
67
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
68
+ * @param int $stackPtr The position of the current token in
69
+ * the stack passed in $tokens.
70
+ *
71
+ * @return int
72
+ */
73
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
74
+ {
75
+ $tokens = $phpcsFile->getTokens();
76
+ for ($i = 1; $i < $phpcsFile->numTokens; $i++) {
77
+ if ($tokens[$i]['column'] === 1) {
78
+ $this->checkLineLength($phpcsFile, $tokens, $i);
79
+ }
80
+ }
81
+
82
+ $this->checkLineLength($phpcsFile, $tokens, $i);
83
+
84
+ // Ignore the rest of the file.
85
+ return ($phpcsFile->numTokens + 1);
86
+
87
+ }//end process()
88
+
89
+
90
+ /**
91
+ * Checks if a line is too long.
92
+ *
93
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
94
+ * @param array $tokens The token stack.
95
+ * @param int $stackPtr The first token on the next line.
96
+ *
97
+ * @return null|false
98
+ */
99
+ protected function checkLineLength(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr)
100
+ {
101
+ // The passed token is the first on the line.
102
+ $stackPtr--;
103
+
104
+ if ($tokens[$stackPtr]['column'] === 1
105
+ && $tokens[$stackPtr]['length'] === 0
106
+ ) {
107
+ // Blank line.
108
+ return;
109
+ }
110
+
111
+ if ($tokens[$stackPtr]['column'] !== 1
112
+ && $tokens[$stackPtr]['content'] === $phpcsFile->eolChar
113
+ ) {
114
+ $stackPtr--;
115
+ }
116
+
117
+ $lineLength = ($tokens[$stackPtr]['column'] + $tokens[$stackPtr]['length'] - 1);
118
+
119
+ // Record metrics for common line length groupings.
120
+ if ($lineLength <= 80) {
121
+ $phpcsFile->recordMetric($stackPtr, 'Line length', '80 or less');
122
+ } else if ($lineLength <= 120) {
123
+ $phpcsFile->recordMetric($stackPtr, 'Line length', '81-120');
124
+ } else if ($lineLength <= 150) {
125
+ $phpcsFile->recordMetric($stackPtr, 'Line length', '121-150');
126
+ } else {
127
+ $phpcsFile->recordMetric($stackPtr, 'Line length', '151 or more');
128
+ }
129
+
130
+ // If this is a long comment, check if it can be broken up onto multiple lines.
131
+ // Some comments contain unbreakable strings like URLs and so it makes sense
132
+ // to ignore the line length in these cases if the URL would be longer than the max
133
+ // line length once you indent it to the correct level.
134
+ if ($lineLength > $this->lineLimit
135
+ && ($tokens[$stackPtr]['code'] === T_COMMENT
136
+ || $tokens[$stackPtr]['code'] === T_DOC_COMMENT_STRING)
137
+ ) {
138
+ $oldLength = strlen($tokens[$stackPtr]['content']);
139
+ $newLength = strlen(ltrim($tokens[$stackPtr]['content'], "/#\t "));
140
+ $indent = (($tokens[$stackPtr]['column'] - 1) + ($oldLength - $newLength));
141
+
142
+ $nonBreakingLength = $tokens[$stackPtr]['length'];
143
+
144
+ $space = strrpos($tokens[$stackPtr]['content'], ' ');
145
+ if ($space !== false) {
146
+ $nonBreakingLength -= ($space + 1);
147
+ }
148
+
149
+ if (($nonBreakingLength + $indent) > $this->lineLimit) {
150
+ return;
151
+ }
152
+ }
153
+
154
+ if ($this->absoluteLineLimit > 0
155
+ && $lineLength > $this->absoluteLineLimit
156
+ ) {
157
+ $data = array(
158
+ $this->absoluteLineLimit,
159
+ $lineLength,
160
+ );
161
+
162
+ $error = 'Line exceeds maximum limit of %s characters; contains %s characters';
163
+ $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
164
+ } else if ($lineLength > $this->lineLimit) {
165
+ $data = array(
166
+ $this->lineLimit,
167
+ $lineLength,
168
+ );
169
+
170
+ $warning = 'Line exceeds %s characters; contains %s characters';
171
+ $phpcsFile->addWarning($warning, $stackPtr, 'TooLong', $data);
172
+ }
173
+
174
+ }//end checkLineLength()
175
+
176
+
177
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/LowercasedFilenameSniff.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Files_LowercasedFilenameSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Andy Grunwald <andygrunwald@gmail.com>
10
+ * @copyright 2010-2014 Andy Grunwald
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Checks that all file names are lowercased.
17
+ *
18
+ * @category PHP
19
+ * @package PHP_CodeSniffer
20
+ * @author Andy Grunwald <andygrunwald@gmail.com>
21
+ * @copyright 2010-2014 Andy Grunwald
22
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
23
+ * @version Release: @package_version@
24
+ * @link http://pear.php.net/package/PHP_CodeSniffer
25
+ */
26
+ class Generic_Sniffs_Files_LowercasedFilenameSniff implements PHP_CodeSniffer_Sniff
27
+ {
28
+
29
+
30
+ /**
31
+ * Returns an array of tokens this test wants to listen for.
32
+ *
33
+ * @return array
34
+ */
35
+ public function register()
36
+ {
37
+ return array(T_OPEN_TAG);
38
+
39
+ }//end register()
40
+
41
+
42
+ /**
43
+ * Processes this sniff, when one of its tokens is encountered.
44
+ *
45
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
+ * @param int $stackPtr The position of the current token in
47
+ * the stack passed in $tokens.
48
+ *
49
+ * @return int
50
+ */
51
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
+ {
53
+ $filename = $phpcsFile->getFilename();
54
+ if ($filename === 'STDIN') {
55
+ return;
56
+ }
57
+
58
+ $filename = basename($filename);
59
+ $lowercaseFilename = strtolower($filename);
60
+ if ($filename !== $lowercaseFilename) {
61
+ $data = array(
62
+ $filename,
63
+ $lowercaseFilename,
64
+ );
65
+ $error = 'Filename "%s" doesn\'t match the expected filename "%s"';
66
+ $phpcsFile->addError($error, $stackPtr, 'NotFound', $data);
67
+ $phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'no');
68
+ } else {
69
+ $phpcsFile->recordMetric($stackPtr, 'Lowercase filename', 'yes');
70
+ }
71
+
72
+ // Ignore the rest of the file.
73
+ return ($phpcsFile->numTokens + 1);
74
+
75
+ }//end process()
76
+
77
+
78
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/OneClassPerFileSniff.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Files_OneClassPerFileSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Andy Grunwald <andygrunwald@gmail.com>
10
+ * @copyright 2010-2014 Andy Grunwald
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Checks that only one class is declared per file.
17
+ *
18
+ * @category PHP
19
+ * @package PHP_CodeSniffer
20
+ * @author Andy Grunwald <andygrunwald@gmail.com>
21
+ * @copyright 2010-2014 Andy Grunwald
22
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
23
+ * @version Release: @package_version@
24
+ * @link http://pear.php.net/package/PHP_CodeSniffer
25
+ */
26
+ class Generic_Sniffs_Files_OneClassPerFileSniff implements PHP_CodeSniffer_Sniff
27
+ {
28
+
29
+
30
+ /**
31
+ * Returns an array of tokens this test wants to listen for.
32
+ *
33
+ * @return array
34
+ */
35
+ public function register()
36
+ {
37
+ return array(T_CLASS);
38
+
39
+ }//end register()
40
+
41
+
42
+ /**
43
+ * Processes this sniff, when one of its tokens is encountered.
44
+ *
45
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
+ * @param int $stackPtr The position of the current token in
47
+ * the stack passed in $tokens.
48
+ *
49
+ * @return void
50
+ */
51
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
+ {
53
+ $nextClass = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
54
+ if ($nextClass !== false) {
55
+ $error = 'Only one class is allowed in a file';
56
+ $phpcsFile->addError($error, $nextClass, 'MultipleFound');
57
+ }
58
+
59
+ }//end process()
60
+
61
+
62
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/OneInterfacePerFileSniff.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Files_OneInterfacePerFileSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Andy Grunwald <andygrunwald@gmail.com>
10
+ * @copyright 2010-2014 Andy Grunwald
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Checks that only one interface is declared per file.
17
+ *
18
+ * @category PHP
19
+ * @package PHP_CodeSniffer
20
+ * @author Andy Grunwald <andygrunwald@gmail.com>
21
+ * @copyright 2010-2014 Andy Grunwald
22
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
23
+ * @version Release: @package_version@
24
+ * @link http://pear.php.net/package/PHP_CodeSniffer
25
+ */
26
+ class Generic_Sniffs_Files_OneInterfacePerFileSniff implements PHP_CodeSniffer_Sniff
27
+ {
28
+
29
+
30
+ /**
31
+ * Returns an array of tokens this test wants to listen for.
32
+ *
33
+ * @return array
34
+ */
35
+ public function register()
36
+ {
37
+ return array(T_INTERFACE);
38
+
39
+ }//end register()
40
+
41
+
42
+ /**
43
+ * Processes this sniff, when one of its tokens is encountered.
44
+ *
45
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
+ * @param int $stackPtr The position of the current token in
47
+ * the stack passed in $tokens.
48
+ *
49
+ * @return void
50
+ */
51
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
+ {
53
+ $nextInterface = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
54
+ if ($nextInterface !== false) {
55
+ $error = 'Only one interface is allowed in a file';
56
+ $phpcsFile->addError($error, $nextInterface, 'MultipleFound');
57
+ }
58
+
59
+ }//end process()
60
+
61
+
62
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Files/OneTraitPerFileSniff.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Files_OneTraitPerFileSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Alexander Obuhovich <aik.bold@gmail.com>
10
+ * @copyright 2010-2014 Alexander Obuhovich
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Checks that only one trait is declared per file.
17
+ *
18
+ * @category PHP
19
+ * @package PHP_CodeSniffer
20
+ * @author Alexander Obuhovich <aik.bold@gmail.com>
21
+ * @copyright 2010-2014 Alexander Obuhovich
22
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
23
+ * @version Release: @package_version@
24
+ * @link http://pear.php.net/package/PHP_CodeSniffer
25
+ */
26
+ class Generic_Sniffs_Files_OneTraitPerFileSniff implements PHP_CodeSniffer_Sniff
27
+ {
28
+
29
+
30
+ /**
31
+ * Returns an array of tokens this test wants to listen for.
32
+ *
33
+ * @return array
34
+ */
35
+ public function register()
36
+ {
37
+ return array(T_TRAIT);
38
+
39
+ }//end register()
40
+
41
+
42
+ /**
43
+ * Processes this sniff, when one of its tokens is encountered.
44
+ *
45
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
+ * @param int $stackPtr The position of the current token in
47
+ * the stack passed in $tokens.
48
+ *
49
+ * @return void
50
+ */
51
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
+ {
53
+ $nextClass = $phpcsFile->findNext($this->register(), ($stackPtr + 1));
54
+ if ($nextClass !== false) {
55
+ $error = 'Only one trait is allowed in a file';
56
+ $phpcsFile->addError($error, $nextClass, 'MultipleFound');
57
+ }
58
+
59
+ }//end process()
60
+
61
+
62
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/DisallowMultipleStatementsSniff.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff.
17
+ *
18
+ * Ensures each statement is on a line by itself.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_Formatting_DisallowMultipleStatementsSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+
32
+ /**
33
+ * Returns an array of tokens this test wants to listen for.
34
+ *
35
+ * @return array
36
+ */
37
+ public function register()
38
+ {
39
+ return array(T_SEMICOLON);
40
+
41
+ }//end register()
42
+
43
+
44
+ /**
45
+ * Processes this test, when one of its tokens is encountered.
46
+ *
47
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
48
+ * @param int $stackPtr The position of the current token in
49
+ * the stack passed in $tokens.
50
+ *
51
+ * @return void
52
+ */
53
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
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
+ }
65
+
66
+ // Ignore multiple statements in a FOR condition.
67
+ if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
68
+ foreach ($tokens[$stackPtr]['nested_parenthesis'] as $bracket) {
69
+ if (isset($tokens[$bracket]['parenthesis_owner']) === false) {
70
+ // Probably a closure sitting inside a function call.
71
+ continue;
72
+ }
73
+
74
+ $owner = $tokens[$bracket]['parenthesis_owner'];
75
+ if ($tokens[$owner]['code'] === T_FOR) {
76
+ return;
77
+ }
78
+ }
79
+ }
80
+
81
+ if ($tokens[$prev]['line'] === $tokens[$stackPtr]['line']) {
82
+ $phpcsFile->recordMetric($stackPtr, 'Multiple statements on same line', 'yes');
83
+
84
+ $error = 'Each PHP statement must be on a line by itself';
85
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SameLine');
86
+ if ($fix === true) {
87
+ $phpcsFile->fixer->beginChangeset();
88
+ $phpcsFile->fixer->addNewline($prev);
89
+ if ($tokens[($prev + 1)]['code'] === T_WHITESPACE) {
90
+ $phpcsFile->fixer->replaceToken(($prev + 1), '');
91
+ }
92
+
93
+ $phpcsFile->fixer->endChangeset();
94
+ }
95
+ } else {
96
+ $phpcsFile->recordMetric($stackPtr, 'Multiple statements on same line', 'no');
97
+ }
98
+
99
+ }//end process()
100
+
101
+
102
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/MultipleStatementAlignmentSniff.php ADDED
@@ -0,0 +1,330 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff.
17
+ *
18
+ * Checks alignment of assignments. If there are multiple adjacent assignments,
19
+ * it will check that the equals signs of each assignment are aligned. It will
20
+ * display a warning to advise that the signs should be aligned.
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Greg Sherwood <gsherwood@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_Formatting_MultipleStatementAlignmentSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+ /**
34
+ * A list of tokenizers this sniff supports.
35
+ *
36
+ * @var array
37
+ */
38
+ public $supportedTokenizers = array(
39
+ 'PHP',
40
+ 'JS',
41
+ );
42
+
43
+ /**
44
+ * If true, an error will be thrown; otherwise a warning.
45
+ *
46
+ * @var bool
47
+ */
48
+ public $error = false;
49
+
50
+ /**
51
+ * The maximum amount of padding before the alignment is ignored.
52
+ *
53
+ * If the amount of padding required to align this assignment with the
54
+ * surrounding assignments exceeds this number, the assignment will be
55
+ * ignored and no errors or warnings will be thrown.
56
+ *
57
+ * @var int
58
+ */
59
+ public $maxPadding = 1000;
60
+
61
+
62
+ /**
63
+ * Returns an array of tokens this test wants to listen for.
64
+ *
65
+ * @return array
66
+ */
67
+ public function register()
68
+ {
69
+ $tokens = PHP_CodeSniffer_Tokens::$assignmentTokens;
70
+ unset($tokens[T_DOUBLE_ARROW]);
71
+ return $tokens;
72
+
73
+ }//end register()
74
+
75
+
76
+ /**
77
+ * Processes this test, when one of its tokens is encountered.
78
+ *
79
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
80
+ * @param int $stackPtr The position of the current token
81
+ * in the stack passed in $tokens.
82
+ *
83
+ * @return int
84
+ */
85
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
86
+ {
87
+ $tokens = $phpcsFile->getTokens();
88
+
89
+ // Ignore assignments used in a condition, like an IF or FOR.
90
+ if (isset($tokens[$stackPtr]['nested_parenthesis']) === true) {
91
+ foreach ($tokens[$stackPtr]['nested_parenthesis'] as $start => $end) {
92
+ if (isset($tokens[$start]['parenthesis_owner']) === true) {
93
+ return;
94
+ }
95
+ }
96
+ }
97
+
98
+ $lastAssign = $this->checkAlignment($phpcsFile, $stackPtr);
99
+ return ($lastAssign + 1);
100
+
101
+ }//end process()
102
+
103
+
104
+ /**
105
+ * Processes this test, when one of its tokens is encountered.
106
+ *
107
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
108
+ * @param int $stackPtr The position of the current token
109
+ * in the stack passed in $tokens.
110
+ *
111
+ * @return int
112
+ */
113
+ public function checkAlignment(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
114
+ {
115
+ $tokens = $phpcsFile->getTokens();
116
+
117
+ $assignments = array();
118
+ $prevAssign = null;
119
+ $lastLine = $tokens[$stackPtr]['line'];
120
+ $maxPadding = null;
121
+ $stopped = null;
122
+ $lastCode = $stackPtr;
123
+ $lastSemi = null;
124
+
125
+ $find = PHP_CodeSniffer_Tokens::$assignmentTokens;
126
+ unset($find[T_DOUBLE_ARROW]);
127
+
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
+ }
135
+
136
+ $lastCode = $assign;
137
+
138
+ if ($tokens[$assign]['code'] === T_SEMICOLON) {
139
+ if ($tokens[$assign]['conditions'] === $tokens[$stackPtr]['conditions']) {
140
+ if ($lastSemi !== null && $prevAssign !== null && $lastSemi > $prevAssign) {
141
+ // This statement did not have an assignment operator in it.
142
+ break;
143
+ } else {
144
+ $lastSemi = $assign;
145
+ }
146
+ } else {
147
+ // Statement is in a different context, so the block is over.
148
+ break;
149
+ }
150
+ }
151
+ }//end if
152
+
153
+ continue;
154
+ } else if ($assign !== $stackPtr && $tokens[$assign]['line'] === $lastLine) {
155
+ // Skip multiple assignments on the same line. We only need to
156
+ // try and align the first assignment.
157
+ continue;
158
+ }//end if
159
+
160
+ if ($assign !== $stackPtr) {
161
+ // Has to be nested inside the same conditions as the first assignment.
162
+ if ($tokens[$assign]['conditions'] !== $tokens[$stackPtr]['conditions']) {
163
+ break;
164
+ }
165
+
166
+ // Make sure it is not assigned inside a condition (eg. IF, FOR).
167
+ if (isset($tokens[$assign]['nested_parenthesis']) === true) {
168
+ foreach ($tokens[$assign]['nested_parenthesis'] as $start => $end) {
169
+ if (isset($tokens[$start]['parenthesis_owner']) === true) {
170
+ break(2);
171
+ }
172
+ }
173
+ }
174
+ }//end if
175
+
176
+ $var = $phpcsFile->findPrevious(
177
+ PHP_CodeSniffer_Tokens::$emptyTokens,
178
+ ($assign - 1),
179
+ null,
180
+ true
181
+ );
182
+
183
+ // Make sure we wouldn't break our max padding length if we
184
+ // aligned with this statement, or they wouldn't break the max
185
+ // padding length if they aligned with us.
186
+ $varEnd = $tokens[($var + 1)]['column'];
187
+ $assignLen = $tokens[$assign]['length'];
188
+ if ($assign !== $stackPtr) {
189
+ if (($varEnd + 1) > $assignments[$prevAssign]['assign_col']) {
190
+ $padding = 1;
191
+ $assignColumn = ($varEnd + 1);
192
+ } else {
193
+ $padding = ($assignments[$prevAssign]['assign_col'] - $varEnd + $assignments[$prevAssign]['assign_len'] - $assignLen);
194
+ if ($padding === 0) {
195
+ $padding = 1;
196
+ }
197
+
198
+ if ($padding > $this->maxPadding) {
199
+ $stopped = $assign;
200
+ break;
201
+ }
202
+
203
+ $assignColumn = ($varEnd + $padding);
204
+ }//end if
205
+
206
+ if (($assignColumn + $assignLen) > ($assignments[$maxPadding]['assign_col'] + $assignments[$maxPadding]['assign_len'])) {
207
+ $newPadding = ($varEnd - $assignments[$maxPadding]['var_end'] + $assignLen - $assignments[$maxPadding]['assign_len'] + 1);
208
+ if ($newPadding > $this->maxPadding) {
209
+ $stopped = $assign;
210
+ break;
211
+ } else {
212
+ // New alignment settings for previous assignments.
213
+ foreach ($assignments as $i => $data) {
214
+ if ($i === $assign) {
215
+ break;
216
+ }
217
+
218
+ $newPadding = ($varEnd - $data['var_end'] + $assignLen - $data['assign_len'] + 1);
219
+ $assignments[$i]['expected'] = $newPadding;
220
+ $assignments[$i]['assign_col'] = ($data['var_end'] + $newPadding);
221
+ }
222
+
223
+ $padding = 1;
224
+ $assignColumn = ($varEnd + 1);
225
+ }
226
+ } else if ($padding > $assignments[$maxPadding]['expected']) {
227
+ $maxPadding = $assign;
228
+ }//end if
229
+ } else {
230
+ $padding = 1;
231
+ $assignColumn = ($varEnd + 1);
232
+ $maxPadding = $assign;
233
+ }//end if
234
+
235
+ $found = 0;
236
+ if ($tokens[($var + 1)]['code'] === T_WHITESPACE) {
237
+ $found = $tokens[($var + 1)]['length'];
238
+ if ($found === 0) {
239
+ // This means a newline was found.
240
+ $found = 1;
241
+ }
242
+ }
243
+
244
+ $assignments[$assign] = array(
245
+ 'var_end' => $varEnd,
246
+ 'assign_len' => $assignLen,
247
+ 'assign_col' => $assignColumn,
248
+ 'expected' => $padding,
249
+ 'found' => $found,
250
+ );
251
+
252
+ $lastLine = $tokens[$assign]['line'];
253
+ $prevAssign = $assign;
254
+ }//end for
255
+
256
+ if (empty($assignments) === true) {
257
+ return $stackPtr;
258
+ }
259
+
260
+ $numAssignments = count($assignments);
261
+
262
+ $errorGenerated = false;
263
+ foreach ($assignments as $assignment => $data) {
264
+ if ($data['found'] === $data['expected']) {
265
+ continue;
266
+ }
267
+
268
+ $expectedText = $data['expected'].' space';
269
+ if ($data['expected'] !== 1) {
270
+ $expectedText .= 's';
271
+ }
272
+
273
+ if ($data['found'] === null) {
274
+ $foundText = 'a new line';
275
+ } else {
276
+ $foundText = $data['found'].' space';
277
+ if ($data['found'] !== 1) {
278
+ $foundText .= 's';
279
+ }
280
+ }
281
+
282
+ if ($numAssignments === 1) {
283
+ $type = 'Incorrect';
284
+ $error = 'Equals sign not aligned correctly; expected %s but found %s';
285
+ } else {
286
+ $type = 'NotSame';
287
+ $error = 'Equals sign not aligned with surrounding assignments; expected %s but found %s';
288
+ }
289
+
290
+ $errorData = array(
291
+ $expectedText,
292
+ $foundText,
293
+ );
294
+
295
+ if ($this->error === true) {
296
+ $fix = $phpcsFile->addFixableError($error, $assignment, $type, $errorData);
297
+ } else {
298
+ $fix = $phpcsFile->addFixableWarning($error, $assignment, $type.'Warning', $errorData);
299
+ }
300
+
301
+ $errorGenerated = true;
302
+
303
+ if ($fix === true && $data['found'] !== null) {
304
+ $newContent = str_repeat(' ', $data['expected']);
305
+ if ($data['found'] === 0) {
306
+ $phpcsFile->fixer->addContentBefore($assignment, $newContent);
307
+ } else {
308
+ $phpcsFile->fixer->replaceToken(($assignment - 1), $newContent);
309
+ }
310
+ }
311
+ }//end foreach
312
+
313
+ if ($numAssignments > 1) {
314
+ if ($errorGenerated === true) {
315
+ $phpcsFile->recordMetric($stackPtr, 'Adjacent assignments aligned', 'no');
316
+ } else {
317
+ $phpcsFile->recordMetric($stackPtr, 'Adjacent assignments aligned', 'yes');
318
+ }
319
+ }
320
+
321
+ if ($stopped !== null) {
322
+ return $this->checkAlignment($phpcsFile, $stopped);
323
+ } else {
324
+ return $assignment;
325
+ }
326
+
327
+ }//end checkAlignment()
328
+
329
+
330
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/NoSpaceAfterCastSniff.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Formatting_NoSpaceAfterCastSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_Formatting_NoSpaceAfterCastSniff.
18
+ *
19
+ * Ensures there is no space after cast tokens.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Marc McIntyre <mmcintyre@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_Formatting_NoSpaceAfterCastSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+
34
+ /**
35
+ * Returns an array of tokens this test wants to listen for.
36
+ *
37
+ * @return array
38
+ */
39
+ public function register()
40
+ {
41
+ return PHP_CodeSniffer_Tokens::$castTokens;
42
+
43
+ }//end register()
44
+
45
+
46
+ /**
47
+ * Processes this test, when one of its tokens is encountered.
48
+ *
49
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
50
+ * @param int $stackPtr The position of the current token in
51
+ * the stack passed in $tokens.
52
+ *
53
+ * @return void
54
+ */
55
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
+ {
57
+ $tokens = $phpcsFile->getTokens();
58
+
59
+ if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
60
+ return;
61
+ }
62
+
63
+ $error = 'A cast statement must not be followed by a space';
64
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'SpaceFound');
65
+ if ($fix === true) {
66
+ $phpcsFile->fixer->replaceToken(($stackPtr + 1), '');
67
+ }
68
+
69
+ }//end process()
70
+
71
+
72
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterCastSniff.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Formatting_SpaceAfterCastSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_Formatting_SpaceAfterCastSniff.
18
+ *
19
+ * Ensures there is a single space after cast tokens.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Marc McIntyre <mmcintyre@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_Formatting_SpaceAfterCastSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+
34
+ /**
35
+ * Returns an array of tokens this test wants to listen for.
36
+ *
37
+ * @return array
38
+ */
39
+ public function register()
40
+ {
41
+ return PHP_CodeSniffer_Tokens::$castTokens;
42
+
43
+ }//end register()
44
+
45
+
46
+ /**
47
+ * Processes this test, when one of its tokens is encountered.
48
+ *
49
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
50
+ * @param int $stackPtr The position of the current token in
51
+ * the stack passed in $tokens.
52
+ *
53
+ * @return void
54
+ */
55
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
+ {
57
+ $tokens = $phpcsFile->getTokens();
58
+
59
+ if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
60
+ $error = 'A cast statement must be followed by a single space';
61
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'NoSpace');
62
+ if ($fix === true) {
63
+ $phpcsFile->fixer->addContent($stackPtr, ' ');
64
+ }
65
+
66
+ $phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', 0);
67
+ return;
68
+ }
69
+
70
+ $phpcsFile->recordMetric($stackPtr, 'Spacing after cast statement', $tokens[($stackPtr + 1)]['length']);
71
+
72
+ if ($tokens[($stackPtr + 1)]['length'] !== 1) {
73
+ $error = 'A cast statement must be followed by a single space';
74
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'TooMuchSpace');
75
+ if ($fix === true) {
76
+ $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
77
+ }
78
+ }
79
+
80
+ }//end process()
81
+
82
+
83
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Formatting/SpaceAfterNotSniff.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Formatting_SpaceAfterNotSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Formatting_SpaceAfterNotSniff.
17
+ *
18
+ * Ensures there is a single space after a NOT operator.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_Formatting_SpaceAfterNotSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+ /**
32
+ * A list of tokenizers this sniff supports.
33
+ *
34
+ * @var array
35
+ */
36
+ public $supportedTokenizers = array(
37
+ 'PHP',
38
+ 'JS',
39
+ );
40
+
41
+
42
+ /**
43
+ * Returns an array of tokens this test wants to listen for.
44
+ *
45
+ * @return array
46
+ */
47
+ public function register()
48
+ {
49
+ return array(T_BOOLEAN_NOT);
50
+
51
+ }//end register()
52
+
53
+
54
+ /**
55
+ * Processes this test, when one of its tokens is encountered.
56
+ *
57
+ * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document.
58
+ * @param int $stackPtr The position of the current token in
59
+ * the stack passed in $tokens.
60
+ *
61
+ * @return void
62
+ */
63
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
64
+ {
65
+ $tokens = $phpcsFile->getTokens();
66
+
67
+ $spacing = 0;
68
+ if ($tokens[($stackPtr + 1)]['code'] === T_WHITESPACE) {
69
+ $spacing = $tokens[($stackPtr + 1)]['length'];
70
+ }
71
+
72
+ if ($spacing === 1) {
73
+ return;
74
+ }
75
+
76
+ $message = 'There must be a single space after a NOT operator; %s found';
77
+ $fix = $phpcsFile->addFixableError($message, $stackPtr, 'Incorrect', array($spacing));
78
+
79
+ if ($fix === true) {
80
+ if ($spacing === 0) {
81
+ $phpcsFile->fixer->addContent($stackPtr, ' ');
82
+ } else {
83
+ $phpcsFile->fixer->replaceToken(($stackPtr + 1), ' ');
84
+ }
85
+ }
86
+
87
+ }//end process()
88
+
89
+
90
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/CallTimePassByReferenceSniff.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Functions_CallTimePassByReferenceSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Florian Grandel <jerico.dev@gmail.com>
10
+ * @copyright 2009-2014 Florian Grandel
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Functions_CallTimePassByReferenceSniff.
17
+ *
18
+ * Ensures that variables are not passed by reference when calling a function.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Florian Grandel <jerico.dev@gmail.com>
23
+ * @copyright 2009-2014 Florian Grandel
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_Functions_CallTimePassByReferenceSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+
32
+ /**
33
+ * Returns an array of tokens this test wants to listen for.
34
+ *
35
+ * @return array
36
+ */
37
+ public function register()
38
+ {
39
+ return array(
40
+ T_STRING,
41
+ T_VARIABLE,
42
+ );
43
+
44
+ }//end register()
45
+
46
+
47
+ /**
48
+ * Processes this test, when one of its tokens is encountered.
49
+ *
50
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
51
+ * @param int $stackPtr The position of the current token
52
+ * in the stack passed in $tokens.
53
+ *
54
+ * @return void
55
+ */
56
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
57
+ {
58
+ $tokens = $phpcsFile->getTokens();
59
+
60
+ $findTokens = array_merge(
61
+ PHP_CodeSniffer_Tokens::$emptyTokens,
62
+ array(T_BITWISE_AND)
63
+ );
64
+
65
+ $prev = $phpcsFile->findPrevious($findTokens, ($stackPtr - 1), null, true);
66
+
67
+ // Skip tokens that are the names of functions or classes
68
+ // within their definitions. For example: function myFunction...
69
+ // "myFunction" is T_STRING but we should skip because it is not a
70
+ // function or method *call*.
71
+ $prevCode = $tokens[$prev]['code'];
72
+ if ($prevCode === T_FUNCTION || $prevCode === T_CLASS) {
73
+ return;
74
+ }
75
+
76
+ // If the next non-whitespace token after the function or method call
77
+ // is not an opening parenthesis then it cant really be a *call*.
78
+ $functionName = $stackPtr;
79
+ $openBracket = $phpcsFile->findNext(
80
+ PHP_CodeSniffer_Tokens::$emptyTokens,
81
+ ($functionName + 1),
82
+ null,
83
+ true
84
+ );
85
+
86
+ if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
87
+ return;
88
+ }
89
+
90
+ if (isset($tokens[$openBracket]['parenthesis_closer']) === false) {
91
+ return;
92
+ }
93
+
94
+ $closeBracket = $tokens[$openBracket]['parenthesis_closer'];
95
+
96
+ $nextSeparator = $openBracket;
97
+ $find = array(
98
+ T_VARIABLE,
99
+ T_OPEN_SHORT_ARRAY,
100
+ );
101
+
102
+ while (($nextSeparator = $phpcsFile->findNext($find, ($nextSeparator + 1), $closeBracket)) !== false) {
103
+ if (isset($tokens[$nextSeparator]['nested_parenthesis']) === false) {
104
+ continue;
105
+ }
106
+
107
+ if ($tokens[$nextSeparator]['code'] === T_OPEN_SHORT_ARRAY) {
108
+ $nextSeparator = $tokens[$nextSeparator]['bracket_closer'];
109
+ continue;
110
+ }
111
+
112
+ // Make sure the variable belongs directly to this function call
113
+ // and is not inside a nested function call or array.
114
+ $brackets = $tokens[$nextSeparator]['nested_parenthesis'];
115
+ $lastBracket = array_pop($brackets);
116
+ if ($lastBracket !== $closeBracket) {
117
+ continue;
118
+ }
119
+
120
+ // Checking this: $value = my_function(...[*]$arg...).
121
+ $tokenBefore = $phpcsFile->findPrevious(
122
+ PHP_CodeSniffer_Tokens::$emptyTokens,
123
+ ($nextSeparator - 1),
124
+ null,
125
+ true
126
+ );
127
+
128
+ if ($tokens[$tokenBefore]['code'] === T_BITWISE_AND) {
129
+ // Checking this: $value = my_function(...[*]&$arg...).
130
+ $tokenBefore = $phpcsFile->findPrevious(
131
+ PHP_CodeSniffer_Tokens::$emptyTokens,
132
+ ($tokenBefore - 1),
133
+ null,
134
+ true
135
+ );
136
+
137
+ // We have to exclude all uses of T_BITWISE_AND that are not
138
+ // references. We use a blacklist approach as we prefer false
139
+ // positives to not identifying a pass-by-reference call at all.
140
+ $tokenCode = $tokens[$tokenBefore]['code'];
141
+ if ($tokenCode === T_VARIABLE
142
+ || $tokenCode === T_CLOSE_PARENTHESIS
143
+ || $tokenCode === T_CLOSE_SQUARE_BRACKET
144
+ || $tokenCode === T_LNUMBER
145
+ || isset(PHP_CodeSniffer_Tokens::$assignmentTokens[$tokenCode]) === true
146
+ ) {
147
+ continue;
148
+ }
149
+
150
+ // T_BITWISE_AND represents a pass-by-reference.
151
+ $error = 'Call-time pass-by-reference calls are prohibited';
152
+ $phpcsFile->addError($error, $tokenBefore, 'NotAllowed');
153
+ }//end if
154
+ }//end while
155
+
156
+ }//end process()
157
+
158
+
159
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/FunctionCallArgumentSpacingSniff.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff.
18
+ *
19
+ * Checks that calls to methods and functions are spaced correctly.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Marc McIntyre <mmcintyre@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_Functions_FunctionCallArgumentSpacingSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+
34
+ /**
35
+ * Returns an array of tokens this test wants to listen for.
36
+ *
37
+ * @return array
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
+
50
+
51
+ /**
52
+ * Processes this test, when one of its tokens is encountered.
53
+ *
54
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
55
+ * @param int $stackPtr The position of the current token in the
56
+ * stack passed in $tokens.
57
+ *
58
+ * @return void
59
+ */
60
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
61
+ {
62
+ $tokens = $phpcsFile->getTokens();
63
+
64
+ // Skip tokens that are the names of functions or classes
65
+ // within their definitions. For example:
66
+ // function myFunction...
67
+ // "myFunction" is T_STRING but we should skip because it is not a
68
+ // function or method *call*.
69
+ $functionName = $stackPtr;
70
+ $ignoreTokens = PHP_CodeSniffer_Tokens::$emptyTokens;
71
+ $ignoreTokens[] = T_BITWISE_AND;
72
+ $functionKeyword = $phpcsFile->findPrevious($ignoreTokens, ($stackPtr - 1), null, true);
73
+ if ($tokens[$functionKeyword]['code'] === T_FUNCTION || $tokens[$functionKeyword]['code'] === T_CLASS) {
74
+ return;
75
+ }
76
+
77
+ // If the next non-whitespace token after the function or method call
78
+ // is not an opening parenthesis then it cant really be a *call*.
79
+ $openBracket = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($functionName + 1), null, true);
80
+ if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
81
+ return;
82
+ }
83
+
84
+ if (isset($tokens[$openBracket]['parenthesis_closer']) === false) {
85
+ return;
86
+ }
87
+
88
+ $closeBracket = $tokens[$openBracket]['parenthesis_closer'];
89
+ $nextSeparator = $openBracket;
90
+
91
+ $find = array(
92
+ T_COMMA,
93
+ T_VARIABLE,
94
+ T_CLOSURE,
95
+ T_OPEN_SHORT_ARRAY,
96
+ );
97
+
98
+ while (($nextSeparator = $phpcsFile->findNext($find, ($nextSeparator + 1), $closeBracket)) !== false) {
99
+ if ($tokens[$nextSeparator]['code'] === T_CLOSURE) {
100
+ // Skip closures.
101
+ $nextSeparator = $tokens[$nextSeparator]['scope_closer'];
102
+ continue;
103
+ } else if ($tokens[$nextSeparator]['code'] === T_OPEN_SHORT_ARRAY) {
104
+ // Skips arrays using short notation.
105
+ $nextSeparator = $tokens[$nextSeparator]['bracket_closer'];
106
+ continue;
107
+ }
108
+
109
+ // Make sure the comma or variable belongs directly to this function call,
110
+ // and is not inside a nested function call or array.
111
+ $brackets = $tokens[$nextSeparator]['nested_parenthesis'];
112
+ $lastBracket = array_pop($brackets);
113
+ if ($lastBracket !== $closeBracket) {
114
+ continue;
115
+ }
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) {
124
+ $phpcsFile->fixer->replaceToken(($nextSeparator - 1), '');
125
+ }
126
+ }
127
+ }
128
+
129
+ if ($tokens[($nextSeparator + 1)]['code'] !== T_WHITESPACE) {
130
+ $error = 'No space found after comma in function call';
131
+ $fix = $phpcsFile->addFixableError($error, $nextSeparator, 'NoSpaceAfterComma');
132
+ if ($fix === true) {
133
+ $phpcsFile->fixer->addContent($nextSeparator, ' ');
134
+ }
135
+ } else {
136
+ // If there is a newline in the space, then they must be formatting
137
+ // each argument on a newline, which is valid, so ignore it.
138
+ $next = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextSeparator + 1), null, true);
139
+ if ($tokens[$next]['line'] === $tokens[$nextSeparator]['line']) {
140
+ $space = strlen($tokens[($nextSeparator + 1)]['content']);
141
+ if ($space > 1) {
142
+ $error = 'Expected 1 space after comma in function call; %s found';
143
+ $data = array($space);
144
+ $fix = $phpcsFile->addFixableError($error, $nextSeparator, 'TooMuchSpaceAfterComma', $data);
145
+ if ($fix === true) {
146
+ $phpcsFile->fixer->replaceToken(($nextSeparator + 1), ' ');
147
+ }
148
+ }
149
+ }
150
+ }//end if
151
+ } else {
152
+ // Token is a variable.
153
+ $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextSeparator + 1), $closeBracket, true);
154
+ if ($nextToken !== false) {
155
+ if ($tokens[$nextToken]['code'] === T_EQUAL) {
156
+ if (($tokens[($nextToken - 1)]['code']) !== T_WHITESPACE) {
157
+ $error = 'Expected 1 space before = sign of default value';
158
+ $fix = $phpcsFile->addFixableError($error, $nextToken, 'NoSpaceBeforeEquals');
159
+ if ($fix === true) {
160
+ $phpcsFile->fixer->addContentBefore($nextToken, ' ');
161
+ }
162
+ }
163
+
164
+ if ($tokens[($nextToken + 1)]['code'] !== T_WHITESPACE) {
165
+ $error = 'Expected 1 space after = sign of default value';
166
+ $fix = $phpcsFile->addFixableError($error, $nextToken, 'NoSpaceAfterEquals');
167
+ if ($fix === true) {
168
+ $phpcsFile->fixer->addContent($nextToken, ' ');
169
+ }
170
+ }
171
+ }
172
+ }
173
+ }//end if
174
+ }//end while
175
+
176
+ }//end process()
177
+
178
+
179
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceBsdAllmanSniff.php ADDED
@@ -0,0 +1,191 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Methods_OpeningMethodBraceBsdAllmanSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff.
18
+ *
19
+ * Checks that the opening brace of a function is on the line after the
20
+ * function declaration.
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Greg Sherwood <gsherwood@squiz.net>
25
+ * @author Marc McIntyre <mmcintyre@squiz.net>
26
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
27
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
28
+ * @version Release: @package_version@
29
+ * @link http://pear.php.net/package/PHP_CodeSniffer
30
+ */
31
+ class Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff implements PHP_CodeSniffer_Sniff
32
+ {
33
+
34
+ /**
35
+ * Should this sniff check function braces?
36
+ *
37
+ * @var bool
38
+ */
39
+ public $checkFunctions = true;
40
+
41
+ /**
42
+ * Should this sniff check closure braces?
43
+ *
44
+ * @var bool
45
+ */
46
+ public $checkClosures = false;
47
+
48
+
49
+ /**
50
+ * Registers the tokens that this sniff wants to listen for.
51
+ *
52
+ * @return void
53
+ */
54
+ public function register()
55
+ {
56
+ return array(
57
+ T_FUNCTION,
58
+ T_CLOSURE,
59
+ );
60
+
61
+ }//end register()
62
+
63
+
64
+ /**
65
+ * Processes this test, when one of its tokens is encountered.
66
+ *
67
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
68
+ * @param int $stackPtr The position of the current token in the
69
+ * stack passed in $tokens.
70
+ *
71
+ * @return void
72
+ */
73
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
74
+ {
75
+ $tokens = $phpcsFile->getTokens();
76
+
77
+ if (isset($tokens[$stackPtr]['scope_opener']) === false) {
78
+ return;
79
+ }
80
+
81
+ if (($tokens[$stackPtr]['code'] === T_FUNCTION
82
+ && (bool) $this->checkFunctions === false)
83
+ || ($tokens[$stackPtr]['code'] === T_CLOSURE
84
+ && (bool) $this->checkClosures === false)
85
+ ) {
86
+ return;
87
+ }
88
+
89
+ $openingBrace = $tokens[$stackPtr]['scope_opener'];
90
+ $closeBracket = $tokens[$stackPtr]['parenthesis_closer'];
91
+ if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
92
+ $use = $phpcsFile->findNext(T_USE, ($closeBracket + 1), $tokens[$stackPtr]['scope_opener']);
93
+ if ($use !== false) {
94
+ $openBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1));
95
+ $closeBracket = $tokens[$openBracket]['parenthesis_closer'];
96
+ }
97
+ }
98
+
99
+ $functionLine = $tokens[$closeBracket]['line'];
100
+ $braceLine = $tokens[$openingBrace]['line'];
101
+
102
+ $lineDifference = ($braceLine - $functionLine);
103
+
104
+ if ($lineDifference === 0) {
105
+ $error = 'Opening brace should be on a new line';
106
+ $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceOnSameLine');
107
+ if ($fix === true) {
108
+ $phpcsFile->fixer->beginChangeset();
109
+ $indent = $phpcsFile->findFirstOnLine(array(), $openingBrace);
110
+ if ($tokens[$indent]['code'] === T_WHITESPACE) {
111
+ $phpcsFile->fixer->addContentBefore($openingBrace, $tokens[$indent]['content']);
112
+ }
113
+
114
+ $phpcsFile->fixer->addNewlineBefore($openingBrace);
115
+ $phpcsFile->fixer->endChangeset();
116
+ }
117
+
118
+ $phpcsFile->recordMetric($stackPtr, 'Function opening brace placement', 'same line');
119
+ } else if ($lineDifference > 1) {
120
+ $error = 'Opening brace should be on the line after the declaration; found %s blank line(s)';
121
+ $data = array(($lineDifference - 1));
122
+ $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceSpacing', $data);
123
+ if ($fix === true) {
124
+ for ($i = ($tokens[$stackPtr]['parenthesis_closer'] + 1); $i < $openingBrace; $i++) {
125
+ if ($tokens[$i]['line'] === $braceLine) {
126
+ $phpcsFile->fixer->addNewLineBefore($i);
127
+ break;
128
+ }
129
+
130
+ $phpcsFile->fixer->replaceToken($i, '');
131
+ }
132
+ }
133
+ }//end if
134
+
135
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($openingBrace + 1), null, true);
136
+ if ($tokens[$next]['line'] === $tokens[$openingBrace]['line']) {
137
+ if ($next === $tokens[$stackPtr]['scope_closer']) {
138
+ // Ignore empty functions.
139
+ return;
140
+ }
141
+
142
+ $error = 'Opening brace must be the last content on the line';
143
+ $fix = $phpcsFile->addFixableError($error, $openingBrace, 'ContentAfterBrace');
144
+ if ($fix === true) {
145
+ $phpcsFile->fixer->addNewline($openingBrace);
146
+ }
147
+ }
148
+
149
+ // Only continue checking if the opening brace looks good.
150
+ if ($lineDifference !== 1) {
151
+ return;
152
+ }
153
+
154
+ // We need to actually find the first piece of content on this line,
155
+ // as if this is a method with tokens before it (public, static etc)
156
+ // or an if with an else before it, then we need to start the scope
157
+ // checking from there, rather than the current token.
158
+ $lineStart = $phpcsFile->findFirstOnLine(T_WHITESPACE, $stackPtr, true);
159
+
160
+ // The opening brace is on the correct line, now it needs to be
161
+ // checked to be correctly indented.
162
+ $startColumn = $tokens[$lineStart]['column'];
163
+ $braceIndent = $tokens[$openingBrace]['column'];
164
+
165
+ if ($braceIndent !== $startColumn) {
166
+ $expected = ($startColumn - 1);
167
+ $found = ($braceIndent - 1);
168
+
169
+ $error = 'Opening brace indented incorrectly; expected %s spaces, found %s';
170
+ $data = array(
171
+ $expected,
172
+ $found,
173
+ );
174
+
175
+ $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceIndent', $data);
176
+ if ($fix === true) {
177
+ $indent = str_repeat(' ', $expected);
178
+ if ($found === 0) {
179
+ $phpcsFile->fixer->addContentBefore($openingBrace, $indent);
180
+ } else {
181
+ $phpcsFile->fixer->replaceToken(($openingBrace - 1), $indent);
182
+ }
183
+ }
184
+ }//end if
185
+
186
+ $phpcsFile->recordMetric($stackPtr, 'Function opening brace placement', 'new line');
187
+
188
+ }//end process()
189
+
190
+
191
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Functions/OpeningFunctionBraceKernighanRitchieSniff.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff.
18
+ *
19
+ * Checks that the opening brace of a function is on the same line
20
+ * as the function declaration.
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Greg Sherwood <gsherwood@squiz.net>
25
+ * @author Marc McIntyre <mmcintyre@squiz.net>
26
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
27
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
28
+ * @version Release: @package_version@
29
+ * @link http://pear.php.net/package/PHP_CodeSniffer
30
+ */
31
+ class Generic_Sniffs_Functions_OpeningFunctionBraceKernighanRitchieSniff implements PHP_CodeSniffer_Sniff
32
+ {
33
+
34
+
35
+ /**
36
+ * Should this sniff check function braces?
37
+ *
38
+ * @var bool
39
+ */
40
+ public $checkFunctions = true;
41
+
42
+ /**
43
+ * Should this sniff check closure braces?
44
+ *
45
+ * @var bool
46
+ */
47
+ public $checkClosures = false;
48
+
49
+
50
+ /**
51
+ * Registers the tokens that this sniff wants to listen for.
52
+ *
53
+ * @return void
54
+ */
55
+ public function register()
56
+ {
57
+ return array(
58
+ T_FUNCTION,
59
+ T_CLOSURE,
60
+ );
61
+
62
+ }//end register()
63
+
64
+
65
+ /**
66
+ * Processes this test, when one of its tokens is encountered.
67
+ *
68
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
69
+ * @param int $stackPtr The position of the current token in the
70
+ * stack passed in $tokens.
71
+ *
72
+ * @return void
73
+ */
74
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
75
+ {
76
+ $tokens = $phpcsFile->getTokens();
77
+
78
+ if (isset($tokens[$stackPtr]['scope_opener']) === false) {
79
+ return;
80
+ }
81
+
82
+ if (($tokens[$stackPtr]['code'] === T_FUNCTION
83
+ && (bool) $this->checkFunctions === false)
84
+ || ($tokens[$stackPtr]['code'] === T_CLOSURE
85
+ && (bool) $this->checkClosures === false)
86
+ ) {
87
+ return;
88
+ }
89
+
90
+ $openingBrace = $tokens[$stackPtr]['scope_opener'];
91
+ $closeBracket = $tokens[$stackPtr]['parenthesis_closer'];
92
+ if ($tokens[$stackPtr]['code'] === T_CLOSURE) {
93
+ $use = $phpcsFile->findNext(T_USE, ($closeBracket + 1), $tokens[$stackPtr]['scope_opener']);
94
+ if ($use !== false) {
95
+ $openBracket = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($use + 1));
96
+ $closeBracket = $tokens[$openBracket]['parenthesis_closer'];
97
+ }
98
+ }
99
+
100
+ $functionLine = $tokens[$closeBracket]['line'];
101
+ $braceLine = $tokens[$openingBrace]['line'];
102
+
103
+ $lineDifference = ($braceLine - $functionLine);
104
+
105
+ if ($lineDifference > 0) {
106
+ $phpcsFile->recordMetric($stackPtr, 'Function opening brace placement', 'new line');
107
+ $error = 'Opening brace should be on the same line as the declaration';
108
+ $fix = $phpcsFile->addFixableError($error, $openingBrace, 'BraceOnNewLine');
109
+ if ($fix === true) {
110
+ $prev = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($openingBrace - 1), $closeBracket, true);
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
+
137
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($openingBrace + 1), null, true);
138
+ if ($tokens[$next]['line'] === $tokens[$openingBrace]['line']) {
139
+ if ($next === $tokens[$stackPtr]['scope_closer']) {
140
+ // Ignore empty functions.
141
+ return;
142
+ }
143
+
144
+ $error = 'Opening brace must be the last content on the line';
145
+ $fix = $phpcsFile->addFixableError($error, $openingBrace, 'ContentAfterBrace');
146
+ if ($fix === true) {
147
+ $phpcsFile->fixer->addNewline($openingBrace);
148
+ }
149
+ }
150
+
151
+ // Only continue checking if the opening brace looks good.
152
+ if ($lineDifference > 0) {
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
+ }
176
+
177
+ }//end process()
178
+
179
+
180
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Metrics/CyclomaticComplexitySniff.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Checks the cyclomatic complexity (McCabe) for functions.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Checks the cyclomatic complexity (McCabe) for functions.
18
+ *
19
+ * The cyclomatic complexity (also called McCabe code metrics)
20
+ * indicates the complexity within a function by counting
21
+ * the different paths the function includes.
22
+ *
23
+ * @category PHP
24
+ * @package PHP_CodeSniffer
25
+ * @author Johann-Peter Hartmann <hartmann@mayflower.de>
26
+ * @author Greg Sherwood <gsherwood@squiz.net>
27
+ * @copyright 2007-2014 Mayflower GmbH
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class Generic_Sniffs_Metrics_CyclomaticComplexitySniff implements PHP_CodeSniffer_Sniff
33
+ {
34
+
35
+ /**
36
+ * A complexity higher than this value will throw a warning.
37
+ *
38
+ * @var int
39
+ */
40
+ public $complexity = 10;
41
+
42
+ /**
43
+ * A complexity higher than this value will throw an error.
44
+ *
45
+ * @var int
46
+ */
47
+ public $absoluteComplexity = 20;
48
+
49
+
50
+ /**
51
+ * Returns an array of tokens this test wants to listen for.
52
+ *
53
+ * @return array
54
+ */
55
+ public function register()
56
+ {
57
+ return array(T_FUNCTION);
58
+
59
+ }//end register()
60
+
61
+
62
+ /**
63
+ * Processes this test, when one of its tokens is encountered.
64
+ *
65
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
66
+ * @param int $stackPtr The position of the current token
67
+ * in the stack passed in $tokens.
68
+ *
69
+ * @return void
70
+ */
71
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
72
+ {
73
+ $this->currentFile = $phpcsFile;
74
+
75
+ $tokens = $phpcsFile->getTokens();
76
+
77
+ // Ignore abstract methods.
78
+ if (isset($tokens[$stackPtr]['scope_opener']) === false) {
79
+ return;
80
+ }
81
+
82
+ // Detect start and end of this function definition.
83
+ $start = $tokens[$stackPtr]['scope_opener'];
84
+ $end = $tokens[$stackPtr]['scope_closer'];
85
+
86
+ // Predicate nodes for PHP.
87
+ $find = array(
88
+ T_CASE => true,
89
+ T_DEFAULT => true,
90
+ T_CATCH => true,
91
+ T_IF => true,
92
+ T_FOR => true,
93
+ T_FOREACH => true,
94
+ T_WHILE => true,
95
+ T_DO => true,
96
+ T_ELSEIF => true,
97
+ );
98
+
99
+ $complexity = 1;
100
+
101
+ // Iterate from start to end and count predicate nodes.
102
+ for ($i = ($start + 1); $i < $end; $i++) {
103
+ if (isset($find[$tokens[$i]['code']]) === true) {
104
+ $complexity++;
105
+ }
106
+ }
107
+
108
+ if ($complexity > $this->absoluteComplexity) {
109
+ $error = 'Function\'s cyclomatic complexity (%s) exceeds allowed maximum of %s';
110
+ $data = array(
111
+ $complexity,
112
+ $this->absoluteComplexity,
113
+ );
114
+ $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
115
+ } else if ($complexity > $this->complexity) {
116
+ $warning = 'Function\'s cyclomatic complexity (%s) exceeds %s; consider refactoring the function';
117
+ $data = array(
118
+ $complexity,
119
+ $this->complexity,
120
+ );
121
+ $phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data);
122
+ }
123
+
124
+ }//end process()
125
+
126
+
127
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Metrics/NestingLevelSniff.php ADDED
@@ -0,0 +1,112 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Checks the nesting level for methods.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Checks the nesting level for methods.
18
+ *
19
+ * @category PHP
20
+ * @package PHP_CodeSniffer
21
+ * @author Johann-Peter Hartmann <hartmann@mayflower.de>
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2007-2014 Mayflower GmbH
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_Metrics_NestingLevelSniff implements PHP_CodeSniffer_Sniff
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
+ */
43
+ public $absoluteNestingLevel = 10;
44
+
45
+
46
+ /**
47
+ * Returns an array of tokens this test wants to listen for.
48
+ *
49
+ * @return array
50
+ */
51
+ public function register()
52
+ {
53
+ return array(T_FUNCTION);
54
+
55
+ }//end register()
56
+
57
+
58
+ /**
59
+ * Processes this test, when one of its tokens is encountered.
60
+ *
61
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
62
+ * @param int $stackPtr The position of the current token
63
+ * in the stack passed in $tokens.
64
+ *
65
+ * @return void
66
+ */
67
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
68
+ {
69
+ $tokens = $phpcsFile->getTokens();
70
+
71
+ // Ignore abstract methods.
72
+ if (isset($tokens[$stackPtr]['scope_opener']) === false) {
73
+ return;
74
+ }
75
+
76
+ // Detect start and end of this function definition.
77
+ $start = $tokens[$stackPtr]['scope_opener'];
78
+ $end = $tokens[$stackPtr]['scope_closer'];
79
+
80
+ $nestingLevel = 0;
81
+
82
+ // Find the maximum nesting level of any token in the function.
83
+ for ($i = ($start + 1); $i < $end; $i++) {
84
+ $level = $tokens[$i]['level'];
85
+ if ($nestingLevel < $level) {
86
+ $nestingLevel = $level;
87
+ }
88
+ }
89
+
90
+ // We subtract the nesting level of the function itself.
91
+ $nestingLevel = ($nestingLevel - $tokens[$stackPtr]['level'] - 1);
92
+
93
+ if ($nestingLevel > $this->absoluteNestingLevel) {
94
+ $error = 'Function\'s nesting level (%s) exceeds allowed maximum of %s';
95
+ $data = array(
96
+ $nestingLevel,
97
+ $this->absoluteNestingLevel,
98
+ );
99
+ $phpcsFile->addError($error, $stackPtr, 'MaxExceeded', $data);
100
+ } else if ($nestingLevel > $this->nestingLevel) {
101
+ $warning = 'Function\'s nesting level (%s) exceeds %s; consider refactoring the function';
102
+ $data = array(
103
+ $nestingLevel,
104
+ $this->nestingLevel,
105
+ );
106
+ $phpcsFile->addWarning($warning, $stackPtr, 'TooHigh', $data);
107
+ }
108
+
109
+ }//end process()
110
+
111
+
112
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/CamelCapsFunctionNameSniff.php ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) {
17
+ throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found');
18
+ }
19
+
20
+ /**
21
+ * Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff.
22
+ *
23
+ * Ensures method names and function names are in CamelCaps and
24
+ * that only magic methods/functions start with a double underscore.
25
+ *
26
+ * @category PHP
27
+ * @package PHP_CodeSniffer
28
+ * @author Greg Sherwood <gsherwood@squiz.net>
29
+ * @author Marc McIntyre <mmcintyre@squiz.net>
30
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
31
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
32
+ * @version Release: @package_version@
33
+ * @link http://pear.php.net/package/PHP_CodeSniffer
34
+ */
35
+ class Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff
36
+ {
37
+
38
+ /**
39
+ * A list of all PHP magic methods.
40
+ *
41
+ * @var array
42
+ */
43
+ protected $magicMethods = array(
44
+ 'construct' => true,
45
+ 'destruct' => true,
46
+ 'call' => true,
47
+ 'callstatic' => true,
48
+ 'get' => true,
49
+ 'set' => true,
50
+ 'isset' => true,
51
+ 'unset' => true,
52
+ 'sleep' => true,
53
+ 'wakeup' => true,
54
+ 'tostring' => true,
55
+ 'set_state' => true,
56
+ 'clone' => true,
57
+ 'invoke' => true,
58
+ 'debuginfo' => true,
59
+ );
60
+
61
+ /**
62
+ * A list of all PHP non-magic methods starting with a double underscore.
63
+ *
64
+ * These come from PHP modules such as SOAPClient.
65
+ *
66
+ * @var array
67
+ */
68
+ protected $methodsDoubleUnderscore = array(
69
+ 'soapcall' => true,
70
+ 'getlastrequest' => true,
71
+ 'getlastresponse' => true,
72
+ 'getlastrequestheaders' => true,
73
+ 'getlastresponseheaders' => true,
74
+ 'getfunctions' => true,
75
+ 'gettypes' => true,
76
+ 'dorequest' => true,
77
+ 'setcookie' => true,
78
+ 'setlocation' => true,
79
+ 'setsoapheaders' => true,
80
+ );
81
+
82
+ /**
83
+ * A list of all PHP magic functions.
84
+ *
85
+ * @var array
86
+ */
87
+ protected $magicFunctions = array('autoload' => true);
88
+
89
+ /**
90
+ * If TRUE, the string must not have two capital letters next to each other.
91
+ *
92
+ * @var bool
93
+ */
94
+ public $strict = true;
95
+
96
+
97
+ /**
98
+ * Constructs a Generic_Sniffs_NamingConventions_CamelCapsFunctionNameSniff.
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
+
106
+
107
+ /**
108
+ * Processes the tokens within the scope.
109
+ *
110
+ * @param PHP_CodeSniffer_File $phpcsFile The file being processed.
111
+ * @param int $stackPtr The position where this token was
112
+ * found.
113
+ * @param int $currScope The position of the current scope.
114
+ *
115
+ * @return void
116
+ */
117
+ protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope)
118
+ {
119
+ $methodName = $phpcsFile->getDeclarationName($stackPtr);
120
+ if ($methodName === null) {
121
+ // Ignore closures.
122
+ return;
123
+ }
124
+
125
+ $className = $phpcsFile->getDeclarationName($currScope);
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
133
+ ) {
134
+ $error = 'Method name "%s" is invalid; only PHP magic methods should be prefixed with a double underscore';
135
+ $phpcsFile->addError($error, $stackPtr, 'MethodDoubleUnderscore', $errorData);
136
+ }
137
+
138
+ return;
139
+ }
140
+
141
+ // PHP4 constructors are allowed to break our rules.
142
+ if ($methodName === $className) {
143
+ return;
144
+ }
145
+
146
+ // PHP4 destructors are allowed to break our rules.
147
+ if ($methodName === '_'.$className) {
148
+ return;
149
+ }
150
+
151
+ // Ignore first underscore in methods prefixed with "_".
152
+ $methodName = ltrim($methodName, '_');
153
+
154
+ $methodProps = $phpcsFile->getMethodProperties($stackPtr);
155
+ if (PHP_CodeSniffer::isCamelCaps($methodName, false, true, $this->strict) === false) {
156
+ if ($methodProps['scope_specified'] === true) {
157
+ $error = '%s method name "%s" is not in camel caps format';
158
+ $data = array(
159
+ ucfirst($methodProps['scope']),
160
+ $errorData[0],
161
+ );
162
+ $phpcsFile->addError($error, $stackPtr, 'ScopeNotCamelCaps', $data);
163
+ } else {
164
+ $error = 'Method name "%s" is not in camel caps format';
165
+ $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $errorData);
166
+ }
167
+
168
+ $phpcsFile->recordMetric($stackPtr, 'CamelCase method name', 'no');
169
+ return;
170
+ } else {
171
+ $phpcsFile->recordMetric($stackPtr, 'CamelCase method name', 'yes');
172
+ }
173
+
174
+ }//end processTokenWithinScope()
175
+
176
+
177
+ /**
178
+ * Processes the tokens outside the scope.
179
+ *
180
+ * @param PHP_CodeSniffer_File $phpcsFile The file being processed.
181
+ * @param int $stackPtr The position where this token was
182
+ * found.
183
+ *
184
+ * @return void
185
+ */
186
+ protected function processTokenOutsideScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
187
+ {
188
+ $functionName = $phpcsFile->getDeclarationName($stackPtr);
189
+ if ($functionName === null) {
190
+ // Ignore closures.
191
+ return;
192
+ }
193
+
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';
201
+ $phpcsFile->addError($error, $stackPtr, 'FunctionDoubleUnderscore', $errorData);
202
+ }
203
+
204
+ return;
205
+ }
206
+
207
+ // Ignore first underscore in functions prefixed with "_".
208
+ $functionName = ltrim($functionName, '_');
209
+
210
+ if (PHP_CodeSniffer::isCamelCaps($functionName, false, true, $this->strict) === false) {
211
+ $error = 'Function name "%s" is not in camel caps format';
212
+ $phpcsFile->addError($error, $stackPtr, 'NotCamelCaps', $errorData);
213
+ $phpcsFile->recordMetric($stackPtr, 'CamelCase function name', 'no');
214
+ } else {
215
+ $phpcsFile->recordMetric($stackPtr, 'CamelCase method name', 'yes');
216
+ }
217
+
218
+ }//end processTokenOutsideScope()
219
+
220
+
221
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/ConstructorNameSniff.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_NamingConventions_ConstructorNameSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Leif Wickland <lwickland@rightnow.com>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ if (class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false) {
17
+ $error = 'Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found';
18
+ throw new PHP_CodeSniffer_Exception($error);
19
+ }
20
+
21
+ /**
22
+ * Generic_Sniffs_NamingConventions_ConstructorNameSniff.
23
+ *
24
+ * Favor PHP 5 constructor syntax, which uses "function __construct()".
25
+ * Avoid PHP 4 constructor syntax, which uses "function ClassName()".
26
+ *
27
+ * @category PHP
28
+ * @package PHP_CodeSniffer
29
+ * @author Leif Wickland <lwickland@rightnow.com>
30
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
31
+ * @version Release: @package_version@
32
+ * @link http://pear.php.net/package/PHP_CodeSniffer
33
+ */
34
+ class Generic_Sniffs_NamingConventions_ConstructorNameSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff
35
+ {
36
+
37
+ /**
38
+ * The name of the class we are currently checking.
39
+ *
40
+ * @var string
41
+ */
42
+ private $_currentClass = '';
43
+
44
+ /**
45
+ * A list of functions in the current class.
46
+ *
47
+ * @var string[]
48
+ */
49
+ private $_functionList = array();
50
+
51
+
52
+ /**
53
+ * Constructs the test with the tokens it wishes to listen for.
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
+
61
+
62
+ /**
63
+ * Processes this test when one of its tokens is encountered.
64
+ *
65
+ * @param PHP_CodeSniffer_File $phpcsFile The current file being scanned.
66
+ * @param int $stackPtr The position of the current token
67
+ * in the stack passed in $tokens.
68
+ * @param int $currScope A pointer to the start of the scope.
69
+ *
70
+ * @return void
71
+ */
72
+ protected function processTokenWithinScope(
73
+ PHP_CodeSniffer_File $phpcsFile,
74
+ $stackPtr,
75
+ $currScope
76
+ ) {
77
+ $className = $phpcsFile->getDeclarationName($currScope);
78
+ if ($className !== $this->_currentClass) {
79
+ $this->loadFunctionNamesInScope($phpcsFile, $currScope);
80
+ $this->_currentClass = $className;
81
+ }
82
+
83
+ $methodName = $phpcsFile->getDeclarationName($stackPtr);
84
+
85
+ if (strcasecmp($methodName, $className) === 0) {
86
+ if (in_array('__construct', $this->_functionList) === false) {
87
+ $error = 'PHP4 style constructors are not allowed; use "__construct()" instead';
88
+ $phpcsFile->addError($error, $stackPtr, 'OldStyle');
89
+ }
90
+ } else if (strcasecmp($methodName, '__construct') !== 0) {
91
+ // Not a constructor.
92
+ return;
93
+ }
94
+
95
+ $tokens = $phpcsFile->getTokens();
96
+
97
+ $parentClassName = $phpcsFile->findExtendedClassName($currScope);
98
+ if ($parentClassName === false) {
99
+ return;
100
+ }
101
+
102
+ // Stop if the constructor doesn't have a body, like when it is abstract.
103
+ if (isset($tokens[$stackPtr]['scope_closer']) === false) {
104
+ return;
105
+ }
106
+
107
+ $endFunctionIndex = $tokens[$stackPtr]['scope_closer'];
108
+ $startIndex = $stackPtr;
109
+ while (($doubleColonIndex = $phpcsFile->findNext(T_DOUBLE_COLON, $startIndex, $endFunctionIndex)) !== false) {
110
+ if ($tokens[($doubleColonIndex + 1)]['code'] === T_STRING
111
+ && $tokens[($doubleColonIndex + 1)]['content'] === $parentClassName
112
+ ) {
113
+ $error = 'PHP4 style calls to parent constructors are not allowed; use "parent::__construct()" instead';
114
+ $phpcsFile->addError($error, ($doubleColonIndex + 1), 'OldStyleCall');
115
+ }
116
+
117
+ $startIndex = ($doubleColonIndex + 1);
118
+ }
119
+
120
+ }//end processTokenWithinScope()
121
+
122
+
123
+ /**
124
+ * Extracts all the function names found in the given scope.
125
+ *
126
+ * @param PHP_CodeSniffer_File $phpcsFile The current file being scanned.
127
+ * @param int $currScope A pointer to the start of the scope.
128
+ *
129
+ * @return void
130
+ */
131
+ protected function loadFunctionNamesInScope(PHP_CodeSniffer_File $phpcsFile, $currScope)
132
+ {
133
+ $this->_functionList = array();
134
+ $tokens = $phpcsFile->getTokens();
135
+
136
+ for ($i = ($tokens[$currScope]['scope_opener'] + 1); $i < $tokens[$currScope]['scope_closer']; $i++) {
137
+ if ($tokens[$i]['code'] !== T_FUNCTION) {
138
+ continue;
139
+ }
140
+
141
+ $next = $phpcsFile->findNext(T_STRING, $i);
142
+ $this->_functionList[] = trim($tokens[$next]['content']);
143
+ }
144
+
145
+ }//end loadFunctionNamesInScope()
146
+
147
+
148
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/NamingConventions/UpperCaseConstantNameSniff.php ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff.
18
+ *
19
+ * Ensures that constant names are all uppercase.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Marc McIntyre <mmcintyre@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_NamingConventions_UpperCaseConstantNameSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+
34
+ /**
35
+ * Returns an array of tokens this test wants to listen for.
36
+ *
37
+ * @return array
38
+ */
39
+ public function register()
40
+ {
41
+ return array(T_STRING);
42
+
43
+ }//end register()
44
+
45
+
46
+ /**
47
+ * Processes this test, when one of its tokens is encountered.
48
+ *
49
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
50
+ * @param int $stackPtr The position of the current token in the
51
+ * stack passed in $tokens.
52
+ *
53
+ * @return void
54
+ */
55
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
+ {
57
+ $tokens = $phpcsFile->getTokens();
58
+ $constName = $tokens[$stackPtr]['content'];
59
+
60
+ // If this token is in a heredoc, ignore it.
61
+ if ($phpcsFile->hasCondition($stackPtr, T_START_HEREDOC) === true) {
62
+ return;
63
+ }
64
+
65
+ // Special case for PHP 5.5 class name resolution.
66
+ if (strtolower($constName) === 'class'
67
+ && $tokens[($stackPtr - 1)]['code'] === T_DOUBLE_COLON
68
+ ) {
69
+ return;
70
+ }
71
+
72
+ // Special case for PHPUnit.
73
+ if ($constName === 'PHPUnit_MAIN_METHOD') {
74
+ return;
75
+ }
76
+
77
+ // If the next non-whitespace token after this token
78
+ // is not an opening parenthesis then it is not a function call.
79
+ for ($openBracket = ($stackPtr + 1); $openBracket < $phpcsFile->numTokens; $openBracket++) {
80
+ if ($tokens[$openBracket]['code'] !== T_WHITESPACE) {
81
+ break;
82
+ }
83
+ }
84
+
85
+ if ($openBracket === $phpcsFile->numTokens) {
86
+ return;
87
+ }
88
+
89
+ if ($tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS) {
90
+ $functionKeyword = $phpcsFile->findPrevious(
91
+ array(
92
+ T_WHITESPACE,
93
+ T_COMMA,
94
+ T_COMMENT,
95
+ T_STRING,
96
+ T_NS_SEPARATOR,
97
+ ),
98
+ ($stackPtr - 1),
99
+ null,
100
+ true
101
+ );
102
+
103
+ if ($tokens[$functionKeyword]['code'] !== T_CONST) {
104
+ return;
105
+ }
106
+
107
+ // This is a class constant.
108
+ if (strtoupper($constName) !== $constName) {
109
+ if (strtolower($constName) === $constName) {
110
+ $phpcsFile->recordMetric($stackPtr, 'Constant name case', 'lower');
111
+ } else {
112
+ $phpcsFile->recordMetric($stackPtr, 'Constant name case', 'mixed');
113
+ }
114
+
115
+ $error = 'Class constants must be uppercase; expected %s but found %s';
116
+ $data = array(
117
+ strtoupper($constName),
118
+ $constName,
119
+ );
120
+ $phpcsFile->addError($error, $stackPtr, 'ClassConstantNotUpperCase', $data);
121
+ } else {
122
+ $phpcsFile->recordMetric($stackPtr, 'Constant name case', 'upper');
123
+ }
124
+
125
+ return;
126
+ }//end if
127
+
128
+ if (strtolower($constName) !== 'define') {
129
+ return;
130
+ }
131
+
132
+ /*
133
+ This may be a "define" function call.
134
+ */
135
+
136
+ // Make sure this is not a method call.
137
+ $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
138
+ if ($tokens[$prev]['code'] === T_OBJECT_OPERATOR
139
+ || $tokens[$prev]['code'] === T_DOUBLE_COLON
140
+ ) {
141
+ return;
142
+ }
143
+
144
+ // The next non-whitespace token must be the constant name.
145
+ $constPtr = $phpcsFile->findNext(T_WHITESPACE, ($openBracket + 1), null, true);
146
+ if ($tokens[$constPtr]['code'] !== T_CONSTANT_ENCAPSED_STRING) {
147
+ return;
148
+ }
149
+
150
+ $constName = $tokens[$constPtr]['content'];
151
+
152
+ // Check for constants like self::CONSTANT.
153
+ $prefix = '';
154
+ $splitPos = strpos($constName, '::');
155
+ if ($splitPos !== false) {
156
+ $prefix = substr($constName, 0, ($splitPos + 2));
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');
170
+ } else {
171
+ $phpcsFile->recordMetric($stackPtr, 'Constant name case', 'mixed');
172
+ }
173
+
174
+ $error = 'Constants must be uppercase; expected %s but found %s';
175
+ $data = array(
176
+ $prefix.strtoupper($constName),
177
+ $prefix.$constName,
178
+ );
179
+ $phpcsFile->addError($error, $stackPtr, 'ConstantNotUpperCase', $data);
180
+ } else {
181
+ $phpcsFile->recordMetric($stackPtr, 'Constant name case', 'upper');
182
+ }
183
+
184
+ }//end process()
185
+
186
+
187
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/BacktickOperatorSniff.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_BacktickOperatorSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_PHP_BacktickOperatorSniff.
18
+ *
19
+ * Checks for the use of the backtick execution operator.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Marc McIntyre <mmcintyre@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_PHP_BacktickOperatorSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+
34
+ /**
35
+ * Returns an array of tokens this test wants to listen for.
36
+ *
37
+ * @return array
38
+ */
39
+ public function register()
40
+ {
41
+ return array(T_BACKTICK);
42
+
43
+ }//end register()
44
+
45
+
46
+ /**
47
+ * Processes this test, when one of its tokens is encountered.
48
+ *
49
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
50
+ * @param int $stackPtr The position of the current token
51
+ * in the stack passed in $tokens.
52
+ *
53
+ * @return void
54
+ */
55
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
56
+ {
57
+ $error = 'Use of the backtick operator is forbidden';
58
+ $phpcsFile->addError($error, $stackPtr, 'Found');
59
+
60
+ }//end process()
61
+
62
+
63
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/CharacterBeforePHPOpeningTagSniff.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_CharacterBeforePHPOpeningTagSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Andy Grunwald <andygrunwald@gmail.com>
10
+ * @copyright 2010-2014 Andy Grunwald
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Checks that the opening PHP tag is the first content in a file.
17
+ *
18
+ * @category PHP
19
+ * @package PHP_CodeSniffer
20
+ * @author Andy Grunwald <andygrunwald@gmail.com>
21
+ * @copyright 2010-2014 Andy Grunwald
22
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
23
+ * @version Release: @package_version@
24
+ * @link http://pear.php.net/package/PHP_CodeSniffer
25
+ */
26
+ class Generic_Sniffs_PHP_CharacterBeforePHPOpeningTagSniff implements PHP_CodeSniffer_Sniff
27
+ {
28
+
29
+
30
+ /**
31
+ * Returns an array of tokens this test wants to listen for.
32
+ *
33
+ * @return array
34
+ */
35
+ public function register()
36
+ {
37
+ return array(T_OPEN_TAG);
38
+
39
+ }//end register()
40
+
41
+
42
+ /**
43
+ * Processes this sniff, when one of its tokens is encountered.
44
+ *
45
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
+ * @param int $stackPtr The position of the current token in
47
+ * the stack passed in $tokens.
48
+ *
49
+ * @return void
50
+ */
51
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
+ {
53
+ $expected = 0;
54
+ if ($stackPtr > 0) {
55
+ // Allow a shebang line.
56
+ $tokens = $phpcsFile->getTokens();
57
+ if (substr($tokens[0]['content'], 0, 2) === '#!') {
58
+ $expected = 1;
59
+ }
60
+ }
61
+
62
+ if ($stackPtr !== $expected) {
63
+ $error = 'The opening PHP tag must be the first content in the file';
64
+ $phpcsFile->addError($error, $stackPtr, 'Found');
65
+ }
66
+
67
+ // Skip the rest of the file so we don't pick up additional
68
+ // open tags, typically embedded in HTML.
69
+ return $phpcsFile->numTokens;
70
+
71
+ }//end process()
72
+
73
+
74
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ClosingPHPTagSniff.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_ClosingPHPTagSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Stefano Kowalke <blueduck@gmx.net>
10
+ * @copyright 2010-2014 Stefano Kowalke
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Checks that open PHP tags are paired with closing tags.
17
+ *
18
+ * @category PHP
19
+ * @package PHP_CodeSniffer
20
+ * @author Stefano Kowalke <blueduck@gmx.net>
21
+ * @copyright 2010-2014 Stefano Kowalke
22
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
23
+ * @version Release: @package_version@
24
+ * @link http://pear.php.net/package/PHP_CodeSniffer
25
+ */
26
+ class Generic_Sniffs_PHP_ClosingPHPTagSniff implements PHP_CodeSniffer_Sniff
27
+ {
28
+
29
+
30
+ /**
31
+ * Returns an array of tokens this test wants to listen for.
32
+ *
33
+ * @return array
34
+ */
35
+ public function register()
36
+ {
37
+ return array(T_OPEN_TAG);
38
+
39
+ }//end register()
40
+
41
+
42
+ /**
43
+ * Processes this sniff, when one of its tokens is encountered.
44
+ *
45
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
46
+ * @param int $stackPtr The position of the current token in
47
+ * the stack passed in $tokens.
48
+ *
49
+ * @return void
50
+ */
51
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
52
+ {
53
+ $closeTag = $phpcsFile->findNext(T_CLOSE_TAG, $stackPtr);
54
+ if ($closeTag === false) {
55
+ $error = 'The PHP open tag does not have a corresponding PHP close tag';
56
+ $phpcsFile->addError($error, $stackPtr, 'NotFound');
57
+ }
58
+
59
+ }//end process()
60
+
61
+
62
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DeprecatedFunctionsSniff.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_DeprecatedFunctionsSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_PHP_DeprecatedFunctionsSniff.
18
+ *
19
+ * Discourages the use of deprecated functions that are kept in PHP for
20
+ * compatibility with older versions.
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Sebastian Bergmann <sb@sebastian-bergmann.de>
25
+ * @author Greg Sherwood <gsherwood@squiz.net>
26
+ * @author Marc McIntyre <mmcintyre@squiz.net>
27
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class Generic_Sniffs_PHP_DeprecatedFunctionsSniff extends Generic_Sniffs_PHP_ForbiddenFunctionsSniff
33
+ {
34
+
35
+ /**
36
+ * A list of forbidden functions with their alternatives.
37
+ *
38
+ * The value is NULL if no alternative exists. IE, the
39
+ * function should just not be used.
40
+ *
41
+ * @var array(string => string|null)
42
+ */
43
+ public $forbiddenFunctions = array();
44
+
45
+
46
+ /**
47
+ * Constructor.
48
+ *
49
+ * Uses the Reflection API to get a list of deprecated functions.
50
+ */
51
+ public function __construct()
52
+ {
53
+ $functions = get_defined_functions();
54
+
55
+ foreach ($functions['internal'] as $functionName) {
56
+ $function = new ReflectionFunction($functionName);
57
+ if (method_exists($function, 'isDeprecated') === false) {
58
+ break;
59
+ }
60
+
61
+ if ($function->isDeprecated() === true) {
62
+ $this->forbiddenFunctions[$functionName] = null;
63
+ }
64
+ }
65
+
66
+ }//end __construct()
67
+
68
+
69
+ /**
70
+ * Generates the error or warning for this sniff.
71
+ *
72
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
73
+ * @param int $stackPtr The position of the forbidden function
74
+ * in the token array.
75
+ * @param string $function The name of the forbidden function.
76
+ * @param string $pattern The pattern used for the match.
77
+ *
78
+ * @return void
79
+ */
80
+ protected function addError($phpcsFile, $stackPtr, $function, $pattern=null)
81
+ {
82
+ $data = array($function);
83
+ $error = 'Function %s() has been deprecated';
84
+ $type = 'Deprecated';
85
+
86
+ if ($this->error === true) {
87
+ $phpcsFile->addError($error, $stackPtr, $type, $data);
88
+ } else {
89
+ $phpcsFile->addWarning($error, $stackPtr, $type, $data);
90
+ }
91
+
92
+ }//end addError()
93
+
94
+
95
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowAlternativePHPTagsSniff.php ADDED
@@ -0,0 +1,269 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_DisallowAlternativePHPTagsSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_PHP_DisallowAlternativePHPTagsSniff.
18
+ *
19
+ * Verifies that no alternative PHP tags are used.
20
+ *
21
+ * If alternative PHP open tags are found, this sniff can fix both the open and close tags.
22
+ *
23
+ * @category PHP
24
+ * @package PHP_CodeSniffer
25
+ * @author Greg Sherwood <gsherwood@squiz.net>
26
+ * @author Marc McIntyre <mmcintyre@squiz.net>
27
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class Generic_Sniffs_PHP_DisallowAlternativePHPTagsSniff implements PHP_CodeSniffer_Sniff
33
+ {
34
+
35
+
36
+ /**
37
+ * Whether ASP tags are enabled or not.
38
+ *
39
+ * @var bool
40
+ */
41
+ private $_aspTags = false;
42
+
43
+ /**
44
+ * The current PHP version.
45
+ *
46
+ * @var integer
47
+ */
48
+ private $_phpVersion = null;
49
+
50
+
51
+ /**
52
+ * Returns an array of tokens this test wants to listen for.
53
+ *
54
+ * @return array
55
+ */
56
+ public function register()
57
+ {
58
+ if ($this->_phpVersion === null) {
59
+ $this->_phpVersion = PHP_CodeSniffer::getConfigData('php_version');
60
+ if ($this->_phpVersion === null) {
61
+ $this->_phpVersion = PHP_VERSION_ID;
62
+ }
63
+ }
64
+
65
+ if ($this->_phpVersion < 70000) {
66
+ $this->_aspTags = (boolean) ini_get('asp_tags');
67
+ }
68
+
69
+ return array(
70
+ T_OPEN_TAG,
71
+ T_OPEN_TAG_WITH_ECHO,
72
+ T_INLINE_HTML,
73
+ );
74
+
75
+ }//end register()
76
+
77
+
78
+ /**
79
+ * Processes this test, when one of its tokens is encountered.
80
+ *
81
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
82
+ * @param int $stackPtr The position of the current token
83
+ * in the stack passed in $tokens.
84
+ *
85
+ * @return void
86
+ */
87
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
88
+ {
89
+ $tokens = $phpcsFile->getTokens();
90
+ $openTag = $tokens[$stackPtr];
91
+ $content = $openTag['content'];
92
+
93
+ if (trim($content) === '') {
94
+ return;
95
+ }
96
+
97
+ if ($openTag['code'] === T_OPEN_TAG) {
98
+ if ($content === '<%') {
99
+ $error = 'ASP style opening tag used; expected "<?php" but found "%s"';
100
+ $closer = $this->findClosingTag($phpcsFile, $tokens, $stackPtr, '%>');
101
+ $errorCode = 'ASPOpenTagFound';
102
+ } else if (strpos($content, '<script ') !== false) {
103
+ $error = 'Script style opening tag used; expected "<?php" but found "%s"';
104
+ $closer = $this->findClosingTag($phpcsFile, $tokens, $stackPtr, '</script>');
105
+ $errorCode = 'ScriptOpenTagFound';
106
+ }
107
+
108
+ if (isset($error, $closer, $errorCode) === true) {
109
+ $data = array($content);
110
+
111
+ if ($closer === false) {
112
+ $phpcsFile->addError($error, $stackPtr, $errorCode, $data);
113
+ } else {
114
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, $errorCode, $data);
115
+ if ($fix === true) {
116
+ $this->addChangeset($phpcsFile, $tokens, $stackPtr, $closer);
117
+ }
118
+ }
119
+ }
120
+
121
+ return;
122
+ }//end if
123
+
124
+ if ($openTag['code'] === T_OPEN_TAG_WITH_ECHO && $content === '<%=') {
125
+ $error = 'ASP style opening tag used with echo; expected "<?php echo %s ..." but found "%s %s ..."';
126
+ $nextVar = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
127
+ $snippet = $this->getSnippet($tokens[$nextVar]['content']);
128
+ $data = array(
129
+ $snippet,
130
+ $content,
131
+ $snippet,
132
+ );
133
+
134
+ $closer = $this->findClosingTag($phpcsFile, $tokens, $stackPtr, '%>');
135
+
136
+ if ($closer === false) {
137
+ $phpcsFile->addError($error, $stackPtr, 'ASPShortOpenTagFound', $data);
138
+ } else {
139
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'ASPShortOpenTagFound', $data);
140
+ if ($fix === true) {
141
+ $this->addChangeset($phpcsFile, $tokens, $stackPtr, $closer, true);
142
+ }
143
+ }
144
+
145
+ return;
146
+ }//end if
147
+
148
+ // Account for incorrect script open tags.
149
+ // The "(?:<s)?" in the regex is to work-around a bug in PHP 5.2.
150
+ if ($openTag['code'] === T_INLINE_HTML
151
+ && preg_match('`((?:<s)?cript (?:[^>]+)?language=[\'"]?php[\'"]?(?:[^>]+)?>)`i', $content, $match) === 1
152
+ ) {
153
+ $error = 'Script style opening tag used; expected "<?php" but found "%s"';
154
+ $snippet = $this->getSnippet($content, $match[1]);
155
+ $data = array($match[1].$snippet);
156
+
157
+ $phpcsFile->addError($error, $stackPtr, 'ScriptOpenTagFound', $data);
158
+ return;
159
+ }
160
+
161
+ if ($openTag['code'] === T_INLINE_HTML && $this->_aspTags === false) {
162
+ if (strpos($content, '<%=') !== false) {
163
+ $error = 'Possible use of ASP style short opening tags detected; found: %s';
164
+ $snippet = $this->getSnippet($content, '<%=');
165
+ $data = array('<%='.$snippet);
166
+
167
+ $phpcsFile->addWarning($error, $stackPtr, 'MaybeASPShortOpenTagFound', $data);
168
+ } else if (strpos($content, '<%') !== false) {
169
+ $error = 'Possible use of ASP style opening tags detected; found: %s';
170
+ $snippet = $this->getSnippet($content, '<%');
171
+ $data = array('<%'.$snippet);
172
+
173
+ $phpcsFile->addWarning($error, $stackPtr, 'MaybeASPOpenTagFound', $data);
174
+ }
175
+ }
176
+
177
+ }//end process()
178
+
179
+
180
+ /**
181
+ * Get a snippet from a HTML token.
182
+ *
183
+ * @param string $content The content of the HTML token.
184
+ * @param string $start Partial string to use as a starting point for the snippet.
185
+ * @param int $length The target length of the snippet to get. Defaults to 40.
186
+ *
187
+ * @return string
188
+ */
189
+ protected function getSnippet($content, $start='', $length=40)
190
+ {
191
+ $startPos = 0;
192
+
193
+ if ($start !== '') {
194
+ $startPos = strpos($content, $start);
195
+ if ($startPos !== false) {
196
+ $startPos += strlen($start);
197
+ }
198
+ }
199
+
200
+ $snippet = substr($content, $startPos, $length);
201
+ if ((strlen($content) - $startPos) > $length) {
202
+ $snippet .= '...';
203
+ }
204
+
205
+ return $snippet;
206
+
207
+ }//end getSnippet()
208
+
209
+
210
+ /**
211
+ * Try and find a matching PHP closing tag.
212
+ *
213
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
214
+ * @param array $tokens The token stack.
215
+ * @param int $stackPtr The position of the current token
216
+ * in the stack passed in $tokens.
217
+ * @param string $content The expected content of the closing tag to match the opener.
218
+ *
219
+ * @return int|false Pointer to the position in the stack for the closing tag or false if not found.
220
+ */
221
+ protected function findClosingTag(PHP_CodeSniffer_File $phpcsFile, $tokens, $stackPtr, $content)
222
+ {
223
+ $closer = $phpcsFile->findNext(T_CLOSE_TAG, ($stackPtr + 1));
224
+
225
+ if ($closer !== false && $content === trim($tokens[$closer]['content'])) {
226
+ return $closer;
227
+ }
228
+
229
+ return false;
230
+
231
+ }//end findClosingTag()
232
+
233
+
234
+ /**
235
+ * Add a changeset to replace the alternative PHP tags.
236
+ *
237
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
238
+ * @param array $tokens The token stack.
239
+ * @param int $open_tag_pointer Stack pointer to the PHP open tag.
240
+ * @param int $close_tag_pointer Stack pointer to the PHP close tag.
241
+ * @param bool $echo Whether to add 'echo' or not.
242
+ *
243
+ * @return void
244
+ */
245
+ protected function addChangeset(PHP_CodeSniffer_File $phpcsFile, $tokens, $open_tag_pointer, $close_tag_pointer, $echo = false)
246
+ {
247
+ // Build up the open tag replacement and make sure there's always whitespace behind it.
248
+ $open_replacement = '<?php';
249
+ if ($echo === true) {
250
+ $open_replacement .= ' echo';
251
+ }
252
+
253
+ if ($tokens[($open_tag_pointer + 1)]['code'] !== T_WHITESPACE) {
254
+ $open_replacement .= ' ';
255
+ }
256
+
257
+ // Make sure we don't remove any line breaks after the closing tag.
258
+ $regex = '`'.preg_quote(trim($tokens[$close_tag_pointer]['content'])).'`';
259
+ $close_replacement = preg_replace($regex, '?>', $tokens[$close_tag_pointer]['content']);
260
+
261
+ $phpcsFile->fixer->beginChangeset();
262
+ $phpcsFile->fixer->replaceToken($open_tag_pointer, $open_replacement);
263
+ $phpcsFile->fixer->replaceToken($close_tag_pointer, $close_replacement);
264
+ $phpcsFile->fixer->endChangeset();
265
+
266
+ }//end addChangeset()
267
+
268
+
269
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/DisallowShortOpenTagSniff.php ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_DisallowShortOpenTagSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_PHP_DisallowShortOpenTagSniff.
18
+ *
19
+ * Makes sure that shorthand PHP open tags are not used.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Marc McIntyre <mmcintyre@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_PHP_DisallowShortOpenTagSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+
34
+ /**
35
+ * Returns an array of tokens this test wants to listen for.
36
+ *
37
+ * @return array
38
+ */
39
+ public function register()
40
+ {
41
+ $targets = array(
42
+ T_OPEN_TAG,
43
+ T_OPEN_TAG_WITH_ECHO,
44
+ );
45
+
46
+ $shortOpenTags = (boolean) ini_get('short_open_tag');
47
+ if ($shortOpenTags === false) {
48
+ $targets[] = T_INLINE_HTML;
49
+ }
50
+
51
+ return $targets;
52
+
53
+ }//end register()
54
+
55
+
56
+ /**
57
+ * Processes this test, when one of its tokens is encountered.
58
+ *
59
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
60
+ * @param int $stackPtr The position of the current token
61
+ * in the stack passed in $tokens.
62
+ *
63
+ * @return void
64
+ */
65
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66
+ {
67
+ $tokens = $phpcsFile->getTokens();
68
+ $token = $tokens[$stackPtr];
69
+
70
+ if ($token['code'] === T_OPEN_TAG && $token['content'] === '<?') {
71
+ $error = 'Short PHP opening tag used; expected "<?php" but found "%s"';
72
+ $data = array($token['content']);
73
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data);
74
+ if ($fix === true) {
75
+ $correctOpening = '<?php';
76
+ if (isset($tokens[($stackPtr + 1)]) === true && $tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
77
+ // Avoid creation of invalid open tags like <?phpecho if the original was <?echo .
78
+ $correctOpening .= ' ';
79
+ }
80
+
81
+ $phpcsFile->fixer->replaceToken($stackPtr, $correctOpening);
82
+ }
83
+
84
+ $phpcsFile->recordMetric($stackPtr, 'PHP short open tag used', 'yes');
85
+ } else {
86
+ $phpcsFile->recordMetric($stackPtr, 'PHP short open tag used', 'no');
87
+ }
88
+
89
+ if ($token['code'] === T_OPEN_TAG_WITH_ECHO) {
90
+ $nextVar = $tokens[$phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true)];
91
+ $error = 'Short PHP opening tag used with echo; expected "<?php echo %s ..." but found "%s %s ..."';
92
+ $data = array(
93
+ $nextVar['content'],
94
+ $token['content'],
95
+ $nextVar['content'],
96
+ );
97
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'EchoFound', $data);
98
+ if ($fix === true) {
99
+ if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) {
100
+ $phpcsFile->fixer->replaceToken($stackPtr, '<?php echo ');
101
+ } else {
102
+ $phpcsFile->fixer->replaceToken($stackPtr, '<?php echo');
103
+ }
104
+ }
105
+ }
106
+
107
+ if ($token['code'] === T_INLINE_HTML) {
108
+ $content = $token['content'];
109
+ $openerFound = strpos($content, '<?');
110
+
111
+ if ($openerFound === false) {
112
+ return;
113
+ }
114
+
115
+ $closerFound = false;
116
+
117
+ // Inspect current token and subsequent inline HTML token to find a close tag.
118
+ for ($i = $stackPtr; $i < $phpcsFile->numTokens; $i++) {
119
+ if ($tokens[$i]['code'] !== T_INLINE_HTML) {
120
+ break;
121
+ }
122
+
123
+ $closerFound = strrpos($tokens[$i]['content'], '?>');
124
+ if ($closerFound !== false) {
125
+ if ($i !== $stackPtr) {
126
+ break;
127
+ } else if ($closerFound > $openerFound) {
128
+ break;
129
+ } else {
130
+ $closerFound = false;
131
+ }
132
+ }
133
+ }
134
+
135
+ if ($closerFound !== false) {
136
+ $error = 'Possible use of short open tags detected; found: %s';
137
+ $snippet = $this->getSnippet($content, '<?');
138
+ $data = array('<?'.$snippet);
139
+
140
+ $phpcsFile->addWarning($error, $stackPtr, 'PossibleFound', $data);
141
+
142
+ // Skip forward to the token containing the closer.
143
+ if (($i - 1) > $stackPtr) {
144
+ return $i;
145
+ }
146
+ }
147
+ }//end if
148
+
149
+ }//end process()
150
+
151
+
152
+ /**
153
+ * Get a snippet from a HTML token.
154
+ *
155
+ * @param string $content The content of the HTML token.
156
+ * @param string $start Partial string to use as a starting point for the snippet.
157
+ * @param int $length The target length of the snippet to get. Defaults to 40.
158
+ *
159
+ * @return string
160
+ */
161
+ protected function getSnippet($content, $start='', $length=40)
162
+ {
163
+ $startPos = 0;
164
+
165
+ if ($start !== '') {
166
+ $startPos = strpos($content, $start);
167
+ if ($startPos !== false) {
168
+ $startPos += strlen($start);
169
+ }
170
+ }
171
+
172
+ $snippet = substr($content, $startPos, $length);
173
+ if ((strlen($content) - $startPos) > $length) {
174
+ $snippet .= '...';
175
+ }
176
+
177
+ return $snippet;
178
+
179
+ }//end getSnippet()
180
+
181
+
182
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/ForbiddenFunctionsSniff.php ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_ForbiddenFunctionsSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_PHP_ForbiddenFunctionsSniff.
18
+ *
19
+ * Discourages the use of alias functions that are kept in PHP for compatibility
20
+ * with older versions. Can be used to forbid the use of any function.
21
+ *
22
+ * @category PHP
23
+ * @package PHP_CodeSniffer
24
+ * @author Greg Sherwood <gsherwood@squiz.net>
25
+ * @author Marc McIntyre <mmcintyre@squiz.net>
26
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
27
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
28
+ * @version Release: @package_version@
29
+ * @link http://pear.php.net/package/PHP_CodeSniffer
30
+ */
31
+ class Generic_Sniffs_PHP_ForbiddenFunctionsSniff implements PHP_CodeSniffer_Sniff
32
+ {
33
+
34
+ /**
35
+ * A list of forbidden functions with their alternatives.
36
+ *
37
+ * The value is NULL if no alternative exists. IE, the
38
+ * function should just not be used.
39
+ *
40
+ * @var array(string => string|null)
41
+ */
42
+ public $forbiddenFunctions = array(
43
+ 'sizeof' => 'count',
44
+ 'delete' => 'unset',
45
+ );
46
+
47
+ /**
48
+ * A cache of forbidden function names, for faster lookups.
49
+ *
50
+ * @var array(string)
51
+ */
52
+ protected $forbiddenFunctionNames = array();
53
+
54
+ /**
55
+ * If true, forbidden functions will be considered regular expressions.
56
+ *
57
+ * @var bool
58
+ */
59
+ protected $patternMatch = false;
60
+
61
+ /**
62
+ * If true, an error will be thrown; otherwise a warning.
63
+ *
64
+ * @var bool
65
+ */
66
+ public $error = true;
67
+
68
+
69
+ /**
70
+ * Returns an array of tokens this test wants to listen for.
71
+ *
72
+ * @return array
73
+ */
74
+ public function register()
75
+ {
76
+ // Everyone has had a chance to figure out what forbidden functions
77
+ // they want to check for, so now we can cache out the list.
78
+ $this->forbiddenFunctionNames = array_keys($this->forbiddenFunctions);
79
+
80
+ if ($this->patternMatch === true) {
81
+ foreach ($this->forbiddenFunctionNames as $i => $name) {
82
+ $this->forbiddenFunctionNames[$i] = '/'.$name.'/i';
83
+ }
84
+
85
+ return array(T_STRING);
86
+ }
87
+
88
+ // If we are not pattern matching, we need to work out what
89
+ // tokens to listen for.
90
+ $string = '<?php ';
91
+ foreach ($this->forbiddenFunctionNames as $name) {
92
+ $string .= $name.'();';
93
+ }
94
+
95
+ $register = array();
96
+
97
+ $tokens = token_get_all($string);
98
+ array_shift($tokens);
99
+ foreach ($tokens as $token) {
100
+ if (is_array($token) === true) {
101
+ $register[] = $token[0];
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()
111
+
112
+
113
+ /**
114
+ * Processes this test, when one of its tokens is encountered.
115
+ *
116
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
117
+ * @param int $stackPtr The position of the current token in
118
+ * the stack passed in $tokens.
119
+ *
120
+ * @return void
121
+ */
122
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
123
+ {
124
+ $tokens = $phpcsFile->getTokens();
125
+
126
+ $ignore = array(
127
+ T_DOUBLE_COLON => true,
128
+ T_OBJECT_OPERATOR => true,
129
+ T_FUNCTION => true,
130
+ T_CONST => true,
131
+ T_PUBLIC => true,
132
+ T_PRIVATE => true,
133
+ T_PROTECTED => true,
134
+ T_AS => true,
135
+ T_NEW => true,
136
+ T_INSTEADOF => true,
137
+ T_NS_SEPARATOR => true,
138
+ T_IMPLEMENTS => true,
139
+ );
140
+
141
+ $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
142
+
143
+ // If function call is directly preceded by a NS_SEPARATOR it points to the
144
+ // global namespace, so we should still catch it.
145
+ if ($tokens[$prevToken]['code'] === T_NS_SEPARATOR) {
146
+ $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($prevToken - 1), null, true);
147
+ if ($tokens[$prevToken]['code'] === T_STRING) {
148
+ // Not in the global namespace.
149
+ return;
150
+ }
151
+ }
152
+
153
+ if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
154
+ // Not a call to a PHP function.
155
+ return;
156
+ }
157
+
158
+ $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
159
+ if (isset($ignore[$tokens[$nextToken]['code']]) === true) {
160
+ // Not a call to a PHP function.
161
+ return;
162
+ }
163
+
164
+ if ($tokens[$stackPtr]['code'] === T_STRING && $tokens[$nextToken]['code'] !== T_OPEN_PARENTHESIS) {
165
+ // Not a call to a PHP function.
166
+ return;
167
+ }
168
+
169
+ $function = strtolower($tokens[$stackPtr]['content']);
170
+ $pattern = null;
171
+
172
+ if ($this->patternMatch === true) {
173
+ $count = 0;
174
+ $pattern = preg_replace(
175
+ $this->forbiddenFunctionNames,
176
+ $this->forbiddenFunctionNames,
177
+ $function,
178
+ 1,
179
+ $count
180
+ );
181
+
182
+ if ($count === 0) {
183
+ return;
184
+ }
185
+
186
+ // Remove the pattern delimiters and modifier.
187
+ $pattern = substr($pattern, 1, -2);
188
+ } else {
189
+ if (in_array($function, $this->forbiddenFunctionNames) === false) {
190
+ return;
191
+ }
192
+ }//end if
193
+
194
+ $this->addError($phpcsFile, $stackPtr, $tokens[$stackPtr]['content'], $pattern);
195
+
196
+ }//end process()
197
+
198
+
199
+ /**
200
+ * Generates the error or warning for this sniff.
201
+ *
202
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
203
+ * @param int $stackPtr The position of the forbidden function
204
+ * in the token array.
205
+ * @param string $function The name of the forbidden function.
206
+ * @param string $pattern The pattern used for the match.
207
+ *
208
+ * @return void
209
+ */
210
+ protected function addError($phpcsFile, $stackPtr, $function, $pattern=null)
211
+ {
212
+ $data = array($function);
213
+ $error = 'The use of function %s() is ';
214
+ if ($this->error === true) {
215
+ $type = 'Found';
216
+ $error .= 'forbidden';
217
+ } else {
218
+ $type = 'Discouraged';
219
+ $error .= 'discouraged';
220
+ }
221
+
222
+ if ($pattern === null) {
223
+ $pattern = strtolower($function);
224
+ }
225
+
226
+ if ($this->forbiddenFunctions[$pattern] !== null
227
+ && $this->forbiddenFunctions[$pattern] !== 'null'
228
+ ) {
229
+ $type .= 'WithAlternative';
230
+ $data[] = $this->forbiddenFunctions[$pattern];
231
+ $error .= '; use %s() instead';
232
+ }
233
+
234
+ if ($this->error === true) {
235
+ $phpcsFile->addError($error, $stackPtr, $type, $data);
236
+ } else {
237
+ $phpcsFile->addWarning($error, $stackPtr, $type, $data);
238
+ }
239
+
240
+ }//end addError()
241
+
242
+
243
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseConstantSniff.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_LowerCaseConstantSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_PHP_LowerCaseConstantSniff.
18
+ *
19
+ * Checks that all uses of true, false and null are lowercase.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Marc McIntyre <mmcintyre@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_PHP_LowerCaseConstantSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+ /**
34
+ * A list of tokenizers this sniff supports.
35
+ *
36
+ * @var array
37
+ */
38
+ public $supportedTokenizers = array(
39
+ 'PHP',
40
+ 'JS',
41
+ );
42
+
43
+
44
+ /**
45
+ * Returns an array of tokens this test wants to listen for.
46
+ *
47
+ * @return array
48
+ */
49
+ public function register()
50
+ {
51
+ return array(
52
+ T_TRUE,
53
+ T_FALSE,
54
+ T_NULL,
55
+ );
56
+
57
+ }//end register()
58
+
59
+
60
+ /**
61
+ * Processes this sniff, when one of its tokens is encountered.
62
+ *
63
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
64
+ * @param int $stackPtr The position of the current token in the
65
+ * stack passed in $tokens.
66
+ *
67
+ * @return void
68
+ */
69
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
70
+ {
71
+ $tokens = $phpcsFile->getTokens();
72
+ $keyword = $tokens[$stackPtr]['content'];
73
+ $expected = strtolower($keyword);
74
+ if ($keyword !== $expected) {
75
+ if ($keyword === strtoupper($keyword)) {
76
+ $phpcsFile->recordMetric($stackPtr, 'PHP constant case', 'upper');
77
+ } else {
78
+ $phpcsFile->recordMetric($stackPtr, 'PHP constant case', 'mixed');
79
+ }
80
+
81
+ $error = 'TRUE, FALSE and NULL must be lowercase; expected "%s" but found "%s"';
82
+ $data = array(
83
+ $expected,
84
+ $keyword,
85
+ );
86
+
87
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data);
88
+ if ($fix === true) {
89
+ $phpcsFile->fixer->replaceToken($stackPtr, $expected);
90
+ }
91
+ } else {
92
+ $phpcsFile->recordMetric($stackPtr, 'PHP constant case', 'lower');
93
+ }
94
+
95
+ }//end process()
96
+
97
+
98
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/LowerCaseKeywordSniff.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_LowerCaseKeywordSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_PHP_LowerCaseKeywordSniff.
17
+ *
18
+ * Checks that all PHP keywords are lowercase.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_PHP_LowerCaseKeywordSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+
32
+ /**
33
+ * Returns an array of tokens this test wants to listen for.
34
+ *
35
+ * @return array
36
+ */
37
+ public function register()
38
+ {
39
+ return array(
40
+ T_HALT_COMPILER,
41
+ T_ABSTRACT,
42
+ T_ARRAY,
43
+ T_ARRAY_HINT,
44
+ T_AS,
45
+ T_BREAK,
46
+ T_CALLABLE,
47
+ T_CASE,
48
+ T_CATCH,
49
+ T_CLASS,
50
+ T_CLONE,
51
+ T_CONST,
52
+ T_CONTINUE,
53
+ T_DECLARE,
54
+ T_DEFAULT,
55
+ T_DO,
56
+ T_ECHO,
57
+ T_ELSE,
58
+ T_ELSEIF,
59
+ T_EMPTY,
60
+ T_ENDDECLARE,
61
+ T_ENDFOR,
62
+ T_ENDFOREACH,
63
+ T_ENDIF,
64
+ T_ENDSWITCH,
65
+ T_ENDWHILE,
66
+ T_EVAL,
67
+ T_EXIT,
68
+ T_EXTENDS,
69
+ T_FINAL,
70
+ T_FINALLY,
71
+ T_FOR,
72
+ T_FOREACH,
73
+ T_FUNCTION,
74
+ T_GLOBAL,
75
+ T_GOTO,
76
+ T_IF,
77
+ T_IMPLEMENTS,
78
+ T_INCLUDE,
79
+ T_INCLUDE_ONCE,
80
+ T_INSTANCEOF,
81
+ T_INSTEADOF,
82
+ T_INTERFACE,
83
+ T_ISSET,
84
+ T_LIST,
85
+ T_LOGICAL_AND,
86
+ T_LOGICAL_OR,
87
+ T_LOGICAL_XOR,
88
+ T_NAMESPACE,
89
+ T_NEW,
90
+ T_PRINT,
91
+ T_PRIVATE,
92
+ T_PROTECTED,
93
+ T_PUBLIC,
94
+ T_REQUIRE,
95
+ T_REQUIRE_ONCE,
96
+ T_RETURN,
97
+ T_STATIC,
98
+ T_SWITCH,
99
+ T_THROW,
100
+ T_TRAIT,
101
+ T_TRY,
102
+ T_UNSET,
103
+ T_USE,
104
+ T_VAR,
105
+ T_WHILE,
106
+ );
107
+
108
+ }//end register()
109
+
110
+
111
+ /**
112
+ * Processes this sniff, when one of its tokens is encountered.
113
+ *
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
+ *
118
+ * @return void
119
+ */
120
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
121
+ {
122
+ $tokens = $phpcsFile->getTokens();
123
+ $keyword = $tokens[$stackPtr]['content'];
124
+ if (strtolower($keyword) !== $keyword) {
125
+ if ($keyword === strtoupper($keyword)) {
126
+ $phpcsFile->recordMetric($stackPtr, 'PHP keyword case', 'upper');
127
+ } else {
128
+ $phpcsFile->recordMetric($stackPtr, 'PHP keyword case', 'mixed');
129
+ }
130
+
131
+ $error = 'PHP keywords must be lowercase; expected "%s" but found "%s"';
132
+ $data = array(
133
+ strtolower($keyword),
134
+ $keyword,
135
+ );
136
+
137
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data);
138
+ if ($fix === true) {
139
+ $phpcsFile->fixer->replaceToken($stackPtr, strtolower($keyword));
140
+ }
141
+ } else {
142
+ $phpcsFile->recordMetric($stackPtr, 'PHP keyword case', 'lower');
143
+ }
144
+
145
+ }//end process()
146
+
147
+
148
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/NoSilencedErrorsSniff.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_NoSilencedErrorsSniff
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Andy Brockhurst <abrock@yahoo-inc.com>
10
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
11
+ * @link http://pear.php.net/package/PHP_CodeSniffer
12
+ */
13
+
14
+ /**
15
+ * Generic_Sniffs_PHP_NoSilencedErrorsSniff.
16
+ *
17
+ * Throws an error or warning when any code prefixed with an asperand is encountered.
18
+ *
19
+ * <code>
20
+ * if (@in_array($array, $needle))
21
+ * {
22
+ * doSomething();
23
+ * }
24
+ * </code>
25
+ *
26
+ * @category PHP
27
+ * @package PHP_CodeSniffer
28
+ * @author Andy Brockhurst <abrock@yahoo-inc.com>
29
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
30
+ * @version Release: @package_version@
31
+ * @link http://pear.php.net/package/PHP_CodeSniffer
32
+ */
33
+ class Generic_Sniffs_PHP_NoSilencedErrorsSniff implements PHP_CodeSniffer_Sniff
34
+ {
35
+
36
+ /**
37
+ * If true, an error will be thrown; otherwise a warning.
38
+ *
39
+ * @var bool
40
+ */
41
+ public $error = false;
42
+
43
+
44
+ /**
45
+ * Returns an array of tokens this test wants to listen for.
46
+ *
47
+ * @return array
48
+ */
49
+ public function register()
50
+ {
51
+ return array(T_ASPERAND);
52
+
53
+ }//end register()
54
+
55
+
56
+ /**
57
+ * Processes this test, when one of its tokens is encountered.
58
+ *
59
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
60
+ * @param int $stackPtr The position of the current token
61
+ * in the stack passed in $tokens.
62
+ *
63
+ * @return void
64
+ */
65
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
66
+ {
67
+ $error = 'Silencing errors is forbidden';
68
+ if ($this->error === true) {
69
+ $error = 'Silencing errors is forbidden';
70
+ $phpcsFile->addError($error, $stackPtr, 'Forbidden');
71
+ } else {
72
+ $error = 'Silencing errors is discouraged';
73
+ $phpcsFile->addWarning($error, $stackPtr, 'Discouraged');
74
+ }
75
+
76
+ }//end process()
77
+
78
+
79
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/SAPIUsageSniff.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_SAPIUsageSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_PHP_SAPIUsageSniff.
17
+ *
18
+ * Ensures the PHP_SAPI constant is used instead of php_sapi_name().
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_PHP_SAPIUsageSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+
32
+ /**
33
+ * Returns an array of tokens this test wants to listen for.
34
+ *
35
+ * @return array
36
+ */
37
+ public function register()
38
+ {
39
+ return array(T_STRING);
40
+
41
+ }//end register()
42
+
43
+
44
+ /**
45
+ * Processes this test, when one of its tokens is encountered.
46
+ *
47
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
48
+ * @param int $stackPtr The position of the current token in
49
+ * the stack passed in $tokens.
50
+ *
51
+ * @return void
52
+ */
53
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
54
+ {
55
+ $tokens = $phpcsFile->getTokens();
56
+
57
+ $ignore = array(
58
+ T_DOUBLE_COLON => true,
59
+ T_OBJECT_OPERATOR => true,
60
+ T_FUNCTION => true,
61
+ T_CONST => true,
62
+ );
63
+
64
+ $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
65
+ if (isset($ignore[$tokens[$prevToken]['code']]) === true) {
66
+ // Not a call to a PHP function.
67
+ return;
68
+ }
69
+
70
+ $function = strtolower($tokens[$stackPtr]['content']);
71
+ if ($function === 'php_sapi_name') {
72
+ $error = 'Use the PHP_SAPI constant instead of calling php_sapi_name()';
73
+ $phpcsFile->addError($error, $stackPtr, 'FunctionFound');
74
+ }
75
+
76
+ }//end process()
77
+
78
+
79
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/SyntaxSniff.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_SyntaxSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Blaine Schmeisser <blainesch@gmail.com>
10
+ * @author Greg Sherwood <gsherwood@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_PHP_SyntaxSniff.
18
+ *
19
+ * Ensures PHP believes the syntax is clean.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Blaine Schmeisser <blainesch@gmail.com>
24
+ * @author Greg Sherwood <gsherwood@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
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.
43
+ *
44
+ * @return array
45
+ */
46
+ public function register()
47
+ {
48
+ return array(T_OPEN_TAG);
49
+
50
+ }//end register()
51
+
52
+
53
+ /**
54
+ * Processes this test, when one of its tokens is encountered.
55
+ *
56
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
57
+ * @param int $stackPtr The position of the current token in
58
+ * the stack passed in $tokens.
59
+ *
60
+ * @return void
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');
89
+ }
90
+
91
+ // Ignore the rest of the file.
92
+ return ($phpcsFile->numTokens + 1);
93
+
94
+ }//end process()
95
+
96
+
97
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/PHP/UpperCaseConstantSniff.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_PHP_UpperCaseConstantSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_PHP_UpperCaseConstantSniff.
18
+ *
19
+ * Checks that all uses of TRUE, FALSE and NULL are uppercase.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Marc McIntyre <mmcintyre@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_PHP_UpperCaseConstantSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+
34
+ /**
35
+ * Returns an array of tokens this test wants to listen for.
36
+ *
37
+ * @return array
38
+ */
39
+ public function register()
40
+ {
41
+ return array(
42
+ T_TRUE,
43
+ T_FALSE,
44
+ T_NULL,
45
+ );
46
+
47
+ }//end register()
48
+
49
+
50
+ /**
51
+ * Processes this sniff, when one of its tokens is encountered.
52
+ *
53
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
54
+ * @param int $stackPtr The position of the current token in the
55
+ * stack passed in $tokens.
56
+ *
57
+ * @return void
58
+ */
59
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
60
+ {
61
+ $tokens = $phpcsFile->getTokens();
62
+ $keyword = $tokens[$stackPtr]['content'];
63
+ $expected = strtoupper($keyword);
64
+ if ($keyword !== $expected) {
65
+ if ($keyword === strtolower($keyword)) {
66
+ $phpcsFile->recordMetric($stackPtr, 'PHP constant case', 'lower');
67
+ } else {
68
+ $phpcsFile->recordMetric($stackPtr, 'PHP constant case', 'mixed');
69
+ }
70
+
71
+ $error = 'TRUE, FALSE and NULL must be uppercase; expected "%s" but found "%s"';
72
+ $data = array(
73
+ $expected,
74
+ $keyword,
75
+ );
76
+
77
+ $fix = $phpcsFile->addFixableError($error, $stackPtr, 'Found', $data);
78
+ if ($fix === true) {
79
+ $phpcsFile->fixer->replaceToken($stackPtr, $expected);
80
+ }
81
+ } else {
82
+ $phpcsFile->recordMetric($stackPtr, 'PHP constant case', 'upper');
83
+ }
84
+
85
+ }//end process()
86
+
87
+
88
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/Strings/UnnecessaryStringConcatSniff.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Strings_UnnecessaryStringConcatSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_Strings_UnnecessaryStringConcatSniff.
17
+ *
18
+ * Checks that two strings are not concatenated together; suggests
19
+ * using one string instead.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
25
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
26
+ * @version Release: @package_version@
27
+ * @link http://pear.php.net/package/PHP_CodeSniffer
28
+ */
29
+ class Generic_Sniffs_Strings_UnnecessaryStringConcatSniff implements PHP_CodeSniffer_Sniff
30
+ {
31
+
32
+ /**
33
+ * A list of tokenizers this sniff supports.
34
+ *
35
+ * @var array
36
+ */
37
+ public $supportedTokenizers = array(
38
+ 'PHP',
39
+ 'JS',
40
+ );
41
+
42
+ /**
43
+ * If true, an error will be thrown; otherwise a warning.
44
+ *
45
+ * @var bool
46
+ */
47
+ public $error = true;
48
+
49
+ /**
50
+ * If true, strings concatenated over multiple lines are allowed.
51
+ *
52
+ * Useful if you break strings over multiple lines to work
53
+ * within a max line length.
54
+ *
55
+ * @var bool
56
+ */
57
+ public $allowMultiline = false;
58
+
59
+
60
+ /**
61
+ * Returns an array of tokens this test wants to listen for.
62
+ *
63
+ * @return array
64
+ */
65
+ public function register()
66
+ {
67
+ return array(
68
+ T_STRING_CONCAT,
69
+ T_PLUS,
70
+ );
71
+
72
+ }//end register()
73
+
74
+
75
+ /**
76
+ * Processes this sniff, when one of its tokens is encountered.
77
+ *
78
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
79
+ * @param int $stackPtr The position of the current token
80
+ * in the stack passed in $tokens.
81
+ *
82
+ * @return void
83
+ */
84
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
85
+ {
86
+ // Work out which type of file this is for.
87
+ $tokens = $phpcsFile->getTokens();
88
+ if ($tokens[$stackPtr]['code'] === T_STRING_CONCAT) {
89
+ if ($phpcsFile->tokenizerType === 'JS') {
90
+ return;
91
+ }
92
+ } else {
93
+ if ($phpcsFile->tokenizerType === 'PHP') {
94
+ return;
95
+ }
96
+ }
97
+
98
+ $prev = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
99
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
100
+ if ($prev === false || $next === false) {
101
+ return;
102
+ }
103
+
104
+ if (isset(PHP_CodeSniffer_Tokens::$stringTokens[$tokens[$prev]['code']]) === true
105
+ && isset(PHP_CodeSniffer_Tokens::$stringTokens[$tokens[$next]['code']]) === true
106
+ ) {
107
+ if ($tokens[$prev]['content'][0] === $tokens[$next]['content'][0]) {
108
+ // Before we throw an error for PHP, allow strings to be
109
+ // combined if they would have < and ? next to each other because
110
+ // this trick is sometimes required in PHP strings.
111
+ if ($phpcsFile->tokenizerType === 'PHP') {
112
+ $prevChar = substr($tokens[$prev]['content'], -2, 1);
113
+ $nextChar = $tokens[$next]['content'][1];
114
+ $combined = $prevChar.$nextChar;
115
+ if ($combined === '?'.'>' || $combined === '<'.'?') {
116
+ return;
117
+ }
118
+ }
119
+
120
+ if ($this->allowMultiline === true
121
+ && $tokens[$prev]['line'] !== $tokens[$next]['line']
122
+ ) {
123
+ return;
124
+ }
125
+
126
+ $error = 'String concat is not required here; use a single string instead';
127
+ if ($this->error === true) {
128
+ $phpcsFile->addError($error, $stackPtr, 'Found');
129
+ } else {
130
+ $phpcsFile->addWarning($error, $stackPtr, 'Found');
131
+ }
132
+ }//end if
133
+ }//end if
134
+
135
+ }//end process()
136
+
137
+
138
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/VersionControl/SubversionPropertiesSniff.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_VersionControl_SubversionPropertiesSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Jack Bates <ms419@freezone.co.uk>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_VersionControl_SubversionPropertiesSniff.
17
+ *
18
+ * Tests that the correct Subversion properties are set.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Jack Bates <ms419@freezone.co.uk>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_VersionControl_SubversionPropertiesSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+ /**
32
+ * The Subversion properties that should be set.
33
+ *
34
+ * Key of array is the SVN property and the value is the
35
+ * exact value the property should have or NULL if the
36
+ * property should just be set but the value is not fixed.
37
+ *
38
+ * @var array
39
+ */
40
+ protected $properties = array(
41
+ 'svn:keywords' => 'Author Id Revision',
42
+ 'svn:eol-style' => 'native',
43
+ );
44
+
45
+
46
+ /**
47
+ * Returns an array of tokens this test wants to listen for.
48
+ *
49
+ * @return array
50
+ */
51
+ public function register()
52
+ {
53
+ return array(T_OPEN_TAG);
54
+
55
+ }//end register()
56
+
57
+
58
+ /**
59
+ * Processes this test, when one of its tokens is encountered.
60
+ *
61
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
62
+ * @param int $stackPtr The position of the current token
63
+ * in the stack passed in $tokens.
64
+ *
65
+ * @return void
66
+ */
67
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
68
+ {
69
+ $tokens = $phpcsFile->getTokens();
70
+
71
+ // Make sure this is the first PHP open tag so we don't process the
72
+ // same file twice.
73
+ $prevOpenTag = $phpcsFile->findPrevious(T_OPEN_TAG, ($stackPtr - 1));
74
+ if ($prevOpenTag !== false) {
75
+ return;
76
+ }
77
+
78
+ $path = $phpcsFile->getFileName();
79
+ $properties = $this->getProperties($path);
80
+ if ($properties === null) {
81
+ // Not under version control.
82
+ return;
83
+ }
84
+
85
+ $allProperties = ($properties + $this->properties);
86
+ foreach ($allProperties as $key => $value) {
87
+ if (isset($properties[$key]) === true
88
+ && isset($this->properties[$key]) === false
89
+ ) {
90
+ $error = 'Unexpected Subversion property "%s" = "%s"';
91
+ $data = array(
92
+ $key,
93
+ $properties[$key],
94
+ );
95
+ $phpcsFile->addError($error, $stackPtr, 'Unexpected', $data);
96
+ continue;
97
+ }
98
+
99
+ if (isset($properties[$key]) === false
100
+ && isset($this->properties[$key]) === true
101
+ ) {
102
+ $error = 'Missing Subversion property "%s" = "%s"';
103
+ $data = array(
104
+ $key,
105
+ $this->properties[$key],
106
+ );
107
+ $phpcsFile->addError($error, $stackPtr, 'Missing', $data);
108
+ continue;
109
+ }
110
+
111
+ if ($properties[$key] !== null
112
+ && $properties[$key] !== $this->properties[$key]
113
+ ) {
114
+ $error = 'Subversion property "%s" = "%s" does not match "%s"';
115
+ $data = array(
116
+ $key,
117
+ $properties[$key],
118
+ $this->properties[$key],
119
+ );
120
+ $phpcsFile->addError($error, $stackPtr, 'NoMatch', $data);
121
+ }
122
+ }//end foreach
123
+
124
+ }//end process()
125
+
126
+
127
+ /**
128
+ * Returns the Subversion properties which are actually set on a path.
129
+ *
130
+ * Returns NULL if the file is not under version control.
131
+ *
132
+ * @param string $path The path to return Subversion properties on.
133
+ *
134
+ * @return array
135
+ * @throws PHP_CodeSniffer_Exception If Subversion properties file could
136
+ * not be opened.
137
+ */
138
+ protected function getProperties($path)
139
+ {
140
+ $properties = array();
141
+
142
+ $paths = array();
143
+ $paths[] = dirname($path).'/.svn/props/'.basename($path).'.svn-work';
144
+ $paths[] = dirname($path).'/.svn/prop-base/'.basename($path).'.svn-base';
145
+
146
+ $foundPath = false;
147
+ foreach ($paths as $path) {
148
+ if (file_exists($path) === true) {
149
+ $foundPath = true;
150
+
151
+ $handle = fopen($path, 'r');
152
+ if ($handle === false) {
153
+ $error = 'Error opening file; could not get Subversion properties';
154
+ throw new PHP_CodeSniffer_Exception($error);
155
+ }
156
+
157
+ while (feof($handle) === false) {
158
+ // Read a key length line. Might be END, though.
159
+ $buffer = trim(fgets($handle));
160
+
161
+ // Check for the end of the hash.
162
+ if ($buffer === 'END') {
163
+ break;
164
+ }
165
+
166
+ // Now read that much into a buffer.
167
+ $key = fread($handle, substr($buffer, 2));
168
+
169
+ // Suck up extra newline after key data.
170
+ fgetc($handle);
171
+
172
+ // Read a value length line.
173
+ $buffer = trim(fgets($handle));
174
+
175
+ // Now read that much into a buffer.
176
+ $length = substr($buffer, 2);
177
+ if ($length === '0') {
178
+ // Length of value is ZERO characters, so
179
+ // value is actually empty.
180
+ $value = '';
181
+ } else {
182
+ $value = fread($handle, $length);
183
+ }
184
+
185
+ // Suck up extra newline after value data.
186
+ fgetc($handle);
187
+
188
+ $properties[$key] = $value;
189
+ }//end while
190
+
191
+ fclose($handle);
192
+ }//end if
193
+ }//end foreach
194
+
195
+ if ($foundPath === false) {
196
+ return null;
197
+ }
198
+
199
+ return $properties;
200
+
201
+ }//end getProperties()
202
+
203
+
204
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_WhiteSpace_DisallowSpaceIndentSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
11
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
12
+ * @link http://pear.php.net/package/PHP_CodeSniffer
13
+ */
14
+
15
+ /**
16
+ * Generic_Sniffs_WhiteSpace_DisallowSpaceIndentSniff.
17
+ *
18
+ * Throws errors if spaces are used for indentation other than precision indentation.
19
+ *
20
+ * @category PHP
21
+ * @package PHP_CodeSniffer
22
+ * @author Greg Sherwood <gsherwood@squiz.net>
23
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
24
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
25
+ * @version Release: @package_version@
26
+ * @link http://pear.php.net/package/PHP_CodeSniffer
27
+ */
28
+ class Generic_Sniffs_WhiteSpace_DisallowSpaceIndentSniff implements PHP_CodeSniffer_Sniff
29
+ {
30
+
31
+ /**
32
+ * A list of tokenizers this sniff supports.
33
+ *
34
+ * @var array
35
+ */
36
+ public $supportedTokenizers = array(
37
+ 'PHP',
38
+ 'JS',
39
+ 'CSS',
40
+ );
41
+
42
+ /**
43
+ * The --tab-width CLI value that is being used.
44
+ *
45
+ * @var int
46
+ */
47
+ private $_tabWidth = null;
48
+
49
+
50
+ /**
51
+ * Returns an array of tokens this test wants to listen for.
52
+ *
53
+ * @return array
54
+ */
55
+ public function register()
56
+ {
57
+ return array(T_OPEN_TAG);
58
+
59
+ }//end register()
60
+
61
+
62
+ /**
63
+ * Processes this test, when one of its tokens is encountered.
64
+ *
65
+ * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document.
66
+ * @param int $stackPtr The position of the current token in
67
+ * the stack passed in $tokens.
68
+ *
69
+ * @return void
70
+ */
71
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
72
+ {
73
+ if ($this->_tabWidth === null) {
74
+ $cliValues = $phpcsFile->phpcs->cli->getCommandLineValues();
75
+ if (isset($cliValues['tabWidth']) === false || $cliValues['tabWidth'] === 0) {
76
+ // We have no idea how wide tabs are, so assume 4 spaces for fixing.
77
+ // It shouldn't really matter because indent checks elsewhere in the
78
+ // standard should fix things up.
79
+ $this->_tabWidth = 4;
80
+ } else {
81
+ $this->_tabWidth = $cliValues['tabWidth'];
82
+ }
83
+ }
84
+
85
+ $checkTokens = array(
86
+ T_WHITESPACE => true,
87
+ T_INLINE_HTML => true,
88
+ T_DOC_COMMENT_WHITESPACE => true,
89
+ );
90
+
91
+ $tokens = $phpcsFile->getTokens();
92
+ for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
93
+ if ($tokens[$i]['column'] !== 1 || isset($checkTokens[$tokens[$i]['code']]) === false) {
94
+ continue;
95
+ }
96
+
97
+ // If tabs are being converted to spaces by the tokeniser, the
98
+ // original content should be checked instead of the converted content.
99
+ if (isset($tokens[$i]['orig_content']) === true) {
100
+ $content = $tokens[$i]['orig_content'];
101
+ } else {
102
+ $content = $tokens[$i]['content'];
103
+ }
104
+
105
+ // If this is an inline HTML token, split the content into
106
+ // indentation whitespace and the actual HTML/text.
107
+ $nonWhitespace = '';
108
+ if ($tokens[$i]['code'] === T_INLINE_HTML && preg_match('`^(\s*)(\S.*)`s', $content, $matches) > 0) {
109
+ if (isset($matches[1]) === true) {
110
+ $content = $matches[1];
111
+ }
112
+
113
+ if (isset($matches[2]) === true) {
114
+ $nonWhitespace = $matches[2];
115
+ }
116
+ }
117
+
118
+ $hasSpaces = strpos($content, ' ');
119
+ $hasTabs = strpos($content, "\t");
120
+
121
+ if ($hasSpaces === false && $hasTabs === false) {
122
+ // Empty line.
123
+ continue;
124
+ }
125
+
126
+ if ($hasSpaces === false && $hasTabs !== false) {
127
+ // All ok, nothing to do.
128
+ $phpcsFile->recordMetric($i, 'Line indent', 'tabs');
129
+ continue;
130
+ }
131
+
132
+ if ($tokens[$i]['code'] === T_DOC_COMMENT_WHITESPACE && $content === ' ') {
133
+ // Ignore file/class-level DocBlock, especially for recording metrics.
134
+ continue;
135
+ }
136
+
137
+ // OK, by now we know there will be spaces.
138
+ // We just don't know yet whether they need to be replaced or
139
+ // are precision indentation, nor whether they are correctly
140
+ // placed at the end of the whitespace.
141
+ $trimmed = str_replace(' ', '', $content);
142
+ $numSpaces = (strlen($content) - strlen($trimmed));
143
+ $numTabs = (int) floor($numSpaces / $this->_tabWidth);
144
+ $tabAfterSpaces = strpos($content, "\t", $hasSpaces);
145
+
146
+ if ($hasTabs === false) {
147
+ $phpcsFile->recordMetric($i, 'Line indent', 'spaces');
148
+
149
+ if ($numTabs === 0) {
150
+ // Ignore: precision indentation.
151
+ continue;
152
+ }
153
+ } else {
154
+ if ($numTabs === 0) {
155
+ // Precision indentation.
156
+ $phpcsFile->recordMetric($i, 'Line indent', 'tabs');
157
+
158
+ if ($tabAfterSpaces === false) {
159
+ // Ignore: precision indentation is already at the
160
+ // end of the whitespace.
161
+ continue;
162
+ }
163
+ } else {
164
+ $phpcsFile->recordMetric($i, 'Line indent', 'mixed');
165
+ }
166
+ }//end if
167
+
168
+ $error = 'Tabs must be used to indent lines; spaces are not allowed';
169
+ $fix = $phpcsFile->addFixableError($error, $i, 'SpacesUsed');
170
+ if ($fix === true) {
171
+ $remaining = ($numSpaces % $this->_tabWidth);
172
+ $padding = str_repeat("\t", $numTabs);
173
+ $padding .= str_repeat(' ', $remaining);
174
+ $phpcsFile->fixer->replaceToken($i, $trimmed.$padding.$nonWhitespace);
175
+ }
176
+ }//end for
177
+
178
+ // Ignore the rest of the file.
179
+ return ($phpcsFile->numTokens + 1);
180
+
181
+ }//end process()
182
+
183
+
184
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/DisallowTabIndentSniff.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff.
18
+ *
19
+ * Throws errors if tabs are used for indentation.
20
+ *
21
+ * @category PHP
22
+ * @package PHP_CodeSniffer
23
+ * @author Greg Sherwood <gsherwood@squiz.net>
24
+ * @author Marc McIntyre <mmcintyre@squiz.net>
25
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
26
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
27
+ * @version Release: @package_version@
28
+ * @link http://pear.php.net/package/PHP_CodeSniffer
29
+ */
30
+ class Generic_Sniffs_WhiteSpace_DisallowTabIndentSniff implements PHP_CodeSniffer_Sniff
31
+ {
32
+
33
+ /**
34
+ * A list of tokenizers this sniff supports.
35
+ *
36
+ * @var array
37
+ */
38
+ public $supportedTokenizers = array(
39
+ 'PHP',
40
+ 'JS',
41
+ 'CSS',
42
+ );
43
+
44
+
45
+ /**
46
+ * Returns an array of tokens this test wants to listen for.
47
+ *
48
+ * @return array
49
+ */
50
+ public function register()
51
+ {
52
+ return array(T_OPEN_TAG);
53
+
54
+ }//end register()
55
+
56
+
57
+ /**
58
+ * Processes this test, when one of its tokens is encountered.
59
+ *
60
+ * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document.
61
+ * @param int $stackPtr The position of the current token in
62
+ * the stack passed in $tokens.
63
+ *
64
+ * @return void
65
+ */
66
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
67
+ {
68
+ $tokens = $phpcsFile->getTokens();
69
+ $error = 'Spaces must be used to indent lines; tabs are not allowed';
70
+ $errorCode = 'TabsUsed';
71
+
72
+ $checkTokens = array(
73
+ T_WHITESPACE => true,
74
+ T_INLINE_HTML => true,
75
+ T_DOC_COMMENT_WHITESPACE => true,
76
+ T_DOC_COMMENT_STRING => true,
77
+ );
78
+
79
+ for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
80
+ if (isset($checkTokens[$tokens[$i]['code']]) === false) {
81
+ continue;
82
+ }
83
+
84
+ // If tabs are being converted to spaces by the tokeniser, the
85
+ // original content should be checked instead of the converted content.
86
+ if (isset($tokens[$i]['orig_content']) === true) {
87
+ $content = $tokens[$i]['orig_content'];
88
+ } else {
89
+ $content = $tokens[$i]['content'];
90
+ }
91
+
92
+ if ($content === '') {
93
+ continue;
94
+ }
95
+
96
+ if ($tokens[$i]['code'] === T_DOC_COMMENT_WHITESPACE && $content === ' ') {
97
+ // Ignore file/class-level DocBlock, especially for recording metrics.
98
+ continue;
99
+ }
100
+
101
+ $tabFound = false;
102
+ if ($tokens[$i]['column'] === 1) {
103
+ if ($content[0] === "\t") {
104
+ $phpcsFile->recordMetric($i, 'Line indent', 'tabs');
105
+ $tabFound = true;
106
+ } else if ($content[0] === ' ') {
107
+ if (strpos($content, "\t") !== false) {
108
+ $phpcsFile->recordMetric($i, 'Line indent', 'mixed');
109
+ $tabFound = true;
110
+ } else {
111
+ $phpcsFile->recordMetric($i, 'Line indent', 'spaces');
112
+ }
113
+ }
114
+ } else {
115
+ // Look for tabs so we can report and replace, but don't
116
+ // record any metrics about them because they aren't
117
+ // line indent tokens.
118
+ if (strpos($content, "\t") !== false) {
119
+ $tabFound = true;
120
+ $error = 'Spaces must be used for alignment; tabs are not allowed';
121
+ $errorCode = 'NonIndentTabsUsed';
122
+ }
123
+ }//end if
124
+
125
+ if ($tabFound === false) {
126
+ continue;
127
+ }
128
+
129
+ $fix = $phpcsFile->addFixableError($error, $i, $errorCode);
130
+ if ($fix === true) {
131
+ if (isset($tokens[$i]['orig_content']) === true) {
132
+ // Use the replacement that PHPCS has already done.
133
+ $phpcsFile->fixer->replaceToken($i, $tokens[$i]['content']);
134
+ } else {
135
+ // Replace tabs with spaces, using an indent of 4 spaces.
136
+ // Other sniffs can then correct the indent if they need to.
137
+ $newContent = str_replace("\t", ' ', $tokens[$i]['content']);
138
+ $phpcsFile->fixer->replaceToken($i, $newContent);
139
+ }
140
+ }
141
+ }//end for
142
+
143
+ // Ignore the rest of the file.
144
+ return ($phpcsFile->numTokens + 1);
145
+
146
+ }//end process()
147
+
148
+
149
+ }//end class
php52/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/Generic/Sniffs/WhiteSpace/ScopeIndentSniff.php ADDED
@@ -0,0 +1,1276 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Generic_Sniffs_Whitespace_ScopeIndentSniff.
4
+ *
5
+ * PHP version 5
6
+ *
7
+ * @category PHP
8
+ * @package PHP_CodeSniffer
9
+ * @author Greg Sherwood <gsherwood@squiz.net>
10
+ * @author Marc McIntyre <mmcintyre@squiz.net>
11
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
12
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
13
+ * @link http://pear.php.net/package/PHP_CodeSniffer
14
+ */
15
+
16
+ /**
17
+ * Generic_Sniffs_Whitespace_ScopeIndentSniff.
18
+ *
19
+ * Checks that control structures are structured correctly, and their content
20
+ * is indented correctly. This sniff will throw errors if tabs are used
21
+ * for indentation rather than spaces.
22
+ *
23
+ * @category PHP
24
+ * @package PHP_CodeSniffer
25
+ * @author Greg Sherwood <gsherwood@squiz.net>
26
+ * @author Marc McIntyre <mmcintyre@squiz.net>
27
+ * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
28
+ * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
29
+ * @version Release: @package_version@
30
+ * @link http://pear.php.net/package/PHP_CodeSniffer
31
+ */
32
+ class Generic_Sniffs_WhiteSpace_ScopeIndentSniff implements PHP_CodeSniffer_Sniff
33
+ {
34
+
35
+ /**
36
+ * A list of tokenizers this sniff supports.
37
+ *
38
+ * @var array
39
+ */
40
+ public $supportedTokenizers = array(
41
+ 'PHP',
42
+ 'JS',
43
+ );
44
+
45
+ /**
46
+ * The number of spaces code should be indented.
47
+ *
48
+ * @var int
49
+ */
50
+ public $indent = 4;
51
+
52
+ /**
53
+ * Does the indent need to be exactly right?
54
+ *
55
+ * If TRUE, indent needs to be exactly $indent spaces. If FALSE,
56
+ * indent needs to be at least $indent spaces (but can be more).
57
+ *
58
+ * @var bool
59
+ */
60
+ public $exact = false;
61
+
62
+ /**
63
+ * Should tabs be used for indenting?
64
+ *
65
+ * If TRUE, fixes will be made using tabs instead of spaces.
66
+ * The size of each tab is important, so it should be specified
67
+ * using the --tab-width CLI argument.
68
+ *
69
+ * @var bool
70
+ */
71
+ public $tabIndent = false;
72
+
73
+ /**
74
+ * The --tab-width CLI value that is being used.
75
+ *
76
+ * @var int
77
+ */
78
+ private $_tabWidth = null;
79
+
80
+ /**
81
+ * List of tokens not needing to be checked for indentation.
82
+ *
83
+ * Useful to allow Sniffs based on this to easily ignore/skip some
84
+ * tokens from verification. For example, inline HTML sections
85
+ * or PHP open/close tags can escape from here and have their own
86
+ * rules elsewhere.
87
+ *
88
+ * @var int[]
89
+ */
90
+ public $ignoreIndentationTokens = array();
91
+
92
+ /**
93
+ * List of tokens not needing to be checked for indentation.
94
+ *
95
+ * This is a cached copy of the public version of this var, which
96
+ * can be set in a ruleset file, and some core ignored tokens.
97
+ *
98
+ * @var int[]
99
+ */
100
+ private $_ignoreIndentationTokens = array();
101
+
102
+ /**
103
+ * Any scope openers that should not cause an indent.
104
+ *
105
+ * @var int[]
106
+ */
107
+ protected $nonIndentingScopes = array();
108
+
109
+ /**
110
+ * Show debug output for this sniff.
111
+ *
112
+ * @var bool
113
+ */
114
+ private $_debug = false;
115
+
116
+
117
+ /**
118
+ * Returns an array of tokens this test wants to listen for.
119
+ *
120
+ * @return array
121
+ */
122
+ public function register()
123
+ {
124
+ if (defined('PHP_CODESNIFFER_IN_TESTS') === true) {
125
+ $this->_debug = false;
126
+ }
127
+
128
+ return array(T_OPEN_TAG);
129
+
130
+ }//end register()
131
+
132
+
133
+ /**
134
+ * Processes this test, when one of its tokens is encountered.
135
+ *
136
+ * @param PHP_CodeSniffer_File $phpcsFile All the tokens found in the document.
137
+ * @param int $stackPtr The position of the current token
138
+ * in the stack passed in $tokens.
139
+ *
140
+ * @return void
141
+ */
142
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
143
+ {
144
+ $debug = PHP_CodeSniffer::getConfigData('scope_indent_debug');
145
+ if ($debug !== null) {
146
+ $this->_debug = (bool) $debug;
147
+ }
148
+
149
+ if ($this->_tabWidth === null) {
150
+ $cliValues = $phpcsFile->phpcs->cli->getCommandLineValues();
151
+ if (isset($cliValues['tabWidth']) === false || $cliValues['tabWidth'] === 0) {
152
+ // We have no idea how wide tabs are, so assume 4 spaces for fixing.
153
+ // It shouldn't really matter because indent checks elsewhere in the
154
+ // standard should fix things up.
155
+ $this->_tabWidth = 4;
156
+ } else {
157
+ $this->_tabWidth = $cliValues['tabWidth'];
158
+ }
159
+ }
160
+
161
+ $currentIndent = 0;
162
+ $lastOpenTag = $stackPtr;
163
+ $lastCloseTag = null;
164
+ $openScopes = array();
165
+ $adjustments = array();
166
+ $setIndents = array();
167
+
168
+ $tokens = $phpcsFile->getTokens();
169
+ $first = $phpcsFile->findFirstOnLine(T_INLINE_HTML, $stackPtr);
170
+ $trimmed = ltrim($tokens[$first]['content']);
171
+ if ($trimmed === '') {
172
+ $currentIndent = ($tokens[$stackPtr]['column'] - 1);
173
+ } else {
174
+ $currentIndent = (strlen($tokens[$first]['content']) - strlen($trimmed));
175
+ }
176
+
177
+ if ($this->_debug === true) {
178
+ $line = $tokens[$stackPtr]['line'];
179
+ echo "Start with token $stackPtr on line $line with indent $currentIndent".PHP_EOL;
180
+ }
181
+
182
+ if (empty($this->_ignoreIndentationTokens) === true) {
183
+ $this->_ignoreIndentationTokens = array(T_INLINE_HTML => true);
184
+ foreach ($this->ignoreIndentationTokens as $token) {
185
+ if (is_int($token) === false) {
186
+ if (defined($token) === false) {
187
+ continue;
188
+ }
189
+
190
+ $token = constant($token);
191
+ }
192
+
193
+ $this->_ignoreIndentationTokens[$token] = true;
194
+ }
195
+ }//end if
196
+
197
+ $this->exact = (bool) $this->exact;
198
+ $this->tabIndent = (bool) $this->tabIndent;
199
+
200
+ for ($i = ($stackPtr + 1); $i < $phpcsFile->numTokens; $i++) {
201
+ if ($i === false) {
202
+ // Something has gone very wrong; maybe a parse error.
203
+ break;
204
+ }
205
+
206
+ $checkToken = null;
207
+ $checkIndent = null;
208
+
209
+ $exact = (bool) $this->exact;
210
+ if ($exact === true && isset($tokens[$i]['nested_parenthesis']) === true) {
211
+ // Don't check indents exactly between parenthesis as they
212
+ // tend to have custom rules, such as with multi-line function calls
213
+ // and control structure conditions.
214
+ $exact = false;
215
+ }
216
+
217
+ // Detect line changes and figure out where the indent is.
218
+ if ($tokens[$i]['column'] === 1) {
219
+ $trimmed = ltrim($tokens[$i]['content']);
220
+ if ($trimmed === '') {
221
+ if (isset($tokens[($i + 1)]) === true
222
+ && $tokens[$i]['line'] === $tokens[($i + 1)]['line']
223
+ ) {
224
+ $checkToken = ($i + 1);
225
+ $tokenIndent = ($tokens[($i + 1)]['column'] - 1);
226
+ }
227
+ } else {
228
+ $checkToken = $i;
229
+ $tokenIndent = (strlen($tokens[$i]['content']) - strlen($trimmed));
230
+ }
231
+ }
232
+
233
+ // Closing parenthesis should just be indented to at least
234
+ // the same level as where they were opened (but can be more).
235
+ if (($checkToken !== null
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;
243
+ } else {
244
+ $parenCloser = $i;
245
+ }
246
+
247
+ if ($this->_debug === true) {
248
+ $line = $tokens[$i]['line'];
249
+ echo "Closing parenthesis found on line $line".PHP_EOL;
250
+ }
251
+
252
+ $parenOpener = $tokens[$parenCloser]['parenthesis_opener'];
253
+ if ($tokens[$parenCloser]['line'] !== $tokens[$parenOpener]['line']) {
254
+ $parens = 0;
255
+ if (isset($tokens[$parenCloser]['nested_parenthesis']) === true
256
+ && empty($tokens[$parenCloser]['nested_parenthesis']) === false
257
+ ) {
258
+ end($tokens[$parenCloser]['nested_parenthesis']);
259
+ $parens = key($tokens[$parenCloser]['nested_parenthesis']);
260
+ if ($this->_debug === true) {
261
+ $line = $tokens[$parens]['line'];
262
+ echo "\t* token has nested parenthesis $parens on line $line *".PHP_EOL;
263
+ }
264
+ }
265
+
266
+ $condition = 0;
267
+ if (isset($tokens[$parenCloser]['conditions']) === true
268
+ && empty($tokens[$parenCloser]['conditions']) === false
269
+ ) {
270
+ end($tokens[$parenCloser]['conditions']);
271
+ $condition = key($tokens[$parenCloser]['conditions']);
272
+ if ($this->_debug === true) {
273
+ $line = $tokens[$condition]['line'];
274
+ $type = $tokens[$condition]['type'];
275
+ echo "\t* token is inside condition $condition ($type) on line $line *".PHP_EOL;
276
+ }
277
+ }
278
+
279
+ if ($parens > $condition) {
280
+ if ($this->_debug === true) {
281
+ echo "\t* using parenthesis *".PHP_EOL;
282
+ }
283
+
284
+ $parenOpener = $parens;
285
+ $condition = 0;
286
+ } else if ($condition > 0) {
287
+ if ($this->_debug === true) {
288
+ echo "\t* using condition *".PHP_EOL;
289
+ }
290
+
291
+ $parenOpener = $condition;
292
+ $parens = 0;
293
+ }
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
+ ) {
320
+ $checkIndent = $setIndents[$tokens[$condition]['scope_opener']];
321
+ if (isset($adjustments[$condition]) === true) {
322
+ $checkIndent += $adjustments[$condition];
323
+ }
324
+
325
+ $currentIndent = $checkIndent;
326
+
327
+ if ($this->_debug === true) {
328
+ $type = $tokens[$condition]['type'];
329
+ echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $condition ($type)".PHP_EOL;
330
+ }
331
+ } else {
332
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $parenOpener, true);
333
+
334
+ $checkIndent = ($tokens[$first]['column'] - 1);
335
+ if (isset($adjustments[$first]) === true) {
336
+ $checkIndent += $adjustments[$first];
337
+ }
338
+
339
+ if ($this->_debug === true) {
340
+ $line = $tokens[$first]['line'];
341
+ $type = $tokens[$first]['type'];
342
+ echo "\t* first token on line $line is $first ($type) *".PHP_EOL;
343
+ }
344
+
345
+ if ($first === $tokens[$parenCloser]['parenthesis_opener']) {
346
+ // This is unlikely to be the start of the statement, so look
347
+ // back further to find it.
348
+ $first--;
349
+ }
350
+
351
+ $prev = $phpcsFile->findStartOfStatement($first, T_COMMA);
352
+ if ($prev !== $first) {
353
+ // This is not the start of the statement.
354
+ if ($this->_debug === true) {
355
+ $line = $tokens[$prev]['line'];
356
+ $type = $tokens[$prev]['type'];
357
+ echo "\t* previous is $type on line $line *".PHP_EOL;
358
+ }
359
+
360
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
361
+ $prev = $phpcsFile->findStartOfStatement($first, T_COMMA);
362
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
363
+ if ($this->_debug === true) {
364
+ $line = $tokens[$first]['line'];
365
+ $type = $tokens[$first]['type'];
366
+ echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL;
367
+ }
368
+ }
369
+
370
+ if (isset($tokens[$first]['scope_closer']) === true
371
+ && $tokens[$first]['scope_closer'] === $first
372
+ ) {
373
+ if ($this->_debug === true) {
374
+ echo "\t* first token is a scope closer *".PHP_EOL;
375
+ }
376
+
377
+ if (isset($tokens[$first]['scope_condition']) === true) {
378
+ $scopeCloser = $first;
379
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $tokens[$scopeCloser]['scope_condition'], true);
380
+
381
+ $currentIndent = ($tokens[$first]['column'] - 1);
382
+ if (isset($adjustments[$first]) === true) {
383
+ $currentIndent += $adjustments[$first];
384
+ }
385
+
386
+ // Make sure it is divisible by our expected indent.
387
+ if ($tokens[$tokens[$scopeCloser]['scope_condition']]['code'] !== T_CLOSURE) {
388
+ $currentIndent = (int) (ceil($currentIndent / $this->indent) * $this->indent);
389
+ }
390
+
391
+ $setIndents[$first] = $currentIndent;
392
+
393
+ if ($this->_debug === true) {
394
+ $type = $tokens[$first]['type'];
395
+ echo "\t=> indent set to $currentIndent by token $first ($type)".PHP_EOL;
396
+ }
397
+ }//end if
398
+ } else {
399
+ // Don't force current indent to divisible because there could be custom
400
+ // rules in place between parenthesis, such as with arrays.
401
+ $currentIndent = ($tokens[$first]['column'] - 1);
402
+ if (isset($adjustments[$first]) === true) {
403
+ $currentIndent += $adjustments[$first];
404
+ }
405
+
406
+ $setIndents[$first] = $currentIndent;
407
+
408
+ if ($this->_debug === true) {
409
+ $type = $tokens[$first]['type'];
410
+ echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)".PHP_EOL;
411
+ }
412
+ }//end if
413
+ }//end if
414
+ } else if ($this->_debug === true) {
415
+ echo "\t * ignoring single-line definition *".PHP_EOL;
416
+ }//end if
417
+ }//end if
418
+
419
+ // Closing short array bracket should just be indented to at least
420
+ // the same level as where it was opened (but can be more).
421
+ if ($tokens[$i]['code'] === T_CLOSE_SHORT_ARRAY
422
+ || ($checkToken !== null
423
+ && $tokens[$checkToken]['code'] === T_CLOSE_SHORT_ARRAY)
424
+ ) {
425
+ if ($checkToken !== null) {
426
+ $arrayCloser = $checkToken;
427
+ } else {
428
+ $arrayCloser = $i;
429
+ }
430
+
431
+ if ($this->_debug === true) {
432
+ $line = $tokens[$arrayCloser]['line'];
433
+ echo "Closing short array bracket found on line $line".PHP_EOL;
434
+ }
435
+
436
+ $arrayOpener = $tokens[$arrayCloser]['bracket_opener'];
437
+ if ($tokens[$arrayCloser]['line'] !== $tokens[$arrayOpener]['line']) {
438
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $arrayOpener, true);
439
+ $checkIndent = ($tokens[$first]['column'] - 1);
440
+ if (isset($adjustments[$first]) === true) {
441
+ $checkIndent += $adjustments[$first];
442
+ }
443
+
444
+ $exact = false;
445
+
446
+ if ($this->_debug === true) {
447
+ $line = $tokens[$first]['line'];
448
+ $type = $tokens[$first]['type'];
449
+ echo "\t* first token on line $line is $first ($type) *".PHP_EOL;
450
+ }
451
+
452
+ if ($first === $tokens[$arrayCloser]['bracket_opener']) {
453
+ // This is unlikely to be the start of the statement, so look
454
+ // back further to find it.
455
+ $first--;
456
+ }
457
+
458
+ $prev = $phpcsFile->findStartOfStatement($first, T_COMMA);
459
+ if ($prev !== $first) {
460
+ // This is not the start of the statement.
461
+ if ($this->_debug === true) {
462
+ $line = $tokens[$prev]['line'];
463
+ $type = $tokens[$prev]['type'];
464
+ echo "\t* previous is $type on line $line *".PHP_EOL;
465
+ }
466
+
467
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
468
+ $prev = $phpcsFile->findStartOfStatement($first, T_COMMA);
469
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $prev, true);
470
+ if ($this->_debug === true) {
471
+ $line = $tokens[$first]['line'];
472
+ $type = $tokens[$first]['type'];
473
+ echo "\t* amended first token is $first ($type) on line $line *".PHP_EOL;
474
+ }
475
+ } else if ($tokens[$first]['code'] === T_WHITESPACE) {
476
+ $first = $phpcsFile->findNext(T_WHITESPACE, ($first + 1), null, true);
477
+ }
478
+
479
+ if (isset($tokens[$first]['scope_closer']) === true
480
+ && $tokens[$first]['scope_closer'] === $first
481
+ ) {
482
+ // The first token is a scope closer and would have already
483
+ // been processed and set the indent level correctly, so
484
+ // don't adjust it again.
485
+ if ($this->_debug === true) {
486
+ echo "\t* first token is a scope closer; ignoring closing short array bracket *".PHP_EOL;
487
+ }
488
+
489
+ if (isset($setIndents[$first]) === true) {
490
+ $currentIndent = $setIndents[$first];
491
+ if ($this->_debug === true) {
492
+ echo "\t=> indent reset to $currentIndent".PHP_EOL;
493
+ }
494
+ }
495
+ } else {
496
+ // Don't force current indent to be divisible because there could be custom
497
+ // rules in place for arrays.
498
+ $currentIndent = ($tokens[$first]['column'] - 1);
499
+ if (isset($adjustments[$first]) === true) {
500
+ $currentIndent += $adjustments[$first];
501
+ }
502
+
503
+ $setIndents[$first] = $currentIndent;
504
+
505
+ if ($this->_debug === true) {
506
+ $type = $tokens[$first]['type'];
507
+ echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)".PHP_EOL;
508
+ }
509
+ }//end if
510
+ } else if ($this->_debug === true) {
511
+ echo "\t * ignoring single-line definition *".PHP_EOL;
512
+ }//end if
513
+ }//end if
514
+
515
+ // Adjust lines within scopes while auto-fixing.
516
+ if ($checkToken !== null
517
+ && $exact === false
518
+ && (empty($tokens[$checkToken]['conditions']) === false
519
+ || (isset($tokens[$checkToken]['scope_opener']) === true
520
+ && $tokens[$checkToken]['scope_opener'] === $checkToken))
521
+ ) {
522
+ if (empty($tokens[$checkToken]['conditions']) === false) {
523
+ end($tokens[$checkToken]['conditions']);
524
+ $condition = key($tokens[$checkToken]['conditions']);
525
+ } else {
526
+ $condition = $tokens[$checkToken]['scope_condition'];
527
+ }
528
+
529
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $condition, true);
530
+
531
+ if (isset($adjustments[$first]) === true
532
+ && (($adjustments[$first] < 0 && $tokenIndent > $currentIndent)
533
+ || ($adjustments[$first] > 0 && $tokenIndent < $currentIndent))
534
+ ) {
535
+ $padding = ($tokenIndent + $adjustments[$first]);
536
+ if ($padding > 0) {
537
+ if ($this->tabIndent === true) {
538
+ $numTabs = floor($padding / $this->_tabWidth);
539
+ $numSpaces = ($padding - ($numTabs * $this->_tabWidth));
540
+ $padding = str_repeat("\t", $numTabs).str_repeat(' ', $numSpaces);
541
+ } else {
542
+ $padding = str_repeat(' ', $padding);
543
+ }
544
+ } else {
545
+ $padding = '';
546
+ }
547
+
548
+ if ($checkToken === $i) {
549
+ $phpcsFile->fixer->replaceToken($checkToken, $padding.$trimmed);
550
+ } else {
551
+ // Easier to just replace the entire indent.
552
+ $phpcsFile->fixer->replaceToken(($checkToken - 1), $padding);
553
+ }
554
+
555
+ if ($this->_debug === true) {
556
+ $length = strlen($padding);
557
+ $line = $tokens[$checkToken]['line'];
558
+ $type = $tokens[$checkToken]['type'];
559
+ echo "Indent adjusted to $length for $type on line $line".PHP_EOL;
560
+ }
561
+
562
+ $adjustments[$checkToken] = $adjustments[$first];
563
+
564
+ if ($this->_debug === true) {
565
+ $line = $tokens[$checkToken]['line'];
566
+ $type = $tokens[$checkToken]['type'];
567
+ echo "\t=> Add adjustment of ".$adjustments[$checkToken]." for token $checkToken ($type) on line $line".PHP_EOL;
568
+ }
569
+ }//end if
570
+ }//end if
571
+
572
+ // Scope closers reset the required indent to the same level as the opening condition.
573
+ if (($checkToken !== null
574
+ && isset($openScopes[$checkToken]) === true
575
+ || (isset($tokens[$checkToken]['scope_condition']) === true
576
+ && isset($tokens[$checkToken]['scope_closer']) === true
577
+ && $tokens[$checkToken]['scope_closer'] === $checkToken
578
+ && $tokens[$checkToken]['line'] !== $tokens[$tokens[$checkToken]['scope_opener']]['line']))
579
+ || ($checkToken === null
580
+ && isset($openScopes[$i]) === true
581
+ || (isset($tokens[$i]['scope_condition']) === true
582
+ && isset($tokens[$i]['scope_closer']) === true
583
+ && $tokens[$i]['scope_closer'] === $i
584
+ && $tokens[$i]['line'] !== $tokens[$tokens[$i]['scope_opener']]['line']))
585
+ ) {
586
+ if ($this->_debug === true) {
587
+ if ($checkToken === null) {
588
+ $type = $tokens[$tokens[$i]['scope_condition']]['type'];
589
+ $line = $tokens[$i]['line'];
590
+ } else {
591
+ $type = $tokens[$tokens[$checkToken]['scope_condition']]['type'];
592
+ $line = $tokens[$checkToken]['line'];
593
+ }
594
+
595
+ echo "Close scope ($type) on line $line".PHP_EOL;
596
+ }
597
+
598
+ $scopeCloser = $checkToken;
599
+ if ($scopeCloser === null) {
600
+ $scopeCloser = $i;
601
+ } else {
602
+ array_pop($openScopes);
603
+ }
604
+
605
+ if (isset($tokens[$scopeCloser]['scope_condition']) === true) {
606
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $tokens[$scopeCloser]['scope_condition'], true);
607
+
608
+ $currentIndent = ($tokens[$first]['column'] - 1);
609
+ if (isset($adjustments[$first]) === true) {
610
+ $currentIndent += $adjustments[$first];
611
+ }
612
+
613
+ // Make sure it is divisible by our expected indent.
614
+ if ($tokens[$tokens[$scopeCloser]['scope_condition']]['code'] !== T_CLOSURE) {
615
+ $currentIndent = (int) (ceil($currentIndent / $this->indent) * $this->indent);
616
+ }
617
+
618
+ $setIndents[$scopeCloser] = $currentIndent;
619
+
620
+ if ($this->_debug === true) {
621
+ $type = $tokens[$scopeCloser]['type'];
622
+ echo "\t=> indent set to $currentIndent by token $scopeCloser ($type)".PHP_EOL;
623
+ }
624
+
625
+ // We only check the indent of scope closers if they are
626
+ // curly braces because other constructs tend to have different rules.
627
+ if ($tokens[$scopeCloser]['code'] === T_CLOSE_CURLY_BRACKET) {
628
+ $exact = true;
629
+ } else {
630
+ $checkToken = null;
631
+ }
632
+ }//end if
633
+ }//end if
634
+
635
+ // Handle scope for JS object notation.
636
+ if ($phpcsFile->tokenizerType === 'JS'
637
+ && (($checkToken !== null
638
+ && $tokens[$checkToken]['code'] === T_CLOSE_OBJECT
639
+ && $tokens[$checkToken]['line'] !== $tokens[$tokens[$checkToken]['bracket_opener']]['line'])
640
+ || ($checkToken === null
641
+ && $tokens[$i]['code'] === T_CLOSE_OBJECT
642
+ && $tokens[$i]['line'] !== $tokens[$tokens[$i]['bracket_opener']]['line']))
643
+ ) {
644
+ if ($this->_debug === true) {
645
+ $line = $tokens[$i]['line'];
646
+ echo "Close JS object on line $line".PHP_EOL;
647
+ }
648
+
649
+ $scopeCloser = $checkToken;
650
+ if ($scopeCloser === null) {
651
+ $scopeCloser = $i;
652
+ } else {
653
+ array_pop($openScopes);
654
+ }
655
+
656
+ $parens = 0;
657
+ if (isset($tokens[$scopeCloser]['nested_parenthesis']) === true
658
+ && empty($tokens[$scopeCloser]['nested_parenthesis']) === false
659
+ ) {
660
+ end($tokens[$scopeCloser]['nested_parenthesis']);
661
+ $parens = key($tokens[$scopeCloser]['nested_parenthesis']);
662
+ if ($this->_debug === true) {
663
+ $line = $tokens[$parens]['line'];
664
+ echo "\t* token has nested parenthesis $parens on line $line *".PHP_EOL;
665
+ }
666
+ }
667
+
668
+ $condition = 0;
669
+ if (isset($tokens[$scopeCloser]['conditions']) === true
670
+ && empty($tokens[$scopeCloser]['conditions']) === false
671
+ ) {
672
+ end($tokens[$scopeCloser]['conditions']);
673
+ $condition = key($tokens[$scopeCloser]['conditions']);
674
+ if ($this->_debug === true) {
675
+ $line = $tokens[$condition]['line'];
676
+ $type = $tokens[$condition]['type'];
677
+ echo "\t* token is inside condition $condition ($type) on line $line *".PHP_EOL;
678
+ }
679
+ }
680
+
681
+ if ($parens > $condition) {
682
+ if ($this->_debug === true) {
683
+ echo "\t* using parenthesis *".PHP_EOL;
684
+ }
685
+
686
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $parens, true);
687
+ $condition = 0;
688
+ } else if ($condition > 0) {
689
+ if ($this->_debug === true) {
690
+ echo "\t* using condition *".PHP_EOL;
691
+ }
692
+
693
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $condition, true);
694
+ $parens = 0;
695
+ } else {
696
+ if ($this->_debug === true) {
697
+ $line = $tokens[$tokens[$scopeCloser]['bracket_opener']]['line'];
698
+ echo "\t* token is not in parenthesis or condition; using opener on line $line *".PHP_EOL;
699
+ }
700
+
701
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $tokens[$scopeCloser]['bracket_opener'], true);
702
+ }//end if
703
+
704
+ $currentIndent = ($tokens[$first]['column'] - 1);
705
+ if (isset($adjustments[$first]) === true) {
706
+ $currentIndent += $adjustments[$first];
707
+ }
708
+
709
+ if ($parens > 0 || $condition > 0) {
710
+ $checkIndent = ($tokens[$first]['column'] - 1);
711
+ if (isset($adjustments[$first]) === true) {
712
+ $checkIndent += $adjustments[$first];
713
+ }
714
+
715
+ if ($condition > 0) {
716
+ $checkIndent += $this->indent;
717
+ $currentIndent += $this->indent;
718
+ $exact = true;
719
+ }
720
+ } else {
721
+ $checkIndent = $currentIndent;
722
+ }
723
+
724
+ // Make sure it is divisible by our expected indent.
725
+ $currentIndent = (int) (ceil($currentIndent / $this->indent) * $this->indent);
726
+ $checkIndent = (int) (ceil($checkIndent / $this->indent) * $this->indent);
727
+ $setIndents[$first] = $currentIndent;
728
+
729
+ if ($this->_debug === true) {
730
+ $type = $tokens[$first]['type'];
731
+ echo "\t=> checking indent of $checkIndent; main indent set to $currentIndent by token $first ($type)".PHP_EOL;
732
+ }
733
+ }//end if
734
+
735
+ if ($checkToken !== null
736
+ && isset(PHP_CodeSniffer_Tokens::$scopeOpeners[$tokens[$checkToken]['code']]) === true
737
+ && in_array($tokens[$checkToken]['code'], $this->nonIndentingScopes) === false
738
+ && isset($tokens[$checkToken]['scope_opener']) === true
739
+ ) {
740
+ $exact = true;
741
+
742
+ $lastOpener = null;
743
+ if (empty($openScopes) === false) {
744
+ end($openScopes);
745
+ $lastOpener = current($openScopes);
746
+ }
747
+
748
+ // A scope opener that shares a closer with another token (like multiple
749
+ // CASEs using the same BREAK) needs to reduce the indent level so its
750
+ // indent is checked correctly. It will then increase the indent again
751
+ // (as all openers do) after being checked.
752
+ if ($lastOpener !== null
753
+ && isset($tokens[$lastOpener]['scope_closer']) === true
754
+ && $tokens[$lastOpener]['level'] === $tokens[$checkToken]['level']
755
+ && $tokens[$lastOpener]['scope_closer'] === $tokens[$checkToken]['scope_closer']
756
+ ) {
757
+ $currentIndent -= $this->indent;
758
+ $setIndents[$lastOpener] = $currentIndent;
759
+ if ($this->_debug === true) {
760
+ $line = $tokens[$i]['line'];
761
+ $type = $tokens[$lastOpener]['type'];
762
+ echo "Shared closer found on line $line".PHP_EOL;
763
+ echo "\t=> indent set to $currentIndent by token $lastOpener ($type)".PHP_EOL;
764
+ }
765
+ }
766
+
767
+ if ($tokens[$checkToken]['code'] === T_CLOSURE
768
+ && $tokenIndent > $currentIndent
769
+ ) {
770
+ // The opener is indented more than needed, which is fine.
771
+ // But just check that it is divisible by our expected indent.
772
+ $checkIndent = (int) (ceil($tokenIndent / $this->indent) * $this->indent);
773
+ $exact = false;
774
+
775
+ if ($this->_debug === true) {
776
+ $line = $tokens[$i]['line'];
777
+ echo "Closure found on line $line".PHP_EOL;
778
+ echo "\t=> checking indent of $checkIndent; main indent remains at $currentIndent".PHP_EOL;
779
+ }
780
+ }
781
+ }//end if
782
+
783
+ // Method prefix indentation has to be exact or else if will break
784
+ // the rest of the function declaration, and potentially future ones.
785
+ if ($checkToken !== null
786
+ && isset(PHP_CodeSniffer_Tokens::$methodPrefixes[$tokens[$checkToken]['code']]) === true
787
+ && $tokens[($checkToken + 1)]['code'] !== T_DOUBLE_COLON
788
+ ) {
789
+ $exact = true;
790
+ }
791
+
792
+ // JS property indentation has to be exact or else if will break
793
+ // things like function and object indentation.
794
+ if ($checkToken !== null && $tokens[$checkToken]['code'] === T_PROPERTY) {
795
+ $exact = true;
796
+ }
797
+
798
+ // PHP tags needs to be indented to exact column positions
799
+ // so they don't cause problems with indent checks for the code
800
+ // within them, but they don't need to line up with the current indent.
801
+ if ($checkToken !== null
802
+ && ($tokens[$checkToken]['code'] === T_OPEN_TAG
803
+ || $tokens[$checkToken]['code'] === T_OPEN_TAG_WITH_ECHO
804
+ || $tokens[$checkToken]['code'] === T_CLOSE_TAG)
805
+ ) {
806
+ $exact = true;
807
+ $checkIndent = ($tokens[$checkToken]['column'] - 1);
808
+ $checkIndent = (int) (ceil($checkIndent / $this->indent) * $this->indent);
809
+ }
810
+
811
+ // Special case for ELSE statements that are not on the same
812
+ // line as the previous IF statements closing brace. They still need
813
+ // to have the same indent or it will break code after the block.
814
+ if ($checkToken !== null && $tokens[$checkToken]['code'] === T_ELSE) {
815
+ $exact = true;
816
+ }
817
+
818
+ if ($checkIndent === null) {
819
+ $checkIndent = $currentIndent;
820
+ }
821
+
822
+ /*
823
+ The indent of the line is checked by the following IF block.
824
+
825
+ Up until now, we've just been figuring out what the indent
826
+ of this line should be.
827
+
828
+ After this IF block, we adjust the indent again for
829
+ the checking of future line.
830
+ */
831
+
832
+ $adjusted = false;
833
+ if ($checkToken !== null
834
+ && isset($this->_ignoreIndentationTokens[$tokens[$checkToken]['code']]) === false
835
+ && (($tokenIndent !== $checkIndent && $exact === true)
836
+ || ($tokenIndent < $checkIndent && $exact === false))
837
+ ) {
838
+ $type = 'IncorrectExact';
839
+ $error = 'Line indented incorrectly; expected ';
840
+ if ($exact === false) {
841
+ $error .= 'at least ';
842
+ $type = 'Incorrect';
843
+ }
844
+
845
+ if ($this->tabIndent === true) {
846
+ $error .= '%s tabs, found %s';
847
+ $data = array(
848
+ floor($checkIndent / $this->_tabWidth),
849
+ floor($tokenIndent / $this->_tabWidth),
850
+ );
851
+ } else {
852
+ $error .= '%s spaces, found %s';
853
+ $data = array(
854
+ $checkIndent,
855
+ $tokenIndent,
856
+ );
857
+ }
858
+
859
+ if ($this->_debug === true) {
860
+ $line = $tokens[$checkToken]['line'];
861
+ $message = vsprintf($error, $data);
862
+ echo "[Line $line] $message".PHP_EOL;
863
+ }
864
+
865
+ $fix = $phpcsFile->addFixableError($error, $checkToken, $type, $data);
866
+ if ($fix === true || $this->_debug === true) {
867
+ $padding = '';
868
+ if ($this->tabIndent === true) {
869
+ $numTabs = floor($checkIndent / $this->_tabWidth);
870
+ if ($numTabs > 0) {
871
+ $numSpaces = ($checkIndent - ($numTabs * $this->_tabWidth));
872
+ $padding = str_repeat("\t", $numTabs).str_repeat(' ', $numSpaces);
873
+ }
874
+ } else if ($checkIndent > 0) {
875
+ $padding = str_repeat(' ', $checkIndent);
876
+ }
877
+
878
+ if ($checkToken === $i) {
879
+ $accepted = $phpcsFile->fixer->replaceToken($checkToken, $padding.$trimmed);
880
+ } else {
881
+ // Easier to just replace the entire indent.
882
+ $accepted = $phpcsFile->fixer->replaceToken(($checkToken - 1), $padding);
883
+ }
884
+
885
+ if ($accepted === true) {
886
+ $adjustments[$checkToken] = ($checkIndent - $tokenIndent);
887
+ if ($this->_debug === true) {
888
+ $line = $tokens[$checkToken]['line'];
889
+ $type = $tokens[$checkToken]['type'];
890
+ echo "\t=> Add adjustment of ".$adjustments[$checkToken]." for token $checkToken ($type) on line $line".PHP_EOL;
891
+ }
892
+ }
893
+ } else {
894
+ // Assume the change would be applied and continue
895
+ // checking indents under this assumption. This gives more
896
+ // technically accurate error messages.
897
+ $adjustments[$checkToken] = ($checkIndent - $tokenIndent);
898
+ }//end if
899
+ }//end if
900
+
901
+ if ($checkToken !== null) {
902
+ $i = $checkToken;
903
+ }
904
+
905
+ // Completely skip here/now docs as the indent is a part of the
906
+ // content itself.
907
+ if ($tokens[$i]['code'] === T_START_HEREDOC
908
+ || $tokens[$i]['code'] === T_START_NOWDOC
909
+ ) {
910
+ $i = $phpcsFile->findNext(array(T_END_HEREDOC, T_END_NOWDOC), ($i + 1));
911
+ continue;
912
+ }
913
+
914
+ // Completely skip multi-line strings as the indent is a part of the
915
+ // content itself.
916
+ if ($tokens[$i]['code'] === T_CONSTANT_ENCAPSED_STRING
917
+ || $tokens[$i]['code'] === T_DOUBLE_QUOTED_STRING
918
+ ) {
919
+ $i = $phpcsFile->findNext($tokens[$i]['code'], ($i + 1), null, true);
920
+ $i--;
921
+ continue;
922
+ }
923
+
924
+ // Completely skip doc comments as they tend to have complex
925
+ // indentation rules.
926
+ if ($tokens[$i]['code'] === T_DOC_COMMENT_OPEN_TAG) {
927
+ $i = $tokens[$i]['comment_closer'];
928
+ continue;
929
+ }
930
+
931
+ // Open tags reset the indent level.
932
+ if ($tokens[$i]['code'] === T_OPEN_TAG
933
+ || $tokens[$i]['code'] === T_OPEN_TAG_WITH_ECHO
934
+ ) {
935
+ if ($this->_debug === true) {
936
+ $line = $tokens[$i]['line'];
937
+ echo "Open PHP tag found on line $line".PHP_EOL;
938
+ }
939
+
940
+ if ($checkToken === null) {
941
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $i, true);
942
+ $currentIndent = (strlen($tokens[$first]['content']) - strlen(ltrim($tokens[$first]['content'])));
943
+ } else {
944
+ $currentIndent = ($tokens[$i]['column'] - 1);
945
+ }
946
+
947
+ $lastOpenTag = $i;
948
+
949
+ if (isset($adjustments[$i]) === true) {
950
+ $currentIndent += $adjustments[$i];
951
+ }
952
+
953
+ // Make sure it is divisible by our expected indent.
954
+ $currentIndent = (int) (ceil($currentIndent / $this->indent) * $this->indent);
955
+ $setIndents[$i] = $currentIndent;
956
+
957
+ if ($this->_debug === true) {
958
+ $type = $tokens[$i]['type'];
959
+ echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL;
960
+ }
961
+
962
+ continue;
963
+ }//end if
964
+
965
+ // Close tags reset the indent level, unless they are closing a tag
966
+ // opened on the same line.
967
+ if ($tokens[$i]['code'] === T_CLOSE_TAG) {
968
+ if ($this->_debug === true) {
969
+ $line = $tokens[$i]['line'];
970
+ echo "Close PHP tag found on line $line".PHP_EOL;
971
+ }
972
+
973
+ if ($tokens[$lastOpenTag]['line'] !== $tokens[$i]['line']) {
974
+ $currentIndent = ($tokens[$i]['column'] - 1);
975
+ $lastCloseTag = $i;
976
+ } else {
977
+ if ($lastCloseTag === null) {
978
+ $currentIndent = 0;
979
+ } else {
980
+ $currentIndent = ($tokens[$lastCloseTag]['column'] - 1);
981
+ }
982
+ }
983
+
984
+ if (isset($adjustments[$i]) === true) {
985
+ $currentIndent += $adjustments[$i];
986
+ }
987
+
988
+ // Make sure it is divisible by our expected indent.
989
+ $currentIndent = (int) (ceil($currentIndent / $this->indent) * $this->indent);
990
+ $setIndents[$i] = $currentIndent;
991
+
992
+ if ($this->_debug === true) {
993
+ $type = $tokens[$i]['type'];
994
+ echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL;
995
+ }
996
+
997
+ continue;
998
+ }//end if
999
+
1000
+ // Anon classes and functions set the indent based on their own indent level.
1001
+ if ($tokens[$i]['code'] === T_CLOSURE || $tokens[$i]['code'] === T_ANON_CLASS) {
1002
+ $closer = $tokens[$i]['scope_closer'];
1003
+ if ($tokens[$i]['line'] === $tokens[$closer]['line']) {
1004
+ if ($this->_debug === true) {
1005
+ $type = str_replace('_', ' ', strtolower(substr($tokens[$i]['type'], 2)));
1006
+ $line = $tokens[$i]['line'];
1007
+ echo "* ignoring single-line $type on line $line".PHP_EOL;
1008
+ }
1009
+
1010
+ $i = $closer;
1011
+ continue;
1012
+ }
1013
+
1014
+ if ($this->_debug === true) {
1015
+ $type = str_replace('_', ' ', strtolower(substr($tokens[$i]['type'], 2)));
1016
+ $line = $tokens[$i]['line'];
1017
+ echo "Open $type on line $line".PHP_EOL;
1018
+ }
1019
+
1020
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $i, true);
1021
+ $currentIndent = (($tokens[$first]['column'] - 1) + $this->indent);
1022
+
1023
+ if (isset($adjustments[$first]) === true) {
1024
+ $currentIndent += $adjustments[$first];
1025
+ }
1026
+
1027
+ // Make sure it is divisible by our expected indent.
1028
+ $currentIndent = (int) (floor($currentIndent / $this->indent) * $this->indent);
1029
+ $i = $tokens[$i]['scope_opener'];
1030
+ $setIndents[$i] = $currentIndent;
1031
+
1032
+ if ($this->_debug === true) {
1033
+ $type = $tokens[$i]['type'];
1034
+ echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL;
1035
+ }
1036
+
1037
+ continue;
1038
+ }//end if
1039
+
1040
+ // Scope openers increase the indent level.
1041
+ if (isset($tokens[$i]['scope_condition']) === true
1042
+ && isset($tokens[$i]['scope_opener']) === true
1043
+ && $tokens[$i]['scope_opener'] === $i
1044
+ ) {
1045
+ $closer = $tokens[$i]['scope_closer'];
1046
+ if ($tokens[$i]['line'] === $tokens[$closer]['line']) {
1047
+ if ($this->_debug === true) {
1048
+ $line = $tokens[$i]['line'];
1049
+ $type = $tokens[$i]['type'];
1050
+ echo "* ignoring single-line $type on line $line".PHP_EOL;
1051
+ }
1052
+
1053
+ $i = $closer;
1054
+ continue;
1055
+ }
1056
+
1057
+ $condition = $tokens[$tokens[$i]['scope_condition']]['code'];
1058
+ if (isset(PHP_CodeSniffer_Tokens::$scopeOpeners[$condition]) === true
1059
+ && in_array($condition, $this->nonIndentingScopes) === false
1060
+ ) {
1061
+ if ($this->_debug === true) {
1062
+ $line = $tokens[$i]['line'];
1063
+ $type = $tokens[$tokens[$i]['scope_condition']]['type'];
1064
+ echo "Open scope ($type) on line $line".PHP_EOL;
1065
+ }
1066
+
1067
+ $currentIndent += $this->indent;
1068
+ $setIndents[$i] = $currentIndent;
1069
+ $openScopes[$tokens[$i]['scope_closer']] = $tokens[$i]['scope_condition'];
1070
+
1071
+ if ($this->_debug === true) {
1072
+ $type = $tokens[$i]['type'];
1073
+ echo "\t=> indent set to $currentIndent by token $i ($type)".PHP_EOL;
1074
+ }
1075
+
1076
+ continue;
1077
+ }
1078
+ }//end if
1079
+
1080
+ // JS objects set the indent level.
1081
+ if ($phpcsFile->tokenizerType === 'JS'
1082
+ && $tokens[$i]['code'] === T_OBJECT
1083
+ ) {
1084
+ $closer = $tokens[$i]['bracket_closer'];
1085
+ if ($tokens[$i]['line'] === $tokens[$closer]['line']) {
1086
+ if ($this->_debug === true) {
1087
+ $line = $tokens[$i]['line'];
1088
+ echo "* ignoring single-line JS object on line $line".PHP_EOL;
1089
+ }
1090
+
1091
+ $i = $closer;
1092
+ continue;
1093
+ }
1094
+
1095
+ if ($this->_debug === true) {
1096
+ $line = $tokens[$i]['line'];
1097
+ echo "Open JS object on line $line".PHP_EOL;
1098
+ }
1099
+
1100
+ $first = $phpcsFile->findFirstOnLine(T_WHITESPACE, $i, true);
1101
+ $currentIndent = (($tokens[$first]['column'] - 1) + $this->indent);
1102
+ if (isset($adjustments[$first]) === true) {
1103
+ $currentIndent += $adjustments[$first];
1104
+ }
1105
+
1106
+ // Make sure it is divisible by our expected indent.
1107
+ $currentIndent = (int) (ceil($currentIndent / $this->indent) * $this->indent);
1108
+ $setIndents[$first] = $currentIndent;
1109
+
1110
+ if ($this->_debug === true) {
1111
+ $type = $tokens[$first]['type'];
1112
+ echo "\t=> indent set to $currentIndent by token $first ($type)".PHP_EOL;
1113
+ }
1114
+
1115
+ continue;
1116
+ }//end if
1117
+
1118
+ // Closing an anon class or function.
1119
+ if (isset($tokens[$i]['scope_condition']) === true
1120
+ && $tokens[$i]['scope_closer'] === $i
1121
+ && ($tokens[$tokens[$i]['scope_condition']]['code'] === T_CLOSURE
1122
+ || $tokens[$tokens[$i]['scope_condition']]['code'] === T_ANON_CLASS)
1123
+ ) {
1124
+ if ($this->_debug === true) {
1125
+ $type = str_replace('_', ' ', strtolower(substr($tokens[$tokens[$i]['scope_condition']]['type'], 2)));
1126
+ $line = $tokens[$i]['line'];
1127
+ echo "Close $type on line $line".PHP_EOL;
1128
+ }
1129
+
1130
+ $prev = false;
1131
+
1132
+ $object = 0;
1133
+ if ($phpcsFile->tokenizerType === 'JS') {
1134
+ $conditions = $tokens[$i]['conditions'];
1135
+ krsort($conditions, SORT_NUMERIC);
1136
+ foreach ($conditions as $token => $condition) {
1137
+ if ($condition === T_OBJECT) {
1138
+ $object = $token;
1139
+ break;
1140
+ }
1141
+ }
1142
+
1143
+ if ($this->_debug === true && $object !== 0) {
1144
+ $line = $tokens[$object]['line'];
1145
+ echo "\t* token is inside JS object $object on line $line *".PHP_EOL;
1146
+ }
1147
+ }
1148
+
1149
+ $parens = 0;
1150
+ if (isset($tokens[$i]['nested_parenthesis']) === true
1151
+ && empty($tokens[$i]['nested_parenthesis']) === false
1152
+ ) {
1153
+ end($tokens[$i]['nested_parenthesis']);
1154
+ $parens = key($tokens[$i]['nested_parenthesis']);
1155
+ if ($this->_debug === true) {
1156
+ $line = $tokens[$parens]['line'];
1157
+ echo "\t* token has nested parenthesis $parens on line $line *".PHP_EOL;
1158
+ }
1159
+ }
1160
+
1161
+ $condition = 0;
1162
+ if (isset($tokens[$i]['conditions']) === true
1163
+ && empty($tokens[$i]['conditions']) === false
1164
+ ) {
1165
+ end($tokens[$i]['conditions']);
1166
+ $condition = key($tokens[$i]['conditions']);
1167
+ if ($this->_debug === true) {
1168
+ $line = $tokens[$condition]['line'];
1169
+ $type = $tokens[$condition]['type'];
1170
+