mirror of
https://github.com/dg/dibi.git
synced 2025-08-02 20:27:35 +02:00
DateTime: added immutable usage detector™
This commit is contained in:
@@ -43,4 +43,64 @@ class DateTime extends \DateTimeImmutable
|
|||||||
{
|
{
|
||||||
return $this->format('Y-m-d H:i:s.u');
|
return $this->format('Y-m-d H:i:s.u');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/********************* immutable usage detector ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
public function __destruct()
|
||||||
|
{
|
||||||
|
$trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
|
||||||
|
if (isset($trace[0]['file'], $trace[1]['function']) && $trace[0]['file'] === __FILE__ && $trace[1]['function'] !== '__construct') {
|
||||||
|
trigger_error(__CLASS__ . ' is immutable now, check how it is used in ' . $trace[1]['file'] . ':' . $trace[1]['line'], E_USER_WARNING);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function add($interval)
|
||||||
|
{
|
||||||
|
return parent::add($interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function modify($modify)
|
||||||
|
{
|
||||||
|
return parent::modify($modify);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function setDate($year, $month, $day)
|
||||||
|
{
|
||||||
|
return parent::setDate($year, $month, $day);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function setISODate($year, $week, $day = 1)
|
||||||
|
{
|
||||||
|
return parent::setISODate($year, $week, $day);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function setTime($hour, $minute, $second = 0, $micro = 0)
|
||||||
|
{
|
||||||
|
return parent::setTime($hour, $minute, $second, $micro);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function setTimestamp($unixtimestamp)
|
||||||
|
{
|
||||||
|
return parent::setTimestamp($unixtimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function setTimezone($timezone)
|
||||||
|
{
|
||||||
|
return parent::setTimezone($timezone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function sub($interval)
|
||||||
|
{
|
||||||
|
return parent::sub($interval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user