Skip to content

Commit

Permalink
Add support for PHP 8.4
Browse files Browse the repository at this point in the history
Calling new ReflectionMethod with a single argument is deprecated
  • Loading branch information
GromNaN committed Oct 3, 2024
1 parent d747f65 commit 06ae404
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 49 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
count: ${{ fromJson(needs.chunk-matrix.outputs.count) }}
chunk: ${{ fromJson(needs.chunk-matrix.outputs.chunks) }}

Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0",
"php": "^7.4 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0",
"ext-SimpleXML": "*",
"ext-ctype": "*",
"ext-dom": "*",
Expand All @@ -30,7 +30,7 @@
"composer/xdebug-handler": "^2.0 || ^3.0",
"dnoegel/php-xdg-base-dir": "^0.1.1",
"felixfbecker/advanced-json-rpc": "^3.1",
"felixfbecker/language-server-protocol": "^1.5.2",
"felixfbecker/language-server-protocol": "^1.5.3",
"fidry/cpu-core-counter": "^0.4.1 || ^0.5.1 || ^1.0.0",
"netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0",
"nikic/php-parser": "^4.17",
Expand All @@ -47,7 +47,7 @@
},
"require-dev": {
"ext-curl": "*",
"amphp/phpunit-util": "^2.0",
"amphp/phpunit-util": "^2.0.1",
"bamarni/composer-bin-plugin": "^1.4",
"brianium/paratest": "^6.9",
"mockery/mockery": "^1.5",
Expand Down
98 changes: 52 additions & 46 deletions tests/Internal/Codebase/InternalCallMapHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
use const PHP_MAJOR_VERSION;
use const PHP_MINOR_VERSION;
use const PHP_VERSION;
use const PHP_VERSION_ID;

/** @group callmap */
class InternalCallMapHandlerTest extends TestCase
Expand Down Expand Up @@ -78,8 +79,8 @@ class InternalCallMapHandlerTest extends TestCase
'array_multisort',
'datefmt_create' => ['8.0'],
'fiber::start',
'get_class' => ['8.3'],
'get_parent_class' => ['8.3'],
'get_class' => ['8.3', '8.4'],
'get_parent_class' => ['8.3', '8.4'],
'imagefilledpolygon',
'imagegd',
'imagegd2',
Expand All @@ -97,7 +98,7 @@ class InternalCallMapHandlerTest extends TestCase
'mailparse_msg_get_structure',
'mailparse_msg_parse',
'mailparse_stream_encode',
'mb_check_encoding' => ['8.1', '8.2', '8.3'],
'mb_check_encoding' => ['8.1', '8.2', '8.3', '8.4'],
'memcached::cas', // memcached 3.2.0 has incorrect reflection
'memcached::casbykey', // memcached 3.2.0 has incorrect reflection
'oauth::fetch',
Expand Down Expand Up @@ -175,60 +176,60 @@ class InternalCallMapHandlerTest extends TestCase
* @var array<int|string, string|list<string>>
*/
private static array $ignoredReturnTypeOnlyFunctions = [
'appenditerator::getinneriterator' => ['8.1', '8.2', '8.3'],
'appenditerator::getiteratorindex' => ['8.1', '8.2', '8.3'],
'cachingiterator::getinneriterator' => ['8.1', '8.2', '8.3'],
'callbackfilteriterator::getinneriterator' => ['8.1', '8.2', '8.3'],
'appenditerator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'appenditerator::getiteratorindex' => ['8.1', '8.2', '8.3', '8.4'],
'cachingiterator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'callbackfilteriterator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'curl_multi_getcontent',
'datetime::add' => ['8.1', '8.2', '8.3'], // DateTime does not contain static
'datetime::modify' => ['8.1', '8.2', '8.3'], // DateTime does not contain static
'datetime::createfromformat' => ['8.1', '8.2', '8.3'], // DateTime does not contain static
'datetime::add' => ['8.1', '8.2', '8.3', '8.4'], // DateTime does not contain static
'datetime::modify' => ['8.1', '8.2', '8.3', '8.4'], // DateTime does not contain static
'datetime::createfromformat' => ['8.1', '8.2', '8.3', '8.4'], // DateTime does not contain static
'datetime::createfromimmutable' => ['8.1'],
'datetime::createfrominterface',
'datetime::setdate' => ['8.1', '8.2', '8.3'], // DateTime does not contain static
'datetime::setisodate' => ['8.1', '8.2', '8.3'], // DateTime does not contain static
'datetime::settime' => ['8.1', '8.2', '8.3'], // DateTime does not contain static
'datetime::settimestamp' => ['8.1', '8.2', '8.3'], // DateTime does not contain static
'datetime::settimezone' => ['8.1', '8.2', '8.3'], // DateTime does not contain static
'datetime::sub' => ['8.1', '8.2', '8.3'], // DateTime does not contain static
'datetime::setdate' => ['8.1', '8.2', '8.3', '8.4'], // DateTime does not contain static
'datetime::setisodate' => ['8.1', '8.2', '8.3', '8.4'], // DateTime does not contain static
'datetime::settime' => ['8.1', '8.2', '8.3', '8.4'], // DateTime does not contain static
'datetime::settimestamp' => ['8.1', '8.2', '8.3', '8.4'], // DateTime does not contain static
'datetime::settimezone' => ['8.1', '8.2', '8.3', '8.4'], // DateTime does not contain static
'datetime::sub' => ['8.1', '8.2', '8.3', '8.4'], // DateTime does not contain static
'datetimeimmutable::createfrominterface',
'fiber::getcurrent',
'filteriterator::getinneriterator' => ['8.1', '8.2', '8.3'],
'filteriterator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'get_cfg_var', // Ignore array return type
'infiniteiterator::getinneriterator' => ['8.1', '8.2', '8.3'],
'iteratoriterator::getinneriterator' => ['8.1', '8.2', '8.3'],
'limititerator::getinneriterator' => ['8.1', '8.2', '8.3'],
'locale::getallvariants' => ['8.1', '8.2', '8.3'],
'locale::getkeywords' => ['8.1', '8.2', '8.3'],
'locale::getprimarylanguage' => ['8.1', '8.2', '8.3'],
'locale::getregion' => ['8.1', '8.2', '8.3'],
'locale::getscript' => ['8.1', '8.2', '8.3'],
'locale::parselocale' => ['8.1', '8.2', '8.3'],
'messageformatter::create' => ['8.1', '8.2', '8.3'],
'multipleiterator::current' => ['8.1', '8.2', '8.3'],
'mysqli::get_charset' => ['8.1', '8.2', '8.3'],
'mysqli_stmt::get_warnings' => ['8.1', '8.2', '8.3'],
'infiniteiterator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'iteratoriterator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'limititerator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'locale::getallvariants' => ['8.1', '8.2', '8.3', '8.4'],
'locale::getkeywords' => ['8.1', '8.2', '8.3', '8.4'],
'locale::getprimarylanguage' => ['8.1', '8.2', '8.3', '8.4'],
'locale::getregion' => ['8.1', '8.2', '8.3', '8.4'],
'locale::getscript' => ['8.1', '8.2', '8.3', '8.4'],
'locale::parselocale' => ['8.1', '8.2', '8.3', '8.4'],
'messageformatter::create' => ['8.1', '8.2', '8.3', '8.4'],
'multipleiterator::current' => ['8.1', '8.2', '8.3', '8.4'],
'mysqli::get_charset' => ['8.1', '8.2', '8.3', '8.4'],
'mysqli_stmt::get_warnings' => ['8.1', '8.2', '8.3', '8.4'],
'mysqli_stmt_get_warnings',
'mysqli_stmt_insert_id',
'norewinditerator::getinneriterator' => ['8.1', '8.2', '8.3'],
'norewinditerator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'passthru',
'recursivecachingiterator::getinneriterator' => ['8.1', '8.2', '8.3'],
'recursivecallbackfilteriterator::getinneriterator' => ['8.1', '8.2', '8.3'],
'recursivefilteriterator::getinneriterator' => ['8.1', '8.2', '8.3'],
'recursiveregexiterator::getinneriterator' => ['8.1', '8.2', '8.3'],
'recursivecachingiterator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'recursivecallbackfilteriterator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'recursivefilteriterator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'recursiveregexiterator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'reflectionclass::getstaticproperties' => ['8.1', '8.2'],
'reflectionclass::newinstanceargs' => ['8.1', '8.2', '8.3'],
'reflectionfunction::getclosurescopeclass' => ['8.1', '8.2', '8.3'],
'reflectionfunction::getclosurethis' => ['8.1', '8.2', '8.3'],
'reflectionmethod::getclosurescopeclass' => ['8.1', '8.2', '8.3'],
'reflectionmethod::getclosurethis' => ['8.1', '8.2', '8.3'],
'reflectionclass::newinstanceargs' => ['8.1', '8.2', '8.3', '8.4'],
'reflectionfunction::getclosurescopeclass' => ['8.1', '8.2', '8.3', '8.4'],
'reflectionfunction::getclosurethis' => ['8.1', '8.2', '8.3', '8.4'],
'reflectionmethod::getclosurescopeclass' => ['8.1', '8.2', '8.3', '8.4'],
'reflectionmethod::getclosurethis' => ['8.1', '8.2', '8.3', '8.4'],
'reflectionobject::getstaticproperties' => ['8.1', '8.2'],
'reflectionobject::newinstanceargs' => ['8.1', '8.2', '8.3'],
'regexiterator::getinneriterator' => ['8.1', '8.2', '8.3'],
'reflectionobject::newinstanceargs' => ['8.1', '8.2', '8.3', '8.4'],
'regexiterator::getinneriterator' => ['8.1', '8.2', '8.3', '8.4'],
'register_shutdown_function' => ['8.0', '8.1'],
'splfileobject::fscanf' => ['8.1', '8.2', '8.3'],
'spltempfileobject::fscanf' => ['8.1', '8.2', '8.3'],
'xsltprocessor::transformtoxml' => ['8.1', '8.2', '8.3'],
'splfileobject::fscanf' => ['8.1', '8.2', '8.3', '8.4'],
'spltempfileobject::fscanf' => ['8.1', '8.2', '8.3', '8.4'],
'xsltprocessor::transformtoxml' => ['8.1', '8.2', '8.3', '8.4'],
];

/**
Expand Down Expand Up @@ -519,7 +520,12 @@ private function getReflectionFunction(string $functionName): ?ReflectionFunctio
{
try {
if (strpos($functionName, '::') !== false) {
return new ReflectionMethod($functionName);
if (PHP_VERSION_ID < 8_03_00) {
[$className, , $methodName] = explode(':', $functionName, 3);

Check failure on line 524 in tests/Internal/Codebase/InternalCallMapHandlerTest.php

View workflow job for this annotation

GitHub Actions / build

PossiblyUndefinedArrayOffset

tests/Internal/Codebase/InternalCallMapHandlerTest.php:524:36: PossiblyUndefinedArrayOffset: Possibly undefined array key (see https://psalm.dev/167)
return new ReflectionMethod($className, $methodName);

Check failure on line 525 in tests/Internal/Codebase/InternalCallMapHandlerTest.php

View workflow job for this annotation

GitHub Actions / build

ArgumentTypeCoercion

tests/Internal/Codebase/InternalCallMapHandlerTest.php:525:49: ArgumentTypeCoercion: Argument 1 of ReflectionMethod::__construct expects class-string|object, but parent type string provided (see https://psalm.dev/193)
}

return ReflectionMethod::createFromMethodName($functionName);

Check failure on line 528 in tests/Internal/Codebase/InternalCallMapHandlerTest.php

View workflow job for this annotation

GitHub Actions / build

UndefinedMethod

tests/Internal/Codebase/InternalCallMapHandlerTest.php:528:24: UndefinedMethod: Method ReflectionMethod::createfrommethodname does not exist (see https://psalm.dev/022)

Check failure on line 528 in tests/Internal/Codebase/InternalCallMapHandlerTest.php

View workflow job for this annotation

GitHub Actions / build

MixedReturnStatement

tests/Internal/Codebase/InternalCallMapHandlerTest.php:528:24: MixedReturnStatement: Could not infer a return type (see https://psalm.dev/138)
}

/** @var callable-string $functionName */
Expand Down

0 comments on commit 06ae404

Please sign in to comment.