From a8c9cd8b68ed0e1ae5f8b2140ce3152449c8bc25 Mon Sep 17 00:00:00 2001 From: Alexey Borokhvostov Date: Mon, 20 May 2024 22:52:55 +0700 Subject: [PATCH] PHP: removed built-in type real - deleted the built-in type real (php does not have a built-in real type: https://www.php.net/manual/en/language.types.intro.php Also see the warning under "Scalar Types": https://www.php.net/manual/en/language.types.declarations.php) - fixed broken tests - new tests added - fixes generation of return type real instead of float for a method when overriding a base class method with an autocomplete - fixes generation of return type real instead of float for a function in phpDoc --- php/php.editor/nbproject/project.properties | 2 +- .../modules/php/editor/model/impl/Type.java | 4 +- .../php/editor/parser/ASTPHP5Parser.java | 10 ++--- .../php/editor/parser/ASTPHP5Symbols.java | 2 +- .../parser/astnodes/CastExpression.java | 7 +++- .../php/editor/parser/astnodes/Scalar.java | 8 +++- .../typinghooks/PhpCommentGenerator.java | 1 + .../verification/PHP54UnhandledError.java | 2 +- .../verification/PHP74UnhandledError.java | 1 + .../verification/PHP81UnhandledError.java | 1 + .../parser/TextSearchQuery.pass | 4 +- .../parser/binaryNotation_01.pass | 2 +- .../parser/binaryNotation_02.pass | 2 +- .../parser/binaryNotation_03.pass | 2 +- .../parser/issueGH5933_01.pass | 2 +- .../parser/netbeans1563_03.pass | 2 +- .../numericLiteralSeparatorParseError_03.pass | 2 +- .../php74/numericLiteralSeparator_01.pass | 38 +++++++++---------- .../parser/php74/typedPropertiesClass.pass | 2 +- .../parser/php74/typedPropertiesTrait.pass | 2 +- ...alIntegerLiteralNotationParseError_03.pass | 2 +- ...alIntegerLiteralNotationParseError_05.pass | 2 +- .../parser/php83/typedClassConstants_01.pass | 2 +- .../data/testfiles/actions/useCase_11.php | 29 ++++++++++++++ .../actions/useCase_11.php.usedNames | 2 + .../data/testfiles/actions/useCase_12.php | 29 ++++++++++++++ .../actions/useCase_12.php.usedNames | 2 + ...nceOverrideMethodWithGuessingFloatType.php | 29 ++++++++++++++ ...rideMethodWithGuessingFloatType_01.codegen | 3 ++ ...rideMethodWithGuessingFloatType_02.codegen | 3 ++ .../functionGuessingFloatReturnType.php | 37 ++++++++++++++++++ ...estFunctionGuessingFloatReturnType_01.html | 9 +++++ ...estFunctionGuessingFloatReturnType_02.html | 9 +++++ .../actions/UsedNamesCollectorTest.java | 8 ++++ .../SelectedPropertyMethodsCreatorTest.java | 12 ++++++ .../completion/PHPCCDocumentationTest.java | 8 ++++ .../typinghooks/PhpCommentGeneratorTest.java | 18 +++++++++ php/php.editor/tools/ASTPHP5Parser.cup | 6 +-- 38 files changed, 258 insertions(+), 48 deletions(-) create mode 100644 php/php.editor/test/unit/data/testfiles/actions/useCase_11.php create mode 100644 php/php.editor/test/unit/data/testfiles/actions/useCase_11.php.usedNames create mode 100644 php/php.editor/test/unit/data/testfiles/actions/useCase_12.php create mode 100644 php/php.editor/test/unit/data/testfiles/actions/useCase_12.php.usedNames create mode 100644 php/php.editor/test/unit/data/testfiles/codegen/testInstanceOverrideMethodWithGuessingFloatType/testInstanceOverrideMethodWithGuessingFloatType.php create mode 100644 php/php.editor/test/unit/data/testfiles/codegen/testInstanceOverrideMethodWithGuessingFloatType/testInstanceOverrideMethodWithGuessingFloatType.php.testInstanceOverrideMethodWithGuessingFloatType_01.codegen create mode 100644 php/php.editor/test/unit/data/testfiles/codegen/testInstanceOverrideMethodWithGuessingFloatType/testInstanceOverrideMethodWithGuessingFloatType.php.testInstanceOverrideMethodWithGuessingFloatType_02.codegen create mode 100644 php/php.editor/test/unit/data/testfiles/completion/documentation/functionGuessingFloatReturnType.php create mode 100644 php/php.editor/test/unit/data/testfiles/completion/documentation/functionGuessingFloatReturnType.php.testFunctionGuessingFloatReturnType_01.html create mode 100644 php/php.editor/test/unit/data/testfiles/completion/documentation/functionGuessingFloatReturnType.php.testFunctionGuessingFloatReturnType_02.html diff --git a/php/php.editor/nbproject/project.properties b/php/php.editor/nbproject/project.properties index c5f700d77b53..2e7d2c160f79 100644 --- a/php/php.editor/nbproject/project.properties +++ b/php/php.editor/nbproject/project.properties @@ -18,7 +18,7 @@ javac.source=1.8 javac.compilerargs=-Xlint -Xlint:-serial nbjavac.ignore.missing.enclosing=**/CUP$ASTPHP5Parser$actions.class nbm.needs.restart=true -spec.version.base=2.39.0 +spec.version.base=2.40.0 release.external/predefined_vars-1.0.zip=docs/predefined_vars.zip sigtest.gen.fail.on.error=false diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/Type.java b/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/Type.java index 079454b4d6ee..3ac60d510cd5 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/Type.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/Type.java @@ -111,7 +111,7 @@ private Type() { public static boolean isPrimitive(String typeName) { boolean retval = false; if (BOOL.equals(typeName) || INT.equals(typeName) - || INTEGER.equals(typeName) || FLOAT.equals(typeName) || REAL.equals(typeName) + || INTEGER.equals(typeName) || FLOAT.equals(typeName) || ARRAY.equals(typeName) || OBJECT.equals(typeName) || MIXED.equals(typeName) || NUMBER.equals(typeName) || CALLBACK.equals(typeName) || RESOURCE.equals(typeName) || DOUBLE.equals(typeName) || STRING.equals(typeName) || NULL.equals(typeName) @@ -125,7 +125,7 @@ public static boolean isPrimitive(String typeName) { public static boolean isPrimitiveAlias(String typeName) { boolean retval = false; - if (BOOLEAN.equals(typeName)) { + if (BOOLEAN.equals(typeName) || REAL.equals(typeName)) { retval = true; } return retval; diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Parser.java b/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Parser.java index 82660b7a5a0c..ed1e4c928b14 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Parser.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Parser.java @@ -19,7 +19,7 @@ //---------------------------------------------------- // The following code was generated by CUP v0.11a beta 20060608 -// Sat Dec 09 20:59:16 JST 2023 +// Tue May 14 21:41:03 NOVT 2024 //---------------------------------------------------- package org.netbeans.modules.php.editor.parser; @@ -30,7 +30,7 @@ import org.openide.util.Pair; /** CUP v0.11a beta 20060608 generated parser. - * @version Sat Dec 09 20:59:16 JST 2023 + * @version Tue May 14 21:41:03 NOVT 2024 */ @org.netbeans.api.annotations.common.SuppressWarnings({"EI_EXPOSE_REP", "MS_PKGPROTECT", "BC_BAD_CAST_TO_CONCRETE_COLLECTION"}) public class ASTPHP5Parser extends java_cup.runtime.lr_parser { @@ -11184,7 +11184,7 @@ public final java_cup.runtime.Symbol fakeMethod400to499( int exprright = ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()).right; Expression expr = (Expression)((java_cup.runtime.Symbol) CUP$ASTPHP5Parser$stack.peek()).value; - RESULT = new CastExpression(tokenleft, exprright, expr , CastExpression.Type.REAL); + RESULT = new CastExpression(tokenleft, exprright, expr , CastExpression.Type.FLOAT); CUP$ASTPHP5Parser$result = parser.getSymbolFactory().newSymbol("expr_without_variable_and_class_instance",53, ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.elementAt(CUP$ASTPHP5Parser$top-1)), ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()), RESULT); } @@ -12805,7 +12805,7 @@ public final java_cup.runtime.Symbol fakeMethod500to599( int scalarright = ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()).right; String scalar = (String)((java_cup.runtime.Symbol) CUP$ASTPHP5Parser$stack.peek()).value; - Scalar s = new Scalar(scalarleft, scalarright, scalar, Scalar.Type.REAL); + Scalar s = new Scalar(scalarleft, scalarright, scalar, Scalar.Type.FLOAT); RESULT = s; CUP$ASTPHP5Parser$result = parser.getSymbolFactory().newSymbol("common_scalar",58, ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()), RESULT); @@ -16735,7 +16735,7 @@ public final java_cup.runtime.Symbol fakeMethod700to799( int numright = ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()).right; String num = (String)((java_cup.runtime.Symbol) CUP$ASTPHP5Parser$stack.peek()).value; - Scalar scalar = new Scalar(numleft,numright, num, Scalar.Type.REAL); + Scalar scalar = new Scalar(numleft,numright, num, Scalar.Type.FLOAT); RESULT = scalar; CUP$ASTPHP5Parser$result = parser.getSymbolFactory().newSymbol("encaps_var_offset",100, ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()), ((java_cup.runtime.Symbol)CUP$ASTPHP5Parser$stack.peek()), RESULT); diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Symbols.java b/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Symbols.java index 73864e60237c..f14f2512ccf4 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Symbols.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/parser/ASTPHP5Symbols.java @@ -19,7 +19,7 @@ //---------------------------------------------------- // The following code was generated by CUP v0.11a beta 20060608 -// Sat Dec 09 20:59:16 JST 2023 +// Tue May 14 21:41:03 NOVT 2024 //---------------------------------------------------- package org.netbeans.modules.php.editor.parser; diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/CastExpression.java b/php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/CastExpression.java index 808316bc4ad1..d698f28ab70c 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/CastExpression.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/CastExpression.java @@ -27,12 +27,17 @@ public class CastExpression extends Expression { public enum Type { INT, // 'int' + /** + * @deprecated will be removed in the future, to follow PHP type system, + * use {@link Type#FLOAT} instead + */ REAL, // 'real' STRING, // 'string' ARRAY, // 'array' OBJECT, // 'object' BOOL, // 'bool' - UNSET// 'unset' + UNSET,// 'unset' + FLOAT, // 'float' } private Expression expression; diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/Scalar.java b/php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/Scalar.java index 693733d20787..cd70b0cbdda2 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/Scalar.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/parser/astnodes/Scalar.java @@ -29,11 +29,15 @@ public class Scalar extends Expression { public enum Type { INT, // 'int' + /** + * @deprecated will be removed in the future, to follow PHP type system, + * use {@link Type#FLOAT} instead + */ REAL, // 'real' STRING, // 'string' UNKNOWN, // unknown scalar in quote expression - SYSTEM // system scalars (__CLASS__ / ...) - + SYSTEM, // system scalars (__CLASS__ / ...) + FLOAT // 'float' } // 'int' //public static final int TYPE_INT = 0; diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGenerator.java b/php/php.editor/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGenerator.java index 9ac7a4bcc2f5..f23dcae025c8 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGenerator.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGenerator.java @@ -542,6 +542,7 @@ public void scan(ASTNode node) { type = Type.INTEGER; break; case REAL: + case FLOAT: type = Type.FLOAT; break; case STRING: diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP54UnhandledError.java b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP54UnhandledError.java index bd7a4b3df35c..34bdb65c0633 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP54UnhandledError.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP54UnhandledError.java @@ -156,7 +156,7 @@ public void visit(Scalar node) { if (CancelSupport.getDefault().isCancelled()) { return; } - if (node.getScalarType().equals(Scalar.Type.REAL) && node.getStringValue().startsWith(BINARY_PREFIX)) { + if ((node.getScalarType().equals(Scalar.Type.FLOAT) || node.getScalarType().equals(Scalar.Type.REAL)) && node.getStringValue().startsWith(BINARY_PREFIX)) { createError(node); } if (node.getScalarType().equals(Scalar.Type.SYSTEM) && "__TRAIT__".equals(node.getStringValue())) { // NOI18N diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP74UnhandledError.java b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP74UnhandledError.java index fdd2e7b9e580..fdf32e2cc379 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP74UnhandledError.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP74UnhandledError.java @@ -149,6 +149,7 @@ private void checkUnpackableArrayElement(UnpackableArrayElement node) { private void checkNumericLiteralSeparator(Scalar node) { if (node.getScalarType() == Scalar.Type.INT + || node.getScalarType() == Scalar.Type.FLOAT || node.getScalarType() == Scalar.Type.REAL) { if (node.getStringValue().contains("_")) { // NOI18N createError(node); diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP81UnhandledError.java b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP81UnhandledError.java index 5c9eb9f5b54b..d502b4598280 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP81UnhandledError.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/verification/PHP81UnhandledError.java @@ -252,6 +252,7 @@ private void checkExplicitOctalNotation(Scalar scalar) { private boolean isNumber(Scalar scalar) { return scalar.getScalarType() == Scalar.Type.INT + || scalar.getScalarType() == Scalar.Type.FLOAT || scalar.getScalarType() == Scalar.Type.REAL; } diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/TextSearchQuery.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/TextSearchQuery.pass index 9f0e6538aa37..222b5d0b7063 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/TextSearchQuery.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/TextSearchQuery.pass @@ -16986,7 +16986,7 @@ - + @@ -17102,7 +17102,7 @@ - + diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/binaryNotation_01.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/binaryNotation_01.pass index b902f7f77462..3da29bdc371d 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/binaryNotation_01.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/binaryNotation_01.pass @@ -28,7 +28,7 @@ - + diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/binaryNotation_02.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/binaryNotation_02.pass index e5e90dd5bd6a..4eb78bc823e0 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/binaryNotation_02.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/binaryNotation_02.pass @@ -28,7 +28,7 @@ - + diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/binaryNotation_03.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/binaryNotation_03.pass index a99d4b6f719d..e87f0faa6d7d 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/binaryNotation_03.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/binaryNotation_03.pass @@ -28,7 +28,7 @@ - + diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/issueGH5933_01.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/issueGH5933_01.pass index 7c82547b524a..4b3129371aab 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/issueGH5933_01.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/issueGH5933_01.pass @@ -449,7 +449,7 @@ - + diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_03.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_03.pass index be326e27a81f..cde4b5058889 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_03.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/netbeans1563_03.pass @@ -54,7 +54,7 @@ - + diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/numericLiteralSeparatorParseError_03.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/numericLiteralSeparatorParseError_03.pass index c2c270f6296a..a95258f4a6cb 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/numericLiteralSeparatorParseError_03.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/numericLiteralSeparatorParseError_03.pass @@ -25,7 +25,7 @@ - + diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/numericLiteralSeparator_01.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/numericLiteralSeparator_01.pass index 2b4174ead5d2..14d525c0f615 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/numericLiteralSeparator_01.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/numericLiteralSeparator_01.pass @@ -296,7 +296,7 @@ - + @@ -304,7 +304,7 @@ - + @@ -312,7 +312,7 @@ - + @@ -332,34 +332,34 @@ - + - + - + - + - + - + - + - + - + - + @@ -371,22 +371,22 @@ - + - + - + - + - + - + diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesClass.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesClass.pass index db75ee66dd24..043975e3fe3b 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesClass.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesClass.pass @@ -689,7 +689,7 @@ - + diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesTrait.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesTrait.pass index d999bed42b31..1f5363c84c3d 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesTrait.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php74/typedPropertiesTrait.pass @@ -685,7 +685,7 @@ - + diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php81/explicitOctalIntegerLiteralNotationParseError_03.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php81/explicitOctalIntegerLiteralNotationParseError_03.pass index 7624c3300fd1..e584f61480f4 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php81/explicitOctalIntegerLiteralNotationParseError_03.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php81/explicitOctalIntegerLiteralNotationParseError_03.pass @@ -25,7 +25,7 @@ - + diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php81/explicitOctalIntegerLiteralNotationParseError_05.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php81/explicitOctalIntegerLiteralNotationParseError_05.pass index ce8a9cd9909e..53fea71589de 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php81/explicitOctalIntegerLiteralNotationParseError_05.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php81/explicitOctalIntegerLiteralNotationParseError_05.pass @@ -21,7 +21,7 @@ - + diff --git a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php83/typedClassConstants_01.pass b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php83/typedClassConstants_01.pass index 817aea5a99f2..7bd482ea53c0 100644 --- a/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php83/typedClassConstants_01.pass +++ b/php/php.editor/test/unit/data/goldenfiles/org/netbeans/modules/php/editor/parser/ASTPHP5ParserTest/parser/php83/typedClassConstants_01.pass @@ -1328,7 +1328,7 @@ - + diff --git a/php/php.editor/test/unit/data/testfiles/actions/useCase_11.php b/php/php.editor/test/unit/data/testfiles/actions/useCase_11.php new file mode 100644 index 000000000000..5d1c29623c67 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/actions/useCase_11.php @@ -0,0 +1,29 @@ + diff --git a/php/php.editor/test/unit/data/testfiles/actions/useCase_11.php.usedNames b/php/php.editor/test/unit/data/testfiles/actions/useCase_11.php.usedNames new file mode 100644 index 000000000000..9d5c3c730840 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/actions/useCase_11.php.usedNames @@ -0,0 +1,2 @@ +Name: real + real --> real:863 diff --git a/php/php.editor/test/unit/data/testfiles/actions/useCase_12.php b/php/php.editor/test/unit/data/testfiles/actions/useCase_12.php new file mode 100644 index 000000000000..7888cbecea6c --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/actions/useCase_12.php @@ -0,0 +1,29 @@ + diff --git a/php/php.editor/test/unit/data/testfiles/actions/useCase_12.php.usedNames b/php/php.editor/test/unit/data/testfiles/actions/useCase_12.php.usedNames new file mode 100644 index 000000000000..7b8d40967354 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/actions/useCase_12.php.usedNames @@ -0,0 +1,2 @@ +Name: real + real --> real:860 diff --git a/php/php.editor/test/unit/data/testfiles/codegen/testInstanceOverrideMethodWithGuessingFloatType/testInstanceOverrideMethodWithGuessingFloatType.php b/php/php.editor/test/unit/data/testfiles/codegen/testInstanceOverrideMethodWithGuessingFloatType/testInstanceOverrideMethodWithGuessingFloatType.php new file mode 100644 index 000000000000..67072b5f77bd --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/codegen/testInstanceOverrideMethodWithGuessingFloatType/testInstanceOverrideMethodWithGuessingFloatType.php @@ -0,0 +1,29 @@ + +
Code completion result for source line:
+testFloatReturn|Type_01();
+(QueryType=COMPLETION, prefixSearch=false, caseSensitive=true)
+METHOD     testFloatReturnType_01()        [PUBLIC]   functionGuessingFloatReturnType.php
+

Documentation:

testFloatReturnType_01


+

Returns:

+ +
Type:float
diff --git a/php/php.editor/test/unit/data/testfiles/completion/documentation/functionGuessingFloatReturnType.php.testFunctionGuessingFloatReturnType_02.html b/php/php.editor/test/unit/data/testfiles/completion/documentation/functionGuessingFloatReturnType.php.testFunctionGuessingFloatReturnType_02.html new file mode 100644 index 000000000000..9eb9b1b77646 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/documentation/functionGuessingFloatReturnType.php.testFunctionGuessingFloatReturnType_02.html @@ -0,0 +1,9 @@ + +
Code completion result for source line:
+testFloatReturnTypeWithUnion|Type_01();
+(QueryType=COMPLETION, prefixSearch=false, caseSensitive=true)
+METHOD     testFloatReturnTypeWithUnionTy  [PUBLIC]   functionGuessingFloatReturnType.php
+

Documentation:

testFloatReturnTypeWithUnionType_01


+

Returns:

+ +
Type:string | float
diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/actions/UsedNamesCollectorTest.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/actions/UsedNamesCollectorTest.java index c27ce585df37..0ac4f94b76fa 100644 --- a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/actions/UsedNamesCollectorTest.java +++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/actions/UsedNamesCollectorTest.java @@ -84,6 +84,14 @@ public void testUseCase_10() throws Exception { performTest("useCase_10", "class Class^Name {"); } + public void testUseCase_11() throws Exception { + performTest("useCase_11", "class Class^Name {"); + } + + public void testUseCase_12() throws Exception { + performTest("useCase_12", "class Class^Name {"); + } + public void testIssue209755() throws Exception { performTest("issue209755", "class Class^Name {"); } diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/codegen/SelectedPropertyMethodsCreatorTest.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/codegen/SelectedPropertyMethodsCreatorTest.java index 1ea04d3c0d01..52f4b89734a9 100644 --- a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/codegen/SelectedPropertyMethodsCreatorTest.java +++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/codegen/SelectedPropertyMethodsCreatorTest.java @@ -234,6 +234,18 @@ public void testInstanceOverrideMethodWithGuessingArrayType_02() throws Exceptio selectProperties(cgsInfo.getPossibleMethods(), "myFoo"), new SinglePropertyMethodCreator.InheritedMethodCreator(cgsInfo))); } + public void testInstanceOverrideMethodWithGuessingFloatType_01() throws Exception { + CGSInfo cgsInfo = getCgsInfo("class Bar extends Foo {^", PhpVersion.PHP_70); + checkResult(new SelectedPropertyMethodsCreator().create( + selectProperties(cgsInfo.getPossibleMethods(), "myFoo"), new SinglePropertyMethodCreator.InheritedMethodCreator(cgsInfo))); + } + + public void testInstanceOverrideMethodWithGuessingFloatType_02() throws Exception { + CGSInfo cgsInfo = getCgsInfo("class Bar extends Foo {^", PhpVersion.PHP_56); + checkResult(new SelectedPropertyMethodsCreator().create( + selectProperties(cgsInfo.getPossibleMethods(), "myFoo"), new SinglePropertyMethodCreator.InheritedMethodCreator(cgsInfo))); + } + public void testGetterWithType_01() throws Exception { CGSInfo cgsInfo = getCgsInfo("class Foo {^", PhpVersion.PHP_70); cgsInfo.setPublicModifier(false); diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCCDocumentationTest.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCCDocumentationTest.java index 372fca21f5b8..71efab23be54 100644 --- a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCCDocumentationTest.java +++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHPCCDocumentationTest.java @@ -654,6 +654,14 @@ public void testPhpDocAndFunctionInDifferentBlocks_02() throws Exception { checkCompletionDocumentation("testfiles/completion/documentation/phpDocAndFunctionInDifferentBlocks.php", "func2^(1)", false, ""); } + public void testFunctionGuessingFloatReturnType_01() throws Exception { + checkCompletionDocumentation("testfiles/completion/documentation/functionGuessingFloatReturnType.php", "testFloatReturn^Type_01();", false, ""); + } + + public void testFunctionGuessingFloatReturnType_02() throws Exception { + checkCompletionDocumentation("testfiles/completion/documentation/functionGuessingFloatReturnType.php", "testFloatReturnTypeWithUnion^Type_01();", false, ""); + } + @Override protected String alterDocumentationForTest(String documentation) { int start = documentation.indexOf("file:"); diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGeneratorTest.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGeneratorTest.java index 58af1bed256a..33cbb99dad10 100644 --- a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGeneratorTest.java +++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/typinghooks/PhpCommentGeneratorTest.java @@ -846,6 +846,24 @@ public void testFunctionGuessingBoolReturnType() throws Exception { "?>\n"); } + public void testFunctionGuessingFloatReturnType() throws Exception { + insertBreak( "\n", + "\n"); + } + public void testFunctionGuessingNullReturnType() throws Exception { insertBreak( "