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

Fix #975 - don’t check things at all when there’s a duplicate class

This commit is contained in:
Matthew Brown 2018-09-04 21:22:05 -04:00
parent add7c14b44
commit 7c274431f0
2 changed files with 26 additions and 6 deletions

View File

@ -85,6 +85,10 @@ class ClassChecker extends ClassLikeChecker
$storage = $this->storage;
if ($storage->has_visitor_issues) {
return;
}
if ($class->name && preg_match(
'/(^|\\\)(int|float|bool|string|void|null|false|true|resource|object|numeric|mixed)$/i',
$fq_class_name
@ -890,12 +894,6 @@ class ClassChecker extends ClassLikeChecker
$return_type_location = null;
$secondary_return_type_location = null;
$self_class = $classlike_storage_provider->get($class_context->self);
if ($self_class->has_visitor_issues) {
return;
}
$actual_method_storage = $codebase->methods->getStorage($actual_method_id);
if (!$actual_method_storage->has_template_return_type) {

View File

@ -449,11 +449,15 @@ class IncludeTest extends TestCase
'files' => [
getcwd() . DIRECTORY_SEPARATOR . 'file1.php' => '<?php
class A {
/** @var string|null */
protected $a;
public function aa() : void {}
public function bb() : void { $this->aa(); }
}',
getcwd() . DIRECTORY_SEPARATOR . 'file2.php' => '<?php
class A {
/** @var string|null */
protected $b;
public function dd() : void {}
public function zz() : void { $this->dd(); }
}',
@ -465,6 +469,24 @@ class IncludeTest extends TestCase
'hoist_constants' => false,
'error_levels' => ['DuplicateClass'],
],
'duplicateClassesProperty' => [
'files' => [
getcwd() . DIRECTORY_SEPARATOR . 'file1.php' => '<?php
class A {
protected $a;
}',
getcwd() . DIRECTORY_SEPARATOR . 'file2.php' => '<?php
class A {
protected $b;
}',
],
'files_to_check' => [
getcwd() . DIRECTORY_SEPARATOR . 'file1.php',
getcwd() . DIRECTORY_SEPARATOR . 'file2.php',
],
'hoist_constants' => false,
'error_levels' => ['DuplicateClass', 'MissingPropertyType'],
],
];
}