Skip to content

Commit

Permalink
PhpdocArrayStyleFixer - fix for classes with _ in name (#955)
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Jan 25, 2024
1 parent 7ddc5ac commit e17ffa5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -5,7 +5,7 @@
[![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)
[![PHP version](https://img.shields.io/packagist/php-v/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://php.net)
[![License](https://img.shields.io/github/license/kubawerlos/php-cs-fixer-custom-fixers.svg)](LICENSE)
![Tests](https://img.shields.io/badge/tests-3527-brightgreen.svg)
![Tests](https://img.shields.io/badge/tests-3528-brightgreen.svg)
[![Downloads](https://img.shields.io/packagist/dt/kubawerlos/php-cs-fixer-custom-fixers.svg)](https://packagist.org/packages/kubawerlos/php-cs-fixer-custom-fixers)

[![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)
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/PhpdocArrayStyleFixer.php
Expand Up @@ -46,7 +46,7 @@ public function getPriority(): int

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

if ($newType === $type) {
return $type;
Expand Down
5 changes: 5 additions & 0 deletions tests/Fixer/PhpdocArrayStyleFixerTest.php
Expand Up @@ -105,6 +105,11 @@ public static function provideFixCases(): iterable
',
];

yield [
'<?php /** @var array<Hello_Legacy_Naming> */',
'<?php /** @var Hello_Legacy_Naming[] */',
];

$expected = $input = 'string';
for ($i = 0; $i < 128; $i++) {
$expected = 'array<' . $expected . '>';
Expand Down

0 comments on commit e17ffa5

Please sign in to comment.