-
Notifications
You must be signed in to change notification settings - Fork 506
Refactor TryRemove/Accepts for DateTime|DateTimeImmutable and Exception|Error #3654
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
src/Type/UnionType.php
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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