Skip to content

Commit 445b604

Browse files
minor symfony#58600 Remove always true/false occurrences (alexandre-daubois)
This PR was merged into the 7.2 branch. Discussion ---------- Remove always true/false occurrences | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | no | Deprecations? | no | Issues | - | License | MIT Most occurrences are surely artifact of when PHP allowed less typing. Commits ------- 6980384 Remove always true/false occurrences
2 parents 52a280e + 6980384 commit 445b604

File tree

34 files changed

+35
-65
lines changed

34 files changed

+35
-65
lines changed

src/Symfony/Bridge/Doctrine/Security/User/EntityUserProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function upgradePassword(PasswordAuthenticatedUserInterface $user, string
121121
}
122122

123123
$repository = $this->getRepository();
124-
if ($user instanceof PasswordAuthenticatedUserInterface && $repository instanceof PasswordUpgraderInterface) {
124+
if ($repository instanceof PasswordUpgraderInterface) {
125125
$repository->upgradePassword($user, $newHashedPassword);
126126
}
127127
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,6 @@ private function findWrongBundleOverrides(): array
412412
}
413413

414414
if ($notFoundBundles = array_diff_key($bundleNames, $this->bundlesMetadata)) {
415-
$alternatives = [];
416415
foreach ($notFoundBundles as $notFoundBundle => $path) {
417416
$alternatives[$path] = $this->findAlternatives($notFoundBundle, array_keys($this->bundlesMetadata));
418417
}

src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/TextDescriptor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ protected function describeContainerService(object $service, array $options = []
172172
$options['output']->table(
173173
['Service ID', 'Class'],
174174
[
175-
[$options['id'] ?? '-', $service::class],
175+
[$options['id'], $service::class],
176176
]
177177
);
178178
}
@@ -333,7 +333,7 @@ protected function describeContainerDefinition(Definition $definition, array $op
333333
$tableRows[] = ['Autoconfigured', $definition->isAutoconfigured() ? 'yes' : 'no'];
334334

335335
if ($definition->getFile()) {
336-
$tableRows[] = ['Required File', $definition->getFile() ?: '-'];
336+
$tableRows[] = ['Required File', $definition->getFile()];
337337
}
338338

339339
if ($factory = $definition->getFactory()) {

src/Symfony/Bundle/FrameworkBundle/Tests/Command/XliffLintCommandTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ private function createCommandTester($application = null): CommandTester
6464

6565
$command = $application->find('lint:xliff');
6666

67-
if ($application) {
68-
$command->setApplication($application);
69-
}
67+
$command->setApplication($application);
7068

7169
return new CommandTester($command);
7270
}

src/Symfony/Bundle/FrameworkBundle/Tests/Command/YamlLintCommandTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@ private function createCommandTester($application = null): CommandTester
112112

113113
$command = $application->find('lint:yaml');
114114

115-
if ($application) {
116-
$command->setApplication($application);
117-
}
115+
$command->setApplication($application);
118116

119117
return new CommandTester($command);
120118
}

src/Symfony/Bundle/SecurityBundle/DependencyInjection/Compiler/ReplaceDecoratedRememberMeHandlerPass.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ public function process(ContainerBuilder $container): void
3737

3838
// get the actual custom remember me handler definition (passed to the decorator)
3939
$realRememberMeHandler = $container->findDefinition((string) $definition->getArgument(0));
40-
if (null === $realRememberMeHandler) {
41-
throw new \LogicException(\sprintf('Invalid service definition for custom remember me handler; no service found with ID "%s".', (string) $definition->getArgument(0)));
42-
}
4340

4441
foreach ($rememberMeHandlerTags as $rememberMeHandlerTag) {
4542
// some custom handlers may be used on multiple firewalls in the same application

src/Symfony/Bundle/SecurityBundle/Tests/Functional/Bundle/SecuredPageBundle/Security/Core/User/ArrayUserProvider.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bundle\SecurityBundle\Tests\Functional\Bundle\SecuredPageBundle\Security\Core\User;
1313

1414
use Symfony\Bundle\SecurityBundle\Tests\Functional\UserWithoutEquatable;
15-
use Symfony\Component\Security\Core\Exception\UnsupportedUserException;
1615
use Symfony\Component\Security\Core\Exception\UserNotFoundException;
1716
use Symfony\Component\Security\Core\User\InMemoryUser;
1817
use Symfony\Component\Security\Core\User\UserInterface;
@@ -59,10 +58,6 @@ public function loadUserByIdentifier(string $identifier): UserInterface
5958

6059
public function refreshUser(UserInterface $user): UserInterface
6160
{
62-
if (!$user instanceof UserInterface) {
63-
throw new UnsupportedUserException(\sprintf('Instances of "%s" are not supported.', get_debug_type($user)));
64-
}
65-
6661
$storedUser = $this->getUser($user->getUserIdentifier());
6762
$class = $storedUser::class;
6863

src/Symfony/Component/Cache/Adapter/TagAwareAdapter.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,10 @@ public function clear(string $prefix = ''): bool
207207
unset($this->deferred[$key]);
208208
}
209209
}
210-
} else {
211-
$this->deferred = [];
212-
}
213210

214-
if ($this->pool instanceof AdapterInterface) {
215211
return $this->pool->clear($prefix);
212+
} else {
213+
$this->deferred = [];
216214
}
217215

218216
return $this->pool->clear();

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ private function write(string $file, string $data, ?int $expiresAt = null): bool
108108

109109
if ('\\' === \DIRECTORY_SEPARATOR) {
110110
$success = copy($tmp, $file);
111-
$unlink = true;
112111
} else {
113112
$success = rename($tmp, $file);
114113
$unlink = !$success;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public static function createConnection(#[\SensitiveParameter] string $dsn, arra
199199
\extension_loaded('relay') => Relay::class,
200200
default => \Predis\Client::class,
201201
},
202-
1 < \count($hosts) && \extension_loaded('redis') => 1 < \count($hosts) ? \RedisArray::class : \Redis::class,
202+
1 < \count($hosts) && \extension_loaded('redis') => \RedisArray::class,
203203
\extension_loaded('redis') => \Redis::class,
204204
\extension_loaded('relay') => Relay::class,
205205
default => \Predis\Client::class,
@@ -614,7 +614,7 @@ private function pipeline(\Closure $generator, ?object $redis = null): \Generato
614614
}
615615
});
616616
} elseif ($redis instanceof \RedisArray) {
617-
$connections = $results = $ids = [];
617+
$connections = $results = [];
618618
foreach ($generator() as $command => $args) {
619619
$id = 'eval' === $command ? $args[1][0] : $args[0];
620620
if (!isset($connections[$h = $redis->_target($id)])) {

0 commit comments

Comments
 (0)