/
TestConfig.php
68 lines (55 loc) · 1.68 KB
/
TestConfig.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
namespace Psalm\Tests;
use Psalm\Config;
use Psalm\Config\ProjectFileFilter;
use Psalm\Internal\IncludeCollector;
use SimpleXMLElement;
use function getcwd;
use const DIRECTORY_SEPARATOR;
class TestConfig extends Config
{
/** @var ProjectFileFilter|null */
private static $cached_project_files = null;
public function __construct()
{
parent::__construct();
$this->throw_exception = true;
$this->use_docblock_types = true;
$this->level = 1;
$this->cache_directory = null;
$this->base_dir = getcwd() . DIRECTORY_SEPARATOR;
if (!self::$cached_project_files) {
self::$cached_project_files = ProjectFileFilter::loadFromXMLElement(
new SimpleXMLElement($this->getContents()),
$this->base_dir,
true
);
}
$this->project_files = self::$cached_project_files;
$this->setIncludeCollector(new IncludeCollector());
$this->collectPredefinedConstants();
$this->collectPredefinedFunctions();
}
protected function getContents(): string
{
return '<?xml version="1.0"?>
<projectFiles>
<directory name="src" />
<file name="tests/somefile.php" />
<ignoreFiles>
<directory name="src/Psalm/Internal/Stubs" />
</ignoreFiles>
</projectFiles>';
}
/**
* @return false
*/
public function getComposerFilePathForClassLike(string $fq_classlike_name): bool
{
return false;
}
public function getProjectDirectories(): array
{
return [];
}
}