Skip to content

Commit 186fbb2

Browse files
committed
Merge branch '5.4' into 6.4
* 5.4: [PropertyInfo] Update DoctrineExtractor for new DBAL 4 BIGINT type Update security.nl.xlf [Validator] IBAN Check digits should always between 2 and 98 [Security] Populate translations for trans-unit 20 add missing plural translation messages filter out empty HTTP header parts [String] Fix folded in compat mode Remove calls to `getMockForAbstractClass()` [ErrorHandler] Do not call xdebug_get_function_stack() with xdebug >= 3.0 when not in develop mode [Serializer] Fix type for missing property add test for JSON response with null as content [Filesystem] Fix dumpFile `stat failed` error hitting custom handler Remove calls to `TestCase::iniSet()` and calls to deprecated methods of `MockBuilder` [PhpUnitBridge] Fix `DeprecationErrorHandler` with PhpUnit 10
2 parents 8a1cb2f + 8307f63 commit 186fbb2

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

Constraints/IbanValidator.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,18 @@ public function validate(mixed $value, Constraint $constraint)
228228
return;
229229
}
230230

231+
// Check digits should always between 2 and 98
232+
// A ECBS document (https://www.ecbs.org/Download/EBS204_V3.PDF) replicates part of the ISO/IEC 7064:2003 standard as a method for generating check digits in the range 02 to 98.
233+
$checkDigits = (int) substr($canonicalized, 2, 2);
234+
if ($checkDigits < 2 || $checkDigits > 98) {
235+
$this->context->buildViolation($constraint->message)
236+
->setParameter('{{ value }}', $this->formatValue($value))
237+
->setCode(Iban::CHECKSUM_FAILED_ERROR)
238+
->addViolation();
239+
240+
return;
241+
}
242+
231243
// Move the first four characters to the end
232244
// e.g. CH93 0076 2011 6238 5295 7
233245
// -> 0076 2011 6238 5295 7 CH93

Tests/Constraints/IbanValidatorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,12 @@ public static function getIbansWithValidFormatButIncorrectChecksum()
401401
['UA213223130000026007233566002'], // Ukraine
402402
['AE260211000000230064017'], // United Arab Emirates
403403
['VA59001123000012345671'], // Vatican City State
404+
405+
// Checksum digits not between 02 and 98
406+
['FO00 5432 0388 8999 44'], // Faroe Islands
407+
['NL01INGB0001393698'], // Netherlands
408+
['NL01RABO0331811235'], // Netherlands
409+
['RU99 0445 2560 0407 0281 0412 3456 7890 1'], // Russia
404410
];
405411
}
406412

Tests/Constraints/UuidValidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testEmptyStringIsValid()
4545
public function testExpectsUuidConstraintCompatibleType()
4646
{
4747
$this->expectException(UnexpectedTypeException::class);
48-
$constraint = $this->getMockForAbstractClass(Constraint::class);
48+
$constraint = $this->createStub(Constraint::class);
4949

5050
$this->validator->validate('216fff40-98d9-11e3-a5e2-0800200c9a66', $constraint);
5151
}

Tests/Mapping/Loader/FilesLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ public function testCallsActualFileLoaderForMetadata()
3636

3737
public function getFilesLoader(LoaderInterface $loader)
3838
{
39-
return $this->getMockForAbstractClass(FilesLoader::class, [[
39+
return new class([
4040
__DIR__.'/constraint-mapping.xml',
4141
__DIR__.'/constraint-mapping.yaml',
4242
__DIR__.'/constraint-mapping.test',
4343
__DIR__.'/constraint-mapping.txt',
44-
], $loader]);
44+
], $loader) extends FilesLoader {};
4545
}
4646
}

0 commit comments

Comments
 (0)