Permalink
Browse files

Merge pull request #571 from elkuku/sniff-concatenation

Code style: Sniff concatenation
  • Loading branch information...
2 parents e1c10e1 + fe7dc31 commit df402899e071fd93b5134b91d7ce39706ea17aac @eddieajau eddieajau committed Dec 2, 2011
@@ -55,9 +55,30 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
- if($tokens[($stackPtr - 1)]['code'] != T_WHITESPACE
- || $tokens[($stackPtr + 1)]['code'] != T_WHITESPACE
- )
+ 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)
@@ -66,8 +87,13 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
return;
}
- $message = 'Concat operator must be surrounded by spaces';
- $phpcsFile->addError($message, $stackPtr, 'Missing');
+ $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
@@ -419,14 +419,14 @@ public function redirect($url, $msg = '', $msgType = 'message', $moved = false)
{
// MSIE type browser and/or server cause issues when url contains utf8 character,so use a javascript redirect method
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=' . $document->getCharset() . '" />'
- .'<script>document.location.href=\'' . htmlspecialchars($url) . '\';</script></head></html>';
+ . '<script>document.location.href=\'' . htmlspecialchars($url) . '\';</script></head></html>';
}
elseif (!$moved and $navigator->isBrowser('konqueror'))
{
// WebKit browser (identified as konqueror by Joomla!) - Do not use 303, as it causes subresources
// reload (https://bugs.webkit.org/show_bug.cgi?id=38690)
echo '<html><head><meta http-equiv="content-type" content="text/html; charset=' . $document->getCharset() . '" />'
- .'<meta http-equiv="refresh" content="0; url=' . htmlspecialchars($url) . '" /></head></html>';
+ . '<meta http-equiv="refresh" content="0; url=' . htmlspecialchars($url) . '" /></head></html>';
}
else
{
@@ -81,7 +81,7 @@ public static function language()
// Create the batch selector to change an access level on a selection list.
$lines = array(
'<label id="batch-language-lbl" for="batch-language" class="hasTip"'
- .' title="' . JText::_('JLIB_HTML_BATCH_LANGUAGE_LABEL') . '::' . JText::_('JLIB_HTML_BATCH_LANGUAGE_LABEL_DESC') . '">',
+ . ' title="' . JText::_('JLIB_HTML_BATCH_LANGUAGE_LABEL') . '::' . JText::_('JLIB_HTML_BATCH_LANGUAGE_LABEL_DESC') . '">',
JText::_('JLIB_HTML_BATCH_LANGUAGE_LABEL'),
'</label>',
'<select name="batch[language_id]" class="inputbox" id="batch-language-id">',

0 comments on commit df40289

Please sign in to comment.