Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply php-cs-fixer changes #1765

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public function captureEvent(Event $event, ?EventHint $hint = null, ?Scope $scop
}
} catch (\Throwable $exception) {
$this->logger->error(
sprintf('Failed to send the event to Sentry. Reason: "%s".', $exception->getMessage()),
\sprintf('Failed to send the event to Sentry. Reason: "%s".', $exception->getMessage()),
['exception' => $exception, 'event' => $event]
);
}
Expand Down Expand Up @@ -294,7 +294,7 @@ private function prepareEvent(Event $event, ?EventHint $hint = null, ?Scope $sco
$event->setEnvironment($this->options->getEnvironment() ?? Event::DEFAULT_ENVIRONMENT);
}

$eventDescription = sprintf(
$eventDescription = \sprintf(
'%s%s [%s]',
$event->getLevel() !== null ? $event->getLevel() . ' ' : '',
(string) $event->getType(),
Expand All @@ -306,7 +306,7 @@ private function prepareEvent(Event $event, ?EventHint $hint = null, ?Scope $sco

// only sample with the `sample_rate` on errors/messages
if ($isEvent && $sampleRate < 1 && mt_rand(1, 100) / 100.0 > $sampleRate) {
$this->logger->info(sprintf('The %s will be discarded because it has been sampled.', $eventDescription), ['event' => $event]);
$this->logger->info(\sprintf('The %s will be discarded because it has been sampled.', $eventDescription), ['event' => $event]);

return null;
}
Expand All @@ -323,7 +323,7 @@ private function prepareEvent(Event $event, ?EventHint $hint = null, ?Scope $sco

if ($event === null) {
$this->logger->info(
sprintf('The %s will be discarded because one of the event processors returned "null".', $eventDescription),
\sprintf('The %s will be discarded because one of the event processors returned "null".', $eventDescription),
['event' => $beforeEventProcessors]
);

Expand All @@ -336,7 +336,7 @@ private function prepareEvent(Event $event, ?EventHint $hint = null, ?Scope $sco

if ($event === null) {
$this->logger->info(
sprintf(
\sprintf(
'The %s will be discarded because the "%s" callback returned "null".',
$eventDescription,
$this->getBeforeSendCallbackName($beforeSendCallback)
Expand Down Expand Up @@ -371,7 +371,7 @@ private function applyIgnoreOptions(Event $event, string $eventDescription): ?Ev
foreach ($exceptions as $exception) {
if ($this->isIgnoredException($exception->getType())) {
$this->logger->info(
sprintf('The %s will be discarded because it matches an entry in "ignore_exceptions".', $eventDescription),
\sprintf('The %s will be discarded because it matches an entry in "ignore_exceptions".', $eventDescription),
['event' => $event]
);

Expand All @@ -389,7 +389,7 @@ private function applyIgnoreOptions(Event $event, string $eventDescription): ?Ev

if (\in_array($transactionName, $this->options->getIgnoreTransactions(), true)) {
$this->logger->info(
sprintf('The %s will be discarded because it matches a entry in "ignore_transactions".', $eventDescription),
\sprintf('The %s will be discarded because it matches a entry in "ignore_transactions".', $eventDescription),
['event' => $event]
);

Expand Down
6 changes: 3 additions & 3 deletions src/Dsn.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ public static function createFromString(string $value): self
$parsedDsn = parse_url($value);

if ($parsedDsn === false) {
throw new \InvalidArgumentException(sprintf('The "%s" DSN is invalid.', $value));
throw new \InvalidArgumentException(\sprintf('The "%s" DSN is invalid.', $value));
}

foreach (['scheme', 'host', 'path', 'user'] as $component) {
if (!isset($parsedDsn[$component]) || (isset($parsedDsn[$component]) && empty($parsedDsn[$component]))) {
throw new \InvalidArgumentException(sprintf('The "%s" DSN must contain a scheme, a host, a user and a path component.', $value));
throw new \InvalidArgumentException(\sprintf('The "%s" DSN must contain a scheme, a host, a user and a path component.', $value));
}
}

if (!\in_array($parsedDsn['scheme'], ['http', 'https'], true)) {
throw new \InvalidArgumentException(sprintf('The scheme of the "%s" DSN must be either "http" or "https".', $value));
throw new \InvalidArgumentException(\sprintf('The scheme of the "%s" DSN must be either "http" or "https".', $value));
}

$segmentPaths = explode('/', $parsedDsn['path']);
Expand Down
2 changes: 1 addition & 1 deletion src/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ public function setExceptions(array $exceptions): self
{
foreach ($exceptions as $exception) {
if (!$exception instanceof ExceptionDataBag) {
throw new \UnexpectedValueException(sprintf('Expected an instance of the "%s" class. Got: "%s".', ExceptionDataBag::class, get_debug_type($exception)));
throw new \UnexpectedValueException(\sprintf('Expected an instance of the "%s" class. Got: "%s".', ExceptionDataBag::class, get_debug_type($exception)));
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/EventHint.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ public static function fromArray(array $hintData): self
$extra = $hintData['extra'] ?? [];

if ($exception !== null && !$exception instanceof \Throwable) {
throw new \InvalidArgumentException(sprintf('The value of the "exception" field must be an instance of a class implementing the "%s" interface. Got: "%s".', \Throwable::class, get_debug_type($exception)));
throw new \InvalidArgumentException(\sprintf('The value of the "exception" field must be an instance of a class implementing the "%s" interface. Got: "%s".', \Throwable::class, get_debug_type($exception)));
}

if ($mechanism !== null && !$mechanism instanceof ExceptionMechanism) {
throw new \InvalidArgumentException(sprintf('The value of the "mechanism" field must be an instance of the "%s" class. Got: "%s".', ExceptionMechanism::class, get_debug_type($mechanism)));
throw new \InvalidArgumentException(\sprintf('The value of the "mechanism" field must be an instance of the "%s" class. Got: "%s".', ExceptionMechanism::class, get_debug_type($mechanism)));
}

if ($stacktrace !== null && !$stacktrace instanceof Stacktrace) {
throw new \InvalidArgumentException(sprintf('The value of the "stacktrace" field must be an instance of the "%s" class. Got: "%s".', Stacktrace::class, get_debug_type($stacktrace)));
throw new \InvalidArgumentException(\sprintf('The value of the "stacktrace" field must be an instance of the "%s" class. Got: "%s".', Stacktrace::class, get_debug_type($stacktrace)));
}

if (!\is_array($extra)) {
throw new \InvalidArgumentException(sprintf('The value of the "extra" field must be an array. Got: "%s".', get_debug_type($extra)));
throw new \InvalidArgumentException(\sprintf('The value of the "extra" field must be an array. Got: "%s".', get_debug_type($extra)));
}

$hint->exception = $exception;
Expand Down
4 changes: 2 additions & 2 deletions src/FrameBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ public function buildFromBacktraceFrame(string $file, int $line, array $backtrac
$functionName = Frame::ANONYMOUS_CLASS_PREFIX . $this->stripPrefixFromFilePath($this->options, substr($backtraceFrame['class'], \strlen(Frame::ANONYMOUS_CLASS_PREFIX)));
}

$rawFunctionName = sprintf('%s::%s', $backtraceFrame['class'], $backtraceFrame['function']);
$functionName = sprintf('%s::%s', preg_replace('/(?::\d+\$|0x)[a-fA-F0-9]+$/', '', $functionName), $backtraceFrame['function']);
$rawFunctionName = \sprintf('%s::%s', $backtraceFrame['class'], $backtraceFrame['function']);
$functionName = \sprintf('%s::%s', preg_replace('/(?::\d+\$|0x)[a-fA-F0-9]+$/', '', $functionName), $backtraceFrame['function']);
} elseif (isset($backtraceFrame['function'])) {
$functionName = $backtraceFrame['function'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Integration/FrameContextifierIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private function getSourceCodeExcerpt(int $maxContextLines, string $filePath, in
}
} catch (\Throwable $exception) {
$this->logger->warning(
sprintf('Failed to get the source code excerpt for the file "%s".', $filePath),
\sprintf('Failed to get the source code excerpt for the file "%s".', $filePath),
['exception' => $exception]
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Integration/IntegrationRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public function setupIntegrations(Options $options, LoggerInterface $logger): ar
}

if (\count($installed) > 0) {
$logger->debug(sprintf('The "%s" integration(s) have been installed.', implode(', ', $installed)));
$logger->debug(\sprintf('The "%s" integration(s) have been installed.', implode(', ', $installed)));
}

return $integrations;
Expand Down Expand Up @@ -123,7 +123,7 @@ private function getIntegrationsToSetup(Options $options): array
$integrations = $userIntegrations($defaultIntegrations);

if (!\is_array($integrations)) {
throw new \UnexpectedValueException(sprintf('Expected the callback set for the "integrations" option to return a list of integrations. Got: "%s".', get_debug_type($integrations)));
throw new \UnexpectedValueException(\sprintf('Expected the callback set for the "integrations" option to return a list of integrations. Got: "%s".', get_debug_type($integrations)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Integration/RequestIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ private function parseUploadedFiles(array $uploadedFiles): array
} elseif (\is_array($item)) {
$result[$key] = $this->parseUploadedFiles($item);
} else {
throw new \UnexpectedValueException(sprintf('Expected either an object implementing the "%s" interface or an array. Got: "%s".', UploadedFileInterface::class, \is_object($item) ? \get_class($item) : \gettype($item)));
throw new \UnexpectedValueException(\sprintf('Expected either an object implementing the "%s" interface or an array. Got: "%s".', UploadedFileInterface::class, \is_object($item) ? \get_class($item) : \gettype($item)));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Logger/DebugFileLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public function __construct(string $filePath)
*/
public function log($level, $message, array $context = []): void
{
file_put_contents($this->filePath, sprintf("sentry/sentry: [%s] %s\n", $level, (string) $message), \FILE_APPEND);
file_put_contents($this->filePath, \sprintf("sentry/sentry: [%s] %s\n", $level, (string) $message), \FILE_APPEND);
}
}
2 changes: 1 addition & 1 deletion src/Logger/DebugStdOutLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ class DebugStdOutLogger extends AbstractLogger
*/
public function log($level, $message, array $context = []): void
{
file_put_contents('php://stdout', sprintf("sentry/sentry: [%s] %s\n", $level, (string) $message));
file_put_contents('php://stdout', \sprintf("sentry/sentry: [%s] %s\n", $level, (string) $message));
}
}
2 changes: 1 addition & 1 deletion src/Metrics/Types/AbstractType.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function addCodeLocation(int $stackLevel): void

public function getMri(): string
{
return sprintf(
return \sprintf(
'%s:%s@%s',
$this->getType(),
$this->getKey(),
Expand Down
2 changes: 1 addition & 1 deletion src/Monolog/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected function doWrite($record): void
$event = Event::createEvent();
$event->setLevel(self::getSeverityFromLevel($record['level']));
$event->setMessage($record['message']);
$event->setLogger(sprintf('monolog.%s', $record['channel']));
$event->setLogger(\sprintf('monolog.%s', $record['channel']));

$hint = new EventHint();

Expand Down
4 changes: 2 additions & 2 deletions src/Profiling/Profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,14 @@ public function getFormattedData(Event $event): ?array
}

if (!$this->validateMaxDuration((float) $duration)) {
$this->logger->warning(sprintf('The profile is %ss which is longer than the allowed %ss, the profile will be discarded.', (float) $duration, self::MAX_PROFILE_DURATION));
$this->logger->warning(\sprintf('The profile is %ss which is longer than the allowed %ss, the profile will be discarded.', (float) $duration, self::MAX_PROFILE_DURATION));

return null;
}

$startTime = \DateTime::createFromFormat('U.u', number_format($this->startTimeStamp, 4, '.', ''), new \DateTimeZone('UTC'));
if ($startTime === false) {
$this->logger->warning(sprintf('The start time (%s) of the profile is not valid, the profile will be discarded.', $this->startTimeStamp));
$this->logger->warning(\sprintf('The start time (%s) of the profile is not valid, the profile will be discarded.', $this->startTimeStamp));

return null;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Profiling/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ private function initProfiler(): void
$this->profiler = new \ExcimerProfiler();
$this->profile->setStartTimeStamp(microtime(true));

$this->profiler->setEventType(EXCIMER_REAL);
$this->profiler->setEventType(\EXCIMER_REAL);
$this->profiler->setPeriod(self::SAMPLE_RATE);
$this->profiler->setMaxDepth(self::MAX_STACK_DEPTH);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Serializer/AbstractSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ protected function serializeCallable($callable): string
}

if (!\is_callable($callable)) {
throw new \InvalidArgumentException(sprintf('Expecting callable, got %s', \is_object($callable) ? \get_class($callable) : \gettype($callable)));
throw new \InvalidArgumentException(\sprintf('Expecting callable, got %s', \is_object($callable) ? \get_class($callable) : \gettype($callable)));
}

try {
Expand Down
2 changes: 1 addition & 1 deletion src/Serializer/EnvelopItems/CheckInItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ public static function toEnvelopeItem(Event $event): string
}
}

return sprintf("%s\n%s", JSON::encode($header), JSON::encode($payload));
return \sprintf("%s\n%s", JSON::encode($header), JSON::encode($payload));
}
}
2 changes: 1 addition & 1 deletion src/Serializer/EnvelopItems/EventItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static function toEnvelopeItem(Event $event): string
];
}

return sprintf("%s\n%s", JSON::encode($header), JSON::encode($payload));
return \sprintf("%s\n%s", JSON::encode($header), JSON::encode($payload));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Serializer/EnvelopItems/MetricsItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function toEnvelopeItem(Event $event): string
'length' => mb_strlen($metricMetaPayload),
];

return sprintf(
return \sprintf(
"%s\n%s\n%s\n%s",
JSON::encode($statsdHeader),
$statsdPayload,
Expand All @@ -80,7 +80,7 @@ public static function toEnvelopeItem(Event $event): string
);
}

return sprintf(
return \sprintf(
"%s\n%s",
JSON::encode($statsdHeader),
$statsdPayload
Expand Down
2 changes: 1 addition & 1 deletion src/Serializer/EnvelopItems/ProfileItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public static function toEnvelopeItem(Event $event): string
return '';
}

return sprintf("%s\n%s", JSON::encode($header), JSON::encode($payload));
return \sprintf("%s\n%s", JSON::encode($header), JSON::encode($payload));
}
}
2 changes: 1 addition & 1 deletion src/Serializer/EnvelopItems/TransactionItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public static function toEnvelopeItem(Event $event): string
$payload['transaction_info']['source'] = (string) $transactionMetadata->getSource();
}

return sprintf("%s\n%s", JSON::encode($header), JSON::encode($payload));
return \sprintf("%s\n%s", JSON::encode($header), JSON::encode($payload));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Serializer/PayloadSerializer.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function serialize(Event $event): string
if ($event->getSdkMetadata('profile') !== null) {
$profileItem = ProfileItem::toEnvelopeItem($event);
if ($profileItem !== '') {
$items = sprintf("%s\n%s", $transactionItem, $profileItem);
$items = \sprintf("%s\n%s", $transactionItem, $profileItem);
break;
}
}
Expand All @@ -83,6 +83,6 @@ public function serialize(Event $event): string
break;
}

return sprintf("%s\n%s", JSON::encode($envelopeHeader), $items);
return \sprintf("%s\n%s", JSON::encode($envelopeHeader), $items);
}
}
2 changes: 1 addition & 1 deletion src/Severity.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ final class Severity implements \Stringable
public function __construct(string $value = self::INFO)
{
if (!\in_array($value, self::ALLOWED_SEVERITIES, true)) {
throw new \InvalidArgumentException(sprintf('The "%s" is not a valid enum value.', $value));
throw new \InvalidArgumentException(\sprintf('The "%s" is not a valid enum value.', $value));
}

$this->value = $value;
Expand Down
4 changes: 2 additions & 2 deletions src/Stacktrace.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function __construct(array $frames)

foreach ($frames as $frame) {
if (!$frame instanceof Frame) {
throw new \UnexpectedValueException(sprintf('Expected an instance of the "%s" class. Got: "%s".', Frame::class, get_debug_type($frame)));
throw new \UnexpectedValueException(\sprintf('Expected an instance of the "%s" class. Got: "%s".', Frame::class, get_debug_type($frame)));
}
}

Expand Down Expand Up @@ -86,7 +86,7 @@ public function addFrame(Frame $frame): self
public function removeFrame(int $index): self
{
if (!isset($this->frames[$index])) {
throw new \OutOfBoundsException(sprintf('Cannot remove the frame at index %d.', $index));
throw new \OutOfBoundsException(\sprintf('Cannot remove the frame at index %d.', $index));
}

if (\count($this->frames) === 1) {
Expand Down
Loading
Loading