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

Intersection between object and named class/interface should return latter #1686

Closed
muglug opened this issue May 25, 2019 · 1 comment
Closed
Labels

Comments

@muglug
Copy link
Collaborator

muglug commented May 25, 2019

class C {}

interface IFoo {
    function foo() : object;
}

interface IBar {
    function foo() : C;
}

/** @param IFoo&IBar $i */
function iFooFirst($i) : stdClass {
    return $i->foo();
}

/** @param IBar&IFoo $i */
function iBarFirst($i) : stdClass {
    return $i->foo();
}

Expected: two InvalidReturnStatement
Actual: one InvalidReturnStatement, one LessSpecificReturnStatement

@bdsl
Copy link
Contributor

bdsl commented May 26, 2019

I found a related issue, which might be worth treating as another of example of the same thing - intersection between int and string should return no-return. In fact it currently returns either int or string, depending which way around the intersection is written.

https://psalm.dev/r/3f21ea9de1

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

No branches or pull requests

2 participants