-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
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
Check whether function parameter+return has typehint #20
Conversation
Missing tests for closures, which must not be covered by this rule. |
Again, I don’t see rules.neon modified.
On Sun, 6 May 2018 at 22:41 Michael Moravec ***@***.***> wrote:
Missing tests for closures, which must not be covered by this rule.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#20 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGZuMiq8rDLkKAOC8DVKNpNN6xUk8ELks5tv2AUgaJpZM4T0Le_>
.
--
Ondřej Mirtes
|
@Majkl578 closures as direct parameter of function or stored into variable? |
5d0143d
to
c60ca9d
Compare
@Majkl578 Added closure test. |
Both. There is no supported way to document closure signature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please apply the same changes also to the second rule.
public function processNode(Node $node, Scope $scope): array | ||
{ | ||
if ($scope->isInClass()) { | ||
throw new \PHPStan\ShouldNotHappenException(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
throw new \PHPStan\ShouldNotHappenException(); | ||
} | ||
|
||
$functionReflection = $this->broker->getCustomFunction(new Node\Name($node->name, $node->getAttributes()), $scope); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that passing the attributes is not necessary.
|
||
if ($parameterType instanceof MixedType && !$parameterType->isExplicitMixed()) { | ||
return sprintf( | ||
'Function %s() has parameter $%s with no typehint specified', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a dot .
at the end. If there are other rules from you without this trailing dot, please add it in a new commit as well 😊
|
||
public function setBroker(Broker $broker): void | ||
{ | ||
$this->broker = $broker; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In rules, you can pass broker directly into the constructor.
private $broker; | ||
|
||
/** | ||
* @return string Class implementing \PhpParser\Node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This phpDoc is not necessary.
Closures have different node type so I think the test is not necessary. |
Fixed and merged, thanks! |
Hi,