4
4
5
5
namespace Roave \BetterReflectionTest \SourceLocator \SourceStubber ;
6
6
7
+ use Closure ;
7
8
use CompileError ;
8
9
use DateInterval ;
9
10
use DatePeriod ;
@@ -133,6 +134,16 @@ static function (string $className): bool {
133
134
return false ;
134
135
}
135
136
137
+ // Missing in JetBrains/phpstorm-stubs
138
+ /** @var list<class-string> $missingClasses */
139
+ $ missingClasses = ['NoDiscard ' ];
140
+ if (
141
+ PHP_VERSION_ID >= 80500
142
+ && in_array ($ className , $ missingClasses , true )
143
+ ) {
144
+ return false ;
145
+ }
146
+
136
147
// Check only always enabled extensions
137
148
return in_array ($ reflection ->getExtensionName (), self ::EXTENSIONS , true );
138
149
},
@@ -188,8 +199,19 @@ private function assertSameClassAttributes(CoreReflectionClass $original, Reflec
188
199
$ this ->assertSameInterfaces ($ original , $ stubbed );
189
200
190
201
foreach ($ original ->getMethods () as $ method ) {
202
+ $ methodName = $ original ->getName () . '# ' . $ method ->getName ();
203
+
204
+ // Needs fixes in JetBrains/phpstorm-stubs
205
+ if (
206
+ in_array ($ methodName , [
207
+ 'Closure#getCurrent ' ,
208
+ ], true )
209
+ ) {
210
+ continue ;
211
+ }
212
+
191
213
$ stubbedMethod = $ stubbed ->getMethod ($ method ->getName ());
192
- self ::assertNotNull ($ stubbedMethod );
214
+ self ::assertNotNull ($ stubbedMethod, $ methodName );
193
215
194
216
$ this ->assertSameMethodAttributes ($ method , $ stubbedMethod );
195
217
}
@@ -204,10 +226,21 @@ private function assertSameClassAttributes(CoreReflectionClass $original, Reflec
204
226
$ originalConstantName = $ originalConstant ->getName ();
205
227
assert ($ originalConstantName !== '' );
206
228
229
+ $ constantName = $ original ->getName () . ':: ' . $ originalConstant ->getName ();
230
+
231
+ // Needs fixes in JetBrains/phpstorm-stubs
232
+ if (
233
+ in_array ($ constantName , [
234
+ 'Attribute::TARGET_CONSTANT ' ,
235
+ ], true )
236
+ ) {
237
+ continue ;
238
+ }
239
+
207
240
$ stubbedConstant = $ stubbed ->getConstant ($ originalConstantName );
208
241
209
- self ::assertNotNull ($ stubbedConstant );
210
- self ::assertSame ($ originalConstant ->getValue (), $ stubbedConstant ->getValue ());
242
+ self ::assertNotNull ($ stubbedConstant, $ constantName );
243
+ self ::assertSame ($ originalConstant ->getValue (), $ stubbedConstant ->getValue (), $ constantName );
211
244
}
212
245
}
213
246
@@ -301,6 +334,20 @@ public static function internalFunctionsProvider(): array
301
334
static function (string $ functionName ): bool {
302
335
$ reflection = new CoreReflectionFunction ($ functionName );
303
336
337
+ // Missing in JetBrains/phpstorm-stubs
338
+ if (
339
+ PHP_VERSION_ID >= 80500
340
+ && in_array ($ functionName , [
341
+ 'array_first ' ,
342
+ 'array_last ' ,
343
+ 'clone ' ,
344
+ 'get_error_handler ' ,
345
+ 'get_exception_handler ' ,
346
+ ], true )
347
+ ) {
348
+ return false ;
349
+ }
350
+
304
351
// Check only always enabled extensions
305
352
return in_array ($ reflection ->getExtensionName (), self ::EXTENSIONS , true );
306
353
},
@@ -361,6 +408,18 @@ public static function internalConstantsProvider(): array
361
408
}
362
409
363
410
foreach ($ extensionConstants as $ constantName => $ constantValue ) {
411
+ // Missing in JetBrains/phpstorm-stubs
412
+ if (
413
+ PHP_VERSION_ID >= 80500
414
+ && in_array ($ constantName , [
415
+ 'IMAGETYPE_SVG ' ,
416
+ 'IMAGETYPE_HEIF ' ,
417
+ 'PHP_BUILD_DATE ' ,
418
+ ], true )
419
+ ) {
420
+ continue ;
421
+ }
422
+
364
423
$ provider [] = [$ constantName , $ constantValue , $ extensionName ];
365
424
}
366
425
}
0 commit comments