Skip to content

Commit 1d45aa8

Browse files
committed
Cleanup
1 parent 64f4efc commit 1d45aa8

4 files changed

+32
-46
lines changed

bin/gen_base_callmap.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,17 @@
1515
}
1616

1717
foreach (get_declared_classes() as $class) {
18-
foreach ((new ReflectionClass($class))->getMethods() as $method) {
18+
$refl = new ReflectionClass($class);
19+
if (!$refl->isInternal()) {
20+
continue;
21+
}
22+
23+
foreach ($refl->getMethods() as $method) {
1924
$args = paramsToEntries($method);
2025

2126
$callmap[$class.'::'.$method->getName()] = $args;
2227
}
2328
}
2429

30+
$callmap = normalizeCallMap($callmap);
2531
var_dump($callmap);

bin/gen_callmap.php

-23
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,8 @@
44

55
// Written by SamMousa in https://github.com/vimeo/psalm/issues/8101, finalized by @danog
66

7-
require 'vendor/autoload.php';
8-
97
require __DIR__ . '/gen_callmap_utils.php';
108

11-
use DG\BypassFinals;
12-
use Psalm\Internal\Analyzer\ProjectAnalyzer;
13-
use Psalm\Internal\Provider\FileProvider;
14-
use Psalm\Internal\Provider\Providers;
15-
use Psalm\Tests\TestConfig;
16-
17-
BypassFinals::enable();
18-
19-
function writeCallMap(string $file, array $callMap): void
20-
{
21-
file_put_contents($file, '<?php // phpcs:ignoreFile
22-
23-
return '.var_export($callMap, true).';');
24-
}
25-
26-
new ProjectAnalyzer(new TestConfig, new Providers(new FileProvider));
27-
$callMap = require "dictionaries/CallMap.php";
28-
$orig = $callMap;
29-
30-
$codebase = ProjectAnalyzer::getInstance()->getCodebase();
31-
329
foreach ($callMap as $functionName => &$entry) {
3310
$refl = getReflectionFunction($functionName);
3411
if (!$refl) {

bin/gen_callmap_utils.php

+23
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
declare(strict_types=1);
44

5+
require 'vendor/autoload.php';
6+
7+
use DG\BypassFinals;
8+
use Psalm\Internal\Analyzer\ProjectAnalyzer;
9+
use Psalm\Internal\Provider\FileProvider;
10+
use Psalm\Internal\Provider\Providers;
11+
use Psalm\Tests\TestConfig;
512
use Psalm\Type;
613

714
function internalNormalizeCallMap(array|string $callMap): array|string {
@@ -227,3 +234,19 @@ function assertTypeValidity(ReflectionType $reflected, string &$specified, strin
227234
// $this->assertSame($expectedType->hasInt(), $callMapType->hasInt(), "{$msgPrefix} type '{$specified}' missing int from reflected type '{$reflected}'");
228235
// $this->assertSame($expectedType->hasFloat(), $callMapType->hasFloat(), "{$msgPrefix} type '{$specified}' missing float from reflected type '{$reflected}'");
229236
}
237+
238+
function writeCallMap(string $file, array $callMap): void
239+
{
240+
file_put_contents($file, '<?php // phpcs:ignoreFile
241+
242+
return '.var_export($callMap, true).';');
243+
}
244+
245+
246+
BypassFinals::enable();
247+
248+
new ProjectAnalyzer(new TestConfig, new Providers(new FileProvider));
249+
$callMap = require "dictionaries/CallMap.php";
250+
$orig = $callMap;
251+
252+
$codebase = ProjectAnalyzer::getInstance()->getCodebase();

bin/normalize-callmap.php

+2-22
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,10 @@
22

33
declare(strict_types=1);
44

5-
require 'vendor/autoload.php';
6-
75
require __DIR__ . '/gen_callmap_utils.php';
86

9-
use DG\BypassFinals;
10-
use Psalm\Internal\Analyzer\ProjectAnalyzer;
11-
use Psalm\Internal\Provider\FileProvider;
12-
use Psalm\Internal\Provider\Providers;
13-
use Psalm\Tests\TestConfig;
14-
use Psalm\Type;
15-
16-
BypassFinals::enable();
17-
18-
new ProjectAnalyzer(new TestConfig, new Providers(new FileProvider));
19-
20-
$codebase = ProjectAnalyzer::getInstance()->getCodebase();
21-
22-
chdir(__DIR__.'/../');
23-
24-
foreach (glob("dictionaries/CallMap*.php") as $file) {
7+
foreach (glob(__DIR__."/../dictionaries/CallMap*.php") as $file) {
258
$callMap = require $file;
269
$callMap = normalizeCallMap($callMap);
27-
28-
file_put_contents($file, '<?php // phpcs:ignoreFile
29-
30-
return '.var_export($callMap, true).';');
10+
writeCallMap($file, $callMap);
3111
}

0 commit comments

Comments
 (0)