-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
Add DateImmutable type #2118
Conversation
@@ -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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #2124
2141a03
to
6fd291e
Compare
6fd291e
to
98dcc66
Compare
{ | ||
$datetime = parent::getDateTime($value); | ||
|
||
return $datetime instanceof DateTime ? DateTimeImmutable::createFromMutable($datetime) : $datetime; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 👍
There was a problem hiding this comment.
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.
495abc4
to
2e74793
Compare
2e74793
to
a1590d0
Compare
Summary
As per title :)