Skip to content

PHP: If a function or method does not have a return statement, the @return void tag is generated when generating a phpDoc #8340

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

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: maybe simpler?

Suggested change
generateDocEntry(doc, toAdd, "@return", indent, null, Type.VOID); // NOI18N
generateDocEntry(doc, toAdd, "@return", indent, null, i.hasReturn ? i.getReturnType() : Type.VOID); // NOI18N

}

addVariables(doc, toAdd, "@throws", indent, i.throwsExceptions);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

/**
* ^
*
* @return void^
*/
function f(){
$r= '/.*/';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

/**
* ^
*
* @return void^
*/
function f(){
$r= '/./*';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

/**
*
* @param type $alias^
* @param type $alias
* @return void^
*/
function func($alias) {
$blah = "/blee*/";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

/**
*
* @param type $alias^
* @param type $alias
* @return void^
*/
function func($alias) {
$blah = "/blee/*";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public void testFunctionDocumentationParam() throws Exception {
"<?php\n" +
"/**\n" +
" * \n" +
" * @param " + PhpCommentGenerator.TYPE_PLACEHOLDER + " $i^\n" +
" * @param " + PhpCommentGenerator.TYPE_PLACEHOLDER + " $i\n" +
" * @return void^\n" +
" */\n" +
"function foo($i) {\n" +
"}\n" +
Expand All @@ -70,7 +71,8 @@ public void testFunctionDocumentationGlobalVar() throws Exception {
"$r = 1;\n" +
"/**\n" +
" * \n" +
" * @global int $r^\n" +
" * @global int $r\n" +
" * @return void^\n" +
" */\n" +
"function foo() {\n" +
" global $r;\n" +
Expand All @@ -88,7 +90,8 @@ public void testFunctionDocumentationStaticVar() throws Exception {
"<?php\n" +
"/**\n" +
" * \n" +
" * @staticvar " + PhpCommentGenerator.TYPE_PLACEHOLDER + " $r^\n" +
" * @staticvar " + PhpCommentGenerator.TYPE_PLACEHOLDER + " $r\n" +
" * @return void^\n" +
" */\n" +
"function foo() {\n" +
" static $r;\n" +
Expand Down Expand Up @@ -159,7 +162,8 @@ public void testMethodDocumentation() throws Exception {
"class foo {\n" +
" /**\n" +
" * \n" +
" * @param " + PhpCommentGenerator.TYPE_PLACEHOLDER + " $par^\n" +
" * @param " + PhpCommentGenerator.TYPE_PLACEHOLDER + " $par\n" +
" * @return void^\n" +
" */\n" +
" function bar($par) {\n" +
" }\n" +
Expand Down Expand Up @@ -206,7 +210,8 @@ public void testIssue236311() throws Exception {
"?>", "<?php\n" +
"class MyCls {\n" +
" /**\n" +
" * ^\n" +
" * \n" +
" * @return void^\n" +
" */\n" +
" public static function beginRequest()\n" +
" {\n" +
Expand All @@ -233,7 +238,8 @@ public void testIssue242356() throws Exception {
"interface Iface1 {\n" +
" /**\n" +
" * \n" +
" * @param type $param^\n" +
" * @param type $param\n" +
" * @return void^\n" +
" */\n" +
" public function faceFnc($param);\n" +
"}\n" +
Expand All @@ -254,7 +260,8 @@ public void testResolveProperType_01() throws Exception {
"class Test {\n" +
" /**\n" +
" * \n" +
" * @param SomeClass $someClass^\n" +
" * @param SomeClass $someClass\n" +
" * @return void^\n" +
" */\n" +
" public function getSomething(SomeClass $someClass) {}\n" +
"}";
Expand All @@ -275,7 +282,8 @@ public void testResolveProperType_02() throws Exception {
"class Test {\n" +
" /**\n" +
" * \n" +
" * @param SomeClassAlias $someClass^\n" +
" * @param SomeClassAlias $someClass\n" +
" * @return void^\n" +
" */\n" +
" public function getSomething(SomeClassAlias $someClass) {}\n" +
"}";
Expand All @@ -295,7 +303,8 @@ public void testIssue248213Variadic() throws Exception {
"<?php\n"
+ "/**\n"
+ " * \n"
+ " * @param " + PhpCommentGenerator.TYPE_PLACEHOLDER + " $i^\n"
+ " * @param " + PhpCommentGenerator.TYPE_PLACEHOLDER + " $i\n"
+ " * @return void^\n"
+ " */\n"
+ "function foo(...$i) {\n"
+ "}\n"
Expand All @@ -319,7 +328,8 @@ public void testIssue248213ReferenceVariadic() throws Exception {
+ "class foo {\n"
+ " /**\n"
+ " * \n"
+ " * @param " + PhpCommentGenerator.TYPE_PLACEHOLDER + " $par^\n"
+ " * @param " + PhpCommentGenerator.TYPE_PLACEHOLDER + " $par\n"
+ " * @return void^\n"
+ " */\n"
+ " function bar(&...$par) {\n"
+ " }\n"
Expand Down Expand Up @@ -351,7 +361,8 @@ public void testIssue269104_01() throws Exception {
+ "class Bar {\n"
+ " /**\n"
+ " * \n"
+ " * @param callable $callable^\n"
+ " * @param callable $callable\n"
+ " * @return void^\n"
+ " */\n"
+ " function callableType(callable $callable) {\n"
+ " //...\n"
Expand Down Expand Up @@ -384,7 +395,8 @@ public void testIssue269104_02() throws Exception {
+ "class Bar {\n"
+ " /**\n"
+ " * \n"
+ " * @param int $int^\n"
+ " * @param int $int\n"
+ " * @return void^\n"
+ " */\n"
+ " function intType(int $int) {\n"
+ " //...\n"
Expand Down Expand Up @@ -417,7 +429,8 @@ public void testIssue269104_03() throws Exception {
+ "class Bar {\n"
+ " /**\n"
+ " * \n"
+ " * @param iterable $iterable^\n"
+ " * @param iterable $iterable\n"
+ " * @return void^\n"
+ " */\n"
+ " function iterableType(iterable $iterable) {\n"
+ " //...\n"
Expand Down
Loading