summaryrefslogtreecommitdiffstats
path: root/Core
diff options
context:
space:
mode:
Diffstat (limited to 'Core')
-rw-r--r--Core/Authentication/Token/Token.php12
-rw-r--r--Core/User/AccountInterface.php7
2 files changed, 6 insertions, 13 deletions
diff --git a/Core/Authentication/Token/Token.php b/Core/Authentication/Token/Token.php
index e4e5d55..1efa5d6 100644
--- a/Core/Authentication/Token/Token.php
+++ b/Core/Authentication/Token/Token.php
@@ -85,13 +85,13 @@ abstract class Token implements TokenInterface
*/
public function __toString()
{
- if (!is_object($this->user)) {
- return (string) $this->user;
- } elseif ($this->user instanceof AccountInterface) {
+ if (is_string($this->user)) {
+ return $this->user;
+ } else if ($this->user instanceof AccountInterface) {
return $this->user->getUsername();
- } else {
- return 'n/a';
}
+
+ return (string) $this->user;
}
/**
@@ -141,7 +141,7 @@ abstract class Token implements TokenInterface
if (!is_string($user) && !is_object($user)) {
throw new \InvalidArgumentException('$user must be an object, or a primitive string.');
- } else if (is_object($user) && !method_exists($user, '__toString')) {
+ } else if (is_object($user) && !$user instanceof AccountInterface && !method_exists($user, '__toString')) {
throw new \InvalidArgumentException('If $user is an object, it must implement __toString().');
}
diff --git a/Core/User/AccountInterface.php b/Core/User/AccountInterface.php
index 1863302..0c6f188 100644
--- a/Core/User/AccountInterface.php
+++ b/Core/User/AccountInterface.php
@@ -19,13 +19,6 @@ namespace Symfony\Component\Security\Core\User;
interface AccountInterface
{
/**
- * Returns a string representation of the User.
- *
- * @return string A string return of the User
- */
- function __toString();
-
- /**
* Returns the roles granted to the user.
*
* @return Role[] The user roles