Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PHPStanStaticTypeMapper] FQCN for Closure type mapper #4584

Merged
merged 12 commits into from
Jul 23, 2023
Merged

Conversation

samsonasik
Copy link
Member

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba I think it is ready.

@samsonasik
Copy link
Member Author

@TomasVotruba the issue with this is, currently, $rectorConfig->importNames() doesn't detect it to be imported to use statement, so NameImportingPhpDocNodeVisitor need to be refactored to allow detect it.

if (! $node instanceof IdentifierTypeNode) {
return null;
}
$staticType = $this->identifierTypeMapper->mapIdentifierTypeNode($node, $this->currentPhpParserNode);

@samsonasik
Copy link
Member Author

It seems NameImportingPhpDocNodeVisitor need to support PHPStan\PhpDocParser\Ast\Type\CallableTypeNode

@samsonasik
Copy link
Member Author

I added auto import failing test case

@samsonasik
Copy link
Member Author

short classes seems excluded by default, so it won't be applied even tweaked

// Importing root namespace classes (like \DateTime) is optional
if ($this->shouldSkipShortClassName($staticType)) {
return null;
}

I reverted auto import test.

The FQCN-ize is happen on printing, so it should be ok.

@samsonasik
Copy link
Member Author

I added test to skip reprint for existing closure nullable skip already nullable closure var so should be fine

@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba let's merge it to have faster feedback to test ;)

@samsonasik samsonasik enabled auto-merge (squash) July 23, 2023 23:25
@samsonasik samsonasik merged commit 578d637 into main Jul 23, 2023
44 checks passed
@samsonasik samsonasik deleted the fqcn-closure branch July 23, 2023 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants