Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify warning messages for deprecated config variables #9135

Merged
merged 12 commits into from
Jan 29, 2023
5 changes: 2 additions & 3 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2243,9 +2243,8 @@ public function visitStubFiles(Codebase $codebase, ?Progress $progress = null):
$is_stub_already_loaded = in_array($ext_stub_path, $this->internal_stubs, true);
if (! $is_stub_already_loaded && extension_loaded($ext_name)) {
$this->internal_stubs[] = $ext_stub_path;
$progress->write("Deprecation: Psalm stubs for ext-$ext_name loaded using legacy way."
. " Instead, please declare ext-$ext_name as dependency in composer.json"
. " or use <enableExtensions> and/or <disableExtensions> directives in Psalm config.\n");
$this->config_warnings[] = "Psalm 6 will not automatically load stubs for ext-$ext_name."
. " You should explicitly enable or disable this ext in composer.json or Psalm config.";
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Analyzer/ProjectAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,8 +564,8 @@ private function generatePHPVersionMessage(): string
$source,
);

if (count($codebase->config->php_extensions) > 0) {
$enabled_extensions_names = array_keys(array_filter($codebase->config->php_extensions));
$enabled_extensions_names = array_keys(array_filter($codebase->config->php_extensions));
if (count($enabled_extensions_names) > 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes empty extensions list output like:

Target PHP version: 7.4 (inferred from composer.json) Enabled extensions: .

new output:

Target PHP version: 7.4 (inferred from composer.json).

$message .= ' Enabled extensions: ' . implode(', ', $enabled_extensions_names);
}

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Cli/Psalm.php
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ private static function configureShepherd(Config $config, array $options, array
if (is_string(getenv('PSALM_SHEPHERD_HOST'))) { // remove this block in Psalm 6
fwrite(
STDERR,
'PSALM_SHEPHERD_HOST env variable is deprecated and will be removed in Psalm 6.'
'Warning: PSALM_SHEPHERD_HOST env variable will be removed in Psalm 6.'
.' Please use "--shepherd" cli option or PSALM_SHEPHERD env variable'
.' to specify a custom Shepherd host/endpoint.'
. PHP_EOL,
Expand Down
3 changes: 1 addition & 2 deletions tests/EndToEnd/PsalmEndToEndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
use function readdir;
use function rmdir;
use function str_replace;
use function substr_count;
use function sys_get_temp_dir;
use function tempnam;
use function unlink;
Expand Down Expand Up @@ -168,7 +167,7 @@ public function testPsalmDiff(): void
$this->assertStringContainsString('InvalidReturnType', $result['STDOUT']);
$this->assertStringContainsString('InvalidReturnStatement', $result['STDOUT']);
$this->assertStringContainsString('3 errors', $result['STDOUT']);
$this->assertEquals(1, substr_count($result['STDERR'], 'E')); // Should only have 'E' from 'Extensions' in version message
$this->assertStringNotContainsString('E', $result['STDERR']);

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

Expand Down