@@ -73,52 +73,52 @@ public function testEnums($testMarker, $testContent, $openerOffset, $closerOffse
73
73
*
74
74
* @see testEnums()
75
75
*
76
- * @return array
76
+ * @return array<string, array<string, string|int>>
77
77
*/
78
78
public static function dataEnums ()
79
79
{
80
80
return [
81
- [
82
- '/* testPureEnum */ ' ,
83
- 'enum ' ,
84
- 4 ,
85
- 12 ,
86
- ],
87
- [
88
- '/* testBackedIntEnum */ ' ,
89
- 'enum ' ,
90
- 7 ,
91
- 29 ,
92
- ],
93
- [
94
- '/* testBackedStringEnum */ ' ,
95
- 'enum ' ,
96
- 8 ,
97
- 30 ,
98
- ],
99
- [
100
- '/* testComplexEnum */ ' ,
101
- 'enum ' ,
102
- 11 ,
103
- 72 ,
104
- ],
105
- [
106
- '/* testEnumWithEnumAsClassName */ ' ,
107
- 'enum ' ,
108
- 6 ,
109
- 7 ,
110
- ],
111
- [
112
- '/* testEnumIsCaseInsensitive */ ' ,
113
- 'EnUm ' ,
114
- 4 ,
115
- 5 ,
116
- ],
117
- [
118
- '/* testDeclarationContainingComment */ ' ,
119
- 'enum ' ,
120
- 6 ,
121
- 14 ,
81
+ ' enum - pure ' => [
82
+ 'testMarker ' => ' /* testPureEnum */ ' ,
83
+ 'testContent ' => ' enum ' ,
84
+ ' openerOffset ' => 4 ,
85
+ ' closerOffset ' => 12 ,
86
+ ],
87
+ ' enum - backed int ' => [
88
+ 'testMarker ' => ' /* testBackedIntEnum */ ' ,
89
+ 'testContent ' => ' enum ' ,
90
+ ' openerOffset ' => 7 ,
91
+ ' closerOffset ' => 29 ,
92
+ ],
93
+ ' enum - backed string ' => [
94
+ 'testMarker ' => ' /* testBackedStringEnum */ ' ,
95
+ 'testContent ' => ' enum ' ,
96
+ ' openerOffset ' => 8 ,
97
+ ' closerOffset ' => 30 ,
98
+ ],
99
+ ' enum - backed int + implements ' => [
100
+ 'testMarker ' => ' /* testComplexEnum */ ' ,
101
+ 'testContent ' => ' enum ' ,
102
+ ' openerOffset ' => 11 ,
103
+ ' closerOffset ' => 72 ,
104
+ ],
105
+ ' enum keyword when "enum" is the name for the construct (yes, this is allowed) ' => [
106
+ 'testMarker ' => ' /* testEnumWithEnumAsClassName */ ' ,
107
+ 'testContent ' => ' enum ' ,
108
+ ' openerOffset ' => 6 ,
109
+ ' closerOffset ' => 7 ,
110
+ ],
111
+ ' enum - keyword is case insensitive ' => [
112
+ 'testMarker ' => ' /* testEnumIsCaseInsensitive */ ' ,
113
+ 'testContent ' => ' EnUm ' ,
114
+ ' openerOffset ' => 4 ,
115
+ ' closerOffset ' => 5 ,
116
+ ],
117
+ ' enum - declaration containing comment ' => [
118
+ 'testMarker ' => ' /* testDeclarationContainingComment */ ' ,
119
+ 'testContent ' => ' enum ' ,
120
+ ' openerOffset ' => 6 ,
121
+ ' closerOffset ' => 14 ,
122
122
],
123
123
];
124
124
@@ -152,74 +152,70 @@ public function testNotEnums($testMarker, $testContent)
152
152
*
153
153
* @see testNotEnums()
154
154
*
155
- * @return array
155
+ * @return array<string, array<string, string>>
156
156
*/
157
157
public static function dataNotEnums ()
158
158
{
159
159
return [
160
- [
161
- '/* testEnumAsClassNameAfterEnumKeyword */ ' ,
162
- 'Enum ' ,
160
+ ' not enum - construct named enum ' => [
161
+ 'testMarker ' => ' /* testEnumAsClassNameAfterEnumKeyword */ ' ,
162
+ 'testContent ' => ' Enum ' ,
163
163
],
164
- [
165
- '/* testEnumUsedAsClassName */ ' ,
166
- 'Enum ' ,
164
+ ' not enum - class named enum ' => [
165
+ 'testMarker ' => ' /* testEnumUsedAsClassName */ ' ,
166
+ 'testContent ' => ' Enum ' ,
167
167
],
168
- [
169
- '/* testEnumUsedAsClassConstantName */ ' ,
170
- 'ENUM ' ,
168
+ ' not enum - class constant named enum ' => [
169
+ 'testMarker ' => ' /* testEnumUsedAsClassConstantName */ ' ,
170
+ 'testContent ' => ' ENUM ' ,
171
171
],
172
- [
173
- '/* testEnumUsedAsMethodName */ ' ,
174
- 'enum ' ,
172
+ ' not enum - method named enum ' => [
173
+ 'testMarker ' => ' /* testEnumUsedAsMethodName */ ' ,
174
+ 'testContent ' => ' enum ' ,
175
175
],
176
- [
177
- '/* testEnumUsedAsPropertyName */ ' ,
178
- 'enum ' ,
176
+ ' not enum - class property named enum ' => [
177
+ 'testMarker ' => ' /* testEnumUsedAsPropertyName */ ' ,
178
+ 'testContent ' => ' enum ' ,
179
179
],
180
- [
181
- '/* testEnumUsedAsFunctionName */ ' ,
182
- 'enum ' ,
180
+ ' not enum - global function named enum ' => [
181
+ 'testMarker ' => ' /* testEnumUsedAsFunctionName */ ' ,
182
+ 'testContent ' => ' enum ' ,
183
183
],
184
- [
185
- '/* testEnumUsedAsEnumName */ ' ,
186
- 'Enum ' ,
184
+ ' not enum - namespace named enum ' => [
185
+ 'testMarker ' => ' /* testEnumUsedAsNamespaceName */ ' ,
186
+ 'testContent ' => ' Enum ' ,
187
187
],
188
- [
189
- '/* testEnumUsedAsNamespaceName */ ' ,
190
- 'Enum ' ,
188
+ ' not enum - part of namespace named enum ' => [
189
+ 'testMarker ' => ' /* testEnumUsedAsPartOfNamespaceName */ ' ,
190
+ 'testContent ' => ' Enum ' ,
191
191
],
192
- [
193
- '/* testEnumUsedAsPartOfNamespaceName */ ' ,
194
- 'Enum ' ,
192
+ ' not enum - class instantiation for class enum ' => [
193
+ 'testMarker ' => ' /* testEnumUsedInObjectInitialization */ ' ,
194
+ 'testContent ' => ' Enum ' ,
195
195
],
196
- [
197
- '/* testEnumUsedInObjectInitialization */ ' ,
198
- 'Enum ' ,
196
+ ' not enum - function call ' => [
197
+ 'testMarker ' => ' /* testEnumAsFunctionCall */ ' ,
198
+ 'testContent ' => ' enum ' ,
199
199
],
200
- [
201
- '/* testEnumAsFunctionCall */ ' ,
202
- 'enum ' ,
200
+ ' not enum - namespace relative function call ' => [
201
+ 'testMarker ' => ' /* testEnumAsFunctionCallWithNamespace */ ' ,
202
+ 'testContent ' => ' enum ' ,
203
203
],
204
- [
205
- '/* testEnumAsFunctionCallWithNamespace */ ' ,
206
- 'enum ' ,
204
+ ' not enum - class constant fetch with enum as class name ' => [
205
+ 'testMarker ' => ' /* testClassConstantFetchWithEnumAsClassName */ ' ,
206
+ 'testContent ' => ' Enum ' ,
207
207
],
208
- [
209
- '/* testClassConstantFetchWithEnumAsClassName */ ' ,
210
- 'Enum ' ,
208
+ ' not enum - class constant fetch with enum as constant name ' => [
209
+ 'testMarker ' => ' /* testClassConstantFetchWithEnumAsConstantName */ ' ,
210
+ 'testContent ' => ' ENUM ' ,
211
211
],
212
- [
213
- '/* testClassConstantFetchWithEnumAsConstantName */ ' ,
214
- 'ENUM ' ,
212
+ ' parse error, not enum - enum declaration without name ' => [
213
+ 'testMarker ' => ' /* testParseErrorMissingName */ ' ,
214
+ 'testContent ' => ' enum ' ,
215
215
],
216
- [
217
- '/* testParseErrorMissingName */ ' ,
218
- 'enum ' ,
219
- ],
220
- [
221
- '/* testParseErrorLiveCoding */ ' ,
222
- 'enum ' ,
216
+ 'parse error, not enum - enum declaration with curlies ' => [
217
+ 'testMarker ' => '/* testParseErrorLiveCoding */ ' ,
218
+ 'testContent ' => 'enum ' ,
223
219
],
224
220
];
225
221
0 commit comments