Skip to content

Commit 5a9886c

Browse files
[11.x] Fix handling exceptions thrown in eval()'d code (#53204)
* [11.x] Fix handling exceptions thrown in eval()'d code * Update Frame.php --------- Co-authored-by: Taylor Otwell <[email protected]>
1 parent 3ee3ad9 commit 5a9886c

File tree

1 file changed

+8
-0
lines changed
  • src/Illuminate/Foundation/Exceptions/Renderer

1 file changed

+8
-0
lines changed

src/Illuminate/Foundation/Exceptions/Renderer/Frame.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ public function file()
106106
*/
107107
public function line()
108108
{
109+
if (! is_file($this->frame['file']) || ! is_readable($this->frame['file'])) {
110+
return 0;
111+
}
112+
109113
$maxLines = count(file($this->frame['file']) ?: []);
110114

111115
return $this->frame['line'] > $maxLines ? 1 : $this->frame['line'];
@@ -131,6 +135,10 @@ public function callable()
131135
*/
132136
public function snippet()
133137
{
138+
if (! is_file($this->frame['file']) || ! is_readable($this->frame['file'])) {
139+
return '';
140+
}
141+
134142
$contents = file($this->frame['file']) ?: [];
135143

136144
$start = max($this->line() - 6, 0);

0 commit comments

Comments
 (0)