Skip to content
Snippets Groups Projects

Add code to extract applied rectors from rector_out so we can determine minimum core version

3 files
+ 176
1
Compare changes
  • Side-by-side
  • Inline
Files
3
@@ -6,6 +6,43 @@ use Composer\Semver\Semver;
abstract class UpdaterBase extends ResultProcessorBase {
/**
* List all applied rectors for a project.
*
* @param string $project_version
*
* @return array
* @throws \Exception
*/
public static function getAppliedRectors(string $project_version): array {
$machine_name = explode('.', $project_version)[0];
$rector_file = ResultProcessorBase::getResultsDir() . "/$machine_name/$project_version.rector_out";
if (!file_exists($rector_file)) {
return [];
}
$applied_rectors = [];
$file = new \SplFileObject($rector_file);
// Loop until we reach the end of the file.
while (!$file->eof()) {
$line = $file->fgets();
if (str_starts_with($line, ' * ')) {
if (preg_match('/^ \* ([^\s\(]+)/', $line, $matches)) {
$applied_rectors[] = $matches[1];
}
}
}
// Unset the file to call __destruct(), closing the file handle.
$file = null;
asort($applied_rectors);
return array_values(array_unique($applied_rectors));
}
/**
* Gets the error and warning messages for an upgrade_status xml file.
*
@@ -62,7 +99,7 @@ abstract class UpdaterBase extends ResultProcessorBase {
/**
* Generates new composer version constraint based on current requirement and new minimum core minor.
*
*
* @param int|null $minimum_core_minor
* New minimum core minor based on Upgrade Status errors reported (and fixed).
* @param $current_requirement
Loading