Skip to content

Commit a7dc64e

Browse files
committed
Apply php-cs-fixer
1 parent b380809 commit a7dc64e

File tree

111 files changed

+608
-608
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+608
-608
lines changed

benchmarks/BuildSchemaBench.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ interface F {
3737

3838
public function makeSchemaString(): void
3939
{
40-
foreach (\range(1, 100) as $i) {
40+
foreach (range(1, 100) as $i) {
4141
$this->schema .= /** @lang GraphQL */ <<<GRAPHQL
4242
union U{$i} = Foo | Bar
4343

benchmarks/Utils/SchemaGenerator.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class SchemaGenerator
2828
/** @param array<string, int> $config */
2929
public function __construct(array $config)
3030
{
31-
$this->config = \array_merge($this->config, $config);
31+
$this->config = array_merge($this->config, $config);
3232
}
3333

3434
public function buildSchema(): Schema
@@ -49,7 +49,7 @@ public function buildQueryType(): ObjectType
4949

5050
public function loadType(string $name): ObjectType
5151
{
52-
$tokens = \explode('_', $name);
52+
$tokens = explode('_', $name);
5353
$nestingLevel = (int) $tokens[1];
5454

5555
return $this->createType($nestingLevel, $name);
@@ -83,7 +83,7 @@ protected function getFieldTypeAndName(int $nestingLevel, int $fieldIndex): arra
8383
$fieldType = Type::string();
8484
$fieldName = 'leafField' . $fieldIndex;
8585
} elseif ($this->typeIndex >= $this->config['totalTypes']) {
86-
$fieldType = $this->objectTypes[\array_rand($this->objectTypes)];
86+
$fieldType = $this->objectTypes[array_rand($this->objectTypes)];
8787
$fieldName = 'randomTypeField' . $fieldIndex;
8888
} else {
8989
$fieldType = $this->createType($nestingLevel);
@@ -108,7 +108,7 @@ protected function createTypeFields(string $typeName, int $nestingLevel): array
108108

109109
for ($index = 0; $index < $this->config['listFieldsPerType']; ++$index) {
110110
[$type, $name] = $this->getFieldTypeAndName($nestingLevel, $index);
111-
$name = 'listOf' . \ucfirst($name);
111+
$name = 'listOf' . ucfirst($name);
112112

113113
$fields[] = [
114114
'name' => $name,

examples/01-blog/Blog/Data/DataSource.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -121,31 +121,31 @@ public static function findComment(int $id): ?Comment
121121

122122
public static function findLastStoryFor(int $authorId): ?Story
123123
{
124-
$storiesFound = \array_filter(
124+
$storiesFound = array_filter(
125125
self::$stories,
126126
static fn (Story $story): bool => $story->authorId === $authorId
127127
);
128128

129-
return $storiesFound[\count($storiesFound) - 1] ?? null;
129+
return $storiesFound[count($storiesFound) - 1] ?? null;
130130
}
131131

132132
/** @return array<int, User> */
133133
public static function findLikes(int $storyId, int $limit): array
134134
{
135135
$likes = self::$storyLikes[$storyId] ?? [];
136-
$users = \array_map(
136+
$users = array_map(
137137
static fn (int $userId) => self::$users[$userId],
138138
$likes
139139
);
140140

141-
return \array_slice($users, 0, $limit);
141+
return array_slice($users, 0, $limit);
142142
}
143143

144144
public static function isLikedBy(int $storyId, int $userId): bool
145145
{
146146
$subscribers = self::$storyLikes[$storyId] ?? [];
147147

148-
return \in_array($userId, $subscribers, true);
148+
return in_array($userId, $subscribers, true);
149149
}
150150

151151
public static function getUserPhoto(int $userId, string $size): Image
@@ -154,24 +154,24 @@ public static function getUserPhoto(int $userId, string $size): Image
154154
'id' => $userId,
155155
'type' => Image::TYPE_USERPIC,
156156
'size' => $size,
157-
'width' => \rand(100, 200),
158-
'height' => \rand(100, 200),
157+
'width' => rand(100, 200),
158+
'height' => rand(100, 200),
159159
]);
160160
}
161161

162162
public static function findLatestStory(): ?Story
163163
{
164-
return self::$stories[\count(self::$stories) - 1] ?? null;
164+
return self::$stories[count(self::$stories) - 1] ?? null;
165165
}
166166

167167
/** @return array<int, Story> */
168168
public static function findStories(int $limit, ?int $afterId = null): array
169169
{
170170
$start = $afterId !== null
171-
? (int) \array_search($afterId, \array_keys(self::$stories), true) + 1
171+
? (int) array_search($afterId, array_keys(self::$stories), true) + 1
172172
: 0;
173173

174-
return \array_slice(\array_values(self::$stories), $start, $limit);
174+
return array_slice(array_values(self::$stories), $start, $limit);
175175
}
176176

177177
/** @return array<int, Comment> */
@@ -180,11 +180,11 @@ public static function findComments(int $storyId, int $limit = 5, ?int $afterId
180180
$storyComments = self::$storyComments[$storyId] ?? [];
181181

182182
$start = isset($afterId)
183-
? (int) \array_search($afterId, $storyComments, true) + 1
183+
? (int) array_search($afterId, $storyComments, true) + 1
184184
: 0;
185-
$storyComments = \array_slice($storyComments, $start, $limit);
185+
$storyComments = array_slice($storyComments, $start, $limit);
186186

187-
return \array_map(
187+
return array_map(
188188
static fn (int $commentId): Comment => self::$comments[$commentId],
189189
$storyComments
190190
);
@@ -196,11 +196,11 @@ public static function findReplies(int $commentId, int $limit = 5, ?int $afterId
196196
$commentReplies = self::$commentReplies[$commentId] ?? [];
197197

198198
$start = isset($afterId)
199-
? (int) \array_search($afterId, $commentReplies, true) + 1
199+
? (int) array_search($afterId, $commentReplies, true) + 1
200200
: 0;
201-
$commentReplies = \array_slice($commentReplies, $start, $limit);
201+
$commentReplies = array_slice($commentReplies, $start, $limit);
202202

203-
return \array_map(
203+
return array_map(
204204
static fn (int $replyId): Comment => self::$comments[$replyId],
205205
$commentReplies
206206
);
@@ -209,14 +209,14 @@ public static function findReplies(int $commentId, int $limit = 5, ?int $afterId
209209
public static function countComments(int $storyId): int
210210
{
211211
return isset(self::$storyComments[$storyId])
212-
? \count(self::$storyComments[$storyId])
212+
? count(self::$storyComments[$storyId])
213213
: 0;
214214
}
215215

216216
public static function countReplies(int $commentId): int
217217
{
218218
return isset(self::$commentReplies[$commentId])
219-
? \count(self::$commentReplies[$commentId])
219+
? count(self::$commentReplies[$commentId])
220220
: 0;
221221
}
222222

examples/01-blog/Blog/Type/Field/HtmlField.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ public static function build(array $config): array
3636
],
3737
'resolve' => static function ($rootValue, array $args) use ($resolver): ?string {
3838
$html = $resolver($rootValue, $args);
39-
$text = \strip_tags($html);
39+
$text = strip_tags($html);
4040

4141
$safeText = isset($args['maxLength'])
42-
? \mb_substr($text, 0, $args['maxLength'])
42+
? mb_substr($text, 0, $args['maxLength'])
4343
: $text;
4444

4545
switch ($args['format']) {
4646
case ContentFormatType::FORMAT_HTML:
4747
if ($safeText !== $text) {
4848
// Text was truncated, so just show what's safe:
49-
return \nl2br($safeText);
49+
return nl2br($safeText);
5050
}
5151

5252
return $html;

examples/01-blog/Blog/Type/Scalar/EmailType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,6 @@ public function parseLiteral(Node $valueNode, ?array $variables = null): string
5656
*/
5757
private function isEmail($value): bool
5858
{
59-
return \filter_var($value, \FILTER_VALIDATE_EMAIL) !== false;
59+
return filter_var($value, \FILTER_VALIDATE_EMAIL) !== false;
6060
}
6161
}

examples/01-blog/Blog/Type/Scalar/UrlType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function parseLiteral(Node $valueNode, ?array $variables = null): string
5555
*/
5656
private function isUrl($value): bool
5757
{
58-
return \is_string($value)
59-
&& \filter_var($value, \FILTER_VALIDATE_URL) !== false;
58+
return is_string($value)
59+
&& filter_var($value, \FILTER_VALIDATE_URL) !== false;
6060
}
6161
}

examples/01-blog/Blog/Type/SearchResultType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function __construct()
2626
return TypeRegistry::type(UserType::class);
2727
}
2828

29-
$unknownType = \get_class($value);
29+
$unknownType = get_class($value);
3030
throw new \Exception("Unknown type: {$unknownType}");
3131
},
3232
]);

src/Error/Error.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ public function __construct(
9494
// Compute list of blame nodes.
9595
if ($nodes instanceof \Traversable) {
9696
/** @phpstan-ignore arrayFilter.strict */
97-
$this->nodes = array_filter(\iterator_to_array($nodes));
98-
} elseif (\is_array($nodes)) {
97+
$this->nodes = array_filter(iterator_to_array($nodes));
98+
} elseif (is_array($nodes)) {
9999
$this->nodes = array_filter($nodes);
100100
} elseif ($nodes !== null) {
101101
$this->nodes = [$nodes];
@@ -108,7 +108,7 @@ public function __construct(
108108
$this->path = $path;
109109
$this->unaliasedPath = $unaliasedPath;
110110

111-
if (\is_array($extensions) && $extensions !== []) {
111+
if (is_array($extensions) && $extensions !== []) {
112112
$this->extensions = $extensions;
113113
} elseif ($previous instanceof ProvidesExtensions) {
114114
$this->extensions = $previous->getExtensions();

src/Error/FormattedError.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public static function printError(Error $error): string
6767

6868
return $printedLocations === []
6969
? $error->getMessage()
70-
: \implode("\n\n", \array_merge([$error->getMessage()], $printedLocations)) . "\n";
70+
: implode("\n\n", array_merge([$error->getMessage()], $printedLocations)) . "\n";
7171
}
7272

7373
/**
@@ -84,7 +84,7 @@ private static function highlightSourceAtLocation(Source $source, SourceLocation
8484
$prevLineNum = (string) ($contextLine - 1);
8585
$lineNum = (string) $contextLine;
8686
$nextLineNum = (string) ($contextLine + 1);
87-
$padLen = \strlen($nextLineNum);
87+
$padLen = strlen($nextLineNum);
8888

8989
$lines = Utils::splitLines($source->body);
9090
$lines[0] = self::spaces($source->locationOffset->column - 1) . $lines[0];
@@ -94,10 +94,10 @@ private static function highlightSourceAtLocation(Source $source, SourceLocation
9494
$line >= 2 ? (self::leftPad($padLen, $prevLineNum) . ': ' . $lines[$line - 2]) : null,
9595
self::leftPad($padLen, $lineNum) . ': ' . $lines[$line - 1],
9696
self::spaces(2 + $padLen + $contextColumn - 1) . '^',
97-
$line < \count($lines) ? self::leftPad($padLen, $nextLineNum) . ': ' . $lines[$line] : null,
97+
$line < count($lines) ? self::leftPad($padLen, $nextLineNum) . ': ' . $lines[$line] : null,
9898
];
9999

100-
return \implode("\n", \array_filter($outputLines));
100+
return implode("\n", array_filter($outputLines));
101101
}
102102

103103
private static function getColumnOffset(Source $source, SourceLocation $location): int
@@ -109,12 +109,12 @@ private static function getColumnOffset(Source $source, SourceLocation $location
109109

110110
private static function spaces(int $length): string
111111
{
112-
return \str_repeat(' ', $length);
112+
return str_repeat(' ', $length);
113113
}
114114

115115
private static function leftPad(int $length, string $str): string
116116
{
117-
return self::spaces($length - \mb_strlen($str)) . $str;
117+
return self::spaces($length - mb_strlen($str)) . $str;
118118
}
119119

120120
/**
@@ -140,7 +140,7 @@ public static function createFromException(\Throwable $exception, int $debugFlag
140140
$formattedError = ['message' => $message];
141141

142142
if ($exception instanceof Error) {
143-
$locations = \array_map(
143+
$locations = array_map(
144144
static fn (SourceLocation $loc): array => $loc->toSerializableArray(),
145145
$exception->getLocations()
146146
);
@@ -155,7 +155,7 @@ public static function createFromException(\Throwable $exception, int $debugFlag
155155

156156
if ($exception instanceof ProvidesExtensions) {
157157
$extensions = $exception->getExtensions();
158-
if (\is_array($extensions) && $extensions !== []) {
158+
if (is_array($extensions) && $extensions !== []) {
159159
$formattedError['extensions'] = $extensions;
160160
}
161161
}
@@ -258,10 +258,10 @@ public static function toSafeTrace(\Throwable $error): array
258258
// Remove invariant entries as they don't provide much value:
259259
&& ($trace[0]['class'] . '::' . $trace[0]['function'] === 'GraphQL\Utils\Utils::invariant')
260260
) {
261-
\array_shift($trace);
261+
array_shift($trace);
262262
} elseif (! isset($trace[0]['file'])) {
263263
// Remove root call as it's likely error handler trace:
264-
\array_shift($trace);
264+
array_shift($trace);
265265
}
266266

267267
$formatted = [];
@@ -277,8 +277,8 @@ public static function toSafeTrace(\Throwable $error): array
277277
}
278278

279279
$func = $err['function'];
280-
$args = \array_map([self::class, 'printVar'], $err['args'] ?? []);
281-
$funcStr = $func . '(' . \implode(', ', $args) . ')';
280+
$args = array_map([self::class, 'printVar'], $err['args'] ?? []);
281+
$funcStr = $func . '(' . implode(', ', $args) . ')';
282282

283283
if (isset($err['class'])) {
284284
$safeErr['call'] = $err['class'] . '::' . $funcStr;
@@ -299,39 +299,39 @@ public static function printVar($var): string
299299
return 'GraphQLType: ' . $var->toString();
300300
}
301301

302-
if (\is_object($var)) {
302+
if (is_object($var)) {
303303
// Calling `count` on instances of `PHPUnit\Framework\Test` triggers an unintended side effect - see https://github.com/sebastianbergmann/phpunit/issues/5866#issuecomment-2172429263
304304
$count = ! $var instanceof Test && $var instanceof \Countable
305-
? '(' . \count($var) . ')'
305+
? '(' . count($var) . ')'
306306
: '';
307307

308-
return 'instance of ' . \get_class($var) . $count;
308+
return 'instance of ' . get_class($var) . $count;
309309
}
310310

311-
if (\is_array($var)) {
312-
return 'array(' . \count($var) . ')';
311+
if (is_array($var)) {
312+
return 'array(' . count($var) . ')';
313313
}
314314

315315
if ($var === '') {
316316
return '(empty string)';
317317
}
318318

319-
if (\is_string($var)) {
320-
return "'" . \addcslashes($var, "'") . "'";
319+
if (is_string($var)) {
320+
return "'" . addcslashes($var, "'") . "'";
321321
}
322322

323-
if (\is_bool($var)) {
323+
if (is_bool($var)) {
324324
return $var ? 'true' : 'false';
325325
}
326326

327-
if (\is_scalar($var)) {
327+
if (is_scalar($var)) {
328328
return (string) $var;
329329
}
330330

331331
if ($var === null) {
332332
return 'null';
333333
}
334334

335-
return \gettype($var);
335+
return gettype($var);
336336
}
337337
}

0 commit comments

Comments
 (0)