@@ -19,7 +19,7 @@ public static function dataPropertyHooks(): iterable
19
19
$ reflectionProvider = self ::createReflectionProvider ();
20
20
21
21
yield [
22
- 'PropertyHooksTypes \\Foo ' ,
22
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\Foo ' ) ,
23
23
'i ' ,
24
24
'set ' ,
25
25
['int ' ],
@@ -28,7 +28,7 @@ public static function dataPropertyHooks(): iterable
28
28
];
29
29
30
30
yield [
31
- 'PropertyHooksTypes \\Foo ' ,
31
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\Foo ' ) ,
32
32
'i ' ,
33
33
'get ' ,
34
34
[],
@@ -37,7 +37,7 @@ public static function dataPropertyHooks(): iterable
37
37
];
38
38
39
39
yield [
40
- 'PropertyHooksTypes \\Foo ' ,
40
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\Foo ' ) ,
41
41
'l ' ,
42
42
'get ' ,
43
43
[],
@@ -46,7 +46,7 @@ public static function dataPropertyHooks(): iterable
46
46
];
47
47
48
48
yield [
49
- 'PropertyHooksTypes \\Foo ' ,
49
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\Foo ' ) ,
50
50
'n ' ,
51
51
'set ' ,
52
52
['array<string>|int ' ],
@@ -55,7 +55,7 @@ public static function dataPropertyHooks(): iterable
55
55
];
56
56
57
57
yield [
58
- 'PropertyHooksTypes \\FooShort ' ,
58
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooShort ' ) ,
59
59
'i ' ,
60
60
'set ' ,
61
61
['int ' ],
@@ -64,7 +64,7 @@ public static function dataPropertyHooks(): iterable
64
64
];
65
65
66
66
yield [
67
- 'PropertyHooksTypes \\FooShort ' ,
67
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooShort ' ) ,
68
68
'k ' ,
69
69
'set ' ,
70
70
['int|string ' ],
@@ -73,7 +73,7 @@ public static function dataPropertyHooks(): iterable
73
73
];
74
74
75
75
yield [
76
- 'PropertyHooksTypes \\FooShort ' ,
76
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooShort ' ) ,
77
77
'l ' ,
78
78
'set ' ,
79
79
['array<string> ' ],
@@ -82,7 +82,7 @@ public static function dataPropertyHooks(): iterable
82
82
];
83
83
84
84
yield [
85
- 'PropertyHooksTypes \\FooShort ' ,
85
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooShort ' ) ,
86
86
'm ' ,
87
87
'set ' ,
88
88
['array<string> ' ],
@@ -91,7 +91,7 @@ public static function dataPropertyHooks(): iterable
91
91
];
92
92
93
93
yield [
94
- 'PropertyHooksTypes \\FooShort ' ,
94
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooShort ' ) ,
95
95
'n ' ,
96
96
'set ' ,
97
97
['array<string>|int ' ],
@@ -100,7 +100,7 @@ public static function dataPropertyHooks(): iterable
100
100
];
101
101
102
102
yield [
103
- 'PropertyHooksTypes \\FooConstructor ' ,
103
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooConstructor ' ) ,
104
104
'i ' ,
105
105
'set ' ,
106
106
['int ' ],
@@ -109,7 +109,7 @@ public static function dataPropertyHooks(): iterable
109
109
];
110
110
111
111
yield [
112
- 'PropertyHooksTypes \\FooConstructor ' ,
112
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooConstructor ' ) ,
113
113
'j ' ,
114
114
'set ' ,
115
115
['int ' ],
@@ -118,7 +118,7 @@ public static function dataPropertyHooks(): iterable
118
118
];
119
119
120
120
yield [
121
- 'PropertyHooksTypes \\FooConstructor ' ,
121
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooConstructor ' ) ,
122
122
'k ' ,
123
123
'set ' ,
124
124
['int|string ' ],
@@ -127,7 +127,7 @@ public static function dataPropertyHooks(): iterable
127
127
];
128
128
129
129
yield [
130
- 'PropertyHooksTypes \\FooConstructor ' ,
130
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooConstructor ' ) ,
131
131
'l ' ,
132
132
'set ' ,
133
133
['array<string> ' ],
@@ -136,7 +136,7 @@ public static function dataPropertyHooks(): iterable
136
136
];
137
137
138
138
yield [
139
- 'PropertyHooksTypes \\FooConstructor ' ,
139
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooConstructor ' ) ,
140
140
'l ' ,
141
141
'get ' ,
142
142
[],
@@ -145,7 +145,7 @@ public static function dataPropertyHooks(): iterable
145
145
];
146
146
147
147
yield [
148
- 'PropertyHooksTypes \\FooConstructor ' ,
148
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooConstructor ' ) ,
149
149
'm ' ,
150
150
'set ' ,
151
151
['array<string> ' ],
@@ -154,7 +154,7 @@ public static function dataPropertyHooks(): iterable
154
154
];
155
155
156
156
yield [
157
- 'PropertyHooksTypes \\FooConstructor ' ,
157
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooConstructor ' ) ,
158
158
'n ' ,
159
159
'set ' ,
160
160
['array<string>|int ' ],
@@ -163,7 +163,7 @@ public static function dataPropertyHooks(): iterable
163
163
];
164
164
165
165
yield [
166
- 'PropertyHooksTypes \\FooConstructorWithParam ' ,
166
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooConstructorWithParam ' ) ,
167
167
'l ' ,
168
168
'set ' ,
169
169
['array<string> ' ],
@@ -172,7 +172,7 @@ public static function dataPropertyHooks(): iterable
172
172
];
173
173
174
174
yield [
175
- 'PropertyHooksTypes \\FooConstructorWithParam ' ,
175
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooConstructorWithParam ' ) ,
176
176
'l ' ,
177
177
'get ' ,
178
178
[],
@@ -181,7 +181,7 @@ public static function dataPropertyHooks(): iterable
181
181
];
182
182
183
183
yield [
184
- 'PropertyHooksTypes \\FooConstructorWithParam ' ,
184
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooConstructorWithParam ' ) ,
185
185
'm ' ,
186
186
'set ' ,
187
187
['array<string> ' ],
@@ -190,7 +190,7 @@ public static function dataPropertyHooks(): iterable
190
190
];
191
191
192
192
yield [
193
- 'PropertyHooksTypes \\FooGenerics ' ,
193
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooGenerics ' ) ,
194
194
'm ' ,
195
195
'set ' ,
196
196
['array<T of stdClass (class PropertyHooksTypes\FooGenerics, parameter)> ' ],
@@ -199,7 +199,7 @@ public static function dataPropertyHooks(): iterable
199
199
];
200
200
201
201
yield [
202
- 'PropertyHooksTypes \\FooGenerics ' ,
202
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooGenerics ' ) ,
203
203
'n ' ,
204
204
'set ' ,
205
205
['array<T of stdClass (class PropertyHooksTypes\FooGenerics, parameter)>|int ' ],
@@ -208,7 +208,7 @@ public static function dataPropertyHooks(): iterable
208
208
];
209
209
210
210
yield [
211
- 'PropertyHooksTypes \\FooGenerics ' ,
211
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooGenerics ' ) ,
212
212
'm ' ,
213
213
'get ' ,
214
214
[],
@@ -217,112 +217,80 @@ public static function dataPropertyHooks(): iterable
217
217
];
218
218
219
219
yield [
220
- 'PropertyHooksTypes \\FooGenerics ' ,
220
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooGenerics ' ) ,
221
221
'n ' ,
222
222
'get ' ,
223
223
[],
224
224
'int ' ,
225
225
true ,
226
226
];
227
227
228
+ $ specificFooGenerics = (new GenericObjectType ('PropertyHooksTypes \\FooGenerics ' , [new IntegerType ()]))->getClassReflection ();
229
+
228
230
yield [
229
- ' PropertyHooksTypes \\ FooGenerics ' ,
231
+ $ specificFooGenerics ,
230
232
'n ' ,
231
- 'get ' ,
232
- [],
233
- 'int ' ,
233
+ 'set ' ,
234
+ [' array<int>|int ' ],
235
+ 'void ' ,
234
236
true ,
235
237
];
236
238
237
239
yield [
238
- 'PropertyHooksTypes \\FooGenerics ' ,
239
- 'm ' ,
240
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooGenerics ' ) ,
241
+ 'n ' ,
240
242
'get ' ,
241
243
[],
242
- 'array<T of stdClass (class PropertyHooksTypes\FooGenerics, parameter)> ' ,
244
+ 'int ' ,
243
245
true ,
244
246
];
245
247
246
248
yield [
247
- ' PropertyHooksTypes \\ FooGenericsConstructor ' ,
248
- 'l ' ,
249
+ $ specificFooGenerics ,
250
+ 'm ' ,
249
251
'set ' ,
250
- ['array<T of stdClass (class PropertyHooksTypes\FooGenericsConstructor, parameter) > ' ],
252
+ ['array<int > ' ],
251
253
'void ' ,
252
254
true ,
253
255
];
254
256
255
257
yield [
256
- 'PropertyHooksTypes \\FooGenericsConstructor ' ,
258
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooGenerics ' ) ,
257
259
'm ' ,
258
- 'set ' ,
259
- [' array<T of stdClass (class PropertyHooksTypes\FooGenericsConstructor, parameter)> ' ],
260
- 'void ' ,
260
+ 'get ' ,
261
+ [],
262
+ 'array<T of stdClass (class PropertyHooksTypes\FooGenerics, parameter)> ' ,
261
263
true ,
262
264
];
263
265
264
266
yield [
265
- 'PropertyHooksTypes \\FooGenericsConstructor ' ,
266
- 'n ' ,
267
+ $ reflectionProvider -> getClass ( 'PropertyHooksTypes \\FooGenericsConstructor ' ) ,
268
+ 'l ' ,
267
269
'set ' ,
268
- ['array<T of stdClass (class PropertyHooksTypes\FooGenericsConstructor, parameter)>|int ' ],
270
+ ['array<T of stdClass (class PropertyHooksTypes\FooGenericsConstructor, parameter)> ' ],
269
271
'void ' ,
270
272
true ,
271
273
];
272
- }
273
-
274
- /**
275
- * @param ExtendedPropertyReflection::HOOK_* $hookName
276
- * @param string[] $parameterTypes
277
- */
278
- #[DataProvider('dataPropertyHooks ' )]
279
- public function testPropertyHooks (
280
- string $ className ,
281
- string $ propertyName ,
282
- string $ hookName ,
283
- array $ parameterTypes ,
284
- string $ returnType ,
285
- bool $ isVirtual ,
286
- ): void
287
- {
288
- $ reflectionProvider = $ this ->createReflectionProvider ();
289
- $ classReflection = $ reflectionProvider ->getClass ($ className );
290
- $ propertyReflection = $ classReflection ->getNativeProperty ($ propertyName );
291
- $ this ->assertSame ($ isVirtual , $ propertyReflection ->isVirtual ()->yes ());
292
-
293
- $ hookReflection = $ propertyReflection ->getHook ($ hookName );
294
- $ hookVariant = $ hookReflection ->getOnlyVariant ();
295
- $ this ->assertSame ($ returnType , $ hookVariant ->getReturnType ()->describe (VerbosityLevel::precise ()));
296
- $ this ->assertCount (count ($ parameterTypes ), $ hookVariant ->getParameters ());
297
-
298
- foreach ($ hookVariant ->getParameters () as $ i => $ parameter ) {
299
- $ this ->assertSame ($ parameterTypes [$ i ], $ parameter ->getType ()->describe (VerbosityLevel::precise ()));
300
- }
301
- }
302
-
303
- public static function dataPropertyHooksFromType (): iterable
304
- {
305
- $ specificFooGenerics = new GenericObjectType ('PropertyHooksTypes \\FooGenerics ' , [new IntegerType ()]);
306
274
307
275
yield [
308
- $ specificFooGenerics ,
276
+ $ reflectionProvider -> getClass ( ' PropertyHooksTypes \\ FooGenericsConstructor ' ) ,
309
277
'm ' ,
310
278
'set ' ,
311
- ['array<int > ' ],
279
+ ['array<T of stdClass (class PropertyHooksTypes\FooGenericsConstructor, parameter) > ' ],
312
280
'void ' ,
313
281
true ,
314
282
];
315
283
316
284
yield [
317
- $ specificFooGenerics ,
285
+ $ reflectionProvider -> getClass ( ' PropertyHooksTypes \\ FooGenericsConstructor ' ) ,
318
286
'n ' ,
319
287
'set ' ,
320
- ['array<int >|int ' ],
288
+ ['array<T of stdClass (class PropertyHooksTypes\FooGenericsConstructor, parameter) >|int ' ],
321
289
'void ' ,
322
290
true ,
323
291
];
324
292
325
- $ specificFooGenericsConstructor = new GenericObjectType ('PropertyHooksTypes \\FooGenericsConstructor ' , [new IntegerType ()]);
293
+ $ specificFooGenericsConstructor = ( new GenericObjectType ('PropertyHooksTypes \\FooGenericsConstructor ' , [new IntegerType ()]))-> getClassReflection ( );
326
294
327
295
yield [
328
296
$ specificFooGenericsConstructor ,
@@ -356,18 +324,16 @@ public static function dataPropertyHooksFromType(): iterable
356
324
* @param ExtendedPropertyReflection::HOOK_* $hookName
357
325
* @param string[] $parameterTypes
358
326
*/
359
- #[DataProvider('dataPropertyHooksFromType ' )]
360
- public function testPropertyHooksFromType (
361
- GenericObjectType $ type ,
327
+ #[DataProvider('dataPropertyHooks ' )]
328
+ public function testPropertyHooks (
329
+ ClassReflection $ classReflection ,
362
330
string $ propertyName ,
363
331
string $ hookName ,
364
332
array $ parameterTypes ,
365
333
string $ returnType ,
366
334
bool $ isVirtual ,
367
335
): void
368
336
{
369
- $ classReflection = $ type ->getClassReflection ();
370
- $ this ->assertNotNull ($ classReflection );
371
337
$ propertyReflection = $ classReflection ->getNativeProperty ($ propertyName );
372
338
$ this ->assertSame ($ isVirtual , $ propertyReflection ->isVirtual ()->yes ());
373
339
0 commit comments