1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Speed up analysis phase

This commit is contained in:
Brown 2018-10-18 09:51:28 -04:00
parent b7c438bf97
commit 4ed5c4bcc6
3 changed files with 16 additions and 8 deletions

View File

@ -310,16 +310,14 @@ class Analyzer
$all_referencing_methods = $project_checker->file_reference_provider->getMethodsReferencing();
$classlikes = $project_checker->codebase->classlikes;
foreach ($all_referencing_methods as $member_id => $referencing_method_ids) {
$member_class_name = preg_replace('/::.*$/', '', $member_id);
try {
$member_class_storage = $this->classlike_storage_provider->get($member_class_name);
} catch (\Exception $e) {
$member_class_storage = null;
}
if ($member_class_storage && !$member_class_storage->is_trait) {
if ($classlikes->hasFullyQualifiedClassLikeName($member_class_name)
&& !$classlikes->hasFullyQualifiedTraitName($member_class_name)
) {
continue;
}

View File

@ -225,6 +225,16 @@ class ClassLikes
}
}
/**
* @param string $fq_class_name_lc
*
* @return void
*/
public function hasFullyQualifiedClassLikeName($fq_class_name_lc)
{
return isset($this->existing_classlikes_lc[$fq_class_name_lc]);
}
/**
* @param string $fq_class_name
*

View File

@ -291,7 +291,7 @@ class StatementsProvider
'comments', 'startLine', 'startFilePos', 'endFilePos',
];
$lexer = new PhpParser\Lexer\Emulative([ 'usedAttributes' => $attributes ]);
$lexer = new PhpParser\Lexer([ 'usedAttributes' => $attributes ]);
self::$parser = (new PhpParser\ParserFactory())->create(PhpParser\ParserFactory::PREFER_PHP7, $lexer);
}