From 4079d5fdbc8917861680fc99fc26584bcf5e80d8 Mon Sep 17 00:00:00 2001 From: Greg Sherwood Date: Tue, 14 Feb 2017 13:57:32 +1100 Subject: [PATCH] Squiz.Commenting.FunctionComment fixed for incorrect fixing of param types and multi-line param comment indents --- .../Commenting/FunctionCommentSniff.php | 187 ++-- .../Commenting/FunctionCommentUnitTest.1.inc | 50 - .../FunctionCommentUnitTest.1.inc.fixed | 50 - .../Commenting/FunctionCommentUnitTest.inc | 46 + .../FunctionCommentUnitTest.inc.fixed | 869 ++++++++++++++++++ .../Commenting/FunctionCommentUnitTest.php | 12 +- package.xml | 7 +- 7 files changed, 1038 insertions(+), 183 deletions(-) delete mode 100644 CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.1.inc delete mode 100644 CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.1.inc.fixed create mode 100644 CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed diff --git a/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php b/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php index 0cc352b46a..0dd5ab4242 100644 --- a/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php +++ b/CodeSniffer/Standards/Squiz/Sniffs/Commenting/FunctionCommentSniff.php @@ -374,92 +374,121 @@ protected function processParams(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $co } // Check the param type value. - $typeNames = explode('|', $param['type']); + $typeNames = explode('|', $param['type']); + $suggestedTypeNames = array(); + foreach ($typeNames as $typeName) { - $suggestedName = PHP_CodeSniffer::suggestType($typeName); - if ($typeName !== $suggestedName) { - $error = 'Expected "%s" but found "%s" for parameter type'; - $data = array( - $suggestedName, - $typeName, - ); + $suggestedName = PHP_CodeSniffer::suggestType($typeName); + $suggestedTypeNames[] = $suggestedName; - $fix = $phpcsFile->addFixableError($error, $param['tag'], 'IncorrectParamVarName', $data); - if ($fix === true) { - $content = $suggestedName; - $content .= str_repeat(' ', $param['type_space']); - $content .= $param['var']; - $content .= str_repeat(' ', $param['var_space']); - if (isset($param['commentLines'][0]) === true) { - $content .= $param['commentLines'][0]['comment']; - } + if (count($typeNames) > 1) { + continue; + } - $phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content); + // Check type hint for array and custom type. + $suggestedTypeHint = ''; + if (strpos($suggestedName, 'array') !== false || substr($suggestedName, -2) === '[]') { + $suggestedTypeHint = 'array'; + } else if (strpos($suggestedName, 'callable') !== false) { + $suggestedTypeHint = 'callable'; + } else if (strpos($suggestedName, 'callback') !== false) { + $suggestedTypeHint = 'callable'; + } else if (in_array($typeName, PHP_CodeSniffer::$allowedTypes) === false) { + $suggestedTypeHint = $suggestedName; + } else if ($this->_phpVersion >= 70000) { + if ($typeName === 'string') { + $suggestedTypeHint = 'string'; + } else if ($typeName === 'int' || $typeName === 'integer') { + $suggestedTypeHint = 'int'; + } else if ($typeName === 'float') { + $suggestedTypeHint = 'float'; + } else if ($typeName === 'bool' || $typeName === 'boolean') { + $suggestedTypeHint = 'bool'; } - } else if (count($typeNames) === 1) { - // Check type hint for array and custom type. - $suggestedTypeHint = ''; - if (strpos($suggestedName, 'array') !== false || substr($suggestedName, -2) === '[]') { - $suggestedTypeHint = 'array'; - } else if (strpos($suggestedName, 'callable') !== false) { - $suggestedTypeHint = 'callable'; - } else if (strpos($suggestedName, 'callback') !== false) { - $suggestedTypeHint = 'callable'; - } else if (in_array($typeName, PHP_CodeSniffer::$allowedTypes) === false) { - $suggestedTypeHint = $suggestedName; - } else if ($this->_phpVersion >= 70000) { - if ($typeName === 'string') { - $suggestedTypeHint = 'string'; - } else if ($typeName === 'int' || $typeName === 'integer') { - $suggestedTypeHint = 'int'; - } else if ($typeName === 'float') { - $suggestedTypeHint = 'float'; - } else if ($typeName === 'bool' || $typeName === 'boolean') { - $suggestedTypeHint = 'bool'; + } + + if ($suggestedTypeHint !== '' && isset($realParams[$pos]) === true) { + $typeHint = $realParams[$pos]['type_hint']; + if ($typeHint === '') { + $error = 'Type hint "%s" missing for %s'; + $data = array( + $suggestedTypeHint, + $param['var'], + ); + + $errorCode = 'TypeHintMissing'; + if ($suggestedTypeHint === 'string' + || $suggestedTypeHint === 'int' + || $suggestedTypeHint === 'float' + || $suggestedTypeHint === 'bool' + ) { + $errorCode = 'Scalar'.$errorCode; } + + $phpcsFile->addError($error, $stackPtr, $errorCode, $data); + } else if ($typeHint !== substr($suggestedTypeHint, (strlen($typeHint) * -1))) { + $error = 'Expected type hint "%s"; found "%s" for %s'; + $data = array( + $suggestedTypeHint, + $typeHint, + $param['var'], + ); + $phpcsFile->addError($error, $stackPtr, 'IncorrectTypeHint', $data); + }//end if + } else if ($suggestedTypeHint === '' && isset($realParams[$pos]) === true) { + $typeHint = $realParams[$pos]['type_hint']; + if ($typeHint !== '') { + $error = 'Unknown type hint "%s" found for %s'; + $data = array( + $typeHint, + $param['var'], + ); + $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHint', $data); } + }//end if + }//end foreach - if ($suggestedTypeHint !== '' && isset($realParams[$pos]) === true) { - $typeHint = $realParams[$pos]['type_hint']; - if ($typeHint === '') { - $error = 'Type hint "%s" missing for %s'; - $data = array( - $suggestedTypeHint, - $param['var'], - ); - - $errorCode = 'TypeHintMissing'; - if ($suggestedTypeHint === 'string' - || $suggestedTypeHint === 'int' - || $suggestedTypeHint === 'float' - || $suggestedTypeHint === 'bool' - ) { - $errorCode = 'Scalar'.$errorCode; - } + $suggestedType = implode($suggestedTypeNames, '|'); + if ($param['type'] !== $suggestedType) { + $error = 'Expected "%s" but found "%s" for parameter type'; + $data = array( + $suggestedType, + $param['type'], + ); + + $fix = $phpcsFile->addFixableError($error, $param['tag'], 'IncorrectParamVarName', $data); + if ($fix === true) { + $phpcsFile->fixer->beginChangeset(); + + $content = $suggestedType; + $content .= str_repeat(' ', $param['type_space']); + $content .= $param['var']; + $content .= str_repeat(' ', $param['var_space']); + if (isset($param['commentLines'][0]) === true) { + $content .= $param['commentLines'][0]['comment']; + } - $phpcsFile->addError($error, $stackPtr, $errorCode, $data); - } else if ($typeHint !== substr($suggestedTypeHint, (strlen($typeHint) * -1))) { - $error = 'Expected type hint "%s"; found "%s" for %s'; - $data = array( - $suggestedTypeHint, - $typeHint, - $param['var'], - ); - $phpcsFile->addError($error, $stackPtr, 'IncorrectTypeHint', $data); - }//end if - } else if ($suggestedTypeHint === '' && isset($realParams[$pos]) === true) { - $typeHint = $realParams[$pos]['type_hint']; - if ($typeHint !== '') { - $error = 'Unknown type hint "%s" found for %s'; - $data = array( - $typeHint, - $param['var'], - ); - $phpcsFile->addError($error, $stackPtr, 'InvalidTypeHint', $data); + $phpcsFile->fixer->replaceToken(($param['tag'] + 2), $content); + + // Fix up the indent of additional comment lines. + foreach ($param['commentLines'] as $lineNum => $line) { + if ($lineNum === 0 + || $param['commentLines'][$lineNum]['indent'] === 0 + ) { + continue; } - }//end if + + $diff = (strlen($param['type']) - strlen($suggestedType)); + $newIndent = ($param['commentLines'][$lineNum]['indent'] - $diff); + $phpcsFile->fixer->replaceToken( + ($param['commentLines'][$lineNum]['token'] - 1), + str_repeat(' ', $newIndent) + ); + } + + $phpcsFile->fixer->endChangeset(); }//end if - }//end foreach + }//end if if ($param['var'] === '') { continue; @@ -572,7 +601,8 @@ protected function checkSpacingAfterParamType(PHP_CodeSniffer_File $phpcsFile, $ continue; } - $newIndent = ($param['commentLines'][$lineNum]['indent'] + $spaces - $param['type_space']); + $diff = ($param['type_space'] - $spaces); + $newIndent = ($param['commentLines'][$lineNum]['indent'] - $diff); $phpcsFile->fixer->replaceToken( ($param['commentLines'][$lineNum]['token'] - 1), str_repeat(' ', $newIndent) @@ -626,7 +656,8 @@ protected function checkSpacingAfterParamName(PHP_CodeSniffer_File $phpcsFile, $ continue; } - $newIndent = ($param['commentLines'][$lineNum]['indent'] + $spaces - $param['var_space']); + $diff = ($param['var_space'] - $spaces); + $newIndent = ($param['commentLines'][$lineNum]['indent'] - $diff); $phpcsFile->fixer->replaceToken( ($param['commentLines'][$lineNum]['token'] - 1), str_repeat(' ', $newIndent) diff --git a/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.1.inc b/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.1.inc deleted file mode 100644 index 308e48360f..0000000000 --- a/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.1.inc +++ /dev/null @@ -1,50 +0,0 @@ -MyClass)|callable And here we have a description - */ -function returnTypeWithDescriptionC() -{ - return 5; - -}//end returnTypeWithDescriptionC() - - -/** - * Return description function + lots of different mixed return types. - * - * @return array(int=>bool)|\OtherVendor\Package\SomeClass2|MyClass[]|void And here we have a description - */ -function returnTypeWithDescriptionD() -{ - -}//end returnTypeWithDescriptionD() diff --git a/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.1.inc.fixed b/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.1.inc.fixed deleted file mode 100644 index 21a2aab805..0000000000 --- a/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.1.inc.fixed +++ /dev/null @@ -1,50 +0,0 @@ - MyClass)|callable And here we have a description - */ -function returnTypeWithDescriptionC() -{ - return 5; - -}//end returnTypeWithDescriptionC() - - -/** - * Return description function + lots of different mixed return types. - * - * @return array(integer => boolean)|\OtherVendor\Package\SomeClass2|MyClass[]|void And here we have a description - */ -function returnTypeWithDescriptionD() -{ - -}//end returnTypeWithDescriptionD() diff --git a/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc b/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc index dca965a0b9..efad0954d1 100644 --- a/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc +++ b/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc @@ -821,3 +821,49 @@ public function someFunc(): void } }; } + +/** + * Return description function + mixed return types. + * + * @return bool|int This is a description. + */ +function returnTypeWithDescriptionA() +{ + return 5; + +}//end returnTypeWithDescriptionA() + + +/** + * Return description function + mixed return types. + * + * @return real|bool This is a description. + */ +function returnTypeWithDescriptionB() +{ + return 5; + +}//end returnTypeWithDescriptionB() + + +/** + * Return description function + lots of different mixed return types. + * + * @return int|object|string[]|real|double|float|bool|array(int=>MyClass)|callable And here we have a description + */ +function returnTypeWithDescriptionC() +{ + return 5; + +}//end returnTypeWithDescriptionC() + + +/** + * Return description function + lots of different mixed return types. + * + * @return array(int=>bool)|\OtherVendor\Package\SomeClass2|MyClass[]|void And here we have a description + */ +function returnTypeWithDescriptionD() +{ + +}//end returnTypeWithDescriptionD() diff --git a/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed b/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed new file mode 100644 index 0000000000..28af90256f --- /dev/null +++ b/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc.fixed @@ -0,0 +1,869 @@ + MyClass) + */ +public function caseSensitive($a1, $a2, $a3, arRay $a4, $a5, $a6, myclas $a7) +{ + +}//end caseSensitive() + + +/** + * More type hint check for custom type and array. + * + * @param array $a1 Comment here. + * @param array $a2 Comment here. + * @param MyClass $a3 Comment here. + * @param MyClass $a4 Comment here. + * + * @return array(integer => MyClass) + */ +public function typeHint(MyClass $a1, $a2, myclass $a3, $a4) +{ + return (3 => 'myclass obj'); + +}//end typeHint() + + +/** + * Mixed variable type separated by a '|'. + * + * @param array|string $a1 Comment here. + * @param mixed $a2 Comment here. + * @param string|array $a3 Comment here. + * @param MyClass|integer $a4 Comment here. + * + * @return boolean + */ +public function mixedType($a1, $a2, $a3, $a4) +{ + return true; + +}//end mixedType() + + +/** + * Array type. + * + * @param array(MyClass) $a1 OK. + * @param array $a2 Invalid type. + * @param array $a3 Typo. + * @param array(integer) $a4 Use 'array(integer)' instead. + * @param array(integer => integer) $a5 Use 'array(integer => integer)' instead. + * @param array(integer => boolean) $a6 Use 'array(integer => boolean)' instead. + * @param array $a7 Use 'array' instead. + * @param string $a8 String with unknown type hint. + * + * @return integer + */ +public function mixedArrayType($a1, $a2, array $a3, $a4, $a5, $a6, $a7, unknownTypeHint $a8) +{ + return 1; + +}//end mixedArrayType() + + +/** + */ +function empty1() +{ +}//end empty1() + + +/** + * + */ +function empty2() +{ +}//end empty2() + + +/** + * + * + * + */ +function empty3() +{ +}//end empty3 + + +/** + * @return boolean + */ +public function missingShortDescriptionInFunctionComment() +{ + return true; + +}//end missingShortDescriptionInFunctionComment() + + +class Another_Class +{ + + /** + * Destructor should not include a return tag. + * + * @return void + */ + function __destruct() + { + return; + } + + /** + * Constructor should not include a return tag. + * + * @return void + */ + function __construct() + { + return; + } + +}//end class + + +/** + * Comment param alignment test. + * + * @param string $varrr1 Comment1.. + * @param string $vr2 Comment2. + * @param string $var3 Comment3.. + * + * @return void + */ +public static function paramAlign($varrr1, $vr2, $var3) +{ + +}//end paramAlign() + + +/** + * Comment. + * + * @param string $id Comment. + * @param array $design Comment. + * + * @return void + */ +public static function paint($id, array $design) +{ + +}//end paint() + + +/** + * Adds specified class name to class attribute of this widget. + * + * @since 4.0.0 + * @return string + */ +public function myFunction() +{ + if ($condition === FALSE) { + echo 'hi'; + } + +}//end myFunction() + + +/** + * Adds specified class name to class attribute of this widget. + * + * @return string + */ +public function myFunction() +{ + if ($condition === FALSE) { + echo 'hi'; + return; + } + + return 'blah'; + +}//end myFunction() + + +/** + * Adds specified class name to class attribute of this widget. + * + * @return string + */ +public function myFunction() +{ + if ($condition === FALSE) { + echo 'hi'; + } + + return 'blah'; + +}//end myFunction() + +/** + * Test function. + * + * @param string $arg1 An argument + * + * @access public + * @return bool + */ + +echo $blah; + +function myFunction($arg1) {} + +class MyClass() { + /** + * An abstract function. + * + * @return string[] + */ + abstract final protected function myFunction(); +} + +/** + * Comment. + * + * @param mixed $test An argument. + * + * @return mixed + */ +function test($test) +{ + if ($test === TRUE) { + return; + } + + return $test; + +}//end test() + + +/** Comment. + * + * @return mixed + * + */ +function test() +{ + +}//end test() + +/** + * Comment. + * + * @param \other\ns\item $test An argument. + * + * @return mixed + */ +function test(\other\ns\item $test) +{ + return $test; + +}//end test() + +/** + * Comment. + * + * @param item $test An argument. + * + * @return mixed + */ +function test(\other\ns\item $test) +{ + return $test; + +}//end test() + +/** + * Comment. + * + * @param \first\ns\item $test An argument. + * + * @return mixed + */ +function test(\first\ns\item $test = \second\ns::CONSTANT) +{ + return $test; + +}//end test() + +/** + * Comment. + * + * @param \first\item $test An argument. + * + * @return mixed + */ +function test(\first\ns\item $test = \second\ns::CONSTANT) +{ + return $test; + +}//end test() + +// Closures should be ignored. +preg_replace_callback( + '~-([a-z])~', + function ($match) { + return strtoupper($match[1]); + }, + 'hello-world' +); + +$callback = function ($bar) use ($foo) + { + $bar += $foo; + }; + +/** + * Comment should end with '*', not '**' before the slash. + **/ +function test123() { + +} + +/** + * Cant use resource for type hint. + * + * @param resource $test An argument. + * + * @return mixed + */ +function test($test) +{ + return $test; + +}//end test() + +/** + * Variable number of args. + * + * @param string $a1 Comment here. + * @param string $a2 Comment here. + * @param string $a2,... Comment here. + * + * @return boolean + */ +public function variableArgs($a1, $a2) +{ + return true; + +}//end variableArgs() + +/** + * Contains closure. + * + * @return void + */ +public function containsClosure() +{ + function ($e) { + return new Event($e); + }, + +}//end containsClosure() + +/** + * 这是一条测试评论. + * + * @return void + */ +public function test() +{ + +}//end variableArgs() + +/** + * Uses callable. + * + * @param callable $cb Test parameter. + * + * @return void + */ +public function usesCallable(callable $cb) { + $cb(); +}//end usesCallable() + +/** + * Creates a map of tokens => line numbers for each token. + * + * @param array $tokens The array of tokens to process. + * @param object $tokenizer The tokenizer being used to process this file. + * @param string $eolChar The EOL character + * to use for splitting strings. + * + * @return void + * @throws Exception If something really bad + * happens while doing foo. + */ +public function foo(array &$tokens, $tokenizer, $eolChar) +{ + +}//end foo() + +/** + * Some description. + * + * @param \Vendor\Package\SomeClass $someclass Some class. + * @param \OtherVendor\Package\SomeClass2 $someclass2 Some class. + * @param \OtherVendor\Package\SomeClass2 $someclass3 Some class. + * + * @return void + */ +public function foo(SomeClass $someclass, \OtherVendor\Package\SomeClass2 $someclass2, SomeClass3 $someclass3) +{ +} + +/** + * Gettext. + * + * @return string + */ +public function _() { + return $foo; +} + +class Baz { + /** + * The PHP5 constructor + * + * No return tag + */ + public function __construct() { + + } +} + +/** + * Test + * + * @return void + * @throws E + */ +function myFunction() {} + +/** + * Yield test + * + * @return integer + */ +function yieldTest() +{ + for ($i = 0; $i < 5; $i++) { + yield $i; + } +} + +/** + * Yield test + * + * @return void + */ +function yieldTest() +{ + for ($i = 0; $i < 5; $i++) { + yield $i; + } +} + +/** + * Using "array" as a type hint should satisfy a specified array parameter type. + * + * @param MyClass[] $values An array of MyClass objects. + * + * @return void + */ +public function specifiedArray(array $values) { + +}// end specifiedArray() + +/** + * Using "callable" as a type hint should satisfy a "callback" parameter type. + * + * @param callback $cb A callback. + * + * @return void + */ +public function callableCallback(callable $cb) { + +}// end callableCallback() + +/** + * PHP7 type hints. + * + * @param string $name1 Comment. + * @param integer $name2 Comment. + * @param float $name3 Comment. + * @param boolean $name4 Comment. + * + * @return void + */ +public function myFunction (string $name1, int $name2, float $name3, bool $name4) { +} + +/** + * Variadic function. + * + * @param string $name1 Comment. + * @param string ...$name2 Comment. + * + * @return void + */ +public function myFunction(string $name1, string ...$name2) { +} + + +/** + * Variadic function. + * + * @param string $name1 Comment. + * @param string $name2 Comment. + * + * @return void + */ +public function myFunction(string $name1, string ...$name2) { +} + +/** + * Return description function + correct type. + * + * @return integer This is a description. + */ +public function myFunction() { + return 5; +} + +/** + * Return description function + incorrect type. + * + * @return integer This is a description. + */ +public function myFunction() { + return 5; +} + +/** + * Return description function + no return. + * + * @return void This is a description. + */ +public function myFunction() { +} + +/** + * Return description function + mixed return. + * + * @return mixed This is a description. + */ +public function myFunction() { +} + +/** + * Function comment. + * + * @param $bar + * Comment here. + * @param ... + * Additional arguments here. + * + * @return + * Return value + * + */ +function foo($bar) { +} + +/** + * Do something. + * + * @return void + */ +public function someFunc(): void +{ + $class = new class + { + /** + * Do something. + * + * @return string + */ + public function getString(): string + { + return 'some string'; + } + }; +} + +/** + * Return description function + mixed return types. + * + * @return boolean|integer This is a description. + */ +function returnTypeWithDescriptionA() +{ + return 5; + +}//end returnTypeWithDescriptionA() + + +/** + * Return description function + mixed return types. + * + * @return float|boolean This is a description. + */ +function returnTypeWithDescriptionB() +{ + return 5; + +}//end returnTypeWithDescriptionB() + + +/** + * Return description function + lots of different mixed return types. + * + * @return integer|object|string[]|float|boolean|array(integer => MyClass)|callable And here we have a description + */ +function returnTypeWithDescriptionC() +{ + return 5; + +}//end returnTypeWithDescriptionC() + + +/** + * Return description function + lots of different mixed return types. + * + * @return array(integer => boolean)|\OtherVendor\Package\SomeClass2|MyClass[]|void And here we have a description + */ +function returnTypeWithDescriptionD() +{ + +}//end returnTypeWithDescriptionD() diff --git a/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php b/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php index d4204599de..0bef2042de 100644 --- a/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php +++ b/CodeSniffer/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php @@ -50,6 +50,7 @@ public function getErrorList($testFile='FunctionCommentUnitTest.inc') 13 => 2, 14 => 1, 15 => 1, + 17 => 2, 28 => 1, 43 => 1, 76 => 1, @@ -62,6 +63,7 @@ public function getErrorList($testFile='FunctionCommentUnitTest.inc') 124 => 2, 125 => 1, 126 => 1, + 128 => 1, 137 => 4, 138 => 4, 139 => 4, @@ -85,7 +87,7 @@ public function getErrorList($testFile='FunctionCommentUnitTest.inc') 226 => 1, 227 => 1, 230 => 2, - 232 => 1, + 232 => 7, 246 => 1, 248 => 4, 261 => 1, @@ -97,7 +99,7 @@ public function getErrorList($testFile='FunctionCommentUnitTest.inc') 280 => 1, 281 => 1, 284 => 1, - 286 => 2, + 286 => 7, 294 => 1, 302 => 1, 312 => 1, @@ -121,6 +123,10 @@ public function getErrorList($testFile='FunctionCommentUnitTest.inc') 794 => 1, 797 => 1, 801 => 1, + 828 => 1, + 840 => 1, + 852 => 1, + 864 => 1, ); // The yield tests will only work in PHP versions where yield exists and @@ -133,7 +139,7 @@ public function getErrorList($testFile='FunctionCommentUnitTest.inc') // Scalar type hints only work from PHP 7 onwards. if (PHP_VERSION_ID >= 70000) { - $errors[17] = 1; + $errors[17] = 3; $errors[143] = 3; $errors[161] = 2; $errors[201] = 1; diff --git a/package.xml b/package.xml index 460a2fa0d7..a8c005565c 100644 --- a/package.xml +++ b/package.xml @@ -27,6 +27,10 @@ http://pear.php.net/dtd/package-2.0.xsd"> BSD 3-Clause License - The PHP-supplied T_COALESCE_EQUAL token has been replicated for PHP versions before 7.2 + - Squiz.Commenting.FunctionComment now corrects multi-line param comment padding more accurately + - Squiz.Commenting.FunctionComment now properly fixes pipe-seperated param types + - Squiz.Commenting.FunctionComment now works correctly when function return types also contain a comment + -- Thanks to Juliette Reinders Folmer for the patch - Fixed bug #1340 : STDIN file contents not being populated in some cases -- Thanks to David Biňovec for the patch - Fixed bug #1344 : PEAR.Functions.FunctionCallSignatureSniff throws error for blank comment lines @@ -1838,8 +1842,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - +