Bug #79804 [Opn]: Reflection doesn't know about DateInterval and DatePeriod properties

From: Date: Tue, 07 Jul 2020 15:29:34 +0000
Subject: Bug #79804 [Opn]: Reflection doesn't know about DateInterval and DatePeriod properties
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227871@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79804&edit=1

 ID:                 79804
 Updated by:         nikic@php.net
 Reported by:        ondrej at mirtes dot cz
 Summary:            Reflection doesn't know about DateInterval and
                     DatePeriod properties
 Status:             Open
 Type:               Bug
 Package:            Reflection related
 PHP Version:        8.0.0alpha1
 Block user comment: N
 Private report:     N

 New Comment:

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.


Previous Comments:
------------------------------------------------------------------------
[2020-07-07 15:13:21] ondrej at mirtes dot cz

The actual result is empty: https://3v4l.org/68832

------------------------------------------------------------------------
[2020-07-07 15:12:41] ondrej at mirtes dot cz

Description:
------------
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: https://github.com/phpstan/phpstan-src/blob/069ffbbece0323a1a22557f41237d4b9efd6c521/src/Reflection/PhpDefect/PhpDefectClassReflectionExtension.php

Test script:
---------------
<?php

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

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

Expected result:
----------------
Dumped list of properties from:

https://www.php.net/manual/en/class.dateinterval.php
https://www.php.net/manual/en/class.dateperiod.php



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=79804&edit=1


Thread (7 messages)

« previous php.bugs (#227871) next »