protected static function AbstractComparisonValidatorTestCase::addPhp5Dot5Comparisons in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/Tests/Constraints/AbstractComparisonValidatorTestCase.php \Symfony\Component\Validator\Tests\Constraints\AbstractComparisonValidatorTestCase::addPhp5Dot5Comparisons()
2 calls to AbstractComparisonValidatorTestCase::addPhp5Dot5Comparisons()
- AbstractComparisonValidatorTestCase::provideAllInvalidComparisons in vendor/
symfony/ validator/ Tests/ Constraints/ AbstractComparisonValidatorTestCase.php - AbstractComparisonValidatorTestCase::provideAllValidComparisons in vendor/
symfony/ validator/ Tests/ Constraints/ AbstractComparisonValidatorTestCase.php
File
- vendor/
symfony/ validator/ Tests/ Constraints/ AbstractComparisonValidatorTestCase.php, line 37
Class
- AbstractComparisonValidatorTestCase
- @author Daniel Holmes <daniel@danielholmes.org>
Namespace
Symfony\Component\Validator\Tests\ConstraintsCode
protected static function addPhp5Dot5Comparisons(array $comparisons) {
if (PHP_VERSION_ID < 50500) {
return $comparisons;
}
$result = $comparisons;
// Duplicate all tests involving DateTime objects to be tested with
// DateTimeImmutable objects as well
foreach ($comparisons as $comparison) {
$add = false;
foreach ($comparison as $i => $value) {
if ($value instanceof \DateTime) {
$comparison[$i] = new \DateTimeImmutable($value
->format('Y-m-d H:i:s.u e'), $value
->getTimezone());
$add = true;
}
elseif ('DateTime' === $value) {
$comparison[$i] = 'DateTimeImmutable';
$add = true;
}
}
if ($add) {
$result[] = $comparison;
}
}
return $result;
}