Skip to content

Commit a6702a1

Browse files
authored
Fix FQ usages (#601)
Fix FQ usages for exposed symbols
1 parent 375fee9 commit a6702a1

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/Symbol/SymbolRegistry.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ public static function create(
4040
): self {
4141
return new self(
4242
array_unique(
43-
array_map('strtolower', $names),
43+
array_map(
44+
static fn (string $name) => strtolower(ltrim($name, '\\')),
45+
$names,
46+
),
4447
),
4548
array_unique($regexes),
4649
false,
@@ -61,7 +64,9 @@ public static function createForConstants(
6164
return new self(
6265
array_unique(
6366
array_map(
64-
static fn (string $name) => self::lowerCaseConstantName($name),
67+
static fn (string $name) => self::lowerCaseConstantName(
68+
ltrim($name, '\\'),
69+
),
6570
$names,
6671
),
6772
),

tests/Symbol/SymbolRegistryTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,18 @@ private static function provideNames(): iterable
118118
true,
119119
];
120120

121+
yield 'FQ namespaced name registered; match' => [
122+
['\PHPUnit\TestCase'],
123+
'PHPUnit\TestCase',
124+
true,
125+
];
126+
127+
yield 'namespaced name registered; (FQ) match' => [
128+
['PHPUnit\TestCase'],
129+
'\PHPUnit\TestCase',
130+
true,
131+
];
132+
121133
yield 'namespaced name registered; different case' => [
122134
['PHPUnit\TestCase'],
123135
'PHPUNIT\TESTCASE',

0 commit comments

Comments
 (0)