From 32f07fd823270de6440dfd34246d09f71086e563 Mon Sep 17 00:00:00 2001 From: Matthew Brown Date: Mon, 11 Jul 2016 19:57:01 -0400 Subject: [PATCH] Only update type from docblock if it gives more info --- src/CodeInspector/ClassMethodChecker.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/CodeInspector/ClassMethodChecker.php b/src/CodeInspector/ClassMethodChecker.php index 0239feec5..3a9fab804 100644 --- a/src/CodeInspector/ClassMethodChecker.php +++ b/src/CodeInspector/ClassMethodChecker.php @@ -269,17 +269,22 @@ class ClassMethodChecker extends FunctionChecker $docblock_param_type_string = $docblock_param['type']; $existing_param_type = $param_info['type']; - $existing_param_type_nullable = $param_info['is_nullable']; $new_param_type = Type::parseString( self::_fixUpReturnType($docblock_param_type_string, $method_id) ); - if ($existing_param_type_nullable && !$new_param_type->isNullable()) { - $new_param_type->types['null'] = Type::getNull(false); + // only fix the type if we're dealing with an undefined or generic type + if ($existing_param_type->isMixed() || $new_param_type->hasGeneric()) { + $existing_param_type_nullable = $param_info['is_nullable']; + + if ($existing_param_type_nullable && !$new_param_type->isNullable()) { + $new_param_type->types['null'] = Type::getNull(false); + } + + $param_info['type'] = $new_param_type; } - $param_info['type'] = $new_param_type; } } }