forked from apache/netbeans
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PHP 8.3 Support: Dynamic class constant fetch (Part 3)
- apache#6701 - https://wiki.php.net/rfc/dynamic_class_constant_fetch - Fix the formatter - Add the option of the around spaces for the scope resolution operator (`::`) - Don't add spaces within braces (`{}`) e.g. {$example} - Add unit tests
- Loading branch information
Showing
14 changed files
with
520 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
php/php.editor/test/unit/data/testfiles/formatting/php83/dynamicClassConstantFetch_01.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
class Test { | ||
public const TEST = 'test'; | ||
public const TES = 'TES'; | ||
public const T = 'T'; | ||
public const TEST1 = self :: { 'TEST' }; | ||
public const TEST2 = self ::{ 'TES' . 'T'} ; | ||
public const TEST3 = self :: {self::TES . self::T}; | ||
|
||
public static function method(): void {} | ||
} | ||
|
||
enum EnumTest: string { | ||
case TEST = 'test'; | ||
case TES = 'TES'; | ||
case T = 'T'; | ||
case TEST1 = self::{'TEST'}; | ||
case TEST2 = self ::{'TES' . 'T'} ; | ||
case TEST3 = self::{ self:: TES . self::T }; | ||
} | ||
|
||
function test(string $param = "test"): void { | ||
} | ||
|
||
$variable = 'TEST'; | ||
$e = 'e'; | ||
$test = "Test"; | ||
|
||
Test :: test () ; | ||
|
||
Test :: {"TEST"}; | ||
$test :: {"TEST"}; | ||
Test :: {$variable}; | ||
$test:: { $variable }; | ||
Test::{$variable . $e }; | ||
$test::{ $variable . $e}; | ||
Test:: { strtoupper("test")}; | ||
$test::{ strtoupper("test")}; | ||
Test::{'$variablee' }; | ||
$test :: {'$variablee'}; | ||
Test :: { strtolower("CLASS")}; | ||
$test :: { strtolower("CLASS")}; | ||
Test::{ 1000 }; | ||
$test :: {1000}; | ||
EnumTest ::{[]}; | ||
$test::{ [ ] }; | ||
|
||
Test :: { Test::method() }::{ test($variable) }; | ||
Test::{ test ('test1') } :: { test( 'test2' ) }; | ||
|
||
$test = new Test(); |
76 changes: 76 additions & 0 deletions
76
...atting/php83/dynamicClassConstantFetch_01.php.testDynamicClassConstantFetch_01a.formatted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
class Test { | ||
|
||
public const TEST = 'test'; | ||
public const TES = 'TES'; | ||
public const T = 'T'; | ||
public const TEST1 = self::{'TEST'}; | ||
public const TEST2 = self::{'TES' . 'T'}; | ||
public const TEST3 = self::{self::TES . self::T}; | ||
|
||
public static function method(): void { | ||
|
||
} | ||
} | ||
|
||
enum EnumTest: string { | ||
|
||
case TEST = 'test'; | ||
case TES = 'TES'; | ||
case T = 'T'; | ||
case TEST1 = self::{'TEST'}; | ||
case TEST2 = self::{'TES' . 'T'}; | ||
case TEST3 = self::{self::TES . self::T}; | ||
} | ||
|
||
function test(string $param = "test"): void { | ||
|
||
} | ||
|
||
$variable = 'TEST'; | ||
$e = 'e'; | ||
$test = "Test"; | ||
|
||
Test::test(); | ||
|
||
Test::{"TEST"}; | ||
$test::{"TEST"}; | ||
Test::{$variable}; | ||
$test::{$variable}; | ||
Test::{$variable . $e}; | ||
$test::{$variable . $e}; | ||
Test::{strtoupper("test")}; | ||
$test::{strtoupper("test")}; | ||
Test::{'$variablee'}; | ||
$test::{'$variablee'}; | ||
Test::{strtolower("CLASS")}; | ||
$test::{strtolower("CLASS")}; | ||
Test::{1000}; | ||
$test::{1000}; | ||
EnumTest::{[]}; | ||
$test::{[]}; | ||
|
||
Test::{Test::method()}::{test($variable)}; | ||
Test::{test('test1')}::{test('test2')}; | ||
|
||
$test = new Test(); |
76 changes: 76 additions & 0 deletions
76
...atting/php83/dynamicClassConstantFetch_01.php.testDynamicClassConstantFetch_01b.formatted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
class Test { | ||
|
||
public const TEST = 'test'; | ||
public const TES = 'TES'; | ||
public const T = 'T'; | ||
public const TEST1 = self :: {'TEST'}; | ||
public const TEST2 = self :: {'TES' . 'T'}; | ||
public const TEST3 = self :: {self :: TES . self :: T}; | ||
|
||
public static function method(): void { | ||
|
||
} | ||
} | ||
|
||
enum EnumTest: string { | ||
|
||
case TEST = 'test'; | ||
case TES = 'TES'; | ||
case T = 'T'; | ||
case TEST1 = self :: {'TEST'}; | ||
case TEST2 = self :: {'TES' . 'T'}; | ||
case TEST3 = self :: {self :: TES . self :: T}; | ||
} | ||
|
||
function test(string $param = "test"): void { | ||
|
||
} | ||
|
||
$variable = 'TEST'; | ||
$e = 'e'; | ||
$test = "Test"; | ||
|
||
Test :: test(); | ||
|
||
Test :: {"TEST"}; | ||
$test :: {"TEST"}; | ||
Test :: {$variable}; | ||
$test :: {$variable}; | ||
Test :: {$variable . $e}; | ||
$test :: {$variable . $e}; | ||
Test :: {strtoupper("test")}; | ||
$test :: {strtoupper("test")}; | ||
Test :: {'$variablee'}; | ||
$test :: {'$variablee'}; | ||
Test :: {strtolower("CLASS")}; | ||
$test :: {strtolower("CLASS")}; | ||
Test :: {1000}; | ||
$test :: {1000}; | ||
EnumTest :: {[]}; | ||
$test :: {[]}; | ||
|
||
Test :: {Test :: method()} :: {test($variable)}; | ||
Test :: {test('test1')} :: {test('test2')}; | ||
|
||
$test = new Test(); |
Oops, something went wrong.