Skip to content
Permalink
Browse files

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](https://github.com/php/php-src/blame/ee80567a83b5092b48b5ef00a16cdb73db4ef25a/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
  • Loading branch information
weirdan authored and muglug committed Dec 28, 2019
1 parent bdb2f3c commit 4110ec351bf6d8d30c8cf89a44f03daddcb5ac50
@@ -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",
@@ -1153,7 +1153,7 @@ public function refactorCodeAfterCompletion(array $to_refactor)
*/
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');
}

@@ -4,6 +4,7 @@
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\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 @@ public static function getCallMap()
$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,16 +347,21 @@ public static function getCallMap()
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>>,
* new: array<string, array<int|string, string>>
* }
* @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);
@@ -181,7 +181,7 @@
],
'domdocument' => [
'actualEncoding' => 'string',
'config' => 'DOMConfiguration',
'config' => 'null',
'doctype' => 'DOMDocumentType',
'documentElement' => 'DOMElement',
'documentURI' => 'string',
@@ -1,8 +1,6 @@
<?php
namespace Psalm\Tests\FileManipulation;

use const PHP_VERSION;

class UnnecessaryVarAnnotationManipulationTest extends FileManipulationTest
{
/**

0 comments on commit 4110ec3

Please sign in to comment.
You can’t perform that action at this time.