Skip to content

Commit 97c1402

Browse files
committed
Run tests and static analysis on PHP 8.5
1 parent 0f0ba0a commit 97c1402

File tree

3 files changed

+66
-4
lines changed

3 files changed

+66
-4
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
- "8.2"
2626
- "8.3"
2727
- "8.4"
28+
- "8.5"
2829
operating-system:
2930
- "ubuntu-latest"
3031
- "windows-latest"
@@ -69,6 +70,7 @@ jobs:
6970
- "8.2"
7071
- "8.3"
7172
- "8.4"
73+
- "8.5"
7274
operating-system:
7375
- "ubuntu-latest"
7476

@@ -110,6 +112,7 @@ jobs:
110112
- "locked"
111113
php-version:
112114
- "8.4"
115+
- "8.5"
113116
operating-system:
114117
- "ubuntu-latest"
115118

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Better Reflection - an improved code reflection API",
44
"license": "MIT",
55
"require": {
6-
"php": "~8.2.0 || ~8.3.2 || ~8.4.1",
6+
"php": "~8.2.0 || ~8.3.2 || ~8.4.1 || ~8.5.0",
77
"ext-json": "*",
88
"jetbrains/phpstorm-stubs": "2024.3",
99
"nikic/php-parser": "^5.6.0"

test/unit/SourceLocator/SourceStubber/PhpStormStubsSourceStubberTest.php

Lines changed: 62 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Roave\BetterReflectionTest\SourceLocator\SourceStubber;
66

7+
use Closure;
78
use CompileError;
89
use DateInterval;
910
use 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

Comments
 (0)