8000 Rewrite condition for legacy call · symfony/symfony@12e0cef · GitHub
[go: up one dir, main page]

Skip to content

Commit 12e0cef

Browse files
committed
Rewrite condition for legacy call
1 parent 7d23db8 commit 12e0cef

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

src/Symfony/Component/PasswordHasher/Hasher/UserPasswordHasher.php

Lines changed: 12 additions & 4 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,13 @@ public function hashPassword($user, string $plainPassword): string
4444
}
4545

4646
$salt = null;
47-
if (method_exists($user, 'getSalt')) {
47+
48+
if ($user instanceof LegacyPasswordAuthenticatedUserInterface) {
49+
$salt = $user->getSalt();
50+
} elseif ($user instanceof UserInterface) {
4851
$salt = $user->getSalt();
49-
if ($salt && !$user instanceof LegacyPasswordAuthenticatedUserInterface) {
52+
53+
if (null !== $salt) {
5054
trigger_deprecation('symfony/password-hasher', '5.3', 'Returning a string from "getSalt()" without implementing the "%s" interface is deprecated, the "%s" class should implement it.', LegacyPasswordAuthenticatedUserInterface::class, get_debug_type($user));
5155
}
5256
}
@@ -69,9 +73,13 @@ public function isPasswordValid($user, string $plainPassword): bool
6973
}
7074

7175
$salt = null;
72-
if (method_exists($user, 'getSalt')) {
76+
77+
if ($user instanceof LegacyPasswordAuthenticatedUserInterface) {
78+
$salt = $user->getSalt();
79+
} elseif ($user instanceof UserInterface) {
7380
$salt = $user->getSalt();
74-
if ($salt && !$user instanceof LegacyPasswordAuthenticatedUserInterface) {
81+
82+
if (null !== $salt) {
7583
trigger_deprecation('symfony/password-hasher', '5.3', 'Returning a string from "getSalt()" without implementing the "%s" interface is deprecated, the "%s" class should implement it.', LegacyPasswordAuthenticatedUserInterface::class, get_debug_type($user));
7684
}
7785
}

src/Symfony/Component/PasswordHasher/Tests/Fixtures/TestLegacyPasswordAuthenticatedUser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php
22

33
namespace Symfony\Component\PasswordHasher\Tests\Fixtures;
44

src/Symfony/Component/PasswordHasher/Tests/Fixtures/TestPasswordAuthenticatedUser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<?php declare(strict_types=1);
1+
<?php
22

33
namespace Symfony\Component\PasswordHasher\Tests\Fixtures;
44

0 commit comments

Comments
 (0)
0