ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Whoops\Exception\Frame Class Reference
+ Inheritance diagram for Whoops\Exception\Frame:
+ Collaboration diagram for Whoops\Exception\Frame:

Public Member Functions

 __construct (array $frame)
 
 getFile ($shortened=false)
 
 getLine ()
 
 getClass ()
 
 getFunction ()
 
 getArgs ()
 
 getFileContents ()
 Returns the full contents of the file for this frame, if it's known. More...
 
 addComment ($comment, $context='global')
 Adds a comment to this frame, that can be received and used by other handlers. More...
 
 getComments ($filter=null)
 Returns all comments for this frame. More...
 
 getRawFrame ()
 Returns the array containing the raw frame data from which this Frame object was built. More...
 
 getFileLines ($start=0, $length=null)
 
 serialize ()
 Implements the Serializable interface, with special steps to also save the existing comments. More...
 
 unserialize ($serializedFrame)
 Unserializes the frame data, while also preserving any existing comment data. More...
 
 equals (Frame $frame)
 Compares Frame against one another. More...
 

Protected Attributes

 $frame
 
 $fileContentsCache
 
 $comments = array()
 

Detailed Description

Definition at line 12 of file Frame.php.

Constructor & Destructor Documentation

◆ __construct()

Whoops\Exception\Frame::__construct ( array  $frame)
Parameters
array[]
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 32 of file Frame.php.

References Whoops\Exception\Frame\$frame.

33  {
34  $this->frame = $frame;
35  }

Member Function Documentation

◆ addComment()

Whoops\Exception\Frame::addComment (   $comment,
  $context = 'global' 
)

Adds a comment to this frame, that can be received and used by other handlers.

For example, the PrettyPage handler can attach these comments under the code for each frame.

An interesting use for this would be, for example, code analysis & annotations.

Parameters
string$comment
string$contextOptional string identifying the origin of the comment
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 137 of file Frame.php.

References $comment.

138  {
139  $this->comments[] = array(
140  'comment' => $comment,
141  'context' => $context,
142  );
143  }
$comment
Definition: buildRTE.php:83

◆ equals()

Whoops\Exception\Frame::equals ( Frame  $frame)

Compares Frame against one another.

Parameters
Frame$frame
Returns
bool
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 262 of file Frame.php.

References Whoops\Exception\Frame\getFile(), and Whoops\Exception\Frame\getLine().

263  {
264  if (!$this->getFile() || $this->getFile() === 'Unknown' || !$this->getLine()) {
265  return false;
266  }
267  return $frame->getFile() === $this->getFile() && $frame->getLine() === $this->getLine();
268  }
getFile($shortened=false)
Definition: Frame.php:41
+ Here is the call graph for this function:

◆ getArgs()

Whoops\Exception\Frame::getArgs ( )
Returns
array
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 95 of file Frame.php.

Referenced by Whoops\Handler\PlainTextHandler\getFrameArgsOutput().

96  {
97  return isset($this->frame['args']) ? (array) $this->frame['args'] : array();
98  }
+ Here is the caller graph for this function:

◆ getClass()

Whoops\Exception\Frame::getClass ( )
Returns
string|null
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 79 of file Frame.php.

80  {
81  return isset($this->frame['class']) ? $this->frame['class'] : null;
82  }

◆ getComments()

Whoops\Exception\Frame::getComments (   $filter = null)

Returns all comments for this frame.

Optionally allows a filter to only retrieve comments from a specific context.

Parameters
string$filter
Returns
array[]
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 153 of file Frame.php.

References Whoops\Exception\Frame\$comments.

154  {
156 
157  if ($filter !== null) {
158  $comments = array_filter($comments, function ($c) use ($filter) {
159  return $c['context'] == $filter;
160  });
161  }
162 
163  return $comments;
164  }

◆ getFile()

Whoops\Exception\Frame::getFile (   $shortened = false)
Parameters
bool$shortened
Returns
string|null
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 41 of file Frame.php.

References $file.

Referenced by Whoops\Exception\Frame\equals(), and Whoops\Exception\Frame\getFileContents().

42  {
43  if (empty($this->frame['file'])) {
44  return null;
45  }
46 
47  $file = $this->frame['file'];
48 
49  // Check if this frame occurred within an eval().
50  // @todo: This can be made more reliable by checking if we've entered
51  // eval() in a previous trace, but will need some more work on the upper
52  // trace collector(s).
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];
56  }
57 
58  if ($shortened && is_string($file)) {
59  // Replace the part of the path that all frames have in common, and add 'soft hyphens' for smoother line-breaks.
60  $dirname = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))));
61  $file = str_replace($dirname, "…", $file);
62  $file = str_replace("/", "/­", $file);
63  }
64 
65  return $file;
66  }
print $file
+ Here is the caller graph for this function:

