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

[Form] minor fixes in DateTime transformers#18548

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
HeahDude wants to merge1 commit intosymfony:2.3fromHeahDude:minor/form-cs_fixes

Conversation

@HeahDude
Copy link
Contributor

QA
Branch?2.3+
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets~
LicenseMIT
Doc PR~

* of \DateTime.
*/
publicfunctiontransform($value)
publicfunctiontransform($dateTime)
Copy link
Member

Choose a reason for hiding this comment

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

-1 for this renaming. It will make it harder to merge branches together for no real benefit

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This needs to be fixed in a way to match the current name in the doc block, otherwise the doc block name should be changed. I did it so it's consistent with all the other DateTime transformers.

I don't understand why do you say it makes it harder to merge if it can be applied in all current maintained branches ?

@xabbuh
Copy link
Member

Can you add a new test to prevent regressions?

@HeahDude
Copy link
ContributorAuthor

@xabbuh I'd like to, but there is no test for this exception in other transformers. I don't know how to make it fail. Any ideas ?

@HeahDude
Copy link
ContributorAuthor

After a deeper look into this, I don't understand why thistry block is in all the other transformers since they all extend theBaseDateTimeTransformer which tests timezones in the constructor. IfsetTimeZone() fails it just returnfalse. So shouldn't we testfalse before throwing instead ?

@HeahDude
Copy link
ContributorAuthor

thrownewTransformationFailedException($e->getMessage(),$e->getCode(),$e);
}

if ($this->outputTimezone !==$dateTime->getTimezone()->getName()) {
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

Thisif condition looks wrong, shouldn't it test the input's timezone ?

$dateTime =clone$dateTime;
if (!$dateTimeinstanceof \DateTimeImmutable) {
$dateTime =clone$dateTime;
}
Copy link
Member

Choose a reason for hiding this comment

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

We should always clone to not modify the input data, shouldn't we?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@xabbuh, I've no strong opinion on this. I just did it because I noticedDateTimeImmutable was not cloned in other transformers needing to clone the value, refDateTimeToArrayTransformer andDateTimeToStringTransformer.

Should we change this behavior there too ?

Copy link
Member

Choose a reason for hiding this comment

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

The point is that theDataTransformerInterface just states that the given input should be transformed and then being returned. To me this does not include that the input is allowed to change.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

This makes even more sense when we consider that aDateTime object will be returned byreverseTransform() anyway, and actually it sets the output timezone on the input data...

So I guess I should change it in all three, thanks@xabbuh for pointing this.

Copy link
Member

Choose a reason for hiding this comment

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

@xabbuh technically, nothing was changing the input in the proposal. A DateTimeImmutable is immutable.

@HeahDude
Copy link
ContributorAuthor

Ok updated afterStof's comment.

If you agree with thiscondition change, this one should be finished.

Thanks for the reviews.

@fabpot
Copy link
Member

Thank you@HeahDude.

fabpot added a commit that referenced this pull requestJun 15, 2016
This PR was submitted for the 2.3 branch but it was merged into the 2.7 branch instead (closes#18548).Discussion----------[Form] minor fixes in DateTime transformers| Q             | A| ------------- | ---| Branch?       | 2.3+| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | ~| License       | MIT| Doc PR        | ~Commits-------b91008f [Form] fixed DateTime transformers
@fabpotfabpot closed thisJun 15, 2016
@HeahDudeHeahDude deleted the minor/form-cs_fixes branchJune 15, 2016 07:53
This was referencedJun 30, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

6 participants

@HeahDude@xabbuh@fabpot@stof@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp