1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
<?php
declare(strict_types=1);
namespace Shirabe\PluginClassifier;
/**
* Package-level classification of composer/composer's runtime vendor
* dependencies, applied by namespace prefix. See the "Mechanical rules"
* step 6 in docs/dev/plugin-class-classification.md for the criterion.
*/
final class VendorPackages
{
/** @var array<string, array{package: string, category: string}> prefix => info */
public const PREFIXES = [
'Composer\\Semver\\' => ['package' => 'composer/semver', 'category' => 'php-native'],
'Composer\\Pcre\\' => ['package' => 'composer/pcre', 'category' => 'php-native'],
'Composer\\CaBundle\\' => ['package' => 'composer/ca-bundle', 'category' => 'php-native'],
'Composer\\ClassMapGenerator\\' => ['package' => 'composer/class-map-generator', 'category' => 'php-native'],
'Composer\\MetadataMinifier\\' => ['package' => 'composer/metadata-minifier', 'category' => 'php-native'],
'Composer\\Spdx\\' => ['package' => 'composer/spdx-licenses', 'category' => 'php-native'],
'Composer\\XdebugHandler\\' => ['package' => 'composer/xdebug-handler', 'category' => 'php-native'],
'JsonSchema\\' => ['package' => 'justinrainbow/json-schema', 'category' => 'php-native'],
'Seld\\JsonLint\\' => ['package' => 'seld/jsonlint', 'category' => 'php-native'],
'Seld\\PharUtils\\' => ['package' => 'seld/phar-utils', 'category' => 'php-native'],
'Seld\\Signal\\' => ['package' => 'seld/signal-handler', 'category' => 'php-native'],
'Psr\\Log\\' => ['package' => 'psr/log', 'category' => 'php-native'],
'React\\Promise\\' => ['package' => 'react/promise', 'category' => 'contract'],
'Symfony\\Component\\Console\\' => ['package' => 'symfony/console', 'category' => 'two-world'],
'Symfony\\Component\\Process\\' => ['package' => 'symfony/process', 'category' => 'php-native'],
'Symfony\\Component\\Filesystem\\' => ['package' => 'symfony/filesystem', 'category' => 'php-native'],
'Symfony\\Component\\Finder\\' => ['package' => 'symfony/finder', 'category' => 'php-native'],
'Symfony\\Polyfill\\' => ['package' => 'symfony/polyfill', 'category' => 'php-native'],
];
/**
* By-ref parameter positions of vendor methods, needed by the purity
* analysis when composer code passes $this-rooted expressions to them.
* Vendor packages other than composer/pcre expose no by-ref parameters
* in APIs composer calls; composer/pcre's output parameter is pervasive.
*
* @var array<string, array<string, list<int>>> FQCN => lowercase method => positions
*/
public const BY_REF = [
'Composer\\Pcre\\Preg' => [
'match' => [2],
'matchstrictgroups' => [2],
'ismatch' => [2],
'ismatchstrictgroups' => [2],
'matchall' => [2],
'matchallstrictgroups' => [2],
'ismatchall' => [2],
'ismatchallstrictgroups' => [2],
],
'Composer\\Pcre\\Regex' => [],
];
/** @return array{package: string, category: string}|null */
public static function lookup(string $fqcn): ?array
{
foreach (self::PREFIXES as $prefix => $info) {
if (str_starts_with($fqcn, $prefix)) {
return $info;
}
}
return null;
}
}
|