diff --git a/bin/gen_base_callmap.php b/bin/gen_base_callmap.php index 0efd6ae0693..9ccd930839a 100644 --- a/bin/gen_base_callmap.php +++ b/bin/gen_base_callmap.php @@ -62,7 +62,7 @@ function paramsToEntries(ReflectionFunctionAbstract $reflectionFunction): array $args = paramsToEntries($func); - $callmap[$name] = $args; + $callmap[strtolower($name)] = $args; } foreach (get_declared_classes() as $class) { @@ -74,7 +74,7 @@ function paramsToEntries(ReflectionFunctionAbstract $reflectionFunction): array foreach ($refl->getMethods() as $method) { $args = paramsToEntries($method); - $callmap[$class.'::'.$method->getName()] = $args; + $callmap[strtolower($class.'::'.$method->getName())] = $args; } } diff --git a/bin/gen_callmap.php b/bin/gen_callmap.php index 22dadb5e9b4..a7e15ff8900 100644 --- a/bin/gen_callmap.php +++ b/bin/gen_callmap.php @@ -2,10 +2,11 @@ declare(strict_types=1); -// Written by SamMousa in https://github.com/vimeo/psalm/issues/8101, finalized by @danog - require __DIR__ . '/gen_callmap_utils.php'; +$callMap = require "dictionaries/CallMap.php"; +$orig = $callMap; + foreach ($callMap as $functionName => &$entry) { $refl = getReflectionFunction($functionName); if (!$refl) { diff --git a/bin/gen_callmap_utils.php b/bin/gen_callmap_utils.php index b244ce57155..983f470701e 100644 --- a/bin/gen_callmap_utils.php +++ b/bin/gen_callmap_utils.php @@ -199,7 +199,5 @@ function writeCallMap(string $file, array $callMap): void BypassFinals::enable(); new ProjectAnalyzer(new TestConfig, new Providers(new FileProvider)); -$callMap = require "dictionaries/CallMap.php"; -$orig = $callMap; $codebase = ProjectAnalyzer::getInstance()->getCodebase(); diff --git a/bin/normalize-callmap.php b/bin/normalize-callmap.php index 00a201c824f..f3dee84a59a 100644 --- a/bin/normalize-callmap.php +++ b/bin/normalize-callmap.php @@ -2,10 +2,63 @@ declare(strict_types=1); +use Webmozart\Assert\Assert; + require __DIR__ . '/gen_callmap_utils.php'; -foreach (glob(__DIR__."/../dictionaries/CallMap*.php") as $file) { - $callMap = require $file; - $callMap = normalizeCallMap($callMap); - writeCallMap($file, $callMap); +$baseMaps = []; + +foreach (glob(__DIR__."/../dictionaries/base/CallMap_*.php") as $file) { + Assert::eq(preg_match('/_(\d+)\.php/', $file, $matches), 1); + $version = $matches[1]; + + $baseMaps[$version] = normalizeCallMap(require $file); +} + +ksort($baseMaps); +$last = array_key_last($baseMaps); + +$customMaps = [ + $last => normalizeCallMap(require __DIR__."/../dictionaries/override/CallMap.php") +]; + +$diffs = []; +foreach (glob(__DIR__."/../dictionaries/override/CallMap_*.php") as $file) { + Assert::eq(preg_match('/_(\d+)_delta\.php/', $file, $matches), 1); + $version = $matches[1]; + $diffs[$version] = normalizeCallMap(require $file); } +krsort($diffs); + +$versions = array_reverse(array_keys($diffs)); + +foreach ($diffs as $version => $diff) { + $callMap = $customMaps[$version]; + $diff = normalizeCallMap(require $file); + foreach ($diff['removed'] as $func => $descr) { + $callMap[$func] = $descr; + } + foreach ($diff['added'] as $func => $descr) { + unset($callMap[$func]); + } + foreach ($diff['changed'] as $func => $sub) { + $callMap[$func] = $sub['old']; + } + + $prevVersion = array_search($version, $versions)-1; + if ($prevVersion < 0) { + continue; + } + $customMaps[$versions[$prevVersion]] = $callMap; +} + +foreach ($customMaps as $version => $data) { + foreach ($data as $name => $func) { + if (($baseMaps[$version][$name] ?? null) === $func) { + unset($customMaps[$version][$name]); + } else if(($baseMaps[$version][$name] ?? null)) + var_dump($name, ($baseMaps[$version][$name] ?? null), $func); + } +} + +var_dump($customMaps); \ No newline at end of file