Skip to content

Commit 7bb0444

Browse files
steeffabpot
authored andcommitted
Fix binary operation +, - or * on string
By type casting to integer.
1 parent 9fe7d05 commit 7bb0444

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Constraints/IssnValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function validate($value, Constraint $constraint)
120120

121121
for ($i = 0; $i < 7; ++$i) {
122122
// Multiply the first digit by 8, the second by 7, etc.
123-
$checkSum += (8 - $i) * $canonical[$i];
123+
$checkSum += (8 - $i) * (int) $canonical[$i];
124124
}
125125

126126
if (0 !== $checkSum % 11) {

Constraints/LuhnValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function validate($value, Constraint $constraint)
8383
// ^ ^ ^ ^ ^
8484
// = 1+8 + 4 + 6 + 1+6 + 2
8585
for ($i = $length - 2; $i >= 0; $i -= 2) {
86-
$checkSum += array_sum(str_split($value[$i] * 2));
86+
$checkSum += array_sum(str_split((int) $value[$i] * 2));
8787
}
8888

8989
if (0 === $checkSum || 0 !== $checkSum % 10) {

0 commit comments

Comments
 (0)