44
55namespace Roave \BetterReflectionTest \SourceLocator \SourceStubber ;
66
7+ use Closure ;
78use CompileError ;
89use DateInterval ;
910use DatePeriod ;
@@ -133,6 +134,16 @@ static function (string $className): bool {
133134 return false ;
134135 }
135136
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+
136147 // Check only always enabled extensions
137148 return in_array ($ reflection ->getExtensionName (), self ::EXTENSIONS , true );
138149 },
@@ -188,8 +199,19 @@ private function assertSameClassAttributes(CoreReflectionClass $original, Reflec
188199 $ this ->assertSameInterfaces ($ original , $ stubbed );
189200
190201 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+
191213 $ stubbedMethod = $ stubbed ->getMethod ($ method ->getName ());
192- self ::assertNotNull ($ stubbedMethod );
214+ self ::assertNotNull ($ stubbedMethod, $ methodName );
193215
194216 $ this ->assertSameMethodAttributes ($ method , $ stubbedMethod );
195217 }
@@ -204,10 +226,21 @@ private function assertSameClassAttributes(CoreReflectionClass $original, Reflec
204226 $ originalConstantName = $ originalConstant ->getName ();
205227 assert ($ originalConstantName !== '' );
206228
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+
207240 $ stubbedConstant = $ stubbed ->getConstant ($ originalConstantName );
208241
209- self ::assertNotNull ($ stubbedConstant );
210- self ::assertSame ($ originalConstant ->getValue (), $ stubbedConstant ->getValue ());
242+ self ::assertNotNull ($ stubbedConstant, $ constantName );
243+ self ::assertSame ($ originalConstant ->getValue (), $ stubbedConstant ->getValue (), $ constantName );
211244 }
212245 }
213246
@@ -301,6 +334,20 @@ public static function internalFunctionsProvider(): array
301334 static function (string $ functionName ): bool {
302335 $ reflection = new CoreReflectionFunction ($ functionName );
303336
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+
304351 // Check only always enabled extensions
305352 return in_array ($ reflection ->getExtensionName (), self ::EXTENSIONS , true );
306353 },
@@ -361,6 +408,18 @@ public static function internalConstantsProvider(): array
361408 }
362409
363410 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+
364423 $ provider [] = [$ constantName , $ constantValue , $ extensionName ];
365424 }
366425 }
0 commit comments