1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00
This commit is contained in:
Daniil Gentili 2023-10-21 19:02:17 +02:00
parent b62fe44982
commit 46ae91e6c1
11 changed files with 12 additions and 15 deletions

View File

@ -154,7 +154,7 @@ class AsyncTestCase extends BaseAsyncTestCase
*/
public static function assertArrayKeysAreZeroOrString(array $array, string $message = ''): void
{
$isZeroOrString = /** @param mixed $key */ fn($key): bool => $key === 0 || is_string($key);
$isZeroOrString = /** @param mixed $key */ static fn($key): bool => $key === 0 || is_string($key);
$validKeys = array_filter($array, $isZeroOrString, ARRAY_FILTER_USE_KEY);
self::assertTrue(count($array) === count($validKeys), $message);
}

View File

@ -161,7 +161,7 @@ class CodebaseTest extends TestCase
? (string)$stmt->extends->getAttribute('resolvedName')
: '';
$storage->custom_metadata['implements'] = array_map(
fn(Name $aspect): string => (string)$aspect->getAttribute('resolvedName'),
static fn(Name $aspect): string => (string)$aspect->getAttribute('resolvedName'),
$stmt->implements,
);
$storage->custom_metadata['a'] = 'b';

View File

@ -1108,7 +1108,7 @@ class ConfigTest extends TestCase
* @param string $issue_name
* @return string
*/
fn($issue_name): string => '<' . $issue_name . ' errorLevel="suppress" />' . "\n",
static fn($issue_name): string => '<' . $issue_name . ' errorLevel="suppress" />' . "\n",
IssueHandler::getAllIssueTypes(),
),
);

View File

@ -56,11 +56,10 @@ class CustomArrayMapFunctionStorageProvider implements DynamicFunctionStoragePro
$custom_array_map_storage->return_type = self::createReturnType($all_expected_callables);
$custom_array_map_storage->params = [
...array_map(
function (TCallable $expected, int $offset) {
static function (TCallable $expected, int $offset) {
$t = new Union([$expected]);
$param = new FunctionLikeParameter('fn' . $offset, false, $t, $t);
$param->is_optional = false;
return $param;
},
$all_expected_callables,

View File

@ -348,7 +348,7 @@ class DocumentationTest extends TestCase
$duplicate_shortcodes = array_filter(
$all_shortcodes,
fn($issues): bool => count($issues) > 1
static fn($issues): bool => count($issues) > 1
);
$this->assertEquals(

View File

@ -64,7 +64,7 @@ class FileDiffTest extends TestCase
* @param array{0: int, 1: int, 2: int, 3: int} $arr
* @return array{0: int, 1: int}
*/
fn(array $arr): array => [$arr[2], $arr[3]],
static fn(array $arr): array => [$arr[2], $arr[3]],
$diff[3],
);
@ -135,7 +135,7 @@ class FileDiffTest extends TestCase
* @param array{0: int, 1: int, 2: int, 3: int} $arr
* @return array{0: int, 1: int}
*/
fn(array $arr): array => [$arr[2], $arr[3]],
static fn(array $arr): array => [$arr[2], $arr[3]],
$diff[3],
);

View File

@ -2602,7 +2602,7 @@ class TaintTest extends TestCase
$this->analyzeFile($filePath, new Context(), false);
$actualIssueTypes = array_map(
fn(IssueData $issue): string => $issue->type . '{ ' . trim($issue->snippet) . ' }',
static fn(IssueData $issue): string => $issue->type . '{ ' . trim($issue->snippet) . ' }',
IssueBuffer::getIssuesDataForFile($filePath),
);
self::assertSame($expectedIssuesTypes, $actualIssueTypes);

View File

@ -151,7 +151,7 @@ class TestCase extends BaseTestCase
public static function assertArrayKeysAreZeroOrString(array $array, string $message = ''): void
{
$isZeroOrString = /** @param mixed $key */ fn($key): bool => $key === 0 || is_string($key);
$isZeroOrString = /** @param mixed $key */ static fn($key): bool => $key === 0 || is_string($key);
$validKeys = array_filter($array, $isZeroOrString, ARRAY_FILTER_USE_KEY);
self::assertTrue(count($array) === count($validKeys), $message);
}

View File

@ -90,7 +90,7 @@ class TypeComparatorTest extends TestCase
$basic_types['list{123}'] = true;
return array_map(
fn($type) => [$type],
static fn($type) => [$type],
array_keys($basic_types),
);
}

View File

@ -9,7 +9,7 @@ foreach ($GLOBALS as $key => $_) {
$GLOBALS[$key] = new Exception;
}
spl_autoload_register(function() {
spl_autoload_register(static function () {
// and destroy vars again
// this will run during scanning (?)
foreach ($GLOBALS as $key => $_) {

View File

@ -3,7 +3,7 @@
use React\Promise\PromiseInterface as ReactPromise;
use Composer\InstalledVersions;
spl_autoload_register(function (string $className) {
spl_autoload_register(static function (string $className) {
$knownBadClasses = [
ReactPromise::class, // amphp/amp
ResourceBundle::class, // symfony/polyfill-php73
@ -25,11 +25,9 @@ spl_autoload_register(function (string $className) {
'Symfony\Component\String\s',
'Symfony\Component\Translation\t',
];
if (in_array($className, $knownBadClasses)) {
return;
}
$ex = new RuntimeException('Attempted to load ' . $className);
echo $ex->__toString() . "\n\n" . $ex->getTraceAsString() . "\n\n";
exit(70);