Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Uid] Add interface forgetDateTime() and apply to relevant UIDs#47507
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[Uid] Add interface forgetDateTime() and apply to relevant UIDs#47507
Uh oh!
There was an error while loading.Please reload this page.
Conversation
What about adding |
Potentially, though personally it would feel like an anti-pattern to me as the behaviour is specific to only certain implementations. |
Uh oh!
There was an error while loading.Please reload this page.
nicolas-grekas commentedSep 7, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'm not a fan of interfaces on value objects personally. I would prefer a new method on the abstract class because it keeps things simple, and it doesn't force any extra logic on consumers. Actually, nullable return values are easier to deal with thanks to nullsafe operators. |
I like the interface, I must admit. It plays nicer with static analysis than a nullable type. We might want to find a better name though. |
nicolas-grekas commentedSep 7, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
|
Well, won't work since class
|
One more thing: we might want to declare |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
getDateTime() and apply to relevant UIDsgetDateTime() and apply to relevant UIDs@nicolas-grekas is psalm failing on the intersection for |
Looks like so 🤷 |
Thank you@shrikeh. |
…elevant UIDs (shrikeh)This PR was squashed before being merged into the 6.2 branch.Discussion----------[Uid] Add interface for `getDateTime()` and apply to relevant UIDs| Q | A| ------------- | ---| Branch? | 6.2| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets | N/A| License | MIT| Doc PR | Unclear how this would be documented.Minor "feature" of better describing that certain flavours of UID have embedded DateTimeImmutable. The method `getDateTime()` is described in the interface, and applied to the relevant UID flavours. This allows usage of the functionality through simpler `instanceof` inspection, or as a typed property of a class representing an entity. A trivial example:```phpif ($uid instanceof DateTimeUidInterface) { return $uid->getDateTime();}// throw an Exception if not, or return a default DateTimeImmutable...```Commits-------0f1bc36 [Uid] Add interface for `getDateTime()` and apply to relevant UIDs
Minor "feature" of better describing that certain flavours of UID have embedded DateTimeImmutable. The method
getDateTime()is described in the interface, and applied to the relevant UID flavours. This allows usage of the functionality through simplerinstanceofinspection, or as a typed property of a class representing an entity. A trivial example: