Permalink
Browse files

Merge remote-tracking branch 'joomla/master' into 18560

  • Loading branch information...
2 parents c8b5953 + a34b024 commit bccfc87d2584f840b77471de3e8da88e91e4abfe @chdemko committed Oct 20, 2011
Showing with 1,933 additions and 1,309 deletions.
  1. +1 −1 build.xml
  2. +2 −0 build/phpcs/Joomla/Sniffs/Commenting/ClassCommentSniff.php
  3. +5 −6 build/phpcs/Joomla/Sniffs/ControlStructures/ControlSignatureSniff.php
  4. +79 −0 build/phpcs/Joomla/Sniffs/ControlStructures/ElseIfDeclarationSniff.php
  5. +1 −1 build/phpcs/Joomla/Sniffs/ControlStructures/InlineControlStructureSniff.php
  6. +15 −44 build/phpcs/Joomla/Sniffs/ControlStructures/MultiLineConditionSniff.php
  7. +6 −0 build/phpcs/Joomla/Sniffs/Files/IncludingFileSniff.php
  8. +228 −0 build/phpcs/Joomla/Sniffs/Functions/FunctionDeclarationSniff.php
  9. +1 −0 build/phpcs/Joomla/Sniffs/WhiteSpace/SuperfluousWhitespaceSniff.php
  10. +0 −9 build/phpcs/Joomla/ruleset.xml
  11. +52 −16 libraries/joomla/access/access.php
  12. +2 −2 libraries/joomla/access/rules.php
  13. +5 −6 libraries/joomla/application/application.php
  14. +2 −2 libraries/joomla/application/categories.php
  15. +23 −19 libraries/joomla/application/cli.php
  16. +3 −3 libraries/joomla/application/cli/daemon.php
  17. +6 −8 libraries/joomla/application/component/controller.php
  18. +2 −2 libraries/joomla/application/component/controlleradmin.php
  19. +13 −7 libraries/joomla/application/component/controllerform.php
  20. +2 −2 libraries/joomla/application/component/model.php
  21. +60 −8 libraries/joomla/application/component/modeladmin.php
  22. +0 −1 libraries/joomla/application/component/modelform.php
  23. +1 −1 libraries/joomla/application/helper.php
  24. +1 −1 libraries/joomla/application/menu.php
  25. +23 −19 libraries/joomla/application/web.php
  26. +2 −2 libraries/joomla/base/adapter.php
  27. +1 −1 libraries/joomla/base/adapterinstance.php
  28. +1 −1 libraries/joomla/base/object.php
  29. +1 −1 libraries/joomla/cache/cache.php
  30. +3 −3 libraries/joomla/cache/storage/file.php
  31. +33 −32 libraries/joomla/client/ftp.php
  32. +1 −1 libraries/joomla/client/helper.php
  33. +2 −2 libraries/joomla/client/ldap.php
  34. +1 −1 libraries/joomla/database/database/mysqlexporter.php
  35. +1 −1 libraries/joomla/database/database/mysqlimporter.php
  36. +1 −1 libraries/joomla/database/database/sqlazure.php
  37. +4 −135 libraries/joomla/database/database/sqlazurequery.php
  38. +1 −1 libraries/joomla/database/database/sqlsrvquery.php
  39. +1 −1 libraries/joomla/database/databasequery.php
  40. +2 −2 libraries/joomla/database/table.php
  41. +1 −2 libraries/joomla/database/table/category.php
  42. +3 −1 libraries/joomla/database/table/extension.php
  43. +1 −2 libraries/joomla/database/table/menu.php
  44. +2 −2 libraries/joomla/database/table/update.php
  45. +1 −2 libraries/joomla/database/table/user.php
  46. +2 −2 libraries/joomla/document/document.php
  47. +1 −1 libraries/joomla/document/html/html.php
  48. +1 −1 libraries/joomla/document/html/renderer/head.php
  49. +2 −12 libraries/joomla/environment/request.php
  50. +1 −1 libraries/joomla/environment/uri.php
  51. +54 −11 libraries/joomla/error/error.php
  52. +1 −1 libraries/joomla/error/exception.php
  53. +1 −1 libraries/joomla/factory.php
  54. +7 −7 libraries/joomla/filesystem/stream.php
  55. +1 −1 libraries/joomla/filesystem/support/stringcontroller.php
  56. +1 −1 libraries/joomla/filter/filterinput.php
  57. +1 −1 libraries/joomla/filter/filteroutput.php
  58. +1 −2 libraries/joomla/form/fields/componentlayout.php
  59. +1 −1 libraries/joomla/form/fields/editor.php
  60. +2 −2 libraries/joomla/form/fields/integer.php
  61. +2 −1 libraries/joomla/form/fields/password.php
  62. +4 −4 libraries/joomla/form/fields/rules.php
  63. +5 −5 libraries/joomla/form/form.php
  64. +2 −2 libraries/joomla/form/rules/tel.php
  65. +2 −3 libraries/joomla/form/rules/url.php
  66. +1 −1 libraries/joomla/html/editor.php
  67. +59 −84 libraries/joomla/html/grid.php
  68. +1 −1 libraries/joomla/html/html.php
  69. +23 −0 libraries/joomla/html/html/batch.php
  70. +69 −69 libraries/joomla/html/html/behavior.php
  71. +2 −2 libraries/joomla/html/html/category.php
  72. +2 −2 libraries/joomla/html/html/contentlanguage.php
  73. +1 −1 libraries/joomla/html/html/grid.php
  74. +2 −2 libraries/joomla/html/html/image.php
  75. +15 −9 libraries/joomla/html/html/jgrid.php
  76. +1 −1 libraries/joomla/html/html/list.php
  77. +1 −1 libraries/joomla/html/html/menu.php
  78. +2 −1 libraries/joomla/html/html/number.php
  79. +12 −9 libraries/joomla/html/html/select.php
  80. +3 −3 libraries/joomla/html/html/tel.php
  81. +1 −1 libraries/joomla/html/parameter/element/hidden.php
  82. +2 −1 libraries/joomla/html/parameter/element/spacer.php
  83. +1 −1 libraries/joomla/html/parameter/element/timezones.php
  84. +4 −5 libraries/joomla/installer/adapters/component.php
  85. +2 −2 libraries/joomla/installer/adapters/file.php
  86. +10 −11 libraries/joomla/installer/adapters/language.php
  87. +2 −2 libraries/joomla/installer/adapters/library.php
  88. +4 −5 libraries/joomla/installer/adapters/module.php
  89. +3 −3 libraries/joomla/installer/adapters/package.php
  90. +4 −5 libraries/joomla/installer/adapters/plugin.php
  91. +3 −4 libraries/joomla/installer/adapters/template.php
  92. +10 −10 libraries/joomla/installer/installer.php
  93. +1 −1 libraries/joomla/installer/librarymanifest.php
  94. +1 −1 libraries/joomla/installer/packagemanifest.php
  95. +1 −1 libraries/joomla/language/helper.php
  96. +8 −2 libraries/joomla/language/language.php
  97. +10 −1 libraries/joomla/log/logentry.php
  98. +1 −1 libraries/joomla/mail/mail.php
  99. +1 −1 libraries/joomla/plugin/helper.php
  100. +1 −2 libraries/joomla/plugin/plugin.php
  101. +1 −1 libraries/joomla/registry/format/ini.php
  102. +2 −0 libraries/joomla/registry/format/json.php
  103. +1 −1 libraries/joomla/registry/format/php.php
  104. +1 −0 libraries/joomla/registry/registry.php
  105. +4 −2 libraries/joomla/session/session.php
  106. +10 −11 libraries/joomla/string/string.php
  107. +7 −7 libraries/joomla/updater/adapters/collection.php
  108. +6 −7 libraries/joomla/updater/adapters/extension.php
  109. +5 −6 libraries/joomla/updater/update.php
  110. +1 −1 libraries/joomla/updater/updateadapter.php
  111. +1 −1 libraries/joomla/updater/updater.php
  112. +3 −3 libraries/joomla/user/authentication.php
  113. +1 −1 libraries/joomla/user/user.php
  114. +2 −2 libraries/joomla/utilities/arrayhelper.php
  115. +1 −1 libraries/joomla/utilities/xmlelement.php
  116. +1 −0 libraries/loader.php
  117. +1 −1 tests/.gitignore
  118. +55 −37 tests/bootstrap.php
  119. +12 −1 tests/{config.php-dist → config.dist.php}
  120. +0 −15 tests/includes/JUnitHelper.php
  121. +121 −102 tests/includes/JoomlaDatabaseTestCase.php
  122. +42 −57 tests/includes/JoomlaTestCase.php
  123. 0 tests/{suite/joomla/application → includes/mocks}/JApplicationMock.php
  124. 0 tests/{suite/joomla/application → includes/mocks}/JConfigMock.php
  125. +1 −1 tests/{suite/joomla/database → includes/mocks}/JDatabaseMock.php
  126. 0 tests/{suite/joomla/database/JDatabaseHelper.php → includes/mocks/JDatabaseQueryDummy.php}
  127. 0 tests/{suite/joomla/event → includes/mocks}/JDispatcherMock.php
  128. 0 tests/{suite/joomla/document → includes/mocks}/JDocumentMock.php
  129. 0 tests/{suite/joomla/language → includes/mocks}/JLanguageMock.php
  130. 0 tests/{suite/joomla/session → includes/mocks}/JSessionMock.php
  131. +1 −0 tests/includes/stubs/test.xml
  132. +0 −4 tests/objects/index.html
  133. +15 −15 tests/suite/JLoaderTest.php
  134. +6 −1 tests/suite/joomla/access/JAccessTest.php
  135. 0 tests/suite/joomla/access/{JAccessTest.xml → stubs/S01.xml}
  136. +43 −22 tests/suite/joomla/application/JCliTest.php
  137. +3 −3 tests/suite/joomla/application/JInputTest.php
  138. +44 −26 tests/suite/joomla/application/JWebTest.php
  139. +1 −4 tests/suite/joomla/application/cli/JDaemonTest.php
  140. 0 tests/suite/joomla/application/cli/{TestStubs/JDaemon_Inspector.php → stubs/JDaemonInspector.php}
  141. +14 −0 tests/suite/joomla/application/component/JControllerTest.php
  142. +2 −2 tests/suite/joomla/application/input/JInputCLITest.php
  143. +1 −1 ...suite/joomla/application/input/{TestStubs/JInputCLI_Inspector.php → stubs/JInputCliInspector.php}
  144. +2 −2 tests/suite/joomla/application/{TestStubs/JCli_Inspector.php → stubs/JCliInspector.php}
  145. 0 tests/suite/joomla/application/{TestStubs/JFilterInput_Mock.php → stubs/JFilterInputMock.php}
  146. 0 .../joomla/application/{TestStubs/JFilterInput_Mock_Tracker.php → stubs/JFilterInputMockTracker.php}
  147. 0 tests/suite/joomla/application/{TestStubs/JInput_Inspector.php → stubs/JInputInspector.php}
  148. +2 −2 tests/suite/joomla/application/{TestStubs/JWeb_Inspector.php → stubs/JWebInspector.php}
  149. +2 −5 tests/suite/joomla/application/web/JWebClientTest.php
  150. 0 ...suite/joomla/application/web/{TestStubs/JWebClient_Inspector.php → stubs/JWebClientInspector.php}
  151. +29 −13 tests/suite/joomla/base/JAdapterInstanceTest.php
  152. +65 −30 tests/suite/joomla/base/JAdapterTest.php
  153. 0 tests/suite/joomla/base/{TestAdapters → stubs}/testadapter.php
  154. 0 tests/suite/joomla/base/{TestAdapters → stubs}/testadapter2.php
  155. 0 tests/suite/joomla/base/{TestAdapters → stubs}/testadapter3.php
  156. 0 tests/suite/joomla/base/{TestAdapters → stubs}/testadapter4.php
  157. +3 −3 tests/suite/joomla/cache/controller/JCacheControllerCallbackCallbackTest.php
  158. +1 −1 tests/suite/joomla/cache/storage/JCacheStorageMainTest.php
  159. +3 −3 tests/suite/joomla/database/JTableNestedTest.php
  160. +1 −1 tests/suite/joomla/database/database/JDatabaseExporterMySqlTest.php
  161. +1 −1 tests/suite/joomla/database/database/JDatabaseImporterMySqlTest.php
  162. +1 −1 tests/suite/joomla/database/database/JDatabaseMySQLTest.php
  163. 0 tests/suite/joomla/database/database/{TestStubs → stubs}/database.xml
  164. 0 tests/{ → suite/joomla/database}/stubs/jos_assets.csv
  165. 0 tests/{ → suite/joomla/database}/stubs/jos_categories.csv
  166. 0 tests/{ → suite/joomla/database}/stubs/jos_menu.csv
  167. +21 −23 tests/suite/joomla/environment/JFilterInput-mock-general.php
  168. +1 −1 tests/suite/joomla/environment/JRequestCleanTest.php
  169. +22 −23 tests/suite/joomla/environment/JRequestGetVarTest.php
  170. +12 −12 tests/suite/joomla/form/JFormTest.php
  171. +1 −1 tests/suite/joomla/form/fields/JFormFieldAccessLevelTest.php
  172. +1 −1 tests/suite/joomla/form/fields/JFormFieldCacheHandlersTest.php
  173. +4 −4 tests/suite/joomla/form/fields/JFormFieldCalendarTest.php
  174. +1 −1 tests/suite/joomla/form/fields/JFormFieldCategoryTest.php
  175. +1 −1 tests/suite/joomla/form/fields/JFormFieldCheckboxTest.php
  176. +2 −2 tests/suite/joomla/form/fields/JFormFieldCheckboxesTest.php
  177. +1 −1 tests/suite/joomla/form/fields/JFormFieldComboTest.php
  178. +1 −1 tests/suite/joomla/form/fields/JFormFieldComponentLayoutsTest.php
  179. +1 −1 tests/suite/joomla/form/fields/JFormFieldContentLanguagesTest.php
  180. +1 −1 tests/suite/joomla/form/fields/JFormFieldEditorTest.php
  181. +1 −1 tests/suite/joomla/form/fields/JFormFieldEditorsTest.php
  182. +1 −1 tests/suite/joomla/form/fields/JFormFieldFileTest.php
  183. +1 −1 tests/suite/joomla/form/fields/JFormFieldHelpsiteTest.php
  184. +1 −1 tests/suite/joomla/form/fields/JFormFieldHiddenTest.php
  185. +1 −1 tests/suite/joomla/form/fields/JFormFieldIntegerTest.php
  186. +1 −1 tests/suite/joomla/form/fields/JFormFieldLanguageTest.php
  187. +1 −1 tests/suite/joomla/form/fields/JFormFieldListTest.php
  188. +1 −1 tests/suite/joomla/form/fields/JFormFieldMediaTest.php
  189. +1 −1 tests/suite/joomla/form/fields/JFormFieldModuleLayoutsTest.php
  190. +1 −1 tests/suite/joomla/form/fields/JFormFieldPasswordTest.php
  191. +1 −1 tests/suite/joomla/form/fields/JFormFieldRadioTest.php
  192. +1 −1 tests/suite/joomla/form/fields/JFormFieldRulesTest.php
  193. +1 −1 tests/suite/joomla/form/fields/JFormFieldSessionHandlersTest.php
  194. +1 −1 tests/suite/joomla/form/fields/JFormFieldSpacerTest.php
  195. +1 −1 tests/suite/joomla/form/fields/JFormFieldTemplateStyleTest.php
  196. +1 −1 tests/suite/joomla/form/fields/JFormFieldTextTest.php
  197. +1 −1 tests/suite/joomla/form/fields/JFormFieldTextareaTest.php
  198. +1 −1 tests/suite/joomla/form/fields/JFormFieldTimezoneTest.php
  199. +1 −1 tests/suite/joomla/form/fields/JFormFieldUserTest.php
  200. +1 −1 tests/suite/joomla/form/fields/JFormFieldUsergroupTest.php
  201. +72 −44 tests/suite/joomla/html/JGridTest.php
  202. +7 −3 tests/suite/joomla/html/JHtmlTest.php
  203. +4 −4 tests/suite/joomla/html/JParameterTest.php
  204. +27 −2 tests/suite/joomla/html/html/JHtmlBatchTest.php
  205. +27 −4 tests/suite/joomla/html/html/JHtmlEmailTest.php
  206. +42 −9 tests/suite/joomla/html/html/JHtmlListTest.php
  207. +50 −9 tests/suite/joomla/html/html/JHtmlMenuTest.php
  208. +5 −1 tests/suite/joomla/html/html/{JHtmlNumber.php → JHtmlNumberTest.php}
  209. +23 −4 tests/suite/joomla/html/html/JHtmlSelectTest.php
  210. +58 −0 tests/suite/joomla/html/html/JHtmlTelTest.php
  211. +24 −0 tests/suite/joomla/html/html/TestHelpers/JHtmlSelect-helper-dataset.php
  212. 0 tests/suite/joomla/html/html/testfiles/{JHtmlBatchTest.xml → JHtmlTest.xml}
  213. +18 −1 tests/suite/joomla/log/JLogTest.php
  214. +4 −4 tests/suite/joomla/log/loggers/JLoggerDatabaseTest.php
  215. +1 −1 tests/suite/joomla/log/loggers/JLoggerFormattedTextTest.php
  216. +1 −1 tests/suite/joomla/log/loggers/JLoggerMessageQueueTest.php
  217. +1 −1 tests/suite/joomla/log/loggers/JLoggerW3CTest.php
  218. +4 −4 tests/suite/joomla/registry/JRegistryTest.php
  219. 0 tests/suite/joomla/registry/{TestStubs/JRegistry_Inspector.php → stubs/JRegistryInspector.php}
  220. 0 tests/suite/joomla/registry/{TestStubs → stubs}/jregistry.ini
  221. 0 tests/suite/joomla/registry/{TestStubs → stubs}/jregistry.json
  222. +1 −1 tests/suite/joomla/user/JAuthenticationTest.php
  223. 0 tests/suite/joomla/user/{TestStubs → stubs}/FakeAuthenticationPlugin.php
  224. +3 −3 tests/suite/joomla/utilities/JSimpleXMLTest.php
  225. 0 tests/suite/joomla/utilities/{TestStubs → stubs}/empty.xml
  226. 0 tests/suite/joomla/utilities/{TestStubs → stubs}/test.xml
  227. 0 tests/suite/joomla/utilities/{TestStubs → stubs}/xmlFile.xml
  228. 0 tests/{objects → suite/stubs}/bogusload.php
  229. 0 tests/{objects → suite/stubs}/discover1/challenger.php
  230. 0 tests/{objects → suite/stubs}/discover1/columbia.php
  231. 0 tests/{objects → suite/stubs}/discover1/enterprise.txt
  232. 0 tests/{objects → suite/stubs}/discover2/challenger.php
  233. 0 tests/{objects → suite/stubs}/discover2/discover3/atlantis.php
  234. +0 −13 tests/test_application/config.jweb-array.php
  235. +0 −14 tests/test_application/config.jweb-snoopy.php
  236. +0 −29 tests/test_application/defines.php
  237. +0 −4 tests/test_application/media/system/images/index.html
  238. +0 −4 tests/test_application/templates/index.html
  239. 0 tests/{test_application → tmp}/config.jweb-wrongclass.php
  240. 0 tests/{test_application → tmp}/configuration.php
