-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Add support for stubs to declare intersection type class properties #8751
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that proper intersection type support is still needed in the below methods:
Type::fromString()
Type::toOptimizerTypeMask()
andType::toOptimizerTypeMaskForArrayValue()
Type::getTypeForDoc()
(+ phd support should also be added)Type::equals()
Type::toString()
37f08dc
to
ccc23ce
Compare
Done
Maybe I'm wrong, but this seems unapplicable because intersection types can't have scalars types?
PhD support has been added a while ago: php/phd@094794e
I'm not sure any changes need to be made to that as the logic looks sound to me for both cases
Done |
@@ -17,6 +17,7 @@ class _ZendTestClass implements _ZendTestInterface { | |||
public int $intProp = 123; | |||
public ?stdClass $classProp = null; | |||
public stdClass|Iterator|null $classUnionProp = null; | |||
public Traversable&Countable $classIntersectionProp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think it's worthwhile to also add a function with intersection param and return types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how to do the check with ZPP or is it possible to them manually?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think you should rely on manual param parsing for now, but we could add a ZPP when we will have a real use-case for an internal intersection param type.
Even though optimizer type masks support the object type, you are right in the sense that we cannot really specify the type mask further now. The only small issue I can imagine with the current implementation (and probably it's an existing problem) is that |
Isn't it a bitmask? So adding it multiple times shouldn't change anything other than being somewhat redundant? |
Yes, I was only referring to the redundancy. :) |
ccc23ce
to
9aaa860
Compare
Haven't figured out yet how to do return types and function parameter types, but this is a start.