mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Always load preloaded stub files when the analysis version is compatible
Before this change, preloaded stubs would only be loaded when running on a PHP version lower than the one that is in the stubs. With this change, the analysis PHP version (defined via config, input parameter, or inferred from the runtime) becomes authoritative. Since the PHP-version-specific stubs are not just polyfills, but actually type refinements on top of the PHP core symbols at hand, this change always loads them, so that it is possible to get more precise type inference downstream. This will likely lead to downstream breakages, because the stubs do indeed provide better type resolution, but indeed formalizes the idea that these stubs will provide better value for finding problems in analyzed code.
This commit is contained in:
parent
30a49633a5
commit
042305107e
@ -2065,7 +2065,7 @@ class Config
|
||||
|
||||
$core_generic_files = [];
|
||||
|
||||
if (PHP_VERSION_ID < 8_00_00 && $codebase->analysis_php_version_id >= 8_00_00) {
|
||||
if ($codebase->analysis_php_version_id >= 8_00_00) {
|
||||
$stringable_path = dirname(__DIR__, 2) . '/stubs/Php80.phpstub';
|
||||
|
||||
if (!file_exists($stringable_path)) {
|
||||
@ -2075,7 +2075,7 @@ class Config
|
||||
$core_generic_files[] = $stringable_path;
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 8_01_00 && $codebase->analysis_php_version_id >= 8_01_00) {
|
||||
if ($codebase->analysis_php_version_id >= 8_01_00) {
|
||||
$stringable_path = dirname(__DIR__, 2) . '/stubs/Php81.phpstub';
|
||||
|
||||
if (!file_exists($stringable_path)) {
|
||||
@ -2085,7 +2085,7 @@ class Config
|
||||
$core_generic_files[] = $stringable_path;
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 8_02_00 && $codebase->analysis_php_version_id >= 8_02_00) {
|
||||
if ($codebase->analysis_php_version_id >= 8_02_00) {
|
||||
$stringable_path = dirname(__DIR__, 2) . '/stubs/Php82.phpstub';
|
||||
|
||||
if (!file_exists($stringable_path)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user