Skip to content

Commit 1e88f7e

Browse files
committed
perf(bootstrapper): Optimize sprintf usage
- Replace all instances of sprintf with \sprintf for consistency. - Ensures better performance and adherence to PHP best practices. - This change affects Bootstrapper, OutputManager, and ConsoleOutput classes.
1 parent 993c8cd commit 1e88f7e

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/Bootstrapper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function getScores(): Collection
6767
$query = $this->matchQuery(self::$queries, $score);
6868

6969
return [
70-
'Summary' => sprintf(
70+
'Summary' => \sprintf(
7171
'[%s|%d分|%s|%s]',
7272
$star = to_star($score['Score']),
7373
$score['Score'],
@@ -152,7 +152,7 @@ protected function getBacktraces(int $limit = 0, int $forgetLines = 0): array
152152
static fn ($trace): bool => isset($trace['file'], $trace['line'])
153153
&& ! Str::contains($trace['file'], 'vendor')
154154
)
155-
->map(static fn ($trace, $index): string => sprintf(
155+
->map(static fn ($trace, $index): string => \sprintf(
156156
'#%s %s:%s',
157157
$index,
158158
str_replace(base_path(), '', $trace['file']),

src/OutputManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function output(Collection $scores, $dispatcher): void
7676
public function offsetSet($offset, $value): void
7777
{
7878
if (! $value instanceof Output) {
79-
throw new InvalidArgumentException(sprintf('The value must be instance of %s', Output::class));
79+
throw new InvalidArgumentException(\sprintf('The value must be instance of %s', Output::class));
8080
}
8181

8282
$this->attributes[$offset] = $value;

src/Outputs/ConsoleOutput.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function output(Collection $scores, $dispatcher): void
4747
*/
4848
protected function toJavascript(Collection $scores): string
4949
{
50-
return sprintf(
50+
return \sprintf(
5151
'<script type="text/javascript">console.%s(`%s`);</script>',
5252
$this->method,
5353
str_replace('`', '\`', $this->hydrateScores($scores)),

0 commit comments

Comments
 (0)