1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Fix branch consolidation

This commit is contained in:
Matthew Brown 2016-01-07 20:02:59 -05:00
parent 0fff1b31f2
commit fa37482cec

View File

@ -240,10 +240,8 @@ class FunctionChecker
$this->_checkStaticCall($stmt, $types_in_scope); $this->_checkStaticCall($stmt, $types_in_scope);
} }
else if ($stmt instanceof PhpParser\Node\Expr\ConstFetch) { else if ($stmt instanceof PhpParser\Node\Expr\ConstFetch) {
if (preg_match('/^[A-Z_0-9]+$/', $stmt->name->parts[0])) {
$this->_checkConstFetch($stmt); $this->_checkConstFetch($stmt);
} }
}
else if ($stmt instanceof PhpParser\Node\Scalar\String_) { else if ($stmt instanceof PhpParser\Node\Scalar\String_) {
// do nothing // do nothing
} }
@ -578,7 +576,12 @@ class FunctionChecker
else if (isset($stmt->expr->returnType)) { else if (isset($stmt->expr->returnType)) {
$var_name = $stmt->var->name; $var_name = $stmt->var->name;
if ($stmt->expr->returnType === 'null') {
if (isset($this->_known_types[$var_name])) { if (isset($this->_known_types[$var_name])) {
$this->_known_types[$var_name] = 'mixed';
}
}
else if (isset($this->_known_types[$var_name])) {
$existing_type = $this->_known_types[$var_name]; $existing_type = $this->_known_types[$var_name];
if ($existing_type !== 'mixed') { if ($existing_type !== 'mixed') {
@ -734,7 +737,11 @@ class FunctionChecker
protected function _checkConstFetch(PhpParser\Node\Expr\ConstFetch $stmt) protected function _checkConstFetch(PhpParser\Node\Expr\ConstFetch $stmt)
{ {
if ($stmt->name instanceof PhpParser\Node\Name) {
if ($stmt->name->parts === ['null']) {
$stmt->returnType = 'null';
}
}
} }
protected function _checkClassConstFetch(PhpParser\Node\Expr\ClassConstFetch $stmt, $types_in_scope) protected function _checkClassConstFetch(PhpParser\Node\Expr\ClassConstFetch $stmt, $types_in_scope)