1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Expose more internal methods through Codebase

- `bool Codebase::canTypeBeContainedByType(Union $input, Union $container)`
- `array{Union,Union} Codebase::getKeyValueParamsForTraversableObject(Atomic $type)`

For usage, see psalm/phpunit-psalm-plugin#15
This commit is contained in:
Bruce Weirdan 2019-02-20 13:54:01 +02:00 committed by Matthew Brown
parent 1e2c29041f
commit a0e040a462

View File

@ -3,6 +3,7 @@ namespace Psalm;
use LanguageServerProtocol\{Position, Range};
use PhpParser;
use Psalm\Internal\Analyzer\Statements\Block\ForeachAnalyzer;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
use Psalm\Internal\Analyzer\TypeAnalyzer;
use Psalm\Internal\Provider\ClassLikeStorageProvider;
@ -1149,7 +1150,7 @@ class Codebase
{
$this->file_provider->removeTemporaryFileChanges($file_path);
}
/**
* @psalm-suppress PossiblyUnusedMethod
*/
@ -1159,4 +1160,31 @@ class Codebase
): bool {
return TypeAnalyzer::isContainedBy($this, $input_type, $container_type);
}
/**
* @psalm-suppress PossiblyUnusedMethod
*/
public function canTypeBeContainedByType(
Type\Union $input_type,
Type\Union $container_type
): bool {
return TypeAnalyzer::canBeContainedBy($this, $input_type, $container_type);
}
/**
* @return array{Type\Union,Type\Union}
* @psalm-suppress PossiblyUnusedMethod
*/
public function getKeyValueParamsForTraversableObject(Type\Atomic $type): array
{
$key_type = null;
$value_type = null;
ForeachAnalyzer::getKeyValueParamsForTraversableObject($type, $this, $key_type, $value_type);
return [
$key_type ?? Type::getMixed(),
$value_type ?? Type::getMixed(),
];
}
}