1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Merge pull request #9089 from lptn/cleaunup-unsupported-extentions-message

Cleanup unsupported extensions message
This commit is contained in:
orklah 2023-01-10 23:29:13 +01:00 committed by GitHub
commit 6bcd3bffe3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 91 additions and 6 deletions

View File

@ -612,6 +612,73 @@ class Config
"xdebug" => false,
];
/**
* A list of php extensions described in CallMap Psalm files
* as opposite to stub files loaded by condition (see stubs/extensions dir).
*
* @see https://www.php.net/manual/en/extensions.membership.php
* @var list<non-empty-string>
* @readonly
*/
public $php_extensions_supported_by_psalm_callmaps = [
'apache',
'bcmath',
'bzip2',
'calendar',
'ctype',
'curl',
'dom',
'enchant',
'exif',
'filter',
'gd',
'gettext',
'gmp',
'hash',
'iconv',
'imap',
'intl',
'json',
'ldap',
'libxml',
'mbstring',
'mysqli',
'mysqlnd',
'mhash',
'oci8',
'opcache',
'openssl',
'pcntl',
'PDO',
'pdo_mysql',
'pdo-sqlite',
'pdo-pgsql',
'pgsql',
'pspell',
'phar',
'phpdbg',
'posix',
'redis',
'readline',
'session',
'sockets',
'sqlite3',
'snmp',
'soap',
'sodium',
'shmop',
'sysvsem',
'tidy',
'tokenizer',
'uodbc',
'xml',
'xmlreader',
'xmlwriter',
'xsl',
'zip',
'zlib',
];
/**
* A list of php extensions required by the project that aren't fully supported by Psalm.
*
@ -2158,7 +2225,7 @@ class Config
$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> directive in Psalm config.\n");
. " or use <enableExtensions> and/or <disableExtensions> directives in Psalm config.\n");
}
}

View File

@ -85,6 +85,7 @@ use function number_format;
use function pcntl_fork;
use function preg_match;
use function rename;
use function sprintf;
use function stream_set_blocking;
use function stream_socket_accept;
use function stream_socket_client;
@ -533,8 +534,6 @@ class ProjectAnalyzer
{
$codebase = $this->codebase;
$version = $codebase->getMajorAnalysisPhpVersion() . '.' . $codebase->getMinorAnalysisPhpVersion();
switch ($codebase->php_version_source) {
case 'cli':
$source = '(set by CLI argument)';
@ -553,9 +552,28 @@ class ProjectAnalyzer
break;
}
return "Target PHP version: $version $source Extensions enabled: "
. implode(", ", array_keys(array_filter($codebase->config->php_extensions))) . " (unsupported extensions: "
. implode(", ", array_keys($codebase->config->php_extensions_not_supported)) . ")\n";
$unsupported_php_extensions = array_diff(
array_keys($codebase->config->php_extensions_not_supported),
$codebase->config->php_extensions_supported_by_psalm_callmaps,
);
$message = sprintf(
"Target PHP version: %d.%d %s",
$codebase->getMajorAnalysisPhpVersion(),
$codebase->getMinorAnalysisPhpVersion(),
$source,
);
if (count($codebase->config->php_extensions) > 0) {
$enabled_extensions_names = array_keys(array_filter($codebase->config->php_extensions));
$message .= ' Enabled extensions: ' . implode(', ', $enabled_extensions_names);
}
if (count($unsupported_php_extensions) > 0) {
$message .= ' (unsupported extensions: ' . implode(', ', $unsupported_php_extensions) . ')';
}
return "$message.\n";
}
public function check(string $base_dir, bool $is_diff = false): void