10000 [HttpFoundation] adds getDate method to the ParameterBag class by maldoinc · Pull Request #19296 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[HttpFoundation] adds getDate method to the ParameterBag class #19296

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 6 commits into from
Closed
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
early return includes null condition. added phpdoc
  • Loading branch information
maldoinc committed Aug 11, 2016
commit b3a292e8a22f970d306e84b758d3f290631068ab
12 changes: 6 additions & 6 deletions src/Symfony/Component/HttpFoundation/ParameterBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,19 @@ public function getBoolean($key, $default = false)
/**
* Returns the parameter value converted to a DateTime object.
*
* @param string $key The parameter key
* @param string $format The expected date format
* @param \DateTimeInterface|string $default The default value to be converted to a DateTime object if the parameter key does not exist
* @param \DateTimeZone|null $timeZone A DateTimeZone object representing the desired time zone
* @param string $key The parameter key
* @param string $format The expected date format
* @param \DateTimeInterface|string|null $default The default value to be converted to a DateTime object if the parameter key does not exist
* @param \DateTimeZone|null $timeZone A DateTimeZone object representing the desired time zone
*
* @return \DateTimeInterface|null
*/
public function getDate($key, $format, $default = null, \DateTimeZone $timeZone = null)
{
$time = $this->get($key, $default);

if ($time instanceof \DateTimeInterface) {
return $default;
if ((null === $time) || $time instanceof \DateTimeInterface) {
Copy link
Member

Choose a reason for hiding this comment

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

(null === $time) parentheses unnecessary ?

return $time;
}

// if the user has specified a timezone then pass that
Expand Down
0