Skip to content

Commit 5fec30c

Browse files
author
Kirill Nesmeyanov
committed
Try to fix PHP 8.1 const in enums bug again
1 parent e05480d commit 5fec30c

File tree

4 files changed

+74
-34
lines changed

4 files changed

+74
-34
lines changed

src/Node/Literal/LiteralKind.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,60 @@
66

77
use TypeLang\Parser\Node\Kind;
88

9-
const LITERAL_KIND = Kind::LITERAL_KIND;
10-
119
enum LiteralKind: int implements \JsonSerializable
1210
{
1311
/**
1412
* Indicates an arbitrary and non-standard literal
1513
* value that has not been explicitly defined.
1614
*
1715
* @internal
16+
* @see Kind::LITERAL_KIND
1817
*/
19-
case UNKNOWN = LITERAL_KIND;
18+
case UNKNOWN = /*Kind::LITERAL_KIND*/0x0400;
2019

2120
/**
2221
* Denotes any {@see bool} type consisting of the
2322
* literal {@see true} and {@see false} values.
23+
*
24+
* @see Kind::LITERAL_KIND
2425
*/
25-
case BOOL_KIND = LITERAL_KIND + 1;
26+
case BOOL_KIND = /*Kind::LITERAL_KIND*/0x0400 + 1;
2627

2728
/**
2829
* Denotes any {@see float} type.
30+
*
31+
* @see Kind::LITERAL_KIND
2932
*/
30-
case FLOAT_KIND = LITERAL_KIND + 2;
33+
case FLOAT_KIND = /*Kind::LITERAL_KIND*/0x0400 + 2;
3134

3235
/**
3336
* Denotes any {@see int} type.
37+
*
38+
* @see Kind::LITERAL_KIND
3439
*/
35-
case INT_KIND = LITERAL_KIND + 3;
40+
case INT_KIND = /*Kind::LITERAL_KIND*/0x0400 + 3;
3641

3742
/**
3843
* Denotes any {@see null} type.
44+
*
45+
* @see Kind::LITERAL_KIND
3946
*/
40-
case NULL_KIND = LITERAL_KIND + 4;
47+
case NULL_KIND = /*Kind::LITERAL_KIND*/0x0400 + 4;
4148

4249
/**
4350
* Denotes any {@see string} type.
51+
*
52+
* @see Kind::LITERAL_KIND
4453
*/
45-
case STRING_KIND = LITERAL_KIND + 5;
54+
case STRING_KIND = /*Kind::LITERAL_KIND*/0x0400 + 5;
4655

4756
/**
4857
* Denotes any variable (for example function
4958
* argument/parameter) type.
59+
*
60+
* @see Kind::LITERAL_KIND
5061
*/
51-
case VARIABLE_KIND = LITERAL_KIND + 6;
62+
case VARIABLE_KIND = /*Kind::LITERAL_KIND*/0x0400 + 6;
5263

5364
/**
5465
* @return int<0, max>

src/Node/Stmt/Condition/ConditionKind.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,30 @@
66

77
use TypeLang\Parser\Node\Kind;
88

9-
const CONDITION_KIND = Kind::CONDITION_KIND;
10-
119
enum ConditionKind: int implements \JsonSerializable
1210
{
1311
/**
1412
* Indicates an arbitrary and non-standard condition
1513
* that has not been explicitly defined.
1614
*
1715
* @internal
16+
* @see Kind::CONDITION_KIND
1817
*/
19-
case UNKNOWN = CONDITION_KIND;
18+
case UNKNOWN = /*Kind::CONDITION_KIND*/0x0300;
2019

2120
/**
2221
* Indicates an equivalent comparison condition.
22+
*
23+
* @see Kind::CONDITION_KIND
2324
*/
24-
case KIND_EQUAL = CONDITION_KIND + 1;
25+
case KIND_EQUAL = /*Kind::CONDITION_KIND*/0x0300 + 1;
2526

2627
/**
2728
* Indicates an non-equivalent comparison condition.
29+
*
30+
* @see Kind::CONDITION_KIND
2831
*/
29-
case KIND_NOT_EQUAL = CONDITION_KIND + 2;
32+
case KIND_NOT_EQUAL = /*Kind::CONDITION_KIND*/0x0300 + 2;
3033

3134
/**
3235
* @return int<0, max>

src/Node/Stmt/Shape/ShapeFieldKind.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,44 @@
66

77
use TypeLang\Parser\Node\Kind;
88

9-
const SHAPE_FIELD_KIND = Kind::SHAPE_FIELD_KIND;
10-
119
enum ShapeFieldKind: int implements \JsonSerializable
1210
{
1311
/**
1412
* Indicates an arbitrary and non-standard shape
1513
* field type that has not been explicitly defined.
1614
*
1715
* @internal
16+
* @see Kind::SHAPE_FIELD_KIND
1817
*/
19-
case UNKNOWN = SHAPE_FIELD_KIND;
18+
case UNKNOWN = /*Kind::SHAPE_FIELD_KIND*/0x0200;
2019

2120
/**
2221
* Defines a field with a key of the form `key`.
22+
*
23+
* @see Kind::SHAPE_FIELD_KIND
2324
*/
24-
case NAMED_FIELD_KIND = SHAPE_FIELD_KIND + 1;
25+
case NAMED_FIELD_KIND = /*Kind::SHAPE_FIELD_KIND*/0x0200 + 1;
2526

2627
/**
2728
* Defines a field with a key of the form `"key"`.
29+
*
30+
* @see Kind::SHAPE_FIELD_KIND
2831
*/
29-
case STRING_FIELD_KIND = SHAPE_FIELD_KIND + 2;
32+
case STRING_FIELD_KIND = /*Kind::SHAPE_FIELD_KIND*/0x0200 + 2;
3033

3134
/**
3235
* Defines a field with a key of the form `42`.
36+
*
37+
* @see Kind::SHAPE_FIELD_KIND
3338
*/
34-
case NUMERIC_FIELD_KIND = SHAPE_FIELD_KIND + 3;
39+
case NUMERIC_FIELD_KIND = /*Kind::SHAPE_FIELD_KIND*/0x0200 + 3;
3540

3641
/**
3742
* Defines a field without key.
43+
*
44+
* @see Kind::SHAPE_FIELD_KIND
3845
*/
39-
case IMPLICIT_FIELD_KIND = SHAPE_FIELD_KIND + 4;
46+
case IMPLICIT_FIELD_KIND = /*Kind::SHAPE_FIELD_KIND*/0x0200 + 4;
4047

4148
/**
4249
* @return int<0, max>

src/Node/Stmt/TypeKind.php

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,16 @@
66

77
use TypeLang\Parser\Node\Kind;
88

9-
const TYPE_KIND = Kind::TYPE_KIND;
10-
119
enum TypeKind: int implements \JsonSerializable
1210
{
1311
/**
1412
* Indicates an arbitrary and non-standard type
1513
* that has not been explicitly defined.
1614
*
1715
* @internal
16+
* @see Kind::TYPE_KIND
1817
*/
19-
case UNKNOWN = TYPE_KIND;
18+
case UNKNOWN = /*Kind::TYPE_KIND*/0x0100;
2019

2120
/**
2221
* Denotes any named type, which may be a reference to a class,
@@ -25,8 +24,10 @@ enum TypeKind: int implements \JsonSerializable
2524
* ```
2625
* Path\To\SomeClass<T, Y>
2726
* ```
27+
*
28+
* @see Kind::TYPE_KIND
2829
*/
29-
case TYPE_KIND = TYPE_KIND + 1;
30+
case TYPE_KIND = /*Kind::TYPE_KIND*/0x0100 + 1;
3031

3132
/**
3233
* Denotes any callable type that can contain parameters
@@ -35,80 +36,98 @@ enum TypeKind: int implements \JsonSerializable
3536
* ```
3637
* example(T, U): V
3738
* ```
39+
*
40+
* @see Kind::TYPE_KIND
3841
*/
39-
case CALLABLE_KIND = TYPE_KIND + 2;
42+
case CALLABLE_KIND = /*Kind::TYPE_KIND*/0x0100 + 2;
4043

4144
/**
4245
* Denotes a constant mask for a class.
4346
*
4447
* ```
4548
* Path\To\SomeClass::CONST_*
4649
* ```
50+
*
51+
* @see Kind::TYPE_KIND
4752
*/
48-
case CLASS_CONST_MASK_KIND = TYPE_KIND + 3;
53+
case CLASS_CONST_MASK_KIND = /*Kind::TYPE_KIND*/0x0100 + 3;
4954

5055
/**
5156
* Denotes a reference to a specific class constant.
5257
*
5358
* ```
5459
* Path\To\SomeClass::CONST_NAME
5560
* ```
61+
*
62+
* @see Kind::TYPE_KIND
5663
*/
57-
case CLASS_CONST_KIND = TYPE_KIND + 4;
64+
case CLASS_CONST_KIND = /*Kind::TYPE_KIND*/0x0100 + 4;
5865

5966
/**
6067
* Denotes a global constant mask.
6168
*
6269
* ```
6370
* JSON_ERROR_*
6471
* ```
72+
*
73+
* @see Kind::TYPE_KIND
6574
*/
66-
case CONST_MASK_KIND = TYPE_KIND + 5;
75+
case CONST_MASK_KIND = /*Kind::TYPE_KIND*/0x0100 + 5;
6776

6877
/**
6978
* Denotes the logical intersection type.
7079
*
7180
* ```
7281
* T & U
7382
* ```
83+
*
84+
* @see Kind::TYPE_KIND
7485
*/
75-
case LOGICAL_INTERSECTION_KIND = TYPE_KIND + 6;
86+
case LOGICAL_INTERSECTION_KIND = /*Kind::TYPE_KIND*/0x0100 + 6;
7687

7788
/**
7889
* Denotes the logical union type.
7990
*
8091
* ```
8192
* T | U
8293
* ```
94+
*
95+
* @see Kind::TYPE_KIND
8396
*/
84-
case LOGICAL_UNION_KIND = TYPE_KIND + 7;
97+
case LOGICAL_UNION_KIND = /*Kind::TYPE_KIND*/0x0100 + 7;
8598

8699
/**
87100
* Denotes the nullable type.
88101
*
89102
* ```
90103
* ?T
91104
* ```
105+
*
106+
* @see Kind::TYPE_KIND
92107
*/
93-
case NULLABLE_KIND = TYPE_KIND + 8;
108+
case NULLABLE_KIND = /*Kind::TYPE_KIND*/0x0100 + 8;
94109

95110
/**
96111
* Denotes the logical ternary type.
97112
*
98113
* ```
99114
* T ? U : V
100115
* ```
116+
*
117+
* @see Kind::TYPE_KIND
101118
*/
102-
case TERNARY_KIND = TYPE_KIND + 9;
119+
case TERNARY_KIND = /*Kind::TYPE_KIND*/0x0100 + 9;
103120

104121
/**
105122
* Indicates a list type in the "legacy" syntax format.
106123
*
107124
* ```
108125
* T[]
109126
* ```
127+
*
128+
* @see Kind::TYPE_KIND
110129
*/
111-
case LIST_KIND = TYPE_KIND + 10;
130+
case LIST_KIND = /*Kind::TYPE_KIND*/0x0100 + 10;
112131

113132
/**
114133
* @return int<0, max>

0 commit comments

Comments
 (0)