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 5)
- apache#6701 - https://wiki.php.net/rfc/dynamic_class_constant_fetch - Fix the `IntroduceSuggestion` and `PHP55UnhandledError` - Add unit tests
- Loading branch information
Showing
24 changed files
with
373 additions
and
8 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
50 changes: 50 additions & 0 deletions
50
...ation/IntroduceSuggestion/testDynamicClassConstantFetch/testDynamicClassConstantFetch.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,50 @@ | ||
<?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 BAR = 'bar'; | ||
public const BA = 'BA'; | ||
public const A = self::{'BAR'}; | ||
public const B = self::{self::{'BA'} . 'R'}; | ||
public const C = self::{self::BA . self::R}; | ||
} | ||
|
||
trait TraitTest { | ||
public const TRAIT_BA = 'BA'; | ||
public const TRAIT_B = self::{self::{'BA'} . 'R'}; | ||
public const TRAIT_C = self::{self::TRAIT_BA . self::TRAIT_R}; | ||
} | ||
|
||
enum EnumTest: string { | ||
case BAR = 'bar'; | ||
case BA = 'BA'; | ||
case A = self::{'BAR'}; | ||
case B = self::{self::{'BA'} . 'R'}; | ||
case C = self::{self::BA . self::R}; | ||
} | ||
|
||
Test::{"BAR"}; | ||
$test::{"BAR"}; | ||
Test::{test()}::{test($bar)}; | ||
Test::{test('foo')}::FOO; | ||
|
||
EnumTest::{"BAR"}; | ||
EnumTest::{test()}::{test($bar)}; | ||
EnumTest::{test('foo')}::FOO; |
1 change: 1 addition & 0 deletions
1
...assConstantFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_01.hints
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 @@ | ||
|
1 change: 1 addition & 0 deletions
1
...assConstantFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_02.hints
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 @@ | ||
|
4 changes: 4 additions & 0 deletions
4
...assConstantFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_03.hints
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,4 @@ | ||
public const C = self::{self::BA . self::^R}; | ||
------- | ||
HINT:Introduce Hint | ||
FIX:Create Constant "R" in Class "Test" (testDynamicClassConstantFetch.php) |
51 changes: 51 additions & 0 deletions
51
...ConstantFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_03Fix.fixed
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,51 @@ | ||
<?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 BAR = 'bar'; | ||
public const BA = 'BA'; | ||
public const A = self::{'BAR'}; | ||
public const B = self::{self::{'BA'} . 'R'}; | ||
public const C = self::{self::BA . self::R}; | ||
const R = ""; | ||
} | ||
|
||
trait TraitTest { | ||
public const TRAIT_BA = 'BA'; | ||
public const TRAIT_B = self::{self::{'BA'} . 'R'}; | ||
public const TRAIT_C = self::{self::TRAIT_BA . self::TRAIT_R}; | ||
} | ||
|
||
enum EnumTest: string { | ||
case BAR = 'bar'; | ||
case BA = 'BA'; | ||
case A = self::{'BAR'}; | ||
case B = self::{self::{'BA'} . 'R'}; | ||
case C = self::{self::BA . self::R}; | ||
} | ||
|
||
Test::{"BAR"}; | ||
$test::{"BAR"}; | ||
Test::{test()}::{test($bar)}; | ||
Test::{test('foo')}::FOO; | ||
|
||
EnumTest::{"BAR"}; | ||
EnumTest::{test()}::{test($bar)}; | ||
EnumTest::{test('foo')}::FOO; |
1 change: 1 addition & 0 deletions
1
...assConstantFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_04.hints
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 @@ | ||
|
1 change: 1 addition & 0 deletions
1
...assConstantFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_05.hints
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 @@ | ||
|
1 change: 1 addition & 0 deletions
1
...assConstantFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_06.hints
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 @@ | ||
|
1 change: 1 addition & 0 deletions
1
...assConstantFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_07.hints
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 @@ | ||
|
1 change: 1 addition & 0 deletions
1
...antFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_EnumCase01.hints
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 @@ | ||
|
1 change: 1 addition & 0 deletions
1
...antFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_EnumCase02.hints
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 @@ | ||
|
6 changes: 6 additions & 0 deletions
6
...antFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_EnumCase03.hints
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,6 @@ | ||
case C = self::{self::BA . self::^R}; | ||
------- | ||
HINT:Introduce Hint | ||
FIX:Create Constant "R" in Enum "EnumTest" (testDynamicClassConstantFetch.php) | ||
HINT:Introduce Hint | ||
FIX:Create Enum Case "R" in Enum "EnumTest" (testDynamicClassConstantFetch.php) |
53 changes: 53 additions & 0 deletions
53
...etch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_EnumCase03aFix.fixed
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,53 @@ | ||
<?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 BAR = 'bar'; | ||
public const BA = 'BA'; | ||
public const A = self::{'BAR'}; | ||
public const B = self::{self::{'BA'} . 'R'}; | ||
public const C = self::{self::BA . self::R}; | ||
} | ||
|
||
trait TraitTest { | ||
public const TRAIT_BA = 'BA'; | ||
public const TRAIT_B = self::{self::{'BA'} . 'R'}; | ||
public const TRAIT_C = self::{self::TRAIT_BA . self::TRAIT_R}; | ||
} | ||
|
||
enum EnumTest: string { | ||
|
||
const R = ""; | ||
|
||
case BAR = 'bar'; | ||
case BA = 'BA'; | ||
case A = self::{'BAR'}; | ||
case B = self::{self::{'BA'} . 'R'}; | ||
case C = self::{self::BA . self::R}; | ||
} | ||
|
||
Test::{"BAR"}; | ||
$test::{"BAR"}; | ||
Test::{test()}::{test($bar)}; | ||
Test::{test('foo')}::FOO; | ||
|
||
EnumTest::{"BAR"}; | ||
EnumTest::{test()}::{test($bar)}; | ||
EnumTest::{test('foo')}::FOO; |
51 changes: 51 additions & 0 deletions
51
...etch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_EnumCase03bFix.fixed
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,51 @@ | ||
<?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 BAR = 'bar'; | ||
public const BA = 'BA'; | ||
public const A = self::{'BAR'}; | ||
public const B = self::{self::{'BA'} . 'R'}; | ||
public const C = self::{self::BA . self::R}; | ||
} | ||
|
||
trait TraitTest { | ||
public const TRAIT_BA = 'BA'; | ||
public const TRAIT_B = self::{self::{'BA'} . 'R'}; | ||
public const TRAIT_C = self::{self::TRAIT_BA . self::TRAIT_R}; | ||
} | ||
|
||
enum EnumTest: string { | ||
case BAR = 'bar'; | ||
case BA = 'BA'; | ||
case A = self::{'BAR'}; | ||
case B = self::{self::{'BA'} . 'R'}; | ||
case C = self::{self::BA . self::R}; | ||
case R = ''; | ||
} | ||
|
||
Test::{"BAR"}; | ||
$test::{"BAR"}; | ||
Test::{test()}::{test($bar)}; | ||
Test::{test('foo')}::FOO; | ||
|
||
EnumTest::{"BAR"}; | ||
EnumTest::{test()}::{test($bar)}; | ||
EnumTest::{test('foo')}::FOO; |
1 change: 1 addition & 0 deletions
1
...antFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_EnumCase04.hints
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 @@ | ||
|
1 change: 1 addition & 0 deletions
1
...antFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_EnumCase05.hints
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 @@ | ||
|
1 change: 1 addition & 0 deletions
1
...antFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_EnumCase06.hints
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 @@ | ||
|
1 change: 1 addition & 0 deletions
1
...nstantFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_Trait01.hints
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 @@ | ||
|
4 changes: 4 additions & 0 deletions
4
...nstantFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_Trait02.hints
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,4 @@ | ||
public const TRAIT_C = self::{self::TRAIT_BA . self::TRA^IT_R}; | ||
------------- | ||
HINT:Introduce Hint | ||
FIX:Create Constant "TRAIT_R" in Trait "TraitTest" (testDynamicClassConstantFetch.php) |
51 changes: 51 additions & 0 deletions
51
...antFetch/testDynamicClassConstantFetch.php.testDynamicClassConstantFetch_Trait02Fix.fixed
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,51 @@ | ||
<?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 BAR = 'bar'; | ||
public const BA = 'BA'; | ||
public const A = self::{'BAR'}; | ||
public const B = self::{self::{'BA'} . 'R'}; | ||
public const C = self::{self::BA . self::R}; | ||
} | ||
|
||
trait TraitTest { | ||
public const TRAIT_BA = 'BA'; | ||
public const TRAIT_B = self::{self::{'BA'} . 'R'}; | ||
public const TRAIT_C = self::{self::TRAIT_BA . self::TRAIT_R}; | ||
const TRAIT_R = ""; | ||
} | ||
|
||
enum EnumTest: string { | ||
case BAR = 'bar'; | ||
case BA = 'BA'; | ||
case A = self::{'BAR'}; | ||
case B = self::{self::{'BA'} . 'R'}; | ||
case C = self::{self::BA . self::R}; | ||
} | ||
|
||
Test::{"BAR"}; | ||
$test::{"BAR"}; | ||
Test::{test()}::{test($bar)}; | ||
Test::{test('foo')}::FOO; | ||
|
||
EnumTest::{"BAR"}; | ||
EnumTest::{test()}::{test($bar)}; | ||
EnumTest::{test('foo')}::FOO; |
Oops, something went wrong.