ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
/usr/local/src/ilias/release_5-2/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php

Returns the contents of the file for this frame as an array of lines, and optionally as a clamped range of lines.NOTE: lines are 0-indexed

Get all lines for this file
$frame->getFileLines(); // => array( 0 => '<?php', 1 => '...', ...)
<?php
namespace Whoops\Exception;
class Frame implements Serializable
{
protected $frame;
protected $fileContentsCache;
protected $comments = [];
protected $application;
public function __construct(array $frame)
{
$this->frame = $frame;
}
public function getFile($shortened = false)
{
if (empty($this->frame['file'])) {
return null;
}
$file = $this->frame['file'];
// Check if this frame occurred within an eval().
// @todo: This can be made more reliable by checking if we've entered
// eval() in a previous trace, but will need some more work on the upper
// trace collector(s).
if (preg_match('/^(.*)\((\d+)\) : (?:eval\(\)\'d|assert) code$/', $file, $matches)) {
$file = $this->frame['file'] = $matches[1];
$this->frame['line'] = (int) $matches[2];
}
if ($shortened && is_string($file)) {
// Replace the part of the path that all frames have in common, and add 'soft hyphens' for smoother line-breaks.
$dirname = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))));
if ($dirname !== '/') {
$file = str_replace($dirname, "&hellip;", $file);
}
$file = str_replace("/", "/&shy;", $file);
}
return $file;
}
public function getLine()
{
return isset($this->frame['line']) ? $this->frame['line'] : null;
}
public function getClass()
{
return isset($this->frame['class']) ? $this->frame['class'] : null;
}
public function getFunction()
{
return isset($this->frame['function']) ? $this->frame['function'] : null;
}
public function getArgs()
{
return isset($this->frame['args']) ? (array) $this->frame['args'] : [];
}
public function getFileContents()
{
if ($this->fileContentsCache === null && $filePath = $this->getFile()) {
// Leave the stage early when 'Unknown' is passed
// this would otherwise raise an exception when
// open_basedir is enabled.
if ($filePath === "Unknown") {
return null;
}
// Return null if the file doesn't actually exist.
if (!is_file($filePath)) {
return null;
}
$this->fileContentsCache = file_get_contents($filePath);
}
}
public function addComment($comment, $context = 'global')
{
$this->comments[] = [
'comment' => $comment,
'context' => $context,
];
}
public function getComments($filter = null)
{
if ($filter !== null) {
$comments = array_filter($comments, function ($c) use ($filter) {
return $c['context'] == $filter;
});
}
return $comments;
}
public function getRawFrame()
{
return $this->frame;
}
public function getFileLines($start = 0, $length = null)
{
if (null !== ($contents = $this->getFileContents())) {
$lines = explode("\n", $contents);
// Get a subset of lines from $start to $end
if ($length !== null) {
$start = (int) $start;
$length = (int) $length;
if ($start < 0) {
$start = 0;
}
if ($length <= 0) {
"\$length($length) cannot be lower or equal to 0"
);
}
$lines = array_slice($lines, $start, $length, true);
}
return $lines;
}
}
public function serialize()
{
if (!empty($this->comments)) {
$frame['_comments'] = $this->comments;
}
return serialize($frame);
}
public function unserialize($serializedFrame)
{
$frame = unserialize($serializedFrame);
if (!empty($frame['_comments'])) {
$this->comments = $frame['_comments'];
unset($frame['_comments']);
}
$this->frame = $frame;
}
public function equals(Frame $frame)
{
if (!$this->getFile() || $this->getFile() === 'Unknown' || !$this->getLine()) {
return false;
}
return $frame->getFile() === $this->getFile() && $frame->getLine() === $this->getLine();
}
public function isApplication()
{
}
public function setApplication($application)
{
$this->application = $application;
}
}