Merge pull request #18 from psalm/1.x

Use better API for inferring trans types
This commit is contained in:
Matthew Brown 2019-11-29 09:21:41 -05:00 committed by GitHub
commit 4fdfd6b5c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -4,7 +4,7 @@
"type": "psalm-plugin", "type": "psalm-plugin",
"require": { "require": {
"barryvdh/laravel-ide-helper": "^2.6", "barryvdh/laravel-ide-helper": "^2.6",
"vimeo/psalm": "3.2.*|3.3.*|3.4.*|3.5.*|3.6.*", "vimeo/psalm": "3.7^",
"orchestra/testbench": "^3.5 || ^4.0" "orchestra/testbench": "^3.5 || ^4.0"
}, },
"license": "MIT", "license": "MIT",

View File

@ -25,10 +25,10 @@ class TransReturnTypeProvider implements \Psalm\Plugin\Hook\FunctionReturnTypePr
Context $context, Context $context,
CodeLocation $code_location CodeLocation $code_location
) : Type\Union { ) : Type\Union {
if ($call_args if ($call_args) {
&& isset($call_args[0]->value->inferredType) $first_arg_type = $statements_source->getNodeTypeProvider()->getType($call_args[0]->value);
) {
if ($call_args[0]->value->inferredType->isString()) { if ($first_arg_type && $first_arg_type->isString()) {
return \Psalm\Type::getString(); return \Psalm\Type::getString();
} }
} }