diff --git a/src/Psalm/Internal/Provider/StatementsProvider.php b/src/Psalm/Internal/Provider/StatementsProvider.php index d190cbb68..e82da8a28 100644 --- a/src/Psalm/Internal/Provider/StatementsProvider.php +++ b/src/Psalm/Internal/Provider/StatementsProvider.php @@ -48,6 +48,11 @@ class StatementsProvider */ private $diff_map = []; + /** + * @var PhpParser\Lexer|null + */ + private static $lexer; + public function __construct( FileProvider $file_provider, ParserCacheProvider $parser_cache_provider = null, @@ -343,9 +348,11 @@ class StatementsProvider 'comments', 'startLine', 'startFilePos', 'endFilePos', ]; - $lexer = new PhpParser\Lexer([ 'usedAttributes' => $attributes ]); + if (!self::$lexer) { + self::$lexer = new PhpParser\Lexer([ 'usedAttributes' => $attributes ]); + } - $parser = (new PhpParser\ParserFactory())->create(PhpParser\ParserFactory::PREFER_PHP7, $lexer); + $parser = (new PhpParser\ParserFactory())->create(PhpParser\ParserFactory::PREFER_PHP7, self::$lexer); $used_cached_statements = false; diff --git a/tests/TestConfig.php b/tests/TestConfig.php index 000d5d0c5..c7ef055c1 100644 --- a/tests/TestConfig.php +++ b/tests/TestConfig.php @@ -48,4 +48,9 @@ class TestConfig extends Config { return false; } + + public function getProjectDirectories() + { + return []; + } }