diff --git a/bin/gen_base_callmap.php b/bin/gen_base_callmap.php index 0c80a900992..4bd015e33d3 100644 --- a/bin/gen_base_callmap.php +++ b/bin/gen_base_callmap.php @@ -15,11 +15,17 @@ } foreach (get_declared_classes() as $class) { - foreach ((new ReflectionClass($class))->getMethods() as $method) { + $refl = new ReflectionClass($class); + if (!$refl->isInternal()) { + continue; + } + + foreach ($refl->getMethods() as $method) { $args = paramsToEntries($method); $callmap[$class.'::'.$method->getName()] = $args; } } +$callmap = normalizeCallMap($callmap); var_dump($callmap); \ No newline at end of file diff --git a/bin/gen_callmap.php b/bin/gen_callmap.php index f94a64f47b0..22dadb5e9b4 100644 --- a/bin/gen_callmap.php +++ b/bin/gen_callmap.php @@ -4,31 +4,8 @@ // Written by SamMousa in https://github.com/vimeo/psalm/issues/8101, finalized by @danog -require 'vendor/autoload.php'; - require __DIR__ . '/gen_callmap_utils.php'; -use DG\BypassFinals; -use Psalm\Internal\Analyzer\ProjectAnalyzer; -use Psalm\Internal\Provider\FileProvider; -use Psalm\Internal\Provider\Providers; -use Psalm\Tests\TestConfig; - -BypassFinals::enable(); - -function writeCallMap(string $file, array $callMap): void -{ - file_put_contents($file, 'getCodebase(); - 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 30385040a44..e48a132b46b 100644 --- a/bin/gen_callmap_utils.php +++ b/bin/gen_callmap_utils.php @@ -2,6 +2,13 @@ declare(strict_types=1); +require 'vendor/autoload.php'; + +use DG\BypassFinals; +use Psalm\Internal\Analyzer\ProjectAnalyzer; +use Psalm\Internal\Provider\FileProvider; +use Psalm\Internal\Provider\Providers; +use Psalm\Tests\TestConfig; use Psalm\Type; function internalNormalizeCallMap(array|string $callMap): array|string { @@ -227,3 +234,19 @@ function assertTypeValidity(ReflectionType $reflected, string &$specified, strin // $this->assertSame($expectedType->hasInt(), $callMapType->hasInt(), "{$msgPrefix} type '{$specified}' missing int from reflected type '{$reflected}'"); // $this->assertSame($expectedType->hasFloat(), $callMapType->hasFloat(), "{$msgPrefix} type '{$specified}' missing float from reflected type '{$reflected}'"); } + +function writeCallMap(string $file, array $callMap): void +{ + file_put_contents($file, 'getCodebase(); diff --git a/bin/normalize-callmap.php b/bin/normalize-callmap.php index fbb7c64dd1d..00a201c824f 100644 --- a/bin/normalize-callmap.php +++ b/bin/normalize-callmap.php @@ -2,30 +2,10 @@ declare(strict_types=1); -require 'vendor/autoload.php'; - require __DIR__ . '/gen_callmap_utils.php'; -use DG\BypassFinals; -use Psalm\Internal\Analyzer\ProjectAnalyzer; -use Psalm\Internal\Provider\FileProvider; -use Psalm\Internal\Provider\Providers; -use Psalm\Tests\TestConfig; -use Psalm\Type; - -BypassFinals::enable(); - -new ProjectAnalyzer(new TestConfig, new Providers(new FileProvider)); - -$codebase = ProjectAnalyzer::getInstance()->getCodebase(); - -chdir(__DIR__.'/../'); - -foreach (glob("dictionaries/CallMap*.php") as $file) { +foreach (glob(__DIR__."/../dictionaries/CallMap*.php") as $file) { $callMap = require $file; $callMap = normalizeCallMap($callMap); - - file_put_contents($file, '