-
Notifications
You must be signed in to change notification settings - Fork 880
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
PHP: If a function or method does not have a return statement, the @return void tag is generated when generating a phpDoc #8340
base: master
Are you sure you want to change the base?
Conversation
…turn void tag is generated when generating a phpDoc.
@@ -114,6 +114,8 @@ private static void generateFunctionDoc(BaseDocument doc, int offset, int indent | |||
|
|||
if (i.hasReturn) { | |||
generateDocEntry(doc, toAdd, "@return", indent, null, i.getReturnType()); // NOI18N | |||
} else { | |||
generateDocEntry(doc, toAdd, "@return", indent, null, Type.VOID); // NOI18N |
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.
Nitpick: maybe simpler?
generateDocEntry(doc, toAdd, "@return", indent, null, Type.VOID); // NOI18N | |
generateDocEntry(doc, toAdd, "@return", indent, null, i.hasReturn ? i.getReturnType() : Type.VOID); // NOI18N |
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.
Looks good to me, but please wait for @junichi11. Thank you for your work.
The existing tests are executed for different purposes, so we should add tests for this fix. function noReturn() {
}
function hasReturn() {
return "test";
}
function emptyReturn() {
return;
}
function multipleEmptyReturns() {
if (true) {
return;
}
return;
}
// ... etc.
class TestClass {
public function noReturn() {
}
// ... etc.
}
interface TestInterface {
public function test(); // in this case, should not add?
// ... etc.
}
abstract class AbstractClass {
public abstract function test(int $param);
// ... etc.
} Please also write examples to the description(Before & After). Thanks! |
If a function or method does not have a
return
statement, the@return void
tag is generated when generating a phpDoc.before:
before.mp4
after:
after.mp4
^Add meaningful description above
Click to collapse/expand PR instructions
By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -
Please make sure (eg.
git log
) that all commits have a valid name and email address for you in the Author field.If you're a first time contributor, see the Contributing guidelines for more information.
If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.
PR approval and merge checklist:
If this PR targets the delivery branch: don't merge. (full wiki article)