Skip to content

Commit

Permalink
Merge pull request #1469 from kukulich/stubs
Browse files Browse the repository at this point in the history
Update dependency `jetbrains/phpstorm-stubs` to `2024.3`
  • Loading branch information
Ocramius authored Dec 17, 2024
2 parents 0f82edc + 7a944f6 commit ab1721c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 68 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"require": {
"php": "~8.2.0 || ~8.3.2 || ~8.4.1",
"ext-json": "*",
"jetbrains/phpstorm-stubs": "2024.2",
"jetbrains/phpstorm-stubs": "2024.3",
"nikic/php-parser": "^5.3.1"
},
"authors": [
Expand Down
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
use ReflectionParameter as CoreReflectionParameter;
use ReflectionProperty as CoreReflectionProperty;
use Roave\BetterReflection\Reflection\ReflectionClass;
use Roave\BetterReflection\Reflection\ReflectionClassConstant;
use Roave\BetterReflection\Reflection\ReflectionConstant;
use Roave\BetterReflection\Reflection\ReflectionFunction;
use Roave\BetterReflection\Reflection\ReflectionMethod;
Expand Down Expand Up @@ -131,20 +130,6 @@ static function (string $className): bool {
return false;
}

// Missing in JetBrains/phpstorm-stubs
if (
PHP_VERSION_ID >= 80400
&& in_array($className, [
'Deprecated',
'Generator',
'RequestParseBodyException',
'RoundingMode',
'StreamBucket',
], true)
) {
return false;
}

// Check only always enabled extensions
return in_array($reflection->getExtensionName(), self::EXTENSIONS, true);
},
Expand All @@ -167,11 +152,6 @@ public function testInternalClasses(string $className): void
self::assertSame($internalReflection->isInterface(), $class->isInterface());
self::assertSame($internalReflection->isTrait(), $class->isTrait());

if (PHP_VERSION_ID >= 80400 && $className === 'SplObjectStorage') {
// Needs fixes in JetBrains/phpstorm-stubs
return;
}

self::assertSameClassAttributes($internalReflection, $class);
}

Expand Down Expand Up @@ -208,10 +188,18 @@ private function assertSameClassAttributes(CoreReflectionClass $original, Reflec
$this->assertSameMethodAttributes($method, $stubbed->getMethod($method->getName()));
}

self::assertEquals(
$original->getConstants(),
array_map(static fn (ReflectionClassConstant $classConstant) => $classConstant->getValue(), $stubbed->getConstants()),
);
// We don't check getConstants() method because native reflection returns constants and enum cases together

foreach ($original->getReflectionConstants() as $originalConstant) {
if ($originalConstant->isEnumCase()) {
continue;
}

$stubbedConstant = $stubbed->getConstant($originalConstant->getName());

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

private function assertSameMethodAttributes(CoreReflectionMethod $original, ReflectionMethod $stubbed): void
Expand Down Expand Up @@ -303,25 +291,6 @@ public static function internalFunctionsProvider(): array
static function (string $functionName): bool {
$reflection = new CoreReflectionFunction($functionName);

// Missing in JetBrains/phpstorm-stubs
if (
PHP_VERSION_ID >= 80400
&& in_array($functionName, [
'array_all',
'array_any',
'array_find',
'array_find_key',
'die',
'exit',
'fpow',
'http_clear_last_response_headers',
'http_get_last_response_headers',
'request_parse_body',
], true)
) {
return false;
}

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

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

$provider[] = [$constantName, $constantValue, $extensionName];
}
}
Expand Down Expand Up @@ -1162,8 +1120,7 @@ public static function dataPropertyIsDeprecatedInPhpVersion(): array
return [
['DateInterval', 'y', 70000, false],
['DateInterval', 'y', 80000, false],
['DOMDocument', 'actualEncoding', 70000, true],
['DOMDocument', 'actualEncoding', 80000, true],
['DOMDocument', 'actualEncoding', 80400, true],
];
}

Expand Down

0 comments on commit ab1721c

Please sign in to comment.