Skip to content

Commit fd5d4bf

Browse files
authored
PhpdocSelfAccessorFixer - do not touch array shape keys (#1076)
1 parent 5507f45 commit fd5d4bf

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/Fixer/PhpdocSelfAccessorFixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ private static function getNewContent(string $content, string $namespace, string
125125
$types = [];
126126
foreach ($annotation->getTypes() as $type) {
127127
$type = Preg::replace(
128-
\sprintf('/(?<![a-zA-Z0-9_\\x7f-\\xff\\\\])(%s|%s)\\b(?!\\\\)/', $classyName, \preg_quote($fqcn, '/')),
128+
\sprintf('/(?<![a-zA-Z0-9_\\x7f-\\xff\\\\])(%s|%s)\\b(?![\\\\:])/', $classyName, \preg_quote($fqcn, '/')),
129129
'self',
130130
$type,
131131
);

tests/Fixer/PhpdocSelfAccessorFixerTest.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,5 +240,38 @@ public function baz(array $a) {}
240240
}
241241
',
242242
];
243+
244+
yield [
245+
<<<'PHP'
246+
<?php class Foo
247+
{
248+
/**
249+
* @return array{Foo: self}
250+
*/
251+
public function f1() {}
252+
/**
253+
* @return array{
254+
* Foo: self
255+
* }
256+
*/
257+
public function f2() {}
258+
}
259+
PHP,
260+
<<<'PHP'
261+
<?php class Foo
262+
{
263+
/**
264+
* @return array{Foo: Foo}
265+
*/
266+
public function f1() {}
267+
/**
268+
* @return array{
269+
* Foo: Foo
270+
* }
271+
*/
272+
public function f2() {}
273+
}
274+
PHP,
275+
];
243276
}
244277
}

0 commit comments

Comments
 (0)