8000 minor #24034 [VarDumper] Prepare period caster for 4.0 (maidmaid) · symfony/symfony@d3630c1 · GitHub
[go: up one dir, main page]

Skip to content

Commit d3630c1

Browse files
minor #24034 [VarDumper] Prepare period caster for 4.0 (maidmaid)
This PR was merged into the 4.0-dev branch. Discussion ---------- [VarDumper] Prepare period caster for 4.0 | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23668 | License | MIT | Doc PR | / Commits ------- fd7352e Prepare period caster for 4.0
2 parents f41bdf1 + fd7352e commit d3630c1

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

src/Symfony/Component/VarDumper/Caster/DateCaster.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
class DateCaster
2222
{
23+
private const PERIOD_LIMIT = 3;
24+
2325
public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, $isNested, $filter)
2426
{
2527
$prefix = Caster::PREFIX_VIRTUAL;
@@ -80,14 +82,10 @@ public static function castTimeZone(\DateTimeZone $timeZone, array $a, Stub $stu
8082

8183
public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, $isNested, $filter)
8284
{
83-
if (defined('HHVM_VERSION_ID') || \PHP_VERSION_ID < 50620 || (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70005)) { // see https://bugs.php.net/bug.php?id=71635
84-
return $a;
85-
}
86-
8785
$dates = array();
8886
if (\PHP_VERSION_ID >= 70107) { // see https://bugs.php.net/bug.php?id=74639
8987
foreach (clone $p as $i => $d) {
90-
if (3 === $i) {
88+
if (self::PERIOD_LIMIT === $i) {
9189
$now = new \DateTimeImmutable();
9290
$dates[] = sprintf('%s more', ($end = $p->getEndDate())
9391
? ceil(($end->format('U.u') - $d->format('U.u')) / ($now->add($p->getDateInterval())->format('U.u') - $now->format('U.u')))

src/Symfony/Component/VarDumper/Tests/Caster/DateCasterTest.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,6 @@ public function provideTimeZones()
291291
*/
292292
public function testDumpPeriod($start, $interval, $end, $options, $expected)
293293
{
294-
if (defined('HHVM_VERSION_ID') || \PHP_VERSION_ID < 50620 || (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70005)) {
295-
$this->markTestSkipped();
296-
}
297-
298294
$p = new \DatePeriod(new \DateTime($start), new \DateInterval($interval), is_int($end) ? $end : new \DateTime($end), $options);
299295

300296
$xDump = <<<EODUMP
@@ -311,10 +307,6 @@ public function testDumpPeriod($start, $interval, $end, $options, $expected)
311307
*/
312308
public function testCastPeriod($start, $interval, $end, $options, $xPeriod, $xDates)
313309
{
314-
if (defined('HHVM_VERSION_ID') || \PHP_VERSION_ID < 50620 || (\PHP_VERSION_ID >= 70000 && \PHP_VERSION_ID < 70005)) {
315-
$this->markTestSkipped();
316-
}
317-
318310
$p = new \DatePeriod(new \DateTime($start), new \DateInterval($interval), is_int($end) ? $end : new \DateTime($end), $options);
319311
$stub = new Stub();
320312

@@ -346,9 +338,6 @@ public function testCastPeriod($start, $interval, $end, $options, $xPeriod, $xDa
346338

347339
public function providePeriods()
348340
{
349-
$i = new \DateInterval('PT0S');
350-
$ms = \PHP_VERSION_ID >= 70100 && isset($i->f) ? '.0' : '';
351-
352341
$periods = array(
353342
array('2017-01-01', 'P1D', '2017-01-03', 0, 'every + 1d, from 2017-01-01 00:00:00 (included) to 2017-01-03 00:00:00', '1) 2017-01-01%a2) 2017-01-02'),
354343
array('2017-01-01', 'P1D', 1, 0, 'every + 1d, from 2017-01-01 00:00:00 (included) recurring 2 time/s', '1) 2017-01-01%a2) 2017-01-02'),
@@ -365,8 +354,8 @@ public function providePeriods()
365354
array('2017-01-01 01:00:00', 'P1D', '2017-01-03 01:00:00', 0, 'every + 1d, from 2017-01-01 01:00:00 (included) to 2017-01-03 01:00:00', '1) 2017-01-01 01:00:00%a2) 2017-01-02 01:00:00'),
366355
array('2017-01-01 01:00:00', 'P1D', 1, 0, 'every + 1d, from 2017-01-01 01:00:00 (included) recurring 2 time/s', '1) 2017-01-01 01:00:00%a2) 2017-01-02 01:00:00'),
367356

368-
array('2017-01-01', 'P1DT1H', '2017-01-03', 0, "every + 1d 01:00:00$ms, from 2017-01-01 00:00:00 (included) to 2017-01-03 00:00:00", '1) 2017-01-01 00:00:00%a2) 2017-01-02 01:00:00'),
369-
array('2017-01-01', 'P1DT1H', 1, 0, "every + 1d 01:00:00$ms, from 2017-01-01 00:00:00 (included) recurring 2 time/s", '1) 2017-01-01 00:00:00%a2) 2017-01-02 01:00:00'),
357+
array('2017-01-01', 'P1DT1H', '2017-01-03', 0, 'every + 1d 01:00:00.0, from 2017-01-01 00:00:00 (included) to 2017-01-03 00:00:00', '1) 2017-01-01 00:00:00%a2) 2017-01-02 01:00:00'),
358+
array('2017-01-01', 'P1DT1H', 1, 0, 'every + 1d 01:00:00.0, from 2017-01-01 00:00:00 (included) recurring 2 time/s', '1) 2017-01-01 00:00:00%a2) 2017-01-02 01:00:00'),
370359

371360
array('2017-01-01', 'P1D', '2017-01-04', \DatePeriod::EXCLUDE_START_DATE, 'every + 1d, from 2017-01-01 00:00:00 (excluded) to 2017-01-04 00:00:00', '1) 2017-01-02%a2) 2017-01-03'),
372361
array('2017-01-01', 'P1D', 2, \DatePeriod::EXCLUDE_START_DATE, 'every + 1d, from 2017-01-01 00:00:00 (excluded) recurring 2 time/s', '1) 2017-01-02%a2) 2017-01-03'),

0 commit comments

Comments
 (0)
0