@@ -47,8 +47,8 @@ which makes creating a voter even easier::
47
47
48
48
abstract class Voter implements VoterInterface
49
49
{
50
- abstract protected function supports(string $attribute, $subject);
51
- abstract protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token);
50
+ abstract protected function supports(string $attribute, mixed $subject);
51
+ abstract protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token);
52
52
}
53
53
54
54
.. _how-to-use-the-voter-in-a-controller :
@@ -129,7 +129,7 @@ would look like this::
129
129
const VIEW = 'view';
130
130
const EDIT = 'edit';
131
131
132
- protected function supports(string $attribute, $subject): bool
132
+ protected function supports(string $attribute, mixed $subject): bool
133
133
{
134
134
// if the attribute isn't one we support, return false
135
135
if (!in_array($attribute, [self::VIEW, self::EDIT])) {
@@ -144,7 +144,7 @@ would look like this::
144
144
return true;
145
145
}
146
146
147
- protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
147
+ protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
148
148
{
149
149
$user = $token->getUser();
150
150
@@ -189,7 +189,7 @@ That's it! The voter is done! Next, :ref:`configure it <declaring-the-voter-as-a
189
189
190
190
To recap, here's what's expected from the two abstract methods:
191
191
192
- ``Voter::supports(string $attribute, $subject) ``
192
+ ``Voter::supports(string $attribute, mixed $subject) ``
193
193
When ``isGranted() `` (or ``denyAccessUnlessGranted() ``) is called, the first
194
194
argument is passed here as ``$attribute `` (e.g. ``ROLE_USER ``, ``edit ``) and
195
195
the second argument (if any) is passed as ``$subject `` (e.g. ``null ``, a ``Post ``
@@ -199,7 +199,7 @@ To recap, here's what's expected from the two abstract methods:
199
199
return ``true `` if the attribute is ``view `` or ``edit `` and if the object is
200
200
a ``Post `` instance.
201
201
202
- ``voteOnAttribute(string $attribute, $subject, TokenInterface $token) ``
202
+ ``voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token) ``
203
203
If you return ``true `` from ``supports() ``, then this method is called. Your
204
204
job is to return ``true `` to allow access and ``false `` to deny access.
205
205
The ``$token `` can be used to find the current user object (if any). In this
@@ -242,7 +242,7 @@ with ``ROLE_SUPER_ADMIN``::
242
242
$this->security = $security;
243
243
}
244
244
245
- protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
245
+ protected function voteOnAttribute($attribute, mixed $subject, TokenInterface $token): bool
246
246
{
247
247
// ...
248
248
0 commit comments