Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Hotelsnl/standards
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/Hotelsnl/standards:
  nice end function check
  loose elseif
  multiline array more flexible
  to restrictive
  undo
  undo
  remove array restriction
  doxygen comments
  Update README.md
  • Loading branch information
doenietzomoeilijk committed May 3, 2012
2 parents dadd2eb + 213d5e2 commit fd169eb
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 468 deletions.
25 changes: 0 additions & 25 deletions Hotelsnl/Sniffs/Arrays/ArrayDeclarationSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,6 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
if ($valueCount > 0) {
$conditionCheck = $phpcsFile->findPrevious(array(T_OPEN_PARENTHESIS, T_SEMICOLON), ($stackPtr - 1), null, false);

if (($conditionCheck === false) || ($tokens[$conditionCheck]['line'] !== $tokens[$stackPtr]['line'])) {
$error = 'Array with multiple values cannot be declared on a single line';
$phpcsFile->addError($error, $stackPtr, 'SingleLineNotAllowed');
return;
}

// We have a multiple value array that is inside a condition or
// function. Check its spacing is correct.
foreach ($commas as $comma) {
Expand Down Expand Up @@ -194,16 +188,6 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
if ($tokens[$lastContent]['line'] !== ($tokens[$arrayEnd]['line'] - 1)) {
$error = 'Closing parenthesis of array declaration must be on a new line';
$phpcsFile->addError($error, $arrayEnd, 'CloseBraceNewLine');
} else if ($tokens[$arrayEnd]['column'] !== $tokens[$stackPtr]['level'] * 2 + 1 && $tokens[$stackPtr]['level'] === 1) {
// Check the closing bracket is lined up under the a in array.
$expected = $tokens[$stackPtr]['level'] * 2;
$found = $tokens[$arrayEnd]['column'] - 1;
$error = 'Closing parenthesis not aligned correctly; expected %s space(s) but found %s';
$data = array(
$expected,
$found,
);
$phpcsFile->addError($error, $arrayEnd, 'CloseBraceNotAligned', $data);
}

$nextToken = $stackPtr;
Expand Down Expand Up @@ -421,15 +405,6 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$phpcsFile->addError($error, $stackPtr, 'FirstIndexNoNewline');
continue;
}
if (($tokens[$index['index']]['column']) !== $indicesStart && $tokens[$stackPtr]['level'] === 1) {
$error = 'Array key not aligned correctly; expected %s spaces but found %s';
$data = array(
$indicesStart - 1,
$tokens[$index['index']]['column'] - 1,
);
$phpcsFile->addError($error, $index['index'], 'KeyNotAligned', $data);
continue;
}

// Check each line ends in a comma.
if ($tokens[$index['value']]['code'] !== T_ARRAY) {
Expand Down
2 changes: 1 addition & 1 deletion Hotelsnl/Sniffs/Commenting/FileCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ protected function processTags($commentStart, $commentEnd)
$tags = array(
'package' => 'precedes @subpackage',
'subpackage' => 'follows @package',
'copyright' => 'follows @author',
'copyright' => 'follows @subpackage',
);

$foundTags = $this->commentParser->getTagOrders();
Expand Down
4 changes: 2 additions & 2 deletions Hotelsnl/Sniffs/Commenting/FunctionCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,8 @@ protected function processSees($commentStart)
}

$spacing = substr_count($see->getWhitespaceBeforeContent(), ' ');
if ($spacing !== 4) {
$error = '@see tag indented incorrectly; expected 4 spaces but found %s';
if ($spacing !== 1) {
$error = '@see tag indented incorrectly; expected 1 space but found %s';
$data = array($spacing);
$this->currentFile->addError($error, $errorPos, 'SeeIndent', $data);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ class Hotelsnl_Sniffs_Commenting_LongConditionClosingCommentSniff implements PHP
*/
protected $lineLimit = 20;

protected $lastFoundLine = 0;


/**
* Returns an array of tokens this test wants to listen for.
Expand Down Expand Up @@ -79,8 +81,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)

$expected = '<?php';
$comment = $phpcsFile->findNext(array(T_COMMENT), $stackPtr, null, false);

if (trim($tokens[$comment]['content']) !== $expected && $tokens[$comment]['level'] === 1) {
if (trim($tokens[$comment]['content']) !== $expected && $tokens[$comment]['level'] === 1 && $tokens[$comment]['line'] === $this->lastFoundLine && $tokens[$stackPtr]['line'] === $tokens[$comment]['line']) {
$found = trim($tokens[$comment]['content']);
$error = 'Do not use closing comments!';
$data = array(
Expand All @@ -90,7 +91,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
$phpcsFile->addError($error, $stackPtr, 'Invalid', $data);
return;
}

$this->lastFoundLine = $tokens[$comment]['line'];
}//end process()


Expand Down
2 changes: 1 addition & 1 deletion Hotelsnl/Sniffs/Commenting/VariableCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,4 @@ protected function processVariableInString(PHP_CodeSniffer_File $phpcsFile, $sta


}//end class
?>
?>
67 changes: 0 additions & 67 deletions Hotelsnl/Sniffs/ControlStructures/ElseIfDeclarationSniff.php

This file was deleted.

Loading

0 comments on commit fd169eb

Please sign in to comment.