diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
index eae87fe4e..2b8d52721 100644
--- a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php
@@ -1180,14 +1180,19 @@ class CallAnalyzer
$codebase = $statements_analyzer->getCodebase();
if ($method_id) {
- if ($in_call_map || !strpos($method_id, '::')) {
+ if (!$in_call_map && strpos($method_id, '::')) {
+ $fq_class_name = explode('::', $method_id)[0];
+ }
+
+ if ($function_storage) {
+ $is_variadic = $function_storage->variadic;
+ } elseif ($fq_class_name === null) {
$is_variadic = $codebase->functions->isVariadic(
$codebase,
strtolower($method_id),
$statements_analyzer->getRootFilePath()
);
} else {
- $fq_class_name = explode('::', $method_id)[0];
$is_variadic = $codebase->methods->isVariadic($method_id);
}
}
diff --git a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php
index be045f898..78f38cf68 100644
--- a/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php
+++ b/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php
@@ -2317,7 +2317,7 @@ class StatementsAnalyzer extends SourceAnalyzer implements StatementsSource
$is_expected = false;
foreach ($ignored_exceptions_and_descendants as $expected_exception => $_) {
- if ($expected_exception === $possibly_thrown_exception
+ if ($expected_exception === strtolower($possibly_thrown_exception)
|| $this->codebase->classExtends($possibly_thrown_exception, $expected_exception)
) {
$is_expected = true;
diff --git a/tests/VariadicTest.php b/tests/VariadicTest.php
index 67a7b2917..306f098bd 100644
--- a/tests/VariadicTest.php
+++ b/tests/VariadicTest.php
@@ -1,7 +1,11 @@
analyzeFile('somefile.php', new Context());
}
+ /**
+ * @throws \Psalm\Exception\ConfigException
+ * @return void
+ */
+ public function testVariadicFunctionFromAutoloadFile()
+ {
+ $this->project_analyzer = $this->getProjectAnalyzerWithConfig(
+ TestConfig::loadFromXML(
+ dirname(__DIR__),
+ '
+
+
+
+
+ '
+ )
+ );
+
+ $file_path = getcwd() . '/src/somefile.php';
+
+ $this->addFile(
+ $file_path,
+ 'analyzeFile($file_path, new Context());
+ }
+
/**
* @return iterable,2?:string[]}>
*/
@@ -91,4 +127,25 @@ class VariadicTest extends TestCase
],
];
}
+
+ /**
+ * @param Config $config
+ *
+ * @return \Psalm\Internal\Analyzer\ProjectAnalyzer
+ */
+ private function getProjectAnalyzerWithConfig(Config $config)
+ {
+ $project_analyzer = new \Psalm\Internal\Analyzer\ProjectAnalyzer(
+ $config,
+ new \Psalm\Internal\Provider\Providers(
+ $this->file_provider,
+ new Provider\FakeParserCacheProvider()
+ )
+ );
+ $project_analyzer->setPhpVersion('7.3');
+
+ $config->visitComposerAutoloadFiles($project_analyzer, null);
+
+ return $project_analyzer;
+ }
}
diff --git a/tests/fixtures/stubs/custom_functions.php b/tests/fixtures/stubs/custom_functions.php
index 32d21d535..b9a1c76c3 100644
--- a/tests/fixtures/stubs/custom_functions.php
+++ b/tests/fixtures/stubs/custom_functions.php
@@ -10,3 +10,8 @@ function barBar(string $a) : string
function variadic()
{
}
+
+function variadic2() : array
+{
+ return func_get_args();
+}