symfony/symfony — pull request #10178 by jameshalsall (2014-02-02 20:19:58+00:00)
Title: Adding __toString() method to Role

| 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()`) impossible without creating your own `Role` classes, 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 be considered a BC break if people are relying on the fact that it will not cast to a string.