Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Closed
shrikeh wants to merge0 commits intosymfony:6.2fromshrikeh:feature/add-interface-to-describe-uids-with-datetime-behaviour
Closed

[Uid] Add interface forgetDateTime() and apply to relevant UIDs#47507

shrikeh wants to merge0 commits intosymfony:6.2fromshrikeh:feature/add-interface-to-describe-uids-with-datetime-behaviour

Conversation

@shrikeh
Copy link
Contributor

QA
Branch?6.2
Bug fix?no
New feature?yes
Deprecations?no
TicketsN/A
LicenseMIT
Doc PRUnclear how this would be documented.

Minor "feature" of better describing that certain flavours of UID have embedded DateTimeImmutable. The methodgetDateTime() is described in the interface, and applied to the relevant UID flavours. This allows usage of the functionality through simplerinstanceof inspection, or as a typed property of a class representing an entity. A trivial example:

if ($uidinstanceof DateTimeUidInterface) {return$uid->getDateTime();}// throw an Exception if not, or return a default DateTimeImmutable...

@nicolas-grekas
Copy link
Member

What about addingAbstractUid::getDateTime(): ?DateTimeImmutable instead?

@shrikeh
Copy link
ContributorAuthor

What about addingAbstractUid::getDateTime(): ?DateTimeImmutable instead?

Potentially, though personally it would feel like an anti-pattern to me as the behaviour is specific to only certain implementations.

derrabus and jvasseur reacted with thumbs up emoji

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedSep 7, 2022
edited
Loading

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.

@derrabus
Copy link
Member

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.TimeBasedUidInterface?

jvasseur and shrikeh reacted with thumbs up emoji

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedSep 7, 2022
edited
Loading

AbstractTimedUid extends AbstractUid?

@nicolas-grekas
Copy link
Member

AbstractTimedUid extends AbstractUid?

Well, won't work since classUuid already extendsAbstractUid and not all UUIDs are time-based.

TimeBasedUidInterface is the correct name since we already haveTimeBasedUuidFactory.

@nicolas-grekas
Copy link
Member

One more thing: we might want to declareTimeBasedUuidFactory::create() as returningUuid&TimeBasedUidInterface

derrabus and shrikeh reacted with thumbs up emoji

@carsonbotcarsonbot changed the titleAdd interface forgetDateTime() and apply to relevant UIDs[Uid] Add interface forgetDateTime() and apply to relevant UIDsSep 7, 2022
@shrikeh
Copy link
ContributorAuthor

@nicolas-grekas is psalm failing on the intersection forTimeBasedUuidFactory::create()?

@nicolas-grekas
Copy link
Member

Looks like so 🤷
We're going to ignore it then.

@nicolas-grekas
Copy link
Member

Thank you@shrikeh.

nicolas-grekas added a commit that referenced this pull requestSep 7, 2022
…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
@shrikehshrikeh deleted the feature/add-interface-to-describe-uids-with-datetime-behaviour branchSeptember 7, 2022 15:38
@fabpotfabpot mentioned this pull requestOct 24, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@derrabusderrabusderrabus requested changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

6.2

Development

Successfully merging this pull request may close these issues.

4 participants

@shrikeh@nicolas-grekas@derrabus@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp