Skip to content

Commit

Permalink
Test: Add test for PhpDoc param and return type hints fixers/sniffs
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed May 14, 2024
1 parent b640a68 commit cbfeadd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
1 change: 0 additions & 1 deletion ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@
->withConfiguredRule(ConcatSpaceFixer::class, ['spacing' => 'one'])
// Removes `@param` and `@return` tags that don't provide any useful information
->withConfiguredRule(NoSuperfluousPhpdocTagsFixer::class, [
'allow_mixed' => true, // allow `@mixed` annotations to be preserved
'allow_unused_params' => false, // whether param annotation without actual signature is allowed
'remove_inheritdoc' => true, // remove @inheritDoc tags
])
Expand Down
13 changes: 13 additions & 0 deletions tests/Integration/Fixtures/PhpDoc.correct.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,17 @@ class PhpDoc
{
return $first . $third;
}

public function methodWithTypesInTypeHints(int $value, mixed $mixedType): bool
{
return $value > 3 ? true : false;
}

/**
* @param string $stringParam This phpdoc should be preserved, because it contains some comment for $stringParam.
*/
public function methodWithMeaningfulParamComment(int $intParam, string $stringParam): void
{
// Do nothing.
}
}
20 changes: 20 additions & 0 deletions tests/Integration/Fixtures/PhpDoc.wrong.php.inc
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,24 @@ class PhpDoc
{
return $first . $third;
}

/**
* @param int $value
* @param mixed $mixedType
* @return bool
*/
public function methodWithTypesInTypeHints($value, $mixedType)
{
return $value > 3 ? true : false;
}

/**
* @param int $intParam
* @param string $stringParam This phpdoc should be preserved, because it contains some comment for $stringParam.
* @return void
*/
public function methodWithMeaningfulParamComment(int $intParam, string $stringParam): void
{
// Do nothing.
}
}

0 comments on commit cbfeadd

Please sign in to comment.