2018-09-30 05:51:06 +02:00
|
|
|
<?php
|
2021-12-15 04:58:32 +01:00
|
|
|
|
2018-11-12 16:57:05 +01:00
|
|
|
namespace Psalm\Tests\Internal\Provider;
|
2018-09-30 05:51:06 +02:00
|
|
|
|
2021-12-03 20:11:20 +01:00
|
|
|
use Psalm\Config;
|
|
|
|
use Psalm\Internal\Provider\FileReferenceCacheProvider;
|
|
|
|
|
2018-09-30 05:51:06 +02:00
|
|
|
/**
|
|
|
|
* Used to determine which files reference other files, necessary for using the --diff
|
|
|
|
* option from the command line.
|
|
|
|
*/
|
2021-12-03 20:11:20 +01:00
|
|
|
class FakeFileReferenceCacheProvider extends FileReferenceCacheProvider
|
2018-09-30 05:51:06 +02:00
|
|
|
{
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_file_references = null;
|
2018-09-30 05:51:06 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_classlike_files = null;
|
2019-04-28 18:59:36 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_method_class_references = null;
|
2020-03-26 17:35:27 +01:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_nonmethod_class_references = null;
|
2020-04-02 23:17:55 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_method_member_references = null;
|
2019-04-16 22:07:48 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_method_dependencies = null;
|
2021-06-12 22:13:29 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_method_property_references = null;
|
2021-05-21 15:25:57 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_method_method_return_references = null;
|
2021-06-10 20:18:15 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_file_member_references = null;
|
2019-04-16 22:07:48 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_file_property_references = null;
|
2021-05-21 15:25:57 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_file_method_return_references = null;
|
2021-06-10 20:18:15 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_method_missing_member_references = null;
|
2019-04-16 22:07:48 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_file_missing_member_references = null;
|
2018-09-30 05:51:06 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_unknown_member_references = null;
|
2019-04-27 23:38:24 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_method_param_uses = null;
|
2019-04-29 23:29:38 +02:00
|
|
|
|
2022-12-16 19:58:47 +01:00
|
|
|
private ?array $cached_issues = null;
|
2018-09-30 05:51:06 +02:00
|
|
|
|
2018-10-07 04:58:21 +02:00
|
|
|
/** @var array<string, array<string, int>> */
|
2022-12-16 19:58:47 +01:00
|
|
|
private array $cached_correct_methods = [];
|
2018-09-30 05:51:06 +02:00
|
|
|
|
2019-06-21 23:10:35 +02:00
|
|
|
/**
|
|
|
|
* @var array<
|
|
|
|
* string,
|
2022-11-12 02:14:21 +01:00
|
|
|
* array{
|
|
|
|
* 0: array<int, array{0: int, 1: non-empty-string}>,
|
|
|
|
* 1: array<int, array{0: int, 1: non-empty-string}>,
|
|
|
|
* 2: array<int, array{0: int, 1: non-empty-string, 2: int}>
|
2019-06-21 23:10:35 +02:00
|
|
|
* }
|
|
|
|
* >
|
|
|
|
*/
|
2022-12-16 19:58:47 +01:00
|
|
|
private array $cached_file_maps = [];
|
2018-10-17 21:52:58 +02:00
|
|
|
|
2020-06-06 22:57:25 +02:00
|
|
|
public function __construct()
|
|
|
|
{
|
2021-12-03 20:11:20 +01:00
|
|
|
$this->config = Config::getInstance();
|
2020-06-06 18:06:31 +02:00
|
|
|
}
|
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getCachedFileReferences(): ?array
|
2018-09-30 05:51:06 +02:00
|
|
|
{
|
|
|
|
return $this->cached_file_references;
|
|
|
|
}
|
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getCachedClassLikeFiles(): ?array
|
2019-04-28 18:59:36 +02:00
|
|
|
{
|
2020-04-02 23:17:55 +02:00
|
|
|
return $this->cached_classlike_files;
|
2019-04-28 18:59:36 +02:00
|
|
|
}
|
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getCachedMethodClassReferences(): ?array
|
2020-03-26 17:35:27 +01:00
|
|
|
{
|
|
|
|
return $this->cached_method_class_references;
|
|
|
|
}
|
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getCachedNonMethodClassReferences(): ?array
|
2020-04-02 23:17:55 +02:00
|
|
|
{
|
2021-05-21 15:25:57 +02:00
|
|
|
return $this->cached_nonmethod_class_references;
|
2020-04-02 23:17:55 +02:00
|
|
|
}
|
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getCachedFileMemberReferences(): ?array
|
2019-04-16 22:07:48 +02:00
|
|
|
{
|
|
|
|
return $this->cached_file_member_references;
|
|
|
|
}
|
|
|
|
|
2021-05-21 15:25:57 +02:00
|
|
|
public function getCachedFilePropertyReferences(): ?array
|
|
|
|
{
|
|
|
|
return $this->cached_file_property_references;
|
|
|
|
}
|
|
|
|
|
2021-06-10 20:18:15 +02:00
|
|
|
public function getCachedFileMethodReturnReferences(): ?array
|
|
|
|
{
|
|
|
|
return $this->cached_file_method_return_references;
|
|
|
|
}
|
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getCachedMethodMemberReferences(): ?array
|
2018-09-30 05:51:06 +02:00
|
|
|
{
|
2019-04-16 22:07:48 +02:00
|
|
|
return $this->cached_method_member_references;
|
|
|
|
}
|
|
|
|
|
2021-06-12 22:13:29 +02:00
|
|
|
public function getCachedMethodDependencies(): ?array
|
|
|
|
{
|
|
|
|
return $this->cached_method_dependencies;
|
|
|
|
}
|
|
|
|
|
2021-05-21 15:25:57 +02:00
|
|
|
public function getCachedMethodPropertyReferences(): ?array
|
|
|
|
{
|
|
|
|
return $this->cached_method_property_references;
|
|
|
|
}
|
|
|
|
|
2021-06-10 20:18:15 +02:00
|
|
|
public function getCachedMethodMethodReturnReferences(): ?array
|
|
|
|
{
|
|
|
|
return $this->cached_method_method_return_references;
|
|
|
|
}
|
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getCachedFileMissingMemberReferences(): ?array
|
2019-04-16 22:07:48 +02:00
|
|
|
{
|
|
|
|
return $this->cached_file_missing_member_references;
|
|
|
|
}
|
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getCachedMixedMemberNameReferences(): ?array
|
2019-04-27 23:38:24 +02:00
|
|
|
{
|
|
|
|
return $this->cached_unknown_member_references;
|
|
|
|
}
|
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getCachedMethodMissingMemberReferences(): ?array
|
2019-04-16 22:07:48 +02:00
|
|
|
{
|
|
|
|
return $this->cached_method_missing_member_references;
|
2018-09-30 05:51:06 +02:00
|
|
|
}
|
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getCachedMethodParamUses(): ?array
|
2019-04-29 23:29:38 +02:00
|
|
|
{
|
2021-05-21 15:25:57 +02:00
|
|
|
return $this->cached_method_param_uses;
|
2019-04-29 23:29:38 +02:00
|
|
|
}
|
|
|
|
|
2020-09-04 22:26:33 +02:00
|
|
|
public function getCachedIssues(): ?array
|
2018-09-30 05:51:06 +02:00
|
|
|
{
|
|
|
|
return $this->cached_issues;
|
|
|
|
}
|
|
|
|
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setCachedFileReferences(array $file_references): void
|
2018-09-30 05:51:06 +02:00
|
|
|
{
|
|
|
|
$this->cached_file_references = $file_references;
|
|
|
|
}
|
|
|
|
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setCachedClassLikeFiles(array $file_references): void
|
2019-04-28 18:59:36 +02:00
|
|
|
{
|
2020-04-02 23:17:55 +02:00
|
|
|
$this->cached_classlike_files = $file_references;
|
2019-04-28 18:59:36 +02:00
|
|
|
}
|
|
|
|
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setCachedMethodClassReferences(array $method_class_references): void
|
2020-03-26 17:35:27 +01:00
|
|
|
{
|
2020-08-10 05:19:59 +02:00
|
|
|
$this->cached_method_class_references = $method_class_references;
|
2020-03-26 17:35:27 +01:00
|
|
|
}
|
|
|
|
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setCachedNonMethodClassReferences(array $file_class_references): void
|
2020-04-02 23:17:55 +02:00
|
|
|
{
|
2020-08-10 05:19:59 +02:00
|
|
|
$this->cached_nonmethod_class_references = $file_class_references;
|
2020-04-02 23:17:55 +02:00
|
|
|
}
|
|
|
|
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setCachedMethodMemberReferences(array $member_references): void
|
2019-04-16 22:07:48 +02:00
|
|
|
{
|
2020-08-10 05:19:59 +02:00
|
|
|
$this->cached_method_member_references = $member_references;
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
2021-06-12 22:13:29 +02:00
|
|
|
public function setCachedMethodDependencies(array $member_references): void
|
|
|
|
{
|
|
|
|
$this->cached_method_dependencies = $member_references;
|
|
|
|
}
|
|
|
|
|
2021-05-21 15:25:57 +02:00
|
|
|
public function setCachedMethodPropertyReferences(array $property_references): void
|
|
|
|
{
|
|
|
|
$this->cached_method_property_references = $property_references;
|
|
|
|
}
|
|
|
|
|
2021-06-10 20:18:15 +02:00
|
|
|
public function setCachedMethodMethodReturnReferences(array $method_return_references): void
|
|
|
|
{
|
|
|
|
$this->cached_method_method_return_references = $method_return_references;
|
|
|
|
}
|
|
|
|
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setCachedMethodMissingMemberReferences(array $member_references): void
|
2019-04-16 22:07:48 +02:00
|
|
|
{
|
2020-08-10 05:19:59 +02:00
|
|
|
$this->cached_method_missing_member_references = $member_references;
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setCachedFileMemberReferences(array $member_references): void
|
2019-04-16 22:07:48 +02:00
|
|
|
{
|
2020-08-10 05:19:59 +02:00
|
|
|
$this->cached_file_member_references = $member_references;
|
2019-04-16 22:07:48 +02:00
|
|
|
}
|
|
|
|
|
2021-05-21 15:25:57 +02:00
|
|
|
public function setCachedFilePropertyReferences(array $property_references): void
|
|
|
|
{
|
|
|
|
$this->cached_file_property_references = $property_references;
|
|
|
|
}
|
|
|
|
|
2021-06-10 20:18:15 +02:00
|
|
|
public function setCachedFileMethodReturnReferences(array $method_return_references): void
|
|
|
|
{
|
|
|
|
$this->cached_file_method_return_references = $method_return_references;
|
|
|
|
}
|
|
|
|
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setCachedFileMissingMemberReferences(array $member_references): void
|
2018-09-30 05:51:06 +02:00
|
|
|
{
|
2020-08-10 05:19:59 +02:00
|
|
|
$this->cached_file_missing_member_references = $member_references;
|
2018-09-30 05:51:06 +02:00
|
|
|
}
|
|
|
|
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setCachedMixedMemberNameReferences(array $references): void
|
2019-04-27 23:38:24 +02:00
|
|
|
{
|
|
|
|
$this->cached_unknown_member_references = $references;
|
|
|
|
}
|
|
|
|
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setCachedMethodParamUses(array $uses): void
|
2019-04-29 23:29:38 +02:00
|
|
|
{
|
|
|
|
$this->cached_method_param_uses = $uses;
|
|
|
|
}
|
|
|
|
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setCachedIssues(array $issues): void
|
2018-09-30 05:51:06 +02:00
|
|
|
{
|
|
|
|
$this->cached_issues = $issues;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2018-10-07 04:58:21 +02:00
|
|
|
* @return array<string, array<string, int>>
|
2018-09-30 05:51:06 +02:00
|
|
|
*/
|
2020-09-12 17:24:05 +02:00
|
|
|
public function getAnalyzedMethodCache(): array
|
2018-09-30 05:51:06 +02:00
|
|
|
{
|
|
|
|
return $this->cached_correct_methods;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-08-10 05:19:59 +02:00
|
|
|
* @param array<string, array<string, int>> $analyzed_methods
|
2018-09-30 05:51:06 +02:00
|
|
|
*/
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setAnalyzedMethodCache(array $analyzed_methods): void
|
2018-09-30 05:51:06 +02:00
|
|
|
{
|
2020-08-10 05:19:59 +02:00
|
|
|
$this->cached_correct_methods = $analyzed_methods;
|
2018-09-30 05:51:06 +02:00
|
|
|
}
|
2018-10-17 21:52:58 +02:00
|
|
|
|
|
|
|
/**
|
2019-06-21 23:10:35 +02:00
|
|
|
* @return array<
|
|
|
|
* string,
|
2022-11-12 02:14:21 +01:00
|
|
|
* array{
|
|
|
|
* 0: array<int, array{0: int, 1: non-empty-string}>,
|
|
|
|
* 1: array<int, array{0: int, 1: non-empty-string}>,
|
|
|
|
* 2: array<int, array{0: int, 1: non-empty-string, 2: int}>
|
2019-06-21 23:10:35 +02:00
|
|
|
* }
|
|
|
|
* >
|
2018-10-17 21:52:58 +02:00
|
|
|
*/
|
2020-09-12 17:24:05 +02:00
|
|
|
public function getFileMapCache(): array
|
2018-10-17 21:52:58 +02:00
|
|
|
{
|
|
|
|
return $this->cached_file_maps;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array<
|
2019-06-21 23:10:35 +02:00
|
|
|
* string,
|
2022-11-12 02:14:21 +01:00
|
|
|
* array{
|
|
|
|
* 0: array<int, array{0: int, 1: non-empty-string}>,
|
|
|
|
* 1: array<int, array{0: int, 1: non-empty-string}>,
|
|
|
|
* 2: array<int, array{0: int, 1: non-empty-string, 2: int}>
|
2019-06-21 23:10:35 +02:00
|
|
|
* }
|
|
|
|
* > $file_maps
|
2018-10-17 21:52:58 +02:00
|
|
|
*/
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setFileMapCache(array $file_maps): void
|
2018-10-17 21:52:58 +02:00
|
|
|
{
|
|
|
|
$this->cached_file_maps = $file_maps;
|
|
|
|
}
|
2020-06-06 22:57:25 +02:00
|
|
|
|
|
|
|
/**
|
2022-11-12 02:14:21 +01:00
|
|
|
* @param array<string, array{int, int}> $mixed_counts
|
2020-06-06 22:57:25 +02:00
|
|
|
*/
|
2020-10-12 21:02:52 +02:00
|
|
|
public function setTypeCoverage(array $mixed_counts): void
|
2020-06-06 22:57:25 +02:00
|
|
|
{
|
|
|
|
}
|
2018-09-30 05:51:06 +02:00
|
|
|
}
|