symfony/symfony — pull request #10179 by jameshalsall (2014-02-02 20:57:00+00:00)
Title: [Security] Adding __toString() method to Role class

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | possibly ?
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | N/A
| License | MIT

This PR proposes adding the `toString()` method to the `\Symfony\Component\Security\Core\Role\Role` class. This should ease the comparison of role strings and instances of `Role` itself. For example, in the `FOSUserBundle` the `User` model contains roles which are represented as strings. Making comparisons between arrays of `Role` objects (for example, returned by the `RoleHierarchy::getReachableRoles()`) difficult without creating your own `Role` class with a `__toString()`, and this isn't always desirable.

I found some conversation around [adding the `\Seriazable` interface to the `Role` class](https://github.com/symfony/symfony/pull/4934), and I realise that this might also be considered a BC break if people are relying on the fact that it will not cast to a string.