Skip to content

Commit fd0cce7

Browse files
committed
More code adjustments for PHP 8.2
1 parent a2f2190 commit fd0cce7

File tree

7 files changed

+11
-15
lines changed

7 files changed

+11
-15
lines changed

tests/ComposerJsonTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function packageDependenciesEqualRootDependencies(): void
4545
}
4646

4747
$unusedDependencies = array_diff(array_keys($rootDependencies), array_unique($usedDependencies));
48-
$message = sprintf('Dependencies declared in root composer.json, which are not declared in any sub-package: %s', implode($unusedDependencies));
48+
$message = sprintf('Dependencies declared in root composer.json, which are not declared in any sub-package: %s', implode('', $unusedDependencies));
4949
$this->assertCount(0, $unusedDependencies, $message);
5050
}
5151

tests/DependencyInjection/Factory/Security/TestableFactoryConfiguration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
class TestableFactoryConfiguration implements ConfigurationInterface
1515
{
16-
public function __construct(private TwoFactorFactory $factory)
16+
public function __construct(private readonly TwoFactorFactory $factory)
1717
{
1818
}
1919

tests/DependencyInjection/SchebTwoFactorExtensionTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Symfony\Component\DependencyInjection\ContainerBuilder;
1212
use Symfony\Component\DependencyInjection\Definition;
1313
use Symfony\Component\DependencyInjection\Reference;
14+
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
15+
use Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken;
1416
use Symfony\Component\Yaml\Parser;
1517
use function array_map;
1618
use function sprintf;
@@ -60,8 +62,8 @@ public function load_emptyConfig_setDefaultValues(): void
6062
$this->assertHasNotParameter('scheb_two_factor.trusted_device.cookie_domain');
6163
$this->assertHasNotParameter('scheb_two_factor.trusted_device.cookie_path');
6264
$this->assertHasParameter([
63-
'Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken',
64-
'Symfony\Component\Security\Http\Authenticator\Token\PostAuthenticationToken',
65+
UsernamePasswordToken::class,
66+
PostAuthenticationToken::class,
6567
], 'scheb_two_factor.security_tokens');
6668
$this->assertHasParameter([], 'scheb_two_factor.ip_whitelist');
6769
}
@@ -707,8 +709,6 @@ private function getConditionRegistryServices(): array
707709
$conditionsArgument = $this->container->getDefinition('scheb_two_factor.condition_registry')->getArgument(0);
708710
$this->assertInstanceOf(IteratorArgument::class, $conditionsArgument);
709711

710-
return array_map(static function (Reference $serviceReference) {
711-
return (string) $serviceReference;
712-
}, $conditionsArgument->getValues());
712+
return array_map(static fn (Reference $serviceReference) => (string) $serviceReference, $conditionsArgument->getValues());
713713
}
714714
}

tests/Security/Http/EventListener/TrustedDeviceListenerTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ private function createPassportMock(): MockObject|Passport
6060
$passport
6161
->expects($this->any())
6262
->method('hasBadge')
63-
->willReturnCallback(function (string $badgeClass) {
64-
return in_array($badgeClass, $this->availableBadges);
65-
});
63+
->willReturnCallback(fn (string $badgeClass) => in_array($badgeClass, $this->availableBadges));
6664

6765
return $passport;
6866
}

tests/Security/TwoFactor/Provider/Google/GoogleAuthenticatorTwoFactorProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ private function createAuthenticationContext(UserInterface|null $user = null): M
5151
$authContext
5252
->expects($this->any())
5353
->method('getUser')
54-
->willReturn($user ? $user : $this->createUser());
54+
->willReturn($user ?: $this->createUser());
5555

5656
return $authContext;
5757
}

tests/Security/TwoFactor/Provider/Totp/TotpAuthenticatorTwoFactorProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private function createAuthenticationContext(UserInterface|null $user = null): M
6262
$authContext
6363
->expects($this->any())
6464
->method('getUser')
65-
->willReturn($user ? $user : $this->createUser());
65+
->willReturn($user ?: $this->createUser());
6666

6767
return $authContext;
6868
}

tests/Security/TwoFactor/TwoFactorFirewallConfigTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,7 @@ private function stubRequestMethod(MockObject|Request $request, string $method):
5757
$request
5858
->expects($this->any())
5959
->method('isMethod')
60-
->willReturnCallback(static function (string $arg) use ($method) {
61-
return $arg === $method;
62-
});
60+
->willReturnCallback(static fn (string $arg) => $arg === $method);
6361
}
6462

6563
private function stubCheckRequestPath(MockObject|Request $request, string $pathToCheck, bool $result): void

0 commit comments

Comments
 (0)