From 419c0ed1365212b878a47df73b197c375475f5a7 Mon Sep 17 00:00:00 2001 From: Junichi Yamamoto Date: Fri, 26 Nov 2021 11:36:33 +0900 Subject: [PATCH] [NETBEANS-5599] PHP 8.1 Support: Never type (Part 2) https://issues.apache.org/jira/browse/NETBEANS-5599 RFC: https://wiki.php.net/rfc/noreturn_type - Fix the code completion - Add and fix unit tests for the code completion --- .../completion/CompletionContextFinder.java | 1 + .../editor/completion/PHPCodeCompletion.java | 2 + ...eturnTypes.php.testReturnType01.completion | 1 + ...eturnTypes.php.testReturnType03.completion | 1 + ...eturnTypes.php.testReturnType05.completion | 1 + ...eturnTypes.php.testReturnType07.completion | 1 + ...eturnTypes.php.testReturnType12.completion | 1 + ...eturnTypes.php.testReturnType13.completion | 1 + ...eturnTypes.php.testReturnType14.completion | 1 + ...g01.php.testReturnTypesTyping01.completion | 1 + ...g02.php.testReturnTypesTyping02.completion | 1 + ...g03.php.testReturnTypesTyping03.completion | 1 + ...04.php.testReturnTypesTyping04a.completion | 1 + ...04.php.testReturnTypesTyping04b.completion | 1 + ...g05.php.testReturnTypesTyping05.completion | 1 + ...g06.php.testReturnTypesTyping06.completion | 1 + ...g07.php.testReturnTypesTyping07.completion | 1 + ...08.php.testReturnTypesTyping08a.completion | 1 + ...08.php.testReturnTypesTyping08b.completion | 1 + ...g09.php.testReturnTypesTyping09.completion | 1 + ...g10.php.testReturnTypesTyping10.completion | 1 + ...g11.php.testReturnTypesTyping11.completion | 1 + ...12.php.testReturnTypesTyping12a.completion | 1 + ...12.php.testReturnTypesTyping12b.completion | 1 + ....php.testVoidReturnType_Class01.completion | 1 + ...p.testVoidReturnType_Function01.completion | 1 + ....testVoidReturnType_Interface01.completion | 1 + ...testObjectTypeHint_ReturnType02.completion | 1 + ...ions.php.testArrowFunctions_05a.completion | 1 + .../mixedType.php.testMixedType_05.completion | 1 + ....php.testUnionTypesFunctions_04.completion | 1 + ....php.testUnionTypesFunctions_09.completion | 1 + ....php.testUnionTypesFunctions_15.completion | 1 + ...ds.php.testUnionTypesMethods_07.completion | 1 + .../testNeverReturnType/neverReturnType.php | 47 ++++++++ ...php.testNeverReturnType_Class01.completion | 22 ++++ ...php.testNeverReturnType_Class02.completion | 5 + ...php.testNeverReturnType_Class03.completion | 3 + ....testNeverReturnType_Function01.completion | 19 +++ ....testNeverReturnType_Function02.completion | 5 + ....testNeverReturnType_Function03.completion | 3 + ...testNeverReturnType_Interface01.completion | 22 ++++ ...testNeverReturnType_Interface02.completion | 5 + ...testNeverReturnType_Interface03.completion | 3 + ...php.testNeverReturnType_Trait01.completion | 22 ++++ ...php.testNeverReturnType_Trait02.completion | 5 + ...php.testNeverReturnType_Trait03.completion | 3 + .../completion/PHP81CodeCompletionTest.java | 111 ++++++++++++++++++ 48 files changed, 310 insertions(+) create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php.testNeverReturnType_Class01.completion create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php.testNeverReturnType_Class02.completion create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php.testNeverReturnType_Class03.completion create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php.testNeverReturnType_Function01.completion create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php.testNeverReturnType_Function02.completion create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php.testNeverReturnType_Function03.completion create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php.testNeverReturnType_Interface01.completion create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php.testNeverReturnType_Interface02.completion create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php.testNeverReturnType_Interface03.completion create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php.testNeverReturnType_Trait01.completion create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php.testNeverReturnType_Trait02.completion create mode 100644 php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php.testNeverReturnType_Trait03.completion create mode 100644 php/php.editor/test/unit/src/org/netbeans/modules/php/editor/completion/PHP81CodeCompletionTest.java diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/completion/CompletionContextFinder.java b/php/php.editor/src/org/netbeans/modules/php/editor/completion/CompletionContextFinder.java index 405bb6553e33..2e400f3018ff 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/completion/CompletionContextFinder.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/completion/CompletionContextFinder.java @@ -1157,6 +1157,7 @@ private static boolean isType(Token token) { || id == PHPTokenId.PHP_TYPE_INT || id == PHPTokenId.PHP_TYPE_STRING || id == PHPTokenId.PHP_TYPE_VOID + || id == PHPTokenId.PHP_TYPE_NEVER || id == PHPTokenId.PHP_TYPE_OBJECT || id == PHPTokenId.PHP_TYPE_MIXED || id == PHPTokenId.PHP_SELF diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java index 1c24d79f4dd6..18786dafef5f 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/completion/PHPCodeCompletion.java @@ -534,8 +534,10 @@ public CodeCompletionResult complete(CodeCompletionContext completionContext) { typesForReturnTypeName.remove(Type.FALSE); typesForReturnTypeName.remove(Type.NULL); typesForReturnTypeName.remove(Type.VOID); + typesForReturnTypeName.remove(Type.NEVER); } else if (context == CompletionContext.RETURN_UNION_TYPE_NAME) { typesForReturnTypeName.remove(Type.VOID); + typesForReturnTypeName.remove(Type.NEVER); typesForReturnTypeName.remove(Type.MIXED); } autoCompleteKeywords(completionResult, request, typesForReturnTypeName); diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType01.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType01.completion index 31a8eb9436b7..99193b49ded1 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType01.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType01.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType03.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType03.completion index f2c21cd10bb0..89afcd7704b6 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType03.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType03.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType05.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType05.completion index 710ae9997413..7e7d457b7244 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType05.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType05.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType07.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType07.completion index 87a52e3d1f17..46de26eccb2c 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType07.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType07.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType12.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType12.completion index 645e75b68e80..e544aa44ac5c 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType12.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType12.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType13.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType13.completion index 86816d256453..5b007f383f49 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType13.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType13.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType14.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType14.completion index 2f87824ec617..9ebc1c3ddcdc 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType14.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypes.php.testReturnType14.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping01.php.testReturnTypesTyping01.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping01.php.testReturnTypesTyping01.completion index fa999b41d028..ba3500f01f35 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping01.php.testReturnTypesTyping01.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping01.php.testReturnTypesTyping01.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping02.php.testReturnTypesTyping02.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping02.php.testReturnTypesTyping02.completion index 21a44274f397..d8b590bcf83e 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping02.php.testReturnTypesTyping02.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping02.php.testReturnTypesTyping02.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping03.php.testReturnTypesTyping03.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping03.php.testReturnTypesTyping03.completion index ab84537048c7..40d0dc5c366f 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping03.php.testReturnTypesTyping03.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping03.php.testReturnTypesTyping03.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping04.php.testReturnTypesTyping04a.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping04.php.testReturnTypesTyping04a.completion index 145d43bb39e3..121c98f9ed5e 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping04.php.testReturnTypesTyping04a.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping04.php.testReturnTypesTyping04a.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping04.php.testReturnTypesTyping04b.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping04.php.testReturnTypesTyping04b.completion index af88ad987791..dcb51aecf005 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping04.php.testReturnTypesTyping04b.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping04.php.testReturnTypesTyping04b.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping05.php.testReturnTypesTyping05.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping05.php.testReturnTypesTyping05.completion index d6f073efc9a1..5e650ad5a059 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping05.php.testReturnTypesTyping05.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping05.php.testReturnTypesTyping05.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping06.php.testReturnTypesTyping06.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping06.php.testReturnTypesTyping06.completion index 0af28d9aa93c..19f558f4c8b0 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping06.php.testReturnTypesTyping06.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping06.php.testReturnTypesTyping06.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping07.php.testReturnTypesTyping07.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping07.php.testReturnTypesTyping07.completion index 6595a0c85ebe..1ddddddb0b4a 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping07.php.testReturnTypesTyping07.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping07.php.testReturnTypesTyping07.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping08.php.testReturnTypesTyping08a.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping08.php.testReturnTypesTyping08a.completion index 5199a7a13d0d..c15f604b8114 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping08.php.testReturnTypesTyping08a.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping08.php.testReturnTypesTyping08a.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping08.php.testReturnTypesTyping08b.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping08.php.testReturnTypesTyping08b.completion index d345af27f94d..fc0e87b8d441 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping08.php.testReturnTypesTyping08b.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping08.php.testReturnTypesTyping08b.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping09.php.testReturnTypesTyping09.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping09.php.testReturnTypesTyping09.completion index 9879d6f262e7..99e13c402fc3 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping09.php.testReturnTypesTyping09.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping09.php.testReturnTypesTyping09.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping10.php.testReturnTypesTyping10.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping10.php.testReturnTypesTyping10.completion index efeabf0cc923..f082ecfcc28f 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping10.php.testReturnTypesTyping10.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping10.php.testReturnTypesTyping10.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping11.php.testReturnTypesTyping11.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping11.php.testReturnTypesTyping11.completion index 2348601439d8..bda5b6a77170 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping11.php.testReturnTypesTyping11.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping11.php.testReturnTypesTyping11.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping12.php.testReturnTypesTyping12a.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping12.php.testReturnTypesTyping12a.completion index 0e39f580a1e8..b0b5c6e1353b 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping12.php.testReturnTypesTyping12a.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping12.php.testReturnTypesTyping12a.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping12.php.testReturnTypesTyping12b.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping12.php.testReturnTypesTyping12b.completion index 5888017aad84..b003504c3444 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping12.php.testReturnTypesTyping12b.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php70/base/returnTypesTyping12.php.testReturnTypesTyping12b.completion @@ -55,6 +55,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php71/testVoidReturnType/voidReturnType.php.testVoidReturnType_Class01.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php71/testVoidReturnType/voidReturnType.php.testVoidReturnType_Class01.completion index a74e944ef20d..108ece1bea8e 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php71/testVoidReturnType/voidReturnType.php.testVoidReturnType_Class01.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php71/testVoidReturnType/voidReturnType.php.testVoidReturnType_Class01.completion @@ -12,6 +12,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php71/testVoidReturnType/voidReturnType.php.testVoidReturnType_Function01.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php71/testVoidReturnType/voidReturnType.php.testVoidReturnType_Function01.completion index 0bc229125315..01b812adf132 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php71/testVoidReturnType/voidReturnType.php.testVoidReturnType_Function01.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php71/testVoidReturnType/voidReturnType.php.testVoidReturnType_Function01.completion @@ -12,6 +12,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php71/testVoidReturnType/voidReturnType.php.testVoidReturnType_Interface01.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php71/testVoidReturnType/voidReturnType.php.testVoidReturnType_Interface01.completion index dba10891c5f7..be3bbb242d3f 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php71/testVoidReturnType/voidReturnType.php.testVoidReturnType_Interface01.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php71/testVoidReturnType/voidReturnType.php.testVoidReturnType_Interface01.completion @@ -12,6 +12,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php72/testObjectTypeHint/objectTypeHint.php.testObjectTypeHint_ReturnType02.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php72/testObjectTypeHint/objectTypeHint.php.testObjectTypeHint_ReturnType02.completion index 85b7c692ee20..497e24c02183 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php72/testObjectTypeHint/objectTypeHint.php.testObjectTypeHint_ReturnType02.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php72/testObjectTypeHint/objectTypeHint.php.testObjectTypeHint_ReturnType02.completion @@ -11,6 +11,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctions/arrowFunctions.php.testArrowFunctions_05a.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctions/arrowFunctions.php.testArrowFunctions_05a.completion index ed175d774afc..eee41183ad43 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctions/arrowFunctions.php.testArrowFunctions_05a.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php74/testArrowFunctions/arrowFunctions.php.testArrowFunctions_05a.completion @@ -11,6 +11,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testMixedType/mixedType.php.testMixedType_05.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testMixedType/mixedType.php.testMixedType_05.completion index 53733bdf6748..d0db2f86c245 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testMixedType/mixedType.php.testMixedType_05.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testMixedType/mixedType.php.testMixedType_05.completion @@ -11,6 +11,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesFunctions/unionTypesFunctions.php.testUnionTypesFunctions_04.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesFunctions/unionTypesFunctions.php.testUnionTypesFunctions_04.completion index 440ec2f69741..6dcc6901c311 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesFunctions/unionTypesFunctions.php.testUnionTypesFunctions_04.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesFunctions/unionTypesFunctions.php.testUnionTypesFunctions_04.completion @@ -13,6 +13,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesFunctions/unionTypesFunctions.php.testUnionTypesFunctions_09.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesFunctions/unionTypesFunctions.php.testUnionTypesFunctions_09.completion index bc358a74e493..e1e21f5a4957 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesFunctions/unionTypesFunctions.php.testUnionTypesFunctions_09.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesFunctions/unionTypesFunctions.php.testUnionTypesFunctions_09.completion @@ -13,6 +13,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesFunctions/unionTypesFunctions.php.testUnionTypesFunctions_15.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesFunctions/unionTypesFunctions.php.testUnionTypesFunctions_15.completion index b1f040768b3c..e682e49c4ced 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesFunctions/unionTypesFunctions.php.testUnionTypesFunctions_15.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesFunctions/unionTypesFunctions.php.testUnionTypesFunctions_15.completion @@ -13,6 +13,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD string null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesMethods/unionTypesMethods.php.testUnionTypesMethods_07.completion b/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesMethods/unionTypesMethods.php.testUnionTypesMethods_07.completion index 91d8fbb4b5ff..f7666d4e646e 100644 --- a/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesMethods/unionTypesMethods.php.testUnionTypesMethods_07.completion +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php80/testUnionTypesMethods/unionTypesMethods.php.testUnionTypesMethods_07.completion @@ -18,6 +18,7 @@ KEYWORD float null KEYWORD int null KEYWORD iterable null KEYWORD mixed null +KEYWORD never null KEYWORD null null KEYWORD object null KEYWORD parent null diff --git a/php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php b/php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php new file mode 100644 index 000000000000..f70cf8358a4c --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/completion/lib/php81/testNeverReturnType/neverReturnType.php @@ -0,0 +1,47 @@ + createClassPathsForTest() { + return Collections.singletonMap( + PhpSourcePath.SOURCE_CP, + ClassPathSupport.createClassPath(new FileObject[]{ + FileUtil.toFileObject(new File(getDataDir(), "/testfiles/completion/lib/php81/" + getTestDirName())) + }) + ); + } + + private String getTestDirName() { + String name = getName(); + int indexOf = name.indexOf("_"); + if (indexOf != -1) { + name = name.substring(0, indexOf); + } + return name; + } + + private String getTestPath(String fileName) { + return String.format("testfiles/completion/lib/php81/%s/%s.php", getTestDirName(), fileName); + } + + private void checkCompletion(String fileName, String caretPosition) throws Exception { + checkCompletion(getTestPath(fileName), caretPosition, false); + } + + public void testNeverReturnType_Function01() throws Exception { + checkCompletion("neverReturnType", "function returnType(): ^never { // func"); + } + + public void testNeverReturnType_Function02() throws Exception { + checkCompletion("neverReturnType", "function returnType(): ne^ver { // func"); + } + + public void testNeverReturnType_Function03() throws Exception { + checkCompletion("neverReturnType", "function invalidInParameter(ne^ver $never): never { // func"); + } + + public void testNeverReturnType_Class01() throws Exception { + checkCompletion("neverReturnType", "public function returnType(): ^never { // class"); + } + + public void testNeverReturnType_Class02() throws Exception { + checkCompletion("neverReturnType", "public function returnType(): neve^r { // class"); + } + + public void testNeverReturnType_Class03() throws Exception { + checkCompletion("neverReturnType", "public function invalidInParameter(ne^ver $never): never { // class"); + } + + public void testNeverReturnType_Trait01() throws Exception { + checkCompletion("neverReturnType", "public function returnType(): ^never { // trait"); + } + + public void testNeverReturnType_Trait02() throws Exception { + checkCompletion("neverReturnType", "public function returnType(): neve^r { // trait"); + } + + public void testNeverReturnType_Trait03() throws Exception { + checkCompletion("neverReturnType", "public function invalidInParameter(ne^ver $never): never { // trait"); + } + + public void testNeverReturnType_Interface01() throws Exception { + checkCompletion("neverReturnType", "public function returnType(): ^never; // interface"); + } + + public void testNeverReturnType_Interface02() throws Exception { + checkCompletion("neverReturnType", "public function returnType(): ne^ver; // interface"); + } + + public void testNeverReturnType_Interface03() throws Exception { + checkCompletion("neverReturnType", "public function invalidInParameter(ne^ver $never): never; // interface"); + } + +}