DateUsage
info on by default quick-fixGroup: Unused · PhpStorm name: DateUsageInspection
date() already formats the current moment when its timestamp argument is omitted, so passing time() explicitly is redundant noise (and costs an extra call). Drop the second argument.
Example
php
<?php
function stamp($pattern, Clock $clock)
{
echo date('D, d M', time());
echo \date($pattern, \time());
echo date('H:i', time(42));
echo date('H:i', $clock->time());
echo date('H:i', Clock::time());
echo gmdate('H:i', time());
echo date('H:i');
}php
<?php
function stamp($pattern, Clock $clock)
{
echo date('D, d M');
echo \date($pattern);
echo date('H:i', time(42));
echo date('H:i', $clock->time());
echo date('H:i', Clock::time());
echo gmdate('H:i', time());
echo date('H:i');
}Reported:
- line 4: Redundant time() argument: date() uses the current time by default.
- line 5: Redundant time() argument: date() uses the current time by default.
Configure
In custos.json:
json
{
"rules": {
"DateUsage": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore DateUsage
/**
* @noinspection DateUsageInspection
*/