diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/codegen/MethodProperty.java b/php/php.editor/src/org/netbeans/modules/php/editor/codegen/MethodProperty.java
index 5db950b415a1..6e2bb457ae03 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/codegen/MethodProperty.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/codegen/MethodProperty.java
@@ -69,7 +69,7 @@ private static String formatName(final MethodElement method, PhpVersion phpVersi
final String nameAndParams = method.asString(PrintAs.NameAndParamsDeclaration, TypeNameResolverImpl.forNull(), phpVersion);
final String returnTypeString = method.asString(PrintAs.ReturnTypes, TypeNameResolverImpl.forNull(), phpVersion);
final String[] split = nameAndParams.split("\\(");
- if (returnTypes.isEmpty() || returnTypeString.isEmpty()) {
+ if (returnTypes.isEmpty() || returnTypeString.isEmpty() || method.isConstructor()) {
return String.format("%s(%s", split[0], split[1]); // NOI18N
}
return String.format("%s(%s : %s", split[0], split[1], returnTypeString); // NOI18N
diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/elements/BaseFunctionElementSupport.java b/php/php.editor/src/org/netbeans/modules/php/editor/elements/BaseFunctionElementSupport.java
index b2b6678bdafd..e5b6e78613a9 100644
--- a/php/php.editor/src/org/netbeans/modules/php/editor/elements/BaseFunctionElementSupport.java
+++ b/php/php.editor/src/org/netbeans/modules/php/editor/elements/BaseFunctionElementSupport.java
@@ -109,7 +109,8 @@ public final String asString(PrintAs as, BaseFunctionElement element, TypeNameRe
Collection returns1 = getReturnTypes();
// we can also write the union type in phpdoc e.g. @return int|float
// check whether the union type is the actual declared return type to avoid adding the union type for phpdoc
- if (returns1.size() == 1 || isReturnUnionType() || isReturnIntersectionType()) {
+ // I also prevent the return type from being generated in the PHPDoc when it is a constructor.
+ if (!element.getName().equals(MethodElement.CONSTRUCTOR_NAME) && (returns1.size() == 1 || isReturnUnionType() || isReturnIntersectionType())) {
String returnType = asString(PrintAs.ReturnTypes, element, typeNameResolver, phpVersion);
if (StringUtils.hasText(returnType)) {
boolean isNullableType = CodeUtils.isNullableType(returnType);