Skip to content

Commit 73c7de5

Browse files
derrabusnicolas-grekas
authored andcommitted
Leverage str_contains/str_starts_with
Signed-off-by: Alexander M. Turek <me@derrabus.de>
1 parent 48329a5 commit 73c7de5

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

DependencyInjection/MainConfiguration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
226226
->beforeNormalization()
227227
->ifArray()->then(function ($v) {
228228
foreach ($v as $originalName => $cookieConfig) {
229-
if (false !== strpos($originalName, '-')) {
229+
if (str_contains($originalName, '-')) {
230230
$normalizedName = str_replace('-', '_', $originalName);
231231
@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);
232232

@@ -304,7 +304,7 @@ private function addFirewallsSection(ArrayNodeDefinition $rootNode, array $facto
304304
continue;
305305
}
306306

307-
if (false !== strpos($firewall[$k]['check_path'], '/') && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) {
307+
if (str_contains($firewall[$k]['check_path'], '/') && !preg_match('#'.$firewall['pattern'].'#', $firewall[$k]['check_path'])) {
308308
throw new \LogicException(sprintf('The check_path "%s" for login method "%s" is not matched by the firewall pattern "%s".', $firewall[$k]['check_path'], $k, $firewall['pattern']));
309309
}
310310
}

Tests/DependencyInjection/CompleteConfigurationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testUserProviders()
4242
{
4343
$container = $this->getContainer('container1');
4444

45-
$providers = array_values(array_filter($container->getServiceIds(), function ($key) { return 0 === strpos($key, 'security.user.provider.concrete'); }));
45+
$providers = array_values(array_filter($container->getServiceIds(), function ($key) { return str_starts_with($key, 'security.user.provider.concrete'); }));
4646

4747
$expectedProviders = [
4848
'security.user.provider.concrete.default',

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"symfony/config": "^4.2|^5.0",
2222
"symfony/dependency-injection": "^4.4|^5.0",
2323
"symfony/http-kernel": "^4.4",
24+
"symfony/polyfill-php80": "^1.16",
2425
"symfony/security-core": "^4.4",
2526
"symfony/security-csrf": "^4.2|^5.0",
2627
"symfony/security-guard": "^4.2|^5.0",

0 commit comments

Comments
 (0)