Edit report at https://bugs.php.net/bug.php?id=65150&edit=1
ID: 65150 Updated by: a...@php.net Reported by: mike at silverorange dot com Summary: DateTime subclasses expose extra properties -Status: Open +Status: Not a bug Type: Bug Package: Date/time related Operating System: CentOS or RHEL PHP Version: 5.3.26 Block user comment: N Private report: N New Comment: Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php The properties are exposed intentionally, so that's ok. To achieve teh goal you've described the proper way were to use an appropriate design pattern, maybe Facade or Proxy. Previous Comments: ------------------------------------------------------------------------ [2013-06-27 21:04:03] mike at silverorange dot com Description: ------------ I expected the DateTime class properties to be private or at least protected so users of my subclass don't get internals exposed. See also https://bugs.php.net/bug.php?id=49382 Test script: --------------- class MyDate extends DateTime { public $extra = ''; } $d = new MyDate('2013-01-01', new DateTimeZone('UTC')); var_dump($d); Expected result: ---------------- class MyDate#1 (4) { public $extra => string(0) "" } Actual result: -------------- class MyDate#1 (4) { public $extra => string(0) "" public $date => string(19) "2013-01-01 00:00:00" public $timezone_type => int(3) public $timezone => string(3) "UTC" } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=65150&edit=1