Skip to content
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

Rule/date time diff #1463

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 5 additions & 1 deletion library/Rules/DateTimeDiff.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ final class DateTimeDiff extends Standard

private readonly Validatable $rule;

/** @param string $type "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds" */
/**
* @param string $type "years"|"months"|"days"|"hours"|"minutes"|"seconds"|"microseconds"
* @param string|null $format Example: "Y-m-d H:i:s.u"
* @param DateTimeImmutable|null $now The value that will be compared to the input
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a against adding documentation to the code like that, I think the name of the parameter should be pretty obvious for what it does, otherwise we should do that for everything. I understand that it can be useful to add some documentation here and there, but for this specific method, I would rather not have it.

*/
public function __construct(
Validatable $rule,
private readonly string $type = 'years',
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/rules/dateTimeDiff.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Wrapped by "not"
The number of years between now and 7 year ago must not be less than 8
- The number of years between now and 7 year ago must not be less than 8
[
'dateTimeDiff' => 'The number of years between now and 7 year ago must not be less than 8',
'notDateTimeDiff' => 'The number of years between now and 7 year ago must not be less than 8',
]

Wrapping "not"
Expand Down