[phpstorm-stubs] add test for forbidden type hints to check agains current PHP version

This commit is contained in:
Ivan Fedorov 2022-11-05 23:05:36 +01:00 committed by Ivan Fedorov
parent e367ade2b0
commit b0e53e92d7
6 changed files with 12 additions and 7 deletions

View File

@ -18,17 +18,17 @@ jobs:
PHP_VERSION: '7.0'
- name: Composer Install
run: docker-compose -f docker-compose.yml run -e PHP_VERSION='7.0' test_runner composer update
run: docker-compose -f docker-compose.yml run -e PHP_VERSION=7.0 test_runner composer update
env:
PHP_VERSION: '7.0'
- name: Dump Reflection To File
run: docker-compose -f docker-compose.yml run -e PHP_VERSION='7.0' php_under_test /usr/local/bin/php tests/Tools/dump-reflection-to-file.php ReflectionData.json
run: docker-compose -f docker-compose.yml run -e PHP_VERSION=7.0 php_under_test /usr/local/bin/php tests/Tools/dump-reflection-to-file.php ReflectionData.json
env:
PHP_VERSION: '7.0'
- name: Run Tests
run: docker-compose -f docker-compose.yml run -e PHP_VERSION='7.0' test_runner vendor/bin/phpunit --testsuite PHP_7.0
run: docker-compose -f docker-compose.yml run -e PHP_VERSION=7.0 test_runner vendor/bin/phpunit --testsuite PHP_7.0
env:
PHP_VERSION: '7.0'
additional:

View File

@ -1291,7 +1291,7 @@ class PDO
* with fields message and pid, otherwise <b>FALSE</b>.
* @since 5.6
*/
public function pgsqlGetNotify(int $fetchMode = PDO::FETCH_LAZY, int $timeoutMilliseconds = 0): array|false {}
public function pgsqlGetNotify(int $fetchMode = PDO::FETCH_LAZY, int $timeoutMilliseconds = 0) {}
/**
* (PHP 5 >= 5.6.0, PHP 7, PHP 8)<br/>

View File

@ -7461,7 +7461,7 @@ class UConverter
* @since 5.5
*/
#[TentativeType]
public static function transcode($str, $toEncoding, $fromEncoding, ?array $options = []): string|false {}
public static function transcode($str, $toEncoding, $fromEncoding, $options = []): string|false {}
/**
* (PHP 5 >=5.5.0)<br/>

View File

@ -6,6 +6,7 @@
<file>tests/BaseConstantsTest.php</file>
<file>tests/BaseFunctionsTest.php</file>
<file>tests/StubsPhpDocTest.php</file>
<file>tests/StubsForbiddenTypeHintsTest.php</file>
</testsuite>
<testsuite name="PhpDoc">
<file>tests/StubsPhpDocTest.php</file>

View File

@ -97,7 +97,10 @@ class StubMethodsProvider
private static function getFilterFunctionForLanguageLevel(float $languageVersion): callable
{
return fn (PHPClass|PHPInterface $class, PHPMethod $method, ?float $firstSinceVersion) => !$method->isFinal &&
!$class->isFinal && $firstSinceVersion !== null && $firstSinceVersion < $languageVersion && !$method->isReturnTypeTentative;
!$class->isFinal && $firstSinceVersion !== null &&
$firstSinceVersion < $languageVersion &&
!$method->isReturnTypeTentative &&
(float)getenv('PHP_VERSION') < $languageVersion;
}
/**

View File

@ -95,6 +95,7 @@ class StubsParametersProvider
private static function getFilterFunctionForLanguageLevel(float $languageVersion): callable
{
return fn (PHPClass|PHPInterface $class, PHPMethod $method, ?float $firstSinceVersion) => !$method->isFinal &&
!$class->isFinal && $firstSinceVersion !== null && $firstSinceVersion < $languageVersion;
!$class->isFinal && $firstSinceVersion !== null && $firstSinceVersion < $languageVersion
&& (float)getenv('PHP_VERSION') < $languageVersion;
}
}