From c23a0aa01b758d5117e18f0fef10c147f637bde2 Mon Sep 17 00:00:00 2001 From: Michael Hoffmann Date: Tue, 17 Oct 2023 00:05:47 +0200 Subject: [PATCH] Remove `symfony/polyfill-php80` --- composer.json | 3 +-- src/FrameBuilder.php | 8 ++++---- src/Tracing/DynamicSamplingContext.php | 2 +- src/Util/PrefixStripper.php | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 32ea2f592..2fc11051f 100644 --- a/composer.json +++ b/composer.json @@ -34,8 +34,7 @@ "psr/http-factory": "^1.0", "psr/http-factory-implementation": "^1.0", "psr/log": "^1.0|^2.0|^3.0", - "symfony/options-resolver": "^3.4.43|^4.4.30|^5.0.11|^6.0", - "symfony/polyfill-php80": "^1.17" + "symfony/options-resolver": "^3.4.43|^4.4.30|^5.0.11|^6.0" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.19|3.4.*", diff --git a/src/FrameBuilder.php b/src/FrameBuilder.php index 5cd61bae6..10854dcdb 100644 --- a/src/FrameBuilder.php +++ b/src/FrameBuilder.php @@ -74,7 +74,7 @@ public function buildFromBacktraceFrame(string $file, int $line, array $backtrac if (isset($backtraceFrame['class']) && isset($backtraceFrame['function'])) { $functionName = $backtraceFrame['class']; - if (str_starts_with($functionName, Frame::ANONYMOUS_CLASS_PREFIX)) { + if (Frame::ANONYMOUS_CLASS_PREFIX === mb_substr($functionName, 0, mb_strlen(Frame::ANONYMOUS_CLASS_PREFIX))) { $functionName = Frame::ANONYMOUS_CLASS_PREFIX . $this->stripPrefixFromFilePath($this->options, substr($backtraceFrame['class'], \strlen(Frame::ANONYMOUS_CLASS_PREFIX))); } @@ -107,7 +107,7 @@ private function isFrameInApp(string $file, ?string $functionName): bool return false; } - if (null !== $functionName && str_starts_with($functionName, 'Sentry\\')) { + if (null !== $functionName && 'Sentry\\' === substr($functionName, 0, \strlen('Sentry\\'))) { return false; } @@ -117,7 +117,7 @@ private function isFrameInApp(string $file, ?string $functionName): bool $isInApp = true; foreach ($excludedAppPaths as $excludedAppPath) { - if (str_starts_with($absoluteFilePath, $excludedAppPath)) { + if (mb_substr($absoluteFilePath, 0, mb_strlen($excludedAppPath)) === $excludedAppPath) { $isInApp = false; break; @@ -125,7 +125,7 @@ private function isFrameInApp(string $file, ?string $functionName): bool } foreach ($includedAppPaths as $includedAppPath) { - if (str_starts_with($absoluteFilePath, $includedAppPath)) { + if (mb_substr($absoluteFilePath, 0, mb_strlen($includedAppPath)) === $includedAppPath) { $isInApp = true; break; diff --git a/src/Tracing/DynamicSamplingContext.php b/src/Tracing/DynamicSamplingContext.php index a9ac69ade..b737ea960 100644 --- a/src/Tracing/DynamicSamplingContext.php +++ b/src/Tracing/DynamicSamplingContext.php @@ -127,7 +127,7 @@ public static function fromHeader(string $header): self [$key, $value] = explode('=', $keyValue, 2); - if (str_starts_with($key, self::SENTRY_ENTRY_PREFIX)) { + if (self::SENTRY_ENTRY_PREFIX === mb_substr($key, 0, mb_strlen(self::SENTRY_ENTRY_PREFIX))) { $samplingContext->set(rawurldecode(mb_substr($key, mb_strlen(self::SENTRY_ENTRY_PREFIX))), rawurldecode($value)); } } diff --git a/src/Util/PrefixStripper.php b/src/Util/PrefixStripper.php index 35c261312..d4f24286a 100644 --- a/src/Util/PrefixStripper.php +++ b/src/Util/PrefixStripper.php @@ -18,7 +18,7 @@ protected function stripPrefixFromFilePath(?Options $options, string $filePath): } foreach ($options->getPrefixes() as $prefix) { - if (str_starts_with($filePath, $prefix)) { + if (mb_substr($filePath, 0, mb_strlen($prefix)) === $prefix) { return mb_substr($filePath, mb_strlen($prefix)); } }