On Sun Dec 5 12:44 PM, Benjamin Eberlei wrote: > > 1. Just create a DateTimeValue object that is immutable, not > optimizing PHP to handle it with efficient garbage collection. > 2. One step further, add a "static class DateTimeValue" like syntax > that creates an immutable class. > > Any ideas?
Some ideas here: http://www.javalobby.org/articles/immutable/index.jsp A pattern I've been using is ~ interface Immutable {} class DateTime_Immutable extends DateTime implements Immutable { // throw exceptions if attempt to modify... } // Get immutable objects... Objects::getImmutable('Datetime', '2009-01-09'); // returns (Immutable) new DateTime_Immutable('2009-01-09') Objects::getImmutable('Datetime', $param1, $param2, ...); // returns (Immutable) new DateTime_Immutable($param1, $param2, ...) -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php