1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 17:52:45 +01:00
psalm/tests/Internal/Provider/FakeFileReferenceCacheProvider.php

295 lines
7.9 KiB
PHP
Raw Normal View History

2018-09-30 05:51:06 +02:00
<?php
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
{
/** @var ?array */
private $cached_file_references;
/** @var ?array */
private $cached_classlike_files;
/** @var ?array */
private $cached_method_class_references;
/** @var ?array */
private $cached_nonmethod_class_references;
2018-09-30 05:51:06 +02:00
/** @var ?array */
private $cached_method_member_references;
/** @var ?array */
private $cached_method_dependencies;
/** @var ?array */
private $cached_method_property_references;
/** @var ?array */
private $cached_method_method_return_references;
/** @var ?array */
private $cached_file_member_references;
/** @var ?array */
private $cached_file_property_references;
/** @var ?array */
private $cached_file_method_return_references;
/** @var ?array */
private $cached_method_missing_member_references;
/** @var ?array */
private $cached_file_missing_member_references;
2018-09-30 05:51:06 +02:00
2019-04-27 23:38:24 +02:00
/** @var ?array */
private $cached_unknown_member_references;
/** @var ?array */
private $cached_method_param_uses;
2018-09-30 05:51:06 +02:00
/** @var ?array */
private $cached_issues;
/** @var array<string, array<string, int>> */
2018-09-30 05:51:06 +02:00
private $cached_correct_methods = [];
/**
* @var array<
* string,
Add support for strict arrays, fix type alias intersection, fix array_is_list assertion on non-lists (#8395) * Immutable CodeLocation * Remove excess clones * Remove external clones * Remove leftover clones * Fix final clone issue * Immutable storages * Refactoring * Fixes * Fixes * Fix * Fix * Fixes * Simplify * Fixes * Fix * Fixes * Update * Fix * Cache global types * Fix * Update * Update * Fixes * Fixes * Refactor * Fixes * Fix * Fix * More caching * Fix * Fix * Update * Update * Fix * Fixes * Update * Refactor * Update * Fixes * Break one more test * Fix * FIx * Fix * Fix * Fix * Fix * Improve performance and readability * Equivalent logic * Fixes * Revert * Revert "Revert" This reverts commit f9175100c8452c80559234200663fd4c4f4dd889. * Fix * Fix reference bug * Make default TypeVisitor immutable * Bugfix * Remove clones * Partial refactoring * Refactoring * Fixes * Fix * Fixes * Fixes * cs-fix * Fix final bugs * Add test * Misc fixes * Update * Fixes * Experiment with removing different property * revert "Experiment with removing different property" This reverts commit ac1156e077fc4ea633530d51096d27b6e88bfdf9. * Uniform naming * Uniform naming * Hack hotfix * Clean up $_FILES ref #8621 * Undo hack, try fixing properly * Helper method * Remove redundant call * Partially fix bugs * Cleanup * Change defaults * Fix bug * Fix (?, hope this doesn't break anything else) * cs-fix * Review fixes * Bugfix * Bugfix * Improve logic * Add support for list{} and callable-list{} types, properly implement array_is_list assertions (fixes #8389) * Default to sealed arrays * Fix array_merge bug * Fixes * Fix * Sealed type checks * Properly infer properties-of and get_object_vars on final classes * Fix array_map zipping * Fix tests * Fixes * Fixes * Fix more stuff * Recursively resolve type aliases * Fix typo * Fixes * Fix array_is_list assertion on keyed array * Add BC docs * Fixes * fix * Update * Update * Update * Update * Seal arrays with count assertions * Fix #8528 * Fix * Update * Improve sealed array foreach logic * get_object_vars on template properties * Fix sealed array assertion reconciler logic * Improved reconciler * Add tests * Single source of truth for test types * Fix tests * Fixup tests * Fixup tests * Fixup tests * Update * Fix tests * Fix tests * Final fixes * Fixes * Use list syntax only when needed * Fix tests * Cs-fix * Update docs * Update docs * Update docs * Update docs * Update docs * Document missing types * Update docs * Improve class-string-map docs * Update * Update * I love working on psalm :) * Keep arrays unsealed by default * Fixup tests * Fix syntax mistake * cs-fix * Fix typo * Re-import missing types * Keep strict types only in return types * argc/argv fixes * argc/argv fixes * Fix test * Comment-out valinor code, pinging @romm pls merge https://github.com/CuyZ/Valinor/pull/246 so we can add valinor to the psalm docs :)
2022-11-05 22:34:42 +01:00
* strict-array{
* 0: array<int, strict-array{0: int, 1: non-empty-string}>,
* 1: array<int, strict-array{0: int, 1: non-empty-string}>,
* 2: array<int, strict-array{0: int, 1: non-empty-string, 2: int}>
* }
* >
*/
2018-10-17 21:52:58 +02:00
private $cached_file_maps = [];
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
}
public function getCachedFileReferences(): ?array
2018-09-30 05:51:06 +02:00
{
return $this->cached_file_references;
}
public function getCachedClassLikeFiles(): ?array
{
return $this->cached_classlike_files;
}
public function getCachedMethodClassReferences(): ?array
{
return $this->cached_method_class_references;
}
public function getCachedNonMethodClassReferences(): ?array
{
return $this->cached_nonmethod_class_references;
}
public function getCachedFileMemberReferences(): ?array
{
return $this->cached_file_member_references;
}
public function getCachedFilePropertyReferences(): ?array
{
return $this->cached_file_property_references;
}
public function getCachedFileMethodReturnReferences(): ?array
{
return $this->cached_file_method_return_references;
}
public function getCachedMethodMemberReferences(): ?array
2018-09-30 05:51:06 +02:00
{
return $this->cached_method_member_references;
}
public function getCachedMethodDependencies(): ?array
{
return $this->cached_method_dependencies;
}
public function getCachedMethodPropertyReferences(): ?array
{
return $this->cached_method_property_references;
}
public function getCachedMethodMethodReturnReferences(): ?array
{
return $this->cached_method_method_return_references;
}
public function getCachedFileMissingMemberReferences(): ?array
{
return $this->cached_file_missing_member_references;
}
public function getCachedMixedMemberNameReferences(): ?array
2019-04-27 23:38:24 +02:00
{
return $this->cached_unknown_member_references;
}
public function getCachedMethodMissingMemberReferences(): ?array
{
return $this->cached_method_missing_member_references;
2018-09-30 05:51:06 +02:00
}
public function getCachedMethodParamUses(): ?array
{
return $this->cached_method_param_uses;
}
public function getCachedIssues(): ?array
2018-09-30 05:51:06 +02:00
{
return $this->cached_issues;
}
public function setCachedFileReferences(array $file_references): void
2018-09-30 05:51:06 +02:00
{
$this->cached_file_references = $file_references;
}
public function setCachedClassLikeFiles(array $file_references): void
{
$this->cached_classlike_files = $file_references;
}
public function setCachedMethodClassReferences(array $method_class_references): void
{
2020-08-10 05:19:59 +02:00
$this->cached_method_class_references = $method_class_references;
}
public function setCachedNonMethodClassReferences(array $file_class_references): void
{
2020-08-10 05:19:59 +02:00
$this->cached_nonmethod_class_references = $file_class_references;
}
public function setCachedMethodMemberReferences(array $member_references): void
{
2020-08-10 05:19:59 +02:00
$this->cached_method_member_references = $member_references;
}
public function setCachedMethodDependencies(array $member_references): void
{
$this->cached_method_dependencies = $member_references;
}
public function setCachedMethodPropertyReferences(array $property_references): void
{
$this->cached_method_property_references = $property_references;
}
public function setCachedMethodMethodReturnReferences(array $method_return_references): void
{
$this->cached_method_method_return_references = $method_return_references;
}
public function setCachedMethodMissingMemberReferences(array $member_references): void
{
2020-08-10 05:19:59 +02:00
$this->cached_method_missing_member_references = $member_references;
}
public function setCachedFileMemberReferences(array $member_references): void
{
2020-08-10 05:19:59 +02:00
$this->cached_file_member_references = $member_references;
}
public function setCachedFilePropertyReferences(array $property_references): void
{
$this->cached_file_property_references = $property_references;
}
public function setCachedFileMethodReturnReferences(array $method_return_references): void
{
$this->cached_file_method_return_references = $method_return_references;
}
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
}
public function setCachedMixedMemberNameReferences(array $references): void
2019-04-27 23:38:24 +02:00
{
$this->cached_unknown_member_references = $references;
}
public function setCachedMethodParamUses(array $uses): void
{
$this->cached_method_param_uses = $uses;
}
public function setCachedIssues(array $issues): void
2018-09-30 05:51:06 +02:00
{
$this->cached_issues = $issues;
}
/**
* @return array<string, array<string, int>>
2018-09-30 05:51:06 +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
*/
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
/**
* @return array<
* string,
Add support for strict arrays, fix type alias intersection, fix array_is_list assertion on non-lists (#8395) * Immutable CodeLocation * Remove excess clones * Remove external clones * Remove leftover clones * Fix final clone issue * Immutable storages * Refactoring * Fixes * Fixes * Fix * Fix * Fixes * Simplify * Fixes * Fix * Fixes * Update * Fix * Cache global types * Fix * Update * Update * Fixes * Fixes * Refactor * Fixes * Fix * Fix * More caching * Fix * Fix * Update * Update * Fix * Fixes * Update * Refactor * Update * Fixes * Break one more test * Fix * FIx * Fix * Fix * Fix * Fix * Improve performance and readability * Equivalent logic * Fixes * Revert * Revert "Revert" This reverts commit f9175100c8452c80559234200663fd4c4f4dd889. * Fix * Fix reference bug * Make default TypeVisitor immutable * Bugfix * Remove clones * Partial refactoring * Refactoring * Fixes * Fix * Fixes * Fixes * cs-fix * Fix final bugs * Add test * Misc fixes * Update * Fixes * Experiment with removing different property * revert "Experiment with removing different property" This reverts commit ac1156e077fc4ea633530d51096d27b6e88bfdf9. * Uniform naming * Uniform naming * Hack hotfix * Clean up $_FILES ref #8621 * Undo hack, try fixing properly * Helper method * Remove redundant call * Partially fix bugs * Cleanup * Change defaults * Fix bug * Fix (?, hope this doesn't break anything else) * cs-fix * Review fixes * Bugfix * Bugfix * Improve logic * Add support for list{} and callable-list{} types, properly implement array_is_list assertions (fixes #8389) * Default to sealed arrays * Fix array_merge bug * Fixes * Fix * Sealed type checks * Properly infer properties-of and get_object_vars on final classes * Fix array_map zipping * Fix tests * Fixes * Fixes * Fix more stuff * Recursively resolve type aliases * Fix typo * Fixes * Fix array_is_list assertion on keyed array * Add BC docs * Fixes * fix * Update * Update * Update * Update * Seal arrays with count assertions * Fix #8528 * Fix * Update * Improve sealed array foreach logic * get_object_vars on template properties * Fix sealed array assertion reconciler logic * Improved reconciler * Add tests * Single source of truth for test types * Fix tests * Fixup tests * Fixup tests * Fixup tests * Update * Fix tests * Fix tests * Final fixes * Fixes * Use list syntax only when needed * Fix tests * Cs-fix * Update docs * Update docs * Update docs * Update docs * Update docs * Document missing types * Update docs * Improve class-string-map docs * Update * Update * I love working on psalm :) * Keep arrays unsealed by default * Fixup tests * Fix syntax mistake * cs-fix * Fix typo * Re-import missing types * Keep strict types only in return types * argc/argv fixes * argc/argv fixes * Fix test * Comment-out valinor code, pinging @romm pls merge https://github.com/CuyZ/Valinor/pull/246 so we can add valinor to the psalm docs :)
2022-11-05 22:34:42 +01:00
* strict-array{
* 0: array<int, strict-array{0: int, 1: non-empty-string}>,
* 1: array<int, strict-array{0: int, 1: non-empty-string}>,
* 2: array<int, strict-array{0: int, 1: non-empty-string, 2: int}>
* }
* >
2018-10-17 21:52:58 +02:00
*/
public function getFileMapCache(): array
2018-10-17 21:52:58 +02:00
{
return $this->cached_file_maps;
}
/**
* @param array<
* string,
Add support for strict arrays, fix type alias intersection, fix array_is_list assertion on non-lists (#8395) * Immutable CodeLocation * Remove excess clones * Remove external clones * Remove leftover clones * Fix final clone issue * Immutable storages * Refactoring * Fixes * Fixes * Fix * Fix * Fixes * Simplify * Fixes * Fix * Fixes * Update * Fix * Cache global types * Fix * Update * Update * Fixes * Fixes * Refactor * Fixes * Fix * Fix * More caching * Fix * Fix * Update * Update * Fix * Fixes * Update * Refactor * Update * Fixes * Break one more test * Fix * FIx * Fix * Fix * Fix * Fix * Improve performance and readability * Equivalent logic * Fixes * Revert * Revert "Revert" This reverts commit f9175100c8452c80559234200663fd4c4f4dd889. * Fix * Fix reference bug * Make default TypeVisitor immutable * Bugfix * Remove clones * Partial refactoring * Refactoring * Fixes * Fix * Fixes * Fixes * cs-fix * Fix final bugs * Add test * Misc fixes * Update * Fixes * Experiment with removing different property * revert "Experiment with removing different property" This reverts commit ac1156e077fc4ea633530d51096d27b6e88bfdf9. * Uniform naming * Uniform naming * Hack hotfix * Clean up $_FILES ref #8621 * Undo hack, try fixing properly * Helper method * Remove redundant call * Partially fix bugs * Cleanup * Change defaults * Fix bug * Fix (?, hope this doesn't break anything else) * cs-fix * Review fixes * Bugfix * Bugfix * Improve logic * Add support for list{} and callable-list{} types, properly implement array_is_list assertions (fixes #8389) * Default to sealed arrays * Fix array_merge bug * Fixes * Fix * Sealed type checks * Properly infer properties-of and get_object_vars on final classes * Fix array_map zipping * Fix tests * Fixes * Fixes * Fix more stuff * Recursively resolve type aliases * Fix typo * Fixes * Fix array_is_list assertion on keyed array * Add BC docs * Fixes * fix * Update * Update * Update * Update * Seal arrays with count assertions * Fix #8528 * Fix * Update * Improve sealed array foreach logic * get_object_vars on template properties * Fix sealed array assertion reconciler logic * Improved reconciler * Add tests * Single source of truth for test types * Fix tests * Fixup tests * Fixup tests * Fixup tests * Update * Fix tests * Fix tests * Final fixes * Fixes * Use list syntax only when needed * Fix tests * Cs-fix * Update docs * Update docs * Update docs * Update docs * Update docs * Document missing types * Update docs * Improve class-string-map docs * Update * Update * I love working on psalm :) * Keep arrays unsealed by default * Fixup tests * Fix syntax mistake * cs-fix * Fix typo * Re-import missing types * Keep strict types only in return types * argc/argv fixes * argc/argv fixes * Fix test * Comment-out valinor code, pinging @romm pls merge https://github.com/CuyZ/Valinor/pull/246 so we can add valinor to the psalm docs :)
2022-11-05 22:34:42 +01:00
* strict-array{
* 0: array<int, strict-array{0: int, 1: non-empty-string}>,
* 1: array<int, strict-array{0: int, 1: non-empty-string}>,
* 2: array<int, strict-array{0: int, 1: non-empty-string, 2: int}>
* }
* > $file_maps
2018-10-17 21:52:58 +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
/**
Add support for strict arrays, fix type alias intersection, fix array_is_list assertion on non-lists (#8395) * Immutable CodeLocation * Remove excess clones * Remove external clones * Remove leftover clones * Fix final clone issue * Immutable storages * Refactoring * Fixes * Fixes * Fix * Fix * Fixes * Simplify * Fixes * Fix * Fixes * Update * Fix * Cache global types * Fix * Update * Update * Fixes * Fixes * Refactor * Fixes * Fix * Fix * More caching * Fix * Fix * Update * Update * Fix * Fixes * Update * Refactor * Update * Fixes * Break one more test * Fix * FIx * Fix * Fix * Fix * Fix * Improve performance and readability * Equivalent logic * Fixes * Revert * Revert "Revert" This reverts commit f9175100c8452c80559234200663fd4c4f4dd889. * Fix * Fix reference bug * Make default TypeVisitor immutable * Bugfix * Remove clones * Partial refactoring * Refactoring * Fixes * Fix * Fixes * Fixes * cs-fix * Fix final bugs * Add test * Misc fixes * Update * Fixes * Experiment with removing different property * revert "Experiment with removing different property" This reverts commit ac1156e077fc4ea633530d51096d27b6e88bfdf9. * Uniform naming * Uniform naming * Hack hotfix * Clean up $_FILES ref #8621 * Undo hack, try fixing properly * Helper method * Remove redundant call * Partially fix bugs * Cleanup * Change defaults * Fix bug * Fix (?, hope this doesn't break anything else) * cs-fix * Review fixes * Bugfix * Bugfix * Improve logic * Add support for list{} and callable-list{} types, properly implement array_is_list assertions (fixes #8389) * Default to sealed arrays * Fix array_merge bug * Fixes * Fix * Sealed type checks * Properly infer properties-of and get_object_vars on final classes * Fix array_map zipping * Fix tests * Fixes * Fixes * Fix more stuff * Recursively resolve type aliases * Fix typo * Fixes * Fix array_is_list assertion on keyed array * Add BC docs * Fixes * fix * Update * Update * Update * Update * Seal arrays with count assertions * Fix #8528 * Fix * Update * Improve sealed array foreach logic * get_object_vars on template properties * Fix sealed array assertion reconciler logic * Improved reconciler * Add tests * Single source of truth for test types * Fix tests * Fixup tests * Fixup tests * Fixup tests * Update * Fix tests * Fix tests * Final fixes * Fixes * Use list syntax only when needed * Fix tests * Cs-fix * Update docs * Update docs * Update docs * Update docs * Update docs * Document missing types * Update docs * Improve class-string-map docs * Update * Update * I love working on psalm :) * Keep arrays unsealed by default * Fixup tests * Fix syntax mistake * cs-fix * Fix typo * Re-import missing types * Keep strict types only in return types * argc/argv fixes * argc/argv fixes * Fix test * Comment-out valinor code, pinging @romm pls merge https://github.com/CuyZ/Valinor/pull/246 so we can add valinor to the psalm docs :)
2022-11-05 22:34:42 +01:00
* @param array<string, strict-array{int, int}> $mixed_counts
2020-06-06 22:57:25 +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
}