Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion dictionaries/CallMap_83.php
Original file line number Diff line number Diff line change
Expand Up @@ -13170,7 +13170,7 @@
),
'dateinterval::createfromdatestring' =>
array (
0 => 'DateInterval|false',
0 => 'DateInterval',
'datetime' => 'string',
),
'dateinterval::format' =>
Expand Down
13 changes: 13 additions & 0 deletions dictionaries/override/CallMap_83_delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@
'timezone' => 'DateTimeZone|IntlTimeZone|null|string',
),
),
'dateinterval::createfromdatestring' =>
array (
'old' =>
array (
0 => 'DateInterval|false',
'datetime' => 'string',
),
'new' =>
array (
0 => 'DateInterval',
'datetime' => 'string',
),
),
'gc_status' =>
array (
'old' =>
Expand Down
13 changes: 0 additions & 13 deletions dictionaries/override/CallMap_84_delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,19 +44,6 @@
'strength' => 'int',
),
),
'dateinterval::createfromdatestring' =>
array (
'old' =>
array (
0 => 'DateInterval|false',
'datetime' => 'string',
),
'new' =>
array (
0 => 'DateInterval',
'datetime' => 'string',
),
),
'domdocument::registernodeclass' =>
array (
'old' =>
Expand Down
4 changes: 4 additions & 0 deletions src/Psalm/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2360,6 +2360,10 @@ public function visitStubFiles(Codebase $codebase, ?Progress $progress = null):
$this->php_extensions['random'] = true; // random is a part of the PHP core starting from PHP 8.2
}

if ($codebase->analysis_php_version_id >= 8_03_00) {
$this->internal_stubs[] = $stubsDir . 'Php83.phpstub';
}

if ($codebase->analysis_php_version_id >= 8_04_00) {
$this->internal_stubs[] = $stubsDir . 'Php84.phpstub';
}
Expand Down
11 changes: 11 additions & 0 deletions stubs/Php83.phpstub
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php
namespace {
class DateInterval
{
/**
* @return DateInterval
* @throws DateMalformedIntervalStringException
*/
public static function createFromDateString(string $datetime = ''): DateInterval {}
}
}
21 changes: 21 additions & 0 deletions tests/CoreStubsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,27 @@ public function providerValidCodeParse(): iterable
'ignored_issues' => ['RedundantCondition'],
'php_version' => '8.0',
];
yield 'DateInterval::createFromDateString returns DateInterval|false on PHP 8.2' => [
'code' => '<?php

$i = DateInterval::createFromDateString("42 days");',
'assertions' => [
'$i' => 'DateInterval|false',
],
'ignored_issues' => [],
'php_version' => '8.2',
];
yield 'DateInterval::createFromDateString returns DateInterval on PHP 8.3' => [
'code' => '<?php

$i = DateInterval::createFromDateString("42 days");
echo $i->format("%d");',
'assertions' => [
'$i' => 'DateInterval',
],
'ignored_issues' => [],
'php_version' => '8.3',
];
yield 'sprintf yields a non-empty-string for non-empty-string value' => [
'code' => '<?php

Expand Down