Skip to content

Commit

Permalink
Merge pull request #6534 from orklah/restr-types
Browse files Browse the repository at this point in the history
remove unused nullable on param types
  • Loading branch information
orklah authored Sep 25, 2021
2 parents 9c65953 + 3e6bf6f commit f279f6c
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/Psalm/Context.php
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ public function isPhantomClass(string $class_name): bool
return isset($this->phantom_classes[strtolower($class_name)]);
}

public function hasVariable(?string $var_name): bool
public function hasVariable(string $var_name): bool
{
if (!$var_name) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function analyze(
Context $outer_context,
Codebase $codebase,
IfScope $if_scope,
?int $branch_point
int $branch_point
): IfConditionalScope {
$entry_clauses = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static function analyze(
Context $else_context,
Context $outer_context,
Codebase $codebase,
?int $branch_point
int $branch_point
): ?bool {
$pre_conditional_context = clone $else_context;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ public static function checkArgumentsMatch(
private static function handlePossiblyMatchingByRefParam(
StatementsAnalyzer $statements_analyzer,
Codebase $codebase,
?string $method_id,
string $method_id,
?string $cased_method_id,
?FunctionLikeParameter $last_param,
array $function_params,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,6 @@ public static function analyze(
$result,
$return_type_candidate,
$all_intersection_return_type,
$method_name_lc,
$codebase
);
}
Expand Down Expand Up @@ -518,28 +517,19 @@ private static function getIntersectionReturnType(

private static function updateResultReturnType(
AtomicMethodCallAnalysisResult $result,
?Type\Union $return_type_candidate,
Type\Union $return_type_candidate,
?Type\Union $all_intersection_return_type,
string $method_name,
Codebase $codebase
) : void {
if ($return_type_candidate) {
if ($all_intersection_return_type) {
$return_type_candidate = Type::intersectUnionTypes(
$all_intersection_return_type,
$return_type_candidate,
$codebase
) ?: Type::getMixed();
}

$result->return_type = Type::combineUnionTypes($return_type_candidate, $result->return_type);
} elseif ($all_intersection_return_type) {
$result->return_type = Type::combineUnionTypes($all_intersection_return_type, $result->return_type);
} elseif ($method_name === '__tostring') {
$result->return_type = Type::getString();
} else {
$result->return_type = Type::getMixed();
if ($all_intersection_return_type) {
$return_type_candidate = Type::intersectUnionTypes(
$all_intersection_return_type,
$return_type_candidate,
$codebase
) ?: Type::getMixed();
}

$result->return_type = Type::combineUnionTypes($return_type_candidate, $result->return_type);
}

private static function handleInvalidClass(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static function analyze(
Codebase $codebase,
PhpParser\Node\Expr\MethodCall $stmt,
?string $lhs_var_id,
?string $cased_method_id,
string $cased_method_id,
MethodIdentifier $method_id,
\Psalm\Storage\MethodStorage $method_storage,
\Psalm\Storage\ClassLikeStorage $class_storage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ private static function handleDependentTypeFunction(
StatementsAnalyzer $statements_analyzer,
PhpParser\Node\Expr\FuncCall $stmt,
PhpParser\Node\Expr\FuncCall $real_stmt,
?string $function_id,
string $function_id,
Context $context
) : void {
$first_arg = isset($stmt->args[0]) ? $stmt->args[0] : null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public static function analyze(

public static function getGlobalConstType(
Codebase $codebase,
?string $fq_const_name,
string $fq_const_name,
string $const_name
): ?Type\Union {
if ($const_name === 'STDERR'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function __construct(Config $config)
$this->modified_timestamps .= $this->config->computeHash();
}

public function writeToCache(ClassLikeStorage $storage, ?string $file_path, ?string $file_contents): void
public function writeToCache(ClassLikeStorage $storage, string $file_path, string $file_contents): void
{
$fq_classlike_name_lc = strtolower($storage->name);

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Provider/ClassLikeStorageProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function has(string $fq_classlike_name): bool
return isset(self::$storage[$fq_classlike_name_lc]);
}

public function exhume(string $fq_classlike_name, ?string $file_path, ?string $file_contents): ClassLikeStorage
public function exhume(string $fq_classlike_name, string $file_path, string $file_contents): ClassLikeStorage
{
$fq_classlike_name_lc = strtolower($fq_classlike_name);

Expand Down

0 comments on commit f279f6c

Please sign in to comment.