Skip to content

Commit

Permalink
Merge branch '3.4' into 4.4
Browse files Browse the repository at this point in the history
* 3.4:
  Enable "native_constant_invocation" CS rule
  Make AbstractPhpFileCacheWarmer public
  • Loading branch information
nicolas-grekas committed Sep 2, 2020
2 parents ad02627 + 5e95789 commit 274b0eb
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Command/UserPasswordEncoderCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if ($input->isInteractive() && !$emptySalt) {
$emptySalt = true;

$errorIo->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. '.PHP_EOL.'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.');
$errorIo->note('The command will take care of generating a salt for you. Be aware that some encoders advise to let them generate their own salt. If you\'re using one of those encoders, please answer \'no\' to the question below. '.\PHP_EOL.'Provide the \'empty-salt\' option in order to let the encoder handle the generation itself.');

if ($errorIo->confirm('Confirm salt generation ?')) {
$salt = $this->generateSalt();
Expand Down
2 changes: 1 addition & 1 deletion Debug/WrappedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __invoke(RequestEvent $event)
if (\is_callable($this->listener)) {
($this->listener)($event);
} else {
@trigger_error(sprintf('Calling the "%s::handle()" method from the firewall is deprecated since Symfony 4.3, extend "%s" instead.', \get_class($this->listener), AbstractListener::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Calling the "%s::handle()" method from the firewall is deprecated since Symfony 4.3, extend "%s" instead.', \get_class($this->listener), AbstractListener::class), \E_USER_DEPRECATED);
$this->listener->handle($event);
}
$this->time = microtime(true) - $startTime;
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/MainConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
foreach ($v as $originalName => $cookieConfig) {
if (false !== strpos($originalName, '-')) {
$normalizedName = str_replace('-', '_', $originalName);
@trigger_error(sprintf('Normalization of cookie names is deprecated since Symfony 4.3. Starting from Symfony 5.0, the "%s" cookie configured in "logout.delete_cookies" will delete the "%s" cookie instead of the "%s" cookie.', $originalName, $originalName, $normalizedName), E_USER_DEPRECATED);
@trigger_error(sprintf('Normalization of cookie names is deprecated since Symfony 4.3. Starting from Symfony 5.0, the "%s" cookie configured in "logout.delete_cookies" will delete the "%s" cookie instead of the "%s" cookie.', $originalName, $originalName, $normalizedName), \E_USER_DEPRECATED);

// normalize cookie names manually for BC reasons. Remove it in Symfony 5.0.
$v[$normalizedName] = $cookieConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,

if (!empty($config['query_string'])) {
if ('' === $config['search_dn'] || '' === $config['search_password']) {
@trigger_error('Using the "query_string" config without using a "search_dn" and a "search_password" is deprecated since Symfony 4.4 and will throw an exception in Symfony 5.0.', E_USER_DEPRECATED);
@trigger_error('Using the "query_string" config without using a "search_dn" and a "search_password" is deprecated since Symfony 4.4 and will throw an exception in Symfony 5.0.', \E_USER_DEPRECATED);
}
$definition->addMethodCall('setQueryString', [$config['query_string']]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function create(ContainerBuilder $container, $id, $config, $userProvider,

if (!empty($config['query_string'])) {
if ('' === $config['search_dn'] || '' === $config['search_password']) {
@trigger_error('Using the "query_string" config without using a "search_dn" and a "search_password" is deprecated since Symfony 4.4 and will throw an exception in Symfony 5.0.', E_USER_DEPRECATED);
@trigger_error('Using the "query_string" config without using a "search_dn" and a "search_password" is deprecated since Symfony 4.4 and will throw an exception in Symfony 5.0.', \E_USER_DEPRECATED);
}
$definition->addMethodCall('setQueryString', [$config['query_string']]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ protected function createAuthProvider(ContainerBuilder $container, $id, $config,

if (!empty($config['query_string'])) {
if ('' === $config['search_dn'] || '' === $config['search_password']) {
@trigger_error('Using the "query_string" config without using a "search_dn" and a "search_password" is deprecated since Symfony 4.4 and will throw an exception in Symfony 5.0.', E_USER_DEPRECATED);
@trigger_error('Using the "query_string" config without using a "search_dn" and a "search_password" is deprecated since Symfony 4.4 and will throw an exception in Symfony 5.0.', \E_USER_DEPRECATED);
}
$definition->addMethodCall('setQueryString', [$config['query_string']]);
}
Expand Down
2 changes: 1 addition & 1 deletion DependencyInjection/Security/Factory/SimpleFormFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(bool $triggerDeprecation = true)
$this->addOption('authenticator', null);

if ($triggerDeprecation) {
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use Guard instead.', __CLASS__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use Guard instead.', __CLASS__), \E_USER_DEPRECATED);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SimplePreAuthenticationFactory implements SecurityFactoryInterface
public function __construct(bool $triggerDeprecation = true)
{
if ($triggerDeprecation) {
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use Guard instead.', __CLASS__), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2, use Guard instead.', __CLASS__), \E_USER_DEPRECATED);
}
}

Expand Down
12 changes: 6 additions & 6 deletions DependencyInjection/SecurityExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ private function createEncoder(array $config)
// bcrypt encoder
if ('bcrypt' === $config['algorithm']) {
$config['algorithm'] = 'native';
$config['native_algorithm'] = PASSWORD_BCRYPT;
$config['native_algorithm'] = \PASSWORD_BCRYPT;

return $this->createEncoder($config);
}
Expand All @@ -556,7 +556,7 @@ private function createEncoder(array $config)
$config['algorithm'] = 'sodium';
} elseif (\defined('PASSWORD_ARGON2I')) {
$config['algorithm'] = 'native';
$config['native_algorithm'] = PASSWORD_ARGON2I;
$config['native_algorithm'] = \PASSWORD_ARGON2I;
} else {
throw new InvalidConfigurationException(sprintf('Algorithm "argon2i" is not available. Either use "%s" or upgrade to PHP 7.2+ instead.', \defined('SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13') ? 'argon2id", "auto' : 'auto'));
}
Expand All @@ -569,7 +569,7 @@ private function createEncoder(array $config)
$config['algorithm'] = 'sodium';
} elseif (\defined('PASSWORD_ARGON2ID')) {
$config['algorithm'] = 'native';
$config['native_algorithm'] = PASSWORD_ARGON2ID;
$config['native_algorithm'] = \PASSWORD_ARGON2ID;
} else {
throw new InvalidConfigurationException(sprintf('Algorithm "argon2id" is not available. Either use "%s", upgrade to PHP 7.3+ or use libsodium 1.0.15+ instead.', \defined('PASSWORD_ARGON2I') || $hasSodium ? 'argon2i", "auto' : 'auto'));
}
Expand Down Expand Up @@ -793,7 +793,7 @@ private function isValidIp(string $cidr): bool
$cidrParts = explode('/', $cidr);

if (1 === \count($cidrParts)) {
return false !== filter_var($cidrParts[0], FILTER_VALIDATE_IP);
return false !== filter_var($cidrParts[0], \FILTER_VALIDATE_IP);
}

$ip = $cidrParts[0];
Expand All @@ -803,11 +803,11 @@ private function isValidIp(string $cidr): bool
return false;
}

if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
if (filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
return $netmask <= 32;
}

if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
if (filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
return $netmask <= 128;
}

Expand Down
2 changes: 1 addition & 1 deletion Security/FirewallContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(iterable $listeners, ExceptionListener $exceptionLis
$this->exceptionListener = $exceptionListener;
if ($logoutListener instanceof FirewallConfig) {
$this->config = $logoutListener;
@trigger_error(sprintf('Passing an instance of %s as the 3rd argument to "%s()" is deprecated since Symfony 4.2. Pass a %s instance instead.', FirewallConfig::class, __METHOD__, LogoutListener::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Passing an instance of %s as the 3rd argument to "%s()" is deprecated since Symfony 4.2. Pass a %s instance instead.', FirewallConfig::class, __METHOD__, LogoutListener::class), \E_USER_DEPRECATED);
} elseif (null === $logoutListener || $logoutListener instanceof LogoutListener) {
$this->logoutListener = $logoutListener;
$this->config = $config;
Expand Down
2 changes: 1 addition & 1 deletion Security/LazyFirewallContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function __invoke(RequestEvent $event)

foreach (parent::getListeners() as $listener) {
if (!\is_callable($listener)) {
@trigger_error(sprintf('Calling the "%s::handle()" method from the firewall is deprecated since Symfony 4.3, extend "%s" instead.', \get_class($listener), AbstractListener::class), E_USER_DEPRECATED);
@trigger_error(sprintf('Calling the "%s::handle()" method from the firewall is deprecated since Symfony 4.3, extend "%s" instead.', \get_class($listener), AbstractListener::class), \E_USER_DEPRECATED);
$listeners[] = [$listener, 'handle'];
$lazy = false;
} elseif (!$lazy || !$listener instanceof AbstractListener) {
Expand Down
2 changes: 1 addition & 1 deletion SecurityUserValueResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Http\Controller\UserValueResolver;

@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.1, use "%s" instead.', SecurityUserValueResolver::class, UserValueResolver::class), E_USER_DEPRECATED);
@trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.1, use "%s" instead.', SecurityUserValueResolver::class, UserValueResolver::class), \E_USER_DEPRECATED);

/**
* Supports the argument type of {@see UserInterface}.
Expand Down
2 changes: 1 addition & 1 deletion Templating/Helper/LogoutUrlHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Bundle\SecurityBundle\Templating\Helper;

@trigger_error('The '.LogoutUrlHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
@trigger_error('The '.LogoutUrlHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', \E_USER_DEPRECATED);

use Symfony\Component\Security\Http\Logout\LogoutUrlGenerator;
use Symfony\Component\Templating\Helper\Helper;
Expand Down
2 changes: 1 addition & 1 deletion Templating/Helper/SecurityHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Symfony\Bundle\SecurityBundle\Templating\Helper;

@trigger_error('The '.SecurityHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', E_USER_DEPRECATED);
@trigger_error('The '.SecurityHelper::class.' class is deprecated since version 4.3 and will be removed in 5.0; use Twig instead.', \E_USER_DEPRECATED);

use Symfony\Component\Security\Acl\Voter\FieldVote;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
Expand Down
4 changes: 2 additions & 2 deletions Tests/DependencyInjection/CompleteConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ public function testEncodersWithArgon2i()
],
'JMS\FooBundle\Entity\User7' => [
'class' => $sodium ? SodiumPasswordEncoder::class : NativePasswordEncoder::class,
'arguments' => $sodium ? [256, 1] : [1, 262144, null, PASSWORD_ARGON2I],
'arguments' => $sodium ? [256, 1] : [1, 262144, null, \PASSWORD_ARGON2I],
],
]], $container->getDefinition('security.encoder_factory.generic')->getArguments());
}
Expand Down Expand Up @@ -555,7 +555,7 @@ public function testEncodersWithBCrypt()
],
'JMS\FooBundle\Entity\User7' => [
'class' => NativePasswordEncoder::class,
'arguments' => [null, null, 15, PASSWORD_BCRYPT],
'arguments' => [null, null, 15, \PASSWORD_BCRYPT],
],
]], $container->getDefinition('security.encoder_factory.generic')->getArguments());
}
Expand Down
18 changes: 9 additions & 9 deletions Tests/Functional/UserPasswordEncoderCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function testEncodePasswordEmptySalt()
'user-class' => 'Symfony\Component\Security\Core\User\User',
'--empty-salt' => true,
], ['decorated' => false]);
$expected = str_replace("\n", PHP_EOL, file_get_contents(__DIR__.'/app/PasswordEncode/emptysalt.txt'));
$expected = str_replace("\n", \PHP_EOL, file_get_contents(__DIR__.'/app/PasswordEncode/emptysalt.txt'));

$this->assertEquals($expected, $this->passwordEncoderCommandTester->getDisplay());
}
Expand All @@ -65,7 +65,7 @@ public function testEncodePasswordBcrypt()
$output = $this->passwordEncoderCommandTester->getDisplay();
$this->assertStringContainsString('Password encoding succeeded', $output);

$encoder = new NativePasswordEncoder(null, null, 17, PASSWORD_BCRYPT);
$encoder = new NativePasswordEncoder(null, null, 17, \PASSWORD_BCRYPT);
preg_match('# Encoded password\s{1,}([\w+\/$.]+={0,2})\s+#', $output, $matches);
$hash = $matches[1];
$this->assertTrue($encoder->isPasswordValid($hash, 'password', null));
Expand All @@ -86,7 +86,7 @@ public function testEncodePasswordArgon2i()
$output = $this->passwordEncoderCommandTester->getDisplay();
$this->assertStringContainsString('Password encoding succeeded', $output);

$encoder = $sodium ? new SodiumPasswordEncoder() : new NativePasswordEncoder(null, null, null, PASSWORD_ARGON2I);
$encoder = $sodium ? new SodiumPasswordEncoder() : new NativePasswordEncoder(null, null, null, \PASSWORD_ARGON2I);
preg_match('# Encoded password\s+(\$argon2i?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches);
$hash = $matches[1];
$this->assertTrue($encoder->isPasswordValid($hash, 'password', null));
Expand All @@ -107,7 +107,7 @@ public function testEncodePasswordArgon2id()
$output = $this->passwordEncoderCommandTester->getDisplay();
$this->assertStringContainsString('Password encoding succeeded', $output);

$encoder = $sodium ? new SodiumPasswordEncoder() : new NativePasswordEncoder(null, null, null, PASSWORD_ARGON2ID);
$encoder = $sodium ? new SodiumPasswordEncoder() : new NativePasswordEncoder(null, null, null, \PASSWORD_ARGON2ID);
preg_match('# Encoded password\s+(\$argon2id?\$[\w,=\$+\/]+={0,2})\s+#', $output, $matches);
$hash = $matches[1];
$this->assertTrue($encoder->isPasswordValid($hash, 'password', null));
Expand Down Expand Up @@ -314,7 +314,7 @@ public function testThrowsExceptionOnNoConfiguredEncoders()

protected function setUp(): void
{
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
putenv('COLUMNS='.(119 + \strlen(\PHP_EOL)));
$kernel = $this->createKernel(['test_case' => 'PasswordEncode']);
$kernel->boot();

Expand All @@ -332,7 +332,7 @@ protected function tearDown(): void

private function setupArgon2i()
{
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
putenv('COLUMNS='.(119 + \strlen(\PHP_EOL)));
$kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'argon2i.yml']);
$kernel->boot();

Expand All @@ -345,7 +345,7 @@ private function setupArgon2i()

private function setupArgon2id()
{
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
putenv('COLUMNS='.(119 + \strlen(\PHP_EOL)));
$kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'argon2id.yml']);
$kernel->boot();

Expand All @@ -358,7 +358,7 @@ private function setupArgon2id()

private function setupBcrypt()
{
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
putenv('COLUMNS='.(119 + \strlen(\PHP_EOL)));
$kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'bcrypt.yml']);
$kernel->boot();

Expand All @@ -371,7 +371,7 @@ private function setupBcrypt()

private function setupSodium()
{
putenv('COLUMNS='.(119 + \strlen(PHP_EOL)));
putenv('COLUMNS='.(119 + \strlen(\PHP_EOL)));
$kernel = $this->createKernel(['test_case' => 'PasswordEncode', 'root_config' => 'sodium.yml']);
$kernel->boot();

Expand Down

0 comments on commit 274b0eb

Please sign in to comment.