ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 
 isApplication ()
 Returns whether this frame belongs to the application or not. More...
 
 setApplication ($application)
 Mark as an frame belonging to the application. More...
 

Protected Attributes

 $frame
 
 $fileContentsCache
 
 $comments = []
 
 $application
 

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-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 37 of file Frame.php.

38 {
39 $this->frame = $frame;
40 }

References Whoops\Exception\Frame\$frame.

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-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 144 of file Frame.php.

145 {
146 $this->comments[] = [
147 'comment' => $comment,
148 'context' => $context,
149 ];
150 }
$comment
Definition: buildRTE.php:83
$context
Definition: webdav.php:25

References $comment, and $context.

◆ equals()

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

Compares Frame against one another.

Parameters
Frame$frame
Returns
bool
Examples
/usr/local/src/ilias/release_5-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 269 of file Frame.php.

270 {
271 if (!$this->getFile() || $this->getFile() === 'Unknown' || !$this->getLine()) {
272 return false;
273 }
274 return $frame->getFile() === $this->getFile() && $frame->getLine() === $this->getLine();
275 }
getFile($shortened=false)
Definition: Frame.php:46

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

+ Here is the call graph for this function:

◆ getArgs()

Whoops\Exception\Frame::getArgs ( )
Returns
array
Examples
/usr/local/src/ilias/release_5-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 102 of file Frame.php.

103 {
104 return isset($this->frame['args']) ? (array) $this->frame['args'] : [];
105 }

Referenced by Whoops\Util\TemplateHelper\dumpArgs(), and Whoops\Handler\PlainTextHandler\getFrameArgsOutput().

+ Here is the caller graph for this function:

◆ getClass()

Whoops\Exception\Frame::getClass ( )
Returns
string|null
Examples
/usr/local/src/ilias/release_5-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 86 of file Frame.php.

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

◆ 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-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 160 of file Frame.php.

161 {
163
164 if ($filter !== null) {
165 $comments = array_filter($comments, function ($c) use ($filter) {
166 return $c['context'] == $filter;
167 });
168 }
169
170 return $comments;
171 }

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

◆ getFile()

Whoops\Exception\Frame::getFile (   $shortened = false)
Parameters
bool$shortened
Returns
string|null
Examples
/usr/local/src/ilias/release_5-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 46 of file Frame.php.

47 {
48 if (empty($this->frame['file'])) {
49 return null;
50 }
51
52 $file = $this->frame['file'];
53
54 // Check if this frame occurred within an eval().
55 // @todo: This can be made more reliable by checking if we've entered
56 // eval() in a previous trace, but will need some more work on the upper
57 // trace collector(s).
58 if (preg_match('/^(.*)\‍((\d+)\‍) : (?:eval\‍(\‍)\'d|assert) code$/', $file, $matches)) {
59 $file = $this->frame['file'] = $matches[1];
60 $this->frame['line'] = (int) $matches[2];
61 }
62
63 if ($shortened && is_string($file)) {
64 // Replace the part of the path that all frames have in common, and add 'soft hyphens' for smoother line-breaks.
65 $dirname = dirname(dirname(dirname(dirname(dirname(dirname(__DIR__))))));
66 if ($dirname !== '/') {
67 $file = str_replace($dirname, "…", $file);
68 }
69 $file = str_replace("/", "/­", $file);
70 }
71
72 return $file;
73 }

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

+ 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-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 112 of file Frame.php.

113 {
114 if ($this->fileContentsCache === null && $filePath = $this->getFile()) {
115 // Leave the stage early when 'Unknown' is passed
116 // this would otherwise raise an exception when
117 // open_basedir is enabled.
118 if ($filePath === "Unknown") {
119 return null;
120 }
121
122 // Return null if the file doesn't actually exist.
123 if (!is_file($filePath)) {
124 return null;
125 }
126
127 $this->fileContentsCache = file_get_contents($filePath);
128 }
129
131 }

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

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

+ 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-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 202 of file Frame.php.

203 {
204 if (null !== ($contents = $this->getFileContents())) {
205 $lines = explode("\n", $contents);
206
207 // Get a subset of lines from $start to $end
208 if ($length !== null) {
209 $start = (int) $start;
210 $length = (int) $length;
211 if ($start < 0) {
212 $start = 0;
213 }
214
215 if ($length <= 0) {
216 throw new InvalidArgumentException(
217 "\$length($length) cannot be lower or equal to 0"
218 );
219 }
220
221 $lines = array_slice($lines, $start, $length, true);
222 }
223
224 return $lines;
225 }
226 }
getFileContents()
Returns the full contents of the file for this frame, if it's known.
Definition: Frame.php:112
$start
Definition: bench.php:8

References $start, and Whoops\Exception\Frame\getFileContents().

+ Here is the call graph for this function:

◆ getFunction()

Whoops\Exception\Frame::getFunction ( )
Returns
string|null
Examples
/usr/local/src/ilias/release_5-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 94 of file Frame.php.

95 {
96 return isset($this->frame['function']) ? $this->frame['function'] : null;
97 }

◆ getLine()

Whoops\Exception\Frame::getLine ( )
Returns
int|null
Examples
/usr/local/src/ilias/release_5-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 78 of file Frame.php.

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

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

+ 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-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 179 of file Frame.php.

180 {
181 return $this->frame;
182 }

References Whoops\Exception\Frame\$frame.

◆ isApplication()

Whoops\Exception\Frame::isApplication ( )

Returns whether this frame belongs to the application or not.

Returns
boolean
Examples
/usr/local/src/ilias/release_5-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 282 of file Frame.php.

283 {
284 return $this->application;
285 }

References Whoops\Exception\Frame\$application.

◆ 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-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 235 of file Frame.php.

236 {
238 if (!empty($this->comments)) {
239 $frame['_comments'] = $this->comments;
240 }
241
242 return serialize($frame);
243 }
serialize()
Implements the Serializable interface, with special steps to also save the existing comments.
Definition: Frame.php:235

References Whoops\Exception\Frame\$comments, Whoops\Exception\Frame\$frame, and Whoops\Exception\Frame\serialize().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setApplication()

Whoops\Exception\Frame::setApplication (   $application)

Mark as an frame belonging to the application.

Parameters
boolean$application
Examples
/usr/local/src/ilias/release_5-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 292 of file Frame.php.

293 {
294 $this->application = $application;
295 }

References Whoops\Exception\Frame\$application.

◆ 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-4/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 252 of file Frame.php.

253 {
254 $frame = unserialize($serializedFrame);
255
256 if (!empty($frame['_comments'])) {
257 $this->comments = $frame['_comments'];
258 unset($frame['_comments']);
259 }
260
261 $this->frame = $frame;
262 }
unserialize($serializedFrame)
Unserializes the frame data, while also preserving any existing comment data.
Definition: Frame.php:252

References Whoops\Exception\Frame\$frame, and Whoops\Exception\Frame\unserialize().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $application

◆ $comments

◆ $fileContentsCache

Whoops\Exception\Frame::$fileContentsCache
protected

◆ $frame


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