| 1 |
<?php |
| 2 |
|
| 3 |
declare (strict_types=1); |
| 4 |
namespace WCPOS\Vendor\Sentry; |
| 5 |
|
| 6 |
/** |
| 7 |
* This class represents a single frame of a stacktrace. |
| 8 |
* |
| 9 |
* @author Stefano Arlandini <[email protected]> |
| 10 |
*/ |
| 11 |
final class Frame |
| 12 |
{ |
| 13 |
public const INTERNAL_FRAME_FILENAME = '[internal]'; |
| 14 |
/** |
| 15 |
* @deprecated This constant is deprecated and will be removed in 5.x. |
| 16 |
*/ |
| 17 |
public const ANONYMOUS_CLASS_PREFIX = "class@anonymous\x00"; |
| 18 |
/** |
| 19 |
* @var string|null The name of the function being called |
| 20 |
*/ |
| 21 |
private $functionName; |
| 22 |
/** |
| 23 |
* @var string|null The original function name, if the function name is |
| 24 |
* shortened or demangled |
| 25 |
*/ |
| 26 |
private $rawFunctionName; |
| 27 |
/** |
| 28 |
* @var string The file where the frame originated |
| 29 |
*/ |
| 30 |
private $file; |
| 31 |
/** |
| 32 |
* @var string|null The absolute path to the source file |
| 33 |
*/ |
| 34 |
private $absoluteFilePath; |
| 35 |
/** |
| 36 |
* @var int The line at which the frame originated |
| 37 |
*/ |
| 38 |
private $line; |
| 39 |
/** |
| 40 |
* @var string[] A list of source code lines before the one where the frame |
| 41 |
* originated |
| 42 |
*/ |
| 43 |
private $preContext = []; |
| 44 |
/** |
| 45 |
* @var string|null The source code written at the line number of the file that |
| 46 |
* originated this frame |
| 47 |
*/ |
| 48 |
private $contextLine; |
| 49 |
/** |
| 50 |
* @var string[] A list of source code lines after the one where the frame |
| 51 |
* originated |
| 52 |
*/ |
| 53 |
private $postContext = []; |
| 54 |
/** |
| 55 |
* @var bool Flag telling whether the frame is related to the execution of |
| 56 |
* the relevant code in this stacktrace |
| 57 |
*/ |
| 58 |
private $inApp; |
| 59 |
/** |
| 60 |
* @var array<string, mixed> A mapping of variables which were available within |
| 61 |
* this frame (usually context-locals) |
| 62 |
*/ |
| 63 |
private $vars = []; |
| 64 |
/** |
| 65 |
* Initializes a new instance of this class using the provided information. |
| 66 |
* |
| 67 |
* @param string|null $functionName The name of the function being called |
| 68 |
* @param string $file The file where the frame originated |
| 69 |
* @param string|null $rawFunctionName The original function name, if the function |
| 70 |
* name is shortened or demangled |
| 71 |
* @param string|null $absoluteFilePath The absolute path to the source file |
| 72 |
* @param int $line The line at which the frame originated |
| 73 |
* @param array<string, mixed> $vars A mapping of variables which were available |
| 74 |
* within the frame |
| 75 |
* @param bool $inApp Whether the frame is related to the |
| 76 |
* execution of code relevant to the |
| 77 |
* application |
| 78 |
*/ |
| 79 |
public function __construct(?string $functionName, string $file, int $line, ?string $rawFunctionName = null, ?string $absoluteFilePath = null, array $vars = [], bool $inApp = \true) |
| 80 |
{ |
| 81 |
$this->functionName = $functionName; |
| 82 |
$this->file = $file; |
| 83 |
$this->line = $line; |
| 84 |
$this->rawFunctionName = $rawFunctionName; |
| 85 |
$this->absoluteFilePath = $absoluteFilePath; |
| 86 |
$this->vars = $vars; |
| 87 |
$this->inApp = $inApp; |
| 88 |
} |
| 89 |
/** |
| 90 |
* Gets the name of the function being called. |
| 91 |
*/ |
| 92 |
public function getFunctionName() : ?string |
| 93 |
{ |
| 94 |
return $this->functionName; |
| 95 |
} |
| 96 |
/** |
| 97 |
* Gets the original function name, if the function name is shortened or |
| 98 |
* demangled. |
| 99 |
*/ |
| 100 |
public function getRawFunctionName() : ?string |
| 101 |
{ |
| 102 |
return $this->rawFunctionName; |
| 103 |
} |
| 104 |
/** |
| 105 |
* Gets the file where the frame originated. |
| 106 |
*/ |
| 107 |
public function getFile() : string |
| 108 |
{ |
| 109 |
return $this->file; |
| 110 |
} |
| 111 |
/** |
| 112 |
* Gets the absolute path to the source file. |
| 113 |
*/ |
| 114 |
public function getAbsoluteFilePath() : ?string |
| 115 |
{ |
| 116 |
return $this->absoluteFilePath; |
| 117 |
} |
| 118 |
/** |
| 119 |
* Gets the line at which the frame originated. |
| 120 |
*/ |
| 121 |
public function getLine() : int |
| 122 |
{ |
| 123 |
return $this->line; |
| 124 |
} |
| 125 |
/** |
| 126 |
* Gets a list of source code lines before the one where the frame originated. |
| 127 |
* |
| 128 |
* @return string[] |
| 129 |
*/ |
| 130 |
public function getPreContext() : array |
| 131 |
{ |
| 132 |
return $this->preContext; |
| 133 |
} |
| 134 |
/** |
| 135 |
* Sets a list of source code lines before the one where the frame originated. |
| 136 |
* |
| 137 |
* @param string[] $preContext The source code lines |
| 138 |
*/ |
| 139 |
public function setPreContext(array $preContext) : self |
| 140 |
{ |
| 141 |
$this->preContext = $preContext; |
| 142 |
return $this; |
| 143 |
} |
| 144 |
/** |
| 145 |
* Gets the source code written at the line number of the file that originated |
| 146 |
* this frame. |
| 147 |
*/ |
| 148 |
public function getContextLine() : ?string |
| 149 |
{ |
| 150 |
return $this->contextLine; |
| 151 |
} |
| 152 |
/** |
| 153 |
* Sets the source code written at the line number of the file that originated |
| 154 |
* this frame. |
| 155 |
* |
| 156 |
* @param string|null $contextLine The source code line |
| 157 |
*/ |
| 158 |
public function setContextLine(?string $contextLine) : self |
| 159 |
{ |
| 160 |
$this->contextLine = $contextLine; |
| 161 |
return $this; |
| 162 |
} |
| 163 |
/** |
| 164 |
* Gets a list of source code lines after the one where the frame originated. |
| 165 |
* |
| 166 |
* @return string[] |
| 167 |
*/ |
| 168 |
public function getPostContext() : array |
| 169 |
{ |
| 170 |
return $this->postContext; |
| 171 |
} |
| 172 |
/** |
| 173 |
* Sets a list of source code lines after the one where the frame originated. |
| 174 |
* |
| 175 |
* @param string[] $postContext The source code lines |
| 176 |
*/ |
| 177 |
public function setPostContext(array $postContext) : self |
| 178 |
{ |
| 179 |
$this->postContext = $postContext; |
| 180 |
return $this; |
| 181 |
} |
| 182 |
/** |
| 183 |
* Gets whether the frame is related to the execution of the relevant code |
| 184 |
* in this stacktrace. |
| 185 |
*/ |
| 186 |
public function isInApp() : bool |
| 187 |
{ |
| 188 |
return $this->inApp; |
| 189 |
} |
| 190 |
/** |
| 191 |
* Sets whether the frame is related to the execution of the relevant code |
| 192 |
* in this stacktrace. |
| 193 |
* |
| 194 |
* @param bool $inApp flag indicating whether the frame is application-related |
| 195 |
*/ |
| 196 |
public function setIsInApp(bool $inApp) : self |
| 197 |
{ |
| 198 |
$this->inApp = $inApp; |
| 199 |
return $this; |
| 200 |
} |
| 201 |
/** |
| 202 |
* Gets a mapping of variables which were available within this frame |
| 203 |
* (usually context-locals). |
| 204 |
* |
| 205 |
* @return array<string, mixed> |
| 206 |
*/ |
| 207 |
public function getVars() : array |
| 208 |
{ |
| 209 |
return $this->vars; |
| 210 |
} |
| 211 |
/** |
| 212 |
* Sets a mapping of variables which were available within this frame |
| 213 |
* (usually context-locals). |
| 214 |
* |
| 215 |
* @param array<string, mixed> $vars The variables |
| 216 |
*/ |
| 217 |
public function setVars(array $vars) : self |
| 218 |
{ |
| 219 |
$this->vars = $vars; |
| 220 |
return $this; |
| 221 |
} |
| 222 |
/** |
| 223 |
* Gets whether the frame is internal. |
| 224 |
*/ |
| 225 |
public function isInternal() : bool |
| 226 |
{ |
| 227 |
return $this->file === self::INTERNAL_FRAME_FILENAME; |
| 228 |
} |
| 229 |
} |
| 230 |
|