diff --git a/src/CodeInspector/StatementsChecker.php b/src/CodeInspector/StatementsChecker.php index 50ccafd95..67631aadf 100644 --- a/src/CodeInspector/StatementsChecker.php +++ b/src/CodeInspector/StatementsChecker.php @@ -74,7 +74,6 @@ class StatementsChecker $this->_class_extends = $this->_source->getParentClass(); $this->_check_variables = FileChecker::shouldCheckVariables($this->_file_name) || $enforce_variable_checks; - $this->_check_nulls = FileChecker::shouldCheckNulls($this->_file_name); $this->_type_checker = new TypeChecker($source, $this); } @@ -1957,7 +1956,7 @@ class StatementsChecker if ($method_id && isset($arg->value->returnType)) { foreach (explode('|', $arg->value->returnType) as $return_type) { - if (TypeChecker::checkMethodParam($return_type, $method_id, $i, $this->_absolute_class, $this->_check_nulls, $this->_file_name, $arg->value->getLine()) === false) { + if (TypeChecker::checkMethodParam($return_type, $method_id, $i, $this->_absolute_class, $this->_file_name, $arg->value->getLine()) === false) { return false; } } @@ -2270,17 +2269,15 @@ class StatementsChecker $input_types = explode('|', $type); $input_types = array_flip($input_types); - if ($this->_check_nulls) { - if (isset($input_types['null']) && !$is_nullable) { - if (ExceptionHandler::accepts( - new InvalidArgumentException( - 'Argument ' . ($argument_offset + 1) . ' of ' . $method_id . ' cannot be null, possibly null value provided', - $file_name, - $line_number - ) - )) { - return false; - } + if (isset($input_types['null']) && !$is_nullable) { + if (ExceptionHandler::accepts( + new InvalidArgumentException( + 'Argument ' . ($argument_offset + 1) . ' of ' . $method_id . ' cannot be null, possibly null value provided', + $file_name, + $line_number + ) + )) { + return false; } } diff --git a/src/CodeInspector/TypeChecker.php b/src/CodeInspector/TypeChecker.php index d4efac674..e28c7af4e 100644 --- a/src/CodeInspector/TypeChecker.php +++ b/src/CodeInspector/TypeChecker.php @@ -27,7 +27,7 @@ class TypeChecker /** * @return bool */ - public static function checkMethodParam($return_type, $method_id, $arg_offset, $current_class, $check_nulls, $file_name, $line_number) + public static function checkMethodParam($return_type, $method_id, $arg_offset, $current_class, $file_name, $line_number) { if ($return_type === 'mixed') { return true;