ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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-3/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 37 of file Frame.php.

References Whoops\Exception\Frame\$frame.

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

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

Definition at line 144 of file Frame.php.

References $comment, and comments.

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

◆ equals()

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

Compares Frame against one another.

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

Definition at line 269 of file Frame.php.

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

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
+ Here is the call graph for this function:

◆ getArgs()

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

Definition at line 102 of file Frame.php.

References array.

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

103  {
104  return isset($this->frame['args']) ? (array) $this->frame['args'] : [];
105  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getClass()

Whoops\Exception\Frame::getClass ( )
Returns
string|null
Examples:
/usr/local/src/ilias/release_5-3/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-3/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 160 of file Frame.php.

References Whoops\Exception\Frame\$comments.

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  }

◆ getFile()

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

Definition at line 46 of file Frame.php.

References $file.

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

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  }
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $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-3/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 112 of file Frame.php.

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

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

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  }
getFile($shortened=false)
Definition: Frame.php:46
+ 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-3/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 202 of file Frame.php.

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

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&#39;s known.
Definition: Frame.php:112
+ Here is the call graph for this function:

◆ getFunction()

Whoops\Exception\Frame::getFunction ( )
Returns
string|null
Examples:
/usr/local/src/ilias/release_5-3/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-3/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 78 of file Frame.php.

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

79  {
80  return isset($this->frame['line']) ? $this->frame['line'] : null;
81  }
+ 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-3/libs/composer/vendor/filp/whoops/src/Whoops/Exception/Frame.php.

Definition at line 179 of file Frame.php.

References Whoops\Exception\Frame\$frame.

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

◆ isApplication()

Whoops\Exception\Frame::isApplication ( )

Returns whether this frame belongs to the application or not.

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

Definition at line 282 of file Frame.php.

References Whoops\Exception\Frame\$application.

Referenced by Whoops\Exception\FrameCollection\countIsApplication().

283  {
284  return $this->application;
285  }
+ Here is the caller graph for this function:

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

Definition at line 235 of file Frame.php.

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

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
Add comments

◆ setApplication()

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

Mark as an frame belonging to the application.

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

Definition at line 292 of file Frame.php.

References Whoops\Exception\Frame\$application.

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

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

Definition at line 252 of file Frame.php.

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

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
Add comments

Field Documentation

◆ $application

◆ $comments

◆ $fileContentsCache

Whoops\Exception\Frame::$fileContentsCache
protected

◆ $frame


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