Skip to content

Commit

Permalink
Flesh out class constants in function call return type
Browse files Browse the repository at this point in the history
Fixes #2884
  • Loading branch information
muglug committed Feb 26, 2020
1 parent f189b25 commit ea0a670
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,14 @@ public static function analyze(
);
}

$return_type = ExpressionAnalyzer::fleshOutType(
$codebase,
$return_type,
null,
null,
null
);

$return_type_location = $function_storage->return_type_location;

if ($config->after_function_checks) {
Expand Down
23 changes: 23 additions & 0 deletions tests/TypeReconciliation/ValueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,29 @@ function consumeNumeric(string $string) : void {
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) {}
}'
],
];
}

Expand Down

0 comments on commit ea0a670

Please sign in to comment.