Closure: report missing function parameter typehint and missing return type
Slamdunk opened this issue · 2 comments
Slamdunk commented
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
?
ondrejmirtes commented
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
Slamdunk commented
PHPStan currently does not read docblocks for closures
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: