Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add the following sniffs but only apply them to select folders:

Generic.Files.LineLength
PEAR.Functions.ValidDefaultValue
Squiz.Operators.IncrementDecrementUsage
Joomla.Classes.MethodScope
Joomla.Commenting.FunctionComment
Joomla.Commenting.SingleComment
Joomla.Commenting.ClassComment
Joomla.WhiteSpace.ConcatenationSpacing
Joomla.ControlStructures.ControlSignature
Joomla.ControlStructures.InlineControlStructure
Joomla.ControlStructures.MultiLineCondition
  • Loading branch information...
commit 7c3aa939bd6ef8365d5248f3765dd0ebdd17e315 1 parent ecb620d
@realityking realityking authored
Showing with 1,700 additions and 51 deletions.
  1. +87 −0 build/phpcs/Joomla/Sniffs/Classes/MethodScopeSniff.php
  2. +299 −0 build/phpcs/Joomla/Sniffs/Commenting/ClassCommentSniff.php
  3. +508 −0 build/phpcs/Joomla/Sniffs/Commenting/FunctionCommentSniff.php
  4. +147 −0 build/phpcs/Joomla/Sniffs/Commenting/SingleCommentSniff.php
  5. +106 −0 build/phpcs/Joomla/Sniffs/ControlStructures/ControlSignatureSniff.php
  6. +121 −0 build/phpcs/Joomla/Sniffs/ControlStructures/InlineControlStructureSniff.php
  7. +133 −0 build/phpcs/Joomla/Sniffs/ControlStructures/MultiLineConditionSniff.php
  8. +99 −0 build/phpcs/Joomla/Sniffs/WhiteSpace/ConcatenationSpacingSniff.php
  9. +136 −1 build/phpcs/Joomla/ruleset.xml
  10. +1 −3 cli/finder_indexer.php
  11. +6 −4 index.php
  12. +4 −2 libraries/cms.php
  13. +1 −0  libraries/cms/feed/factory.php
  14. +2 −0  libraries/cms/feed/parser.php
  15. +3 −1 libraries/cms/form/field/captcha.php
  16. +2 −2 libraries/cms/html/bootstrap.php
  17. +1 −1  libraries/cms/html/icons.php
  18. +1 −1  libraries/cms/html/sortablelist.php
  19. +31 −25 libraries/cms/schema/changeitempostgresql.php
  20. +1 −0  libraries/cms/toolbar/button/help.php
  21. +2 −2 libraries/cms/toolbar/button/popup.php
  22. +1 −1  libraries/cms/toolbar/button/slider.php
  23. +1 −1  libraries/cms/toolbar/button/standard.php
  24. +2 −2 libraries/joomla/form/fields/rules.php
  25. +2 −2 libraries/joomla/html/grid.php
  26. +2 −2 libraries/joomla/session/storage/database.php
  27. +1 −1  libraries/joomla/table/table.php
