Skip to content

Run tests and static analysis on PHP 8.5 #1515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: 6.60.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
operating-system:
- "ubuntu-latest"
- "windows-latest"
Expand Down Expand Up @@ -69,6 +70,7 @@ jobs:
- "8.2"
- "8.3"
- "8.4"
- "8.5"
operating-system:
- "ubuntu-latest"

Expand Down Expand Up @@ -110,6 +112,7 @@ jobs:
- "locked"
php-version:
- "8.4"
- "8.5"
operating-system:
- "ubuntu-latest"

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Better Reflection - an improved code reflection API",
"license": "MIT",
"require": {
"php": "~8.2.0 || ~8.3.2 || ~8.4.1",
"php": "~8.2.0 || ~8.3.2 || ~8.4.1 || ~8.5.0",
"ext-json": "*",
"jetbrains/phpstorm-stubs": "2024.3",
"nikic/php-parser": "^5.6.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Roave\BetterReflectionTest\SourceLocator\SourceStubber;

use Closure;
use CompileError;
use DateInterval;
use DatePeriod;
Expand Down Expand Up @@ -133,6 +134,16 @@ static function (string $className): bool {
return false;
}

// Missing in JetBrains/phpstorm-stubs
/** @var list<class-string> $missingClasses */
$missingClasses = ['NoDiscard'];
if (
PHP_VERSION_ID >= 80500
&& in_array($className, $missingClasses, true)
) {
return false;
}

// Check only always enabled extensions
return in_array($reflection->getExtensionName(), self::EXTENSIONS, true);
},
Expand Down Expand Up @@ -188,8 +199,19 @@ private function assertSameClassAttributes(CoreReflectionClass $original, Reflec
$this->assertSameInterfaces($original, $stubbed);

foreach ($original->getMethods() as $method) {
$methodName = $original->getName() . '#' . $method->getName();

// Needs fixes in JetBrains/phpstorm-stubs
if (
in_array($methodName, [
'Closure#getCurrent',
], true)
) {
continue;
}

$stubbedMethod = $stubbed->getMethod($method->getName());
self::assertNotNull($stubbedMethod);
self::assertNotNull($stubbedMethod, $methodName);

$this->assertSameMethodAttributes($method, $stubbedMethod);
}
Expand All @@ -204,10 +226,21 @@ private function assertSameClassAttributes(CoreReflectionClass $original, Reflec
$originalConstantName = $originalConstant->getName();
assert($originalConstantName !== '');

$constantName = $original->getName() . '::' . $originalConstant->getName();

// Needs fixes in JetBrains/phpstorm-stubs
if (
in_array($constantName, [
'Attribute::TARGET_CONSTANT',
], true)
) {
continue;
}

$stubbedConstant = $stubbed->getConstant($originalConstantName);

self::assertNotNull($stubbedConstant);
self::assertSame($originalConstant->getValue(), $stubbedConstant->getValue());
self::assertNotNull($stubbedConstant, $constantName);
self::assertSame($originalConstant->getValue(), $stubbedConstant->getValue(), $constantName);
}
}

Expand Down Expand Up @@ -301,6 +334,20 @@ public static function internalFunctionsProvider(): array
static function (string $functionName): bool {
$reflection = new CoreReflectionFunction($functionName);

// Missing in JetBrains/phpstorm-stubs
if (
PHP_VERSION_ID >= 80500
&& in_array($functionName, [
'array_first',
'array_last',
'clone',
'get_error_handler',
'get_exception_handler',
], true)
) {
return false;
}

// Check only always enabled extensions
return in_array($reflection->getExtensionName(), self::EXTENSIONS, true);
},
Expand Down Expand Up @@ -361,6 +408,18 @@ public static function internalConstantsProvider(): array
}

foreach ($extensionConstants as $constantName => $constantValue) {
// Missing in JetBrains/phpstorm-stubs
if (
PHP_VERSION_ID >= 80500
&& in_array($constantName, [
'IMAGETYPE_SVG',
'IMAGETYPE_HEIF',
'PHP_BUILD_DATE',
], true)
) {
continue;
}

$provider[] = [$constantName, $constantValue, $extensionName];
}
}
Expand Down
Loading