-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Php83] add type to final class constant
Since PHP8.1 it has been possible to mark a class constant as final. A "final public const FOO" should be treated the same as a "public const FOO" within a "final class" and the type should be added, which isn't currently the case.
- Loading branch information
Phil Bates
committed
Feb 23, 2024
1 parent
3ef3e35
commit 78a7443
Showing
2 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
...lassConst/AddTypeToConstRector/Fixture/apply_type_to_class_const_when_const_final.php.inc
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,45 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\Php83\Rector\ClassConst\AddTypeToConstRector\Fixture; | ||
|
||
class ApplyTypesWhenClassFinal | ||
{ | ||
final public const STRING = 'some_type'; | ||
|
||
final public const INT = 1; | ||
|
||
final public const FLOAT = 1.0; | ||
|
||
final public const BOOL = true; | ||
|
||
final public const NULL = null; | ||
|
||
final public const ARRAY = []; | ||
|
||
final public const CONCAT = self::STRING . 'concat'; | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\Php83\Rector\ClassConst\AddTypeToConstRector\Fixture; | ||
|
||
class ApplyTypesWhenClassFinal | ||
{ | ||
final public const string STRING = 'some_type'; | ||
|
||
final public const int INT = 1; | ||
|
||
final public const float FLOAT = 1.0; | ||
|
||
final public const bool BOOL = true; | ||
|
||
final public const null NULL = null; | ||
|
||
final public const array ARRAY = []; | ||
|
||
final public const string CONCAT = self::STRING . 'concat'; | ||
} | ||
|
||
?> |
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