Skip to content

Commit b266f4b

Browse files
Merge pull request #130 from VincentLanglet/phpDocSupport
✨ Support intersection
2 parents 34777c6 + fa766ac commit b266f4b

File tree

4 files changed

+43
-1
lines changed

4 files changed

+43
-1
lines changed

SymfonyCustom/Sniffs/Namespaces/UnusedUseSniff.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ private function isClassUsed(File $phpcsFile, int $usePtr, int $classPtr): bool
315315
|| ('class' === $type
316316
&& ((T_DOC_COMMENT_STRING === $tokens[$classUsed]['code']
317317
&& preg_match(
318-
'/(\s|\||\(|\<|\,|^)'.preg_quote($searchName, '/').'(\s|\||\\\\|\<|\,|\>|$|\[\])/i',
318+
'/(\s|\||\&|\(|\<|\,|^)'.preg_quote($searchName, '/').'(\s|\||\&|\\\\|\<|\,|\>|\}|$|\[\])/i',
319319
$tokens[$classUsed]['content']
320320
))
321321
|| (T_DOC_COMMENT_TAG === $tokens[$classUsed]['code']

SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.inc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,24 @@ function ($a)
150150
{
151151
return null;
152152
}
153+
154+
namespace PhpDoc;
155+
156+
use Some\Key;
157+
use Some\Key2;
158+
use Some\Value;
159+
use Some\Value2;
160+
use Some\Foo;
161+
use Some\Bar;
162+
use Some\Baz;
163+
164+
/**
165+
* @param array{Key: Value, Key2: Value2} $a
166+
* @param Foo&Bar&Baz $a
167+
*
168+
* @return null
169+
*/
170+
function ($a)
171+
{
172+
return null;
173+
}

SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.inc.fixed

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,22 @@ function ($a)
137137
{
138138
return null;
139139
}
140+
141+
namespace PhpDoc;
142+
143+
use Some\Value;
144+
use Some\Value2;
145+
use Some\Foo;
146+
use Some\Bar;
147+
use Some\Baz;
148+
149+
/**
150+
* @param array{Key: Value, Key2: Value2} $a
151+
* @param Foo&Bar&Baz $a
152+
*
153+
* @return null
154+
*/
155+
function ($a)
156+
{
157+
return null;
158+
}

SymfonyCustom/Tests/Namespaces/UnusedUseUnitTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ protected function getErrorList(): array
3535
127 => 1,
3636
128 => 1,
3737
129 => 1,
38+
156 => 1,
39+
157 => 1,
3840
];
3941
}
4042

0 commit comments

Comments
 (0)