CrashDump: do not assume that file() always returns array

phpstan level 7 prep
This commit is contained in:
Dylan K. Taylor 2020-03-15 15:46:03 +00:00
parent 47c7872c88
commit 35490ca41c

View File

@ -288,11 +288,13 @@ class CrashDump{
if($this->server->getProperty("auto-report.send-code", true) !== false and file_exists($error["fullFile"])){ if($this->server->getProperty("auto-report.send-code", true) !== false and file_exists($error["fullFile"])){
$file = @file($error["fullFile"], FILE_IGNORE_NEW_LINES); $file = @file($error["fullFile"], FILE_IGNORE_NEW_LINES);
if($file !== false){
for($l = max(0, $error["line"] - 10); $l < $error["line"] + 10 and isset($file[$l]); ++$l){ for($l = max(0, $error["line"] - 10); $l < $error["line"] + 10 and isset($file[$l]); ++$l){
$this->addLine("[" . ($l + 1) . "] " . $file[$l]); $this->addLine("[" . ($l + 1) . "] " . $file[$l]);
$this->data["code"][$l + 1] = $file[$l]; $this->data["code"][$l + 1] = $file[$l];
} }
} }
}
$this->addLine(); $this->addLine();
$this->addLine("Backtrace:"); $this->addLine("Backtrace:");