Skip to content

Commit c047e00

Browse files
authored
Fix PhpdocSelfAccessorFixer (#909)
1 parent 82c08ee commit c047e00

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Latest stable version](https://img.shields.io/packagist/v/kubawerlos/php-cs-fixer-custom-fixers.svg?label=current%20version)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
44
[![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://php.net)
55
[![License](https://img.shields.io/github/license/kubawerlos/php-cs-fixer-custom-fixers.svg)](LICENSE)
6-
![Tests](https://img.shields.io/badge/tests-3445-brightgreen.svg)
6+
![Tests](https://img.shields.io/badge/tests-3446-brightgreen.svg)
77
[![Downloads](https://img.shields.io/packagist/dt/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
88

99
[![CI Status](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/workflows/CI/badge.svg?branch=main)](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions)

src/Fixer/PhpdocSelfAccessorFixer.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ private function getNewContent(string $content, string $namespace, string $class
129129
$types[] = $type;
130130
}
131131

132-
$annotation->setTypes($types);
132+
if ($types !== []) {
133+
$annotation->setTypes($types);
134+
}
133135
}
134136

135137
return $docBlock->getContent();

tests/Fixer/PhpdocSelfAccessorFixerTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,5 +227,18 @@ public static function create() {}
227227
}
228228
',
229229
];
230+
231+
yield [
232+
'<?php class Foo
233+
{
234+
/**
235+
* @return array{
236+
* bar: string
237+
* }
238+
*/
239+
public function baz(array $a) {}
240+
}
241+
',
242+
];
230243
}
231244
}

0 commit comments

Comments
 (0)