9use InvalidArgumentException;
12class Frame implements Serializable
41 public function getFile($shortened =
false)
43 if (empty($this->frame[
'file'])) {
47 $file = $this->frame[
'file'];
53 if (preg_match(
'/^(.*)\((\d+)\) : (?:eval\(\)\'d|assert) code$/',
$file, $matches)) {
54 $file = $this->frame[
'file'] = $matches[1];
55 $this->frame[
'line'] = (int) $matches[2];
58 if ($shortened && is_string(
$file)) {
60 $dirname = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))));
73 return isset($this->frame[
'line']) ? $this->frame[
'line'] :
null;
81 return isset($this->frame[
'class']) ? $this->frame[
'class'] :
null;
89 return isset($this->frame[
'function']) ? $this->frame[
'function'] :
null;
97 return isset($this->frame[
'args']) ? (array) $this->frame[
'args'] : array();
107 if ($this->fileContentsCache ===
null && $filePath = $this->
getFile()) {
111 if ($filePath ===
"Unknown") {
116 if (!is_file($filePath)) {
120 $this->fileContentsCache = file_get_contents($filePath);
139 $this->comments[] = array(
141 'context' => $context,
157 if ($filter !==
null) {
159 return $c[
'context'] == $filter;
198 $lines = explode(
"\n", $contents);
201 if ($length !==
null) {
202 $start = (int) $start;
203 $length = (int) $length;
209 throw new InvalidArgumentException(
210 "\$length($length) cannot be lower or equal to 0"
214 $lines = array_slice($lines, $start, $length,
true);
231 if (!empty($this->comments)) {
249 if (!empty(
$frame[
'_comments'])) {
250 $this->comments =
$frame[
'_comments'];
251 unset(
$frame[
'_comments']);
getFileLines($start=0, $length=null)
addComment($comment, $context='global')
Adds a comment to this frame, that can be received and used by other handlers.
serialize()
Implements the Serializable interface, with special steps to also save the existing comments.
getFileContents()
Returns the full contents of the file for this frame, if it's known.
equals(Frame $frame)
Compares Frame against one another.
getComments($filter=null)
Returns all comments for this frame.
__construct(array $frame)
getFile($shortened=false)
unserialize($serializedFrame)
Unserializes the frame data, while also preserving any existing comment data.
getRawFrame()
Returns the array containing the raw frame data from which this Frame object was built.
Whoops - php errors for cool kids.