Skip to content

Remove useless code #57868

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

Merged
merged 1 commit into from
Aug 12, 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
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ private function createFirewalls(array $config, ContainerBuilder $container): vo

$configId = 'security.firewall.map.config.'.$name;

[$matcher, $listeners, $exceptionListener, $logoutListener, $firewallAuthenticators] = $this->createFirewall($container, $name, $firewall, $authenticationProviders, $providerIds, $configId);
[$matcher, $listeners, $exceptionListener, $logoutListener, $firewallAuthenticators] = $this->createFirewall($container, $name, $firewall, $providerIds, $configId);

if (!$firewallAuthenticators) {
$authenticators[$name] = null;
Expand Down Expand Up @@ -348,7 +348,7 @@ private function createFirewalls(array $config, ContainerBuilder $container): vo
}
}

private function createFirewall(ContainerBuilder $container, string $id, array $firewall, array &$authenticationProviders, array $providerIds, string $configId): array
private function createFirewall(ContainerBuilder $container, string $id, array $firewall, array $providerIds, string $configId): array
{
$config = $container->setDefinition($configId, new ChildDefinition('security.firewall.config'));
$config->replaceArgument(0, $id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public function buildForm(FormBuilderInterface $builder, array $options): void

if ('single_text' === $options['widget']) {
$builder->addEventListener(FormEvents::PRE_SUBMIT, static function (FormEvent $e) use ($options) {
/** @var PreSubmitEvent $event */
$data = $e->getData();
if ($data && preg_match('/^(?P<hours>\d{2}):(?P<minutes>\d{2})(?::(?P<seconds>\d{2})(?:\.\d+)?)?$/', $data, $matches)) {
if ($options['with_seconds']) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ protected function generateDataForRoot(BundleEntryReaderInterface $reader, strin

protected function generateDataForMeta(BundleEntryReaderInterface $reader, string $tempDir): ?array
{
$rootBundle = $reader->read($tempDir, 'root');

$this->zoneIds = array_unique($this->zoneIds);

sort($this->zoneIds);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Lock/Store/PostgreSqlStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function exists(Key $key): bool
$stmt = $this->getConnection()->prepare($sql);

$stmt->bindValue(':key', $this->getHashedKey($key));
$result = $stmt->execute();
$stmt->execute();

if ($stmt->fetchColumn() > 0) {
// connection is locked, check for lock in internal store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function doSendApi(SentMessage $sentMessage, Email $email, Envelope $e

$response = $this->client->request('POST', 'https://'.$endpoint, [
'body' => json_encode($payload),
'headers' => $this->getSignedHeaders($payload, $email),
'headers' => $this->getSignedHeaders($payload),
]);

try {
Expand Down Expand Up @@ -189,7 +189,7 @@ private function generateAuthenticationSignature(string $content): string
/**
* Get authenticated headers for signed request,.
*/
private function getSignedHeaders(array $payload, Email $message): array
private function getSignedHeaders(array $payload): array
{
// HTTP Method verb (uppercase)
$verb = 'POST';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,6 @@ public function testCustomHeader()
*/
public function testPrefixHeaderWithH()
{
$json = json_encode(['foo' => 'bar']);
$deliveryTime = (new \DateTimeImmutable('2020-03-20 13:01:00'))->format(\DateTimeInterface::RFC2822);

$email = new Email();
$email->getHeaders()->addTextHeader('h:bar', 'bar-value');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ private function createSqsEnvelope()

private function createSerializer(): Serializer
{
$serializer = new Serializer(
return new Serializer(
new SerializerComponent\Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()])
);

return $serializer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static function fromDsn(#[\SensitiveParameter] string $dsn, array $option
}

$parsedPath = explode('/', ltrim($params['path'] ?? '/', '/'));
if (\count($parsedPath) > 0 && ($queueName = end($parsedPath))) {
if ($queueName = end($parsedPath)) {
$configuration['queue_name'] = $queueName;
}
$configuration['account'] = 2 === \count($parsedPath) ? $parsedPath[0] : $options['account'] ?? self::DEFAULT_OPTIONS['account'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public function countMessagesInQueues(): int
private function publishWithDelay(string $body, array $headers, int $delay, ?AmqpStamp $amqpStamp = null): void
{
$routingKey = $this->getRoutingKeyForMessage($amqpStamp);
$isRetryAttempt = $amqpStamp ? $amqpStamp->isRetryAttempt() : false;
$isRetryAttempt = $amqpStamp && $amqpStamp->isRetryAttempt();

$this->setupDelay($delay, $routingKey, $isRetryAttempt);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,8 @@ private function createBeanstalkdEnvelope(): array

private function createSerializer(): Serializer
{
$serializer = new Serializer(
return new Serializer(
new SerializerComponent\Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()])
);

return $serializer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -314,10 +314,8 @@ private function createDoctrineEnvelope(): array

private function createSerializer(): Serializer
{
$serializer = new Serializer(
return new Serializer(
new SerializerComponent\Serializer([new ObjectNormalizer()], ['json' => new JsonEncoder()])
);

return $serializer;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public function get(): ?array
if (method_exists(QueryBuilder::class, 'forUpdate')) {
$sql = $this->addLockMode($query, $sql);
} else {
if (preg_match('/FROM (.+) WHERE/', (string) $sql, $matches)) {
if (preg_match('/FROM (.+) WHERE/', $sql, $matches)) {
$fromClause = $matches[1];
$sql = str_replace(
\sprintf('FROM %s WHERE', $fromClause),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ final class EmailAttachmentCount extends Constraint
{
public function __construct(
private int $expectedValue,
private ?string $transport = null,
) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ final class FakeSmsLoggerTransportTest extends TransportTestCase
{
public static function createTransport(?HttpClientInterface $client = null, ?LoggerInterface $logger = null): FakeSmsLoggerTransport
{
$transport = (new FakeSmsLoggerTransport($logger ?? new NullLogger(), $client ?? new MockHttpClient()));

return $transport;
return new FakeSmsLoggerTransport($logger ?? new NullLogger(), $client ?? new MockHttpClient());
}

public static function toStringProvider(): iterable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Symfony\Component\Notifier\Bridge\PagerDuty;

use Symfony\Component\Clock\Clock;
use Symfony\Component\Clock\ClockInterface;
use Symfony\Component\Notifier\Exception\InvalidArgumentException;
use Symfony\Component\Notifier\Message\MessageOptionsInterface;

Expand All @@ -21,9 +19,7 @@
*/
final class PagerDutyOptions implements MessageOptionsInterface
{
private ClockInterface $clock;

public function __construct(string $routingKey, string $eventAction, string $severity, private array $options = [], ?ClockInterface $clock = null)
public function __construct(string $routingKey, string $eventAction, string $severity, private array $options = [])
{
if (!\in_array($eventAction, ['trigger', 'acknowledge', 'resolve'], true)) {
throw new InvalidArgumentException('Invalid "event_action" option given.');
Expand Down Expand Up @@ -56,8 +52,6 @@ public function __construct(string $routingKey, string $eventAction, string $sev
if (null === $dedupKey && \in_array($eventAction, ['acknowledge', 'resolve'], true)) {
throw new InvalidArgumentException('Option "dedup_key" must be set for event actions: "acknowledge" & "resolve".');
}

$this->clock = $clock ?? Clock::get();
}

public function toArray(): array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
],
"require": {
"php": ">=8.2",
"symfony/clock": "^6.4|^7.0",
"symfony/http-client": "^6.4|^7.0",
"symfony/notifier": "^6.4|^7.0"
},
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Routing/RouteCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private static function compilePattern(Route $route, string $pattern, bool $isHo

$regexp = $route->getRequirement($varName);
if (null === $regexp) {
$followingPattern = (string) substr($pattern, $pos);
$followingPattern = substr($pattern, $pos);
// Find the next static character after the variable that functions as a separator. By default, this separator and '/'
// are disallowed for the variable. This default requirement makes sure that optional variables can be matched at all
// and that the generating-matching-combination of URLs unambiguous, i.e. the params used for generating the URL are
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Security/Core/User/InMemoryUser.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ public function isEqualTo(UserInterface $user): bool
return false;
}

$currentRoles = array_map('strval', (array) $this->getRoles());
$newRoles = array_map('strval', (array) $user->getRoles());
$currentRoles = array_map('strval', $this->getRoles());
$newRoles = array_map('strval', $user->getRoles());
$rolesChanged = \count($currentRoles) !== \count($newRoles) || \count($currentRoles) !== \count(array_intersect($currentRoles, $newRoles));
if ($rolesChanged) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private static function hasUserChanged(UserInterface $originalUser, TokenInterfa
}
}

$userRoles = array_map('strval', (array) $refreshedUser->getRoles());
$userRoles = array_map('strval', $refreshedUser->getRoles());

if (
\count($userRoles) !== \count($refreshedToken->getRoleNames())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,6 @@ private function startAuthentication(Request $request, AuthenticationException $
$this->throwUnauthorizedException($authException);
}

if (!$response instanceof Response) {
$given = get_debug_type($response);

throw new \LogicException(\sprintf('The "%s::start()" method must return a Response object ("%s" returned).', get_debug_type($this->authenticationEntryPoint), $given));
}

return $response;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,7 @@ abstract protected function processRememberMe(RememberMeDetails $rememberMeDetai

public function consumeRememberMeCookie(RememberMeDetails $rememberMeDetails): UserInterface
{
try {
$user = $this->userProvider->loadUserByIdentifier($rememberMeDetails->getUserIdentifier());
} catch (AuthenticationException $e) {
throw $e;
}

if (!$user instanceof UserInterface) {
throw new \LogicException(\sprintf('The UserProviderInterface implementation must return an instance of UserInterface, but returned "%s".', get_debug_type($user)));
}

$user = $this->userProvider->loadUserByIdentifier($rememberMeDetails->getUserIdentifier());
$this->processRememberMe($rememberMeDetails, $user);

$this->logger?->info('Remember-me cookie accepted.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,4 @@ private function createCheckPassportEvent($passport = null)

return new CheckPassportEvent($this->createMock(AuthenticatorInterface::class), $passport);
}

private function createAuthenticationSuccessEvent()
{
return new AuthenticationSuccessEvent(new PostAuthenticationToken($this->user, 'main', []));
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/String/ByteString.php
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public function reverse(): static
public function slice(int $start = 0, ?int $length = null): static
{
$str = clone $this;
$str->string = (string) substr($this->string, $start, $length ?? \PHP_INT_MAX);
$str->string = substr($this->string, $start, $length ?? \PHP_INT_MAX);

return $str;
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/TypeInfo/Type/GenericType.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function __toString(): string
$variableTypesString = '';
$glue = '';
foreach ($this->variableTypes as $t) {
$variableTypesString .= $glue.((string) $t);
$variableTypesString .= $glue.$t;
$glue = ',';
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/TypeInfo/Type/IntersectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function __toString(): string
$glue = '';

foreach ($this->types as $t) {
$string .= $glue.($t instanceof UnionType ? '('.((string) $t).')' : ((string) $t));
$string .= $glue.($t instanceof UnionType ? '('.$t.')' : $t);
$glue = '&';
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/TypeInfo/Type/UnionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function __toString(): string
$glue = '';

foreach ($this->types as $t) {
$string .= $glue.($t instanceof IntersectionType ? '('.((string) $t).')' : ((string) $t));
$string .= $glue.($t instanceof IntersectionType ? '('.$t.')' : $t);
$glue = '|';
}

Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Validator/Constraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected function normalizeOptions(mixed $options): array
$normalizedOptions = [];
$defaultOption = $this->getDefaultOption();
$invalidOptions = [];
$missingOptions = array_flip((array) $this->getRequiredOptions());
$missingOptions = array_flip($this->getRequiredOptions());
$knownOptions = get_class_vars(static::class);

if (\is_array($options) && isset($options['value']) && !property_exists($this, 'value')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ protected function expectValidateValue(int $i, mixed $value, array $constraints
{
$contextualValidator = $this->context->getValidator()->inContext($this->context);
$contextualValidator->expectValidation($i, null, $value, $group, function ($passedConstraints) use ($constraints) {
if (\is_array($constraints) && !\is_array($passedConstraints)) {
if (!\is_array($passedConstraints)) {
$passedConstraints = [$passedConstraints];
}

Expand All @@ -247,7 +247,7 @@ protected function expectFailingValueValidation(int $i, mixed $value, array $con
{
$contextualValidator = $this->context->getValidator()->inContext($this->context);
$contextualValidator->expectValidation($i, null, $value, $group, function ($passedConstraints) use ($constraints) {
if (\is_array($constraints) && !\is_array($passedConstraints)) {
if (!\is_array($passedConstraints)) {
$passedConstraints = [$passedConstraints];
}

Expand Down
11 changes: 4 additions & 7 deletions src/Symfony/Component/Workflow/Dumper/PlantUmlDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,23 +115,20 @@ public function dump(Definition $definition, ?Marking $marking = null, array $op
}
}

return $this->startPuml($options).$this->getLines($code).$this->endPuml($options);
return $this->startPuml().$this->getLines($code).$this->endPuml();
}

private function isWorkflowTransitionType(): bool
{
return self::WORKFLOW_TRANSITION === $this->transitionType;
}

private function startPuml(array $options): string
private function startPuml(): string
{
$start = '@startuml'.\PHP_EOL;
$start .= 'allow_mixing'.\PHP_EOL;

return $start;
return '@startuml'.\PHP_EOL.'allow_mixing'.\PHP_EOL;
}

private function endPuml(array $options): string
private function endPuml(): string
{
return \PHP_EOL.'@enduml';
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Yaml/Inline.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
}

// an unquoted *
if (false === $value || '' === $value) {
if ('' === $value) {
throw new ParseException('A reference must contain at least one character.', self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}

Expand All @@ -594,7 +594,7 @@ private static function evaluateScalar(string $scalar, int $flags, array &$refer
case '!' === $scalar[0]:
switch (true) {
case str_starts_with($scalar, '!!str '):
$s = (string) substr($scalar, 6);
$s = substr($scalar, 6);

if (\in_array($s[0] ?? '', ['"', "'"], true)) {
$isQuotedString = true;
Expand Down