2016-12-14 18:28:38 +01:00
|
|
|
<?php
|
2021-12-15 04:58:32 +01:00
|
|
|
|
2023-10-19 13:12:06 +02:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2016-12-14 18:28:38 +01:00
|
|
|
namespace Psalm\Tests;
|
|
|
|
|
2019-07-05 22:24:00 +02:00
|
|
|
use Psalm\Config;
|
2021-12-04 21:55:53 +01:00
|
|
|
use Psalm\Config\ProjectFileFilter;
|
2020-07-11 23:17:22 +02:00
|
|
|
use Psalm\Internal\IncludeCollector;
|
2021-12-03 21:40:18 +01:00
|
|
|
use SimpleXMLElement;
|
2016-12-14 18:28:38 +01:00
|
|
|
|
2021-06-08 04:55:21 +02:00
|
|
|
use function getcwd;
|
|
|
|
|
|
|
|
use const DIRECTORY_SEPARATOR;
|
|
|
|
|
2016-12-14 18:28:38 +01:00
|
|
|
class TestConfig extends Config
|
|
|
|
{
|
2022-12-16 19:58:47 +01:00
|
|
|
private static ?ProjectFileFilter $cached_project_files = null;
|
2019-04-29 20:05:43 +02:00
|
|
|
|
2016-12-14 18:28:38 +01:00
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
2016-12-19 01:00:32 +01:00
|
|
|
|
2021-12-09 00:47:32 +01:00
|
|
|
foreach ($this->php_extensions as $ext => $_enabled) {
|
|
|
|
$this->php_extensions[$ext] = true;
|
|
|
|
}
|
|
|
|
|
2016-12-19 01:00:32 +01:00
|
|
|
$this->throw_exception = true;
|
|
|
|
$this->use_docblock_types = true;
|
2020-02-17 22:33:28 +01:00
|
|
|
$this->level = 1;
|
2016-12-20 18:29:52 +01:00
|
|
|
$this->cache_directory = null;
|
2023-10-06 15:06:36 +02:00
|
|
|
$this->ignore_internal_falsable_issues = true;
|
|
|
|
$this->ignore_internal_nullable_issues = true;
|
2017-04-03 18:36:49 +02:00
|
|
|
|
2023-10-09 22:40:21 +02:00
|
|
|
$this->base_dir = (string) getcwd() . DIRECTORY_SEPARATOR;
|
2017-07-25 23:04:58 +02:00
|
|
|
|
2019-04-29 20:05:43 +02:00
|
|
|
if (!self::$cached_project_files) {
|
2021-12-04 21:55:53 +01:00
|
|
|
self::$cached_project_files = ProjectFileFilter::loadFromXMLElement(
|
2021-12-03 21:40:18 +01:00
|
|
|
new SimpleXMLElement($this->getContents()),
|
2019-04-29 20:05:43 +02:00
|
|
|
$this->base_dir,
|
2022-12-18 17:15:15 +01:00
|
|
|
true,
|
2019-04-29 20:05:43 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->project_files = self::$cached_project_files;
|
2020-07-11 23:17:22 +02:00
|
|
|
$this->setIncludeCollector(new IncludeCollector());
|
2017-07-25 23:04:58 +02:00
|
|
|
|
2017-04-03 18:36:49 +02:00
|
|
|
$this->collectPredefinedConstants();
|
|
|
|
$this->collectPredefinedFunctions();
|
2016-12-14 18:28:38 +01:00
|
|
|
}
|
2018-03-03 21:25:35 +01:00
|
|
|
|
2021-12-05 18:51:26 +01:00
|
|
|
protected function getContents(): string
|
2020-02-24 20:43:44 +01:00
|
|
|
{
|
|
|
|
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 20:43:44 +01:00
|
|
|
<ignoreFiles>
|
|
|
|
<directory name="src/Psalm/Internal/Stubs" />
|
|
|
|
</ignoreFiles>
|
|
|
|
</projectFiles>';
|
|
|
|
}
|
|
|
|
|
2023-07-24 10:51:25 +02:00
|
|
|
public function getComposerFilePathForClassLike(string $fq_classlike_name): string|false
|
2018-03-03 21:25:35 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2019-05-17 17:22:34 +02:00
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getProjectDirectories(): array
|
2019-05-17 17:22:34 +02:00
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
2016-12-14 18:28:38 +01:00
|
|
|
}
|