MktimeUsage
warning on by default quick-fixGroup: Compatibility · PhpStorm name: MktimeUsageInspection
Two legacy mktime() / gmmktime() usages: calling them without arguments just returns the current timestamp (and emits an E_STRICT/deprecation notice on PHP 5.x/7.x) — time() is the intended call; and the seventh $is_dst argument was deprecated in PHP 5.1 and removed in PHP 7.0.
Example
php
<?php
namespace Billing;
use function gmmktime;
function epoch_values($flag)
{
$now = mktime();
$utc = gmmktime();
$root = \mktime();
$dst = mktime(12, 0, 0, 6, 1, 2010, $flag);
$dst2 = gmmktime(1, 2, 3, 4, 5, 2001, 0);
$noon = mktime(12);
$full = gmmktime(1, 2, 3, 4, 5, 2001);
}php
<?php
namespace Billing;
use function gmmktime;
function epoch_values($flag)
{
$now = time();
$utc = time();
$root = time();
$dst = mktime(12, 0, 0, 6, 1, 2010, $flag);
$dst2 = gmmktime(1, 2, 3, 4, 5, 2001, 0);
$noon = mktime(12);
$full = gmmktime(1, 2, 3, 4, 5, 2001);
}Reported:
- line 8: Call time() instead; mktime()/gmmktime() without arguments is deprecated.
- line 9: Call time() instead; mktime()/gmmktime() without arguments is deprecated.
- line 10: Call time() instead; mktime()/gmmktime() without arguments is deprecated.
- line 11: The is_dst argument is deprecated and was removed in PHP 7.0.
- line 12: The is_dst argument is deprecated and was removed in PHP 7.0.
Configure
In custos.json:
json
{
"rules": {
"MktimeUsage": {
"enabled": false
}
}
}Suppress
Before the statement or declaration (or the first statement of the file), either of:
php
// @custos-ignore MktimeUsage
/**
* @noinspection MktimeUsageInspection
*/