PluginProbe
WCPOS – Point of Sale (POS) plugin for WooCommerce / 1.10.11
WCPOS – Point of Sale (POS) plugin for WooCommerce v1.10.11
1.10.25 1.10.24 1.10.23 1.10.22 1.10.21 1.10.20 1.10.19 1.10.18 1.10.17 1.10.16 1.10.15 1.10.13 1.10.14 1.10.12 1.10.11 1.10.10 1.10.9 1.10.8 untagged-3d9b7ccddc54df87c672 1.10.7 1.10.6 1.10.5 1.10.3 1.10.4 1.10.2 All 169 releases
woocommerce-pos / vendor_prefixed / sentry / sentry / src / StacktraceBuilder.php

StacktraceBuilder.php in WCPOS – Point of Sale (POS) plugin for WooCommerce 1.10.11, at vendor_prefixed/sentry/sentry/src/StacktraceBuilder.php

64 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare (strict_types=1);
4 namespace WCPOS\Vendor\Sentry;
5
6 use WCPOS\Vendor\Sentry\Serializer\RepresentationSerializerInterface;
7 use WCPOS\Vendor\Sentry\Util\PHPConfiguration;
8 /**
9 * This class builds {@see Stacktrace} objects from an instance of an exception
10 * or from a backtrace.
11 *
12 * @phpstan-import-type StacktraceFrame from FrameBuilder
13 */
14 final class StacktraceBuilder
15 {
16 /**
17 * @var FrameBuilder An instance of the builder of {@see Frame} objects
18 */
19 private $frameBuilder;
20 /**
21 * Constructor.
22 *
23 * @param Options $options The SDK client options
24 * @param RepresentationSerializerInterface $representationSerializer The representation serializer
25 */
26 public function __construct(Options $options, RepresentationSerializerInterface $representationSerializer)
27 {
28 $this->frameBuilder = new FrameBuilder($options, $representationSerializer);
29 if (PHPConfiguration::isBooleanIniOptionEnabled('zend.exception_ignore_args')) {
30 $options->getLoggerOrNullLogger()->warning('The "zend.exception_ignore_args" PHP setting is enabled which results in missing stack trace arguments, see: https://docs.sentry.io/platforms/php/troubleshooting/#missing-variables-in-stack-traces.');
31 }
32 }
33 /**
34 * Builds a {@see Stacktrace} object from the given exception.
35 *
36 * @param \Throwable $exception The exception object
37 */
38 public function buildFromException(\Throwable $exception) : Stacktrace
39 {
40 return $this->buildFromBacktrace($exception->getTrace(), $exception->getFile(), $exception->getLine());
41 }
42 /**
43 * Builds a {@see Stacktrace} object from the given backtrace.
44 *
45 * @param array<int, array<string, mixed>> $backtrace The backtrace
46 * @param string $file The file where the backtrace originated from
47 * @param int $line The line from which the backtrace originated from
48 *
49 * @phpstan-param list<StacktraceFrame> $backtrace
50 */
51 public function buildFromBacktrace(array $backtrace, string $file, int $line) : Stacktrace
52 {
53 $frames = [];
54 foreach ($backtrace as $backtraceFrame) {
55 $frames[] = $this->frameBuilder->buildFromBacktraceFrame($file, $line, $backtraceFrame);
56 $file = $backtraceFrame['file'] ?? Frame::INTERNAL_FRAME_FILENAME;
57 $line = $backtraceFrame['line'] ?? 0;
58 }
59 // Add a final stackframe for the first method ever of this stacktrace
60 $frames[] = $this->frameBuilder->buildFromBacktraceFrame($file, $line, []);
61 return new Stacktrace(\array_reverse($frames));
62 }
63 }
64