mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Change analyzeMethods to analyze
This commit is contained in:
parent
17329015dc
commit
28cd8caca8
@ -332,7 +332,43 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
|
|||||||
$implemented_method_id = $this->fq_class_name . '::' . $method_name;
|
$implemented_method_id = $this->fq_class_name . '::' . $method_name;
|
||||||
|
|
||||||
MethodChecker::setOverriddenMethodId($implemented_method_id, $mentioned_method_id);
|
MethodChecker::setOverriddenMethodId($implemented_method_id, $mentioned_method_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Context|null $class_context
|
||||||
|
* @param Context|null $global_context
|
||||||
|
* @param bool $update_docblocks
|
||||||
|
* @return null|false
|
||||||
|
*/
|
||||||
|
public function analyze(
|
||||||
|
Context $class_context = null,
|
||||||
|
Context $global_context = null,
|
||||||
|
$update_docblocks = false
|
||||||
|
) {
|
||||||
|
$config = Config::getInstance();
|
||||||
|
|
||||||
|
$fq_class_name = $class_context && $class_context->self ? $class_context->self : $this->fq_class_name;
|
||||||
|
|
||||||
|
$storage = self::$storage[$fq_class_name];
|
||||||
|
|
||||||
|
if ($this instanceof ClassChecker && $this->class instanceof PhpParser\Node\Stmt\Class_) {
|
||||||
|
foreach (ClassChecker::getInterfacesForClass(
|
||||||
|
$this->fq_class_name
|
||||||
|
) as $interface_id => $interface_name) {
|
||||||
|
$interface_storage = self::$storage[$interface_name];
|
||||||
|
|
||||||
|
$storage->public_class_constants += $interface_storage->public_class_constants;
|
||||||
|
|
||||||
|
foreach ($interface_storage->methods as $method_name => $method) {
|
||||||
|
if ($method->visibility === self::VISIBILITY_PUBLIC) {
|
||||||
|
$implemented_method_id = $this->fq_class_name . '::' . $method_name;
|
||||||
|
$mentioned_method_id = $interface_name . '::' . $method_name;
|
||||||
$declaring_method_id = MethodChecker::getDeclaringMethodId($implemented_method_id);
|
$declaring_method_id = MethodChecker::getDeclaringMethodId($implemented_method_id);
|
||||||
|
|
||||||
$method_storage = $declaring_method_id
|
$method_storage = $declaring_method_id
|
||||||
@ -374,26 +410,6 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Context|null $class_context
|
|
||||||
* @param Context|null $global_context
|
|
||||||
* @param bool $update_docblocks
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function analyzeMethods(
|
|
||||||
Context $class_context = null,
|
|
||||||
Context $global_context = null,
|
|
||||||
$update_docblocks = false
|
|
||||||
) {
|
|
||||||
$config = Config::getInstance();
|
|
||||||
|
|
||||||
$fq_class_name = $class_context && $class_context->self ? $class_context->self : $this->fq_class_name;
|
|
||||||
|
|
||||||
$storage = self::$storage[$fq_class_name];
|
|
||||||
|
|
||||||
if (!$class_context) {
|
if (!$class_context) {
|
||||||
$class_context = new Context($this->source->getFileName(), $this->fq_class_name);
|
$class_context = new Context($this->source->getFileName(), $this->fq_class_name);
|
||||||
$class_context->parent = $this->parent_fq_class_name;
|
$class_context->parent = $this->parent_fq_class_name;
|
||||||
@ -444,7 +460,7 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
|
|||||||
|
|
||||||
$trait_checker = self::$trait_checkers[$trait_name];
|
$trait_checker = self::$trait_checkers[$trait_name];
|
||||||
|
|
||||||
$trait_checker->analyzeMethods($class_context, $global_context, $update_docblocks);
|
$trait_checker->analyze($class_context, $global_context, $update_docblocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -289,7 +289,7 @@ class FileChecker extends SourceChecker implements StatementsSource
|
|||||||
* @param boolean $update_docblocks
|
* @param boolean $update_docblocks
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function analyzeMethods($update_docblocks = false)
|
public function analyze($update_docblocks = false)
|
||||||
{
|
{
|
||||||
$config = Config::getInstance();
|
$config = Config::getInstance();
|
||||||
|
|
||||||
@ -298,11 +298,11 @@ class FileChecker extends SourceChecker implements StatementsSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->namespace_checkers as $namespace_checker) {
|
foreach ($this->namespace_checkers as $namespace_checker) {
|
||||||
$namespace_checker->analyzeMethods(clone $this->context);
|
$namespace_checker->analyze(clone $this->context);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->class_checkers as $class_checker) {
|
foreach ($this->class_checkers as $class_checker) {
|
||||||
$class_checker->analyzeMethods(null, $this->context, $update_docblocks);
|
$class_checker->analyze(null, $this->context, $update_docblocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->function_checkers as $function_checker) {
|
foreach ($this->function_checkers as $function_checker) {
|
||||||
@ -332,6 +332,8 @@ class FileChecker extends SourceChecker implements StatementsSource
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->namespace_checkers = [];
|
||||||
|
|
||||||
$this->class_checkers = [];
|
$this->class_checkers = [];
|
||||||
|
|
||||||
$this->function_checkers = [];
|
$this->function_checkers = [];
|
||||||
@ -361,7 +363,7 @@ class FileChecker extends SourceChecker implements StatementsSource
|
|||||||
public function visitAndAnalyzeMethods(Context $file_context = null, $update_docblocks = false)
|
public function visitAndAnalyzeMethods(Context $file_context = null, $update_docblocks = false)
|
||||||
{
|
{
|
||||||
$this->visit($file_context);
|
$this->visit($file_context);
|
||||||
$this->analyzeMethods($update_docblocks);
|
$this->analyze($update_docblocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -202,7 +202,7 @@ class MethodChecker extends FunctionLikeChecker
|
|||||||
* @param array<string> $suppressed_issues
|
* @param array<string> $suppressed_issues
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function analyzeMethodstatic(
|
public static function analyzetatic(
|
||||||
$method_id,
|
$method_id,
|
||||||
$self_call,
|
$self_call,
|
||||||
CodeLocation $code_location,
|
CodeLocation $code_location,
|
||||||
|
@ -102,10 +102,10 @@ class NamespaceChecker extends SourceChecker implements StatementsSource
|
|||||||
* @param Context $context
|
* @param Context $context
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function analyzeMethods(Context $context)
|
public function analyze(Context $context)
|
||||||
{
|
{
|
||||||
foreach ($this->class_checkers as $class_checker) {
|
foreach ($this->class_checkers as $class_checker) {
|
||||||
$class_checker->analyzeMethods(null, $context);
|
$class_checker->analyze(null, $context);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->class_checkers = [];
|
$this->class_checkers = [];
|
||||||
|
@ -204,7 +204,7 @@ class ProjectChecker
|
|||||||
echo 'Analyzing ' . $file_checker->getFilePath() . PHP_EOL;
|
echo 'Analyzing ' . $file_checker->getFilePath() . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_checker->analyzeMethods();
|
$file_checker->analyze();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,7 +368,7 @@ class ProjectChecker
|
|||||||
}
|
}
|
||||||
|
|
||||||
$file_checker->visit();
|
$file_checker->visit();
|
||||||
$file_checker->analyzeMethods();
|
$file_checker->analyze();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,7 +414,7 @@ class ProjectChecker
|
|||||||
echo 'Analyzing ' . $file_checker->getFilePath() . PHP_EOL;
|
echo 'Analyzing ' . $file_checker->getFilePath() . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_checker->analyzeMethods();
|
$file_checker->analyze();
|
||||||
|
|
||||||
IssueBuffer::finish(false, $start_checks, $this->debug_output);
|
IssueBuffer::finish(false, $start_checks, $this->debug_output);
|
||||||
}
|
}
|
||||||
@ -451,7 +451,7 @@ class ProjectChecker
|
|||||||
echo 'Analyzing ' . $file_checker->getFilePath() . PHP_EOL;
|
echo 'Analyzing ' . $file_checker->getFilePath() . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_checker->analyzeMethods();
|
$file_checker->analyze();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -796,7 +796,7 @@ class CallChecker
|
|||||||
|| !ClassChecker::classExtends($context->self, $fq_class_name)
|
|| !ClassChecker::classExtends($context->self, $fq_class_name)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if (MethodChecker::analyzeMethodstatic(
|
if (MethodChecker::analyzetatic(
|
||||||
$method_id,
|
$method_id,
|
||||||
$stmt->class instanceof PhpParser\Node\Name && $stmt->class->parts[0] === 'self',
|
$stmt->class instanceof PhpParser\Node\Name && $stmt->class->parts[0] === 'self',
|
||||||
new CodeLocation($statements_checker->getSource(), $stmt),
|
new CodeLocation($statements_checker->getSource(), $stmt),
|
||||||
|
Loading…
Reference in New Issue
Block a user