Skip to content

Commit

Permalink
minor #53352 CS: trailing commas (keradus)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 7.1 branch.

Discussion
----------

CS: trailing commas

| Q             | A
| ------------- | ---
| Branch?       | 7.1
| Bug fix?      | no
| New feature?  | no <!-- please update src/**/CHANGELOG.md files -->
| Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Issues        | CS <!-- prefix each issue number with "Fix #", no need to create an issue if none exists, explain below instead -->
| License       | MIT

kind-of requested in #53230 (comment)
cc `@OskarStark`

The diff may be bigger and tricky. I put each part of standalone change as separated commit, easy to revert if you don't like particular change.

This PR is more demonstration what we can do with Fixer, you decides which way to go

Commits
-------

0cda041 CS: trailing commas
  • Loading branch information
nicolas-grekas committed Jan 3, 2024
2 parents 7269a3d + 0cda041 commit 894ef83
Show file tree
Hide file tree
Showing 51 changed files with 53 additions and 52 deletions.
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'modernize_strpos' => true,
'get_class_to_class_keyword' => true,
'nullable_type_declaration' => true,
'trailing_comma_in_multiline' => ['elements' => ['arrays', 'match', 'parameters']],
])
->setRiskyAllowed(true)
->setFinder(
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Doctrine/IdGenerator/UlidGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
final class UlidGenerator extends AbstractIdGenerator
{
public function __construct(
private readonly ?UlidFactory $factory = null
private readonly ?UlidFactory $factory = null,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(
bool|string|array $ignoreNull = null,
array $groups = null,
$payload = null,
array $options = []
array $options = [],
) {
if (\is_array($fields) && \is_string(key($fields))) {
$options = array_merge($fields, $options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class NotFoundActivationStrategy implements ActivationStrategyInterface
public function __construct(
private RequestStack $requestStack,
array $excludedUrls,
private ActivationStrategyInterface $inner
private ActivationStrategyInterface $inner,
) {
$this->exclude = '{('.implode('|', $excludedUrls).')}i';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(
private readonly ?string $accessDeniedUrl = null,
private readonly array $authenticators = [],
private readonly ?array $switchUser = null,
private readonly ?array $logout = null
private readonly ?array $logout = null,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public function testToolbarConfigUsingInterceptRedirects(
bool $toolbarEnabled,
bool $interceptRedirects,
bool $listenerInjected,
bool $listenerEnabled
bool $listenerEnabled,
) {
$extension = new WebProfilerExtension();
$extension->load(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct(
public readonly string $packageName,
public readonly string $dependencyPackageName,
public readonly string $requiredVersionConstraint,
public readonly ?string $installedVersion
public readonly ?string $installedVersion,
) {
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Completion/Suggestion.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Suggestion implements \Stringable
{
public function __construct(
private readonly string $value,
private readonly string $description = ''
private readonly string $description = '',
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Console/Helper/OutputWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ final class OutputWrapper
private const URL_PATTERN = 'https?://\S+';

public function __construct(
private bool $allowCutUrls = false
private bool $allowCutUrls = false,
) {
}

Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Console/Output/AnsiColorMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function convertFromHexToAnsiColorCode(string $hexColor): string
return match ($this) {
self::Ansi4 => (string) $this->convertFromRGB($r, $g, $b),
self::Ansi8 => '8;5;'.((string) $this->convertFromRGB($r, $g, $b)),
self::Ansi24 => sprintf('8;2;%d;%d;%d', $r, $g, $b)
self::Ansi24 => sprintf('8;2;%d;%d;%d', $r, $g, $b),
};
}

Expand All @@ -72,7 +72,7 @@ private function convertFromRGB(int $r, int $g, int $b): int
return match ($this) {
self::Ansi4 => $this->degradeHexColorToAnsi4($r, $g, $b),
self::Ansi8 => $this->degradeHexColorToAnsi8($r, $g, $b),
default => throw new InvalidArgumentException("RGB cannot be converted to {$this->name}.")
default => throw new InvalidArgumentException("RGB cannot be converted to {$this->name}."),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function resolve(Request $request, ArgumentMetadata $argument): array
'int' => \FILTER_VALIDATE_INT,
'string' => \FILTER_DEFAULT,
default => throw new \LogicException(sprintf('#[MapQueryParameter] cannot be used on controller argument "%s$%s" of type "%s"; one of array, string, int, float, bool or \BackedEnum should be used.', $argument->isVariadic() ? '...' : '', $argument->getName(), $type ?? 'mixed')),
}
},
};

$value = filter_var($value, $attribute->filter ?? $filter, $options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function onKernelControllerArguments(ControllerArgumentsEvent $event): vo
$payload = match (true) {
$argument->metadata->hasDefaultValue() => $argument->metadata->getDefaultValue(),
$argument->metadata->isNullable() => null,
default => throw HttpException::fromStatusCode($validationFailedCode)
default => throw HttpException::fromStatusCode($validationFailedCode),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,13 @@ public function controllerDisablingResolver(#[ValueResolver(RequestAttributeValu
public function controllerTargetingManyResolvers(
#[ValueResolver(RequestAttributeValueResolver::class)]
#[ValueResolver(DefaultValueResolver::class)]
int $foo
int $foo,
) {
}

public function controllerTargetingUnknownResolver(
#[ValueResolver('foo')]
int $bar
int $bar,
) {
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,7 @@ public function fooAction(
string $apiKey,
#[Target('image.storage')]
ControllerDummy $service1,
ControllerDummy $service2
ControllerDummy $service2,
) {
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function create(Dsn $dsn): TransportInterface

'mailersend', 'mailersend+smtp' => new MailerSendSmtpTransport($this->getUser($dsn), $this->getPassword($dsn), $this->dispatcher, $this->logger),

default => throw new UnsupportedSchemeException($dsn, 'mailersend', $this->getSupportedSchemes())
default => throw new UnsupportedSchemeException($dsn, 'mailersend', $this->getSupportedSchemes()),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ final class BlueskyTransportFactory extends AbstractTransportFactory
public function __construct(
EventDispatcherInterface $dispatcher = null,
HttpClientInterface $client = null,
private ?LoggerInterface $logger = null
private ?LoggerInterface $logger = null,
) {
parent::__construct($dispatcher, $client);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function fromNotification(Notification $notification): self
Notification::IMPORTANCE_URGENT => 2,
Notification::IMPORTANCE_HIGH => 1,
Notification::IMPORTANCE_MEDIUM => 0,
Notification::IMPORTANCE_LOW => -1
Notification::IMPORTANCE_LOW => -1,
};
$options->priority($priority);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BrowserChannelTest extends TestCase
public function testImportanceLevelIsReflectedInFlashMessageType(
FlashMessageImportanceMapperInterface $mapper,
string $importance,
string $expectedFlashMessageType
string $expectedFlashMessageType,
) {
$session = $this->createMock(Session::class);
$session->method('getFlashBag')->willReturn(new FlashBag());
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Routing/Attribute/Route.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
string $format = null,
bool $utf8 = null,
bool $stateless = null,
private ?string $env = null
private ?string $env = null,
) {
if (\is_array($path)) {
$this->localizedPaths = $path;
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Security/Core/User/OidcUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function __construct(
private ?\DateTimeInterface $updatedAt = null,

// Additional Claims (https://openid.net/specs/openid-connect-core-1_0.html#AdditionalClaims)
...$additionalClaims
...$additionalClaims,
) {
if (null === $sub || '' === $sub) {
throw new \InvalidArgumentException('The "sub" claim cannot be empty.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
final class FormEncodedBodyExtractor implements AccessTokenExtractorInterface
{
public function __construct(
private readonly string $parameter = 'access_token'
private readonly string $parameter = 'access_token',
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class HeaderAccessTokenExtractor implements AccessTokenExtractorInterface

public function __construct(
private readonly string $headerParameter = 'Authorization',
private readonly string $tokenType = 'Bearer'
private readonly string $tokenType = 'Bearer',
) {
$this->regex = sprintf(
'/^%s([a-zA-Z0-9\-_\+~\/\.]+)$/',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function __construct(
private array $issuers,
private string $claim = 'sub',
private ?LoggerInterface $logger = null,
private ClockInterface $clock = new Clock()
private ClockInterface $clock = new Clock(),
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class OidcUserInfoTokenHandler implements AccessTokenHandlerInterface
public function __construct(
private HttpClientInterface $client,
private ?LoggerInterface $logger = null,
private string $claim = 'sub'
private string $claim = 'sub',
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Serializer/Encoder/ChainDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class ChainDecoder implements ContextAwareDecoderInterface
* @param array<DecoderInterface> $decoders
*/
public function __construct(
private readonly array $decoders = []
private readonly array $decoders = [],
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Serializer/Encoder/ChainEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ChainEncoder implements ContextAwareEncoderInterface
* @param array<EncoderInterface> $encoders
*/
public function __construct(
private readonly array $encoders = []
private readonly array $encoders = [],
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(
private LoggerInterface $logger,
private string $defaultLocale,
private LoaderInterface $loader,
private XliffFileDumper $xliffFileDumper
private XliffFileDumper $xliffFileDumper,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
final class ConstraintVisitor extends AbstractVisitor implements NodeVisitor
{
public function __construct(
private readonly array $constraintClassNames = []
private readonly array $constraintClassNames = [],
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Uid/Factory/TimeBasedUuidFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TimeBasedUuidFactory
*/
public function __construct(
private string $class,
private ?Uuid $node = null
private ?Uuid $node = null,
) {
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Cidr.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct(
int $netmaskMax = null,
string $message = null,
array $groups = null,
$payload = null
$payload = null,
) {
$this->version = $version ?? $options['version'] ?? $this->version;

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Count.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function __construct(
string $divisibleByMessage = null,
array $groups = null,
mixed $payload = null,
array $options = []
array $options = [],
) {
if (\is_array($exactly)) {
$options = array_merge($exactly, $options);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(
string $message = null,
bool $alpha3 = null,
array $groups = null,
mixed $payload = null
mixed $payload = null,
) {
if (!class_exists(Countries::class)) {
throw new LogicException('The Intl component is required to use the Country constraint. Try running "composer require symfony/intl".');
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function __construct(
string $mode = null,
callable $normalizer = null,
array $groups = null,
mixed $payload = null
mixed $payload = null,
) {
if (\is_array($options) && \array_key_exists('mode', $options) && !\in_array($options['mode'], self::VALIDATION_MODES, true)) {
throw new InvalidArgumentException('The "mode" parameter value is not valid.');
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Hostname.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(
string $message = null,
bool $requireTld = null,
array $groups = null,
mixed $payload = null
mixed $payload = null,
) {
parent::__construct($options, $groups, $payload);

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function __construct(
string $allowPortraitMessage = null,
string $corruptedMessage = null,
array $groups = null,
mixed $payload = null
mixed $payload = null,
) {
parent::__construct(
$options,
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Ip.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function __construct(
string $message = null,
callable $normalizer = null,
array $groups = null,
mixed $payload = null
mixed $payload = null,
) {
parent::__construct($options, $groups, $payload);

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Isbn.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function __construct(
string $bothIsbnMessage = null,
array $groups = null,
mixed $payload = null,
array $options = []
array $options = [],
) {
if (\is_array($type)) {
$options = array_merge($type, $options);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Issn.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function __construct(
bool $caseSensitive = null,
bool $requireHyphen = null,
array $groups = null,
mixed $payload = null
mixed $payload = null,
) {
parent::__construct($options, $groups, $payload);

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(
string $message = null,
bool $alpha3 = null,
array $groups = null,
mixed $payload = null
mixed $payload = null,
) {
if (!class_exists(Languages::class)) {
throw new LogicException('The Intl component is required to use the Language constraint. Try running "composer require symfony/intl".');
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Length.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function __construct(
string $charsetMessage = null,
array $groups = null,
mixed $payload = null,
array $options = []
array $options = [],
) {
if (\is_array($exactly)) {
$options = array_merge($exactly, $options);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function __construct(
string $message = null,
bool $canonicalize = null,
array $groups = null,
mixed $payload = null
mixed $payload = null,
) {
if (!class_exists(Locales::class)) {
throw new LogicException('The Intl component is required to use the Locale constraint. Try running "composer require symfony/intl".');
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraints/Luhn.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function __construct(
array $options = null,
string $message = null,
array $groups = null,
mixed $payload = null
mixed $payload = null,
) {
parent::__construct($options, $groups, $payload);

Expand Down

0 comments on commit 894ef83

Please sign in to comment.