From da5c98875624b4215211a6df991d0403b20ccc45 Mon Sep 17 00:00:00 2001 From: Junichi Yamamoto Date: Tue, 21 Jan 2025 19:07:07 +0900 Subject: [PATCH] PHP 8.4 Support: Asymmetric Visibility v2 (Part 5) - https://github.com/apache/netbeans/issues/8035 - https://wiki.php.net/rfc#php_84 - https://wiki.php.net/rfc/asymmetric-visibility-v2 - Add unit tests for formatter - set visibility (`private(set) int $i;`) - final property (`final public string $s = "string";`) --- .../asymmetricVisibilityAnonClass_01.php | 108 ++++++++++++++++ ...metricVisibilityAnonClass_01.php.formatted | 109 +++++++++++++++++ .../asymmetricVisibilityAnonClass_02.php | 108 ++++++++++++++++ ...metricVisibilityAnonClass_02.php.formatted | 110 +++++++++++++++++ .../php84/asymmetricVisibilityClass_01.php | 108 ++++++++++++++++ ...asymmetricVisibilityClass_01.php.formatted | 110 +++++++++++++++++ .../php84/asymmetricVisibilityClass_02.php | 108 ++++++++++++++++ ...asymmetricVisibilityClass_02.php.formatted | 110 +++++++++++++++++ ...ibilityConstructorPropertyPromotion_01.php | 112 +++++++++++++++++ ...structorPropertyPromotion_01.php.formatted | 115 ++++++++++++++++++ ...ibilityConstructorPropertyPromotion_02.php | 112 +++++++++++++++++ ...structorPropertyPromotion_02.php.formatted | 115 ++++++++++++++++++ .../php84/asymmetricVisibilityTrait_01.php | 108 ++++++++++++++++ ...asymmetricVisibilityTrait_01.php.formatted | 110 +++++++++++++++++ .../php84/asymmetricVisibilityTrait_02.php | 108 ++++++++++++++++ ...asymmetricVisibilityTrait_02.php.formatted | 110 +++++++++++++++++ .../php84/finalFieldsAnonClass_01.php | 111 +++++++++++++++++ .../finalFieldsAnonClass_01.php.formatted | 100 +++++++++++++++ .../php84/finalFieldsAnonClass_02.php | 111 +++++++++++++++++ .../finalFieldsAnonClass_02.php.formatted | 100 +++++++++++++++ .../formatting/php84/finalFieldsClass_01.php | 111 +++++++++++++++++ .../php84/finalFieldsClass_01.php.formatted | 100 +++++++++++++++ .../formatting/php84/finalFieldsClass_02.php | 111 +++++++++++++++++ .../php84/finalFieldsClass_02.php.formatted | 100 +++++++++++++++ .../formatting/php84/finalFieldsTrait_01.php | 111 +++++++++++++++++ .../php84/finalFieldsTrait_01.php.formatted | 100 +++++++++++++++ .../formatting/php84/finalFieldsTrait_02.php | 111 +++++++++++++++++ .../php84/finalFieldsTrait_02.php.formatted | 100 +++++++++++++++ .../php/editor/indent/PHPFormatterTest.java | 71 +++++++++++ 29 files changed, 3098 insertions(+) create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityAnonClass_01.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityAnonClass_01.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityAnonClass_02.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityAnonClass_02.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityClass_01.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityClass_01.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityClass_02.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityClass_02.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityConstructorPropertyPromotion_01.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityConstructorPropertyPromotion_01.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityConstructorPropertyPromotion_02.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityConstructorPropertyPromotion_02.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityTrait_01.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityTrait_01.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityTrait_02.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityTrait_02.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/finalFieldsAnonClass_01.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/finalFieldsAnonClass_01.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/finalFieldsAnonClass_02.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/finalFieldsAnonClass_02.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/finalFieldsClass_01.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/finalFieldsClass_01.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/finalFieldsClass_02.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/finalFieldsClass_02.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/finalFieldsTrait_01.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/finalFieldsTrait_01.php.formatted create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/finalFieldsTrait_02.php create mode 100644 php/php.editor/test/unit/data/testfiles/formatting/php84/finalFieldsTrait_02.php.formatted diff --git a/php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityAnonClass_01.php b/php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityAnonClass_01.php new file mode 100644 index 000000000000..3934802010c1 --- /dev/null +++ b/php/php.editor/test/unit/data/testfiles/formatting/php84/asymmetricVisibilityAnonClass_01.php @@ -0,0 +1,108 @@ + options = new HashMap<>(FmtOptions.getDefaults()); reformatFileContents("testfiles/formatting/php84/newWithoutParentheses_02.php", options); } + + // GH-8035 PHP 8.4: Asymmetric Visibility + public void testAsymmetricVisibilityClass_01() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/asymmetricVisibilityClass_01.php", options); + } + + public void testAsymmetricVisibilityClass_02() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/asymmetricVisibilityClass_02.php", options); + } + + public void testAsymmetricVisibilityTrait_01() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/asymmetricVisibilityTrait_01.php", options); + } + + public void testAsymmetricVisibilityTrait_02() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/asymmetricVisibilityTrait_02.php", options); + } + + public void testAsymmetricVisibilityAnonClass_01() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/asymmetricVisibilityAnonClass_01.php", options); + } + + public void testAsymmetricVisibilityAnonClass_02() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/asymmetricVisibilityAnonClass_02.php", options); + } + + public void testAsymmetricVisibilityConstructorPropertyPromotion_01() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/asymmetricVisibilityConstructorPropertyPromotion_01.php", options); + } + + public void testAsymmetricVisibilityConstructorPropertyPromotion_02() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/asymmetricVisibilityConstructorPropertyPromotion_02.php", options); + } + + public void testFinalFieldsClass_01() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/finalFieldsClass_01.php", options); + } + + public void testFinalFieldsClass_02() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/finalFieldsClass_02.php", options); + } + + public void testFinalFieldsTrait_01() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/finalFieldsTrait_01.php", options); + } + + public void testFinalFieldsTrait_02() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/finalFieldsTrait_02.php", options); + } + + public void testFinalFieldsAnonClass_01() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/finalFieldsAnonClass_01.php", options); + } + + public void testFinalFieldsAnonClass_02() throws Exception { + HashMap options = new HashMap<>(FmtOptions.getDefaults()); + reformatFileContents("testfiles/formatting/php84/finalFieldsAnonClass_02.php", options); + } }