Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.5.0a4

Request #17851 Class name is hard coded in methods
Submitted: 2010-09-08 15:06 UTC
From: dumb Assigned:
Status: Wont fix Package: Date (version 1.5.0a1)
PHP Version: 5.1.6 OS: Linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 31 + 42 = ?

 
 [2010-09-08 15:06 UTC] dumb (Dumb Terminal)
Description: ------------ The class name of "Date" is hard coded in various methods, which makes extending this class difficault. An example of this in the source is here: function getNextDay() { $ret = new Date($this); $ret->addDays(1); return $ret; } Maybe this should be changed to: public function getNextDay() { $class = get_class($this); $ret = new $class($this); $ret->addDays(1); return $ret; } Keep up the good work on this handy class. Thanks Test script: --------------- <?php require_once "Date.php"; class myDate extends Date{ } $date1 = new myDate(); $date2 = $date1->getNextDay(); echo "date1: " . get_class($date1) . "\n"; echo "date2: " . get_class($date2) . "\n"; ?> Expected result: ---------------- date1: myDate date2: myDate Actual result: -------------- date1: myDate date2: Date

Comments

 [2010-09-09 03:12 UTC] doconnor (Daniel O'Connor)
-Type: Bug +Type: Feature/Change Request
Unfortunately this is one of those things which would be tricky to fix... it pretty much breaks the API to do it properly. I would encourage you to make use of PHP's DateTime as an alternative where possible.
 [2010-09-09 03:19 UTC] alan_k (Alan Knowles)
This is probably a workable solution, without any API knock on effect $ret = clone($this);
 [2013-10-08 10:08 UTC] cweiske (Christian Weiske)
-Status: Open +Status: Wont fix
This package is unmaintained and will only get bugfixes, but no new features.