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

[Clock] Return Symfony ClockInterface in ClockSensitiveTrait#53080

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

Merged
fabpot merged 1 commit intosymfony:7.1fromruudk:patch-1
Jan 6, 2024

Conversation

@ruudk
Copy link
Contributor

@ruudkruudk commentedDec 14, 2023
edited by xabbuh
Loading

QA
Branch?6.4
Bug fix?no
New feature?no
Deprecations?no
Issues
LicenseMIT

@nicolas-grekas I don't understand why the ClockSensitiveTrait::mockTime returns a PSR ClockInterface, instead of a Symfony ClockInterface. Is this done on purpose? Or was this a mistake?

@carsonbotcarsonbot added this to the6.4 milestoneDec 14, 2023
@ruudkruudk marked this pull request as draftDecember 14, 2023 15:21
@alexandre-daubois
Copy link
Member

In the same idea, I'm not sure to clearly understand the convention in the code base on which class to use when one is available in Contracts, PSR and in the component itself (e.g. EventDispatcher)? 🤔

@carsonbotcarsonbot changed the titleReturn Symfony ClockInterface in ClockSensitiveTrait[Clock] Return Symfony ClockInterface in ClockSensitiveTraitDec 18, 2023
@nicolas-grekas
Copy link
Member

why the ClockSensitiveTrait::mockTime returns a PSR ClockInterface, instead of a Symfony ClockInterface

No specific reason I can think of...

In the same idea, I'm not sure to clearly understand the convention in the code base on which class to use when one is available in Contracts, PSR and in the component itself (e.g. EventDispatcher)? 🤔

See SOLID principles: use the most abstract interface when it fits your need. If you need a more capable interface, use the more capable one.

alexandre-daubois reacted with thumbs up emoji

@stof
Copy link
Member

Anytime a component only needs the API of the PSR interface, we use that as parameter type as it makes the component usable with any PSR-20 implementation and not justsymfony/clock

alexandre-daubois reacted with thumbs up emoji

@alexandre-daubois
Copy link
Member

Got it, thank you both 👍

@nicolas-grekas
Copy link
Member

@ruudk please advise what you'd like to do with this PR. "Draft status" is blurry for OSS maintainers.

@ruudkruudk marked this pull request as ready for reviewJanuary 2, 2024 14:58
@ruudk
Copy link
ContributorAuthor

I made it Draft because I wasn't sure. So I made it ready for review now.

I think that the return type should be the thing that is going to be returned. That allows the developer, when using this in the test, to callwithTimeZone on the returned Symfony Clock. Obviously, that already works, except that PHPStorm and PHPStan don't understand it.

Copy link
Member

@xabbuhxabbuh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

for 7.1 (this doesn't look like a bugfix to me)

@fabpotfabpot modified the milestones:6.4,7.1Jan 6, 2024
I don't understand why the ClockSensitiveTrait::mockTime returns a PSR ClockInterface, instead of a Symfony ClockInterface.Is this done on purpose? Or was this a mistake?
@fabpotfabpot changed the base branch from6.4 to7.1January 6, 2024 14:53
@fabpot
Copy link
Member

Thank you@ruudk.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@xabbuhxabbuhxabbuh approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

7.1

Development

Successfully merging this pull request may close these issues.

8 participants

@ruudk@alexandre-daubois@nicolas-grekas@stof@fabpot@xabbuh@OskarStark@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp