Skip to content

Commit 0205ab8

Browse files
Merge branch '4.4' into 5.1
* 4.4: Enable "native_constant_invocation" CS rule Make AbstractPhpFileCacheWarmer public
2 parents c761866 + 274b0eb commit 0205ab8

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

Command/UserPasswordEncoderCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
134134
if ($input->isInteractive() && !$emptySalt) {
135135
$emptySalt = true;
136136

137-
$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.');
137+
$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.');
138138

139139
if ($errorIo->confirm('Confirm salt generation ?')) {
140140
$salt = $this->generateSalt();

DependencyInjection/SecurityExtension.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ private function createEncoder(array $config)
680680
// bcrypt encoder
681681
if ('bcrypt' === $config['algorithm']) {
682682
$config['algorithm'] = 'native';
683-
$config['native_algorithm'] = PASSWORD_BCRYPT;
683+
$config['native_algorithm'] = \PASSWORD_BCRYPT;
684684

685685
return $this->createEncoder($config);
686686
}
@@ -691,7 +691,7 @@ private function createEncoder(array $config)
691691
$config['algorithm'] = 'sodium';
692692
} elseif (\defined('PASSWORD_ARGON2I')) {
693693
$config['algorithm'] = 'native';
694-
$config['native_algorithm'] = PASSWORD_ARGON2I;
694+
$config['native_algorithm'] = \PASSWORD_ARGON2I;
695695
} else {
696696
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'));
697697
}
@@ -704,7 +704,7 @@ private function createEncoder(array $config)
704704
$config['algorithm'] = 'sodium';
705705
} elseif (\defined('PASSWORD_ARGON2ID')) {
706706
$config['algorithm'] = 'native';
707-
$config['native_algorithm'] = PASSWORD_ARGON2ID;
707+
$config['native_algorithm'] = \PASSWORD_ARGON2ID;
708708
} else {
709709
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'));
710710
}
@@ -928,7 +928,7 @@ private function isValidIp(string $cidr): bool
928928
$cidrParts = explode('/', $cidr);
929929

930930
if (1 === \count($cidrParts)) {
931-
return false !== filter_var($cidrParts[0], FILTER_VALIDATE_IP);
931+
return false !== filter_var($cidrParts[0], \FILTER_VALIDATE_IP);
932932
}
933933

934934
$ip = $cidrParts[0];
@@ -938,11 +938,11 @@ private function isValidIp(string $cidr): bool
938938
return false;
939939
}
940940

941-
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
941+
if (filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4)) {
942942
return $netmask <= 32;
943943
}
944944

945-
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
945+
if (filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
946946
return $netmask <= 128;
947947
}
948948

Tests/DependencyInjection/CompleteConfigurationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ public function testEncodersWithArgon2i()
432432
],
433433
'JMS\FooBundle\Entity\User7' => [
434434
'class' => $sodium ? SodiumPasswordEncoder::class : NativePasswordEncoder::class,
435-
'arguments' => $sodium ? [256, 1] : [1, 262144, null, PASSWORD_ARGON2I],
435+
'arguments' => $sodium ? [256, 1] : [1, 262144, null, \PASSWORD_ARGON2I],
436436
],
437437
]], $container->getDefinition('security.encoder_factory.generic')->getArguments());
438438
}
@@ -542,7 +542,7 @@ public function testEncodersWithBCrypt()
542542
],
543543
'JMS\FooBundle\Entity\User7' => [
544544
'class' => NativePasswordEncoder::class,
545-
'arguments' => [null, null, 15, PASSWORD_BCRYPT],
545+
'arguments' => [null, null, 15, \PASSWORD_BCRYPT],
546546
],
547547
]], $container->getDefinition('security.encoder_factory.generic')->getArguments());
548548
}

Tests/Functional/UserPasswordEncoderCommandTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testEncodePasswordEmptySalt()
3838
'user-class' => 'Symfony\Component\Security\Core\User\User',
3939
'--empty-salt' => true,
4040
], ['decorated' => false]);
41-
$expected = str_replace("\n", PHP_EOL, file_get_contents(__DIR__.'/app/PasswordEncode/emptysalt.txt'));
41+
$expected = str_replace("\n", \PHP_EOL, file_get_contents(__DIR__.'/app/PasswordEncode/emptysalt.txt'));
4242

4343
$this->assertEquals($expected, $this->passwordEncoderCommandTester->getDisplay());
4444
}
@@ -65,7 +65,7 @@ public function testEncodePasswordBcrypt()
6565
$output = $this->passwordEncoderCommandTester->getDisplay();
6666
$this->assertStringContainsString('Password encoding succeeded', $output);
6767

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

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

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

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

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

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

@@ -345,7 +345,7 @@ private function setupArgon2i()
345345

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

@@ -358,7 +358,7 @@ private function setupArgon2id()
358358

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

@@ -371,7 +371,7 @@ private function setupBcrypt()
371371

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

0 commit comments

Comments
 (0)