diff --git a/tests/AsyncTestCase.php b/tests/AsyncTestCase.php index 0e89d7659..09c0eb810 100644 --- a/tests/AsyncTestCase.php +++ b/tests/AsyncTestCase.php @@ -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); } diff --git a/tests/CodebaseTest.php b/tests/CodebaseTest.php index 0a1764307..d10d92014 100644 --- a/tests/CodebaseTest.php +++ b/tests/CodebaseTest.php @@ -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'; diff --git a/tests/Config/ConfigTest.php b/tests/Config/ConfigTest.php index 9fa8042c5..34a5b06f9 100644 --- a/tests/Config/ConfigTest.php +++ b/tests/Config/ConfigTest.php @@ -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(), ), ); diff --git a/tests/Config/Plugin/Hook/CustomArrayMapFunctionStorageProvider.php b/tests/Config/Plugin/Hook/CustomArrayMapFunctionStorageProvider.php index fb2853f35..cb3284754 100644 --- a/tests/Config/Plugin/Hook/CustomArrayMapFunctionStorageProvider.php +++ b/tests/Config/Plugin/Hook/CustomArrayMapFunctionStorageProvider.php @@ -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, diff --git a/tests/DocumentationTest.php b/tests/DocumentationTest.php index 9768eecfa..d86293a82 100644 --- a/tests/DocumentationTest.php +++ b/tests/DocumentationTest.php @@ -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( diff --git a/tests/FileDiffTest.php b/tests/FileDiffTest.php index 0e7982552..2e206537b 100644 --- a/tests/FileDiffTest.php +++ b/tests/FileDiffTest.php @@ -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], ); diff --git a/tests/TaintTest.php b/tests/TaintTest.php index f83d45bae..4e7c2bda4 100644 --- a/tests/TaintTest.php +++ b/tests/TaintTest.php @@ -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); diff --git a/tests/TestCase.php b/tests/TestCase.php index 8e61664f8..5ddeebd3b 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -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); } diff --git a/tests/TypeComparatorTest.php b/tests/TypeComparatorTest.php index 434a1f304..00ad55bea 100644 --- a/tests/TypeComparatorTest.php +++ b/tests/TypeComparatorTest.php @@ -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), ); } diff --git a/tests/fixtures/DestructiveAutoloader/autoloader.php b/tests/fixtures/DestructiveAutoloader/autoloader.php index 17cb0a152..37a8624de 100644 --- a/tests/fixtures/DestructiveAutoloader/autoloader.php +++ b/tests/fixtures/DestructiveAutoloader/autoloader.php @@ -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 => $_) { diff --git a/tests/fixtures/SuicidalAutoloader/autoloader.php b/tests/fixtures/SuicidalAutoloader/autoloader.php index 365fa7b72..d506219c1 100644 --- a/tests/fixtures/SuicidalAutoloader/autoloader.php +++ b/tests/fixtures/SuicidalAutoloader/autoloader.php @@ -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);