Skip to content

Commit

Permalink
FunctionComment sniffs now throw errors for some invalid @param line …
Browse files Browse the repository at this point in the history
  • Loading branch information
photodude committed Mar 7, 2017
1 parent 13524ae commit 34a0abf
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions Joomla/Sniffs/Commenting/FunctionCommentSniff.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,17 @@ protected function processParams(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
$matches = array();
preg_match('/([^$&.]+)(?:((?:\.\.\.)?(?:\$|&)[^\s]+)(?:(\s+)(.*))?)?/', $tokens[($tag + 2)]['content'], $matches);

$typeLen = strlen($matches[1]);
$type = trim($matches[1]);
$typeSpace = ($typeLen - strlen($type));
$typeLen = strlen($type);

if ($typeLen > $maxType)
if (empty($matches) === false)
{
$typeLen = strlen($matches[1]);
$type = trim($matches[1]);
$typeSpace = ($typeLen - strlen($type));
$typeLen = strlen($type);

if ($typeLen > $maxType)
{
$maxType = $typeLen;
}
}

if (isset($matches[2]) === true)
Expand Down Expand Up @@ -272,8 +275,10 @@ protected function processParams(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co
* We want to use ... for all variable length arguments,
* so added this prefix to the variable name so comparisons are easier.
*/
foreach ($realParams as $pos => $param) {
if ($param['variable_length'] === true) {
foreach ($realParams as $pos => $param)
{
if ($param['variable_length'] === true)
{
$realParams[$pos]['name'] = '...'.$realParams[$pos]['name'];
}
}
Expand Down

0 comments on commit 34a0abf

Please sign in to comment.