woocommerce-pos
/
vendor_prefixed
/
sentry
/
sentry
/
src
/
Serializer
/
Traits
/
StacktraceFrameSeralizerTrait.php
StacktraceFrameSeralizerTrait.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.24, at vendor_prefixed/sentry/sentry/src/Serializer/Traits/StacktraceFrameSeralizerTrait.php
| 1 | <?php |
| 2 | |
| 3 | declare (strict_types=1); |
| 4 | namespace WCPOS\Vendor\Sentry\Serializer\Traits; |
| 5 | |
| 6 | use WCPOS\Vendor\Sentry\Frame; |
| 7 | /** |
| 8 | * @internal |
| 9 | */ |
| 10 | trait StacktraceFrameSeralizerTrait |
| 11 | { |
| 12 | /** |
| 13 | * @return array<string, mixed> |
| 14 | * |
| 15 | * @phpstan-return array{ |
| 16 | * filename: string, |
| 17 | * lineno: int, |
| 18 | * in_app: bool, |
| 19 | * abs_path?: string, |
| 20 | * function?: string, |
| 21 | * raw_function?: string, |
| 22 | * pre_context?: string[], |
| 23 | * context_line?: string, |
| 24 | * post_context?: string[], |
| 25 | * vars?: array<string, mixed> |
| 26 | * } |
| 27 | */ |
| 28 | protected static function serializeStacktraceFrame(Frame $frame) : array |
| 29 | { |
| 30 | $result = ['filename' => $frame->getFile(), 'lineno' => $frame->getLine(), 'in_app' => $frame->isInApp()]; |
| 31 | if ($frame->getAbsoluteFilePath() !== null) { |
| 32 | $result['abs_path'] = $frame->getAbsoluteFilePath(); |
| 33 | } |
| 34 | if ($frame->getFunctionName() !== null) { |
| 35 | $result['function'] = $frame->getFunctionName(); |
| 36 | } |
| 37 | if ($frame->getRawFunctionName() !== null) { |
| 38 | $result['raw_function'] = $frame->getRawFunctionName(); |
| 39 | } |
| 40 | if (!empty($frame->getPreContext())) { |
| 41 | $result['pre_context'] = $frame->getPreContext(); |
| 42 | } |
| 43 | if ($frame->getContextLine() !== null) { |
| 44 | $result['context_line'] = $frame->getContextLine(); |
| 45 | } |
| 46 | if (!empty($frame->getPostContext())) { |
| 47 | $result['post_context'] = $frame->getPostContext(); |
| 48 | } |
| 49 | if (!empty($frame->getVars())) { |
| 50 | $result['vars'] = $frame->getVars(); |
| 51 | } |
| 52 | return $result; |
| 53 | } |
| 54 | } |
| 55 |