Skip to content

Commit

Permalink
Merge pull request #3785 from fredden/php-fatal/squiz-commeting-funct…
Browse files Browse the repository at this point in the history
…ion-comment

Fix PHP Fatal error in `Squiz.Commenting.FunctionComment`
  • Loading branch information
jrfnl authored Jul 11, 2023
2 parents edda91a + 8c84123 commit a5d085f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@ protected function processParams(File $phpcsFile, $stackPtr, $commentStart)
$suggestedTypeNames = [];

foreach ($typeNames as $typeName) {
if ($typeName === '') {
continue;
}

// Strip nullable operator.
if ($typeName[0] === '?') {
$typeName = substr($typeName, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1046,3 +1046,11 @@ public function ignored() {
* @return void
* @throws Exception If any other error occurs. */
function throwCommentOneLine() {}

/**
* When two adjacent pipe symbols are used (by mistake), the sniff should not throw a PHP Fatal error
*
* @param stdClass||null $object While invalid, this should not throw a PHP Fatal error.
* @return void
*/
function doublePipeFatalError(?stdClass $object) {}
Original file line number Diff line number Diff line change
Expand Up @@ -1046,3 +1046,11 @@ public function ignored() {
* @return void
* @throws Exception If any other error occurs. */
function throwCommentOneLine() {}

/**
* When two adjacent pipe symbols are used (by mistake), the sniff should not throw a PHP Fatal error
*
* @param stdClass|null $object While invalid, this should not throw a PHP Fatal error.
* @return void
*/
function doublePipeFatalError(?stdClass $object) {}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ public function getErrorList()
1004 => 2,
1006 => 1,
1029 => 1,
1053 => 1,
];

// Scalar type hints only work from PHP 7 onwards.
Expand Down

0 comments on commit a5d085f

Please sign in to comment.