mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Improve dead code analysis and fix errors found
This commit is contained in:
parent
5ec2a9742b
commit
ec65f31aaa
@ -1561,8 +1561,6 @@ abstract class ClassLikeChecker extends SourceChecker implements StatementsSourc
|
||||
|
||||
list($fq_class_name, $property_name) = explode('::$', $property_id);
|
||||
|
||||
$old_property_id = null;
|
||||
|
||||
if (!isset(self::$storage[strtolower($fq_class_name)])) {
|
||||
throw new \UnexpectedValueException(
|
||||
'Storage not defined for ' . $property_id
|
||||
|
@ -1012,8 +1012,6 @@ class FileChecker extends SourceChecker implements StatementsSource
|
||||
$function_line = $file_lines[$line_number - 1];
|
||||
$left_padding = str_replace(ltrim($function_line), '', $function_line);
|
||||
|
||||
$line_before = $file_lines[$line_number - 2];
|
||||
|
||||
$parsed_docblock = [];
|
||||
$existing_line_count = $existing_docblock ? substr_count($existing_docblock, PHP_EOL) + 1 : 0;
|
||||
|
||||
|
@ -556,8 +556,6 @@ class MethodChecker extends FunctionLikeChecker
|
||||
|
||||
list($fq_class_name, $method_name) = explode('::', $method_id);
|
||||
|
||||
$fq_class_name = $fq_class_name;
|
||||
|
||||
if (!isset(ClassLikeChecker::$storage[$fq_class_name])) {
|
||||
throw new \UnexpectedValueException('$storage should not be null for ' . $fq_class_name);
|
||||
}
|
||||
|
@ -492,8 +492,6 @@ class ProjectChecker
|
||||
|
||||
$file_name_parts = explode('.', $file_name);
|
||||
|
||||
$extension = array_pop($file_name_parts);
|
||||
|
||||
$filetype_handlers = $this->config->getFiletypeHandlers();
|
||||
|
||||
FileChecker::loadReferenceCache();
|
||||
@ -824,8 +822,6 @@ class ProjectChecker
|
||||
throw new Exception\ConfigException('Config not found at location ' . $path_to_config);
|
||||
}
|
||||
|
||||
$dir_path = dirname($path_to_config) . DIRECTORY_SEPARATOR;
|
||||
|
||||
$this->config = Config::loadFromXMLFile($path_to_config);
|
||||
}
|
||||
|
||||
|
@ -254,7 +254,7 @@ class AssignmentChecker
|
||||
$context->vars_possibly_in_scope[$var_id] = true;
|
||||
}
|
||||
|
||||
if ($var_id && $context->hasVariable($var_id) && $context->vars_in_scope[$var_id]->isVoid()) {
|
||||
if ($var_id && isset($context->vars_in_scope[$var_id]) && $context->vars_in_scope[$var_id]->isVoid()) {
|
||||
if (IssueBuffer::accepts(
|
||||
new FailedTypeResolution(
|
||||
'Cannot assign ' . $var_id . ' to type void',
|
||||
|
@ -559,9 +559,9 @@ class CallChecker
|
||||
/** @var Type\Union|null */
|
||||
$return_type = null;
|
||||
|
||||
foreach ($class_type->types as $type) {
|
||||
if (!$type instanceof TNamedObject) {
|
||||
switch (get_class($type)) {
|
||||
foreach ($class_type->types as $class_type_part) {
|
||||
if (!$class_type_part instanceof TNamedObject) {
|
||||
switch (get_class($class_type_part)) {
|
||||
case 'Psalm\\Type\\Atomic\\TNull':
|
||||
if (IssueBuffer::accepts(
|
||||
new NullReference(
|
||||
@ -608,7 +608,7 @@ class CallChecker
|
||||
continue;
|
||||
}
|
||||
|
||||
$fq_class_name = $type->value;
|
||||
$fq_class_name = $class_type_part->value;
|
||||
|
||||
$is_mock = ExpressionChecker::isMock($fq_class_name);
|
||||
|
||||
|
@ -46,8 +46,6 @@ class StatementsChecker extends SourceChecker implements StatementsSource
|
||||
public function __construct(StatementsSource $source)
|
||||
{
|
||||
$this->source = $source;
|
||||
|
||||
$config = Config::getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +150,6 @@ class IssueBuffer
|
||||
protected static function getEmacsOutput(Issue\CodeIssue $e, $severity = Config::REPORT_ERROR)
|
||||
{
|
||||
$location = $e->getLocation();
|
||||
$selection_bounds = $location->getSelectionBounds();
|
||||
|
||||
return $location->file_path . ':' . $location->getLineNumber() . ':' . $location->getColumn() . ': ' .
|
||||
($severity === Config::REPORT_ERROR ? 'error' : 'warning') . ' - ' . $e->getMessage();
|
||||
|
Loading…
Reference in New Issue
Block a user