View
87 build/phpcs/Joomla/Sniffs/Classes/MethodScopeSniff.php
@@ -0,0 +1,87 @@
+<?php
+/**
+ * Verifies that class members have scope modifiers.
+ *
+ * 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: MethodScopeSniff.php 8 2010-11-06 00:40:23Z elkuku $
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+
+if(class_exists('PHP_CodeSniffer_Standards_AbstractScopeSniff', true) === false)
+{
+ throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractScopeSniff not found');
+}
+
+/**
+ * Verifies that class members have scope modifiers.
+ *
+ * Example:
+ * class Foo
+ * {
+ * <b class="good">public function foo()</b>
+ * {
+ * }
+ *
+ * <b class="bad">function foo()</b>
+ * {
+ * }
+ * }
+ *
+ * @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.0RC1
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+class Joomla_Sniffs_Classes_MethodScopeSniff extends PHP_CodeSniffer_Standards_AbstractScopeSniff
+{
+ /**
+ * Constructs a Squiz_Sniffs_Scope_MethodScopeSniff.
+ */
+ public function __construct()
+ {
+ parent::__construct(array(T_CLASS, T_INTERFACE), array(T_FUNCTION));
+ }//function
+
+ /**
+ * Processes the function tokens within the class.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file where this token was found.
+ * @param integer $stackPtr The position where the token was found.
+ * @param integer $currScope The current scope opener token.
+ *
+ * @return void
+ */
+ protected function processTokenWithinScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $currScope)
+ {
+ $tokens = $phpcsFile->getTokens();
+
+ $methodName = $phpcsFile->getDeclarationName($stackPtr);
+
+ if($methodName === null)
+ {
+ // Ignore closures.
+ return;
+ }
+
+ $modifier = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$scopeModifiers, $stackPtr);
+
+ if(($modifier === false) || ($tokens[$modifier]['line'] !== $tokens[$stackPtr]['line']))
+ {
+ $error = sprintf('No scope modifier specified for function "%s"'
+ , $methodName);
+
+ $phpcsFile->addWarning($error, $stackPtr, 'Missing');
+ }
+ }//function
+}//class
View
299 build/phpcs/Joomla/Sniffs/Commenting/ClassCommentSniff.php
@@ -0,0 +1,299 @@
+<?php
+/**
+ * Parses and verifies the doc comments for classes.
+ *
+ * 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: ClassCommentSniff.php 301632 2010-07-28 01:57:56Z squiz $
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+
+if (class_exists('PHP_CodeSniffer_CommentParser_ClassCommentParser', true) === false) {
+ $error = 'Class PHP_CodeSniffer_CommentParser_ClassCommentParser not found';
+ 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);
+}
+
+/**
+ * Parses and verifies the doc comments for classes.
+ *
+ * Verifies that :
+ * <ul>
+ * <li>A doc comment exists.</li>
+ * <li>There is a blank newline after the short description.</li>
+ * <li>There is a blank newline between the long and short description.</li>
+ * <li>There is a blank newline between the long description and tags.</li>
+ * <li>Check the order of the tags.</li>
+ * <li>Check the indentation of each tag.</li>
+ * <li>Check required and optional tags and the format of their content.</li>
+ * </ul>
+ *
+ * @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.0RC2
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+class Joomla_Sniffs_Commenting_ClassCommentSniff extends Joomla_Sniffs_Commenting_FileCommentSniff
+{
+
+
+ /**
+ * Tags in correct order and related info.
+ *
+ * @var array
+ */
+ protected $tags = array(
+ 'version' => array(
+ 'required' => false,
+ 'allow_multiple' => false,
+ 'order_text' => 'is first',
+ ),
+ 'category' => array(
+ 'required' => false,
+ 'allow_multiple' => false,
+ 'order_text' => 'must follow @version (if used)',
+ ),
+ 'package' => array(
+ 'required' => true,
+ 'allow_multiple' => false,
+ 'order_text' => 'must follow @category (if used)',
+ ),
+ 'subpackage' => array(
+ 'required' => false,
+ 'allow_multiple' => false,
+ 'order_text' => 'must follow @package',
+ ),
+ 'author' => array(
+ 'required' => false,
+ 'allow_multiple' => true,
+ 'order_text' => 'is first',
+ ),
+ 'copyright' => array(
+ 'required' => false,
+ 'allow_multiple' => true,
+ 'order_text' => 'must follow @author (if used) or @subpackage (if used) or @package',
+ ),
+ 'license' => array(
+ 'required' => false,
+ 'allow_multiple' => false,
+ 'order_text' => 'must follow @copyright (if used)',
+ ),
+ 'link' => array(
+ 'required' => false,
+ 'allow_multiple' => true,
+ 'order_text' => 'must follow @version (if used)',
+ ),
+ 'see' => array(
+ 'required' => false,
+ 'allow_multiple' => true,
+ 'order_text' => 'must follow @link (if used)',
+ ),
+ 'since' => array(
+ 'required' => true,
+ 'allow_multiple' => false,
+ 'order_text' => 'must follow @see (if used) or @link (if used)',
+ ),
+ 'deprecated' => array(
+ 'required' => false,
+ 'allow_multiple' => false,
+ 'order_text' => 'must follow @since (if used) or @see (if used) or @link (if used)',
+ ),
+ );
+
+ /**
+ * Returns an array of tokens this test wants to listen for.
+ *
+ * @return array
+ */
+ public function register()
+ {
+ return array(
+ T_CLASS,
+ T_INTERFACE,
+ );
+
+ }//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)
+ {
+ $this->currentFile = $phpcsFile;
+
+ $tokens = $phpcsFile->getTokens();
+ $type = strtolower($tokens[$stackPtr]['content']);
+ $errorData = array($type);
+ $find = array(
+ T_ABSTRACT,
+ T_WHITESPACE,
+ T_FINAL,
+ );
+
+ // Extract the class comment docblock.
+ $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
+
+ if ($commentEnd !== false && $tokens[$commentEnd]['code'] === T_COMMENT) {
+ $error = 'You must use "/**" style comments for a %s comment';
+ $phpcsFile->addError($error, $stackPtr, 'WrongStyle', $errorData);
+ return;
+ } else if ($commentEnd === false
+ || $tokens[$commentEnd]['code'] !== T_DOC_COMMENT
+ ) {
+ $phpcsFile->addError('Missing %s doc comment', $stackPtr, 'Missing', $errorData);
+ return;
+ }
+
+ $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1);
+ $commentNext = $phpcsFile->findPrevious(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar);
+
+ // Distinguish file and class comment.
+ $prevClassToken = $phpcsFile->findPrevious(T_CLASS, ($stackPtr - 1));
+ if ($prevClassToken === false) {
+ // This is the first class token in this file, need extra checks.
+ $prevNonComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($commentStart - 1), null, true);
+ if ($prevNonComment !== false) {
+ $prevComment = $phpcsFile->findPrevious(T_DOC_COMMENT, ($prevNonComment - 1));
+ if ($prevComment === false) {
+ // There is only 1 doc comment between open tag and class token.
+ $newlineToken = $phpcsFile->findNext(T_WHITESPACE, ($commentEnd + 1), $stackPtr, false, $phpcsFile->eolChar);
+ if ($newlineToken !== false) {
+ $newlineToken = $phpcsFile->findNext(
+ T_WHITESPACE,
+ ($newlineToken + 1),
+ $stackPtr,
+ false,
+ $phpcsFile->eolChar
+ );
+
+ if ($newlineToken !== false) {
+ // Blank line between the class and the doc block.
+ // The doc block is most likely a file comment.
+ $error = 'Missing %s doc comment';
+ $phpcsFile->addError($error, ($stackPtr + 1), 'Missing', $errorData);
+ return;
+ }
+ }//end if
+ }//end if
+ }//end if
+ }//end if
+
+ $comment = $phpcsFile->getTokensAsString(
+ $commentStart,
+ ($commentEnd - $commentStart + 1)
+ );
+
+ // Parse the class comment.docblock.
+ try {
+ $this->commentParser = new PHP_CodeSniffer_CommentParser_ClassCommentParser($comment, $phpcsFile);
+ $this->commentParser->parse();
+ } catch (PHP_CodeSniffer_CommentParser_ParserException $e) {
+ $line = ($e->getLineWithinComment() + $commentStart);
+ $phpcsFile->addError($e->getMessage(), $line, 'FailedParse');
+ return;
+ }
+
+ $comment = $this->commentParser->getComment();
+ if (is_null($comment) === true) {
+ $error = 'Doc comment is empty for %s';
+ $phpcsFile->addError($error, $commentStart, 'Empty', $errorData);
+ return;
+ }
+
+ // No extra newline before short description.
+ $short = $comment->getShortComment();
+ $newlineCount = 0;
+ $newlineSpan = strspn($short, $phpcsFile->eolChar);
+ if ($short !== '' && $newlineSpan > 0) {
+ $error = 'Extra newline(s) found before %s comment short description';
+ $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort', $errorData);
+ }
+
+ $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1);
+
+ // Exactly one blank line between short and long description.
+ $long = $comment->getLongComment();
+ if (empty($long) === false) {
+ $between = $comment->getWhiteSpaceBetween();
+ $newlineBetween = substr_count($between, $phpcsFile->eolChar);
+ if ($newlineBetween !== 2) {
+ $error = 'There must be exactly one blank line between descriptions in %s comments';
+ $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingAfterShort', $errorData);
+ }
+
+ $newlineCount += $newlineBetween;
+ }
+
+ // Exactly one blank line before tags.
+ $tags = $this->commentParser->getTagOrders();
+ if (count($tags) > 1) {
+ $newlineSpan = $comment->getNewlineAfter();
+ if ($newlineSpan !== 2) {
+ $error = 'There must be exactly one blank line before the tags in %s comments';
+ if ($long !== '') {
+ $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1);
+ }
+
+ $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags', $errorData);
+ $short = rtrim($short, $phpcsFile->eolChar.' ');
+ }
+ }
+
+ // Check each tag.
+ $this->processTags($commentStart, $commentEnd);
+
+ }//end process()
+
+
+ /**
+ * Process the version tag.
+ *
+ * @param int $errorPos The line number where the error occurs.
+ *
+ * @return void
+ */
+ protected function processVersion($errorPos)
+ {
+ $version = $this->commentParser->getVersion();
+ if ($version !== null) {
+ $content = $version->getContent();
+ $matches = array();
+ if (empty($content) === true) {
+ $error = 'Content missing for @version tag in doc comment';
+ $this->currentFile->addError($error, $errorPos, 'EmptyVersion');
+ } else if ((strstr($content, 'Release:') === false)) {
+ $error = 'Invalid version "%s" in doc comment; consider "Release: <package_version>" instead';
+ $data = array($content);
+ $this->currentFile->addWarning($error, $errorPos, 'InvalidVersion', $data);
+ }
+ }
+
+ }//end processVersion()
+
+
+}//end class
+
+?>
View
508 build/phpcs/Joomla/Sniffs/Commenting/FunctionCommentSniff.php
@@ -0,0 +1,508 @@
+<?php
+/**
+ * Parses and verifies the doc comments for functions.
+ *
+ * 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: FunctionCommentSniff.php 301632 2010-07-28 01:57:56Z squiz $
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+
+if (class_exists('PHP_CodeSniffer_CommentParser_FunctionCommentParser', true) === false) {
+ throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_CommentParser_FunctionCommentParser not found');
+}
+
+/**
+ * Parses and verifies the doc comments for functions.
+ *
+ * Verifies that :
+ * <ul>
+ * <li>A comment exists</li>
+ * <li>There is a blank newline after the short description.</li>
+ * <li>There is a blank newline between the long and short description.</li>
+ * <li>There is a blank newline between the long description and tags.</li>
+ * <li>Parameter names represent those in the method.</li>
+ * <li>Parameter comments are in the correct order</li>
+ * <li>Parameter comments are complete</li>
+ * <li>A space is present before the first and after the last parameter</li>
+ * <li>A return type exists</li>
+ * <li>There must be one blank line between body and headline comments.</li>
+ * <li>Any throw tag must have an exception class.</li>
+ * </ul>
+ *
+ * @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.0RC2
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+class Joomla_Sniffs_Commenting_FunctionCommentSniff implements PHP_CodeSniffer_Sniff
+{
+
+ /**
+ * The name of the method that we are currently processing.
+ *
+ * @var string
+ */
+ private $_methodName = '';
+
+ /**
+ * The position in the stack where the fucntion token was found.
+ *
+ * @var int
+ */
+ private $_functionToken = null;
+
+ /**
+ * The position in the stack where the class token was found.
+ *
+ * @var int
+ */
+ private $_classToken = null;
+
+ /**
+ * The function comment parser for the current method.
+ *
+ * @var PHP_CodeSniffer_Comment_Parser_FunctionCommentParser
+ */
+ protected $commentParser = null;
+
+ /**
+ * The current PHP_CodeSniffer_File object we are processing.
+ *
+ * @var PHP_CodeSniffer_File
+ */
+ protected $currentFile = null;
+
+
+ /**
+ * Returns an array of tokens this test wants to listen for.
+ *
+ * @return array
+ */
+ public function register()
+ {
+ return array(T_FUNCTION);
+
+ }//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)
+ {
+ $find = array(
+ T_COMMENT,
+ T_DOC_COMMENT,
+ T_CLASS,
+ T_FUNCTION,
+ T_OPEN_TAG,
+ );
+
+ $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1));
+
+ if ($commentEnd === false) {
+ return;
+ }
+
+ $this->currentFile = $phpcsFile;
+ $tokens = $phpcsFile->getTokens();
+
+ // If the token that we found was a class or a function, then this
+ // function has no doc comment.
+ $code = $tokens[$commentEnd]['code'];
+
+ if ($code === T_COMMENT) {
+ $error = 'You must use "/**" style comments for a function comment';
+ $phpcsFile->addError($error, $stackPtr, 'WrongStyle');
+ return;
+ } else if ($code !== T_DOC_COMMENT) {
+ $phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing');
+ return;
+ }
+
+ // If there is any code between the function keyword and the doc block
+ // then the doc block is not for us.
+ $ignore = PHP_CodeSniffer_Tokens::$scopeModifiers;
+ $ignore[] = T_STATIC;
+ $ignore[] = T_WHITESPACE;
+ $ignore[] = T_ABSTRACT;
+ $ignore[] = T_FINAL;
+ $prevToken = $phpcsFile->findPrevious($ignore, ($stackPtr - 1), null, true);
+ if ($prevToken !== $commentEnd) {
+ $phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing');
+ return;
+ }
+
+ $this->_functionToken = $stackPtr;
+
+ $this->_classToken = null;
+ foreach ($tokens[$stackPtr]['conditions'] as $condPtr => $condition) {
+ if ($condition === T_CLASS || $condition === T_INTERFACE) {
+ $this->_classToken = $condPtr;
+ break;
+ }
+ }
+
+ // If the first T_OPEN_TAG is right before the comment, it is probably
+ // a file comment.
+ $commentStart = ($phpcsFile->findPrevious(T_DOC_COMMENT, ($commentEnd - 1), null, true) + 1);
+ $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($commentStart - 1), null, true);
+ if ($tokens[$prevToken]['code'] === T_OPEN_TAG) {
+ // Is this the first open tag?
+ if ($stackPtr === 0 || $phpcsFile->findPrevious(T_OPEN_TAG, ($prevToken - 1)) === false) {
+ $phpcsFile->addError('Missing function doc comment', $stackPtr, 'Missing');
+ return;
+ }
+ }
+
+ $comment = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1));
+ $this->_methodName = $phpcsFile->getDeclarationName($stackPtr);
+
+ try {
+ $this->commentParser = new PHP_CodeSniffer_CommentParser_FunctionCommentParser($comment, $phpcsFile);
+ $this->commentParser->parse();
+ } catch (PHP_CodeSniffer_CommentParser_ParserException $e) {
+ $line = ($e->getLineWithinComment() + $commentStart);
+ $phpcsFile->addError($e->getMessage(), $line, 'FailedParse');
+ return;
+ }
+
+ $comment = $this->commentParser->getComment();
+ if (is_null($comment) === true) {
+ $error = 'Function doc comment is empty';
+ $phpcsFile->addError($error, $commentStart, 'Empty');
+ return;
+ }
+
+ $this->processParams($commentStart);
+ $this->processReturn($commentStart, $commentEnd);
+ $this->processThrows($commentStart);
+
+ // No extra newline before short description.
+ $short = $comment->getShortComment();
+ $newlineCount = 0;
+ $newlineSpan = strspn($short, $phpcsFile->eolChar);
+ if ($short !== '' && $newlineSpan > 0) {
+ $error = 'Extra newline(s) found before function comment short description';
+ $phpcsFile->addError($error, ($commentStart + 1), 'SpacingBeforeShort');
+ }
+
+ $newlineCount = (substr_count($short, $phpcsFile->eolChar) + 1);
+
+ // Exactly one blank line between short and long description.
+ $long = $comment->getLongComment();
+ if (empty($long) === false) {
+ $between = $comment->getWhiteSpaceBetween();
+ $newlineBetween = substr_count($between, $phpcsFile->eolChar);
+ if ($newlineBetween !== 2) {
+ $error = 'There must be exactly one blank line between descriptions in function comment';
+ $phpcsFile->addError($error, ($commentStart + $newlineCount + 1), 'SpacingAfterShort');
+ }
+
+ $newlineCount += $newlineBetween;
+ }
+
+ // Exactly one blank line before tags.
+ $params = $this->commentParser->getTagOrders();
+ if (count($params) > 1) {
+ $newlineSpan = $comment->getNewlineAfter();
+ if ($newlineSpan !== 2) {
+ $error = 'There must be exactly one blank line before the tags in function comment';
+ if ($long !== '') {
+ $newlineCount += (substr_count($long, $phpcsFile->eolChar) - $newlineSpan + 1);
+ }
+
+ $phpcsFile->addError($error, ($commentStart + $newlineCount), 'SpacingBeforeTags');
+ $short = rtrim($short, $phpcsFile->eolChar.' ');
+ }
+ }
+
+ }//end process()
+
+
+ /**
+ * Process any throw tags that this function comment has.
+ *
+ * @param int $commentStart The position in the stack where the
+ * comment started.
+ *
+ * @return void
+ */
+ protected function processThrows($commentStart)
+ {
+ if (count($this->commentParser->getThrows()) === 0) {
+ return;
+ }
+
+ foreach ($this->commentParser->getThrows() as $throw) {
+
+ $exception = $throw->getValue();
+ $errorPos = ($commentStart + $throw->getLine());
+
+ if ($exception === '') {
+ $error = '@throws tag must contain the exception class name';
+ $this->currentFile->addError($error, $errorPos, 'EmptyThrows');
+ }
+ }
+
+ }//end processThrows()
+
+
+ /**
+ * Process the return comment of this function comment.
+ *
+ * @param int $commentStart The position in the stack where the comment started.
+ * @param int $commentEnd The position in the stack where the comment ended.
+ *
+ * @return void
+ */
+ protected function processReturn($commentStart, $commentEnd)
+ {
+ // Skip constructor and destructor.
+ $className = '';
+ if ($this->_classToken !== null) {
+ $className = $this->currentFile->getDeclarationName($this->_classToken);
+ $className = strtolower(ltrim($className, '_'));
+ }
+
+ $methodName = strtolower(ltrim($this->_methodName, '_'));
+ $isSpecialMethod = ($this->_methodName === '__construct' || $this->_methodName === '__destruct');
+
+ if ($isSpecialMethod === false && $methodName !== $className) {
+ // Report missing return tag.
+ if ($this->commentParser->getReturn() === null) {
+ $error = 'Missing @return tag in function comment';
+ $this->currentFile->addError($error, $commentEnd, 'MissingReturn');
+ } else if (trim($this->commentParser->getReturn()->getRawContent()) === '') {
+ $error = '@return tag is empty in function comment';
+ $errorPos = ($commentStart + $this->commentParser->getReturn()->getLine());
+ $this->currentFile->addError($error, $errorPos, 'EmptyReturn');
+ } else {
+ if (substr_count($this->commentParser->getReturn()->getWhitespaceAfter(), $this->currentFile->eolChar) !== 2) {
+ $error = 'Return comment requires a blank newline after it';
+ $errorPos = ($this->commentParser->getReturn()->getLine() + $commentStart);
+ $this->currentFile->addError($error, $errorPos, 'SpacingAfterReturn');
+ }
+ }
+ }
+ else
+ {
+ if ($this->commentParser->getReturn() != null)
+ {
+ $error = 'Constructor and destructor comments must not have a @return tag';
+ $errorPos = ($this->commentParser->getReturn()->getLine() + $commentStart);
+ $this->currentFile->addError($error, $errorPos, 'UselessReturn');
+ }
+ }
+ }//end processReturn()
+
+
+ /**
+ * Process the function parameter comments.
+ *
+ * @param int $commentStart The position in the stack where
+ * the comment started.
+ *
+ * @return void
+ */
+ protected function processParams($commentStart)
+ {
+ $realParams = $this->currentFile->getMethodParameters($this->_functionToken);
+
+ $params = $this->commentParser->getParams();
+ $foundParams = array();
+
+ if (empty($params) === false) {
+
+ $lastParm = (count($params) - 1);
+ if (substr_count($params[$lastParm]->getWhitespaceAfter(), $this->currentFile->eolChar) !== 2) {
+ $error = 'Last parameter comment requires a blank newline after it';
+ $errorPos = ($params[$lastParm]->getLine() + $commentStart);
+ $this->currentFile->addError($error, $errorPos, 'SpacingAfterParams');
+ }
+
+ // Parameters must appear immediately after the comment.
+ if ($params[0]->getOrder() !== 2) {
+ $error = 'Parameters must appear immediately after the comment';
+ $errorPos = ($params[0]->getLine() + $commentStart);
+ $this->currentFile->addError($error, $errorPos, 'SpacingBeforeParams');
+ }
+
+ $previousParam = null;
+ $spaceBeforeVar = 10000;
+ $spaceBeforeComment = 10000;
+ $longestType = 0;
+ $longestVar = 0;
+
+ foreach ($params as $param) {
+
+ $paramComment = trim($param->getComment());
+ $errorPos = ($param->getLine() + $commentStart);
+
+ // Make sure that there is only one space before the var type.
+ // Joomla change: 3 spaces to make it line up with the @return tag with a 2 space gap.
+ if ($param->getWhitespaceBeforeType() !== ' ') {
+ $error = 'Expected 3 spaces before variable type';
+ $this->currentFile->addError($error, $errorPos, 'BeforeParamType');
+ }
+
+ $spaceCount = substr_count($param->getWhitespaceBeforeVarName(), ' ');
+ if ($spaceCount < $spaceBeforeVar) {
+ $spaceBeforeVar = $spaceCount;
+ $longestType = $errorPos;
+ }
+
+ $spaceCount = substr_count($param->getWhitespaceBeforeComment(), ' ');
+
+ if ($spaceCount < $spaceBeforeComment && $paramComment !== '') {
+ $spaceBeforeComment = $spaceCount;
+ $longestVar = $errorPos;
+ }
+
+ // Make sure they are in the correct order,
+ // and have the correct name.
+ $pos = $param->getPosition();
+
+ $paramName = ($param->getVarName() !== '') ? $param->getVarName() : '[ UNKNOWN ]';
+
+ if ($previousParam !== null) {
+ $previousName = ($previousParam->getVarName() !== '') ? $previousParam->getVarName() : 'UNKNOWN';
+
+ // Check to see if the parameters align properly.
+ if ($param->alignsVariableWith($previousParam) === false) {
+ $error = 'The variable names for parameters %s (%s) and %s (%s) do not align';
+ $data = array(
+ $previousName,
+ ($pos - 1),
+ $paramName,
+ $pos,
+ );
+ $this->currentFile->addError($error, $errorPos, 'ParameterNamesNotAligned', $data);
+ }
+
+ if ($param->alignsCommentWith($previousParam) === false) {
+ $error = 'The comments for parameters %s (%s) and %s (%s) do not align';
+ $data = array(
+ $previousName,
+ ($pos - 1),
+ $paramName,
+ $pos,
+ );
+ $this->currentFile->addError($error, $errorPos, 'ParameterCommentsNotAligned', $data);
+ }
+ }//end if
+
+ // Make sure the names of the parameter comment matches the
+ // actual parameter.
+ if (isset($realParams[($pos - 1)]) === true) {
+ $realName = $realParams[($pos - 1)]['name'];
+ $foundParams[] = $realName;
+
+ // Append ampersand to name if passing by reference.
+ if ($realParams[($pos - 1)]['pass_by_reference'] === true) {
+ $realName = '&'.$realName;
+ }
+
+ if ($realName !== $paramName) {
+ $code = 'ParamNameNoMatch';
+ $data = array(
+ $paramName,
+ $realName,
+ $pos,
+ );
+
+ $error = 'Doc comment for var %s does not match ';
+ if (strtolower($paramName) === strtolower($realName)) {
+ $error .= 'case of ';
+ $code = 'ParamNameNoCaseMatch';
+ }
+
+ $error .= 'actual variable name %s at position %s';
+
+ $this->currentFile->addError($error, $errorPos, $code, $data);
+ }
+ } else {
+ // We must have an extra parameter comment.
+ $error = 'Superfluous doc comment at position '.$pos;
+ $this->currentFile->addError($error, $errorPos, 'ExtraParamComment');
+ }
+
+ if ($param->getVarName() === '') {
+ $error = 'Missing parameter name at position '.$pos;
+ $this->currentFile->addError($error, $errorPos, 'MissingParamName');
+ }
+
+ if ($param->getType() === '') {
+ $error = 'Missing type at position '.$pos;
+ $this->currentFile->addError($error, $errorPos, 'MissingParamType');
+ }
+
+ if ($paramComment === '') {
+ $error = 'Missing comment for param "%s" at position %s';
+ $data = array(
+ $paramName,
+ $pos,
+ );
+ $this->currentFile->addError($error, $errorPos, 'MissingParamComment', $data);
+ }
+
+ $previousParam = $param;
+
+ }//end foreach
+
+ // Joomla modification to 2 spaces.
+ if ($spaceBeforeVar !== 2 && $spaceBeforeVar !== 10000 && $spaceBeforeComment !== 10000) {
+ $error = 'Expected 2 spaces after the longest type';
+ $this->currentFile->addError($error, $longestType, 'SpacingAfterLongType');
+ }
+
+ // Joomla modification to 2 spaces.
+ if ($spaceBeforeComment !== 2 && $spaceBeforeComment !== 10000) {
+ $error = 'Expected 2 spaces after the longest variable name';
+ $this->currentFile->addError($error, $longestVar, 'SpacingAfterLongName');
+ }
+
+ }//end if
+
+ $realNames = array();
+ foreach ($realParams as $realParam) {
+ $realNames[] = $realParam['name'];
+ }
+
+ // Report and missing comments.
+ $diff = array_diff($realNames, $foundParams);
+ foreach ($diff as $neededParam) {
+ if (count($params) !== 0) {
+ $errorPos = ($params[(count($params) - 1)]->getLine() + $commentStart);
+ } else {
+ $errorPos = $commentStart;
+ }
+
+ $error = 'Doc comment for "%s" missing';
+ $data = array($neededParam);
+ $this->currentFile->addError($error, $errorPos, 'MissingParamTag', $data);
+ }
+
+ }//end processParams()
+
+
+}//end class
+
+?>
View
147 build/phpcs/Joomla/Sniffs/Commenting/SingleCommentSniff.php
@@ -0,0 +1,147 @@
+<?php
+
+class Joomla_Sniffs_Commenting_SingleCommentSniff implements PHP_CodeSniffer_Sniff
+{
+ /**
+ * Returns the token types that this sniff is interested in.
+ *
+ * @return array(int)
+ */
+ public function register()
+ {
+ return array(T_COMMENT);
+ }
+
+ /**
+ * Processes the tokens that this sniff is interested in.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file where the token was found.
+ * @param int $stackPtr The position in the stack where
+ * the token was found.
+ *
+ * @return void
+ */
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ $tokens = $phpcsFile->getTokens();
+
+ $comment = trim($tokens[$stackPtr]['content']);
+
+ /*
+ * Hash comments are not allowed.
+ */
+
+ if (0 === strpos($comment, '#'))
+ {
+ $phpcsFile->addError('Hash comments are prohibited; found %s'
+ , $stackPtr, 'HashComment', array($comment));
+
+ return;
+ }
+
+ if(0 !== strpos($comment, '//'))
+ {
+ // Not of our concern
+
+ return;
+ }
+
+ /*
+ * Always have a space between // and the start of comment text.
+ * The exception to this is if the preceding line consists of a single open bracket.
+ */
+
+ if (isset($comment{2}) && $comment{2} != ' ')
+ {
+ $phpcsFile->addError('Please put a space between the // and the start of comment text; found "%s"'
+ , $stackPtr, 'NoSpace', array($comment));
+
+ return;
+ }
+
+ /*
+ * New lines should always start with an upper case letter unless
+ * The line is a continuation of a complete sentence
+ * The term is code and is case sensitive.(@todo)
+ */
+
+ if(isset($comment{3}) && $comment{3} != strtoupper($comment{3}))
+ {
+ // Comment does not start with an upper case letter
+
+ $previous = $phpcsFile->findPrevious(T_COMMENT, $stackPtr - 1);
+
+ if($tokens[$previous]['line'] == $tokens[$stackPtr]['line'] - 1)
+ {
+ // There is a comment on the previous line.
+ $test = trim($tokens[$previous]['content']);
+
+ if('.' != substr($test, strlen($test) - 1))
+ {
+ // If the previous comment does not end with a full stop "." we
+ // assume a sentence spanned over multiple lines.
+ return;
+ }
+ }
+
+ $phpcsFile->addError('Please start your comment with a capital letter; found "%s"'
+ , $stackPtr, 'LowerCase', array($comment));
+
+ return;
+ }
+
+ /*
+ * Comments should not be on the same line as the code to which they refer
+ * (which puts them after the code they reference).
+ * They should be on their own lines.
+ */
+
+ $previous = $phpcsFile->findPrevious(T_SEMICOLON, $stackPtr);
+
+ if($tokens[$previous]['line'] == $tokens[$stackPtr]['line'])
+ {
+ $phpcsFile->addError('Please put your comment on a separate line *preceding* your code; found "%s"'
+ , $stackPtr, 'Inline', array($comment));
+
+ return;
+ }
+
+ /*
+ * Always have a single blank line before a comment or block of comments.
+ * -- Don't allow preceding "code" - identified by a semicolon ;)
+ */
+ if($tokens[$previous]['line'] == $tokens[$stackPtr]['line'] - 1)
+ {
+ $phpcsFile->addError('Please consider a blank line preceding your comment'
+ , $stackPtr, 'TooClose');
+
+ return;
+ }
+
+ /*
+ * Comment blocks that introduce large sections of code and are more than 3 lines long
+ * should use /* * / and should use * on each line with the same space/tab rules as doc blocks.
+ * If you need a large introduction consider whether this block should be separated into a
+ * method to reduce complexity and therefore providing a full docblock.
+ */
+
+ $next = $phpcsFile->findNext(T_COMMENT, $stackPtr + 1);
+
+ if($tokens[$next]['line'] == $tokens[$stackPtr]['line'] + 1)
+ {
+ // The following line contains also a comment
+ $nextNext = $phpcsFile->findNext(T_COMMENT, $next + 1);
+
+ if($tokens[$nextNext]['line'] == $tokens[$next]['line'] + 1)
+ {
+ // Found 3 lines of // comments - too much.
+ $phpcsFile->addError('Please consider the /* */ style for comments that span over multiple lines.'
+ , $stackPtr, 'MultiLine');
+
+ return;
+ }
+ }
+
+ }//function
+
+}//class
View
106 build/phpcs/Joomla/Sniffs/ControlStructures/ControlSignatureSniff.php
@@ -0,0 +1,106 @@
+<?php
+/**
+ * Verifies that control statements conform to their coding standards.
+ *
+ * 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: ControlSignatureSniff.php 244676 2007-10-23 06:05:14Z squiz $
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+
+if (class_exists('PHP_CodeSniffer_Standards_AbstractPatternSniff', true) === false) {
+ throw new PHP_CodeSniffer_Exception('Class PHP_CodeSniffer_Standards_AbstractPatternSniff not found');
+}
+
+/**
+ * Verifies that control statements conform to their coding standards.
+ *
+ * @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.0RC2
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+class Joomla_Sniffs_ControlStructures_ControlSignatureSniff extends PHP_CodeSniffer_Standards_AbstractPatternSniff
+{
+
+ /**
+ * Constructs a Joomla_Sniffs_ControlStructures_ControlSignatureSniff.
+ */
+ public function __construct()
+ {
+ parent::__construct(true);
+
+ }//end __construct()
+
+ /**
+ * Returns the patterns that this test wishes to verify.
+ *
+ * @return array(string)
+ */
+ protected function getPatterns()
+ {
+ return array(
+ 'if (...)EOL...{...}EOL...elseEOL',
+ 'if (...)EOL...{...}EOL...elseif (...)EOL',
+ 'if (...)EOL',
+
+ 'tryEOL...{EOL...}EOL',
+ 'catch (...)EOL...{EOL',
+
+ 'doEOL...{...}EOL',
+ 'while (...)EOL...{EOL',
+
+ 'for (...)EOL...{EOL',
+ 'foreach (...)EOL...{EOL',
+
+ 'switch (...)EOL...{EOL',
+ );
+
+ }//end getPatterns()
+
+ /**
+ * Process a pattern.
+ *
+ * Returns if we are inside a "tmpl" folder - workaround for the Joomla! CMS :(
+ *
+ * @param array $patternInfo Information about the pattern used for checking, which includes are
+ * parsed token representation of the pattern.
+ * @param PHP_CodeSniffer_File $phpcsFile The PHP_CodeSniffer file where the token occured.
+ * @param integer $stackPtr The postion in the tokens stack where the listening token type was found.
+ *
+ * @return return_type
+ */
+ protected function processPattern($patternInfo, PHP_CodeSniffer_File $phpcsFile
+ , $stackPtr)
+ {
+ if(0)
+ {
+ /*
+ * @todo disabled - This is a special sniff for the Joomla! CMS to exclude
+ * the tmpl folder which may contain constructs in colon notation
+ */
+
+ $parts = explode(DIRECTORY_SEPARATOR, $phpcsFile->getFileName());
+
+ if('tmpl' == $parts[count($parts) - 2])
+ {
+ return false;
+ }
+ }
+
+ return parent::processPattern($patternInfo, $phpcsFile, $stackPtr);
+ }//function
+
+}//end class
+
+?>
View
121 build/phpcs/Joomla/Sniffs/ControlStructures/InlineControlStructureSniff.php
@@ -0,0 +1,121 @@
+<?php
+/**
+ * Joomla_Sniffs_ControlStructures_InlineControlStructureSniff.
+ *
+ * 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: InlineControlStructureSniff.php 258843 2008-05-01 00:49:32Z squiz $
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+
+/**
+ * Joomla_Sniffs_ControlStructures_InlineControlStructureSniff.
+ *
+ * Verifies that inline control statements are not present.
+ *
+ * @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.0RC2
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+class Joomla_Sniffs_ControlStructures_InlineControlStructureSniff extends Generic_Sniffs_ControlStructures_InlineControlStructureSniff
+{
+
+ /**
+ * A list of tokenizers this sniff supports.
+ *
+ * @var array
+ */
+ public $supportedTokenizers = array(
+ 'PHP',
+ 'JS',
+ );
+
+ /**
+ * If true, an error will be thrown; otherwise a warning.
+ *
+ * @var bool
+ */
+ public $error = false;
+
+
+ /**
+ * Returns an array of tokens this test wants to listen for.
+ *
+ * @return array
+ */
+ public function register()
+ {
+ return array(
+ T_IF,
+ T_ELSE,
+ T_FOREACH,
+ T_WHILE,
+ T_DO,
+ T_SWITCH,
+ T_FOR,
+ );
+
+ }//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();
+
+ if (isset($tokens[$stackPtr]['scope_opener']) === false) {
+ // Ignore the ELSE in ELSE IF. We'll process the IF part later.
+ if (($tokens[$stackPtr]['code'] === T_ELSE) && ($tokens[($stackPtr + 2)]['code'] === T_IF)) {
+ return;
+ }
+
+ if ($tokens[$stackPtr]['code'] === T_WHILE) {
+ // This could be from a DO WHILE, which doesn't have an opening brace.
+ $lastContent = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true);
+ if ($tokens[$lastContent]['code'] === T_CLOSE_CURLY_BRACKET) {
+ $brace = $tokens[$lastContent];
+ if (isset($brace['scope_condition']) === true) {
+ $condition = $tokens[$brace['scope_condition']];
+ if ($condition['code'] === T_DO) {
+ return;
+ }
+ }
+ }
+ }
+
+ // This is a control structure without an opening brace,
+ // so it is an inline statement.
+ if ($this->error === true) {
+ $phpcsFile->addError('Inline control structures are not allowed', $stackPtr, 'NotAllowed');
+ } else {
+ $phpcsFile->addWarning('Inline control structures are discouraged', $stackPtr, 'Discouraged');
+ }
+
+ return;
+ }//end if
+
+ }//end process()
+
+
+}//end class
+
+?>
View
133 build/phpcs/Joomla/Sniffs/ControlStructures/MultiLineConditionSniff.php
@@ -0,0 +1,133 @@
+<?php
+/**
+ * Joomla_Sniffs_ControlStructures_MultiLineConditionSniff.
+ *
+ * PHP version 5
+ *
+ * @category PHP
+ * @package PHP_CodeSniffer
+ * @author Greg Sherwood <gsherwood@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: MultiLineConditionSniff.php 289839 2009-10-21 23:11:33Z squiz $
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+
+/**
+ * Joomla_Sniffs_ControlStructures_MultiLineConditionSniff.
+ *
+ * Ensure multi-line IF conditions are defined correctly.
+ *
+ * @category PHP
+ * @package PHP_CodeSniffer
+ * @author Greg Sherwood <gsherwood@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.0RC2
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+class Joomla_Sniffs_ControlStructures_MultiLineConditionSniff implements PHP_CodeSniffer_Sniff
+{
+
+ /**
+ * Returns an array of tokens this test wants to listen for.
+ *
+ * @return array
+ */
+ public function register()
+ {
+ return array(T_IF);
+
+ }//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();
+
+ // We need to work out how far indented the if statement
+ // itself is, so we can work out how far to indent conditions.
+ $statementIndent = 0;
+ for ($i = ($stackPtr - 1); $i >= 0; $i--) {
+ if ($tokens[$i]['line'] !== $tokens[$stackPtr]['line']) {
+ $i++;
+ break;
+ }
+ }
+
+ if ($i >= 0 && $tokens[$i]['code'] === T_WHITESPACE) {
+ $statementIndent = strlen($tokens[$i]['content']);
+ }
+
+ // Each line between the parenthesis should be indented 4 spaces
+ // and start with an operator, unless the line is inside a
+ // 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++) {
+ if ($tokens[$i]['line'] !== $lastLine) {
+ if ($tokens[$i]['line'] === $tokens[$closeBracket]['line']) {
+ $next = $phpcsFile->findNext(T_WHITESPACE, $i, null, true);
+ 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;
+ }
+ }
+
+ $expectedIndent = ($statementIndent + 1);
+
+ // We changed lines, so this should be a whitespace indent token.
+ if ($tokens[$i]['code'] !== T_WHITESPACE) {
+ $foundIndent = 0;
+ } else {
+ $foundIndent = strlen($tokens[$i]['content']);
+ }
+
+ if ($expectedIndent !== $foundIndent) {
+ $error = 'Multi-line IF statement not indented correctly; expected %s spaces but found %s';
+ $data = array(
+ $expectedIndent,
+ $foundIndent,
+ );
+ $phpcsFile->addError($error, $i, 'Alignment', $data);
+ }
+
+ $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'];
+ }//end if
+
+ if ($tokens[$i]['code'] === T_STRING) {
+ $next = $phpcsFile->findNext(T_WHITESPACE, ($i + 1), null, true);
+ if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS) {
+ // This is a function call, so skip to the end as they
+ // have their own indentation rules.
+ $i = $tokens[$next]['parenthesis_closer'];
+ $lastLine = $tokens[$i]['line'];
+ continue;
+ }
+ }
+ }//end for
+
+ }//end process()
+
+}//end class
+
+?>
View
99 build/phpcs/Joomla/Sniffs/WhiteSpace/ConcatenationSpacingSniff.php
@@ -0,0 +1,99 @@
+<?php
+/**
+ * Squiz_Sniffs_Strings_ConcatenationSpacingSniff.
+ *
+ * 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: ConcatenationSpacingSniff.php 151 2010-11-26 01:07:46Z elkuku $
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+
+/**
+ * Makes sure there are is a spaces between the concatenation operator <b>.</b> and the strings being concatenated.
+ *
+ * Example:
+ * <b class="bad">$a = $b.$c;</b>
+ * <b class="good">$a = $b . $c;</b>
+ *
+ * @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.0RC1
+ * @link http://pear.php.net/package/PHP_CodeSniffer
+ */
+class Joomla_Sniffs_WhiteSpace_ConcatenationSpacingSniff implements PHP_CodeSniffer_Sniff
+{
+ /**
+ * Returns an array of tokens this test wants to listen for.
+ *
+ * @return array
+ */
+ public function register()
+ {
+ return array(T_STRING_CONCAT);
+ }//function
+
+ /**
+ * Processes this test, when one of its tokens is encountered.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param integer $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();
+
+ if($tokens[($stackPtr + 1)]['code'] != T_WHITESPACE)
+ {
+ // space after
+ $message = 'Concat operator must be followed by one space';
+ $phpcsFile->addError($message, $stackPtr, 'Missing');
+ }
+ else
+ {
+ $found = strlen($tokens[($stackPtr + 1)]['content']);
+
+ if($found > 1)
+ {
+ $error = sprintf('Expected 1 space after concat operator; %s found', $found);
+ $phpcsFile->addError($error, $stackPtr, 'Too much');
+ }
+ }
+
+ if($tokens[($stackPtr - 1)]['code'] != T_WHITESPACE)
+ {
+ // space before
+ $message = 'Concat operator must be preceeded by one space';
+ $phpcsFile->addError($message, $stackPtr, 'Missing');
+ }
+ else
+ {
+ if(strpos($tokens[($stackPtr - 2)]['content'], $phpcsFile->eolChar) !== false
+ || strpos($tokens[($stackPtr - 1)]['content'], $phpcsFile->eolChar) !== false)
+ {
+ // the dot is on a new line
+ return;
+ }
+
+ $found = strlen($tokens[($stackPtr - 1)]['content']);
+
+ if($found > 1)
+ {
+ $error = sprintf('Expected 1 space before concat operator; %s found', $found);
+ $phpcsFile->addError($error, $stackPtr, 'Too much');
+ }
+ }
+ }//function
+}//class
View
137 build/phpcs/Joomla/ruleset.xml
@@ -40,6 +40,18 @@
<rule ref="PEAR.Commenting.InlineComment"/>
<rule ref="Generic.Files.LineEndings"/>
+ <rule ref="Generic.Files.LineLength">
+ <!-- We only want this for cli for now -->
+ <exclude-pattern>/administrator/*</exclude-pattern>
+ <exclude-pattern>/components/*</exclude-pattern>
+ <exclude-pattern>/plugins/*</exclude-pattern>
+ <exclude-pattern>/modules/*</exclude-pattern>
+ <exclude-pattern>/libraries/*</exclude-pattern>
+ <exclude-pattern>/installation/*</exclude-pattern>
+ <exclude-pattern>/templates/*</exclude-pattern>
+ <exclude-pattern>/language/*</exclude-pattern>
+ <exclude-pattern>/includes/*</exclude-pattern>
+ </rule>
<rule ref="Zend.Files.ClosingTag">
<exclude-pattern>*/tmpl/*</exclude-pattern>
<exclude-pattern>/templates/*</exclude-pattern>
@@ -53,9 +65,20 @@
<rule ref="PEAR.Formatting.MultiLineAssignment"/>
<rule ref="Generic.Functions.FunctionCallArgumentSpacing"/>
+ <rule ref="PEAR.Functions.ValidDefaultValue">
+ <!-- We only want this for cli, includes and joomla-platform for now -->
+ <exclude-pattern>/administrator/*</exclude-pattern>
+ <exclude-pattern>/components/*</exclude-pattern>
+ <exclude-pattern>/plugins/*</exclude-pattern>
+ <exclude-pattern>/modules/*</exclude-pattern>
+ <exclude-pattern>/installation/*</exclude-pattern>
+ <exclude-pattern>/libraries/cms/*</exclude-pattern>
+ <exclude-pattern>/templates/*</exclude-pattern>
+ <exclude-pattern>/language/*</exclude-pattern>
+ </rule>
<rule ref="PEAR.NamingConventions.ValidClassName">
- <!-- We only want this for libraries and cli for now -->
+ <!-- We only want this for libraries, cli and includes for now -->
<exclude-pattern>/administrator/*</exclude-pattern>
<exclude-pattern>/components/*</exclude-pattern>
<exclude-pattern>/plugins/*</exclude-pattern>
@@ -70,8 +93,27 @@
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
+ <rule ref="Squiz.Operators.IncrementDecrementUsage">
+ <!-- We only want this for libraries, cli and includes for now -->
+ <exclude-pattern>/administrator/*</exclude-pattern>
+ <exclude-pattern>/components/*</exclude-pattern>
+ <exclude-pattern>/plugins/*</exclude-pattern>
+ <exclude-pattern>/modules/*</exclude-pattern>
+ <exclude-pattern>/installation/*</exclude-pattern>
+ <exclude-pattern>/templates/*</exclude-pattern>
+ <exclude-pattern>/language/*</exclude-pattern>
+ </rule>
+
<rule ref="Squiz.Scope.StaticThisUsage"/>
+ <!-- Lines can be 85 chars long, but never show errors -->
+ <rule ref="Generic.Files.LineLength">
+ <properties>
+ <property name="lineLimit" value="150"/>
+ <property name="absoluteLineLimit" value="0"/>
+ </properties>
+ </rule>
+
<!-- Use Unix newlines -->
<rule ref="Generic.Files.LineEndings">
<properties>
@@ -84,4 +126,97 @@
<severity>0</severity>
</rule>
+ <!-- Remove the following when the folder limitations are dropped -->
+
+ <rule ref="Joomla.Classes.MethodScope">
+ <!-- We only want this for libraries and cli for now -->
+ <exclude-pattern>/administrator/*</exclude-pattern>
+ <exclude-pattern>/components/*</exclude-pattern>
+ <exclude-pattern>/plugins/*</exclude-pattern>
+ <exclude-pattern>/modules/*</exclude-pattern>
+ <exclude-pattern>/installation/*</exclude-pattern>
+ <exclude-pattern>/templates/*</exclude-pattern>
+ <exclude-pattern>/language/*</exclude-pattern>
+ <exclude-pattern>/includes/*</exclude-pattern>
+ </rule>
+
+ <rule ref="Joomla.Commenting.FunctionComment">
+ <!-- We only want this for libraries and cli for now -->
+ <exclude-pattern>/administrator/*</exclude-pattern>
+ <exclude-pattern>/components/*</exclude-pattern>
+ <exclude-pattern>/plugins/*</exclude-pattern>
+ <exclude-pattern>/modules/*</exclude-pattern>
+ <exclude-pattern>/installation/*</exclude-pattern>
+ <exclude-pattern>/templates/*</exclude-pattern>
+ <exclude-pattern>/language/*</exclude-pattern>
+ <exclude-pattern>/includes/*</exclude-pattern>
+ </rule>
+
+ <rule ref="Joomla.Commenting.SingleComment">
+ <!-- We only want this for libraries and cli for now -->
+ <exclude-pattern>/administrator/*</exclude-pattern>
+ <exclude-pattern>/components/*</exclude-pattern>
+ <exclude-pattern>/plugins/*</exclude-pattern>
+ <exclude-pattern>/modules/*</exclude-pattern>
+ <exclude-pattern>/installation/*</exclude-pattern>
+ <exclude-pattern>/templates/*</exclude-pattern>
+ <exclude-pattern>/language/*</exclude-pattern>
+ <exclude-pattern>/includes/*</exclude-pattern>
+ </rule>
+
+ <rule ref="Joomla.Commenting.ClassComment">
+ <!-- We exclude components and modules for now -->
+ <exclude-pattern>/administrator/components/*</exclude-pattern>
+ <exclude-pattern>/administrator/modules/*</exclude-pattern>
+ <exclude-pattern>/components/*</exclude-pattern>
+ <exclude-pattern>/modules/*</exclude-pattern>
+ </rule>
+
+ <rule ref="Joomla.WhiteSpace.ConcatenationSpacing">
+ <!-- We only want this for libraries and cli for now -->
+ <exclude-pattern>/administrator/*</exclude-pattern>
+ <exclude-pattern>/components/*</exclude-pattern>
+ <exclude-pattern>/plugins/*</exclude-pattern>
+ <exclude-pattern>/modules/*</exclude-pattern>
+ <exclude-pattern>/installation/*</exclude-pattern>
+ <exclude-pattern>/templates/*</exclude-pattern>
+ <exclude-pattern>/language/*</exclude-pattern>
+ <exclude-pattern>/includes/*</exclude-pattern>
+ </rule>
+
+ <rule ref="Joomla.ControlStructures.ControlSignature">
+ <!-- We only want this for libraries and cli for now -->
+ <exclude-pattern>/administrator/*</exclude-pattern>
+ <exclude-pattern>/components/*</exclude-pattern>
+ <exclude-pattern>/plugins/*</exclude-pattern>
+ <exclude-pattern>/modules/*</exclude-pattern>
+ <exclude-pattern>/installation/*</exclude-pattern>
+ <exclude-pattern>/templates/*</exclude-pattern>
+ <exclude-pattern>/language/*</exclude-pattern>
+ <exclude-pattern>/includes/*</exclude-pattern>
+ </rule>
+
+ <rule ref="Joomla.ControlStructures.InlineControlStructure">
+ <!-- We only want this for cli and libraries for now -->
+ <exclude-pattern>/administrator/*</exclude-pattern>
+ <exclude-pattern>/components/*</exclude-pattern>
+ <exclude-pattern>/plugins/*</exclude-pattern>
+ <exclude-pattern>/modules/*</exclude-pattern>
+ <exclude-pattern>/installation/*</exclude-pattern>
+ <exclude-pattern>/templates/*</exclude-pattern>
+ <exclude-pattern>/language/*</exclude-pattern>
+ </rule>
+
+ <rule ref="Joomla.ControlStructures.MultiLineCondition">
+ <!-- We only want this for libraries and cli for now -->
+ <exclude-pattern>/administrator/*</exclude-pattern>
+ <exclude-pattern>/components/*</exclude-pattern>
+ <exclude-pattern>/plugins/*</exclude-pattern>
+ <exclude-pattern>/modules/*</exclude-pattern>
+ <exclude-pattern>/installation/*</exclude-pattern>
+ <exclude-pattern>/templates/*</exclude-pattern>
+ <exclude-pattern>/language/*</exclude-pattern>
+ <exclude-pattern>/includes/*</exclude-pattern>
+ </rule>
+
</ruleset>
View
4 cli/finder_indexer.php
@@ -105,13 +105,11 @@ public function doExecute()
*/
private function _index()
{
- // initialize the time value
$this->_time = microtime(true);
- // import library dependencies
require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/indexer.php';
- // fool the system into thinking we are running as JSite with Finder as the active component
+ // Fool the system into thinking we are running as JSite with Finder as the active component
JFactory::getApplication('site');
$_SERVER['HTTP_HOST'] = 'domain.com';
define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/com_finder');
View
10 index.php
@@ -9,16 +9,18 @@
// Set flag that this is a parent file.
const _JEXEC = 1;
-if (file_exists(__DIR__ . '/defines.php')) {
+if (file_exists(__DIR__ . '/defines.php'))
+{
include_once __DIR__ . '/defines.php';
}
-if (!defined('_JDEFINES')) {
+if (!defined('_JDEFINES'))
+{
define('JPATH_BASE', __DIR__);
- require_once JPATH_BASE.'/includes/defines.php';
+ require_once JPATH_BASE . '/includes/defines.php';
}
-require_once JPATH_BASE.'/includes/framework.php';
+require_once JPATH_BASE . '/includes/framework.php';
// Mark afterLoad in the profiler.
JDEBUG ? $_PROFILER->mark('afterLoad') : null;
View
6 libraries/cms.php
@@ -9,7 +9,8 @@
defined('_JEXEC') or die;
// Set the platform root path as a constant if necessary.
-if (!defined('JPATH_PLATFORM')) {
+if (!defined('JPATH_PLATFORM'))
+{
define('JPATH_PLATFORM', __DIR__);
}
@@ -28,7 +29,8 @@ class_exists('JLoader') or die;
set_exception_handler(array('JErrorPage', 'render'));
// Define the Joomla version if not already defined.
-if (!defined('JVERSION')) {
+if (!defined('JVERSION'))
+{
$jversion = new JVersion;
define('JVERSION', $jversion->getShortVersion());
}
View
1  libraries/cms/feed/factory.php
@@ -73,6 +73,7 @@ public function getFeed($uri)
{
// @codeCoverageIgnoreStart
throw new RuntimeException('Unable to open the feed.');
+
// @codeCoverageIgnoreEnd
}
View
2  libraries/cms/feed/parser.php
@@ -208,6 +208,7 @@ protected function expandToSimpleXml()
{
// @codeCoverageIgnoreStart
throw new RuntimeException('Unable to expand node to SimpleXML element.');
+
// @codeCoverageIgnoreEnd
}
@@ -303,6 +304,7 @@ protected function moveToClosingElement()
// @codeCoverageIgnoreStart
throw new RuntimeException('Unable to find the closing XML node.');
+
// @codeCoverageIgnoreEnd
}
}
View
4 libraries/cms/form/field/captcha.php
@@ -42,7 +42,9 @@ public function setup(SimpleXMLElement $element, $value, $group = null)
{
$result = parent::setup($element, $value, $group);
- $plugin = $this->element['plugin'] ? (string) $this->element['plugin'] : JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha'));
+ $plugin = $this->element['plugin'] ?
+ (string) $this->element['plugin'] :
+ JFactory::getApplication()->getParams()->get('captcha', JFactory::getConfig()->get('captcha'));
if ($plugin === 0 || $plugin === '0' || $plugin === '' || $plugin === null)
{
$this->hidden = true;
View
4 libraries/cms/html/bootstrap.php
@@ -28,7 +28,7 @@
* Add javascript support for Bootstrap alerts
*
* @param string $selector Common class for the alerts
-
+ *
* @return void
*
* @since 3.0
@@ -103,7 +103,7 @@ public static function carousel($selector = 'carousel', $params = array())
* Add javascript support for Bootstrap dropdowns
*
* @param string $selector Common class for the dropdowns
-
+ *
* @return void
*
* @since 3.0
View
2  libraries/cms/html/icons.php
@@ -79,7 +79,7 @@ public static function button($button)
$html[] = (empty($button['onclick']) ? '' : (' onclick="' . $button['onclick'] . '"'));
$html[] = (empty($button['title']) ? '' : (' title="' . htmlspecialchars($button['title']) . '"'));
$html[] = '>';
- $html[] = '<i class="icon-'.$button['image'].'"></i> ';
+ $html[] = '<i class="icon-' . $button['image'] . '"></i> ';
$html[] = (empty($button['text'])) ? '' : ('<span>' . $button['text'] . '</span>');
$html[] = '</a>';
$html[] = '</div>';
View
2  libraries/cms/html/sortablelist.php
@@ -56,7 +56,7 @@ public static function sortable($tableId, $formId, $sortDir = 'asc', $saveOrderi
JFactory::getDocument()->addScriptDeclaration("
(function ($){
$(document).ready(function (){
- var sortableList = new $.JSortableList('#" . $tableId . " tbody','" . $formId . "','" . $sortDir . "' , '" . $saveOrderingUrl . "','','".$nestedList."');
+ var sortableList = new $.JSortableList('#" . $tableId . " tbody','" . $formId . "','" . $sortDir . "' , '" . $saveOrderingUrl . "','','" . $nestedList . "');
});
})(jQuery);
"
View
56 libraries/cms/schema/changeitempostgresql.php
@@ -19,7 +19,6 @@
class JSchemaChangeitempostgresql extends JSchemaChangeitem
{
/**
- *
* Checks a DDL query to see if it is a known type
* If yes, build a check query to see if the DDL has been run on the database.
* If successful, the $msgElements, $queryType, $checkStatus and $checkQuery fields are populated.
@@ -42,23 +41,24 @@ protected function buildCheckQuery()
$this->checkStatus = -1; // change status to skipped
$result = null;
- // remove any newlines
+ // Remove any newlines
$this->updateQuery = str_replace("\n", '', $this->updateQuery);
- // fix up extra spaces around () and in general
+ // Fix up extra spaces around () and in general
$find = array('#((\s*)\(\s*([^)\s]+)\s*)(\))#', '#(\s)(\s*)#');
$replace = array('($3)', '$1');
$updateQuery = preg_replace($find, $replace, $this->updateQuery);
$wordArray = explode(' ', $updateQuery);
- // first, make sure we have an array of at least 6 elements
+ // First, make sure we have an array of at least 6 elements
// if not, we can't make a check query for this one
if (count($wordArray) < 6)
{
- return; // done with method
+ // Done with method
+ return;
}
- // we can only make check queries for alter table and create table queries
+ // We can only make check queries for alter table and create table queries
$command = strtoupper($wordArray[0] . ' ' . $wordArray[1]);
if ($command === 'ALTER TABLE')
{
@@ -76,17 +76,17 @@ protected function buildCheckQuery()
if (strtoupper($wordArray[6]) == 'TYPE')
{
$type = '';
- for($i = 7; $i < count($wordArray); $i++)
+ for ($i = 7; $i < count($wordArray); $i++)
{
$type .= $wordArray[$i] . ' ';
}
- if($pos = strpos($type, '('))
+ if ($pos = strpos($type, '('))
{
$type = substr($type, 0, $pos);
}
- if($pos = strpos($type, ';'))
+ if ($pos = strpos($type, ';'))
{
$type = substr($type, 0, $pos);
}
@@ -100,12 +100,14 @@ protected function buildCheckQuery()
}
elseif(strtoupper($wordArray[7] . ' ' . $wordArray[8]) == 'NOT NULL')
{
- if ( strtoupper($wordArray[6]) == 'SET' ) //SET NOT NULL
+ if ( strtoupper($wordArray[6]) == 'SET' )
{
+ // SET NOT NULL
$isNullable = $this->fixQuote('NO');
}
- else //DROP NOT NULL
+ else
{
+ // DROP NOT NULL
$isNullable = $this->fixQuote('YES');
}
$result = 'SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name=' .
@@ -122,8 +124,9 @@ protected function buildCheckQuery()
{
$isNullDef = 'IS NOT NULL';
}
- else //DROP DEFAULT
+ else
{
+ // DROP DEFAULT
$isNullDef = 'IS NULL';
}
$result = 'SELECT column_name, data_type, column_default FROM information_schema.columns WHERE table_name=' .
@@ -138,7 +141,7 @@ protected function buildCheckQuery()
}
elseif ($command === 'DROP INDEX')
{
- if (strtoupper($wordArray[2].$wordArray[3]) == 'IFEXISTS')
+ if (strtoupper($wordArray[2] . $wordArray[3]) == 'IFEXISTS')
{
$idx = $this->fixQuote($wordArray[4]);
}
@@ -173,7 +176,7 @@ protected function buildCheckQuery()
if ($command == 'CREATE TABLE')
{
- if (strtoupper($wordArray[2].$wordArray[3].$wordArray[4]) == 'IFNOTEXISTS')
+ if (strtoupper($wordArray[2] . $wordArray[3] . $wordArray[4]) == 'IFNOTEXISTS')
{
$table = $this->fixQuote($wordArray[5]);
}
@@ -187,12 +190,16 @@ protected function buildCheckQuery()
$this->msgElements = array($table);
}
- // set fields based on results
- if ($this->checkQuery = $result) {
- $this->checkStatus = 0; // unchecked status
+ // Set fields based on results
+ if ($this->checkQuery = $result)
+ {
+ // Unchecked status
+ $this->checkStatus = 0;
}
- else {
- $this->checkStatus = -1; // skipped
+ else
+ {
+ // Skipped
+ $this->checkStatus = -1;
}
}
@@ -201,12 +208,12 @@ protected function buildCheckQuery()
* If you change a column to "integer unsigned" it shows
* as "int(10) unsigned" in the check query.
*
- * @param string $type1 the column type
- * @param string $type2 the column attributes
+ * @param string $type1 the column type
+ * @param string $type2 the column attributes
*
- * @return string The original or changed column type.
+ * @return string The original or changed column type.
*
- * @since 3.0
+ * @since 3.0
*/
private function fixInteger($type1, $type2)
{
@@ -219,12 +226,12 @@ private function fixInteger($type1, $type2)
}
/**
- *
* Fixes up a string for inclusion in a query.
* Replaces name quote character with normal quote for literal.
* Drops trailing semi-colon. Injects the database prefix.
*
* @param string $string The input string to be cleaned up.
+ *
* @return string The modified string.
*
* @since 3.0
@@ -236,5 +243,4 @@ private function fixQuote($string)
$string = str_replace('#__', $this->db->getPrefix(), $string);
return $this->db->quote($string);
}
-
}
View
1  libraries/cms/toolbar/button/help.php
@@ -80,6 +80,7 @@ public function fetchId()
protected function _getCommand($ref, $com, $override, $component)
{
JHtml::_('behavior.framework');
+
// Get Help URL
$url = JHelp::createURL($ref, $com, $override, $component);
$url = htmlspecialchars($url, ENT_QUOTES);
View
4 libraries/cms/toolbar/button/popup.php
@@ -104,9 +104,9 @@ public function fetchId($type, $name)
/**
* Get the JavaScript command for the button
*
- * @param string $url URL for popup
+ * @param string $url URL for popup
*
- * @return string JavaScript command string
+ * @return string JavaScript command string
*
* @since 3.0
*/
View
2  libraries/cms/toolbar/button/slider.php
@@ -77,7 +77,7 @@ public function fetchId($type, $name)
/**
* Get the JavaScript command for the button
*
- * @param string $url URL for popup
+ * @param string $url URL for popup
*
* @return string JavaScript command string
*
View
2  libraries/cms/toolbar/button/standard.php
@@ -55,7 +55,7 @@ public function fetchButton($type = 'Standard', $name = '', $text = '', $task =
$iconWhite = "";
}
- $html = "<button href=\"#\" onclick=\"$doTask\" class=\"".$btnClass."\">\n";
+ $html = "<button href=\"#\" onclick=\"$doTask\" class=\"" . $btnClass . "\">\n";
$html .= "<i class=\"$class $iconWhite\">\n";
$html .= "</i>\n";
$html .= "$i18n_text\n";
View
4 libraries/joomla/form/fields/rules.php
@@ -119,7 +119,7 @@ protected function getInput()
}
$html[] = '<li class="' . $active . '">';
- $html[] = '<a href="#permission-'. $group->value .'" data-toggle="tab">';
+ $html[] = '<a href="#permission-' . $group->value . '" data-toggle="tab">';
$html[] = str_repeat('<span class="level">&ndash;</i> ', $curLevel = $group->level) . $group->text;
$html[] = '</a>';
$html[] = '</li>';
@@ -140,7 +140,7 @@ protected function getInput()
$difLevel = $group->level - $curLevel;
- $html[] = '<div class="tab-pane' . $active . '" id="permission-' . $group->value .'">';
+ $html[] = '<div class="tab-pane' . $active . '" id="permission-' . $group->value . '">';
$html[] = '<table class="table table-striped">';
$html[] = '<thead>';
$html[] = '<tr>';
View
4 libraries/joomla/html/grid.php
@@ -90,12 +90,12 @@ public static function sort($title, $order, $direction = 'asc', $selected = 0, $
}
$html = '<a href="#" onclick="Joomla.tableOrdering(\'' . $order . '\',\'' . $direction . '\',\'' . $task . '\');"'
- . ' class="hasTip" title="' . JText::_($tip ? $tip : $title) . '::' . JText::_('JGLOBAL_CLICK_TO_SORT_THIS_COLUMN') . '">';
+ . ' class="hasTip" title="' . JText::_($tip ? $tip : $title) . '::' . JText::_('JGLOBAL_CLICK_TO_SORT_THIS_COLUMN') . '">';
$html .= JText::_($title);
if ($order == $selected)
{
- $html .= ' <i class="icon-'.$icon[$index].'"></i>';
+ $html .= ' <i class="icon-' . $icon[$index] . '"></i>';
}
$html .= '</a>';
View
4 libraries/joomla/session/storage/database.php
@@ -45,7 +45,7 @@ public function read($id)
$result = (string) $db->loadResult();
- $result = str_replace('\0\0\0', chr(0).'*'.chr(0), $result);
+ $result = str_replace('\0\0\0', chr(0) . '*' . chr(0), $result);
return $result;
}
@@ -70,7 +70,7 @@ public function write($id, $data)
// Get the database connection object and verify its connected.
$db = JFactory::getDbo();
- $data = str_replace(chr(0).'*'.chr(0), '\0\0\0', $data);
+ $data = str_replace(chr(0) . '*' . chr(0), '\0\0\0', $data);
try
{
View
2  libraries/joomla/table/table.php
@@ -577,7 +577,7 @@ public function store($updateNulls = false)
$currentAssetId = $this->asset_id;
}
- if(0 == $this->$k)
+ if (0 == $this->$k)
{
$this->$k = null;
}
Please sign in to comment.
Something went wrong with that request. Please try again.