2016-07-25 00:02:15 +02:00
|
|
|
<?php
|
2016-07-26 00:37:44 +02:00
|
|
|
namespace Psalm\Tests;
|
2016-07-25 00:02:15 +02:00
|
|
|
|
|
|
|
use PhpParser\ParserFactory;
|
|
|
|
use PHPUnit_Framework_TestCase;
|
2016-11-02 07:29:00 +01:00
|
|
|
use Psalm\Checker\FileChecker;
|
|
|
|
use Psalm\Config;
|
2016-07-25 00:02:15 +02:00
|
|
|
|
|
|
|
class IssueSuppressionTest extends PHPUnit_Framework_TestCase
|
|
|
|
{
|
2016-11-02 07:29:00 +01:00
|
|
|
protected static $parser;
|
|
|
|
protected static $file_filter;
|
2016-07-25 00:02:15 +02:00
|
|
|
|
|
|
|
public static function setUpBeforeClass()
|
|
|
|
{
|
2016-11-02 07:29:00 +01:00
|
|
|
self::$parser = (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
|
2016-07-25 00:02:15 +02:00
|
|
|
|
2016-11-02 07:29:00 +01:00
|
|
|
$config = Config::getInstance();
|
2016-07-25 00:02:15 +02:00
|
|
|
$config->throw_exception = true;
|
|
|
|
|
2016-11-02 07:29:00 +01:00
|
|
|
$filter = new Config\FileFilter();
|
2016-07-25 00:02:15 +02:00
|
|
|
$filter->addExcludeFile('somefile.php');
|
|
|
|
$filter->makeExclusive();
|
|
|
|
|
2016-11-02 07:29:00 +01:00
|
|
|
self::$file_filter = $filter;
|
2016-07-25 00:02:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
2016-11-02 07:29:00 +01:00
|
|
|
FileChecker::clearCache();
|
|
|
|
Config::getInstance()->setIssueHandler('PossiblyUndefinedVariable', null);
|
2016-07-25 00:02:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testUndefinedClass()
|
|
|
|
{
|
2016-11-02 07:29:00 +01:00
|
|
|
$stmts = self::$parser->parse('<?php
|
2016-07-25 00:02:15 +02:00
|
|
|
|
|
|
|
class A{
|
|
|
|
/**
|
2016-10-11 20:17:55 +02:00
|
|
|
* @psalm-suppress UndefinedClass
|
2016-10-15 19:10:05 +02:00
|
|
|
* @psalm-suppress MixedMethodCall
|
2016-11-11 23:13:24 +01:00
|
|
|
* @psalm-suppress MissingReturnType
|
2016-07-25 00:02:15 +02:00
|
|
|
*/
|
|
|
|
public function a() {
|
|
|
|
B::foo()->bar()->bat()->baz()->bam()->bas()->bee()->bet()->bes()->bis();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
');
|
|
|
|
|
2016-11-02 07:29:00 +01:00
|
|
|
$file_checker = new FileChecker('somefile.php', $stmts);
|
2016-07-25 00:02:15 +02:00
|
|
|
$file_checker->check();
|
|
|
|
}
|
|
|
|
}
|