Skip to content
Permalink
Browse files

Fix #2590 - allow null argument for DateTime when no second arg passed

  • Loading branch information
muglug committed Jan 10, 2020
1 parent 03030d4 commit df8e3845e580aba4fc03b289c697fe83a0baa38f
Showing with 14 additions and 2 deletions.
  1. +4 −2 src/Psalm/Internal/CallMap.php
  2. +10 −0 tests/MethodCallTest.php
@@ -1763,7 +1763,8 @@
'DatePeriod::getDateInterval' => ['DateInterval'],
'DatePeriod::getEndDate' => ['?DateTimeInterface'],
'DatePeriod::getStartDate' => ['DateTimeInterface'],
'DateTime::__construct' => ['void', 'time='=>'string', 'timezone='=>'?DateTimeZone'],
'DateTime::__construct' => ['void', 'time='=>'string'],
'DateTime::__construct\'1' => ['void', 'time'=>'?string', 'timezone'=>'?DateTimeZone'],
'DateTime::__set_state' => ['static', 'array'=>'array'],
'DateTime::__wakeup' => ['void'],
'DateTime::add' => ['static', 'interval'=>'DateInterval'],
@@ -1782,7 +1783,8 @@
'DateTime::setTimestamp' => ['static', 'unixtimestamp'=>'int'],
'DateTime::setTimezone' => ['static', 'timezone'=>'DateTimeZone'],
'DateTime::sub' => ['static', 'interval'=>'DateInterval'],
'DateTimeImmutable::__construct' => ['void', 'time='=>'string', 'timezone='=>'?DateTimeZone'],
'DateTimeImmutable::__construct' => ['void', 'time='=>'string'],
'DateTimeImmutable::__construct\'1' => ['void', 'time'=>'?string', 'timezone'=>'?DateTimeZone'],
'DateTimeImmutable::__set_state' => ['static', 'array'=>'array'],
'DateTimeImmutable::__wakeup' => ['void'],
'DateTimeImmutable::add' => ['static', 'interval'=>'DateInterval'],
@@ -506,6 +506,11 @@ function fetch_named() : object {
return $sth->fetch(PDO::FETCH_OBJ);
}'
],
'dateTimeSecondArg' => [
'<?php
$date = new DateTime(null, new DateTimeZone("Pacific/Nauru"));
echo $date->format("Y-m-d H:i:sP") . "\n";'
],
];
}

@@ -821,6 +826,11 @@ public function foo(): void {}
$p->foo()->bar();',
'error_message' => 'NullReference'
],
'dateTimeNullFirstArg' => [
'<?php
$date = new DateTime(null);',
'error_message' => 'NullArgument'
],
];
}
}

0 comments on commit df8e384

Please sign in to comment.
You can’t perform that action at this time.