Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfox committed Oct 6, 2024
1 parent 5c77c9c commit 0c2de7c
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ public function getNodeTypes(): array
*/
public function refactor(Node $node): ?Node
{
$varType = $this->getType($node->var);

if (! $varType instanceof IntersectionType || ! $varType->isIterable()->yes()) {
if ($node->isFirstClassCallable()) {
return null;
}

if ($node->isFirstClassCallable()) {
$varType = $this->getType($node->var);

if (! $varType instanceof IntersectionType || ! $varType->isIterable()->yes()) {
return null;
}

Expand Down Expand Up @@ -145,9 +145,11 @@ public function refactor(Node $node): ?Node
if (! $arg instanceof Arg) {
continue;
}

if (! $arg->value instanceof Closure) {
continue;
}

$parameter = (is_string($index) ? $parameters[$nameIndex[$index]] : $parameters[$index]);

if ($this->updateClosureWithTypes($className, $parameter, $arg->value, $keyType, $valueType)) {
Expand Down Expand Up @@ -214,6 +216,11 @@ private function refactorParameter(Param $param, Type $type): bool
}

$paramTypeNode = $this->staticTypeMapper->mapPHPStanTypeToPhpParserNode($type, TypeKind::PARAM);

if (! $paramTypeNode instanceof Node) {
return false;
}

$param->type = $paramTypeNode;

return true;
Expand Down

0 comments on commit 0c2de7c

Please sign in to comment.