Skip to content

Commit

Permalink
Merge pull request #3033 from stof/fix_user_deprecation
Browse files Browse the repository at this point in the history
Fix deprecation warning for UserInterface on Symfony 4
  • Loading branch information
stof committed Jan 14, 2022
2 parents 90d7848 + 334a6e8 commit 5459f83
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
4 changes: 4 additions & 0 deletions Changelog.md
@@ -1,6 +1,10 @@
Changelog
=========

### 2.2.4 (2022-01-14)

* Fixed a deprecated warning reported by DebugClassLoader in the AdvancedUserInterface BC layer due to the change done in 2.2.3.

### 2.2.3 (2022-01-14)

* Added missing deprecations on some group-related event classes
Expand Down
45 changes: 23 additions & 22 deletions Model/UserInterface.php
Expand Up @@ -14,10 +14,31 @@
use Symfony\Component\Security\Core\User\EquatableInterface;
use Symfony\Component\Security\Core\User\UserInterface as BaseUserInterface;

// This is required to support apps that explicitly check if a user is an instance of AdvancedUserInterface
if (interface_exists('\Symfony\Component\Security\Core\User\AdvancedUserInterface')) {
/**
* @internal Only for back compatibility. Remove / merge when dropping support for Symfony 4
*
* @deprecated
*/
interface CompatUserInterface extends \Symfony\Component\Security\Core\User\AdvancedUserInterface
{
}
} else {
/**
* @internal Only for back compatibility. Remove / merge when dropping support for Symfony 4
*/
interface CompatUserInterface extends BaseUserInterface, EquatableInterface
{
}
}

/**
* @internal Only for back compatibility. Remove / merge when dropping support for Symfony 4
* @author Thibault Duplessis <thibault.duplessis@gmail.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
* @author Julian Finkler <julian@developer-heaven.de>
*/
interface FosUserInterface extends \Serializable
interface UserInterface extends CompatUserInterface, \Serializable
{
public const ROLE_DEFAULT = 'ROLE_USER';

Expand Down Expand Up @@ -270,23 +291,3 @@ public function isCredentialsNonExpired();
*/
public function isEnabled();
}

// This is required to support apps that explicitly check if a user is an instance of AdvancedUserInterface
if (interface_exists('\Symfony\Component\Security\Core\User\AdvancedUserInterface')) {
/**
* @author Thibault Duplessis <thibault.duplessis@gmail.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
*/
interface UserInterface extends FosUserInterface, \Symfony\Component\Security\Core\User\AdvancedUserInterface
{
}
} else {
/**
* @author Thibault Duplessis <thibault.duplessis@gmail.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
* @author Julian Finkler <julian@developer-heaven.de>
*/
interface UserInterface extends FosUserInterface, BaseUserInterface, EquatableInterface
{
}
}

0 comments on commit 5459f83

Please sign in to comment.