Refactor TryRemove/Accepts for DateTime|DateTimeImmutable and Exception|Error#3654
Refactor TryRemove/Accepts for DateTime|DateTimeImmutable and Exception|Error#3654ondrejmirtes merged 6 commits intophpstan:2.0.xfrom
Conversation
| public const EQUAL_UNION_CLASSES = [ | ||
| DateTimeInterface::class => [DateTimeImmutable::class, DateTime::class], | ||
| Throwable::class => [Error::class, Exception::class], | ||
| Traversable::class => [IteratorAggregate::class, Iterator::class], | ||
| ]; |
There was a problem hiding this comment.
Not sure if I need to put this constant somewhere else (like UnionTypeHelper) / as a static function or with a better naming.
I support any number of classes in values, just in case.
|
shouldn't this be implemented through the mechanism of |
|
@stof We tried that but it didn't work for some reason. I think that rules reading the "allowed subtypes" extensions would report some unwanted errors. |
15e6b56 to
8590a1e
Compare
|
This pull request has been marked as ready for review. |
src/Type/UnionType.php
Outdated
| public const EQUAL_UNION_CLASSES = [ | ||
| DateTimeInterface::class => [DateTimeImmutable::class, DateTime::class], | ||
| Throwable::class => [Error::class, Exception::class], // phpcs:ignore SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.ReferencedGeneralException | ||
| Traversable::class => [IteratorAggregate::class, Iterator::class], |
There was a problem hiding this comment.
I'd accept part of this PR - the refactoring into this constant. Without addition of the Traversable entry.
|
I changed the base to 2.0.x, please fix the confict. Thanks. |
f0ccea4 to
b897b8d
Compare
Done |
|
Thank you. |
Closes phpstan/phpstan#12102