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


##########
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:
   I am not sure, but I would expect that if we swap the conditions, the 
performance should be better (comparing strings should be faster than working 
with file objects).
   



-- 
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