|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79804 Reflection doesn't know about DateInterval and DatePeriod properties
Submitted: 2020-07-07 15:12 UTC Modified: 2020-07-08 13:19 UTC
Avg. Score:3.0 ± 0.0
Reproduced:0 of 1 (0.0%)
From: ondrej at mirtes dot cz Assigned:
Status: Open Package: Reflection related
PHP Version: 8.0.0alpha1 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2020-07-07 15:12 UTC] ondrej at mirtes dot cz
There isn't any PHP version that would know about properties coming from classes like DateInterval and DatePeriod. I think that PHP 8 is a great opportunity to fix this.

There are also other classes with the same problem, mainly coming from ext-dom. Here's a list of how I compensated for that in PHPStan:

Test script:

$ref = new \ReflectionClass(\DateInterval::class);
foreach ($ref->getProperties() as $property) {

$ref = new \ReflectionClass(\DatePeriod::class);
foreach ($ref->getProperties() as $property) {

Expected result:
Dumped list of properties from:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-07-07 15:13 UTC] ondrej at mirtes dot cz
The actual result is empty:
 [2020-07-07 15:29 UTC]
I'm not willing to address this unless either a) those become normal properties or b) we get first-class accessor support, and those properties become accessors.

For now, the right way to think about them is like properties implemented through __get(), which is effectively what these are, just on the internal layer.
 [2020-07-07 15:31 UTC]
We may be able to address some cases though, for example I don't see any reason why LibXMLError doesn't have declared properties -- it doesn't seem to be doing anything magic.
 [2020-07-07 15:36 UTC] ondrej at mirtes dot cz
These properties are not even mentioned in any way in these new stubs ( which makes it really difficult to support them in static analysis...
 [2020-07-08 08:49 UTC]
Typed property declarations for LibXMLError added in
 [2020-07-08 13:19 UTC] ondrej at mirtes dot cz
Can something be done about LibXMLError missing from the stubs?
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed May 22 01:01:31 2024 UTC