2016-12-14 12:28:38 -05:00
|
|
|
<?php
|
|
|
|
namespace Psalm\Tests;
|
|
|
|
|
2019-07-05 16:24:00 -04:00
|
|
|
use Psalm\Config;
|
2020-07-12 00:17:22 +03:00
|
|
|
use Psalm\Internal\IncludeCollector;
|
2016-12-14 12:28:38 -05:00
|
|
|
|
2021-06-08 05:55:21 +03:00
|
|
|
use function getcwd;
|
|
|
|
|
|
|
|
use const DIRECTORY_SEPARATOR;
|
|
|
|
|
2016-12-14 12:28:38 -05:00
|
|
|
class TestConfig extends Config
|
|
|
|
{
|
2019-04-29 14:05:43 -04:00
|
|
|
/** @var Config\ProjectFileFilter|null */
|
|
|
|
private static $cached_project_files = null;
|
|
|
|
|
2016-12-20 17:29:52 +00:00
|
|
|
/**
|
2018-01-10 10:56:43 -05:00
|
|
|
* @psalm-suppress PossiblyNullPropertyAssignmentValue because cache_directory isn't strictly nullable
|
2016-12-20 17:29:52 +00:00
|
|
|
*/
|
2016-12-14 12:28:38 -05:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
2016-12-18 19:00:32 -05:00
|
|
|
|
|
|
|
$this->throw_exception = true;
|
|
|
|
$this->use_docblock_types = true;
|
2020-02-17 16:33:28 -05:00
|
|
|
$this->level = 1;
|
2016-12-20 17:29:52 +00:00
|
|
|
$this->cache_directory = null;
|
2017-04-03 12:36:49 -04:00
|
|
|
|
2017-07-25 17:04:58 -04:00
|
|
|
$this->base_dir = getcwd() . DIRECTORY_SEPARATOR;
|
|
|
|
|
2019-04-29 14:05:43 -04:00
|
|
|
if (!self::$cached_project_files) {
|
|
|
|
self::$cached_project_files = Config\ProjectFileFilter::loadFromXMLElement(
|
2020-02-24 11:43:44 -08:00
|
|
|
new \SimpleXMLElement($this->getContents()),
|
2019-04-29 14:05:43 -04:00
|
|
|
$this->base_dir,
|
|
|
|
true
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->project_files = self::$cached_project_files;
|
2020-07-12 00:17:22 +03:00
|
|
|
$this->setIncludeCollector(new IncludeCollector());
|
2017-07-25 17:04:58 -04:00
|
|
|
|
2017-04-03 12:36:49 -04:00
|
|
|
$this->collectPredefinedConstants();
|
|
|
|
$this->collectPredefinedFunctions();
|
2016-12-14 12:28:38 -05:00
|
|
|
}
|
2018-03-03 15:25:35 -05:00
|
|
|
|
2020-02-24 11:43:44 -08:00
|
|
|
protected function getContents() : string
|
|
|
|
{
|
|
|
|
return '<?xml version="1.0"?>
|
|
|
|
<projectFiles>
|
|
|
|
<directory name="src" />
|
2021-08-19 19:31:58 +02:00
|
|
|
<file name="tests/somefile.php" />
|
2020-02-24 11:43:44 -08:00
|
|
|
<ignoreFiles>
|
|
|
|
<directory name="src/Psalm/Internal/Stubs" />
|
|
|
|
</ignoreFiles>
|
|
|
|
</projectFiles>';
|
|
|
|
}
|
|
|
|
|
2020-09-13 22:39:06 +02:00
|
|
|
/**
|
|
|
|
* @return false
|
|
|
|
*/
|
|
|
|
public function getComposerFilePathForClassLike(string $fq_classlike_name): bool
|
2018-03-03 15:25:35 -05:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2019-05-17 11:22:34 -04:00
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getProjectDirectories(): array
|
2019-05-17 11:22:34 -04:00
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
2016-12-14 12:28:38 -05:00
|
|
|
}
|