1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-27 04:45:20 +01:00

Update DateTime and DateTimeImmutable signatures

`DateTime::format` and `DateTimeImmutable::format` will always
return a string starting in PHP 8.0.
This commit is contained in:
Justin 2021-07-03 01:19:37 -04:00
parent 4cb1e2b77d
commit f7a2aaef6e
No known key found for this signature in database
GPG Key ID: F9FFE26D69BBE879
4 changed files with 15 additions and 5 deletions

View File

@ -1776,7 +1776,7 @@ return [
'DateTime::createFromImmutable' => ['static', 'datetTimeImmutable'=>'DateTimeImmutable'],
'DateTime::createFromInterface' => ['self', 'object' => 'DateTimeInterface'],
'DateTime::diff' => ['DateInterval|false', 'datetime2'=>'DateTimeInterface', 'absolute='=>'bool'],
'DateTime::format' => ['string|false', 'format'=>'string'],
'DateTime::format' => ['string', 'format'=>'string'],
'DateTime::getLastErrors' => ['array{warning_count:int,warnings:array<int,string>,error_count:int,errors:array<int,string>}'],
'DateTime::getOffset' => ['int'],
'DateTime::getTimestamp' => ['int|false'],
@ -1797,7 +1797,7 @@ return [
'DateTimeImmutable::createFromInterface' => ['self', 'object' => 'DateTimeInterface'],
'DateTimeImmutable::createFromMutable' => ['static', 'datetime'=>'DateTime'],
'DateTimeImmutable::diff' => ['DateInterval', 'datetime2'=>'DateTimeInterface', 'absolute='=>'bool'],
'DateTimeImmutable::format' => ['string|false', 'format'=>'string'],
'DateTimeImmutable::format' => ['string', 'format'=>'string'],
'DateTimeImmutable::getLastErrors' => ['array{warning_count:int,warnings:array<int,string>,error_count:int,errors:array<int,string>}'],
'DateTimeImmutable::getOffset' => ['int'],
'DateTimeImmutable::getTimestamp' => ['int|false'],

View File

@ -51,6 +51,8 @@ return [
'curl_share_setopt' => ['bool', 'sh'=>'CurlShareHandle', 'option'=>'int', 'value'=>'mixed'],
'curl_unescape' => ['string|false', 'ch'=>'CurlShareHandle', 'string'=>'string'],
'DateTime::createFromInterface' => ['self', 'object' => 'DateTimeInterface'],
'DateTime::format' => ['string', 'format'=>'string'],
'DateTimeImmutable::format' => ['string', 'format'=>'string'],
'DateTimeImmutable::createFromInterface' => ['self', 'object' => 'DateTimeInterface'],
'DateTimeZone::listIdentifiers' => ['list<string>', 'timezoneGroup='=>'int', 'countryCode='=>'string|null'],
'date_add' => ['DateTime', 'object'=>'DateTime', 'interval'=>'DateInterval'],
@ -352,6 +354,8 @@ return [
'date_time_set' => ['DateTime|false', 'object'=>'DateTime', 'hour'=>'int', 'minute'=>'int', 'second='=>'int', 'microseconds='=>'int'],
'date_timestamp_set' => ['DateTime|false', 'object'=>'DateTime', 'unixtimestamp'=>'int'],
'date_timezone_set' => ['DateTime|false', 'object'=>'DateTime', 'timezone'=>'DateTimeZone'],
'DateTime::format' => ['string|false', 'format'=>'string'],
'DateTimeImmutable::format' => ['string|false', 'format'=>'string'],
'DateTimeZone::listIdentifiers' => ['list<string>|false', 'timezoneGroup='=>'int', 'countryCode='=>'string|null'],
'each' => ['array{0:int|string,key:int|string,1:mixed,value:mixed}', '&r_arr'=>'array'],
'explode' => ['list<string>', 'separator'=>'string', 'str'=>'string', 'limit='=>'int'],

View File

@ -1445,7 +1445,7 @@ class ArrayFunctionCallTest extends TestCase
function Foo(DateTime ...$dateTimes) : array {
return array_map(
function ($dateTime) {
return (string) ($dateTime->format("c"));
return ($dateTime->format("c"));
},
$dateTimes
);
@ -1456,13 +1456,13 @@ class ArrayFunctionCallTest extends TestCase
/** @return array<string> */
function Foo(DateTime ...$dateTimes) : array {
return array_map(
fn ($dateTime) => (string) ($dateTime->format("c")),
fn ($dateTime) => ($dateTime->format("c")),
$dateTimes
);
}',
'assertions' => [],
'error_levels' => [],
'7.4',
'php_version' => '7.4',
],
'arrayPad' => [
'<?php

View File

@ -275,6 +275,9 @@ class MethodCallTest extends TestCase
'$yesterday' => 'MyDate|false',
'$b' => 'DateTimeImmutable',
],
'error_levels' => [],
'php_version' => '8.0'
],
'magicCall' => [
'<?php
@ -370,6 +373,9 @@ class MethodCallTest extends TestCase
if (false !== $formatted) {}
function takesString(string $s) : void {}
takesString($formatted);',
'assertions' => [],
'error_levels' => [],
'php_version' => '8.0'
],
'domElement' => [
'<?php