Skip to content

Commit 4ccbf78

Browse files
Merge branch '3.4' into 4.2
* 3.4: Fix expired lock not cleaned [HttpFoundation] Fix SA/phpdoc JsonResponse SimpleCacheAdapter fails to cache any item if a namespace is used validate composite constraints in all groups [Serializer] Handle true and false appropriately in CSV encoder Fix binary operation `+`, `-` or `*` on string [VarDumper] fix dumping objects that implement __debugInfo() [Routing] fix absolute url generation when scheme is not known
2 parents 2f76bf2 + 7b92618 commit 4ccbf78

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

Caster/Caster.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,8 @@ class Caster
4848
*/
4949
public static function castObject($obj, $class, $hasDebugInfo = false)
5050
{
51-
if ($hasDebugInfo) {
52-
$a = $obj->__debugInfo();
53-
} elseif ($obj instanceof \Closure) {
54-
$a = [];
55-
} else {
56-
$a = (array) $obj;
57-
}
51+
$a = $obj instanceof \Closure ? [] : (array) $obj;
52+
5853
if ($obj instanceof \__PHP_Incomplete_Class) {
5954
return $a;
6055
}
@@ -88,6 +83,17 @@ public static function castObject($obj, $class, $hasDebugInfo = false)
8883
}
8984
}
9085

86+
if ($hasDebugInfo && \is_array($debugInfo = $obj->__debugInfo())) {
87+
foreach ($debugInfo as $k => $v) {
88+
if (!isset($k[0]) || "\0" !== $k[0]) {
89+
$k = self::PREFIX_VIRTUAL.$k;
90+
}
91+
92+
unset($a[$k]);
93+
$a[$k] = $v;
94+
}
95+
}
96+
9197
return $a;
9298
}
9399

Caster/DateCaster.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static function castPeriod(\DatePeriod $p, array $a, Stub $stub, $isNeste
8888
if (self::PERIOD_LIMIT === $i) {
8989
$now = new \DateTimeImmutable();
9090
$dates[] = sprintf('%s more', ($end = $p->getEndDate())
91-
? ceil(($end->format('U.u') - $d->format('U.u')) / ($now->add($p->getDateInterval())->format('U.u') - $now->format('U.u')))
91+
? ceil(($end->format('U.u') - $d->format('U.u')) / ((int) $now->add($p->getDateInterval())->format('U.u') - (int) $now->format('U.u')))
9292
: $p->recurrences - $i
9393
);
9494
break;

0 commit comments

Comments
 (0)