Closed luxemate closed 10 months ago
Hi, this is not a bug. Your method should be declared such as:
protected function supports(string $attribute, mixed $subject): bool
Same as the parent. If you widen the type by omitting the parameter type on purpose, you should say in the PHPDoc what the type is supposed to be, such as @param mixed $attribute
.
@ondrejmirtes Symfony 4.4 doesn't have native types set, thus I also can't use native type in supports
(because of the signature mismatch). But what symfony does have is the @param string $attribute
set, which is ignored in the supports
method, but is not ignored in the voteOnAttribute
method (probably because of asserts in the stub).
But maybe I misinterpret the situation and with treatPhpDocTypesAsCertain: false
it's required to add @param string $attribute
to the supports
method in a custom Voter
. Though it seems a little bit redundant, as annotation was already added by the third-party vendor.
@luxemate You've left out the information about Symfony 4.4 in your issue. I'd accept a PR that adds @param string $attribute
into the stub.
@ondrejmirtes I've created a new PR and added only @param string $attribute
as you've suggested.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
After update from 1.1.8 to 1.3.4 all custom voters started producing an error, although Symfony's abstract Voter has type annotation for $attribute:
Consider the following simple Voter implementation:
The funny thing is it only gets upset by the
supports
method, but not thevoteOnAttribute
method.