Skip to content

Commit d600a35

Browse files
authored
Merge pull request #9135 from lptn/unify-deprecation-messages
Unify warning messages for deprecated config variables
2 parents aec0edc + c55d297 commit d600a35

4 files changed

Lines changed: 6 additions & 8 deletions

File tree

src/Psalm/Config.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2243,9 +2243,8 @@ public function visitStubFiles(Codebase $codebase, ?Progress $progress = null):
22432243
$is_stub_already_loaded = in_array($ext_stub_path, $this->internal_stubs, true);
22442244
if (! $is_stub_already_loaded && extension_loaded($ext_name)) {
22452245
$this->internal_stubs[] = $ext_stub_path;
2246-
$progress->write("Deprecation: Psalm stubs for ext-$ext_name loaded using legacy way."
2247-
. " Instead, please declare ext-$ext_name as dependency in composer.json"
2248-
. " or use <enableExtensions> and/or <disableExtensions> directives in Psalm config.\n");
2246+
$this->config_warnings[] = "Psalm 6 will not automatically load stubs for ext-$ext_name."
2247+
. " You should explicitly enable or disable this ext in composer.json or Psalm config.";
22492248
}
22502249
}
22512250

src/Psalm/Internal/Analyzer/ProjectAnalyzer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,8 +564,8 @@ private function generatePHPVersionMessage(): string
564564
$source,
565565
);
566566

567-
if (count($codebase->config->php_extensions) > 0) {
568-
$enabled_extensions_names = array_keys(array_filter($codebase->config->php_extensions));
567+
$enabled_extensions_names = array_keys(array_filter($codebase->config->php_extensions));
568+
if (count($enabled_extensions_names) > 0) {
569569
$message .= ' Enabled extensions: ' . implode(', ', $enabled_extensions_names);
570570
}
571571

src/Psalm/Internal/Cli/Psalm.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,7 @@ private static function configureShepherd(Config $config, array $options, array
11551155
if (is_string(getenv('PSALM_SHEPHERD_HOST'))) { // remove this block in Psalm 6
11561156
fwrite(
11571157
STDERR,
1158-
'PSALM_SHEPHERD_HOST env variable is deprecated and will be removed in Psalm 6.'
1158+
'Warning: PSALM_SHEPHERD_HOST env variable will be removed in Psalm 6.'
11591159
.' Please use "--shepherd" cli option or PSALM_SHEPHERD env variable'
11601160
.' to specify a custom Shepherd host/endpoint.'
11611161
. PHP_EOL,

tests/EndToEnd/PsalmEndToEndTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
use function readdir;
2121
use function rmdir;
2222
use function str_replace;
23-
use function substr_count;
2423
use function sys_get_temp_dir;
2524
use function tempnam;
2625
use function unlink;
@@ -168,7 +167,7 @@ public function testPsalmDiff(): void
168167
$this->assertStringContainsString('InvalidReturnType', $result['STDOUT']);
169168
$this->assertStringContainsString('InvalidReturnStatement', $result['STDOUT']);
170169
$this->assertStringContainsString('3 errors', $result['STDOUT']);
171-
$this->assertEquals(1, substr_count($result['STDERR'], 'E')); // Should only have 'E' from 'Extensions' in version message
170+
$this->assertStringNotContainsString('E', $result['STDERR']);
172171

173172
$this->assertSame(2, $result['CODE']);
174173

0 commit comments

Comments
 (0)