Skip to content

Commit e17ffa5

Browse files
authored
PhpdocArrayStyleFixer - fix for classes with _ in name (#955)
1 parent 7ddc5ac commit e17ffa5

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![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)
66
[![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://php.net)
77
[![License](https://img.shields.io/github/license/kubawerlos/php-cs-fixer-custom-fixers.svg)](LICENSE)
8-
![Tests](https://img.shields.io/badge/tests-3527-brightgreen.svg)
8+
![Tests](https://img.shields.io/badge/tests-3528-brightgreen.svg)
99
[![Downloads](https://img.shields.io/packagist/dt/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)
1010

1111
[![CI status](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions/workflows/ci.yaml/badge.svg)](https://github.com/kubawerlos/php-cs-fixer-custom-fixers/actions/workflows/ci.yaml)

src/Fixer/PhpdocArrayStyleFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getPriority(): int
4646

4747
protected function fixType(string $type): string
4848
{
49-
$newType = Preg::replace('/([\\\\a-zA-Z0-9>]+)\[\]/', 'array<$1>', $type);
49+
$newType = Preg::replace('/([\\\\a-zA-Z0-9_>]+)\[\]/', 'array<$1>', $type);
5050

5151
if ($newType === $type) {
5252
return $type;

tests/Fixer/PhpdocArrayStyleFixerTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ public static function provideFixCases(): iterable
105105
',
106106
];
107107

108+
yield [
109+
'<?php /** @var array<Hello_Legacy_Naming> */',
110+
'<?php /** @var Hello_Legacy_Naming[] */',
111+
];
112+
108113
$expected = $input = 'string';
109114
for ($i = 0; $i < 128; $i++) {
110115
$expected = 'array<' . $expected . '>';

0 commit comments

Comments
 (0)