1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Simplify clearCache calls

This commit is contained in:
Matthew Brown 2016-08-15 11:01:50 -04:00
parent faae9062ba
commit 84b4e09873
11 changed files with 23 additions and 12 deletions

View File

@ -124,4 +124,14 @@ class ClassChecker extends ClassLikeChecker
return isset($class_implementations[$interface]);
}
public static function clearCache()
{
self::$existing_classes = [];
self::$existing_classes_ci = [];
self::$class_extends = [];
ClassMethodChecker::clearCache();
}
}

View File

@ -755,9 +755,6 @@ abstract class ClassLikeChecker implements StatementsSource
self::$this_class = null;
self::$existing_classes = [];
self::$existing_classes_ci = [];
self::$existing_interfaces_ci = [];
self::$class_implements = [];
self::$class_methods = [];
@ -771,6 +768,7 @@ abstract class ClassLikeChecker implements StatementsSource
self::$protected_static_class_properties = [];
self::$private_static_class_properties = [];
self::$class_extends = [];
ClassChecker::clearCache();
InterfaceChecker::clearCache();
}
}

View File

@ -385,6 +385,5 @@ class ClassMethodChecker extends FunctionLikeChecker
self::$inherited_methods = [];
self::$declaring_class = [];
self::$method_visibility = [];
self::$new_docblocks = [];
}
}

View File

@ -361,5 +361,7 @@ class FileChecker implements StatementsSource
self::$functions_checked = [];
self::$classes_checked = [];
self::$file_checked = [];
ClassLikeChecker::clearCache();
}
}

View File

@ -57,4 +57,10 @@ class InterfaceChecker extends ClassLikeChecker
return isset(self::$existing_interfaces[$absolute_class]);
}
public static function clearCache()
{
self::$existing_interfaces = [];
self::$existing_interfaces_ci = [];
}
}

View File

@ -21,7 +21,7 @@ class ArrayReturnTypeTest extends PHPUnit_Framework_TestCase
public function setUp()
{
\Psalm\Checker\ClassMethodChecker::clearCache();
\Psalm\Checker\FileChecker::clearCache();
}
public function testGenericArrayCreation()

View File

@ -29,8 +29,7 @@ class IssueSuppressionTest extends PHPUnit_Framework_TestCase
public function setUp()
{
\Psalm\Checker\ClassLikeChecker::clearCache();
\Psalm\Checker\ClassMethodChecker::clearCache();
\Psalm\Checker\FileChecker::clearCache();
\Psalm\Config::getInstance()->setIssueHandler('PossiblyUndefinedVariable', null);
}

View File

@ -23,7 +23,7 @@ class PropertyTypeTest extends PHPUnit_Framework_TestCase
public function setUp()
{
\Psalm\Checker\ClassMethodChecker::clearCache();
\Psalm\Checker\FileChecker::clearCache();
}
public function testNewVarInIf()

View File

@ -21,7 +21,6 @@ class ReturnTypeTest extends PHPUnit_Framework_TestCase
public function setUp()
{
\Psalm\Checker\ClassMethodChecker::clearCache();
\Psalm\Checker\FileChecker::clearCache();
}

View File

@ -29,7 +29,6 @@ class ScopeTest extends PHPUnit_Framework_TestCase
public function setUp()
{
\Psalm\Checker\ClassMethodChecker::clearCache();
\Psalm\Checker\FileChecker::clearCache();
\Psalm\Config::getInstance()->setIssueHandler('PossiblyUndefinedVariable', null);
}

View File

@ -22,7 +22,6 @@ class TypeTest extends PHPUnit_Framework_TestCase
public function setUp()
{
\Psalm\Checker\ClassMethodChecker::clearCache();
\Psalm\Checker\FileChecker::clearCache();
}