View
@@ -81,7 +81,7 @@
<exec executable="phpcs">
<arg value="--report=checkstyle" />
<arg value="--report-file=${basedir}/build/logs/checkstyle.xml" />
- <arg value="--standard=Joomla" />
+ <arg value="--standard=${basedir}/build/phpcs/Joomla" />
<arg path="${source}/joomla" />
</exec>
</target>
@@ -19,6 +19,8 @@
throw new PHP_CodeSniffer_Exception($error);
}
+require_once 'FileCommentSniff.php';
+
if (class_exists('Joomla_Sniffs_Commenting_FileCommentSniff', true) === false) {
$error = 'Class Joomla_Sniffs_Commenting_FileCommentSniff not found';
throw new PHP_CodeSniffer_Exception($error);
@@ -50,10 +50,9 @@ public function __construct()
protected function getPatterns()
{
return array(
- 'if (...)EOL...{...}EOL',
- 'elseEOL...{EOL',
- 'elseif (...)EOL...{EOL',
- 'else if (...)EOL...{EOL',
+ 'if (...)EOL...{...}EOL...elseEOL',
+ 'if (...)EOL...{...}EOL...elseif (...)EOL',
+ 'if (...)EOL',
'tryEOL...{EOL...}EOL',
'catch (...)EOL...{EOL',
@@ -88,8 +87,8 @@ protected function processPattern($patternInfo, PHP_CodeSniffer_File $phpcsFile
{
/*
* @todo disabled - This is a special sniff for the Joomla! CMS to exclude
- * the tmpl folder which may contain constructs in colon notation
- */
+ * the tmpl folder which may contain constructs in colon notation
+ */
$parts = explode(DIRECTORY_SEPARATOR, $phpcsFile->getFileName());
@@ -0,0 +1,79 @@
+<?php
+/**
+ * Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff.
+ *
+ * PHP version 5
+ *
+ * @category PHP
+ * @package PHP_CodeSniffer
+ * @author Greg Sherwood <gsherwood@squiz.net>
+ * @author Marc McIntyre <mmcintyre@squiz.net>
+ * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
+ * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
+ * @version CVS: $Id: ElseIfDeclarationSniff.php 301632 2010-07-28 01:57:56Z squiz $
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+
+/**
+ * Squiz_Sniffs_ControlStructures_ElseIfDeclarationSniff.
+ *
+ * Verifies that there are no "else if" statements. The else and the if should
+ * be a single word "elseif".
+ *
+ * @category PHP
+ * @package PHP_CodeSniffer
+ * @author Greg Sherwood <gsherwood@squiz.net>
+ * @author Marc McIntyre <mmcintyre@squiz.net>
+ * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
+ * @license http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
+ * @version Release: 1.3.0
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+class Joomla_Sniffs_ControlStructures_ElseIfDeclarationSniff implements PHP_CodeSniffer_Sniff
+{
+
+
+ /**
+ * Returns an array of tokens this test wants to listen for.
+ *
+ * @return array
+ */
+ public function register()
+ {
+ return array(T_ELSE);
+
+ }//end register()
+
+
+ /**
+ * Processes this test, when one of its tokens is encountered.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param int $stackPtr The position of the current token in the
+ * stack passed in $tokens.
+ *
+ * @return void
+ */
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ $tokens = $phpcsFile->getTokens();
+
+ $nextNonWhiteSpace = $phpcsFile->findNext(
+ T_WHITESPACE,
+ $stackPtr + 1,
+ null,
+ true,
+ null,
+ true
+ );
+
+ if($tokens[$nextNonWhiteSpace]['code'] == T_IF)
+ {
+ $error = 'Usage of ELSE IF is not allowed; use ELSEIF instead';
+ $phpcsFile->addError($error, $stackPtr, 'NotAllowed');
+ }
+
+ }//end process()
+
+
+}//end class
@@ -46,7 +46,7 @@ class Joomla_Sniffs_ControlStructures_InlineControlStructureSniff extends Generi
*
* @var bool
*/
- public $error = true;
+ public $error = false;
/**
@@ -29,7 +29,6 @@
class Joomla_Sniffs_ControlStructures_MultiLineConditionSniff implements PHP_CodeSniffer_Sniff
{
-
/**
* Returns an array of tokens this test wants to listen for.
*
@@ -41,7 +40,6 @@ public function register()
}//end register()
-
/**
* Processes this test, when one of its tokens is encountered.
*
@@ -74,25 +72,22 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
// function call, in which case it is ignored.
$openBracket = $tokens[$stackPtr]['parenthesis_opener'];
$closeBracket = $tokens[$stackPtr]['parenthesis_closer'];
- $lastLine = $tokens[$openBracket]['line'];
- for ($i = ($openBracket + 1); $i < $closeBracket; $i++) {
+ $lastLine = $tokens[$openBracket]['line'];
+
+ for ($i = ($openBracket + 1); $i <= $closeBracket; $i++) {
if ($tokens[$i]['line'] !== $lastLine) {
if ($tokens[$i]['line'] === $tokens[$closeBracket]['line']) {
$next = $phpcsFile->findNext(T_WHITESPACE, $i, null, true);
- if ($next !== $closeBracket) {
- // Closing bracket is on the same line as a condition.
- $error = 'Closing parenthesis of a multi-line IF statement must be on a new line';
- $phpcsFile->addError($error, $i, 'CloseBracketNewLine');
- $expectedIndent = ($statementIndent + 1);
- } else {
- // Closing brace needs to be indented to the same level
- // as the function.
- $expectedIndent = $statementIndent;
+ if ($next == $closeBracket) {
+ $error = 'Closing parenthesis of a multi-line IF statement must be on the same line';
+ $phpcsFile->addError($error, $i, 'CloseBracketNewLine');
+ $i ++;
+ continue;
}
- } else {
- $expectedIndent = ($statementIndent + 1);
}
+ $expectedIndent = ($statementIndent + 1);
+
// We changed lines, so this should be a whitespace indent token.
if ($tokens[$i]['code'] !== T_WHITESPACE) {
$foundIndent = 0;
@@ -109,12 +104,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$phpcsFile->addError($error, $i, 'Alignment', $data);
}
- if ($tokens[$i]['line'] !== $tokens[$closeBracket]['line']) {
- $next = $phpcsFile->findNext(T_WHITESPACE, $i, null, true);
- if (in_array($tokens[$next]['code'], PHP_CodeSniffer_Tokens::$booleanOperators) === false) {
- $error = 'Each line in a multi-line IF statement must begin with a boolean operator';
- $phpcsFile->addError($error, $i, 'StartWithBoolean');
- }
+ $next = $phpcsFile->findNext(T_WHITESPACE, $i, null, true);
+
+ if (in_array($tokens[$next]['code'], PHP_CodeSniffer_Tokens::$booleanOperators) === false) {
+ $error = 'Each line in a multi-line IF statement must begin with a boolean operator';
+ $phpcsFile->addError($error, $i, 'StartWithBoolean');
}
$lastLine = $tokens[$i]['line'];
@@ -132,31 +126,8 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
}
}//end for
- // From here on, we are checking the spacing of the opening and closing
- // braces. If this IF statement does not use braces, we end here.
- if (isset($tokens[$stackPtr]['scope_opener']) === false) {
- return;
- }
-
- // The opening brace needs to be one space away from the closing parenthesis.
- if ($tokens[($closeBracket + 1)]['code'] !== T_WHITESPACE) {
- $length = 0;
- } else if ($tokens[($closeBracket + 1)]['content'] === $phpcsFile->eolChar) {
- $length = -1;
- } else {
- $length = strlen($tokens[($closeBracket + 1)]['content']);
- }
-
- // And just in case they do something funny before the brace...
- $next = $phpcsFile->findNext(T_WHITESPACE, ($closeBracket + 1), null, true);
- if ($next !== false && $tokens[$next]['code'] !== T_OPEN_CURLY_BRACKET) {
- $error = 'There must be a single space between the closing parenthesis and the opening brace of a multi-line IF statement';
- $phpcsFile->addError($error, $next, 'NoSpaceBeforeOpenBrace');
- }
-
}//end process()
-
}//end class
?>
@@ -83,6 +83,12 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$phpcsFile->addError($error, $stackPtr, 'BracketsNotRequired', $data);
}
+ /*
+ * elkuku: The test for conditional including has been disabled.
+ */
+
+ return;
+
$inCondition = (count($tokens[$stackPtr]['conditions']) !== 0) ? true : false;
// Check to see if this including statement is within the parenthesis
Oops, something went wrong.

0 comments on commit bccfc87

Please sign in to comment.