Req #53439 [Asn->Nab]: DatePeriod does not expose any properties

[email protected]
Newsgroups php.bugs
Message-ID <[email protected]>
Edit report at https://bugs.php.net/bug.php?id=53439&edit=1

 ID:                 53439
 Updated by:         [email protected]
 Reported by:        from dot php dot net at brainbox dot cz
 Summary:            DatePeriod does not expose any properties
-Status:             Assigned
+Status:             Not a bug
 Type:               Feature/Change Request
 Package:            Date/time related
 Operating System:   Windows XP SP3
 PHP Version:        5.3.3
 Assigned To:        derick
 Block user comment: N
 Private report:     N

 New Comment:

There's no need to access the internal properties when you want to extend the class. It's entirely up to the person designing the class to expose them or not. Here they are not exposed. So if you want to extend the class you will need to use the public methods to get the information you need to handle whatever your extending class should achieve.

Therefore it'S not a bug but a feature.


Previous Comments:
------------------------------------------------------------------------
[2014-02-06 13:51:17] arjen at react dot com

Fixed since 5.3.27/5.4.17, see http://3v4l.org/r0mFG#v5327
Probably by https://bugs.php.net/bug.php?id=53437

------------------------------------------------------------------------
[2012-08-30 09:30:35] [email protected]

Same thing happens with DateInterval

------------------------------------------------------------------------
[2012-05-30 19:15:28] krebs dot seb at googlemail dot com

Anything new here? As far as I understood cataphract a patch exists. What 
happened to it?

------------------------------------------------------------------------
[2011-01-09 06:00:13] [email protected]

Reassigning to Derick, as the patch I've written is under his consideration.

------------------------------------------------------------------------
[2010-12-01 17:58:19] from dot php dot net at brainbox dot cz

Description:
------------
The DatePeriod instance does not expose its internal properties, thus makes impossible to extend the class.

The properties are not visible in the reflection as well. Also, when I cast the instance to array (which usually exposes all properties), no props are shown.

The draft of the test follows.

Test script:
---------------
$dp = new DatePeriod(new DateTime('2010-01-01'), new DateInterval('P1D'), 2);
$r = new ReflectionObject($dp);
$arr = (array)$dp; // cast to array to see the values of propeties

echo "Properties:\r\n";
foreach($r->getProperties() as $v) {
	echo $v->getName()."\r\n";
}
echo "\r\n";

echo "Methods:\r\n";
foreach($r->getMethods() as $v) {
	echo $v->getName()."\r\n";
}
echo "\r\n";

echo "Array cast:\r\n";
echo strtr(print_r($arr, true), "\0", '_');

Expected result:
----------------
Properties:
any_valid_properties...
...listed_here_after_implementing

Array cast:
Array
(
   any_valid_properties...
   ...listed_here_after_implementing
)


Actual result:
--------------
Properties:

Array cast:
Array
(
)



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



--
Edit this bug report at https://bugs.php.net/bug.php?id=53439&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.