summaryrefslogtreecommitdiffstats
path: root/Core/Authentication
diff options
context:
space:
mode:
authorJohannes Schmitt <schmittjoh@gmail.com>2011-02-11 00:04:55 +0100
committerFabien Potencier <fabien.potencier@gmail.com>2011-02-12 21:53:04 +0100
commit0c9e3edd50a02b8ac80f5ba9165df792b28575c7 (patch)
tree200e573f7395055357f350de15884a43d2f38a0b /Core/Authentication
parent40698c0c3004d1dd5f83394ba8a0a90918590da8 (diff)
downloadsymfony-security-0c9e3edd50a02b8ac80f5ba9165df792b28575c7.zip
symfony-security-0c9e3edd50a02b8ac80f5ba9165df792b28575c7.tar.gz
symfony-security-0c9e3edd50a02b8ac80f5ba9165df792b28575c7.tar.bz2
[Security] removed __toString() from AccountInterface
Diffstat (limited to 'Core/Authentication')
-rw-r--r--Core/Authentication/Token/Token.php12
1 files changed, 6 insertions, 6 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().');
}