Fix binary operation +
, -
or *
on string
By type casting to integer.
This commit is contained in:
parent
a0b6d3de65
commit
d445465ef4
@ -21,7 +21,7 @@ class BirthdayType extends AbstractType
|
||||
*/
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefault('years', range(date('Y') - 120, date('Y')));
|
||||
$resolver->setDefault('years', range((int) date('Y') - 120, date('Y')));
|
||||
|
||||
$resolver->setAllowedTypes('years', 'array');
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ class DateType extends AbstractType
|
||||
};
|
||||
|
||||
$resolver->setDefaults([
|
||||
'years' => range(date('Y') - 5, date('Y') + 5),
|
||||
'years' => range((int) date('Y') - 5, (int) date('Y') + 5),
|
||||
'months' => range(1, 12),
|
||||
'days' => range(1, 31),
|
||||
'widget' => 'choice',
|
||||
|
@ -707,7 +707,7 @@ class Response
|
||||
return (int) $age;
|
||||
}
|
||||
|
||||
return max(time() - $this->getDate()->format('U'), 0);
|
||||
return max(time() - (int) $this->getDate()->format('U'), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -788,7 +788,7 @@ class Response
|
||||
}
|
||||
|
||||
if (null !== $this->getExpires()) {
|
||||
return $this->getExpires()->format('U') - $this->getDate()->format('U');
|
||||
return (int) $this->getExpires()->format('U') - (int) $this->getDate()->format('U');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ class ResponseCacheStrategy implements ResponseCacheStrategyInterface
|
||||
$this->storeRelativeAgeDirective('s-maxage', $response->headers->getCacheControlDirective('s-maxage') ?: $response->headers->getCacheControlDirective('max-age'), $age);
|
||||
|
||||
$expires = $response->getExpires();
|
||||
$expires = null !== $expires ? $expires->format('U') - $response->getDate()->format('U') : null;
|
||||
$expires = null !== $expires ? (int) $expires->format('U') - (int) $response->getDate()->format('U') : null;
|
||||
$this->storeRelativeAgeDirective('expires', $expires >= 0 ? $expires : null, 0);
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ class DayOfYearTransformer extends Transformer
|
||||
*/
|
||||
public function format(\DateTime $dateTime, $length)
|
||||
{
|
||||
$dayOfYear = $dateTime->format('z') + 1;
|
||||
$dayOfYear = (int) $dateTime->format('z') + 1;
|
||||
|
||||
return $this->padLeft($dayOfYear, $length);
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ class FullTransformer
|
||||
preg_match_all($this->regExp, $this->pattern, $matches);
|
||||
if (\in_array('yy', $matches[0])) {
|
||||
$dateTime->setTimestamp(time());
|
||||
$year = $year > $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year;
|
||||
$year = $year > (int) $dateTime->format('y') + 20 ? 1900 + $year : 2000 + $year;
|
||||
}
|
||||
|
||||
$dateTime->setDate($year, $month, $day);
|
||||
|
@ -120,7 +120,7 @@ class IssnValidator extends ConstraintValidator
|
||||
|
||||
for ($i = 0; $i < 7; ++$i) {
|
||||
// Multiply the first digit by 8, the second by 7, etc.
|
||||
$checkSum += (8 - $i) * $canonical[$i];
|
||||
$checkSum += (8 - $i) * (int) $canonical[$i];
|
||||
}
|
||||
|
||||
if (0 !== $checkSum % 11) {
|
||||
|
@ -83,7 +83,7 @@ class LuhnValidator extends ConstraintValidator
|
||||
// ^ ^ ^ ^ ^
|
||||
// = 1+8 + 4 + 6 + 1+6 + 2
|
||||
for ($i = $length - 2; $i >= 0; $i -= 2) {
|
||||
$checkSum += array_sum(str_split($value[$i] * 2));
|
||||
$checkSum += array_sum(str_split((int) $value[$i] * 2));
|
||||
}
|
||||
|
||||
if (0 === $checkSum || 0 !== $checkSum % 10) {
|
||||
|
@ -95,7 +95,7 @@ class DateCaster
|
||||
if (3 === $i) {
|
||||
$now = new \DateTimeImmutable();
|
||||
$dates[] = sprintf('%s more', ($end = $p->getEndDate())
|
||||
? ceil(($end->format('U.u') - $d->format('U.u')) / ($now->add($p->getDateInterval())->format('U.u') - $now->format('U.u')))
|
||||
? ceil(($end->format('U.u') - $d->format('U.u')) / ((int) $now->add($p->getDateInterval())->format('U.u') - (int) $now->format('U.u')))
|
||||
: $p->recurrences - $i
|
||||
);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user