Skip to content

Commit 874ef53

Browse files
cluster28isfedorov
authored andcommitted
Scope DatePeriod constructor exception annotation to PHP 8.3+
DateMalformedPeriodStringException was introduced in PHP 8.3, but the DatePeriod ISO string constructor stub declared it without version constraints, causing IDEs to incorrectly flag it in earlier PHP versions.
1 parent b3f1942 commit 874ef53

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

date/date_c.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,13 +1537,24 @@ public function __construct(DateTimeInterface $start, DateInterval $interval, Da
15371537
*/
15381538
public function __construct(DateTimeInterface $start, DateInterval $interval, $recurrences, $options = 0) {}
15391539

1540+
/**
1541+
* Creates a new DatePeriod object
1542+
* @param string $isostr String containing the ISO interval.
1543+
* @param int $options Can be set to DatePeriod::EXCLUDE_START_DATE.
1544+
* @throws Exception when the $isostr cannot be parsed as a valid ISO 8601 period.
1545+
* @link https://php.net/manual/en/dateperiod.construct.php
1546+
*/
1547+
#[PhpStormStubsElementAvailable(from: '5.3', to: '8.2')]
1548+
public function __construct($isostr, $options = 0) {}
1549+
15401550
/**
15411551
* Creates a new DatePeriod object
15421552
* @param string $isostr String containing the ISO interval.
15431553
* @param int $options Can be set to DatePeriod::EXCLUDE_START_DATE.
15441554
* @throws DateMalformedPeriodStringException
15451555
* @link https://php.net/manual/en/dateperiod.construct.php
15461556
*/
1557+
#[PhpStormStubsElementAvailable(from: '8.3')]
15471558
public function __construct($isostr, $options = 0) {}
15481559

15491560
/**

0 commit comments

Comments
 (0)