DateInterval::$from_string undefined until a lookup
Open
@derickr is already working on this.
Since Jun 21, 2024.
Bug
Extension: date
Status: Needs Triage
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
Description
The following code:
<?php
$dateInterval = new DateInterval('PT1S'); // or even DateInterval::createFromDateString('1 second')
var_dump(isset($dateInterval->from_string));
(array) $dateInterval; // or print_r() or var_dump()
var_dump(isset($dateInterval->from_string));
Resulted in this output:
bool(false)
bool(true)
But I expected this output instead:
bool(true)
bool(true)
According documentation property $from_string should be always defined (in PHP >= 8.2) but it isn't. Dump of the object initializes the property "ad hoc". var_dump() shouldn't have side effects IMHO.
PHP Version
PHP 8.2.20
Operating System
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.