mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix tests
This commit is contained in:
parent
8131f806d8
commit
b274c7dd68
@ -74,6 +74,7 @@ class ClassChecker implements StatementsSource
|
||||
: null;
|
||||
|
||||
self::$_existing_classes[$absolute_class] = true;
|
||||
self::$_existing_classes_ci[strtolower($absolute_class)] = true;
|
||||
|
||||
if (self::$_this_class || $class instanceof PhpParser\Node\Stmt\Trait_) {
|
||||
self::$_class_checkers[$absolute_class] = $this;
|
||||
@ -416,16 +417,21 @@ class ClassChecker implements StatementsSource
|
||||
}
|
||||
|
||||
if (isset(self::$_existing_classes_ci[strtolower($absolute_class)])) {
|
||||
$reflection_class = new ReflectionClass($absolute_class);
|
||||
try {
|
||||
$reflection_class = new ReflectionClass($absolute_class);
|
||||
|
||||
if ($reflection_class->getName() !== $absolute_class) {
|
||||
if (IssueBuffer::accepts(
|
||||
new InvalidClass('Class or interface ' . $absolute_class . ' has wrong casing', $file_name, $line_number),
|
||||
$suppressed_issues
|
||||
)) {
|
||||
return false;
|
||||
if ($reflection_class->getName() !== $absolute_class) {
|
||||
if (IssueBuffer::accepts(
|
||||
new InvalidClass('Class or interface ' . $absolute_class . ' has wrong casing', $file_name, $line_number),
|
||||
$suppressed_issues
|
||||
)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (\ReflectionException $e) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -712,11 +718,21 @@ class ClassChecker implements StatementsSource
|
||||
self::$_this_class = null;
|
||||
|
||||
self::$_existing_classes = [];
|
||||
self::$_existing_classes_ci = [];
|
||||
self::$_existing_interfaces_ci = [];
|
||||
self::$_class_implements = [];
|
||||
|
||||
self::$_class_methods = [];
|
||||
self::$_class_checkers = [];
|
||||
|
||||
self::$_public_class_properties = [];
|
||||
self::$_protected_class_properties = [];
|
||||
self::$_private_class_properties = [];
|
||||
|
||||
self::$_public_static_class_properties = [];
|
||||
self::$_protected_static_class_properties = [];
|
||||
self::$_private_static_class_properties = [];
|
||||
|
||||
self::$_class_extends = [];
|
||||
}
|
||||
}
|
||||
|
@ -29,15 +29,11 @@ class FileChecker implements StatementsSource
|
||||
|
||||
protected static $_cache_dir = null;
|
||||
protected static $_file_checkers = [];
|
||||
protected static $_functions = [];
|
||||
protected static $_includes_to_ignore = [];
|
||||
|
||||
protected static $_class_methods_checked = [];
|
||||
protected static $_classes_checked = [];
|
||||
protected static $_file_checked = [];
|
||||
|
||||
protected static $_ignore_check_variables_pattern = null;
|
||||
|
||||
public static $show_notices = true;
|
||||
|
||||
public function __construct($file_name, array $preloaded_statements = [])
|
||||
@ -359,23 +355,12 @@ class FileChecker implements StatementsSource
|
||||
return $argument_offset < count($this->_function_params[$function_name]) && $this->_function_params[$function_name][$argument_offset];
|
||||
}
|
||||
|
||||
public static function ignoreIncludes(array $includes)
|
||||
public static function clearCache()
|
||||
{
|
||||
self::$_includes_to_ignore = $includes;
|
||||
}
|
||||
self::$_file_checkers = [];
|
||||
|
||||
public static function getIncludesToIgnore()
|
||||
{
|
||||
return self::$_includes_to_ignore;
|
||||
}
|
||||
|
||||
public static function ignoreVariableChecksFor($pattern)
|
||||
{
|
||||
self::$_ignore_check_variables_pattern = $pattern;
|
||||
}
|
||||
|
||||
public static function shouldCheckVariables($file_name)
|
||||
{
|
||||
return !self::$_ignore_check_variables_pattern || !preg_match(self::$_ignore_check_variables_pattern, $file_name);
|
||||
self::$_class_methods_checked = [];
|
||||
self::$_classes_checked = [];
|
||||
self::$_file_checked = [];
|
||||
}
|
||||
}
|
||||
|
@ -541,7 +541,7 @@ class TypeChecker
|
||||
* @param array $existing_types
|
||||
* @return array|false
|
||||
*/
|
||||
public static function reconcileKeyedTypes(array $new_types, array $existing_types, $file_name, $line_number, array $suppressed_issues)
|
||||
public static function reconcileKeyedTypes(array $new_types, array $existing_types, $file_name, $line_number, array $suppressed_issues = null)
|
||||
{
|
||||
$keys = array_merge(array_keys($new_types), array_keys($existing_types));
|
||||
$keys = array_unique($keys);
|
||||
@ -601,7 +601,7 @@ class TypeChecker
|
||||
* @param int $line_number
|
||||
* @return Type\Union|false
|
||||
*/
|
||||
public static function reconcileTypes($new_var_type, Type\Union $existing_var_type = null, $key = null, $file_name = null, $line_number = null, array $suppressed_issues)
|
||||
public static function reconcileTypes($new_var_type, Type\Union $existing_var_type = null, $key = null, $file_name = null, $line_number = null, array $suppressed_issues = null)
|
||||
{
|
||||
$result_var_types = null;
|
||||
|
||||
|
@ -22,6 +22,7 @@ class ReturnTypeTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
\Psalm\ClassMethodChecker::clearCache();
|
||||
\Psalm\FileChecker::clearCache();
|
||||
}
|
||||
|
||||
public function testReturnTypeAfterUselessNullcheck()
|
||||
|
@ -30,6 +30,7 @@ class ScopeTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
\Psalm\ClassMethodChecker::clearCache();
|
||||
\Psalm\FileChecker::clearCache();
|
||||
\Psalm\Config::getInstance()->setIssueHandler('PossiblyUndefinedVariable', null);
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ class TypeTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
\Psalm\ClassMethodChecker::clearCache();
|
||||
\Psalm\FileChecker::clearCache();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user