1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Make travis green again (#2518)

* Bumped phpspec/prophecy version to prevent 7.4 deprecations

* Fix DOMDocument::$config type

This property was documented as containing DOMConfiguration object, but
in fact always returned `null` (see [php source](ee80567a83/ext/dom/document.c (L542))).

DOMConfiguration class is removed in PHP 8.

* Dropped unused use

* Allow to set PHP 8.0 as current version

* Fix CallMap issues for PHP 8.0

- Use both major and minor version to load deltas
- Don't load non-existent deltas
- Stop at lowest possible delta
This commit is contained in:
Bruce Weirdan 2019-12-28 02:06:09 +02:00 committed by Matthew Brown
parent bdb2f3c2be
commit 4110ec351b
5 changed files with 20 additions and 7 deletions

View File

@ -49,6 +49,7 @@
"prefer-stable": true,
"require-dev": {
"phpunit/phpunit": "^7.5 || ^8.0",
"phpspec/prophecy": ">=1.9.0",
"squizlabs/php_codesniffer": "^3.5",
"bamarni/composer-bin-plugin": "^1.2",
"psalm/plugin-phpunit": "^0.6",

View File

@ -1153,7 +1153,7 @@ class ProjectAnalyzer
*/
public function setPhpVersion(string $version)
{
if (!preg_match('/^(5\.[456]|7\.[01234])(\..*)?$/', $version)) {
if (!preg_match('/^(5\.[456]|7\.[01234]|8\.[0])(\..*)?$/', $version)) {
throw new \UnexpectedValueException('Expecting a version number in the format x.y');
}

View File

@ -4,6 +4,7 @@ namespace Psalm\Internal\Codebase;
use function array_shift;
use function assert;
use function count;
use function file_exists;
use PhpParser;
use Psalm\Codebase;
use Psalm\Internal\Analyzer\ProjectAnalyzer;
@ -13,6 +14,7 @@ use Psalm\Type;
use Psalm\Type\Atomic\TCallable;
use function strtolower;
use function substr;
use function version_compare;
/**
* @internal
@ -23,6 +25,7 @@ class CallMap
{
const PHP_MAJOR_VERSION = 7;
const PHP_MINOR_VERSION = 3;
const LOWEST_AVAILABLE_DELTA = 71;
/**
* @var ?int
@ -321,6 +324,12 @@ class CallMap
$analyzer_major_version = $codebase->php_major_version;
$analyzer_minor_version = $codebase->php_minor_version;
$analyzer_version = $analyzer_major_version . '.' . $analyzer_minor_version;
$current_version = self::PHP_MAJOR_VERSION . '.' . self::PHP_MINOR_VERSION;
$analyzer_version_int = (int) ($analyzer_major_version . $analyzer_minor_version);
$current_version_int = (int) (self::PHP_MAJOR_VERSION . self::PHP_MINOR_VERSION);
if (self::$call_map !== null
&& $analyzer_major_version === self::$loaded_php_major_version
&& $analyzer_minor_version === self::$loaded_php_minor_version
@ -338,8 +347,13 @@ class CallMap
self::$call_map[$cased_key] = $value;
}
if ($analyzer_minor_version < self::PHP_MINOR_VERSION) {
for ($i = self::PHP_MINOR_VERSION; $i > $analyzer_minor_version; --$i) {
if (version_compare($analyzer_version, $current_version, '<')) {
// the following assumes both minor and major versions a single digits
for ($i = $current_version_int; $i > $analyzer_version_int && $i >= self::LOWEST_AVAILABLE_DELTA; --$i) {
$delta_file = __DIR__ . '/../CallMap_' . $i . '_delta.php';
if (!file_exists($delta_file)) {
continue;
}
/**
* @var array{
* old: array<string, array<int|string, string>>,
@ -347,7 +361,7 @@ class CallMap
* }
* @psalm-suppress UnresolvableInclude
*/
$diff_call_map = require(__DIR__ . '/../CallMap_7' . $i . '_delta.php');
$diff_call_map = require($delta_file);
foreach ($diff_call_map['new'] as $key => $_) {
$cased_key = strtolower($key);

View File

@ -181,7 +181,7 @@ return [
],
'domdocument' => [
'actualEncoding' => 'string',
'config' => 'DOMConfiguration',
'config' => 'null',
'doctype' => 'DOMDocumentType',
'documentElement' => 'DOMElement',
'documentURI' => 'string',

View File

@ -1,8 +1,6 @@
<?php
namespace Psalm\Tests\FileManipulation;
use const PHP_VERSION;
class UnnecessaryVarAnnotationManipulationTest extends FileManipulationTest
{
/**