Skip to content
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

Add DateImmutable type #2118

Merged
merged 2 commits into from
Nov 28, 2019
Merged

Conversation

malarzm
Copy link
Member

@malarzm malarzm commented Nov 23, 2019

Q A
Type feature
BC Break no
Fixed issues #1975

Summary

As per title :)

@malarzm malarzm added this to the 2.1.0 milestone Nov 23, 2019
@@ -211,11 +212,11 @@ public function executeInserts(array $options = []) : void
if ($this->class->isVersioned) {
$versionMapping = $this->class->fieldMappings[$this->class->versionField];
$nextVersion = null;
if ($versionMapping['type'] === 'int') {
if ($versionMapping['type'] === Type::INT || $versionMapping['type'] === Type::INTEGER) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure why we haven't used consts in the first place so I've used them everywhere and kept it as a separate commit

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 deprecate and remove the boolean and integer types to be consistent with PHP, which only allows bool and int. For now this works. 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Created #2124

@malarzm malarzm force-pushed the datetime-immutable-type branch 3 times, most recently from 2141a03 to 6fd291e Compare November 23, 2019 14:37
@malarzm malarzm mentioned this pull request Nov 23, 2019
@alcaeus alcaeus self-requested a review November 24, 2019 06:47
{
$datetime = parent::getDateTime($value);

return $datetime instanceof DateTime ? DateTimeImmutable::createFromMutable($datetime) : $datetime;
Copy link
Member

Choose a reason for hiding this comment

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

This can lead to returning something that isn't a DateTimeImmutable if so given from the parent class. I would suggest checking for that.

Copy link
Member Author

Choose a reason for hiding this comment

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

DateTimeInterface has only two implementations and IIRC it's forbidden to write a new one in userland. But if you prefer so I can check what's returned and throw an exception if it's neither DateTime or DateTimeImmutable 👍

@@ -79,14 +79,14 @@ public function testMultipleFlushesDoIncrementalUpdates()
$this->dm->persist($test);
$this->dm->flush();

$this->assertIsInt($test->getVersion());
$this->assertInternalType('int', $test->getVersion());
Copy link
Member

Choose a reason for hiding this comment

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

Why the change? This method is deprecated in PHPUnit 8.

Copy link
Member Author

Choose a reason for hiding this comment

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

Somehow I had newest PHPUnit running and it complained while I was running entire LockTest class. Can revert it and keep the change for the upgrade PR 👍

Copy link
Member

Choose a reason for hiding this comment

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

Yes please, let's refactor that separately.

@malarzm malarzm force-pushed the datetime-immutable-type branch 2 times, most recently from 495abc4 to 2e74793 Compare November 26, 2019 19:36
@malarzm malarzm requested a review from alcaeus November 26, 2019 19:37
@alcaeus alcaeus merged commit 6ecd273 into doctrine:master Nov 28, 2019
@malarzm malarzm deleted the datetime-immutable-type branch April 21, 2020 17:10
@malarzm malarzm mentioned this pull request Apr 21, 2020
@franmomu franmomu mentioned this pull request Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants