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 a way how to load stubs for extensions #8881

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 7 additions & 20 deletions src/Psalm/Config.php
Expand Up @@ -62,7 +62,6 @@
use function count;
use function dirname;
use function explode;
use function extension_loaded;
use function fclose;
use function file_exists;
use function file_get_contents;
Expand Down Expand Up @@ -590,11 +589,16 @@ class Config
public $threads;

/**
* A list of php extensions supported by Psalm.
* Where key - extension name (without ext- prefix), value - whether to load extension’s stub.
*
* @psalm-readonly-allow-private-mutation
* @var array{
* apcu: bool,
* decimal: bool,
* dom: bool,
* ds: bool,
* ffi: bool,
* geos: bool,
* gmp: bool,
* mongodb: bool,
Expand All @@ -603,13 +607,14 @@ class Config
* simplexml: bool,
* soap: bool,
* xdebug: bool,
* ffi: bool,
* }
*/
public $php_extensions = [
"apcu" => false,
"decimal" => false,
"dom" => false,
"ds" => false,
"ffi" => false,
"geos" => false,
"gmp" => false,
"mongodb" => false,
Expand All @@ -618,7 +623,6 @@ class Config
"simplexml" => false,
"soap" => false,
"xdebug" => false,
"ffi" => false,
];

/**
Expand Down Expand Up @@ -2142,23 +2146,6 @@ public function visitStubFiles(Codebase $codebase, ?Progress $progress = null):
}
}

// phpredis
if (extension_loaded('redis')) {
$ext_phpredis_path = $dir_lvl_2 . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'phpredis.phpstub';
$this->internal_stubs[] = $ext_phpredis_path;
}

if (extension_loaded('apcu')) {
$ext_apcu_path = $dir_lvl_2 . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR . 'ext-apcu.phpstub';
$this->internal_stubs[] = $ext_apcu_path;
}

if (extension_loaded('random')) {
$ext_random_path = $dir_lvl_2 . DIRECTORY_SEPARATOR . 'stubs' . DIRECTORY_SEPARATOR
. 'extensions' . DIRECTORY_SEPARATOR . 'ext-random.phpstub';
$this->internal_stubs[] = $ext_random_path;
}

foreach ($this->internal_stubs as $stub_path) {
if (!file_exists($stub_path)) {
throw new UnexpectedValueException('Cannot locate ' . $stub_path);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.