Skip to content

Commit 5ec11d9

Browse files
committed
Test: Add test for PhpDoc param and return type hints fixers/sniffs
1 parent 24fc9ea commit 5ec11d9

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

Diff for: ecs.php

-1
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@
526526
->withConfiguredRule(ConcatSpaceFixer::class, ['spacing' => 'one'])
527527
// Removes `@param` and `@return` tags that don't provide any useful information
528528
->withConfiguredRule(NoSuperfluousPhpdocTagsFixer::class, [
529-
'allow_mixed' => true, // allow `@mixed` annotations to be preserved
530529
'allow_unused_params' => false, // whether param annotation without actual signature is allowed
531530
'remove_inheritdoc' => true, // remove @inheritDoc tags
532531
])

Diff for: tests/Integration/Fixtures/PhpDoc.correct.php.inc

+13
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,17 @@ class PhpDoc
2222
{
2323
return $first . $third;
2424
}
25+
26+
public function methodWithTypesInTypeHints(int $value, mixed $mixedType): bool
27+
{
28+
return $value > 3 ? true : false;
29+
}
30+
31+
/**
32+
* @param string $stringParam This phpdoc should be preserved, because it contains some comment for $stringParam.
33+
*/
34+
public function methodWithMeaningfulParamComment(int $intParam, string $stringParam): void
35+
{
36+
// Do nothing.
37+
}
2538
}

Diff for: tests/Integration/Fixtures/PhpDoc.wrong.php.inc

+20
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,24 @@ class PhpDoc
2626
{
2727
return $first . $third;
2828
}
29+
30+
/**
31+
* @param int $value
32+
* @param mixed $mixedType
33+
* @return bool
34+
*/
35+
public function methodWithTypesInTypeHints($value, $mixedType)
36+
{
37+
return $value > 3 ? true : false;
38+
}
39+
40+
/**
41+
* @param int $intParam
42+
* @param string $stringParam This phpdoc should be preserved, because it contains some comment for $stringParam.
43+
* @return void
44+
*/
45+
public function methodWithMeaningfulParamComment(int $intParam, string $stringParam): void
46+
{
47+
// Do nothing.
48+
}
2949
}

0 commit comments

Comments
 (0)