Skip to content

Commit 01584fb

Browse files
committed
Fix ext priority
1 parent 35df97f commit 01584fb

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

src/UsedSymbolExtractor.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,15 @@ public function parseUsedSymbols(
155155
break;
156156
}
157157

158-
if (isset($extensionSymbols[$lowerName])) {
159-
$symbolName = $name;
160-
$kind = $extensionSymbols[$lowerName];
161-
$usedSymbols[$kind][$symbolName][] = $token[2];
162-
163-
} elseif (isset($useStatements[$name])) {
158+
if (isset($useStatements[$name])) {
164159
$symbolName = $useStatements[$name];
165160
$kind = $useStatementKinds[$name];
166161
$usedSymbols[$kind][$symbolName][] = $token[2];
162+
163+
} elseif (isset($extensionSymbols[$lowerName])) {
164+
$symbolName = $name;
165+
$kind = $extensionSymbols[$lowerName];
166+
$usedSymbols[$kind][$symbolName][] = $token[2];
167167
}
168168

169169
break;

tests/UsedSymbolExtractorTest.php

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function test(string $path, array $expectedUsages): void
2525
$expectedUsages,
2626
$extractor->parseUsedSymbols(
2727
[
28+
strtolower('XMLReader') => SymbolKind::CLASSLIKE,
2829
strtolower('PDO') => SymbolKind::CLASSLIKE,
2930
strtolower('json_encode') => SymbolKind::FUNCTION,
3031
strtolower('DDTrace\active_span') => SymbolKind::FUNCTION,
@@ -153,6 +154,7 @@ public function provideVariants(): iterable
153154
],
154155
SymbolKind::CLASSLIKE => [
155156
'PDO' => [11],
157+
'My\App\XMLReader' => [15],
156158
'CURLOPT_SSL_VERIFYHOST' => [19],
157159
],
158160
],
@@ -174,6 +176,7 @@ public function provideVariants(): iterable
174176
],
175177
SymbolKind::CLASSLIKE => [
176178
'PDO' => [11],
179+
'My\App\XMLReader' => [15],
177180
'CURLOPT_SSL_VERIFYHOST' => [19],
178181
],
179182
],

tests/data/not-autoloaded/used-symbols/extensions-global.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44

5-
5+
use My\App\XMLReader;
66
use function DDTrace\active_span;
77

88
json_encode('');
@@ -12,7 +12,7 @@
1212
active_span();
1313
DDTrace\root_span();
1414
DDTrace\DBM_PROPAGATION_FULL;
15-
15+
XMLReader::class;
1616

1717

1818
// those are not provided as known ext symbols in the test

tests/data/not-autoloaded/used-symbols/extensions.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
2-
32
namespace Extensions;
43

54
use DDTrace;
65
use function DDTrace\active_span;
6+
use My\App\XMLReader;
77

88
json_encode('');
99
LIBXML_ERR_FATAL;
@@ -12,7 +12,7 @@
1212
active_span();
1313
DDTrace\root_span();
1414
DDTrace\DBM_PROPAGATION_FULL;
15-
15+
XMLReader::class;
1616

1717

1818
// those are not provided as known ext symbols in the test

0 commit comments

Comments
 (0)