mirror of
https://github.com/danog/psalm.git
synced 2024-11-30 04:39:00 +01:00
Merge pull request #7291 from weirdan/bump-php-version
This commit is contained in:
commit
c8440796ce
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -9,7 +9,7 @@ jobs:
|
||||
- name: Set up PHP
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '7.1'
|
||||
php-version: '7.4'
|
||||
tools: composer:v2
|
||||
coverage: none
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.1|^8",
|
||||
"php": "^7.4 || ~8.0.0 || ~8.1.0",
|
||||
"ext-SimpleXML": "*",
|
||||
"ext-ctype": "*",
|
||||
"ext-dom": "*",
|
||||
@ -28,12 +28,12 @@
|
||||
"composer/semver": "^1.4 || ^2.0 || ^3.0",
|
||||
"composer/xdebug-handler": "^1.1 || ^2.0 || ^3.0",
|
||||
"dnoegel/php-xdg-base-dir": "^0.1.1",
|
||||
"felixfbecker/advanced-json-rpc": "^3.0.3",
|
||||
"felixfbecker/advanced-json-rpc": "^3.1",
|
||||
"felixfbecker/language-server-protocol": "^1.5",
|
||||
"netresearch/jsonmapper": "^1.0 || ^2.0 || ^3.0 || ^4.0",
|
||||
"nikic/php-parser": "^4.13",
|
||||
"openlss/lib-array2xml": "^1.0",
|
||||
"sebastian/diff": "^3.0 || ^4.0",
|
||||
"sebastian/diff": "^4.0",
|
||||
"symfony/console": "^3.4.17 || ^4.1.6 || ^5.0 || ^6.0",
|
||||
"webmozart/path-util": "^2.3"
|
||||
},
|
||||
@ -42,16 +42,16 @@
|
||||
},
|
||||
"require-dev": {
|
||||
"ext-curl": "*",
|
||||
"bamarni/composer-bin-plugin": "^1.2",
|
||||
"bamarni/composer-bin-plugin": "^1.4",
|
||||
"brianium/paratest": "^4.0||^6.0",
|
||||
"php-parallel-lint/php-parallel-lint": "^1.2",
|
||||
"phpdocumentor/reflection-docblock": "^5",
|
||||
"phpmyadmin/sql-parser": "5.1.0||dev-master",
|
||||
"phpspec/prophecy": ">=1.9.0",
|
||||
"phpspec/prophecy": ">=1.10.2",
|
||||
"phpunit/phpunit": "^9.0",
|
||||
"psalm/plugin-phpunit": "^0.16.1",
|
||||
"slevomat/coding-standard": "^7.0",
|
||||
"squizlabs/php_codesniffer": "^3.5",
|
||||
"squizlabs/php_codesniffer": "^3.6",
|
||||
"symfony/process": "^4.3 || ^5.0 || ^6.0",
|
||||
"weirdan/prophecy-shim": "^1.0 || ^2.0"
|
||||
},
|
||||
@ -80,10 +80,7 @@
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Psalm\\": "src/Psalm/"
|
||||
},
|
||||
"files": [
|
||||
"src/spl_object_id.php"
|
||||
]
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
|
@ -34,7 +34,6 @@
|
||||
<file name="src/Psalm/Internal/PhpTraverser/CustomTraverser.php"/>
|
||||
<file name="tests/ErrorBaselineTest.php"/>
|
||||
<file name="vendor/symfony/console/Command/Command.php"/>
|
||||
<file name="src/spl_object_id.php"/>
|
||||
<directory name="tests/fixtures"/>
|
||||
<file name="vendor/felixfbecker/advanced-json-rpc/lib/Dispatcher.php" />
|
||||
<directory name="vendor/netresearch/jsonmapper" />
|
||||
|
@ -1,54 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* PHP Polyfill for spl_object_id() for PHP <= 7.1
|
||||
* This file will be included even in releases which will analyze PHP 7.2,
|
||||
* there aren't any major compatibilities preventing analysis of PHP 7.2 from running in PHP 7.1.
|
||||
*/
|
||||
if (!function_exists('spl_object_id')) {
|
||||
if (function_exists('runkit_object_id') &&
|
||||
!(new ReflectionFunction('runkit_object_id'))->isUserDefined()) {
|
||||
/**
|
||||
* See https://github.com/runkit7/runkit_object_id for a faster native version for php <= 7.1
|
||||
*
|
||||
* @param object $object
|
||||
* @return int The object id
|
||||
*/
|
||||
function spl_object_id($object): int
|
||||
{
|
||||
return runkit_object_id($object);
|
||||
}
|
||||
} elseif (PHP_INT_SIZE === 8) {
|
||||
/**
|
||||
* See https://github.com/runkit7/runkit_object_id for a faster native version for php <= 7.1
|
||||
*
|
||||
* @param object $object
|
||||
* @return int (The object id, XORed with a random number)
|
||||
*/
|
||||
function spl_object_id($object): int
|
||||
{
|
||||
$hash = spl_object_hash($object);
|
||||
// Fit this into a php long (32-bit or 64-bit signed int).
|
||||
// The first 16 hex digits (64 bytes) vary, the last 16 don't.
|
||||
// Values are usually padded with 0s at the front.
|
||||
return intval(substr($hash, 1, 15), 16);
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
* See https://github.com/runkit7/runkit_object_id for a faster native version for php <= 7.1
|
||||
*
|
||||
* @param object $object
|
||||
* @return int (The object id, XORed with a random number)
|
||||
*/
|
||||
function spl_object_id($object): int
|
||||
{
|
||||
$hash = spl_object_hash($object);
|
||||
// Fit this into a php long (32-bit or 64-bit signed int).
|
||||
// The first 16 hex digits (64 bytes) vary, the last 16 don't.
|
||||
// Values are usually padded with 0s at the front.
|
||||
return intval(substr($hash, 9, 7), 16);
|
||||
}
|
||||
}
|
||||
}
|
@ -330,7 +330,7 @@ class ClosureTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'PHP71-mirrorCallableParams' => [
|
||||
'mirrorCallableParams' => [
|
||||
'<?php
|
||||
namespace NS;
|
||||
use Closure;
|
||||
@ -357,7 +357,7 @@ class ClosureTest extends TestCase
|
||||
[1, 2, 3]
|
||||
);',
|
||||
],
|
||||
'PHP71-closureFromCallableInvokableNamedClass' => [
|
||||
'closureFromCallableInvokableNamedClass' => [
|
||||
'<?php
|
||||
namespace NS;
|
||||
use Closure;
|
||||
@ -373,7 +373,7 @@ class ClosureTest extends TestCase
|
||||
|
||||
acceptsIntToBool(Closure::fromCallable(new NamedInvokable));',
|
||||
],
|
||||
'PHP71-closureFromCallableInvokableAnonymousClass' => [
|
||||
'closureFromCallableInvokableAnonymousClass' => [
|
||||
'<?php
|
||||
namespace NS;
|
||||
use Closure;
|
||||
@ -389,7 +389,7 @@ class ClosureTest extends TestCase
|
||||
|
||||
acceptsIntToBool(Closure::fromCallable($anonInvokable));',
|
||||
],
|
||||
'PHP71-publicCallableFromInside' => [
|
||||
'publicCallableFromInside' => [
|
||||
'<?php
|
||||
class Base {
|
||||
public function publicMethod() : void {}
|
||||
@ -401,7 +401,7 @@ class ClosureTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'PHP71-protectedCallableFromInside' => [
|
||||
'protectedCallableFromInside' => [
|
||||
'<?php
|
||||
class Base {
|
||||
protected function protectedMethod() : void {}
|
||||
@ -413,7 +413,7 @@ class ClosureTest extends TestCase
|
||||
}
|
||||
}',
|
||||
],
|
||||
'PHP71-closureFromCallableNamedFunction' => [
|
||||
'closureFromCallableNamedFunction' => [
|
||||
'<?php
|
||||
$closure = Closure::fromCallable("strlen");
|
||||
',
|
||||
@ -965,7 +965,7 @@ class ClosureTest extends TestCase
|
||||
}',
|
||||
'error_message' => 'TypeDoesNotContainType',
|
||||
],
|
||||
'PHP71-closureFromCallableInvokableNamedClassWrongArgs' => [
|
||||
'closureFromCallableInvokableNamedClassWrongArgs' => [
|
||||
'<?php
|
||||
namespace NS;
|
||||
use Closure;
|
||||
@ -999,7 +999,7 @@ class ClosureTest extends TestCase
|
||||
};',
|
||||
'error_message' => 'DuplicateParam',
|
||||
],
|
||||
'PHP71-privateCallable' => [
|
||||
'privateCallable' => [
|
||||
'<?php
|
||||
class Base {
|
||||
private function privateMethod() : void {}
|
||||
|
@ -1032,7 +1032,7 @@ class FunctionCallTest extends TestCase
|
||||
'$c' => 'int',
|
||||
],
|
||||
],
|
||||
'PHP73-hrtime' => [
|
||||
'hrtime' => [
|
||||
'<?php
|
||||
$a = hrtime(true);
|
||||
$b = hrtime();
|
||||
@ -1046,7 +1046,7 @@ class FunctionCallTest extends TestCase
|
||||
'$d' => 'array{0: int, 1: int}',
|
||||
],
|
||||
],
|
||||
'PHP73-hrtimeCanBeFloat' => [
|
||||
'hrtimeCanBeFloat' => [
|
||||
'<?php
|
||||
$a = hrtime(true);
|
||||
|
||||
@ -1239,7 +1239,7 @@ class FunctionCallTest extends TestCase
|
||||
/** @psalm-suppress TooFewArguments */
|
||||
min(0);',
|
||||
],
|
||||
'PHP73-allowIsCountableToInformType' => [
|
||||
'allowIsCountableToInformType' => [
|
||||
'<?php
|
||||
function getObject() : iterable{
|
||||
return [];
|
||||
@ -1345,7 +1345,7 @@ class FunctionCallTest extends TestCase
|
||||
'$matches===' => 'array<array-key, array{string, int}>',
|
||||
],
|
||||
],
|
||||
'PHP72-pregMatchWithFlagUnmatchedAsNull' => [
|
||||
'pregMatchWithFlagUnmatchedAsNull' => [
|
||||
'<?php
|
||||
$r = preg_match("{foo}", "foo", $matches, PREG_UNMATCHED_AS_NULL);',
|
||||
'assertions' => [
|
||||
@ -1353,7 +1353,7 @@ class FunctionCallTest extends TestCase
|
||||
'$matches===' => 'array<array-key, null|string>',
|
||||
],
|
||||
],
|
||||
'PHP72-pregMatchWithFlagOffsetCaptureAndUnmatchedAsNull' => [
|
||||
'pregMatchWithFlagOffsetCaptureAndUnmatchedAsNull' => [
|
||||
'<?php
|
||||
$r = preg_match("{foo}", "foo", $matches, PREG_OFFSET_CAPTURE | PREG_UNMATCHED_AS_NULL);',
|
||||
'assertions' => [
|
||||
@ -1399,7 +1399,7 @@ class FunctionCallTest extends TestCase
|
||||
return compact("a", "b", "c");
|
||||
}',
|
||||
],
|
||||
'PHP73-setCookiePhp73' => [
|
||||
'setCookiePhp73' => [
|
||||
'<?php
|
||||
setcookie(
|
||||
"name",
|
||||
|
@ -42,11 +42,7 @@ trait InvalidCodeAnalysisTestTrait
|
||||
string $php_version = '7.3'
|
||||
): void {
|
||||
$test_name = $this->getTestName();
|
||||
if (strpos($test_name, 'PHP71-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
|
||||
$this->markTestSkipped('Test case requires PHP 7.1.');
|
||||
}
|
||||
} elseif (strpos($test_name, 'PHP80-') !== false) {
|
||||
if (strpos($test_name, 'PHP80-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
|
||||
$this->markTestSkipped('Test case requires PHP 8.0.');
|
||||
}
|
||||
|
@ -39,19 +39,7 @@ trait ValidCodeAnalysisTestTrait
|
||||
string $php_version = '7.3'
|
||||
): void {
|
||||
$test_name = $this->getTestName();
|
||||
if (strpos($test_name, 'PHP71-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '7.1.0', '<')) {
|
||||
$this->markTestSkipped('Test case requires PHP 7.1.');
|
||||
}
|
||||
} elseif (strpos($test_name, 'PHP72-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '7.2.0', '<')) {
|
||||
$this->markTestSkipped('Test case requires PHP 7.2.');
|
||||
}
|
||||
} elseif (strpos($test_name, 'PHP73-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '7.3.0', '<')) {
|
||||
$this->markTestSkipped('Test case requires PHP 7.3.');
|
||||
}
|
||||
} elseif (strpos($test_name, 'PHP80-') !== false) {
|
||||
if (strpos($test_name, 'PHP80-') !== false) {
|
||||
if (version_compare(PHP_VERSION, '8.0.0', '<')) {
|
||||
$this->markTestSkipped('Test case requires PHP 8.0.');
|
||||
}
|
||||
|
@ -1006,7 +1006,7 @@ class ConditionalTest extends TestCase
|
||||
atan($a);
|
||||
atan($b);',
|
||||
],
|
||||
'PHP71-removeNonCallable' => [
|
||||
'removeNonCallable' => [
|
||||
'<?php
|
||||
$f = rand(0, 1) ? "strlen" : 1.1;
|
||||
if (is_callable($f)) {
|
||||
|
Loading…
Reference in New Issue
Block a user