mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
parent
734b6915db
commit
4ff7db09f9
@ -74,7 +74,7 @@ class FunctionChecker extends FunctionLikeChecker
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($call_map_key, ['pathinfo'], true)) {
|
||||
if ($call_map_key === 'pathinfo') {
|
||||
if (isset($call_args[1])) {
|
||||
return Type::getString();
|
||||
}
|
||||
@ -82,6 +82,21 @@ class FunctionChecker extends FunctionLikeChecker
|
||||
return Type::getArray();
|
||||
}
|
||||
|
||||
if ($call_map_key === 'var_export') {
|
||||
if (isset($call_args[1]->value->inferredType)) {
|
||||
/** @var Type\Union */
|
||||
$subject_type = $call_args[1]->value->inferredType;
|
||||
|
||||
if ((string) $subject_type === 'true') {
|
||||
return Type::getString();
|
||||
}
|
||||
|
||||
return new Type\Union([new Type\Atomic\TString, new Type\Atomic\TNull]);
|
||||
}
|
||||
|
||||
return Type::getVoid();
|
||||
}
|
||||
|
||||
if (substr($call_map_key, 0, 6) === 'array_') {
|
||||
$array_return_type = self::getArrayReturnType(
|
||||
$statements_checker,
|
||||
|
@ -589,6 +589,13 @@ class FunctionCallTest extends TestCase
|
||||
'<?php
|
||||
$urls = array_map("implode", [["a", "b"]]);',
|
||||
],
|
||||
'varExport' => [
|
||||
'<?php
|
||||
$a = var_export(["a"], true);',
|
||||
'assertions' => [
|
||||
'$a' => 'string',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -805,6 +812,11 @@ class FunctionCallTest extends TestCase
|
||||
array_map("foo", [1, 2, 3]);',
|
||||
'error_message' => 'TooManyArguments',
|
||||
],
|
||||
'varExportAssignmentToVoid' => [
|
||||
'<?php
|
||||
$a = var_export(["a"]);',
|
||||
'error_message' => 'AssignmentToVoid',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user