mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Fix #2380 - prevent string docblock for callable param
This commit is contained in:
parent
4334ddcaa3
commit
a154191922
@ -1031,11 +1031,14 @@ class Config
|
||||
{
|
||||
$codebase = $project_analyzer->getCodebase();
|
||||
|
||||
$project_analyzer->progress->debug('Initializing plugins...' . PHP_EOL);
|
||||
|
||||
$socket = new PluginRegistrationSocket($this, $codebase);
|
||||
// initialize plugin classes earlier to let them hook into subsequent load process
|
||||
foreach ($this->plugin_classes as $plugin_class_entry) {
|
||||
$plugin_class_name = $plugin_class_entry['class'];
|
||||
$plugin_config = $plugin_class_entry['config'];
|
||||
|
||||
try {
|
||||
// Below will attempt to load plugins from the project directory first.
|
||||
// Failing that, it will use registered autoload chain, which will load
|
||||
@ -1045,6 +1048,10 @@ class Config
|
||||
if ($this->composer_class_loader
|
||||
&& ($plugin_class_path = $this->composer_class_loader->findFile($plugin_class_name))
|
||||
) {
|
||||
$project_analyzer->progress->debug(
|
||||
'Loading plugin ' . $plugin_class_name . ' via require'. PHP_EOL
|
||||
);
|
||||
|
||||
/** @psalm-suppress UnresolvableInclude */
|
||||
require_once($plugin_class_path);
|
||||
} else {
|
||||
@ -1063,6 +1070,8 @@ class Config
|
||||
} catch (\Throwable $e) {
|
||||
throw new ConfigException('Failed to load plugin ' . $plugin_class_name, 0, $e);
|
||||
}
|
||||
|
||||
$project_analyzer->progress->debug('Loaded plugin ' . $plugin_class_name . ' successfully'. PHP_EOL);
|
||||
}
|
||||
|
||||
foreach ($this->filetype_scanner_paths as $extension => $path) {
|
||||
|
@ -1374,7 +1374,7 @@ class TypeAnalyzer
|
||||
|
||||
if ($container_type_part instanceof TCallable &&
|
||||
(
|
||||
$input_type_part instanceof TString
|
||||
$input_type_part instanceof TLiteralString
|
||||
|| $input_type_part instanceof TArray
|
||||
|| $input_type_part instanceof ObjectLike
|
||||
|| $input_type_part instanceof TList
|
||||
|
@ -1574,6 +1574,16 @@ class CallableTest extends TestCase
|
||||
new Func("f", ["Foo", "bar"]);',
|
||||
'error_message' => 'InvalidArgument'
|
||||
],
|
||||
'preventStringDocblockType' => [
|
||||
'<?php
|
||||
/**
|
||||
* @param string $mapper
|
||||
*/
|
||||
function map2(callable $mapper): void {}
|
||||
|
||||
map2("foo");',
|
||||
'error_message' => 'MismatchingDocblockParamType',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user