troizet commented on code in PR #5648:
URL: https://github.com/apache/netbeans/pull/5648#discussion_r1135945343


##########
php/php.editor/src/org/netbeans/modules/php/editor/verification/ReturnTypeHintError.java:
##########
@@ -116,13 +118,18 @@ private void checkReturnType(Map<ASTNode, 
Set<ReturnStatement>> returnStatements
                 NamespaceName namespaceName = (NamespaceName) returnType;
                 String name = CodeUtils.extractUnqualifiedName(namespaceName);
                 checkVoidAndNeverReturnStatements(statements, name, hints);
+                checkReturnStatementsWithoutValue(statements, name, hints);
             } else if (returnType instanceof NullableType) {
                 Expression type = ((NullableType) returnType).getType();
                 if (type instanceof NamespaceName) {
                     NamespaceName namespaceName = (NamespaceName) type;
                     String name = 
CodeUtils.extractUnqualifiedName(namespaceName);
                     checkInvalidVoidAndNeverReturnType(type, name, hints);
-                }
+                } 

Review Comment:
   Done.



##########
php/php.editor/src/org/netbeans/modules/php/editor/verification/ReturnTypeHintError.java:
##########
@@ -152,17 +159,40 @@ private void 
checkVoidAndNeverReturnStatements(Set<ReturnStatement> statements,
         "ReturnTypeHintErrorInvalidVoidDesc=\"{0}\" cannot be used with \"?\""
     })
     private void checkInvalidVoidAndNeverReturnType(Expression returnType, 
String name, List<Hint> hints) {
-        if (Type.VOID.equals(name)
+        if (isVoidType(name)
                 || isNeverType(name)) {
             addHint(returnType, 
Bundle.ReturnTypeHintErrorInvalidVoidDesc(name), hints);
         }
     }
 
+    @NbBundle.Messages({
+        "ReturnStatementWithoutValueHintErrorDesc=Return statement must be 
filled with the value"
+    })
+    private void checkReturnStatementsWithoutValue(Set<ReturnStatement> 
statements, String name, List<Hint> hints) {
+        if (!isVoidType(name) && !isNeverType(name)) {
+            // check empty return statement
+            for (ReturnStatement statement: statements) {
+                if (CancelSupport.getDefault().isCancelled()) {
+                    return;
+                }
+                Expression expression = statement.getExpression();
+                if (expression == null) {
+                    addHint(statement, 
Bundle.ReturnStatementWithoutValueHintErrorDesc(), hints);
+                }
+            }
+        }
+    }
+
     private boolean isNeverType(String name) {
         return getPhpVersion(fileObject).hasNeverType()
                 && Type.NEVER.equals(name);
     }
 
+   private boolean isVoidType(String name) {
+        return getPhpVersion(fileObject).hasVoidReturnType()
+                && Type.VOID.equals(name);

Review Comment:
   Done.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to