mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Psalm\Tests;
|
|
|
|
use Psalm\Type;
|
|
|
|
use PhpParser;
|
|
use PhpParser\ParserFactory;
|
|
use PHPUnit_Framework_TestCase;
|
|
|
|
class IssueSuppressionTest extends PHPUnit_Framework_TestCase
|
|
{
|
|
protected static $_parser;
|
|
protected static $_file_filter;
|
|
|
|
public static function setUpBeforeClass()
|
|
{
|
|
self::$_parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
|
|
|
|
$config = \Psalm\Config::getInstance();
|
|
$config->throw_exception = true;
|
|
|
|
$filter = new \Psalm\Config\FileFilter();
|
|
$filter->addExcludeFile('somefile.php');
|
|
$filter->makeExclusive();
|
|
|
|
self::$_file_filter = $filter;
|
|
}
|
|
|
|
public function setUp()
|
|
{
|
|
\Psalm\Checker\ClassLikeChecker::clearCache();
|
|
\Psalm\Checker\ClassMethodChecker::clearCache();
|
|
\Psalm\Config::getInstance()->setIssueHandler('PossiblyUndefinedVariable', null);
|
|
}
|
|
|
|
public function testUndefinedClass()
|
|
{
|
|
$stmts = self::$_parser->parse('<?php
|
|
|
|
class A{
|
|
/**
|
|
* @suppress UndefinedClass
|
|
*/
|
|
public function a() {
|
|
B::foo()->bar()->bat()->baz()->bam()->bas()->bee()->bet()->bes()->bis();
|
|
}
|
|
}
|
|
');
|
|
|
|
$file_checker = new \Psalm\Checker\FileChecker('somefile.php', $stmts);
|
|
$file_checker->check();
|
|
}
|
|
}
|