Commit 8e717c8e authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

Issue #3224409 by Gábor Hojtsy, mstrelan: Test PHP 8 compatibility of info...

Issue #3224409 by Gábor Hojtsy, mstrelan: Test PHP 8 compatibility of info files and composer require statements on Drupal 9
parent c83b85ac
......@@ -406,6 +406,10 @@ final class DeprecationAnalyzer {
$result['data']['totals']['file_errors']++;
$result['data']['totals']['upgrade_status_split']['declared_ready'] = FALSE;
}
// No need to check info files for PHP 8 compatibility information because
// they can only define minimal PHP versions not maximum or excluded PHP
// versions.
}
// Manually add on composer.json file incompatibility to results.
......@@ -429,6 +433,15 @@ final class DeprecationAnalyzer {
$result['data']['totals']['file_errors']++;
$result['data']['totals']['upgrade_status_split']['declared_ready'] = FALSE;
}
elseif ((projectCollector::getDrupalCoreMajorVersion() > 8) && !empty($composer_json->require->{'php'} && !projectCollector::isCompatibleWithPHP8($composer_json->require->{'php'}))) {
$result['data']['files'][$extension->getPath() . '/composer.json']['messages'][] = [
'message' => "The PHP requirement is not compatible with PHP 8. Once the codebase is actually compatible, either remove this limitation or update it to be compatible.",
'line' => 0,
];
$result['data']['totals']['errors']++;
$result['data']['totals']['file_errors']++;
$result['data']['totals']['upgrade_status_split']['declared_ready'] = FALSE;
}
}
// Assume next step is to relax (there were no errors found).
......
......@@ -512,6 +512,24 @@ class ProjectCollector {
return $parsed_constraints->matches($provider);
}
/**
* Checks constraint compatibility with PHP 8.
*
* A customized version of Semver::satisfies(), since that only works for
* a == condition.
*
* @paran string $constraints
* Composer compatible constraints from a PHP version requirement.
*
* @return bool
*/
public static function isCompatibleWithPHP8(string $constraints) {
$version_parser = new VersionParser();
$provider = new Constraint('>=', $version_parser->normalize('8.0.0'));
$parsed_constraints = $version_parser->parseConstraints($constraints);
return $parsed_constraints->matches($provider);
}
/**
* Return the oldest supported minor version for the current core major.
*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment