Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Form] DateTimeImmutable norm data in DateTime form types #25273

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed the codestyle issues
  • Loading branch information
vudaltsov committed Dec 2, 2017
commit db757d25f985b3fe5b3c9e363a74377b87f974b9
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function transform($dateTime): array
if (!$this->pad) {
foreach ($result as &$entry) {
// remove leading zeros
$entry = (string)(int)$entry;
$entry = (string) (int) $entry;
}
// unset reference to keep scope clear
unset($entry);
Expand Down Expand Up @@ -130,31 +130,31 @@ public function reverseTransform($value): ?\DateTimeImmutable
throw new TransformationFailedException(sprintf('The fields "%s" should not be empty', implode('", "', $emptyFields)));
}

if (isset($value['month']) && !ctype_digit((string)$value['month'])) {
if (isset($value['month']) && !ctype_digit((string) $value['month'])) {
throw new TransformationFailedException('This month is invalid');
}

if (isset($value['day']) && !ctype_digit((string)$value['day'])) {
if (isset($value['day']) && !ctype_digit((string) $value['day'])) {
throw new TransformationFailedException('This day is invalid');
}

if (isset($value['year']) && !ctype_digit((string)$value['year'])) {
if (isset($value['year']) && !ctype_digit((string) $value['year'])) {
throw new TransformationFailedException('This year is invalid');
}

if (!empty($value['month']) && !empty($value['day']) && !empty($value['year']) && false === checkdate($value['month'], $value['day'], $value['year'])) {
throw new TransformationFailedException('This is an invalid date');
}

if (isset($value['hour']) && !ctype_digit((string)$value['hour'])) {
if (isset($value['hour']) && !ctype_digit((string) $value['hour'])) {
throw new TransformationFailedException('This hour is invalid');
}

if (isset($value['minute']) && !ctype_digit((string)$value['minute'])) {
if (isset($value['minute']) && !ctype_digit((string) $value['minute'])) {
throw new TransformationFailedException('This minute is invalid');
}

if (isset($value['second']) && !ctype_digit((string)$value['second'])) {
if (isset($value['second']) && !ctype_digit((string) $value['second'])) {
throw new TransformationFailedException('This second is invalid');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Symfony\Component\Form\DataTransformerInterface;

/**
* A BC-layer trait for DateTimeTo*Transformers
* A BC-layer trait for DateTimeTo*Transformers.
*
* @author Valentin Udaltsov <udaltsov.valentin@gmail.com>
*
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.