1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Flesh out class constants in function call return type

Fixes #2884
This commit is contained in:
Brown 2020-02-26 17:28:31 -05:00
parent f189b25b99
commit ea0a670230
2 changed files with 31 additions and 0 deletions

View File

@ -573,6 +573,14 @@ class FunctionCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expressio
);
}
$return_type = ExpressionAnalyzer::fleshOutType(
$codebase,
$return_type,
null,
null,
null
);
$return_type_location = $function_storage->return_type_location;
if ($config->after_function_checks) {

View File

@ -660,6 +660,29 @@ class ValueTest extends TestCase
consumeNumeric("12.34");'
],
'resolveScalarClassConstant' => [
'<?php
class PaymentFailure {
const NO_CLIENT = "no_client";
const NO_CARD = "no_card";
}
/**
* @return PaymentFailure::NO_CARD|PaymentFailure::NO_CLIENT
*/
function something() {
if (rand(0, 1)) {
return PaymentFailure::NO_CARD;
}
return PaymentFailure::NO_CLIENT;
}
function blah(): void {
$test = something();
if ($test === PaymentFailure::NO_CLIENT) {}
}'
],
];
}