Skip to content

Commit

Permalink
Merge pull request #21 from bmitch/Issue#13
Browse files Browse the repository at this point in the history
Fixes #13
  • Loading branch information
bmitch authored Dec 4, 2016
2 parents 4fb7ec5 + 2676f7d commit a3d40e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ script:
- vendor/bin/phpcs --standard=psr2 src
- vendor/bin/phpcs --standard=phpcs.xml src
- vendor/bin/phpcs --standard=phpcs.xml tests --ignore=tests/Sniffs
- vendor/bin/phpcs --standard=src/Codor/ruleset.xml src
- vendor/bin/phpunit --debug --coverage-clover=coverage.xml
- vendor/bin/phpmd src text codesize,unusedcode,naming
- vendor/bin/phploc src --progress
Expand Down
13 changes: 5 additions & 8 deletions src/Codor/Sniffs/Files/FunctionParameterSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ public function register()
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];

$openParenIndex = $token['parenthesis_opener'];
$tokens = $phpcsFile->getTokens();
$token = $tokens[$stackPtr];
$openParenIndex = $token['parenthesis_opener'];
$closedParenIndex = $token['parenthesis_closer'];

$numberOfParameters = 0;
Expand All @@ -47,13 +46,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
}

if ($numberOfParameters > $this->maxParameters) {
$error = "Function has more than {$this->maxParameters} parameters. Please reduce.";
$phpcsFile->addError($error, $stackPtr);
$phpcsFile->addError("Function has more than {$this->maxParameters} parameters. Please reduce.", $stackPtr);
}

if ($numberOfParameters == $this->maxParameters) {
$warning = "Function has {$this->maxParameters} parameters. Please reduce if possible.";
$phpcsFile->addWarning($warning, $stackPtr);
$phpcsFile->addWarning("Function has {$this->maxParameters} parameters.", $stackPtr);
}
}
}

0 comments on commit a3d40e0

Please sign in to comment.