Skip to content

Commit ee7ced3

Browse files
committed
minor #13820 Update voters.rst (atailouloute)
This PR was merged into the 5.0 branch. Discussion ---------- Update voters.rst Commits ------- ed0b98f Update voters.rst
2 parents 24d0975 + ed0b98f commit ee7ced3

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

security/voters.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ would look like this::
118118
const VIEW = 'view';
119119
const EDIT = 'edit';
120120

121-
protected function supports($attribute, $subject)
121+
protected function supports(string $attribute, $subject)
122122
{
123123
// if the attribute isn't one we support, return false
124124
if (!in_array($attribute, [self::VIEW, self::EDIT])) {
@@ -133,7 +133,7 @@ would look like this::
133133
return true;
134134
}
135135

136-
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
136+
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)
137137
{
138138
$user = $token->getUser();
139139

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

179179
To recap, here's what's expected from the two abstract methods:
180180

181-
``Voter::supports($attribute, $subject)``
181+
``Voter::supports(string $attribute, $subject)``
182182
When ``isGranted()`` (or ``denyAccessUnlessGranted()``) is called, the first
183183
argument is passed here as ``$attribute`` (e.g. ``ROLE_USER``, ``edit``) and
184184
the second argument (if any) is passed as ``$subject`` (e.g. ``null``, a ``Post``
@@ -188,7 +188,7 @@ To recap, here's what's expected from the two abstract methods:
188188
return ``true`` if the attribute is ``view`` or ``edit`` and if the object is
189189
a ``Post`` instance.
190190

191-
``voteOnAttribute($attribute, $subject, TokenInterface $token)``
191+
``voteOnAttribute(string $attribute, $subject, TokenInterface $token)``
192192
If you return ``true`` from ``supports()``, then this method is called. Your
193193
job is simple: return ``true`` to allow access and ``false`` to deny access.
194194
The ``$token`` can be used to find the current user object (if any). In this
@@ -231,7 +231,7 @@ with ``ROLE_SUPER_ADMIN``::
231231
$this->security = $security;
232232
}
233233

234-
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
234+
protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token)
235235
{
236236
// ...
237237

0 commit comments

Comments
 (0)