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 types #1394

Open
ciaranmcnulty opened this issue Oct 14, 2021 · 2 comments
Open

Intersection types #1394

ciaranmcnulty opened this issue Oct 14, 2021 · 2 comments

Comments

@ciaranmcnulty
Copy link
Member

ciaranmcnulty commented Oct 14, 2021

It'd be nice to be able to ask for an intersection type:

function it_does_stuff( Foo&Bar $fooBar) 
{
   $fooBar->methodFromFoo()->willReturn(1);
   $fooBar->methodFromBar()->willReturn(2);
}

This should be technically possible, Prophecy is happy to double multiple types after all.

This probably won't be useful until Prophecy gets the ability to double classes that use intersections though :/

In the short term we probably want to disallow Intersection type hints in the codebase before we tag a release for 8.1

@GrahamCampbell
Copy link
Contributor

Was about to write "but what about intersection of two classes"... but of course this is ⊥ unless one of them is a subtype of the other, so. :trollface:

@ciaranmcnulty
Copy link
Member Author

Yes I _think_so 😅 That's good to point out though

Reader&XmlReader is just the same as XmlReader so probably an error on the author's part

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

No branches or pull requests

2 participants