Skip to content

Commit

Permalink
Remove removed funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
danog committed Jan 25, 2025
1 parent 4f0439d commit 74db0e9
Show file tree
Hide file tree
Showing 30 changed files with 1,360 additions and 6,151 deletions.
64 changes: 48 additions & 16 deletions bin/gen_callmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@

$codebase = ProjectAnalyzer::getInstance()->getCodebase();

$allFuncs = [];

// Load+normalize autogenerated maps
$baseMaps = [];
foreach (glob(__DIR__."/../dictionaries/autogen/CallMap_*.php") as $file) {
Assert::eq(preg_match('/_(\d+)\.php/', $file, $matches), 1);
$version = $matches[1];

$baseMaps[$version] = normalizeCallMap(require $file);
$allFuncs += $baseMaps[$version];

$baseMaps[$version]['debug_zval_dump'] = [
0 => 'void',
'value' => 'mixed',
Expand All @@ -37,7 +41,7 @@
'&var' => 'array<array-key, mixed>|object|string',
'...&vars=' => 'array<array-key, mixed>|object|string',
];
$baseMaps[$version] = [
$baseMaps[$version]['closure::__invoke'] = [
0 => 'mixed',
'...args=' => 'mixed',
];
Expand All @@ -51,21 +55,21 @@
}
if (count($baseMaps[$version]['amqpbasicproperties::__construct']) === 1) {
$baseMaps[$version]['amqpbasicproperties::__construct'] = [
0 => 'void',
'contentType=' => 'null|string',
'contentEncoding=' => 'null|string',
'headers=' => 'array<array-key, mixed>',
'deliveryMode=' => 'int',
'priority=' => 'int',
'correlationId=' => 'null|string',
'replyTo=' => 'null|string',
'expiration=' => 'null|string',
'messageId=' => 'null|string',
'timestamp=' => 'int|null',
'type=' => 'null|string',
'userId=' => 'null|string',
'appId=' => 'null|string',
'clusterId=' => 'null|string',
0 => 'void',
'contentType=' => 'null|string',
'contentEncoding=' => 'null|string',
'headers=' => 'array<array-key, mixed>',
'deliveryMode=' => 'int',
'priority=' => 'int',
'correlationId=' => 'null|string',
'replyTo=' => 'null|string',
'expiration=' => 'null|string',
'messageId=' => 'null|string',
'timestamp=' => 'int|null',
'type=' => 'null|string',
'userId=' => 'null|string',
'appId=' => 'null|string',
'clusterId=' => 'null|string',
];
}
if (isset($baseMaps[$version]['file_get_contents']['flags='])) {
Expand Down Expand Up @@ -128,11 +132,39 @@
if (isset($baseMaps[$version][$func])) {
$baseParams = $baseMaps[$version][$func];
$params = assertEntryParameters($func, $baseParams, $params);
} else if (!str_contains($func, "'")
&& !str_starts_with($func, 'apache')
&& !str_starts_with($func, 'ftp')
&& !str_starts_with($func, 'db2')
&& $func !== 'exit'
&& isset($allFuncs[$func])
) {
unset($data[$func]);
}
} unset($params);
$data = normalizeCallMap($data);
} unset($data);

$equal = [];
foreach ($baseMaps as $version => $data) {
foreach ($data as $func => $params) {
$customParams = $customMaps[$version][$func] ?? null;
if ($params === $customParams) {
$equal[$func] ??= true;
} else {
$equal[$func] = false;
}
}
}

foreach ($equal as $func => $ok) {
if ($ok) {
foreach ($customMaps as &$data) {
//unset($data[$func]);
} unset($data);
}
}

// Merge hand-written full maps into autogenerated full maps, write to files
foreach ($customMaps as $version => $data) {
$data = normalizeCallMap(array_replace($baseMaps[$version] ?? [], $data));
Expand Down
Loading

0 comments on commit 74db0e9

Please sign in to comment.