Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
dd7d1fc2
Unverified
Commit
dd7d1fc2
authored
Jul 28, 2017
by
Marco Pivetta
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fix/#2794-revert-bc-break-preventing-datetimeimmutable-conversion-2.6' into 2.6
Backport #2794 to 2.6.1 ge aborts
parents
43878673
3c604541
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
8 deletions
+37
-8
DateTimeType.php
lib/Doctrine/DBAL/Types/DateTimeType.php
+2
-2
DateTimeTzType.php
lib/Doctrine/DBAL/Types/DateTimeTzType.php
+2
-2
DateType.php
lib/Doctrine/DBAL/Types/DateType.php
+2
-2
TimeType.php
lib/Doctrine/DBAL/Types/TimeType.php
+2
-2
BaseDateTypeTestCase.php
tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php
+29
-0
No files found.
lib/Doctrine/DBAL/Types/DateTimeType.php
View file @
dd7d1fc2
...
...
@@ -53,7 +53,7 @@ class DateTimeType extends Type
return
$value
;
}
if
(
$value
instanceof
\DateTime
)
{
if
(
$value
instanceof
\DateTime
Interface
)
{
return
$value
->
format
(
$platform
->
getDateTimeFormatString
());
}
...
...
@@ -65,7 +65,7 @@ class DateTimeType extends Type
*/
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
Interface
)
{
return
$value
;
}
...
...
lib/Doctrine/DBAL/Types/DateTimeTzType.php
View file @
dd7d1fc2
...
...
@@ -71,7 +71,7 @@ class DateTimeTzType extends Type
return
$value
;
}
if
(
$value
instanceof
\DateTime
)
{
if
(
$value
instanceof
\DateTime
Interface
)
{
return
$value
->
format
(
$platform
->
getDateTimeTzFormatString
());
}
...
...
@@ -83,7 +83,7 @@ class DateTimeTzType extends Type
*/
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
Interface
)
{
return
$value
;
}
...
...
lib/Doctrine/DBAL/Types/DateType.php
View file @
dd7d1fc2
...
...
@@ -53,7 +53,7 @@ class DateType extends Type
return
$value
;
}
if
(
$value
instanceof
\DateTime
)
{
if
(
$value
instanceof
\DateTime
Interface
)
{
return
$value
->
format
(
$platform
->
getDateFormatString
());
}
...
...
@@ -65,7 +65,7 @@ class DateType extends Type
*/
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
Interface
)
{
return
$value
;
}
...
...
lib/Doctrine/DBAL/Types/TimeType.php
View file @
dd7d1fc2
...
...
@@ -53,7 +53,7 @@ class TimeType extends Type
return
$value
;
}
if
(
$value
instanceof
\DateTime
)
{
if
(
$value
instanceof
\DateTime
Interface
)
{
return
$value
->
format
(
$platform
->
getTimeFormatString
());
}
...
...
@@ -65,7 +65,7 @@ class TimeType extends Type
*/
public
function
convertToPHPValue
(
$value
,
AbstractPlatform
$platform
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
)
{
if
(
$value
===
null
||
$value
instanceof
\DateTime
Interface
)
{
return
$value
;
}
...
...
tests/Doctrine/Tests/DBAL/Types/BaseDateTypeTestCase.php
View file @
dd7d1fc2
...
...
@@ -70,6 +70,35 @@ abstract class BaseDateTypeTestCase extends PHPUnit_Framework_TestCase
$this
->
assertSame
(
$date
,
$this
->
type
->
convertToPHPValue
(
$date
,
$this
->
platform
));
}
/**
* @group #2794
*
* Note that while \@see \DateTimeImmutable is supposed to be handled
* by @see \Doctrine\DBAL\Types\DateTimeImmutableType, previous DBAL versions handled it just fine.
* This test is just in place to prevent further regressions, even if the type is being misused
*/
public
function
testConvertDateTimeImmutableToPHPValue
()
{
$date
=
new
\DateTimeImmutable
(
'now'
);
self
::
assertSame
(
$date
,
$this
->
type
->
convertToPHPValue
(
$date
,
$this
->
platform
));
}
/**
* @group #2794
*
* Note that while \@see \DateTimeImmutable is supposed to be handled
* by @see \Doctrine\DBAL\Types\DateTimeImmutableType, previous DBAL versions handled it just fine.
* This test is just in place to prevent further regressions, even if the type is being misused
*/
public
function
testDateTimeImmutableConvertsToDatabaseValue
()
{
self
::
assertInternalType
(
'string'
,
$this
->
type
->
convertToDatabaseValue
(
new
\DateTimeImmutable
(),
$this
->
platform
)
);
}
/**
* @return mixed[][]
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment