Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 46a6695

Browse files
CS fixes
1 parent 0ca5051 commit 46a6695

File tree

32 files changed

+82
-99
lines changed

32 files changed

+82
-99
lines changed

src/Symfony/Bridge/Twig/Command/DebugCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ private function getPrettyMetadata(string $type, mixed $entity, bool $decorated)
384384

385385
if ('globals' === $type) {
386386
if (\is_object($meta)) {
387-
return ' = object('.\get_class($meta).')';
387+
return ' = object('.$meta::class.')';
388388
}
389389

390390
$description = substr(@json_encode($meta), 0, 50);

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,14 +2806,15 @@ private function resolveTrustedHeaders(array $headers): int
28062806
$trustedHeaders = 0;
28072807

28082808
foreach ($headers as $h) {
2809-
switch ($h) {
2810-
case 'forwarded': $trustedHeaders |= Request::HEADER_FORWARDED; break;
2811-
case 'x-forwarded-for': $trustedHeaders |= Request::HEADER_X_FORWARDED_FOR; break;
2812-
case 'x-forwarded-host': $trustedHeaders |= Request::HEADER_X_FORWARDED_HOST; break;
2813-
case 'x-forwarded-proto': $trustedHeaders |= Request::HEADER_X_FORWARDED_PROTO; break;
2814-
case 'x-forwarded-port': $trustedHeaders |= Request::HEADER_X_FORWARDED_PORT; break;
2815-
case 'x-forwarded-prefix': $trustedHeaders |= Request::HEADER_X_FORWARDED_PREFIX; break;
2816-
}
2809+
$trustedHeaders |= match ($h) {
2810+
'forwarded' => Request::HEADER_FORWARDED,
2811+
'x-forwarded-for' => Request::HEADER_X_FORWARDED_FOR,
2812+
'x-forwarded-host' => Request::HEADER_X_FORWARDED_HOST,
2813+
'x-forwarded-proto' => Request::HEADER_X_FORWARDED_PROTO,
2814+
'x-forwarded-port' => Request::HEADER_X_FORWARDED_PORT,
2815+
'x-forwarded-prefix' => Request::HEADER_X_FORWARDED_PREFIX,
2816+
default => 0,
2817+
};
28172818
}
28182819

28192820
return $trustedHeaders;

src/Symfony/Component/Cache/DataCollector/CacheDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function collect(Request $request, Response $response, \Throwable $except
4242
$this->data = ['instances' => $empty, 'total' => $empty];
4343
foreach ($this->instances as $name => $instance) {
4444
$this->data['instances']['calls'][$name] = $instance->getCalls();
45-
$this->data['instances']['adapters'][$name] = \get_debug_type($instance->getPool());
45+
$this->data['instances']['adapters'][$name] = get_debug_type($instance->getPool());
4646
}
4747

4848
$this->data['instances']['statistics'] = $this->calculateStatistics();

src/Symfony/Component/Cache/Traits/RedisTrait.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,12 @@ public static function createConnection(string $dsn, array $options = []): \Redi
288288
if (0 < $params['tcp_keepalive'] && \defined('Redis::OPT_TCP_KEEPALIVE')) {
289289
$redis->setOption(\Redis::OPT_TCP_KEEPALIVE, $params['tcp_keepalive']);
290290
}
291-
switch ($params['failover']) {
292-
case 'error': $redis->setOption(\RedisCluster::OPT_SLAVE_FAILOVER, \RedisCluster::FAILOVER_ERROR); break;
293-
case 'distribute': $redis->setOption(\RedisCluster::OPT_SLAVE_FAILOVER, \RedisCluster::FAILOVER_DISTRIBUTE); break;
294-
case 'slaves': $redis->setOption(\RedisCluster::OPT_SLAVE_FAILOVER, \RedisCluster::FAILOVER_DISTRIBUTE_SLAVES); break;
295-
}
291+
$redis->setOption(\RedisCluster::OPT_SLAVE_FAILOVER, match ($params['failover']) {
292+
'error' => \RedisCluster::FAILOVER_ERROR,
293+
'distribute' => \RedisCluster::FAILOVER_DISTRIBUTE,
294+
'slaves' => \RedisCluster::FAILOVER_DISTRIBUTE_SLAVES,
295+
'none' => \RedisCluster::FAILOVER_NONE,
296+
});
296297

297298
return $redis;
298299
};

src/Symfony/Component/Console/Command/Command.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,9 +439,9 @@ public function getNativeDefinition(): InputDefinition
439439
* @param $default The default value (for InputArgument::OPTIONAL mode only)
440440
* @param array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
441441
*
442-
* @throws InvalidArgumentException When argument mode is not valid
443-
*
444442
* @return $this
443+
*
444+
* @throws InvalidArgumentException When argument mode is not valid
445445
*/
446446
public function addArgument(string $name, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = null */): static
447447
{
@@ -463,9 +463,9 @@ public function addArgument(string $name, int $mode = null, string $description
463463
* @param $default The default value (must be null for InputOption::VALUE_NONE)
464464
* @param array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
465465
*
466-
* @throws InvalidArgumentException If option mode is invalid or incompatible
467-
*
468466
* @return $this
467+
*
468+
* @throws InvalidArgumentException If option mode is invalid or incompatible
469469
*/
470470
public function addOption(string $name, string|array $shortcut = null, int $mode = null, string $description = '', mixed $default = null /* array|\Closure $suggestedValues = [] */): static
471471
{

src/Symfony/Component/Console/Tests/ApplicationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2086,7 +2086,7 @@ public function __construct(bool $emitsSignal = true)
20862086
protected function execute(InputInterface $input, OutputInterface $output): int
20872087
{
20882088
if ($this->emitsSignal) {
2089-
posix_kill(posix_getpid(), SIGUSR1);
2089+
posix_kill(posix_getpid(), \SIGUSR1);
20902090
}
20912091

20922092
for ($i = 0; $i < $this->loop; ++$i) {

src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ public function addObjectResource(object|string $object): static
291291
{
292292
if ($this->trackResources) {
293293
if (\is_object($object)) {
294-
$object = \get_class($object);
294+
$object = $object::class;
295295
}
296296
if (!isset($this->classReflectors[$object])) {
297297
$this->classReflectors[$object] = new \ReflectionClass($object);
@@ -1037,7 +1037,7 @@ private function createService(Definition $definition, array &$inlineServices, b
10371037
if (null !== $factory) {
10381038
$service = $factory(...$arguments);
10391039

1040-
if (\is_object($tryProxy) && \get_class($service) !== $parameterBag->resolveValue($definition->getClass())) {
1040+
if (\is_object($tryProxy) && $service::class !== $parameterBag->resolveValue($definition->getClass())) {
10411041
throw new LogicException(sprintf('Lazy service of type "%s" cannot be hydrated because its factory returned an unexpected instance of "%s". Try adding the "proxy" tag to the corresponding service definition with attribute "interface" set to "%1$s".', $definition->getClass(), get_debug_type($service)));
10421042
}
10431043

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1665,7 +1665,7 @@ private function exportParameters(array $parameters, string $path = '', int $ind
16651665
throw new InvalidArgumentException(sprintf('You cannot dump a container with parameters that contain expressions. Expression "%s" found in "%s".', $value, $path.'/'.$key));
16661666
} elseif ($value instanceof \UnitEnum) {
16671667
$hasEnum = true;
1668-
$value = sprintf('\%s::%s', \get_class($value), $value->name);
1668+
$value = sprintf('\%s::%s', $value::class, $value->name);
16691669
} else {
16701670
$value = $this->export($value);
16711671
}
@@ -1917,7 +1917,7 @@ private function dumpValue(mixed $value, bool $interpolate = true): string
19171917
return $code;
19181918
}
19191919
} elseif ($value instanceof \UnitEnum) {
1920-
return sprintf('\%s::%s', \get_class($value), $value->name);
1920+
return sprintf('\%s::%s', $value::class, $value->name);
19211921
} elseif ($value instanceof AbstractArgument) {
19221922
throw new RuntimeException($value->getTextWithContext());
19231923
} elseif (\is_object($value) || \is_resource($value)) {

src/Symfony/Component/DependencyInjection/LazyProxy/Instantiator/InstantiatorInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ interface InstantiatorInterface
2525
/**
2626
* Instantiates a proxy object.
2727
*
28-
* @param string $id Identifier of the requested service
28+
* @param string $id Identifier of the requested service
2929
* @param callable(object=) $realInstantiator A callback that is capable of producing the real service instance
3030
*
3131
* @return object

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function hasListeners(string $eventName = null): bool
108108

109109
public function dispatch(object $event, string $eventName = null): object
110110
{
111-
$eventName ??= \get_class($event);
111+
$eventName ??= $event::class;
112112

113113
if (null === $this->callStack) {
114114
$this->callStack = new \SplObjectStorage();

src/Symfony/Component/EventDispatcher/Debug/WrappedListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function __construct(callable|array $listener, ?string $name, Stopwatch $
6161
} else {
6262
$this->name = get_debug_type($listener);
6363
$this->pretty = $this->name.'::__invoke';
64-
$this->callableRef = \get_class($listener).'::__invoke';
64+
$this->callableRef = $listener::class.'::__invoke';
6565
}
6666

6767
if (null !== $name) {

src/Symfony/Component/EventDispatcher/EventDispatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function __construct()
4444

4545
public function dispatch(object $event, string $eventName = null): object
4646
{
47-
$eventName ??= \get_class($event);
47+
$eventName ??= $event::class;
4848

4949
if (isset($this->optimized)) {
5050
$listeners = $this->optimized[$eventName] ?? (empty($this->listeners[$eventName]) ? [] : $this->optimizeListeners($eventName));

src/Symfony/Component/Form/Tests/Extension/Core/Type/EnumTypeTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,13 @@ public function provideSingleSubmitData(): iterable
9191

9292
yield 'string backed' => [
9393
Suit::class,
94-
(Suit::Spades)->value,
94+
Suit::Spades->value,
9595
Suit::Spades,
9696
];
9797

9898
yield 'integer backed' => [
9999
Number::class,
100-
(string) (Number::Two)->value,
100+
(string) Number::Two->value,
101101
Number::Two,
102102
];
103103
}
@@ -131,7 +131,7 @@ public function testSubmitNull($expected = null, $norm = null, $view = null)
131131

132132
public function testSubmitNullUsesDefaultEmptyData($emptyData = 'empty', $expectedData = null)
133133
{
134-
$emptyData = (Suit::Hearts)->value;
134+
$emptyData = Suit::Hearts->value;
135135

136136
$form = $this->factory->create($this->getTestedType(), null, [
137137
'class' => Suit::class,
@@ -151,7 +151,7 @@ public function testSubmitMultipleChoiceWithEmptyData()
151151
'multiple' => true,
152152
'expanded' => false,
153153
'class' => Suit::class,
154-
'empty_data' => [(Suit::Diamonds)->value],
154+
'empty_data' => [Suit::Diamonds->value],
155155
]);
156156

157157
$form->submit(null);
@@ -165,7 +165,7 @@ public function testSubmitSingleChoiceExpandedWithEmptyData()
165165
'multiple' => false,
166166
'expanded' => true,
167167
'class' => Suit::class,
168-
'empty_data' => (Suit::Hearts)->value,
168+
'empty_data' => Suit::Hearts->value,
169169
]);
170170

171171
$form->submit(null);
@@ -179,7 +179,7 @@ public function testSubmitMultipleChoiceExpandedWithEmptyData()
179179
'multiple' => true,
180180
'expanded' => true,
181181
'class' => Suit::class,
182-
'empty_data' => [(Suit::Spades)->value],
182+
'empty_data' => [Suit::Spades->value],
183183
]);
184184

185185
$form->submit(null);
@@ -233,13 +233,13 @@ public function provideMultiSubmitData(): iterable
233233

234234
yield 'string backed' => [
235235
Suit::class,
236-
[(Suit::Hearts)->value, (Suit::Spades)->value],
236+
[Suit::Hearts->value, Suit::Spades->value],
237237
[Suit::Hearts, Suit::Spades],
238238
];
239239

240240
yield 'integer backed' => [
241241
Number::class,
242-
[(string) (Number::Two)->value, (string) (Number::Three)->value],
242+
[(string) Number::Two->value, (string) Number::Three->value],
243243
[Number::Two, Number::Three],
244244
];
245245
}

src/Symfony/Component/HttpClient/AmpHttpClient.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ public function request(string $method, string $url, array $options = []): Respo
111111
$request = new Request(implode('', $url), $method);
112112

113113
if ($options['http_version']) {
114-
switch ((float) $options['http_version']) {
115-
case 1.0: $request->setProtocolVersions(['1.0']); break;
116-
case 1.1: $request->setProtocolVersions(['1.1', '1.0']); break;
117-
default: $request->setProtocolVersions(['2', '1.1', '1.0']); break;
118-
}
114+
$request->setProtocolVersions(match ((float) $options['http_version']) {
115+
1.0 => ['1.0'],
116+
1.1 => $request->setProtocolVersions(['1.1', '1.0']),
117+
default => ['2', '1.1', '1.0'],
118+
});
119119
}
120120

121121
foreach ($options['headers'] as $v) {

src/Symfony/Component/HttpFoundation/StreamedResponse.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ public function sendContent(): static
9595
}
9696

9797
/**
98-
* @throws \LogicException when the content is not null
99-
*
10098
* @return $this
99+
*
100+
* @throws \LogicException when the content is not null
101101
*/
102102
public function setContent(?string $content): static
103103
{

src/Symfony/Component/HttpKernel/Log/Logger.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,13 @@ public function __construct(string $minLevel = null, $output = null, callable $f
4848
$minLevel = null === $output || 'php://stdout' === $output || 'php://stderr' === $output ? LogLevel::ERROR : LogLevel::WARNING;
4949

5050
if (isset($_ENV['SHELL_VERBOSITY']) || isset($_SERVER['SHELL_VERBOSITY'])) {
51-
switch ((int) ($_ENV['SHELL_VERBOSITY'] ?? $_SERVER['SHELL_VERBOSITY'])) {
52-
case -1: $minLevel = LogLevel::ERROR; break;
53-
case 1: $minLevel = LogLevel::NOTICE; break;
54-
case 2: $minLevel = LogLevel::INFO; break;
55-
case 3: $minLevel = LogLevel::DEBUG; break;
56-
}
51+
$minLevel = match ((int) ($_ENV['SHELL_VERBOSITY'] ?? $_SERVER['SHELL_VERBOSITY'])) {
52+
-1 => LogLevel::ERROR,
53+
1 => LogLevel::NOTICE,
54+
2 => LogLevel::INFO,
55+
3 => LogLevel::DEBUG,
56+
default => $minLevel,
57+
};
5758
}
5859
}
5960

@@ -96,7 +97,7 @@ private function format(string $level, string $message, array $context, bool $pr
9697
} elseif ($val instanceof \DateTimeInterface) {
9798
$replacements["{{$key}}"] = $val->format(\DateTime::RFC3339);
9899
} elseif (\is_object($val)) {
99-
$replacements["{{$key}}"] = '[object '.\get_class($val).']';
100+
$replacements["{{$key}}"] = '[object '.$val::class.']';
100101
} else {
101102
$replacements["{{$key}}"] = '['.\gettype($val).']';
102103
}

src/Symfony/Component/Intl/Resources/emoji/build.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public static function saveRules(iterable $rulesByLocale): void
173173
file_put_contents(self::TARGET_DIR."/emoji-$locale.php", "<?php\n\nreturn ".VarExporter::export($rules).";\n");
174174

175175
foreach ($rules as $k => $v) {
176-
for ($i = 0; \ord($k[$i]) < 128 || "\xC2" === $k[$i]; ++$i) {
176+
for ($i = 0; ord($k[$i]) < 128 || "\xC2" === $k[$i]; ++$i) {
177177
}
178178
for ($j = $i; isset($k[$j]) && !isset($firstChars[$k[$j]]); ++$j) {
179179
}
@@ -189,7 +189,7 @@ public static function saveRules(iterable $rulesByLocale): void
189189

190190
$quickCheck = '"'.str_replace('%', '\\x', rawurlencode(implode('', $firstChars))).'"';
191191

192-
$file = \dirname(__DIR__, 2).'/Transliterator/EmojiTransliterator.php';
192+
$file = dirname(__DIR__, 2).'/Transliterator/EmojiTransliterator.php';
193193
file_put_contents($file, preg_replace('/QUICK_CHECK = .*;/m', "QUICK_CHECK = {$quickCheck};", file_get_contents($file)));
194194
}
195195

src/Symfony/Component/Mailer/EventListener/MessageListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1616
use Symfony\Component\Mailer\Event\MessageEvent;
1717
use Symfony\Component\Mailer\Exception\InvalidArgumentException;
18-
use Symfony\Component\Mailer\Exception\RuntimeException;
1918
use Symfony\Component\Mailer\Exception\LogicException;
19+
use Symfony\Component\Mailer\Exception\RuntimeException;
2020
use Symfony\Component\Mime\BodyRendererInterface;
2121
use Symfony\Component\Mime\Header\Headers;
2222
use Symfony\Component\Mime\Header\MailboxListHeader;

src/Symfony/Component/Messenger/Handler/HandlerDescriptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function __construct(callable $handler, array $options = [])
4343
$this->batchHandler = $handler;
4444
}
4545

46-
$this->name = \get_class($handler).'::'.$r->name;
46+
$this->name = $handler::class.'::'.$r->name;
4747
}
4848
}
4949

src/Symfony/Component/Messenger/Transport/Receiver/ReceiverInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ interface ReceiverInterface
3939
* be retried again (e.g. if there's a queue, it should be removed)
4040
* and a MessageDecodingFailedException should be thrown.
4141
*
42-
* @throws TransportException If there is an issue communicating with the transport
43-
*
4442
* @return Envelope[]
43+
*
44+
* @throws TransportException If there is an issue communicating with the transport
4545
*/
4646
public function get(): iterable;
4747

src/Symfony/Component/Mime/Header/MailboxListHeader.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public function setBody(mixed $body)
4444
}
4545

4646
/**
47-
* @throws RfcComplianceException
48-
*
4947
* @return Address[]
48+
*
49+
* @throws RfcComplianceException
5050
*/
5151
public function getBody(): array
5252
{
@@ -99,9 +99,9 @@ public function getAddresses(): array
9999
/**
100100
* Gets the full mailbox list of this Header as an array of valid RFC 2822 strings.
101101
*
102-
* @throws RfcComplianceException
103-
*
104102
* @return string[]
103+
*
104+
* @throws RfcComplianceException
105105
*/
106106
public function getAddressStrings(): array
107107
{

src/Symfony/Component/Runtime/GenericRuntime.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function getRunner(?object $application): RunnerInterface
122122
}
123123

124124
if (!$application instanceof \Closure) {
125-
if ($runtime = $this->resolveRuntime(\get_class($application))) {
125+
if ($runtime = $this->resolveRuntime($application::class)) {
126126
return $runtime->getRunner($application);
127127
}
128128

src/Symfony/Component/Security/Core/Authorization/AuthorizationChecker.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use Symfony\Component\Security\Core\Authentication\Token\NullToken;
1515
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
16-
use Symfony\Component\Security\Core\Exception\AuthenticationCredentialsNotFoundException;
1716

1817
/**
1918
* AuthorizationChecker is the main authorization point of the Security component.

0 commit comments

Comments
 (0)