for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace SimpleSAML\Module\logpeek\Syslog;
use function getdate;
use function intval;
use function sprintf;
use function sscanf;
use function strtotime;
class ParseLine
{
/**
* @param int $time
* @param string $logLine
* @return bool
*/
public static function isOlderThan(int $time, string $logLine): bool
$time
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public static function isOlderThan(/** @scrutinizer ignore-unused */ int $time, string $logLine): bool
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$logLine
public static function isOlderThan(int $time, /** @scrutinizer ignore-unused */ string $logLine): bool
return true;
}
* @param int|null $year
* @return int|false
public static function getUnixTime(string $logLine, int $year = null)
// I can read month and day and time from the file.
// but I will assume year is current year retured by time().
// Unless month and day in the file is bigger than current month and day,
// I will then assume previous year.
// A better approach would be to get the year from last modification time (mtime) of the
// file this record is taken from. But that requires knowledge about the file.
if ($year === null) {
$now = getdate();
$year = intval($now['year']);
list($month, $day, $hour, $minute, $second) = sscanf($logLine, "%s %d %d:%d:%d ");
$time = sprintf("%d %s %d %d:%d:%d", $day, $month, $year, $hour, $minute, $second);
return strtotime($time);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.