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

[TypeDeclaration] Skip use return docblock on typed intersection type #1728

Merged
merged 13 commits into from
Jan 26, 2022

Conversation

samsonasik
Copy link
Member

@samsonasik samsonasik commented Jan 25, 2022

@TomasVotruba this continue PR #1727. Given the following code:

    /**
     * @template T
     * @psalm-param class-string<T> $className
     * @return string
     */
    protected function getObject(string $className): object {
    	$object = new $className();

        if (!$object instanceof $className) {
            throw new Exception();
        }

        return $object;
    }

It produce replace return object to string, which invalid:

-    protected function getObject(string $className): object {
+    protected function getObject(string $className): string {

@samsonasik samsonasik changed the title [TypeDeclaration] Skip use return docblock on typed intersection type [TypeDeclaration] Handle use return docblock on typed intersection type Jan 25, 2022
@samsonasik samsonasik marked this pull request as draft January 25, 2022 15:09
@samsonasik samsonasik force-pushed the skip-use-return-doc-on-typed-intersection branch from a75be7f to 71e52dd Compare January 26, 2022 09:45
@samsonasik samsonasik changed the title [TypeDeclaration] Handle use return docblock on typed intersection type [TypeDeclaration] Skip use return docblock on typed intersection type Jan 26, 2022
@samsonasik samsonasik force-pushed the skip-use-return-doc-on-typed-intersection branch from 82a9bbf to e54b334 Compare January 26, 2022 09:47
@samsonasik
Copy link
Member Author

Fixed 🎉 with skip when in resolved type name is 'string' or 'object'

@samsonasik samsonasik marked this pull request as ready for review January 26, 2022 09:58
@samsonasik
Copy link
Member Author

All checks have passed 🎉 @TomasVotruba it is ready for review.

@samsonasik samsonasik force-pushed the skip-use-return-doc-on-typed-intersection branch from c34b181 to 8876d3c Compare January 26, 2022 10:25
@TomasVotruba TomasVotruba merged commit a26c59a into main Jan 26, 2022
@TomasVotruba TomasVotruba deleted the skip-use-return-doc-on-typed-intersection branch January 26, 2022 11:11
@TomasVotruba
Copy link
Member

Thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants