From 2e153cd25e52dd1f9f118b17fc19b66be9fa7056 Mon Sep 17 00:00:00 2001 From: Damiano Improta Date: Thu, 26 Feb 2026 16:07:26 +0100 Subject: [PATCH 1/2] Return type not added to constructor override --- .../modules/php/editor/completion/PHPCompletionItem.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java index 651cb6d1398c..977d48e7b2ea 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java @@ -1452,11 +1452,14 @@ protected String getNameAndFunctionBodyForTemplate() { if (phpVersion != null && phpVersion.compareTo(PhpVersion.PHP_70) >= 0) { Collection returnTypes = getBaseFunctionElement().getReturnTypes(); + // check whether the method in question is the constructor. If it is, the return type should not be added. + boolean isConstructor = getBaseFunctionElement() instanceof MethodElement + && ((MethodElement) getBaseFunctionElement()).isConstructor(); // we can also write a union type in phpdoc e.g. @return int|float // check whether the union type is actual declared return type to avoid adding the union type for phpdoc - if (returnTypes.size() == 1 + if (!isConstructor && (returnTypes.size() == 1 || getBaseFunctionElement().isReturnUnionType() - || getBaseFunctionElement().isReturnIntersectionType()) { + || getBaseFunctionElement().isReturnIntersectionType())) { String returnType = getBaseFunctionElement().asString(PrintAs.ReturnTypes, typeNameResolver, phpVersion); if (StringUtils.hasText(returnType)) { boolean nullableType = CodeUtils.isNullableType(returnType); From 7a4138f39083dc0240ec2d668f9d4e41d45a9774 Mon Sep 17 00:00:00 2001 From: Damiano Improta Date: Sun, 8 Mar 2026 23:51:35 +0100 Subject: [PATCH 2/2] Reduced the check to only the specific label "__construct", and not also the class name --- .../modules/php/editor/completion/PHPCompletionItem.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java index 977d48e7b2ea..c5e458e61cc7 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCompletionItem.java @@ -1454,7 +1454,7 @@ protected String getNameAndFunctionBodyForTemplate() { Collection returnTypes = getBaseFunctionElement().getReturnTypes(); // check whether the method in question is the constructor. If it is, the return type should not be added. boolean isConstructor = getBaseFunctionElement() instanceof MethodElement - && ((MethodElement) getBaseFunctionElement()).isConstructor(); + && ((MethodElement) getBaseFunctionElement()).getName().equals(MethodElement.CONSTRUCTOR_NAME); // we can also write a union type in phpdoc e.g. @return int|float // check whether the union type is actual declared return type to avoid adding the union type for phpdoc if (!isConstructor && (returnTypes.size() == 1