Skip to content

Commit 30ba09a

Browse files
committed
Merge remote-tracking branch 'upstream/6.0' into 6.0
* upstream/6.0: [Security] Add type hints
2 parents bdb8616 + 69d6a6a commit 30ba09a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

security/voters.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ which makes creating a voter even easier::
4747

4848
abstract class Voter implements VoterInterface
4949
{
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);
5252
}
5353

5454
.. _how-to-use-the-voter-in-a-controller:
@@ -129,7 +129,7 @@ would look like this::
129129
const VIEW = 'view';
130130
const EDIT = 'edit';
131131

132-
protected function supports(string $attribute, $subject): bool
132+
protected function supports(string $attribute, mixed $subject): bool
133133
{
134134
// if the attribute isn't one we support, return false
135135
if (!in_array($attribute, [self::VIEW, self::EDIT])) {
@@ -144,7 +144,7 @@ would look like this::
144144
return true;
145145
}
146146

147-
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool
147+
protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
148148
{
149149
$user = $token->getUser();
150150

@@ -189,7 +189,7 @@ That's it! The voter is done! Next, :ref:`configure it <declaring-the-voter-as-a
189189

190190
To recap, here's what's expected from the two abstract methods:
191191

192-
``Voter::supports(string $attribute, $subject)``
192+
``Voter::supports(string $attribute, mixed $subject)``
193193
When ``isGranted()`` (or ``denyAccessUnlessGranted()``) is called, the first
194194
argument is passed here as ``$attribute`` (e.g. ``ROLE_USER``, ``edit``) and
195195
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:
199199
return ``true`` if the attribute is ``view`` or ``edit`` and if the object is
200200
a ``Post`` instance.
201201

202-
``voteOnAttribute(string $attribute, $subject, TokenInterface $token)``
202+
``voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token)``
203203
If you return ``true`` from ``supports()``, then this method is called. Your
204204
job is to return ``true`` to allow access and ``false`` to deny access.
205205
The ``$token`` can be used to find the current user object (if any). In this
@@ -242,7 +242,7 @@ with ``ROLE_SUPER_ADMIN``::
242242
$this->security = $security;
243243
}
244244

245-
protected function voteOnAttribute($attribute, $subject, TokenInterface $token): bool
245+
protected function voteOnAttribute($attribute, mixed $subject, TokenInterface $token): bool
246246
{
247247
// ...
248248

0 commit comments

Comments
 (0)