◆ getFileContents()

Whoops\Exception\Frame::getFileContents ( )

Returns the full contents of the file for this frame, if it's known.

Returns
string|null
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 105 of file Frame.php.

References Whoops\Exception\Frame\$fileContentsCache, and Whoops\Exception\Frame\getFile().

Referenced by Whoops\Exception\Frame\getFileLines().

106  {
107  if ($this->fileContentsCache === null && $filePath = $this->getFile()) {
108  // Leave the stage early when 'Unknown' is passed
109  // this would otherwise raise an exception when
110  // open_basedir is enabled.
111  if ($filePath === "Unknown") {
112  return null;
113  }
114 
115  // Return null if the file doesn't actually exist.
116  if (!is_file($filePath)) {
117  return null;
118  }
119 
120  $this->fileContentsCache = file_get_contents($filePath);
121  }
122 
124  }
getFile($shortened=false)
Definition: Frame.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFileLines()

Whoops\Exception\Frame::getFileLines (   $start = 0,
  $length = null 
)
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 195 of file Frame.php.

References Whoops\Exception\Frame\getFileContents().

196  {
197  if (null !== ($contents = $this->getFileContents())) {
198  $lines = explode("\n", $contents);
199 
200  // Get a subset of lines from $start to $end
201  if ($length !== null) {
202  $start = (int) $start;
203  $length = (int) $length;
204  if ($start < 0) {
205  $start = 0;
206  }
207 
208  if ($length <= 0) {
209  throw new InvalidArgumentException(
210  "\$length($length) cannot be lower or equal to 0"
211  );
212  }
213 
214  $lines = array_slice($lines, $start, $length, true);
215  }
216 
217  return $lines;
218  }
219  }
getFileContents()
Returns the full contents of the file for this frame, if it&#39;s known.
Definition: Frame.php:105
+ Here is the call graph for this function:

◆ getFunction()

Whoops\Exception\Frame::getFunction ( )
Returns
string|null
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 87 of file Frame.php.

88  {
89  return isset($this->frame['function']) ? $this->frame['function'] : null;
90  }

◆ getLine()

Whoops\Exception\Frame::getLine ( )
Returns
int|null
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 71 of file Frame.php.

Referenced by Whoops\Exception\Frame\equals().

72  {
73  return isset($this->frame['line']) ? $this->frame['line'] : null;
74  }
+ Here is the caller graph for this function:

◆ getRawFrame()

Whoops\Exception\Frame::getRawFrame ( )

Returns the array containing the raw frame data from which this Frame object was built.

Returns
array
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 172 of file Frame.php.

References Whoops\Exception\Frame\$frame.

173  {
174  return $this->frame;
175  }

◆ serialize()

Whoops\Exception\Frame::serialize ( )

Implements the Serializable interface, with special steps to also save the existing comments.

See also
Serializable::serialize
Returns
string
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 228 of file Frame.php.

References Whoops\Exception\Frame\$comments, and Whoops\Exception\Frame\$frame.

229  {
231  if (!empty($this->comments)) {
232  $frame['_comments'] = $this->comments;
233  }
234 
235  return serialize($frame);
236  }
serialize()
Implements the Serializable interface, with special steps to also save the existing comments...
Definition: Frame.php:228

◆ unserialize()

Whoops\Exception\Frame::unserialize (   $serializedFrame)

Unserializes the frame data, while also preserving any existing comment data.

See also
Serializable::unserialize
Parameters
string$serializedFrame
Examples:
/usr/local/src/ilias/release_5-1/Services/Exceptions/lib/Whoops/Exception/Frame.php.

Definition at line 245 of file Frame.php.

References Whoops\Exception\Frame\$frame.

246  {
247  $frame = unserialize($serializedFrame);
248 
249  if (!empty($frame['_comments'])) {
250  $this->comments = $frame['_comments'];
251  unset($frame['_comments']);
252  }
253 
254  $this->frame = $frame;
255  }
unserialize($serializedFrame)
Unserializes the frame data, while also preserving any existing comment data.
Definition: Frame.php:245

Field Documentation

◆ $comments

Whoops\Exception\Frame::$comments = array()
protected

◆ $fileContentsCache

Whoops\Exception\Frame::$fileContentsCache
protected

◆ $frame


The documentation for this class was generated from the following file: