Skip to content

Commit a23e85e

Browse files
bug #61855 [DoctrineBridge][Yaml] don't cast strings exceeding the min/max int ranges (xabbuh)
This PR was merged into the 6.4 branch. Discussion ---------- [DoctrineBridge][Yaml] don't cast strings exceeding the min/max int ranges | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | | License | MIT see php/php-src#19760 and https://wiki.php.net/rfc/warnings-php-8-5#casting_out_of_range_floats_to_int Commits ------- bac84d1 don't cast strings exceeding the min/max int ranges
2 parents 4d7cc32 + bac84d1 commit a23e85e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/Symfony/Bridge/Doctrine/Form/ChoiceList/ORMQueryBuilderLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function getEntitiesByIds(string $identifier, array $values): array
6767

6868
// Filter out non-integer values (e.g. ""). If we don't, some
6969
// databases such as PostgreSQL fail.
70-
$values = array_values(array_filter($values, fn ($v) => (string) $v === (string) (int) $v || ctype_digit($v)));
70+
$values = array_values(array_filter($values, static fn ($v) => \is_string($v) && ctype_digit($v) || (string) $v === (string) (int) $v));
7171
} elseif (\in_array($type, ['ulid', 'uuid', 'guid'])) {
7272
$parameterType = class_exists(ArrayParameterType::class) ? ArrayParameterType::STRING : Connection::PARAM_STR_ARRAY;
7373

src/Symfony/Component/Yaml/Inline.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,10 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
701701
switch (true) {
702702
case ctype_digit($scalar):
703703
case '-' === $scalar[0] && ctype_digit(substr($scalar, 1)):
704+
if ($scalar < \PHP_INT_MIN || \PHP_INT_MAX < $scalar) {
705+
return $scalar;
706+
}
707+
704708
$cast = (int) $scalar;
705709

706710
return ($scalar === (string) $cast) ? $cast : $scalar;

0 commit comments

Comments
 (0)