Skip to content

Commit

Permalink
NoSuperfluousPhpdocTagsFixer now handles null in every position inste…
Browse files Browse the repository at this point in the history
…ad of last only
  • Loading branch information
dmvdbrugge committed Jul 6, 2018
1 parent 922ba6e commit b14eaad
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixer.php
Expand Up @@ -255,8 +255,8 @@ private function annotationIsSuperfluous(Annotation $annotation, array $info, ar
/**
* Normalizes types to make them comparable.
*
* Converts given types to lowercase and replaces imports aliases with
* their matching FQCN.
* Converts given types to lowercase, replaces imports aliases with
* their matching FQCN, and finally sort the result.
*
* @param array $types The types to normalize
* @param array $symbolShortNames The imports aliases
Expand All @@ -265,7 +265,7 @@ private function annotationIsSuperfluous(Annotation $annotation, array $info, ar
*/
private function toComparableNames(array $types, array $symbolShortNames)
{
return array_map(
$normalized = array_map(
function ($type) use ($symbolShortNames) {
$type = strtolower($type);

Expand All @@ -277,5 +277,9 @@ function ($type) use ($symbolShortNames) {
},
$types
);

sort($normalized);

return $normalized;
}
}
18 changes: 18 additions & 0 deletions tests/Fixer/Phpdoc/NoSuperfluousPhpdocTagsFixerTest.php
Expand Up @@ -442,6 +442,24 @@ class Foo {
* @return Baz|null
*/
public function doFoo(?Bar $bar): ?Baz {}
}',
],
'same_nullable_typehint_reversed' => [
'<?php
class Foo {
/**
*
*/
public function doFoo(?Bar $bar): ?Baz {}
}',
'<?php
class Foo {
/**
* @param null|Bar $bar
*
* @return null|Baz
*/
public function doFoo(?Bar $bar): ?Baz {}
}',
],
'same_nullable_typehint_with_description' => [
Expand Down

0 comments on commit b14eaad

Please sign in to comment.