Open stof opened 2 years ago
Noting that getTypes() for the following code may now (PHP8.2) return 'ReflectionIntersectionType':
I'm unsure what the underlying decision to not support ReflectionIntersectionType
was. My assumption is that it was difficult (maybe impossible) to create the double with the necessary values.
Possible solution would be to loop through types looking for ReflectionIntersectionType
and throwing a nice Exception.
It does throw an err. The class effectively turns this:
public function doSomething () : A|(B&D)|null
{
}
Into
public function doSomething(): A|B&D|null { //At least one err here. Should be A|(B&D)|null I believe.
return $this->getProphecy()->makeProphecyMethodCall(__FUNCTION__, func_get_args());
}
All this said, I'm confused by something, so going to ping the php-src group. Either found a bug or something I don't understand.
I'm unsure what the underlying decision to not support ReflectionIntersectionType was
Simply that PHP 8.1 was coming and we wanted a clear exception to be thrown here rather than a hard error
Nobody's made it work since (or TBH has raised an issue)
if someone wants to make intersection types work that's fine, to be clear
The issue tracking proper support for intersection types is #535, but nobody worked on it yet.
See https://wiki.php.net/rfc/dnf_types
We need to make sure they can be doubled properly, with tests ensuring they work fine.