Skip to content

Commit

Permalink
fix other places that have a similar bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kkmuffme committed Dec 18, 2023
1 parent f8a53eb commit a8e072a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/Psalm/Codebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -1688,7 +1688,7 @@ public function getSignatureInformation(
if (InternalCallMapHandler::inCallMap($function_symbol)) {
$callables = InternalCallMapHandler::getCallablesFromCallMap($function_symbol);

if (!$callables || !$callables[0]->params) {
if (!$callables || !isset($callables[0]->params)) {
return null;
}

Expand Down Expand Up @@ -1838,7 +1838,7 @@ public function getBeginedLiteralPart(string $file_path, Position $position): st
$offset = $position->toOffset($file_contents);

preg_match('/\$?\w+$/', substr($file_contents, 0, $offset), $matches);

return $matches[0] ?? '';
}

Expand All @@ -1857,7 +1857,7 @@ public function getTypeContextAtPosition(string $file_path, Position $position):
}
// First parameter to a function-like
$function_storage = $this->getFunctionStorageForSymbol($file_path, $function . '()');
if (!$function_storage || !$function_storage->params || !isset($function_storage->params[$argument_num])) {
if (!$function_storage || !isset($function_storage->params) || !isset($function_storage->params[$argument_num])) {

Check failure on line 1860 in src/Psalm/Codebase.php

View workflow job for this annotation

GitHub Actions / build

DocblockTypeContradiction

src/Psalm/Codebase.php:1860:17: DocblockTypeContradiction: Docblock-defined type list<Psalm\Storage\FunctionLikeParameter> for $function_storage->params is always isset (see https://psalm.dev/155)

Check failure on line 1860 in src/Psalm/Codebase.php

View workflow job for this annotation

GitHub Actions / build

DocblockTypeContradiction

src/Psalm/Codebase.php:1860:39: DocblockTypeContradiction: Cannot resolve types for $function_storage->params with docblock-defined type list<Psalm\Storage\FunctionLikeParameter> and !isset assertion (see https://psalm.dev/155)
return null;
}

Expand Down Expand Up @@ -1957,7 +1957,7 @@ public function getCompletionItemsForClassishThing(
str_replace('$', '', $property_name),
);
}

foreach ($class_storage->pseudo_property_set_types as $property_name => $type) {
$pseudo_property_types[$property_name] = new CompletionItem(
str_replace('$', '', $property_name),
Expand All @@ -1969,7 +1969,7 @@ public function getCompletionItemsForClassishThing(
str_replace('$', '', $property_name),
);
}

$completion_items = [...$completion_items, ...array_values($pseudo_property_types)];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Psalm/Internal/Codebase/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ public function isCallMapFunctionPure(
null,
);

if (!$function_callable->params
if (!isset($function_callable->params)
|| ($args !== null && count($args) === 0)
|| ($function_callable->return_type && $function_callable->return_type->isVoid())
) {
Expand Down

0 comments on commit a8e072a

Please sign in to comment.