You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
By clicking “Sign up for GitHub”, you agree to our
terms of service
and
privacy statement
. We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Hi, I would like to enable for Closures the two rules already present for normal functions,
MissingFunctionParameterTypehintRule
and
MissingFunctionReturnTypehintRule
.
I found that master branch has this commit
491540d
which already enabled
PHPStan\Rules\Missing\MissingClosureNativeReturnTypehintRule
, so I guess only the parameter typehint is still missing.
May I propose a PR for a
MissingClosureParameterTypehintRule
?
Hi, the main blocker is that PHPStan currently does not read docblocks for
closures. So things like union types or what’s in an array cannot be
expressed for closures. We’d need to do that first and then adding such a
rule would be easy.
MissingClosureNativeReturnTypehintRule
is a little bit different. It looks at what you’re returning from the
function, and if it can be expressed with a native typehint, it asks you to
do so.
On Thu, 22 Aug 2019 at 14:27, Filippo Tessarotto ***@***.***> wrote:
Hi, I would like to enable for Closures the two rules already present for
normal functions, MissingFunctionParameterTypehintRule and
MissingFunctionReturnTypehintRule.
I found that master branch has this commit
491540d
<
491540d
>
which already enabled
PHPStan\Rules\Missing\MissingClosureNativeReturnTypehintRule, so I guess
only the parameter typehint is still missing.
May I propose a PR for a MissingClosureParameterTypehintRule?
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<
#87
?email_source=notifications&email_token=AAAZTOCUBETEUI6ULR7AO6TQF2A2DA5CNFSM4IOUMVPKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HGYWNSQ>,
or mute the thread
<
https://github.com/notifications/unsubscribe-auth/AAAZTOC4F5PLHXZUK4LLXVLQF2A2DANCNFSM4IOUMVPA
>
Ondřej Mirtes
Ok then, I'll wait for a PR.
For those who don't want to wait, don't use docblocks for closures and don't handle mixed types, a simple rule like this can be added to the project:
https://github.com/Slamdunk/phpstan-extensions/blob/v3.6.0/lib/MissingClosureParameterTypehintRule.php